Re: [FFmpeg-devel] [PATCH] Populate field order returned by avs script, Trac Ticket 8757

2021-02-01 Thread emcodem

Am 2021-01-21 19:08, schrieb emco...@ffastrans.com:

On 2021-01-21 14:10, Stephen Hutchinson wrote:

Yeah, never mind about that.  I didn't notice that those are declared
AVSC_INLINE, not AVSC_API, so they don't get used through the dynamic
API loader.

The comment formatting seems to have been messed up in the second
version, though.

/* The following typically only works when assumetff (-bff) and
 * assumefieldbased is used in-script. Additional
 * logic using GetParity() could deliver more accurate results
 * but also decodes a frame which we want to avoid. */


OK, i have to admit formatting comments is in the top 10 of my
greatest weaknesses :D
Thanks for your patience and also thanks for telling me directly how
the formatting is done correctly.
New patch with formatted comment attached


Is it OK to ping this?
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH v2 1/6] avcodec/qsv_h2645: fix memory leak for plugin load

2021-02-01 Thread Anton Khirnov
Quoting Guangxin Xu (2021-01-30 04:19:27)
> Hi  Anton, Haihao
> If this is the case, we allocated the string in caller, free and reallocate
> it in callee.
> It's not a good practice.
> 1. It will make the user confused, The original qsvdec_other.c author and I
> are both confused about this.
> https://github.com/FFmpeg/FFmpeg/blob/399c1f923574234e899beef72fe249863bd1722a/libavcodec/qsvdec_other.c#L86

I see no problem with reallocating the string really, as long as av_free
is used it makes no difference. Also note, that all other
AV_OPT_TYPE_STRING options are freed in this manner, so for someone who
understand the AVOption API it is confusing to free just this one
explicitly.

> 2. The av_opt_free may change the design in the future, the new design may
> not use av_freep to free the string

That is very unlikely, as that would be a massive API break. I can think
of no reason to do it.

Also note that extra frees are harmless, other than causing confusion.

-- 
Anton Khirnov
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] lavf/utils: reset event_flags if extradata is not extracted correctly

2021-02-01 Thread Anton Khirnov
Quoting Linjie Fu (2021-01-30 07:44:09)
> On Mon, Jan 25, 2021 at 9:08 PM Anton Khirnov  wrote:
> >
> > Quoting Linjie Fu (2021-01-25 04:49:21)
> > > On Mon, Jan 25, 2021 at 12:49 AM Anton Khirnov  wrote:
> > > >
> > > > Quoting Linjie Fu (2021-01-24 16:05:56)
> > > > > Regression since 87f0c8280.
> > > > >
> > > > > If the extradata of a stream could not be extracted correctly,
> > > > > codec_info_nb_frames would remain zero, while st->event_flag would 
> > > > > still
> > > > > be marked as AVSTREAM_EVENT_FLAG_NEW_PACKETS.
> > > > >
> > > > > The two expressions could be different in this case, hence reset
> > > > > event_flags and calculate the correct score.
> > > > >
> > > > > Fix #9029.
> > > >
> > > > The ticket mentions ffplay, but ffplay does not access event_flags.
> > > >
> > >
> > > You are right, this helps ffmpeg cmdline to copy and dump:
> > > $ ffmpeg -i sample_cut.flv -c copy -y dump.mp4
> > >
> > > Before 87f0c8280 and after this patch:
> > >
> > > audio streams could be dumped and playable, while video streams still not.
> > >
> > > 87f0c8280..master:
> > > Error reporting and quits.
> > >
> > > [mp4 @ 0x7fb276809a00] dimensions not set
> > > Could not write header for output file #0 (incorrect codec parameters
> > > ?): Invalid argument
> > > Error initializing output stream 0:1 --
> > >
> > > I'd change the commit message to "#9029 related" for this, since the
> > > ffplay issue remains the same.
> >
> > I am still not convinced this is really a regression. You can still
> > process the file by explicitly mapping only the audio stream.
> Okay, I'm fine with this if it won't trigger failures for to different paths.
> 
> > This file is damaged and the video stream is not readable. IMO it is
> > better to report an error and let the user decide what to do with it
> > than silently skip the video stream while pretending everything is fine.
> VLC is able to decode/play this correctly, hence maybe need to
> investigate more into this.

VLC can also play only the audio stream. ffmpeg handles it as I
described above, which seems appropriate to me.

I suppose ffplay could be changed to be more lenient about decoding
errors, but then I see ffplay mainly as a testing/development tool
rather than a serious player.

-- 
Anton Khirnov
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avformat/mxf: Establish register of local tags

2021-02-01 Thread Tomas Härdin
fre 2021-01-29 klockan 22:06 +0100 skrev Marton Balint:
> 
> On Thu, 28 Jan 2021, Tomas Härdin wrote:
> 
> > tor 2021-01-28 klockan 14:48 +0100 skrev Tomas Härdin:
> > > tor 2021-01-28 klockan 08:56 +0100 skrev Marton Balint:
> > > > On Thu, 28 Jan 2021, Tomas Härdin wrote:
> > > > > ons 2021-01-27 klockan 23:50 +0100 skrev Marton Balint:
> > > > > > On Wed, 27 Jan 2021, Tomas Härdin wrote:
> > > > > There's not really anything to av_assert0() on in
> > > > > mxf_lookup_local_tag(). Either way, I'm thinking replacing the return
> > > > > NULL with either
> > > > > 
> > > > >av_log(NULL, AV_LOG_PANIC, "Tried to use unregistered local tag
> > > > > 0x%04x\n", tag);
> > > > >abort();
> > > > > 
> > > > > or
> > > > > 
> > > > >av_assert0(0 && "Tried to use unregistered local tag");
> > > > > 
> > > > > or maybe
> > > > > 
> > > > >av_log(NULL, AV_LOG_PANIC, "Tried to use unregistered local tag
> > > > > 0x%04x\n", tag);
> > > > >av_assert0(0);
> > > > > 
> > > > > to avoid explicitly calling abort()
> > > > 
> > > > I think we usually do av_assert0(0) in this case. I am not sure if the
> > > > error message is particularly useful, afterall who sees it should be a
> > > > programmer and file/line is printed by assert anyway, so a comment in 
> > > > the
> > > > source code before the assert makes more sense to me.
> > > 
> > > Maybe av_assert0(0 && "you forgot to add a local tag to the registry")?
> > 
> > Here's a rebased patch that does this, with a little comment also
> 
> LGTM, thanks.

Will push later today

/Tomas

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 1/5] avformat/sbgdec: Use av_sat_add64() in str_to_time()

2021-02-01 Thread Nicolas George
Michael Niedermayer (12021-01-31):
> Fixes: signed integer overflow: 727999279212000 + 4611686018427387904 
> cannot be represented in type 'long long'
> Fixes: 
> 29744/clusterfuzz-testcase-minimized-ffmpeg_dem_SBG_fuzzer-6434060249464832
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavformat/sbgdec.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

No objection.

Regards,

-- 
  Nicolas George


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH v6 1/3] avformat/mxfdec: set toolkit version metadata

2021-02-01 Thread Tomas Härdin
mån 2021-02-01 klockan 07:50 +0800 skrev lance.lmw...@gmail.com:
> From: Limin Wang 
> 
> Please check the string of toolkit version with below command:
> ./ffmpeg -i ../fate-suite/mxf/Sony-1.mxf -c:v copy -c:a copy out.mxf
> ./ffmpeg -i out.mxf
> 
> toolkit_version : 58.65.101
> 
> Signed-off-by: Limin Wang 
> ---
>  libavformat/mxfdec.c| 25 +
>  tests/ref/fate/mxf-probe-applehdr10 |  1 +
>  tests/ref/fate/mxf-probe-dnxhd  |  1 +
>  3 files changed, 27 insertions(+)
> 
> diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
> index afff204..61c8104 100644
> --- a/libavformat/mxfdec.c
> +++ b/libavformat/mxfdec.c
> @@ -1970,6 +1970,18 @@ static int mxf_umid_to_str(UID ul, UID uid, char **str)
>  return 0;
>  }
>  
> +static int mxf_version_to_str(uint16_t major, uint16_t minor, uint16_t 
> tertiary, char **str)
> +{
> +int size = sizeof(major) * 5 + 1;

This is just wrong. Should be 3*5+2+1 = 18.

> +
> +*str = av_mallocz(size);
> +if (!*str)
> +return AVERROR(ENOMEM);
> +
> +snprintf(*str, size, "%d.%d.%d", major, minor, tertiary);

snprintf() is not safe - *str can end up not NUL terminated

> +#define SET_VERSION_METADATA(pb, name, major, minor, tertiary, str) do { \
> +major = avio_rb16(pb); \
> +minor = avio_rb16(pb); \
> +tertiary = avio_rb16(pb); \
> +if ((ret = mxf_version_to_str(major, minor, tertiary, &str)) < 0) \
> +return ret; \
> +av_dict_set(&s->metadata, name, str, AV_DICT_DONT_STRDUP_VAL); \
> +} while (0)

Why not a function?

/Tomas

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH v6 2/3] avformat/mxf: add platform local tag

2021-02-01 Thread Tomas Härdin
mån 2021-02-01 klockan 07:50 +0800 skrev lance.lmw...@gmail.com:
> From: Limin Wang 
> 
> Please check the string of platform with below command:
> ./ffmpeg -i ../fate-suite/mxf/Sony-1.mxf -c:v copy -c:a copy out.mxf
> ./ffmpeg -i out.mxf
> 
> application_platform: Lavf (linux)
> 
> Signed-off-by: Limin Wang 
> ---
>  configure   | 1 +
>  libavformat/mxfenc.c| 4 
>  tests/ref/fate/copy-trac4914| 2 +-
>  tests/ref/fate/mxf-d10-user-comments| 2 +-
>  tests/ref/fate/mxf-opatom-user-comments | 2 +-
>  tests/ref/fate/mxf-reel_name| 2 +-
>  tests/ref/fate/mxf-user-comments| 2 +-
>  tests/ref/fate/time_base| 2 +-
>  tests/ref/lavf/mxf  | 6 +++---
>  tests/ref/lavf/mxf_d10  | 2 +-
>  tests/ref/lavf/mxf_dv25 | 2 +-
>  tests/ref/lavf/mxf_dvcpro50 | 2 +-
>  tests/ref/lavf/mxf_opatom   | 2 +-
>  tests/ref/lavf/mxf_opatom_audio | 2 +-
>  14 files changed, 19 insertions(+), 14 deletions(-)
> 
> diff --git a/configure b/configure
> index df298b4..a092a6b 100755
> --- a/configure
> +++ b/configure
> @@ -7579,6 +7579,7 @@ cat > $TMPH <  #define FFMPEG_DATADIR "$(eval c_escape $datadir)"
>  #define AVCONV_DATADIR "$(eval c_escape $datadir)"
>  #define CC_IDENT "$(c_escape ${cc_ident:-Unknown compiler})"
> +#define OS_NAME $target_os

Is there some way to force a reconfigure? I got "Lavf (OS_NAME)" before
I re-ran ./configure. Not a huge issue however.

> @@ -753,6 +756,7 @@ static void mxf_write_identification(AVFormatContext *s)
>  store_version(s);
>  
>  mxf_write_local_tag_utf16(pb, 0x3C04, version); // Version String
> +mxf_write_local_tag_utf16(pb, 0x3C08, platform); // Platform

OK since 0x3C08 is already in mxf_local_tag_batch

/Tomas

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH v6 3/3] avformat/mxfenc: prefer to use the configured metadta

2021-02-01 Thread Tomas Härdin
mån 2021-02-01 klockan 07:50 +0800 skrev lance.lmw...@gmail.com:
> @@ -724,9 +724,13 @@ static void mxf_write_identification(AVFormatContext *s)
>  {
>  MXFContext *mxf = s->priv_data;
>  AVIOContext *pb = s->pb;
> -const char *company = "FFmpeg";
> -const char *product = s->oformat != &ff_mxf_opatom_muxer ? "OP1a Muxer" 
> : "OPAtom Muxer";
> -const char *version;
> +AVDictionaryEntry *com_entry =  av_dict_get(s->metadata, "company_name", 
> NULL, 0);
> +AVDictionaryEntry *product_entry =  av_dict_get(s->metadata, 
> "product_name", NULL, 0);
> +AVDictionaryEntry *version_entry =  av_dict_get(s->metadata, 
> "product_version", NULL, 0);
> +const char *company = com_entry ? com_entry->value : "FFmpeg";
> +const char *product = product_entry ? product_entry->value : s->oformat 
> != &ff_mxf_opatom_muxer ? "OP1a Muxer" : "OPAtom Muxer";
> +const char *version = NULL;

Nit: it's not necessary to NULL version
Looks OK

/Tomas

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH v4 1/4] avutil/{avstring, bprint}: add XML escaping from ffprobe to avutil

2021-02-01 Thread Jan Ekström
On Mon, Jan 25, 2021 at 2:47 PM Nicolas George  wrote:
>
> Jan Ekström (12021-01-25):
> > For now I kept them separate since one is just moving Stefano's code,
> > and another adds new functionality that you requested.
>
> Stefano's code was good enough for ffprobe, because it had to perform a
> very precise task in a very constrained context, but as is, it is not
> good enough for lavu, it needs to be adapted.
>

I beg to differ, since it seemed to fully implement the cases noted in
2.4. Does escape double and single quotes unnecessarily in some cases,
yes. But not invalid.

But at this point I have wasted enough time with parts of this patch
set that I do not care about. I do wish that I had said to you earlier
that if you want to rework this stuff, you could do it yourself. I
just noticed the existing code and attempted to do the Right Thing and
move it into general code. I bet if I had not done it, nobody would
have bat an eye regarding it, since that's exactly how the existing
XML output things do things right now. I hope it is understandable why
it is annoying to me that instead of the code that I actually proposed
to add, the stuff that was *already* *there*s is the stuff that gets
now picked out.

> > I really have no bigger bone with either naming, I just utilized:
> > 1. How the XML spec calls the thing ("AttValue" thus becoming
> > ATT_VALUE, "CharData" becoming CHAR_DATA). I slightly would prefer to
> > keep this due to this making it easy to point towards what is actually
> > meant in the XML spec.
>
> CharData is only used a few times in the abstract syntax of the spec, it
> will have meaning only for people who are very familiar with it.
>

It also contains a nice definition of it in 2.4

"[Definition: All text that is not markup constitutes the character
data of the document.] "

> > 2. Single and double quotes are the wording that I am more acquainted
> > with, but I have no hard opinion so if you want _QUOT/_APOS, sure.
>
> I am fine with "double_quotes" and "single_quotes" or "dquot" and
> "squot" too.
>

This is where (for now) I go through the route of least resistance and post a v5

https://github.com/jeeb/ffmpeg/commits/ttml_encoder_v5

- I changed "quoted" to "quotes".
- I kept the names matching to the spec, esp. due to the definitions
in the spec in 2.3 and 2.4, as well as kept the fact that it is
escaping for the actual value of the attribute, not just "the
attribute".
- I removed the double and single quote escaping from the CHAR_DATA
escaping, as you requested.

For the record, I have no great interest in XML. If you wish to take
this stuff further, please do so. But at this point I am feeling
rather stumped that after the initial reviews which actually were
concerned of code that I wrote, most of the comments have been
regarding things that were already there in the code base.

Best regards,
Jan
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH v4 1/4] avutil/{avstring, bprint}: add XML escaping from ffprobe to avutil

2021-02-01 Thread Nicolas George
Jan Ekström (12021-02-01):
> I beg to differ, since it seemed to fully implement the cases noted in
> 2.4. Does escape double and single quotes unnecessarily in some cases,
> yes. But not invalid.

Not invalid, but not good enough.

> https://github.com/jeeb/ffmpeg/commits/ttml_encoder_v5
> 
> - I changed "quoted" to "quotes".

I strongly suggest you merge the commits, but I will not block on it.

> - I kept the names matching to the spec, esp. due to the definitions
> in the spec in 2.3 and 2.4, as well as kept the fact that it is
> escaping for the actual value of the attribute, not just "the
> attribute".

"ATT_VALUE" is a terrible part of the name, virtually impossible to
memorize. Nobody learns the names used by the XML spec by rote. Call
these modes:

AV_ESCAPE_MODE_XML
AV_ESCAPE_MODE_XML_DOUBLE_QUOTES
AV_ESCAPE_MODE_XML_SINGLE_QUOTES

and be done with it.

This is a public API, it needs to be good immediately.

> - I removed the double and single quote escaping from the CHAR_DATA
> escaping, as you requested.

Thank you very much.

> For the record, I have no great interest in XML. If you wish to take
> this stuff further, please do so. But at this point I am feeling
> rather stumped that after the initial reviews which actually were
> concerned of code that I wrote, most of the comments have been
> regarding things that were already there in the code base.

As for me, I am quite stumped that you wasted your time arguing
something you have no great interest in, instead of just following
advice and be done with it.

Regards,

-- 
  Nicolas George


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH v4 1/4] avutil/{avstring, bprint}: add XML escaping from ffprobe to avutil

2021-02-01 Thread Jan Ekström
On Mon, Feb 1, 2021 at 1:52 PM Nicolas George  wrote:
>
> Jan Ekström (12021-02-01):
> > I beg to differ, since it seemed to fully implement the cases noted in
> > 2.4. Does escape double and single quotes unnecessarily in some cases,
> > yes. But not invalid.
>
> Not invalid, but not good enough.
>
> > https://github.com/jeeb/ffmpeg/commits/ttml_encoder_v5
> >
> > - I changed "quoted" to "quotes".
>
> I strongly suggest you merge the commits, but I will not block on it.
>
> > - I kept the names matching to the spec, esp. due to the definitions
> > in the spec in 2.3 and 2.4, as well as kept the fact that it is
> > escaping for the actual value of the attribute, not just "the
> > attribute".
>
> "ATT_VALUE" is a terrible part of the name, virtually impossible to
> memorize. Nobody learns the names used by the XML spec by rote. Call
> these modes:
>
> AV_ESCAPE_MODE_XML
> AV_ESCAPE_MODE_XML_DOUBLE_QUOTES
> AV_ESCAPE_MODE_XML_SINGLE_QUOTES
>
> and be done with it.
>
> This is a public API, it needs to be good immediately.
>

I fear that those sound way, way too generic. "This escapes all XML"
definitely is not what that does.

And yes, even if it has the better definition in the Doxygen comment.

> > - I removed the double and single quote escaping from the CHAR_DATA
> > escaping, as you requested.
>
> Thank you very much.
>
> > For the record, I have no great interest in XML. If you wish to take
> > this stuff further, please do so. But at this point I am feeling
> > rather stumped that after the initial reviews which actually were
> > concerned of code that I wrote, most of the comments have been
> > regarding things that were already there in the code base.
>
> As for me, I am quite stumped that you wasted your time arguing
> something you have no great interest in, instead of just following
> advice and be done with it.
>

Well, my first reaction is to attempt to validate your requests. Then
when I'm not easily capable of doing that I become annoyed because
this code is not what I came here to receive change requests that I
cannot easily apply without blindly trusting you. Which I have done,
but only because that seems to have been the course of least
resistance. But yet, this is where we are.

Jan
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH v4 1/4] avutil/{avstring, bprint}: add XML escaping from ffprobe to avutil

2021-02-01 Thread Nicolas George
Jan Ekström (12021-02-01):
> I fear that those sound way, way too generic. "This escapes all XML"
> definitely is not what that does.
> 
> And yes, even if it has the better definition in the Doxygen comment.

Why? Do you expect to add something that "escapes all XML"? What does it
even mean?

These symbols are what developers will need to type. Making them long is
just a waste of time. Adding hard to remembers parts like "ATT" (is it
"ATTR"? or "ATTRIBUTE"?) is just adding insult to injury.

Make the documentation as clear as possible, but keep the symbols short
and easy to remember.

Regards,

-- 
  Nicolas George


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH v4 1/4] avutil/{avstring, bprint}: add XML escaping from ffprobe to avutil

2021-02-01 Thread Jan Ekström
On Mon, Feb 1, 2021 at 2:25 PM Nicolas George  wrote:
>
> Jan Ekström (12021-02-01):
> > I fear that those sound way, way too generic. "This escapes all XML"
> > definitely is not what that does.
> >
> > And yes, even if it has the better definition in the Doxygen comment.
>
> Why? Do you expect to add something that "escapes all XML"? What does it
> even mean?
>

No, I do not expect to. Just that as you made me add modifications to
this logic, I no longer wish to make it as simple as "XML escaping"
since at least in my opinion if nothing else - that would now include
those cases that have now been separated.

Of course I would *love* secondary opinions here. If other people
accept the naming then I will become less hesitant about them.

Also removing the attribute value part out of the attribute value
things seems like a dangerous bid. Same regarding others' opinions
with this as well.

> These symbols are what developers will need to type. Making them long is
> just a waste of time. Adding hard to remembers parts like "ATT" (is it
> "ATTR"? or "ATTRIBUTE"?) is just adding insult to injury.
>

I don't disagree with it being ugly, just that it is what it matches
in the spec. I wouldn't be against making it "ATTR_VALUE" or
"ATTRIBUTE_VALUE", but effectively does that improve anything?

Also for the record, I have clang-based auto-completion in most of my
editors, just for this. So that I can find things that I do not know
yet/recall.

> Make the documentation as clear as possible, but keep the symbols short
> and easy to remember.
>

As a general guide line I 100% agree with you. It's just that in this
case I'm not sure if removing details from the names like this is the
right way forward.

Jan
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH v4 1/4] avutil/{avstring, bprint}: add XML escaping from ffprobe to avutil

2021-02-01 Thread Nicolas George
Jan Ekström (12021-02-01):
> I don't disagree with it being ugly, just that it is what it matches
> in the spec.

Nobody reads the XML spec. Especially for something as trivial as the
syntax to escape attributes. People learn XML from tutorials and
examples, which will not have exactly the same wording as the spec.

I second your request of a third opinion.

Regards,

-- 
  Nicolas George


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH] ffmpeg: add -rmax to clamp output framerate

2021-02-01 Thread Gyan Doshi
Useful when encoding in batch or with aberrant inputs.
---
 doc/ffmpeg.texi  |  7 +++
 fftools/ffmpeg.c |  7 ++-
 fftools/ffmpeg.h |  3 +++
 fftools/ffmpeg_opt.c | 22 +++---
 4 files changed, 35 insertions(+), 4 deletions(-)

diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi
index 8eb012b7c0..7726f25082 100644
--- a/doc/ffmpeg.texi
+++ b/doc/ffmpeg.texi
@@ -759,6 +759,13 @@ If in doubt use @option{-framerate} instead of the input 
option @option{-r}.
 As an output option, duplicate or drop input frames to achieve constant output
 frame rate @var{fps}.
 
+@item -rmax[:@var{stream_specifier}] @var{fps} (@emph{output,per-stream})
+Set maximum frame rate (Hz value, fraction or abbreviation).
+
+Clamps output frame rate when output framerate is auto-set and is higher than 
this value.
+Useful in batch processing or when input framerate is wrongly detected as very 
high.
+Ignored when either @code{-r} is set or during streamcopy.
+
 @item -s[:@var{stream_specifier}] @var{size} (@emph{input/output,per-stream})
 Set frame size.
 
diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index d7c833be63..add5a3e505 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -3376,7 +3376,7 @@ static int init_output_stream_encode(OutputStream *ost, 
AVFrame *frame)
 ost->frame_rate = ist->framerate;
 if (ist && !ost->frame_rate.num)
 ost->frame_rate = ist->st->r_frame_rate;
-if (ist && !ost->frame_rate.num) {
+if (ist && !ost->frame_rate.num && !ost->max_frame_rate.num) {
 ost->frame_rate = (AVRational){25, 1};
 av_log(NULL, AV_LOG_WARNING,
"No information "
@@ -3386,6 +3386,11 @@ static int init_output_stream_encode(OutputStream *ost, 
AVFrame *frame)
ost->file_index, ost->index);
 }
 
+if (ost->max_frame_rate.num &&
+(av_q2d(ost->frame_rate) > av_q2d(ost->max_frame_rate) ||
+!ost->frame_rate.den))
+ost->frame_rate = ost->max_frame_rate;
+
 if (ost->enc->supported_framerates && !ost->force_fps) {
 int idx = av_find_nearest_q_idx(ost->frame_rate, 
ost->enc->supported_framerates);
 ost->frame_rate = ost->enc->supported_framerates[idx];
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 8046e75026..3662130da4 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -108,6 +108,8 @@ typedef struct OptionsContext {
 intnb_audio_sample_rate;
 SpecifierOpt *frame_rates;
 intnb_frame_rates;
+SpecifierOpt *max_frame_rates;
+intnb_max_frame_rates;
 SpecifierOpt *frame_sizes;
 intnb_frame_sizes;
 SpecifierOpt *frame_pix_fmts;
@@ -479,6 +481,7 @@ typedef struct OutputStream {
 
 /* video only */
 AVRational frame_rate;
+AVRational max_frame_rate;
 int is_cfr;
 int force_fps;
 int top_field_first;
diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index bf2eb26246..06b1c03dc8 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -55,6 +55,7 @@ static const char *const opt_name_codec_names[]   
= {"c", "codec", "
 static const char *const opt_name_audio_channels[]= {"ac", NULL};
 static const char *const opt_name_audio_sample_rate[] = {"ar", NULL};
 static const char *const opt_name_frame_rates[]   = {"r", NULL};
+static const char *const opt_name_max_frame_rates[]   = {"rmax", NULL};
 static const char *const opt_name_frame_sizes[]   = {"s", NULL};
 static const char *const opt_name_frame_pix_fmts[]= {"pix_fmt", 
NULL};
 static const char *const opt_name_ts_scale[]  = {"itsscale", 
NULL};
@@ -1688,7 +1689,7 @@ static OutputStream *new_video_stream(OptionsContext *o, 
AVFormatContext *oc, in
 AVStream *st;
 OutputStream *ost;
 AVCodecContext *video_enc;
-char *frame_rate = NULL, *frame_aspect_ratio = NULL;
+char *frame_rate = NULL, *max_frame_rate = NULL, *frame_aspect_ratio = 
NULL;
 
 ost = new_output_stream(o, oc, AVMEDIA_TYPE_VIDEO, source_index);
 st  = ost->st;
@@ -1699,8 +1700,20 @@ static OutputStream *new_video_stream(OptionsContext *o, 
AVFormatContext *oc, in
 av_log(NULL, AV_LOG_FATAL, "Invalid framerate value: %s\n", 
frame_rate);
 exit_program(1);
 }
-if (frame_rate && video_sync_method == VSYNC_PASSTHROUGH)
-av_log(NULL, AV_LOG_ERROR, "Using -vsync 0 and -r can produce invalid 
output files\n");
+
+MATCH_PER_STREAM_OPT(max_frame_rates, str, max_frame_rate, oc, st);
+if (max_frame_rate && av_parse_video_rate(&ost->max_frame_rate, 
max_frame_rate) < 0) {
+av_log(NULL, AV_LOG_FATAL, "Invalid maximum framerate value: %s\n", 
max_frame_rate);
+exit_program(1);
+}
+
+if (frame_rate && max_frame_rate)
+av_log(NULL, AV_LOG_WARNING, "-rmax for stream %d:%d will have no 
effect as"
+   " -r is also set.\n"

[FFmpeg-devel] [PATCH v2] ffmpeg: add -rmax to clamp output framerate

2021-02-01 Thread Gyan Doshi
Useful when encoding in batch or with aberrant inputs.
---
 doc/ffmpeg.texi  |  7 +++
 fftools/ffmpeg.c |  7 ++-
 fftools/ffmpeg.h |  3 +++
 fftools/ffmpeg_opt.c | 24 +---
 4 files changed, 37 insertions(+), 4 deletions(-)

Forgot to nullify rmax with r set.

diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi
index 8eb012b7c0..7726f25082 100644
--- a/doc/ffmpeg.texi
+++ b/doc/ffmpeg.texi
@@ -759,6 +759,13 @@ If in doubt use @option{-framerate} instead of the input 
option @option{-r}.
 As an output option, duplicate or drop input frames to achieve constant output
 frame rate @var{fps}.
 
+@item -rmax[:@var{stream_specifier}] @var{fps} (@emph{output,per-stream})
+Set maximum frame rate (Hz value, fraction or abbreviation).
+
+Clamps output frame rate when output framerate is auto-set and is higher than 
this value.
+Useful in batch processing or when input framerate is wrongly detected as very 
high.
+Ignored when either @code{-r} is set or during streamcopy.
+
 @item -s[:@var{stream_specifier}] @var{size} (@emph{input/output,per-stream})
 Set frame size.
 
diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index d7c833be63..add5a3e505 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -3376,7 +3376,7 @@ static int init_output_stream_encode(OutputStream *ost, 
AVFrame *frame)
 ost->frame_rate = ist->framerate;
 if (ist && !ost->frame_rate.num)
 ost->frame_rate = ist->st->r_frame_rate;
-if (ist && !ost->frame_rate.num) {
+if (ist && !ost->frame_rate.num && !ost->max_frame_rate.num) {
 ost->frame_rate = (AVRational){25, 1};
 av_log(NULL, AV_LOG_WARNING,
"No information "
@@ -3386,6 +3386,11 @@ static int init_output_stream_encode(OutputStream *ost, 
AVFrame *frame)
ost->file_index, ost->index);
 }
 
+if (ost->max_frame_rate.num &&
+(av_q2d(ost->frame_rate) > av_q2d(ost->max_frame_rate) ||
+!ost->frame_rate.den))
+ost->frame_rate = ost->max_frame_rate;
+
 if (ost->enc->supported_framerates && !ost->force_fps) {
 int idx = av_find_nearest_q_idx(ost->frame_rate, 
ost->enc->supported_framerates);
 ost->frame_rate = ost->enc->supported_framerates[idx];
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 8046e75026..3662130da4 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -108,6 +108,8 @@ typedef struct OptionsContext {
 intnb_audio_sample_rate;
 SpecifierOpt *frame_rates;
 intnb_frame_rates;
+SpecifierOpt *max_frame_rates;
+intnb_max_frame_rates;
 SpecifierOpt *frame_sizes;
 intnb_frame_sizes;
 SpecifierOpt *frame_pix_fmts;
@@ -479,6 +481,7 @@ typedef struct OutputStream {
 
 /* video only */
 AVRational frame_rate;
+AVRational max_frame_rate;
 int is_cfr;
 int force_fps;
 int top_field_first;
diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index bf2eb26246..2080499e65 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -55,6 +55,7 @@ static const char *const opt_name_codec_names[]   
= {"c", "codec", "
 static const char *const opt_name_audio_channels[]= {"ac", NULL};
 static const char *const opt_name_audio_sample_rate[] = {"ar", NULL};
 static const char *const opt_name_frame_rates[]   = {"r", NULL};
+static const char *const opt_name_max_frame_rates[]   = {"rmax", NULL};
 static const char *const opt_name_frame_sizes[]   = {"s", NULL};
 static const char *const opt_name_frame_pix_fmts[]= {"pix_fmt", 
NULL};
 static const char *const opt_name_ts_scale[]  = {"itsscale", 
NULL};
@@ -1688,7 +1689,7 @@ static OutputStream *new_video_stream(OptionsContext *o, 
AVFormatContext *oc, in
 AVStream *st;
 OutputStream *ost;
 AVCodecContext *video_enc;
-char *frame_rate = NULL, *frame_aspect_ratio = NULL;
+char *frame_rate = NULL, *max_frame_rate = NULL, *frame_aspect_ratio = 
NULL;
 
 ost = new_output_stream(o, oc, AVMEDIA_TYPE_VIDEO, source_index);
 st  = ost->st;
@@ -1699,8 +1700,22 @@ static OutputStream *new_video_stream(OptionsContext *o, 
AVFormatContext *oc, in
 av_log(NULL, AV_LOG_FATAL, "Invalid framerate value: %s\n", 
frame_rate);
 exit_program(1);
 }
-if (frame_rate && video_sync_method == VSYNC_PASSTHROUGH)
-av_log(NULL, AV_LOG_ERROR, "Using -vsync 0 and -r can produce invalid 
output files\n");
+
+MATCH_PER_STREAM_OPT(max_frame_rates, str, max_frame_rate, oc, st);
+if (max_frame_rate && av_parse_video_rate(&ost->max_frame_rate, 
max_frame_rate) < 0) {
+av_log(NULL, AV_LOG_FATAL, "Invalid maximum framerate value: %s\n", 
max_frame_rate);
+exit_program(1);
+}
+
+if (frame_rate && max_frame_rate) {
+av_log(NULL, AV_LOG_WARNING, "-rmax for stream %d:%d will have no 
effect 

Re: [FFmpeg-devel] [PATCH v6 3/3] avformat/mxfenc: prefer to use the configured metadta

2021-02-01 Thread lance . lmwang
On Mon, Feb 01, 2021 at 12:05:40PM +0100, Tomas Härdin wrote:
> mån 2021-02-01 klockan 07:50 +0800 skrev lance.lmw...@gmail.com:
> > @@ -724,9 +724,13 @@ static void mxf_write_identification(AVFormatContext 
> > *s)
> >  {
> >  MXFContext *mxf = s->priv_data;
> >  AVIOContext *pb = s->pb;
> > -const char *company = "FFmpeg";
> > -const char *product = s->oformat != &ff_mxf_opatom_muxer ? "OP1a 
> > Muxer" : "OPAtom Muxer";
> > -const char *version;
> > +AVDictionaryEntry *com_entry =  av_dict_get(s->metadata, 
> > "company_name", NULL, 0);
> > +AVDictionaryEntry *product_entry =  av_dict_get(s->metadata, 
> > "product_name", NULL, 0);
> > +AVDictionaryEntry *version_entry =  av_dict_get(s->metadata, 
> > "product_version", NULL, 0);
> > +const char *company = com_entry ? com_entry->value : "FFmpeg";
> > +const char *product = product_entry ? product_entry->value : 
> > s->oformat != &ff_mxf_opatom_muxer ? "OP1a Muxer" : "OPAtom Muxer";
> > +const char *version = NULL;
> 
> Nit: it's not necessary to NULL version

OK, fix it.

> Looks OK
> 
> /Tomas
> 
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

-- 
Thanks,
Limin Wang
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] libavformat: add librist protocol

2021-02-01 Thread Rodney Baker
On Monday, 1 February 2021 8:03:28 ACDT Sergio M. Ammirata, Ph.D. wrote:
> librist has an internal buffer limit of 1 bytes (the
> protocol has none).
> 
> For writing, the data you give librist, will go out "as is"
> to the network with some added protocol overhead bytes (28
> bytes without encryption enabled and 36 bytes with
> encryption enabled).
> 
> To avoid your data being fragmented because of network MTU,
> you should really limit the write size to what you want
> your IP packets to be. For mpegts, for example, 1316 is a
> good number to keep the overall packet size below the
> typical internet MTU size of 1500 (1400 to be safe).
> 
> I suggest this "max" write size be a configurable setting
> in ffmpeg so that a higher number can be used if you are
> running it where the network supports jumbo packets.

If I can chime in as an experienced network designer/administrator, I concur 
with comments by Sergio and Marton. This should definitely be a configurable 
parameter for writing, with a default value of 1500 or less, and a maximum 
allowed value of 9216 (the highest jumbo frame MTU guaranteed to be supported 
by most modern networking equipment). 

The generally agreed (industry-wide) standard for jumbo packet MTU's is 9000 
bytes, but most will support up to 9216. That does, however, depend on the 
maximum MTU configured by the network admins at any given location or 
organisation. 

Any packets larger than that must be fragmented by the network equipment, and 
that means CPU/Process switching all such packets rather than hardware 
switching, which adds to CPU and memory usage on the network kit and gets the 
network admins offside.

The only time <1500 is really needed is for network links where tunnelling/
encapsulation is involved (e.g. VPN links using GRE, IPSec, IP-in-IP or some 
other encapsulation that results in a reduced MTU). In this case it should be 
able to be configured for values anywere from 1316 to 1422. Any network admin 
worth his salt will know how to check the maximum MTU for a given network path 
and advise the app owner to set the values accordingly. 
> 
> For reading, you can keep the 9964 number always.

No harm in that, agreed. 

[...]
-- 
==
Rodney Baker VK5ZTV
rodney.ba...@iinet.net.au
CCNA #CSCO12880208
==


___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] libavformat: add librist protocol

2021-02-01 Thread Nicolas George
Sergio M. Ammirata, Ph.D. (12021-01-31):
> For writing, the data you give librist, will go out "as is"
> to the network with some added protocol overhead bytes (28
> bytes without encryption enabled and 36 bytes with
> encryption enabled).

Can you clarify something? Is this supposed to be a packet protocol or a
stream protocol?

I.e., if the reader is waiting for 100 octets, and the writer sent 20
then 30 then 40, will the reader get three reads of 20, 30, 40 or a
single read of 20+30+40=90?

> To avoid your data being fragmented because of network MTU,
> you should really limit the write size to what you want
> your IP packets to be. For mpegts, for example, 1316 is a
> good number to keep the overall packet size below the
> typical internet MTU size of 1500 (1400 to be safe).

It looks to me like reinventing the wheel that TCP had had years to make
nicely round. Do we need to implement the Nagle algorithm?

Regards,

-- 
  Nicolas George


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] libavformat: add librist protocol

2021-02-01 Thread Rodney Baker
On Tuesday, 2 February 2021 0:52:23 ACDT Nicolas George wrote:
> Sergio M. Ammirata, Ph.D. (12021-01-31):
> > For writing, the data you give librist, will go out "as is"
> > to the network with some added protocol overhead bytes (28
> > bytes without encryption enabled and 36 bytes with
> > encryption enabled).
> 
> Can you clarify something? Is this supposed to be a packet protocol or a
> stream protocol?
> 
> I.e., if the reader is waiting for 100 octets, and the writer sent 20
> then 30 then 40, will the reader get three reads of 20, 30, 40 or a
> single read of 20+30+40=90?
> 
> > To avoid your data being fragmented because of network MTU,
> > you should really limit the write size to what you want
> > your IP packets to be. For mpegts, for example, 1316 is a
> > good number to keep the overall packet size below the
> > typical internet MTU size of 1500 (1400 to be safe).
> 
> It looks to me like reinventing the wheel that TCP had had years to make
> nicely round. Do we need to implement the Nagle algorithm?
> 
> Regards,

Nagle can introduce unwanted latency which is not desirable for real-time 
streaming. Mind you, tcp is inappropriate for real-time streaming anyway - 
that's what rtsp was invented for. I don't think Nagle belongs at app level 
anyway - it's a network stack function (that can be disabled with the 
TCP_NODELAY setting). 

Truth be told, the MTU should be (and is) controlled by the network stack too, 
but there's no reason to cause packet fragmentation (and the increased latency 
assocaited with packet fragmentation and reassembly) by deliberately 
configuring the app to generate packets larger than the largest possible MTU 
(but I don't really have a say in the matter - just providing advice based on 
hard-learned lessons and experience tuning networks where the largest 
bandwidth application - by orders of magnitude - is real-time streaming 
video). 

Regards,
Rodney.

-- 
==
Rodney Baker VK5ZTV
rodney.ba...@iinet.net.au
CCNA #CSCO12880208
==


___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] libavformat: add librist protocol

2021-02-01 Thread Nicolas George
Rodney Baker (12021-02-02):
> Nagle can introduce unwanted latency which is not desirable for real-time 
> streaming. Mind you, tcp is inappropriate for real-time streaming anyway - 
> that's what rtsp was invented for. I don't think Nagle belongs at app level 
> anyway - it's a network stack function (that can be disabled with the 
> TCP_NODELAY setting). 

I know all that. Please do not answer ONLY to the last sentence of my
mail. You have not answered the important part:

> > Can you clarify something? Is this supposed to be a packet protocol or a
> > stream protocol?
> > 
> > I.e., if the reader is waiting for 100 octets, and the writer sent 20
> > then 30 then 40, will the reader get three reads of 20, 30, 40 or a
> > single read of 20+30+40=90?

Regards,

-- 
  Nicolas George


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH v6 1/3] avformat/mxfdec: set toolkit version metadata

2021-02-01 Thread lance . lmwang
On Mon, Feb 01, 2021 at 11:56:25AM +0100, Tomas Härdin wrote:
> mån 2021-02-01 klockan 07:50 +0800 skrev lance.lmw...@gmail.com:
> > From: Limin Wang 
> > 
> > Please check the string of toolkit version with below command:
> > ./ffmpeg -i ../fate-suite/mxf/Sony-1.mxf -c:v copy -c:a copy out.mxf
> > ./ffmpeg -i out.mxf
> > 
> > toolkit_version : 58.65.101
> > 
> > Signed-off-by: Limin Wang 
> > ---
> >  libavformat/mxfdec.c| 25 +
> >  tests/ref/fate/mxf-probe-applehdr10 |  1 +
> >  tests/ref/fate/mxf-probe-dnxhd  |  1 +
> >  3 files changed, 27 insertions(+)
> > 
> > diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
> > index afff204..61c8104 100644
> > --- a/libavformat/mxfdec.c
> > +++ b/libavformat/mxfdec.c
> > @@ -1970,6 +1970,18 @@ static int mxf_umid_to_str(UID ul, UID uid, char 
> > **str)
> >  return 0;
> >  }
> >  
> > +static int mxf_version_to_str(uint16_t major, uint16_t minor, uint16_t 
> > tertiary, char **str)
> > +{
> > +int size = sizeof(major) * 5 + 1;
> 
> This is just wrong. Should be 3*5+2+1 = 18.

will fix it.

> 
> > +
> > +*str = av_mallocz(size);
> > +if (!*str)
> > +return AVERROR(ENOMEM);
> > +
> > +snprintf(*str, size, "%d.%d.%d", major, minor, tertiary);
> 
> snprintf() is not safe - *str can end up not NUL terminated

what's your suggestion?
I think allocate *str with +1 byte and zero it to sure the string will be NULL
terminated.

> 
> > +#define SET_VERSION_METADATA(pb, name, major, minor, tertiary, str) do { \
> > +major = avio_rb16(pb); \
> > +minor = avio_rb16(pb); \
> > +tertiary = avio_rb16(pb); \
> > +if ((ret = mxf_version_to_str(major, minor, tertiary, &str)) < 0) \
> > +return ret; \
> > +av_dict_set(&s->metadata, name, str, AV_DICT_DONT_STRDUP_VAL); \
> > +} while (0)
> 
> Why not a function?

Function is OK to me, I'm just following the same style for SET_STR_METADATA, 
SET_UID_METADATA,
SET_TS_METADATA.

> 
> /Tomas
> 
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

-- 
Thanks,
Limin Wang
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH v6 2/3] avformat/mxf: add platform local tag

2021-02-01 Thread lance . lmwang
On Mon, Feb 01, 2021 at 12:01:02PM +0100, Tomas Härdin wrote:
> mån 2021-02-01 klockan 07:50 +0800 skrev lance.lmw...@gmail.com:
> > From: Limin Wang 
> > 
> > Please check the string of platform with below command:
> > ./ffmpeg -i ../fate-suite/mxf/Sony-1.mxf -c:v copy -c:a copy out.mxf
> > ./ffmpeg -i out.mxf
> > 
> > application_platform: Lavf (linux)
> > 
> > Signed-off-by: Limin Wang 
> > ---
> >  configure   | 1 +
> >  libavformat/mxfenc.c| 4 
> >  tests/ref/fate/copy-trac4914| 2 +-
> >  tests/ref/fate/mxf-d10-user-comments| 2 +-
> >  tests/ref/fate/mxf-opatom-user-comments | 2 +-
> >  tests/ref/fate/mxf-reel_name| 2 +-
> >  tests/ref/fate/mxf-user-comments| 2 +-
> >  tests/ref/fate/time_base| 2 +-
> >  tests/ref/lavf/mxf  | 6 +++---
> >  tests/ref/lavf/mxf_d10  | 2 +-
> >  tests/ref/lavf/mxf_dv25 | 2 +-
> >  tests/ref/lavf/mxf_dvcpro50 | 2 +-
> >  tests/ref/lavf/mxf_opatom   | 2 +-
> >  tests/ref/lavf/mxf_opatom_audio | 2 +-
> >  14 files changed, 19 insertions(+), 14 deletions(-)
> > 
> > diff --git a/configure b/configure
> > index df298b4..a092a6b 100755
> > --- a/configure
> > +++ b/configure
> > @@ -7579,6 +7579,7 @@ cat > $TMPH < >  #define FFMPEG_DATADIR "$(eval c_escape $datadir)"
> >  #define AVCONV_DATADIR "$(eval c_escape $datadir)"
> >  #define CC_IDENT "$(c_escape ${cc_ident:-Unknown compiler})"
> > +#define OS_NAME $target_os
> 
> Is there some way to force a reconfigure? I got "Lavf (OS_NAME)" before
> I re-ran ./configure. Not a huge issue however.

No, but I can check OS_NAME macro in the code, if it's not defined, 
we can use "Lavf" instead of "Lavf (OS_NAME)"

> 
> > @@ -753,6 +756,7 @@ static void mxf_write_identification(AVFormatContext *s)
> >  store_version(s);
> >  
> >  mxf_write_local_tag_utf16(pb, 0x3C04, version); // Version String
> > +mxf_write_local_tag_utf16(pb, 0x3C08, platform); // Platform
> 
> OK since 0x3C08 is already in mxf_local_tag_batch
> 
> /Tomas
> 
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

-- 
Thanks,
Limin Wang
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] libavformat: add librist protocol

2021-02-01 Thread Sergio M. Ammirata, Ph.D.
> Can you clarify something? Is this supposed to be a
> packet protocol or astream protocol?
> I.e., if the reader is waiting for 100 octets, and the
> writer sent 20then 30 then 40, will the reader get three
> reads of 20, 30, 40 or asingle read of 20+30+40=90?

This is a packet protocol. In your example above, the
reader will get three reads of 20, 30 and 40
Sergio
On Mon, 2021-02-01 at 15:22 +0100, Nicolas George wrote:
> Sergio M. Ammirata, Ph.D. (12021-01-31):
> For writing, the data you give librist, will go out "as
> is"to the network with some added protocol overhead bytes
> (28bytes without encryption enabled and 36 bytes
> withencryption enabled).
> Can you clarify something? Is this supposed to be a
> packet protocol or astream protocol?
> I.e., if the reader is waiting for 100 octets, and the
> writer sent 20then 30 then 40, will the reader get three
> reads of 20, 30, 40 or asingle read of 20+30+40=90?
> To avoid your data being fragmented because of network
> MTU,you should really limit the write size to what you
> wantyour IP packets to be. For mpegts, for example, 1316
> is agood number to keep the overall packet size below
> thetypical internet MTU size of 1500 (1400 to be safe).
> It looks to me like reinventing the wheel that TCP had
> had years to makenicely round. Do we need to implement
> the Nagle algorithm?
> Regards,
> 
> ___ffmpeg-
> devel mailing listffmpeg-de...@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> To unsubscribe, visit link above, or 
> emailffmpeg-devel-requ...@ffmpeg.org with subject
> "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH v6 2/3] avformat/mxf: add platform local tag

2021-02-01 Thread Tomas Härdin
mån 2021-02-01 klockan 22:54 +0800 skrev lance.lmw...@gmail.com:
> On Mon, Feb 01, 2021 at 12:01:02PM +0100, Tomas Härdin wrote:
> > mån 2021-02-01 klockan 07:50 +0800 skrev lance.lmw...@gmail.com:
> > > From: Limin Wang 
> > > 
> > > Please check the string of platform with below command:
> > > ./ffmpeg -i ../fate-suite/mxf/Sony-1.mxf -c:v copy -c:a copy out.mxf
> > > ./ffmpeg -i out.mxf
> > > 
> > > application_platform: Lavf (linux)
> > > 
> > > Signed-off-by: Limin Wang 
> > > ---
> > >  configure   | 1 +
> > >  libavformat/mxfenc.c| 4 
> > >  tests/ref/fate/copy-trac4914| 2 +-
> > >  tests/ref/fate/mxf-d10-user-comments| 2 +-
> > >  tests/ref/fate/mxf-opatom-user-comments | 2 +-
> > >  tests/ref/fate/mxf-reel_name| 2 +-
> > >  tests/ref/fate/mxf-user-comments| 2 +-
> > >  tests/ref/fate/time_base| 2 +-
> > >  tests/ref/lavf/mxf  | 6 +++---
> > >  tests/ref/lavf/mxf_d10  | 2 +-
> > >  tests/ref/lavf/mxf_dv25 | 2 +-
> > >  tests/ref/lavf/mxf_dvcpro50 | 2 +-
> > >  tests/ref/lavf/mxf_opatom   | 2 +-
> > >  tests/ref/lavf/mxf_opatom_audio | 2 +-
> > >  14 files changed, 19 insertions(+), 14 deletions(-)
> > > 
> > > diff --git a/configure b/configure
> > > index df298b4..a092a6b 100755
> > > --- a/configure
> > > +++ b/configure
> > > @@ -7579,6 +7579,7 @@ cat > $TMPH < > >  #define FFMPEG_DATADIR "$(eval c_escape $datadir)"
> > >  #define AVCONV_DATADIR "$(eval c_escape $datadir)"
> > >  #define CC_IDENT "$(c_escape ${cc_ident:-Unknown compiler})"
> > > +#define OS_NAME $target_os
> > 
> > Is there some way to force a reconfigure? I got "Lavf (OS_NAME)" before
> > I re-ran ./configure. Not a huge issue however.
> 
> No, but I can check OS_NAME macro in the code, if it's not defined, 
> we can use "Lavf" instead of "Lavf (OS_NAME)"

Eh, don't bother. This is probably the case for a whole lot of other
defines.

I can apply this while I apply my MXF patch. Or did you have access to
git?

/Tomas

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] libavformat: add librist protocol

2021-02-01 Thread Nicolas George
Sergio M. Ammirata, Ph.D. (12021-02-01):
> This is a packet protocol. In your example above, the
> reader will get three reads of 20, 30 and 40

Thank you for the clarification. I looked a little in the code in the
meantime.

Considering what was said, h->max_packet_size should be set to the
maximum packet size allowed by librist. Unfortunately, this number seems
to be RIST_MAX_PACKET_SIZE and defined in a private.

It does not make sense to have packet_size an option if it is not
actually applied to librist, as it is in the current version of the
patch.

For reading, max_packet_size must not be too low. For writing, it can be
lowered, but it is not specific to this particular protocol.

Regards,

-- 
  Nicolas George


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] libavformat: add librist protocol

2021-02-01 Thread Sergio M. Ammirata, Ph.D.


On Mon, 2021-02-01 at 16:25 +0100, Nicolas George wrote:
> Sergio M. Ammirata, Ph.D. (12021-02-01):
> This is a packet protocol. In your example above,
> thereader will get three reads of 20, 30 and 40
> Thank you for the clarification. I looked a little in the
> code in themeantime.
> Considering what was said, h->max_packet_size should be
> set to themaximum packet size allowed by librist.
> Unfortunately, this number seemsto be
> RIST_MAX_PACKET_SIZE and defined in a private.
> It does not make sense to have packet_size an option if
> it is notactually applied to librist, as it is in the
> current version of thepatch.
> For reading, max_packet_size must not be too low. For
> writing, it can belowered, but it is not specific to this
> particular protocol.

Correct, the write size has more to do with the desired IP
packet size than the protocol itself. It would be the exact
equivalent to the pkt_size setting on the udp output
module.
Sergio
> Regards,
> 
> ___ffmpeg-
> devel mailing listffmpeg-de...@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> To unsubscribe, visit link above, or 
> emailffmpeg-devel-requ...@ffmpeg.org with subject
> "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH v6 2/3] avformat/mxf: add platform local tag

2021-02-01 Thread lance . lmwang
On Mon, Feb 01, 2021 at 04:18:08PM +0100, Tomas Härdin wrote:
> mån 2021-02-01 klockan 22:54 +0800 skrev lance.lmw...@gmail.com:
> > On Mon, Feb 01, 2021 at 12:01:02PM +0100, Tomas Härdin wrote:
> > > mån 2021-02-01 klockan 07:50 +0800 skrev lance.lmw...@gmail.com:
> > > > From: Limin Wang 
> > > > 
> > > > Please check the string of platform with below command:
> > > > ./ffmpeg -i ../fate-suite/mxf/Sony-1.mxf -c:v copy -c:a copy out.mxf
> > > > ./ffmpeg -i out.mxf
> > > > 
> > > > application_platform: Lavf (linux)
> > > > 
> > > > Signed-off-by: Limin Wang 
> > > > ---
> > > >  configure   | 1 +
> > > >  libavformat/mxfenc.c| 4 
> > > >  tests/ref/fate/copy-trac4914| 2 +-
> > > >  tests/ref/fate/mxf-d10-user-comments| 2 +-
> > > >  tests/ref/fate/mxf-opatom-user-comments | 2 +-
> > > >  tests/ref/fate/mxf-reel_name| 2 +-
> > > >  tests/ref/fate/mxf-user-comments| 2 +-
> > > >  tests/ref/fate/time_base| 2 +-
> > > >  tests/ref/lavf/mxf  | 6 +++---
> > > >  tests/ref/lavf/mxf_d10  | 2 +-
> > > >  tests/ref/lavf/mxf_dv25 | 2 +-
> > > >  tests/ref/lavf/mxf_dvcpro50 | 2 +-
> > > >  tests/ref/lavf/mxf_opatom   | 2 +-
> > > >  tests/ref/lavf/mxf_opatom_audio | 2 +-
> > > >  14 files changed, 19 insertions(+), 14 deletions(-)
> > > > 
> > > > diff --git a/configure b/configure
> > > > index df298b4..a092a6b 100755
> > > > --- a/configure
> > > > +++ b/configure
> > > > @@ -7579,6 +7579,7 @@ cat > $TMPH < > > >  #define FFMPEG_DATADIR "$(eval c_escape $datadir)"
> > > >  #define AVCONV_DATADIR "$(eval c_escape $datadir)"
> > > >  #define CC_IDENT "$(c_escape ${cc_ident:-Unknown compiler})"
> > > > +#define OS_NAME $target_os
> > > 
> > > Is there some way to force a reconfigure? I got "Lavf (OS_NAME)" before
> > > I re-ran ./configure. Not a huge issue however.
> > 
> > No, but I can check OS_NAME macro in the code, if it's not defined, 
> > we can use "Lavf" instead of "Lavf (OS_NAME)"
> 
> Eh, don't bother. This is probably the case for a whole lot of other
> defines.
> 
> I can apply this while I apply my MXF patch. Or did you have access to
> git?

No problem, please apply it anyway if you think this is OK.

> 
> /Tomas
> 
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

-- 
Thanks,
Limin Wang
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avdevice/avdevice: Deprecate AVDevice Capabilities API

2021-02-01 Thread Nicolas George
Mark Thompson (12021-01-27):
> See for example the list of suggestions I made for improving the API a few 
> days ago.

I intended to reply to them, but the conversation never came back to it
before now.

> * Handle frames as well as packets.

Already possible.

>   * Including hardware frames - DRM objects from KMS/V4L2, D3D
>   surfaces from Windows desktop duplication (which doesn't currentl y
>   exist but should).

I do not know if it is possible, you know this stuff better than me.

> * Clear core option set - currently almost everything is set by
> inconsistent private options; things like pixel/sample format,
> frame/sample rate, geometry and hardware device should be common
> options to all.

That would be good, but can be done with any API.

> * Asynchronicity - a big annoyance in current recording scenarios with
> the ffmpeg utility is that both audio and video capture block, and do
> so on the same thread which results in skipped frames.

This is a problem for devices, protocols and demuxers, and even filters,
and is therefore not an argument for a separate device API.

Please know that I am working on fixing this issue. This is the event
loop stuff. But it is a complex task.

> * Capability probing - the existing method of options which log the
> capabilities are not very useful for API users.

This is true, but it is not a problem with the API, just a missing
feature. See below for details about what I mean.

> How are we to determine who has the most relevant experience, so that
> we avoid appealing to a false authority?

Please accept my apology. I mistakenly assumed that you were speaking
from the same of lack of experience as the other people who want to
destroy libavdevice.

Did you use libavdevice in projects, not through ffmpeg.c, as well?

> Please will you explain what your ideas are about how to enhance the
> API of libavdevice.
> 
> Even if we disagree about exactly where such changes should be
> implemented, I would very much welcome hearing about the improvements
> you would like to make underneath.

First, I need to say that I agree with you that intuitively libavdevice
needs a dedicated API: devices are not the same thing as muxers and
demuxers, they have special need.

BUT...

But it means yet another f...ing API, and that is not good either. It
requires learning another API, special code, etc. Or it will be used
only through wrappers, and as such useless in itself.

Devices have special needs, but at the core, they are components that
produce or consume frames.

We already have APIs for components that produce or consume frames. We
already have several of them in fact.

So, my thoughts on devices is:

Let us choose the most nimble and extensible such API, and extend it as
needed.

This is, in essence, object-oriented design: instead of inventing a
completely new interface for devices, let the interface for devices
inherit from an existing interface, choosing the best one.

How does it sound for now?

> Indeed.  The most obvious use-case for much of what I have said is of
> course the ffmpeg utility itself - the ability to avoid pointless
> copies when working with devices and to be able to record video and

That would be nice, but I wonder how urgent it is.

> audio at the same time without weird interactions would both be useful
> features.

This would be very useful, but it is not specific to devices. We need to
be able to capture from the sound device and from a networked webcam
too.

If you try to fix this with a device API, you will be missing the bigger
picture.

> I should note that my original intent in engaging with this discussion
> was to gather thoughts from other members of the project wrt this sort
> of improvement before doing significant work on it, to avoid
> proceeding down a path which wouldn't go anywhere useful.

My advice is: before starting to work on code, discuss concrete details
of your project.

> I would prefer that you do not refrain from offering constructive
> criticism of "the VAAPI stuff", or anything else that I work on,
> should you have any.

I will refrain still, because I do not know anything about them.

Regards,

-- 
  Nicolas George


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avfilter: Added siti filter

2021-02-01 Thread Nicolas George
Werner Robitza (12021-01-22):
> Thanks, I know this, but this is not a known format that can be easily
> parsed like a plain CSV file.

What you need to do is to extend the metadata filter so that it lets
output to a file and choose the format.

Regards,

-- 
  Nicolas George


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 1/5] avformat/sbgdec: Use av_sat_add64() in str_to_time()

2021-02-01 Thread Michael Niedermayer
On Mon, Feb 01, 2021 at 11:39:42AM +0100, Nicolas George wrote:
> Michael Niedermayer (12021-01-31):
> > Fixes: signed integer overflow: 727999279212000 + 4611686018427387904 
> > cannot be represented in type 'long long'
> > Fixes: 
> > 29744/clusterfuzz-testcase-minimized-ffmpeg_dem_SBG_fuzzer-6434060249464832
> > 
> > Found-by: continuous fuzzing process 
> > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> > Signed-off-by: Michael Niedermayer 
> > ---
> >  libavformat/sbgdec.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> No objection.

will apply

thx

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Observe your enemies, for they first find out your faults. -- Antisthenes


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH] avfilter: add colorcorrect filter

2021-02-01 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 doc/filters.texi  |  33 +
 libavfilter/Makefile  |   1 +
 libavfilter/allfilters.c  |   1 +
 libavfilter/vf_colorcorrect.c | 218 ++
 4 files changed, 253 insertions(+)
 create mode 100644 libavfilter/vf_colorcorrect.c

diff --git a/doc/filters.texi b/doc/filters.texi
index 490586c063..2d85a414ec 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -8056,6 +8056,39 @@ Set the amount of preserving lightness. Default value is 
0.0. Allowed range is f
 
 This filter supports the all above options as @ref{commands}.
 
+@section colorcorrect
+
+Adjust color white balance selectively for blacks and whites.
+This filter operates in YUV colorspace.
+
+The filter accepts the following options:
+
+@table @option
+@item rl
+Set the red shadow spot. Allowed range is from -1.0 to 1.0.
+Default value is 0.
+
+@item bl
+Set the blue shadow spot. Allowed range is from -1.0 to 1.0.
+Default value is 0.
+
+@item rh
+Set the red highlight spot. Allowed range is from -1.0 to 1.0.
+Default value is 0.
+
+@item bh
+Set the red highlight spot. Allowed range is from -1.0 to 1.0.
+Default value is 0.
+
+@item saturation
+Set the amount of saturation. Allowed range is from -3.0 to 3.0.
+Default value is 1.
+@end table
+
+@subsection Commands
+
+This filter supports the all above options as @ref{commands}.
+
 @section colorchannelmixer
 
 Adjust video input frames by re-mixing color channels.
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 3a4d3d8e31..68ff8e26d2 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -197,6 +197,7 @@ OBJS-$(CONFIG_CODECVIEW_FILTER)  += 
vf_codecview.o qp_table.o
 OBJS-$(CONFIG_COLORBALANCE_FILTER)   += vf_colorbalance.o
 OBJS-$(CONFIG_COLORCHANNELMIXER_FILTER)  += vf_colorchannelmixer.o
 OBJS-$(CONFIG_COLORCONTRAST_FILTER)  += vf_colorcontrast.o
+OBJS-$(CONFIG_COLORCORRECT_FILTER)   += vf_colorcorrect.o
 OBJS-$(CONFIG_COLORKEY_FILTER)   += vf_colorkey.o
 OBJS-$(CONFIG_COLORKEY_OPENCL_FILTER)+= vf_colorkey_opencl.o opencl.o \
 opencl/colorkey.o
diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
index 6d269b48bf..3b4620a5d7 100644
--- a/libavfilter/allfilters.c
+++ b/libavfilter/allfilters.c
@@ -187,6 +187,7 @@ extern AVFilter ff_vf_codecview;
 extern AVFilter ff_vf_colorbalance;
 extern AVFilter ff_vf_colorchannelmixer;
 extern AVFilter ff_vf_colorcontrast;
+extern AVFilter ff_vf_colorcorrect;
 extern AVFilter ff_vf_colorkey;
 extern AVFilter ff_vf_colorkey_opencl;
 extern AVFilter ff_vf_colorhold;
diff --git a/libavfilter/vf_colorcorrect.c b/libavfilter/vf_colorcorrect.c
new file mode 100644
index 00..edb48c3ff6
--- /dev/null
+++ b/libavfilter/vf_colorcorrect.c
@@ -0,0 +1,218 @@
+/*
+ * Copyright (c) 2021 Paul B Mahol
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include 
+
+#include "libavutil/opt.h"
+#include "libavutil/imgutils.h"
+#include "avfilter.h"
+#include "formats.h"
+#include "internal.h"
+#include "video.h"
+
+typedef struct ColorCorrectContext {
+const AVClass *class;
+
+float rl, bl;
+float rh, bh;
+float saturation;
+
+int depth;
+
+int (*do_slice)(AVFilterContext *s, void *arg,
+int jobnr, int nb_jobs);
+} ColorCorrectContext;
+
+#define PROCESS()   \
+ny = y; \
+nu = saturation * (u + y * (bh - bl) + bl); \
+nv = saturation * (v + y * (rh - rl) + rl);
+
+static int colorcorrect_slice8(AVFilterContext *ctx, void *arg, int jobnr, int 
nb_jobs)
+{
+ColorCorrectContext *s = ctx->priv;
+AVFrame *frame = arg;
+const int width = frame->width;
+const int height = frame->height;
+const int slice_start = (height * jobnr) / nb_jobs;
+const int slice_end = (height * (jobnr + 1)) / nb_jobs;
+const int ylinesize = frame->linesize[0];
+const int ulinesize = frame->linesize[1];
+const int vlinesize = frame->linesize[2];
+uint8_t *yptr = frame->data[0] + slice_start * ylinesize;
+uint8_t *uptr = frame->data[1] + slice_start * ulinesize;
+uint8_t *vptr = frame->data[

Re: [FFmpeg-devel] [PATCH 04/13] avformat/rtmppkt: Remove ff_amf_read_bool

2021-02-01 Thread Andreas Rheinhardt
Andreas Rheinhardt:
> Added in 50468f93e3940ba78836dfdac5165c20ae75327a, but never used.
> 
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavformat/rtmppkt.c | 8 
>  libavformat/rtmppkt.h | 9 -
>  2 files changed, 17 deletions(-)
> 
> diff --git a/libavformat/rtmppkt.c b/libavformat/rtmppkt.c
> index 1eeae17337..0e61e83699 100644
> --- a/libavformat/rtmppkt.c
> +++ b/libavformat/rtmppkt.c
> @@ -84,14 +84,6 @@ void ff_amf_write_object_end(uint8_t **dst)
>  bytestream_put_be24(dst, AMF_DATA_TYPE_OBJECT_END);
>  }
>  
> -int ff_amf_read_bool(GetByteContext *bc, int *val)
> -{
> -if (bytestream2_get_byte(bc) != AMF_DATA_TYPE_BOOL)
> -return AVERROR_INVALIDDATA;
> -*val = bytestream2_get_byte(bc);
> -return 0;
> -}
> -
>  int ff_amf_read_number(GetByteContext *bc, double *val)
>  {
>  uint64_t read;
> diff --git a/libavformat/rtmppkt.h b/libavformat/rtmppkt.h
> index eb68f1d3e1..a15d2a5773 100644
> --- a/libavformat/rtmppkt.h
> +++ b/libavformat/rtmppkt.h
> @@ -259,15 +259,6 @@ void ff_amf_write_field_name(uint8_t **dst, const char 
> *str);
>   */
>  void ff_amf_write_object_end(uint8_t **dst);
>  
> -/**
> - * Read AMF boolean value.
> - *
> - *@param[in,out] gbc GetByteContext initialized with AMF-formatted data
> - *@param[out]val 0 or 1
> - *@return 0 on success or an AVERROR code on failure
> -*/
> -int ff_amf_read_bool(GetByteContext *gbc, int *val);
> -
>  /**
>   * Read AMF number value.
>   *
> Will apply the rest of this patchset tomorrow unless there are objections.

- Andreas
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 2/4] lav/dnxhd: CID 1256 is RGB, not BGR or YUV444

2021-02-01 Thread Christophe Gisquet
Hi,

Le dim. 31 janv. 2021 à 14:11, Michael Niedermayer
 a écrit :
> This transmutes the following dog into a hyperspace neon dog
> ./ffplay DNxHDtest2.mov

I'm not sure I prefer the correct version, but here goes. This sample
is YUV444 basically, the reverse of what I've seen in another sample.

-- 
Christophe


0002-lav-dnxhd-CID-1256-is-RGB-not-BGR-or-YUV444.patch
Description: Binary data
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH v6 1/3] avformat/mxfdec: set toolkit version metadata

2021-02-01 Thread Andreas Rheinhardt
Tomas Härdin:
> mån 2021-02-01 klockan 07:50 +0800 skrev lance.lmw...@gmail.com:
>> From: Limin Wang 
>>
>> Please check the string of toolkit version with below command:
>> ./ffmpeg -i ../fate-suite/mxf/Sony-1.mxf -c:v copy -c:a copy out.mxf
>> ./ffmpeg -i out.mxf
>> 
>> toolkit_version : 58.65.101
>>
>> Signed-off-by: Limin Wang 
>> ---
>>  libavformat/mxfdec.c| 25 +
>>  tests/ref/fate/mxf-probe-applehdr10 |  1 +
>>  tests/ref/fate/mxf-probe-dnxhd  |  1 +
>>  3 files changed, 27 insertions(+)
>>
>> diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
>> index afff204..61c8104 100644
>> --- a/libavformat/mxfdec.c
>> +++ b/libavformat/mxfdec.c
>> @@ -1970,6 +1970,18 @@ static int mxf_umid_to_str(UID ul, UID uid, char 
>> **str)
>>  return 0;
>>  }
>>  
>> +static int mxf_version_to_str(uint16_t major, uint16_t minor, uint16_t 
>> tertiary, char **str)
>> +{
>> +int size = sizeof(major) * 5 + 1;
> 
> This is just wrong. Should be 3*5+2+1 = 18.
> 
>> +
>> +*str = av_mallocz(size);
>> +if (!*str)
>> +return AVERROR(ENOMEM);
>> +
>> +snprintf(*str, size, "%d.%d.%d", major, minor, tertiary);
> 
> snprintf() is not safe - *str can end up not NUL terminated
> 
Not true -- snprintf always zero-terminates (and truncates the output if
it needs to do so) unless size is zero (which it is not).

But nevertheless av_asprintf would be better IMO.

- Andreas
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [RFC] Event loop

2021-02-01 Thread Nicolas George
Based on this discussion, I say that the need for an event loop is
confirmed.

I will now start discussing actual plans for going forward. Since the
coding work will be significant and not incremental, I want the outcome
of this discussion to be binding: if we agree to do it a certain way,
then the code for doing it will be accepted, pending code quality or new
unforeseen issues. If anybody objects to this, please explain your
reasons.

First, again: Why we need an event loop.

We need an event loop because we already have several ones. We already
have five protocols and two devices implementing their own event loops.
Factoring this duplicated code and implementing it properly is just the
obvious way forward.

Plus, it makes implementing new protocols simpler, especially when they
are somewhat complex. And it can make applications simpler.

So, my plan. Note that a lot of it will need to be ready before anything
can be applied.


1. Add an event loop to libavutil.

1.1. Add a simple event loop implementation.

It needs to be powerful enough to replace all our current needs:

- watching file descriptors;
- timeouts;
- low-latency I/O threads (for the UDP thread).

And I will add:

- threads for bulk tasks

because it is needed for something later (see below).

1.2. Add an event loop API to libavutil.

It will be mostly made with callbacks, so that applications can use
the event loop of their choice instead of the more limited one we
provide. But by default, it will use our implementation, of course.

I propose AVScheduler for the root structure of this API, and
av_scheduler as function prefix.

The API would consist of just a few entry points:

- allocate, init, free an AVScheduler;
- allocate, add, alter, remove, free events;
- start, run, stop the loop.

1.3. Implement a libev wrapper.

Implement the callbacks of the event loop API with libev as
back-end.

Make it either an example or a build option. A build option would
have the benefit of more extensive testing.


2. Add a callback-based API for protocols.

2.1. Implement the new API.

To use this, an application will:

- create an AVScheduler;
- attach its protocols to the AVScheduler;
- set the callbacks;
- if useful, set the buffers;
- run the AVScheduler.

As soon as the AVScheduler.

2.2. Implement a compatibility layer for new protocols.

Protocols using the new design need to be callable through the old
API. The compatibility layer will need to allocate an AVScheduler
just for this protocol, and start, run, stop it for each read or
write operation.

2.3. Port the low-level network protocols.

To get any benefit from this, at least TCP and UDP need to be
ported.

2.4. Implement a compatibility layer for old protocols.

We need to be able to still use the protocols that have not been
ported to the new design. It will involve reading or writing on them
with a short timeout. It is inefficient, but the same kind as
inefficient as we have now.

2.5. Port complex protocols.

To check that it works as expected, porting at least one of the
protocols that use several sockets is necessary.


3. Use the even loop for running libavfilter.

The reason I want threads for bulk tasks is that we can then use
them for inter-filter threading. Having a well-designed event loop
in libavutil will give us a better API and parallelism for
libavfilter for very little effort.


4. Use the new API in the fftools.

This is necessary to prove the API works.


This is it, please share your comments.

Regards,

-- 
  Nicolas George


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH v6 1/3] avformat/mxfdec: set toolkit version metadata

2021-02-01 Thread Tomas Härdin
mån 2021-02-01 klockan 18:23 +0100 skrev Andreas Rheinhardt:
> Tomas Härdin:
> > mån 2021-02-01 klockan 07:50 +0800 skrev lance.lmw...@gmail.com:
> > > From: Limin Wang 
> > > 
> > > Please check the string of toolkit version with below command:
> > > ./ffmpeg -i ../fate-suite/mxf/Sony-1.mxf -c:v copy -c:a copy out.mxf
> > > ./ffmpeg -i out.mxf
> > > 
> > > toolkit_version : 58.65.101
> > > 
> > > Signed-off-by: Limin Wang 
> > > ---
> > >  libavformat/mxfdec.c| 25 +
> > >  tests/ref/fate/mxf-probe-applehdr10 |  1 +
> > >  tests/ref/fate/mxf-probe-dnxhd  |  1 +
> > >  3 files changed, 27 insertions(+)
> > > 
> > > diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
> > > index afff204..61c8104 100644
> > > --- a/libavformat/mxfdec.c
> > > +++ b/libavformat/mxfdec.c
> > > @@ -1970,6 +1970,18 @@ static int mxf_umid_to_str(UID ul, UID uid, char 
> > > **str)
> > >  return 0;
> > >  }
> > >  
> > > +static int mxf_version_to_str(uint16_t major, uint16_t minor, uint16_t 
> > > tertiary, char **str)
> > > +{
> > > +int size = sizeof(major) * 5 + 1;
> > 
> > This is just wrong. Should be 3*5+2+1 = 18.
> > 
> > > +
> > > +*str = av_mallocz(size);
> > > +if (!*str)
> > > +return AVERROR(ENOMEM);
> > > +
> > > +snprintf(*str, size, "%d.%d.%d", major, minor, tertiary);
> > 
> > snprintf() is not safe - *str can end up not NUL terminated
> > 
> Not true -- snprintf always zero-terminates (and truncates the output if
> it needs to do so) unless size is zero (which it is not).

Ack, you're right. I was thinking of strn*

> But nevertheless av_asprintf would be better IMO.

Yes

/Tomas

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH v6 1/3] avformat/mxfdec: set toolkit version metadata

2021-02-01 Thread Marton Balint



On Mon, 1 Feb 2021, lance.lmw...@gmail.com wrote:


From: Limin Wang 

Please check the string of toolkit version with below command:
./ffmpeg -i ../fate-suite/mxf/Sony-1.mxf -c:v copy -c:a copy out.mxf
./ffmpeg -i out.mxf

toolkit_version : 58.65.101

Signed-off-by: Limin Wang 
---
libavformat/mxfdec.c| 25 +
tests/ref/fate/mxf-probe-applehdr10 |  1 +
tests/ref/fate/mxf-probe-dnxhd  |  1 +
3 files changed, 27 insertions(+)

diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
index afff204..61c8104 100644
--- a/libavformat/mxfdec.c
+++ b/libavformat/mxfdec.c
@@ -1970,6 +1970,18 @@ static int mxf_umid_to_str(UID ul, UID uid, char **str)
return 0;
}

+static int mxf_version_to_str(uint16_t major, uint16_t minor, uint16_t 
tertiary, char **str)
+{
+int size = sizeof(major) * 5 + 1;
+
+*str = av_mallocz(size);
+if (!*str)
+return AVERROR(ENOMEM);
+
+snprintf(*str, size, "%d.%d.%d", major, minor, tertiary);


ToolkitVersion is a ProductVersion which means it consists of 5 UInt16 
numbers, not 3. So you should present all 5 values.


Regards,
Marton
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [RFC] Event loop

2021-02-01 Thread Paul B Mahol
On Mon, Feb 1, 2021 at 8:14 PM Nicolas George  wrote:

> Based on this discussion, I say that the need for an event loop is
> confirmed.
>
> I will now start discussing actual plans for going forward. Since the
> coding work will be significant and not incremental, I want the outcome
> of this discussion to be binding: if we agree to do it a certain way,
> then the code for doing it will be accepted, pending code quality or new
> unforeseen issues. If anybody objects to this, please explain your
> reasons.
>
> First, again: Why we need an event loop.
>
> We need an event loop because we already have several ones. We already
> have five protocols and two devices implementing their own event loops.
> Factoring this duplicated code and implementing it properly is just the
> obvious way forward.
>
> Plus, it makes implementing new protocols simpler, especially when they
> are somewhat complex. And it can make applications simpler.
>
> So, my plan. Note that a lot of it will need to be ready before anything
> can be applied.
>
>
> 1. Add an event loop to libavutil.
>
> 1.1. Add a simple event loop implementation.
>
> It needs to be powerful enough to replace all our current needs:
>
> - watching file descriptors;
> - timeouts;
> - low-latency I/O threads (for the UDP thread).
>
> And I will add:
>
> - threads for bulk tasks
>
> because it is needed for something later (see below).
>
> 1.2. Add an event loop API to libavutil.
>
> It will be mostly made with callbacks, so that applications can use
> the event loop of their choice instead of the more limited one we
> provide. But by default, it will use our implementation, of course.
>
> I propose AVScheduler for the root structure of this API, and
> av_scheduler as function prefix.
>
> The API would consist of just a few entry points:
>
> - allocate, init, free an AVScheduler;
> - allocate, add, alter, remove, free events;
> - start, run, stop the loop.
>
> 1.3. Implement a libev wrapper.
>
> Implement the callbacks of the event loop API with libev as
> back-end.
>
> Make it either an example or a build option. A build option would
> have the benefit of more extensive testing.
>
>
> 2. Add a callback-based API for protocols.
>
> 2.1. Implement the new API.
>
> To use this, an application will:
>
> - create an AVScheduler;
> - attach its protocols to the AVScheduler;
> - set the callbacks;
> - if useful, set the buffers;
> - run the AVScheduler.
>
> As soon as the AVScheduler.
>
> 2.2. Implement a compatibility layer for new protocols.
>
> Protocols using the new design need to be callable through the old
> API. The compatibility layer will need to allocate an AVScheduler
> just for this protocol, and start, run, stop it for each read or
> write operation.
>
> 2.3. Port the low-level network protocols.
>
> To get any benefit from this, at least TCP and UDP need to be
> ported.
>
> 2.4. Implement a compatibility layer for old protocols.
>
> We need to be able to still use the protocols that have not been
> ported to the new design. It will involve reading or writing on them
> with a short timeout. It is inefficient, but the same kind as
> inefficient as we have now.
>
> 2.5. Port complex protocols.
>
> To check that it works as expected, porting at least one of the
> protocols that use several sockets is necessary.
>
>
> 3. Use the even loop for running libavfilter.
>
> The reason I want threads for bulk tasks is that we can then use
> them for inter-filter threading. Having a well-designed event loop
> in libavutil will give us a better API and parallelism for
> libavfilter for very little effort.
>

Why event loop is needed for filters?

libavcodec have frame threads and it does not need it.



>
>
> 4. Use the new API in the fftools.
>
> This is necessary to prove the API works.
>
>
> This is it, please share your comments.
>
> Regards,
>
> --
>   Nicolas George
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [RFC] Event loop

2021-02-01 Thread Nicolas George
Paul B Mahol (12021-02-01):
> Why event loop is needed for filters?
> 
> libavcodec have frame threads and it does not need it.

libavcodec has its own scheduler. Duplicated code everywhere.

-- 
  Nicolas George


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [RFC] Event loop

2021-02-01 Thread James Almer

On 2/1/2021 4:14 PM, Nicolas George wrote:

1.3. Implement a libev wrapper.

 Implement the callbacks of the event loop API with libev as
 back-end.

 Make it either an example or a build option. A build option would
 have the benefit of more extensive testing.


I support the idea of it being a build option (Perhaps simply 
--enable-libev, like any other external dep). There's a precedent of 
external libraries being used as backend for certain features, with the 
most prominent example being libsoxr as the resample engine in 
libswresample.


This of course as long as it's not autodetected, so FATE clients don't 
use it. The last thing we want is the internal implementation being 
neglected because all devs use libev.

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 3/8] avcodec/utils: Use more bits for intermediate for AV_CODEC_ID_ADPCM_MS

2021-02-01 Thread Michael Niedermayer
Fixes: signed integer overflow: 1172577312 * 2 cannot be represented in type 
'int'
Fixes: 
29924/clusterfuzz-testcase-minimized-ffmpeg_dem_BOA_fuzzer-4882912874594304

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 
---
 libavcodec/utils.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index a1ae9cab18..8be4c4949c 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -1786,7 +1786,7 @@ static int get_audio_frame_duration(enum AVCodecID id, 
int sr, int ch, int ba,
 case AV_CODEC_ID_ADPCM_IMA_RAD:
 return blocks * ((ba - 4 * ch) * 2 / ch);
 case AV_CODEC_ID_ADPCM_MS:
-return blocks * (2 + (ba - 7 * ch) * 2 / ch);
+return blocks * (2 + (ba - 7 * ch) * 2LL / ch);
 case AV_CODEC_ID_ADPCM_MTAF:
 return blocks * (ba - 16) * 2 / ch;
 }
-- 
2.17.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 1/8] avcodec/cbs_sei_syntax_template: Check for non negativity before setting size_t bits_left

2021-02-01 Thread Michael Niedermayer
Fixes: Timeout
Fixes: 
29892/clusterfuzz-testcase-minimized-ffmpeg_BSF_H264_REDUNDANT_PPS_fuzzer-6310830956216320

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 
---
 libavcodec/cbs_sei_syntax_template.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libavcodec/cbs_sei_syntax_template.c 
b/libavcodec/cbs_sei_syntax_template.c
index 9114e61ff6..3b9bc942f5 100644
--- a/libavcodec/cbs_sei_syntax_template.c
+++ b/libavcodec/cbs_sei_syntax_template.c
@@ -178,6 +178,8 @@ static int FUNC(message)(CodedBitstreamContext *ctx, 
RWContext *rw,
 GetBitContext tmp = *rw;
 int trailing_bits, trailing_zero_bits;
 
+if (8 * current->payload_size < bits_written)
+return AVERROR_INVALIDDATA;
 bits_left = 8 * current->payload_size - bits_written;
 if (bits_left > 8)
 skip_bits_long(&tmp, bits_left - 8);
-- 
2.17.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 2/8] avformat/ipmovie: Free packets allocated in header reading

2021-02-01 Thread Michael Niedermayer
Fixes: memleaks
Fixes: 
29905/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5679700745781248

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 
---
 libavformat/ipmovie.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/libavformat/ipmovie.c b/libavformat/ipmovie.c
index 137c857700..3234d591da 100644
--- a/libavformat/ipmovie.c
+++ b/libavformat/ipmovie.c
@@ -661,8 +661,10 @@ static int ipmovie_read_header(AVFormatContext *s)
 ipmovie->palette[i] = 0xFFU << 24;
 
 /* process the first chunk which should be CHUNK_INIT_VIDEO */
-if (process_ipmovie_chunk(ipmovie, pb, &pkt) != CHUNK_INIT_VIDEO)
+if (process_ipmovie_chunk(ipmovie, pb, &pkt) != CHUNK_INIT_VIDEO) {
+av_packet_unref(&pkt);
 return AVERROR_INVALIDDATA;
+}
 
 /* peek ahead to the next chunk-- if it is an init audio chunk, process
  * it; if it is the first video chunk, this is a silent file */
@@ -674,8 +676,10 @@ static int ipmovie_read_header(AVFormatContext *s)
 
 if (chunk_type == CHUNK_VIDEO)
 ipmovie->audio_type = AV_CODEC_ID_NONE;  /* no audio */
-else if (process_ipmovie_chunk(ipmovie, pb, &pkt) != CHUNK_INIT_AUDIO)
+else if (process_ipmovie_chunk(ipmovie, pb, &pkt) != CHUNK_INIT_AUDIO) {
+av_packet_unref(&pkt);
 return AVERROR_INVALIDDATA;
+}
 
 /* initialize the stream decoders */
 st = avformat_new_stream(s, NULL);
-- 
2.17.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 6/8] avcodec/cri: Use ff_set_dimensions()

2021-02-01 Thread Michael Niedermayer
Fixes: out of memory
Fixes: 
29985/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CRI_fuzzer-6424425392111616

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 
---
 libavcodec/cri.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/libavcodec/cri.c b/libavcodec/cri.c
index 2d33b54e42..3312606b75 100644
--- a/libavcodec/cri.c
+++ b/libavcodec/cri.c
@@ -184,6 +184,7 @@ static int cri_decode_frame(AVCodecContext *avctx, void 
*data,
 char codec_name[1024];
 uint32_t key, length;
 float framerate;
+int width, height;
 
 key= bytestream2_get_le32(gb);
 length = bytestream2_get_le32(gb);
@@ -199,11 +200,14 @@ static int cri_decode_frame(AVCodecContext *avctx, void 
*data,
 case 100:
 if (length < 16)
 return AVERROR_INVALIDDATA;
-avctx->width   = bytestream2_get_le32(gb);
-avctx->height  = bytestream2_get_le32(gb);
+width   = bytestream2_get_le32(gb);
+height  = bytestream2_get_le32(gb);
 s->color_model = bytestream2_get_le32(gb);
 if (bytestream2_get_le32(gb) != 1)
 return AVERROR_INVALIDDATA;
+ret = ff_set_dimensions(avctx, width, height);
+if (ret < 0)
+return ret;
 length -= 16;
 goto skip;
 case 101:
-- 
2.17.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 7/8] tools/target_dec_fuzzer: Update maxpixels_per_frame for low thresholds

2021-02-01 Thread Michael Niedermayer
Fixes: Timeout
Fixes: 
29990/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MSS2_fuzzer-5469155073589248

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 
---
 tools/target_dec_fuzzer.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tools/target_dec_fuzzer.c b/tools/target_dec_fuzzer.c
index affa6e3b51..728a6bb065 100644
--- a/tools/target_dec_fuzzer.c
+++ b/tools/target_dec_fuzzer.c
@@ -98,7 +98,7 @@ static int audio_video_handler(AVCodecContext *avctx, AVFrame 
*frame,
 
 // Ensure we don't loop forever
 const uint32_t maxiteration = 8096;
-const uint64_t maxpixels_per_frame = 4096 * 4096;
+uint64_t maxpixels_per_frame = 4096 * 4096;
 uint64_t maxpixels;
 
 uint64_t maxsamples_per_frame = 256*1024*32;
@@ -194,6 +194,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t 
size) {
 }
 
 maxsamples_per_frame = FFMIN(maxsamples_per_frame, maxsamples);
+maxpixels_per_frame  = FFMIN(maxpixels_per_frame , maxpixels);
 
 AVCodecContext* ctx = avcodec_alloc_context3(c);
 AVCodecContext* parser_avctx = avcodec_alloc_context3(NULL);
-- 
2.17.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 5/8] avcodec/cri: Stop the bitreader at the end of uncompressed input

2021-02-01 Thread Michael Niedermayer
Fixes: Timeout
Fixes: 
29983/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CRI_fuzzer-6420415838814208

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 
---
 libavcodec/cri.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libavcodec/cri.c b/libavcodec/cri.c
index f7c3b4ef48..2d33b54e42 100644
--- a/libavcodec/cri.c
+++ b/libavcodec/cri.c
@@ -331,6 +331,9 @@ skip:
 for (int y = 0; y < avctx->height; y++) {
 uint16_t *dst = (uint16_t *)(p->data[0] + y * p->linesize[0]);
 
+if (get_bits_left(&gbit) < avctx->width * bps)
+break;
+
 for (int x = 0; x < avctx->width; x++)
 dst[x] = get_bits(&gbit, bps) << shift;
 }
-- 
2.17.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 8/8] avcodec/exr: Check col/line for integer overflow

2021-02-01 Thread Michael Niedermayer
Fixes: signed integer overflow: -2272 + -2147483360 cannot be represented in 
type 'int'
Fixes: 
30009/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_EXR_fuzzer-5005660322398208

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 
---
 libavcodec/exr.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/libavcodec/exr.c b/libavcodec/exr.c
index 6e6ce4275c..752ab17d7a 100644
--- a/libavcodec/exr.c
+++ b/libavcodec/exr.c
@@ -1029,6 +1029,11 @@ static int decode_block(AVCodecContext *avctx, void 
*tdata,
 return AVERROR_PATCHWELCOME;
 }
 
+if (tile_x && s->tile_attr.xSize + (int64_t)FFMAX(s->xmin, 0) >= 
INT_MAX / tile_x )
+return AVERROR_INVALIDDATA;
+if (tile_y && s->tile_attr.ySize + (int64_t)FFMAX(s->ymin, 0) >= 
INT_MAX / tile_y )
+return AVERROR_INVALIDDATA;
+
 line = s->ymin + s->tile_attr.ySize * tile_y;
 col = s->tile_attr.xSize * tile_x;
 
-- 
2.17.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 4/8] avformat/mxfdec: Fix file position addition

2021-02-01 Thread Michael Niedermayer
Not sure this is the best solution, maybe a more general solution limiting the 
avio_tell() output to less than 63bit would be a better option
Fixes: signed integer overflow: 9223372036854775805 + 4 cannot be represented 
in type 'long'
Fixes: 
29927/clusterfuzz-testcase-minimized-ffmpeg_dem_MXF_fuzzer-5579985228267520

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 
---
 libavformat/mxfdec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
index afff20402d..97a1b749fe 100644
--- a/libavformat/mxfdec.c
+++ b/libavformat/mxfdec.c
@@ -2861,7 +2861,7 @@ static int mxf_read_local_tags(MXFContext *mxf, KLVPacket 
*klv, MXFMetadataReadF
 return AVERROR(ENOMEM);
 if (ctx_size)
 mxf_metadataset_init(ctx, type);
-while (avio_tell(pb) + 4 < klv_end && !avio_feof(pb)) {
+while (avio_tell(pb) + (uint64_t)4 < klv_end && !avio_feof(pb)) {
 int ret;
 int tag = avio_rb16(pb);
 int size = avio_rb16(pb); /* KLV specified by 0x53 */
-- 
2.17.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 00/10] deprecate av_init_packet() and sizeof(AVPacket) as part of the ABI

2021-02-01 Thread James Almer
As the subject says, this puts AVPacket in line with AVFrame, allowing
easier extensibility of the struct, and preventing potential undefined behavior
in some cases when packets are used uninitialized on stack.

This set adapts only a few modules, examples, and the tools, as those were the
most complex and the ones that better reflect how AVPackets must be used after
the deprecation period.
I have a branch ready removing every other instance of av_init_packet() in the
tree, and all uses of AVPacket on stack i could find. They are pretty trivial,
so i wont bother spamming the ML with 40+ patches until the core changes are
upstreamed. It's also not exhaustive, as i'm sure i missed a few cases of stack
usage, but they can be removed any time between the deprecation of public
sizeof(AVPacket) and it's effective removal 2+ years from now.
Then there's the few cases where an AVPacket is part of another public struct,
as is the case of AVPacketList, or attached_pic in AVSteam. The latter i could
adapt right now, but it would mean a lot of preprocessor checks littering the
codebase until removed, so i refrained from doing so.

James Almer (10):
  avformat/mux: use av_packet_alloc() to allocate packets
  avformat/movenc: use av_packet_alloc() to allocate packets
  avformat/utils: use av_packet_alloc() to allocate packets
  doc/examples/demuxing_decoding: use av_packet_alloc() to allocate
packets
  doc/examples/transcode_aac: use av_packet_alloc() to allocate packets
  doc/examples/transcoding: use av_packet_alloc() to allocate packets
  fftools/ffprobe: use av_packet_alloc() to allocate packets
  fftools/ffmpeg: use av_packet_alloc() to allocate packets
  fftools/ffplay: use av_packet_alloc() to allocate packets
  avcodec/packet: deprecate av_init_packet()

 doc/examples/demuxing_decoding.c |  25 +--
 doc/examples/transcode_aac.c |  46 +++--
 doc/examples/transcoding.c   |  48 +++--
 fftools/ffmpeg.c | 318 ---
 fftools/ffmpeg.h |   4 +
 fftools/ffmpeg_opt.c |   5 +-
 fftools/ffplay.c | 222 -
 fftools/ffprobe.c|  34 ++--
 libavcodec/avpacket.c|  23 ++-
 libavcodec/packet.h  |  23 ++-
 libavcodec/version.h |   3 +
 libavformat/avformat.h   |   4 +
 libavformat/internal.h   |   6 +
 libavformat/movenc.c | 101 ++
 libavformat/movenc.h |   2 +
 libavformat/movenchint.c |  19 +-
 libavformat/mux.c|  44 +++--
 libavformat/options.c|   9 +
 libavformat/utils.c  | 106 ++-
 19 files changed, 613 insertions(+), 429 deletions(-)

-- 
2.30.0

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 01/10] avformat/mux: use av_packet_alloc() to allocate packets

2021-02-01 Thread James Almer
Signed-off-by: James Almer 
---
 libavformat/internal.h |  5 +
 libavformat/mux.c  | 40 
 libavformat/options.c  |  6 ++
 libavformat/utils.c|  1 +
 4 files changed, 32 insertions(+), 20 deletions(-)

diff --git a/libavformat/internal.h b/libavformat/internal.h
index f45b1cd6b4..2fe1afa8e3 100644
--- a/libavformat/internal.h
+++ b/libavformat/internal.h
@@ -92,6 +92,11 @@ struct AVFormatInternal {
  */
 struct AVPacketList *parse_queue;
 struct AVPacketList *parse_queue_end;
+
+/**
+ * Used to hold temporary packets.
+ */
+AVPacket *pkt;
 /**
  * Remaining size available for raw_packet_buffer, in bytes.
  */
diff --git a/libavformat/mux.c b/libavformat/mux.c
index 84c56ac6ba..ce9724e834 100644
--- a/libavformat/mux.c
+++ b/libavformat/mux.c
@@ -1208,7 +1208,7 @@ static int write_packets_common(AVFormatContext *s, 
AVPacket *pkt, int interleav
 
 int av_write_frame(AVFormatContext *s, AVPacket *in)
 {
-AVPacket local_pkt, *pkt = &local_pkt;
+AVPacket *pkt = s->internal->pkt;
 int ret;
 
 if (!in) {
@@ -1229,6 +1229,7 @@ int av_write_frame(AVFormatContext *s, AVPacket *in)
  * The following avoids copying in's data unnecessarily.
  * Copying side data is unavoidable as a bitstream filter
  * may change it, e.g. free it on errors. */
+av_packet_unref(pkt);
 pkt->buf  = NULL;
 pkt->data = in->data;
 pkt->size = in->size;
@@ -1270,14 +1271,14 @@ int av_interleaved_write_frame(AVFormatContext *s, 
AVPacket *pkt)
 int av_write_trailer(AVFormatContext *s)
 {
 int i, ret1, ret = 0;
-AVPacket pkt = {0};
-av_init_packet(&pkt);
+AVPacket *pkt = s->internal->pkt;
 
+av_packet_unref(pkt);
 for (i = 0; i < s->nb_streams; i++) {
 if (s->streams[i]->internal->bsfc) {
-ret1 = write_packets_from_bsfs(s, s->streams[i], &pkt, 
1/*interleaved*/);
+ret1 = write_packets_from_bsfs(s, s->streams[i], pkt, 
1/*interleaved*/);
 if (ret1 < 0)
-av_packet_unref(&pkt);
+av_packet_unref(pkt);
 if (ret >= 0)
 ret = ret1;
 }
@@ -1351,7 +1352,7 @@ static void uncoded_frame_free(void *unused, uint8_t 
*data)
 static int write_uncoded_frame_internal(AVFormatContext *s, int stream_index,
 AVFrame *frame, int interleaved)
 {
-AVPacket pkt, *pktp;
+AVPacket *pkt = s->internal->pkt;
 
 av_assert0(s->oformat);
 if (!s->oformat->write_uncoded_frame) {
@@ -1360,18 +1361,17 @@ static int write_uncoded_frame_internal(AVFormatContext 
*s, int stream_index,
 }
 
 if (!frame) {
-pktp = NULL;
+pkt = NULL;
 } else {
 size_t   bufsize = sizeof(frame) + AV_INPUT_BUFFER_PADDING_SIZE;
 AVFrame **framep = av_mallocz(bufsize);
 
 if (!framep)
 goto fail;
-pktp = &pkt;
-av_init_packet(&pkt);
-pkt.buf = av_buffer_create((void *)framep, bufsize,
+av_packet_unref(pkt);
+pkt->buf = av_buffer_create((void *)framep, bufsize,
uncoded_frame_free, NULL, 0);
-if (!pkt.buf) {
+if (!pkt->buf) {
 av_free(framep);
 fail:
 av_frame_free(&frame);
@@ -1379,17 +1379,17 @@ static int write_uncoded_frame_internal(AVFormatContext 
*s, int stream_index,
 }
 *framep = frame;
 
-pkt.data = (void *)framep;
-pkt.size = sizeof(frame);
-pkt.pts  =
-pkt.dts  = frame->pts;
-pkt.duration = frame->pkt_duration;
-pkt.stream_index = stream_index;
-pkt.flags |= AV_PKT_FLAG_UNCODED_FRAME;
+pkt->data = (void *)framep;
+pkt->size = sizeof(frame);
+pkt->pts  =
+pkt->dts  = frame->pts;
+pkt->duration = frame->pkt_duration;
+pkt->stream_index = stream_index;
+pkt->flags |= AV_PKT_FLAG_UNCODED_FRAME;
 }
 
-return interleaved ? av_interleaved_write_frame(s, pktp) :
- av_write_frame(s, pktp);
+return interleaved ? av_interleaved_write_frame(s, pkt) :
+ av_write_frame(s, pkt);
 }
 
 int av_write_uncoded_frame(AVFormatContext *s, int stream_index,
diff --git a/libavformat/options.c b/libavformat/options.c
index 59e0389815..2de2db8f09 100644
--- a/libavformat/options.c
+++ b/libavformat/options.c
@@ -222,6 +222,12 @@ AVFormatContext *avformat_alloc_context(void)
 }
 avformat_get_context_defaults(ic);
 ic->internal = internal;
+ic->internal->pkt = av_packet_alloc();
+if (!ic->internal->pkt) {
+av_free(ic->internal);
+av_free(ic);
+return NULL;
+}
 ic->internal->offset = AV_NOPTS_VALUE;
 ic->internal->raw_packet_buffer_remaining_size = RAW_PACKET_BUFFER_SIZE;
 ic->i

[FFmpeg-devel] [PATCH 03/10] avformat/utils: use av_packet_alloc() to allocate packets

2021-02-01 Thread James Almer
Signed-off-by: James Almer 
---
av_get_packet() and av_read_frame() were allowed to be called with
uninitialized packets in stack, so to keep supporting that we need to leave the
calls to av_init_packet() in place during the deprecation period.

 libavformat/internal.h |   1 +
 libavformat/options.c  |  13 +++--
 libavformat/utils.c| 105 +++--
 3 files changed, 68 insertions(+), 51 deletions(-)

diff --git a/libavformat/internal.h b/libavformat/internal.h
index 2fe1afa8e3..ff8b657343 100644
--- a/libavformat/internal.h
+++ b/libavformat/internal.h
@@ -90,6 +90,7 @@ struct AVFormatInternal {
 /**
  * Packets split by the parser get queued here.
  */
+AVPacket *parse_pkt;
 struct AVPacketList *parse_queue;
 struct AVPacketList *parse_queue_end;
 
diff --git a/libavformat/options.c b/libavformat/options.c
index 2de2db8f09..07403b533e 100644
--- a/libavformat/options.c
+++ b/libavformat/options.c
@@ -220,14 +220,17 @@ AVFormatContext *avformat_alloc_context(void)
 av_free(ic);
 return NULL;
 }
-avformat_get_context_defaults(ic);
-ic->internal = internal;
-ic->internal->pkt = av_packet_alloc();
-if (!ic->internal->pkt) {
-av_free(ic->internal);
+internal->pkt = av_packet_alloc();
+internal->parse_pkt = av_packet_alloc();
+if (!internal->pkt || !internal->parse_pkt) {
+av_packet_free(&internal->pkt);
+av_packet_free(&internal->parse_pkt);
+av_free(internal);
 av_free(ic);
 return NULL;
 }
+avformat_get_context_defaults(ic);
+ic->internal = internal;
 ic->internal->offset = AV_NOPTS_VALUE;
 ic->internal->raw_packet_buffer_remaining_size = RAW_PACKET_BUFFER_SIZE;
 ic->internal->shortest_end = AV_NOPTS_VALUE;
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 2587bedc05..8cd5d0760f 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -309,9 +309,15 @@ static int append_packet_chunked(AVIOContext *s, AVPacket 
*pkt, int size)
 
 int av_get_packet(AVIOContext *s, AVPacket *pkt, int size)
 {
+#if FF_API_INIT_PACKET
+FF_DISABLE_DEPRECATION_WARNINGS
 av_init_packet(pkt);
 pkt->data = NULL;
 pkt->size = 0;
+FF_ENABLE_DEPRECATION_WARNINGS
+#else
+av_packet_unref(pkt);
+#endif
 pkt->pos  = avio_tell(s);
 
 return append_packet_chunked(s, pkt, size);
@@ -799,9 +805,7 @@ int ff_read_packet(AVFormatContext *s, AVPacket *pkt)
 int ret, i, err;
 AVStream *st;
 
-pkt->data = NULL;
-pkt->size = 0;
-av_init_packet(pkt);
+av_packet_unref(pkt);
 
 for (;;) {
 AVPacketList *pktl = s->internal->raw_packet_buffer;
@@ -1401,14 +1405,14 @@ FF_ENABLE_DEPRECATION_WARNINGS
 static int parse_packet(AVFormatContext *s, AVPacket *pkt,
 int stream_index, int flush)
 {
-AVPacket out_pkt;
+AVPacket *out_pkt = s->internal->parse_pkt;
 AVStream *st = s->streams[stream_index];
 uint8_t *data = pkt->data;
 int size  = pkt->size;
 int ret = 0, got_output = flush;
 
 if (size || flush) {
-av_init_packet(&out_pkt);
+av_packet_unref(out_pkt);
 } else if (st->parser->flags & PARSER_FLAG_COMPLETE_FRAMES) {
 // preserve 0-size sync packets
 compute_pkt_fields(s, st, st->parser, pkt, AV_NOPTS_VALUE, 
AV_NOPTS_VALUE);
@@ -1420,7 +1424,7 @@ static int parse_packet(AVFormatContext *s, AVPacket *pkt,
 int64_t next_dts = pkt->dts;
 
 len = av_parser_parse2(st->parser, st->internal->avctx,
-   &out_pkt.data, &out_pkt.size, data, size,
+   &out_pkt->data, &out_pkt->size, data, size,
pkt->pts, pkt->dts, pkt->pos);
 
 pkt->pts = pkt->dts = AV_NOPTS_VALUE;
@@ -1429,39 +1433,39 @@ static int parse_packet(AVFormatContext *s, AVPacket 
*pkt,
 data += len;
 size -= len;
 
-got_output = !!out_pkt.size;
+got_output = !!out_pkt->size;
 
-if (!out_pkt.size)
+if (!out_pkt->size)
 continue;
 
-if (pkt->buf && out_pkt.data == pkt->data) {
-/* reference pkt->buf only when out_pkt.data is guaranteed to point
+if (pkt->buf && out_pkt->data == pkt->data) {
+/* reference pkt->buf only when out_pkt->data is guaranteed to 
point
  * to data in it and not in the parser's internal buffer. */
 /* XXX: Ensure this is the case with all parsers when 
st->parser->flags
  * is PARSER_FLAG_COMPLETE_FRAMES and check for that instead? */
-out_pkt.buf = av_buffer_ref(pkt->buf);
-if (!out_pkt.buf) {
+out_pkt->buf = av_buffer_ref(pkt->buf);
+if (!out_pkt->buf) {
 ret = AVERROR(ENOMEM);
 goto fail;
 }
 } else {
-ret = av_packet_make_refcounted(&out_pkt);
+ret = av_packet_make_refcounted(

[FFmpeg-devel] [PATCH 02/10] avformat/movenc: use av_packet_alloc() to allocate packets

2021-02-01 Thread James Almer
Signed-off-by: James Almer 
---
 libavformat/movenc.c | 101 ---
 libavformat/movenc.h |   2 +
 libavformat/movenchint.c |  19 
 libavformat/mux.c|   4 +-
 4 files changed, 77 insertions(+), 49 deletions(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 372c04295d..254677a331 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -365,7 +365,7 @@ static int mov_write_ac3_tag(AVFormatContext *s, 
AVIOContext *pb, MOVTrack *trac
 }
 
 struct eac3_info {
-AVPacket pkt;
+AVPacket *pkt;
 uint8_t ec3_done;
 uint8_t num_blocks;
 
@@ -407,6 +407,9 @@ static int handle_eac3(MOVMuxContext *mov, AVPacket *pkt, 
MOVTrack *track)
 return AVERROR(ENOMEM);
 info = track->eac3_priv;
 
+if (!info->pkt && !(info->pkt = av_packet_alloc()))
+return AVERROR(ENOMEM);
+
 if (avpriv_ac3_parse_header(&hdr, pkt->data, pkt->size) < 0) {
 /* drop the packets until we see a good one */
 if (!track->entry) {
@@ -511,20 +514,20 @@ concatenate:
 }
 
 if (!info->num_blocks) {
-ret = av_packet_ref(&info->pkt, pkt);
+ret = av_packet_ref(info->pkt, pkt);
 if (!ret)
 info->num_blocks = num_blocks;
 goto end;
 } else {
-if ((ret = av_grow_packet(&info->pkt, pkt->size)) < 0)
+if ((ret = av_grow_packet(info->pkt, pkt->size)) < 0)
 goto end;
-memcpy(info->pkt.data + info->pkt.size - pkt->size, pkt->data, 
pkt->size);
+memcpy(info->pkt->data + info->pkt->size - pkt->size, pkt->data, 
pkt->size);
 info->num_blocks += num_blocks;
-info->pkt.duration += pkt->duration;
+info->pkt->duration += pkt->duration;
 if (info->num_blocks != 6)
 goto end;
 av_packet_unref(pkt);
-av_packet_move_ref(pkt, &info->pkt);
+av_packet_move_ref(pkt, info->pkt);
 info->num_blocks = 0;
 }
 ret = pkt->size;
@@ -5303,16 +5306,17 @@ static int mov_flush_fragment(AVFormatContext *s, int 
force)
 for (i = 0; i < s->nb_streams; i++) {
 MOVTrack *track = &mov->tracks[i];
 if (!track->end_reliable) {
-AVPacket pkt;
-if (!ff_interleaved_peek(s, i, &pkt, 1)) {
+AVPacket *pkt = mov->pkt;
+if (!ff_interleaved_peek(s, i, pkt, 1)) {
 if (track->dts_shift != AV_NOPTS_VALUE)
-pkt.dts += track->dts_shift;
-track->track_duration = pkt.dts - track->start_dts;
-if (pkt.pts != AV_NOPTS_VALUE)
-track->end_pts = pkt.pts;
+pkt->dts += track->dts_shift;
+track->track_duration = pkt->dts - track->start_dts;
+if (pkt->pts != AV_NOPTS_VALUE)
+track->end_pts = pkt->pts;
 else
-track->end_pts = pkt.dts;
+track->end_pts = pkt->dts;
 }
+av_packet_unref(pkt);
 }
 }
 
@@ -5965,20 +5969,20 @@ static int mov_write_single_packet(AVFormatContext *s, 
AVPacket *pkt)
 static int mov_write_subtitle_end_packet(AVFormatContext *s,
  int stream_index,
  int64_t dts) {
-AVPacket end;
+MOVMuxContext *mov = s->priv_data;
+AVPacket *end = mov->pkt;
 uint8_t data[2] = {0};
 int ret;
 
-av_init_packet(&end);
-end.size = sizeof(data);
-end.data = data;
-end.pts = dts;
-end.dts = dts;
-end.duration = 0;
-end.stream_index = stream_index;
+end->size = sizeof(data);
+end->data = data;
+end->pts = dts;
+end->dts = dts;
+end->duration = 0;
+end->stream_index = stream_index;
 
-ret = mov_write_single_packet(s, &end);
-av_packet_unref(&end);
+ret = mov_write_single_packet(s, end);
+av_packet_unref(end);
 
 return ret;
 }
@@ -6091,7 +6095,7 @@ static int mov_create_chapter_track(AVFormatContext *s, 
int tracknum)
 
 MOVMuxContext *mov = s->priv_data;
 MOVTrack *track = &mov->tracks[tracknum];
-AVPacket pkt = { .stream_index = tracknum, .flags = AV_PKT_FLAG_KEY };
+AVPacket *pkt = mov->pkt;
 int i, len;
 
 track->mode = mov->mode;
@@ -6153,13 +6157,16 @@ static int mov_create_chapter_track(AVFormatContext *s, 
int tracknum)
 }
 #endif
 
+pkt->stream_index = tracknum;
+pkt->flags = AV_PKT_FLAG_KEY;
+
 for (i = 0; i < s->nb_chapters; i++) {
 AVChapter *c = s->chapters[i];
 AVDictionaryEntry *t;
 
 int64_t end = av_rescale_q(c->end, c->time_base, 
(AVRational){1,MOV_TIMESCALE});
-pkt.pts = pkt.dts = av_rescale_q(c->start, c->time_base, 
(AVRational){1,MOV_TIMESCALE});
-pkt.duration = end - pkt.dts;
+pkt->pts = pkt->dts = av_rescale_q(c->start, c->time_base, 
(AVRational){1,MOV_TIMESCALE});
+pkt->duration = end - pkt->dts;
 
 if 

[FFmpeg-devel] [PATCH 06/10] doc/examples/transcoding: use av_packet_alloc() to allocate packets

2021-02-01 Thread James Almer
Signed-off-by: James Almer 
---
 doc/examples/transcoding.c | 48 ++
 1 file changed, 28 insertions(+), 20 deletions(-)

diff --git a/doc/examples/transcoding.c b/doc/examples/transcoding.c
index 5aff08c135..6ca3089330 100644
--- a/doc/examples/transcoding.c
+++ b/doc/examples/transcoding.c
@@ -42,6 +42,7 @@ typedef struct FilteringContext {
 AVFilterContext *buffersrc_ctx;
 AVFilterGraph *filter_graph;
 
+AVPacket *enc_pkt;
 AVFrame *filtered_frame;
 } FilteringContext;
 static FilteringContext *filter_ctx;
@@ -407,6 +408,10 @@ static int init_filters(void)
 if (ret)
 return ret;
 
+filter_ctx[i].enc_pkt = av_packet_alloc();
+if (!filter_ctx[i].enc_pkt)
+return AVERROR(ENOMEM);
+
 filter_ctx[i].filtered_frame = av_frame_alloc();
 if (!filter_ctx[i].filtered_frame)
 return AVERROR(ENOMEM);
@@ -414,17 +419,17 @@ static int init_filters(void)
 return 0;
 }
 
-static int encode_write_frame(AVFrame *filt_frame, unsigned int stream_index)
+static int encode_write_frame(unsigned int stream_index, int flush)
 {
 StreamContext *stream = &stream_ctx[stream_index];
+FilteringContext *filter = &filter_ctx[stream_index];
+AVFrame *filt_frame = flush ? NULL : filter->filtered_frame;
+AVPacket *enc_pkt = filter->enc_pkt;
 int ret;
-AVPacket enc_pkt;
 
 av_log(NULL, AV_LOG_INFO, "Encoding frame\n");
 /* encode filtered frame */
-enc_pkt.data = NULL;
-enc_pkt.size = 0;
-av_init_packet(&enc_pkt);
+av_packet_unref(enc_pkt);
 
 ret = avcodec_send_frame(stream->enc_ctx, filt_frame);
 
@@ -432,20 +437,20 @@ static int encode_write_frame(AVFrame *filt_frame, 
unsigned int stream_index)
 return ret;
 
 while (ret >= 0) {
-ret = avcodec_receive_packet(stream->enc_ctx, &enc_pkt);
+ret = avcodec_receive_packet(stream->enc_ctx, enc_pkt);
 
 if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)
 return 0;
 
 /* prepare packet for muxing */
-enc_pkt.stream_index = stream_index;
-av_packet_rescale_ts(&enc_pkt,
+enc_pkt->stream_index = stream_index;
+av_packet_rescale_ts(enc_pkt,
  stream->enc_ctx->time_base,
  ofmt_ctx->streams[stream_index]->time_base);
 
 av_log(NULL, AV_LOG_DEBUG, "Muxing frame\n");
 /* mux encoded frame */
-ret = av_interleaved_write_frame(ofmt_ctx, &enc_pkt);
+ret = av_interleaved_write_frame(ofmt_ctx, enc_pkt);
 }
 
 return ret;
@@ -481,7 +486,7 @@ static int filter_encode_write_frame(AVFrame *frame, 
unsigned int stream_index)
 }
 
 filter->filtered_frame->pict_type = AV_PICTURE_TYPE_NONE;
-ret = encode_write_frame(filter->filtered_frame, stream_index);
+ret = encode_write_frame(stream_index, 0);
 av_frame_unref(filter->filtered_frame);
 if (ret < 0)
 break;
@@ -497,13 +502,13 @@ static int flush_encoder(unsigned int stream_index)
 return 0;
 
 av_log(NULL, AV_LOG_INFO, "Flushing stream #%u encoder\n", stream_index);
-return encode_write_frame(NULL, stream_index);
+return encode_write_frame(stream_index, 1);
 }
 
 int main(int argc, char **argv)
 {
 int ret;
-AVPacket packet = { .data = NULL, .size = 0 };
+AVPacket *packet = NULL;
 unsigned int stream_index;
 unsigned int i;
 
@@ -518,12 +523,14 @@ int main(int argc, char **argv)
 goto end;
 if ((ret = init_filters()) < 0)
 goto end;
+if (!(packet = av_packet_alloc()))
+goto end;
 
 /* read all packets */
 while (1) {
-if ((ret = av_read_frame(ifmt_ctx, &packet)) < 0)
+if ((ret = av_read_frame(ifmt_ctx, packet)) < 0)
 break;
-stream_index = packet.stream_index;
+stream_index = packet->stream_index;
 av_log(NULL, AV_LOG_DEBUG, "Demuxer gave frame of stream_index %u\n",
 stream_index);
 
@@ -532,10 +539,10 @@ int main(int argc, char **argv)
 
 av_log(NULL, AV_LOG_DEBUG, "Going to reencode&filter the frame\n");
 
-av_packet_rescale_ts(&packet,
+av_packet_rescale_ts(packet,
  ifmt_ctx->streams[stream_index]->time_base,
  stream->dec_ctx->time_base);
-ret = avcodec_send_packet(stream->dec_ctx, &packet);
+ret = avcodec_send_packet(stream->dec_ctx, packet);
 if (ret < 0) {
 av_log(NULL, AV_LOG_ERROR, "Decoding failed\n");
 break;
@@ -555,15 +562,15 @@ int main(int argc, char **argv)
 }
 } else {
 /* remux this frame without reencoding */
-av_packet_rescale_ts(&packet,
+av_packet_rescale_ts(packet,
  ifmt_ctx->streams[stream_index]->time_base,
   

[FFmpeg-devel] [PATCH 07/10] fftools/ffprobe: use av_packet_alloc() to allocate packets

2021-02-01 Thread James Almer
Signed-off-by: James Almer 
---
 fftools/ffprobe.c | 34 +++---
 1 file changed, 19 insertions(+), 15 deletions(-)

diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c
index 3453aa09ff..68fecd61e5 100644
--- a/fftools/ffprobe.c
+++ b/fftools/ffprobe.c
@@ -2465,14 +2465,12 @@ static int read_interval_packets(WriterContext *w, 
InputFile *ifile,
  const ReadInterval *interval, int64_t *cur_ts)
 {
 AVFormatContext *fmt_ctx = ifile->fmt_ctx;
-AVPacket pkt;
+AVPacket *pkt = NULL;
 AVFrame *frame = NULL;
 int ret = 0, i = 0, frame_count = 0;
 int64_t start = -INT64_MAX, end = interval->end;
 int has_start = 0, has_end = interval->has_end && !interval->end_is_offset;
 
-av_init_packet(&pkt);
-
 av_log(NULL, AV_LOG_VERBOSE, "Processing read interval ");
 log_read_interval(interval, NULL, AV_LOG_VERBOSE);
 
@@ -2505,18 +2503,23 @@ static int read_interval_packets(WriterContext *w, 
InputFile *ifile,
 ret = AVERROR(ENOMEM);
 goto end;
 }
-while (!av_read_frame(fmt_ctx, &pkt)) {
+pkt = av_packet_alloc();
+if (!pkt) {
+ret = AVERROR(ENOMEM);
+goto end;
+}
+while (!av_read_frame(fmt_ctx, pkt)) {
 if (fmt_ctx->nb_streams > nb_streams) {
 REALLOCZ_ARRAY_STREAM(nb_streams_frames,  nb_streams, 
fmt_ctx->nb_streams);
 REALLOCZ_ARRAY_STREAM(nb_streams_packets, nb_streams, 
fmt_ctx->nb_streams);
 REALLOCZ_ARRAY_STREAM(selected_streams,   nb_streams, 
fmt_ctx->nb_streams);
 nb_streams = fmt_ctx->nb_streams;
 }
-if (selected_streams[pkt.stream_index]) {
-AVRational tb = ifile->streams[pkt.stream_index].st->time_base;
+if (selected_streams[pkt->stream_index]) {
+AVRational tb = ifile->streams[pkt->stream_index].st->time_base;
 
-if (pkt.pts != AV_NOPTS_VALUE)
-*cur_ts = av_rescale_q(pkt.pts, tb, AV_TIME_BASE_Q);
+if (pkt->pts != AV_NOPTS_VALUE)
+*cur_ts = av_rescale_q(pkt->pts, tb, AV_TIME_BASE_Q);
 
 if (!has_start && *cur_ts != AV_NOPTS_VALUE) {
 start = *cur_ts;
@@ -2538,26 +2541,27 @@ static int read_interval_packets(WriterContext *w, 
InputFile *ifile,
 frame_count++;
 if (do_read_packets) {
 if (do_show_packets)
-show_packet(w, ifile, &pkt, i++);
-nb_streams_packets[pkt.stream_index]++;
+show_packet(w, ifile, pkt, i++);
+nb_streams_packets[pkt->stream_index]++;
 }
 if (do_read_frames) {
 int packet_new = 1;
-while (process_frame(w, ifile, frame, &pkt, &packet_new) > 0);
+while (process_frame(w, ifile, frame, pkt, &packet_new) > 0);
 }
 }
-av_packet_unref(&pkt);
+av_packet_unref(pkt);
 }
-av_packet_unref(&pkt);
+av_packet_unref(pkt);
 //Flush remaining frames that are cached in the decoder
 for (i = 0; i < fmt_ctx->nb_streams; i++) {
-pkt.stream_index = i;
+pkt->stream_index = i;
 if (do_read_frames)
-while (process_frame(w, ifile, frame, &pkt, &(int){1}) > 0);
+while (process_frame(w, ifile, frame, pkt, &(int){1}) > 0);
 }
 
 end:
 av_frame_free(&frame);
+av_packet_free(&pkt);
 if (ret < 0) {
 av_log(NULL, AV_LOG_ERROR, "Could not read packets in interval ");
 log_read_interval(interval, NULL, AV_LOG_ERROR);
-- 
2.30.0

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 10/10] avcodec/packet: deprecate av_init_packet()

2021-02-01 Thread James Almer
Once removed, sizeof(AVPacket) will stop being a part of the public ABI.

Signed-off-by: James Almer 
---
 libavcodec/avpacket.c  | 23 +++
 libavcodec/packet.h| 23 +++
 libavcodec/version.h   |  3 +++
 libavformat/avformat.h |  4 
 4 files changed, 41 insertions(+), 12 deletions(-)

diff --git a/libavcodec/avpacket.c b/libavcodec/avpacket.c
index e4ba403cf6..ae0cbfb9f9 100644
--- a/libavcodec/avpacket.c
+++ b/libavcodec/avpacket.c
@@ -32,6 +32,7 @@
 #include "packet.h"
 #include "packet_internal.h"
 
+#if FF_API_INIT_PACKET
 void av_init_packet(AVPacket *pkt)
 {
 pkt->pts  = AV_NOPTS_VALUE;
@@ -49,6 +50,16 @@ FF_ENABLE_DEPRECATION_WARNINGS
 pkt->side_data= NULL;
 pkt->side_data_elems  = 0;
 }
+#endif
+
+static void get_packet_defaults(AVPacket *pkt)
+{
+memset(pkt, 0, sizeof(*pkt));
+
+pkt->pts = AV_NOPTS_VALUE;
+pkt->dts = AV_NOPTS_VALUE;
+pkt->pos = -1;
+}
 
 AVPacket *av_packet_alloc(void)
 {
@@ -56,7 +67,7 @@ AVPacket *av_packet_alloc(void)
 if (!pkt)
 return pkt;
 
-av_init_packet(pkt);
+get_packet_defaults(pkt);
 
 return pkt;
 }
@@ -92,7 +103,7 @@ int av_new_packet(AVPacket *pkt, int size)
 if (ret < 0)
 return ret;
 
-av_init_packet(pkt);
+get_packet_defaults(pkt);
 pkt->buf  = buf;
 pkt->data = buf->data;
 pkt->size = size;
@@ -607,9 +618,7 @@ void av_packet_unref(AVPacket *pkt)
 {
 av_packet_free_side_data(pkt);
 av_buffer_unref(&pkt->buf);
-av_init_packet(pkt);
-pkt->data = NULL;
-pkt->size = 0;
+get_packet_defaults(pkt);
 }
 
 int av_packet_ref(AVPacket *dst, const AVPacket *src)
@@ -664,9 +673,7 @@ AVPacket *av_packet_clone(const AVPacket *src)
 void av_packet_move_ref(AVPacket *dst, AVPacket *src)
 {
 *dst = *src;
-av_init_packet(src);
-src->data = NULL;
-src->size = 0;
+get_packet_defaults(src);
 }
 
 int av_packet_make_refcounted(AVPacket *pkt)
diff --git a/libavcodec/packet.h b/libavcodec/packet.h
index b9d4c9c2c8..c442b6a6eb 100644
--- a/libavcodec/packet.h
+++ b/libavcodec/packet.h
@@ -319,10 +319,6 @@ typedef struct AVPacketSideData {
  * packets, with no compressed data, containing only side data
  * (e.g. to update some stream parameters at the end of encoding).
  *
- * AVPacket is one of the few structs in FFmpeg, whose size is a part of public
- * ABI. Thus it may be allocated on stack and no new fields can be added to it
- * without libavcodec and libavformat major bump.
- *
  * The semantics of data ownership depends on the buf field.
  * If it is set, the packet data is dynamically allocated and is
  * valid indefinitely until a call to av_packet_unref() reduces the
@@ -334,6 +330,12 @@ typedef struct AVPacketSideData {
  * The side data is always allocated with av_malloc(), copied by
  * av_packet_ref() and freed by av_packet_unref().
  *
+ * sizeof(AVPacket) being a part of the public ABI is deprecated. once
+ * av_init_packet() is removed, new packets will only be able to be allocated
+ * with av_packet_alloc(), and new fields may be added to the end of the struct
+ * with a minor bump.
+ *
+ * @see av_packet_alloc
  * @see av_packet_ref
  * @see av_packet_unref
  */
@@ -394,7 +396,11 @@ typedef struct AVPacket {
 } AVPacket;
 
 typedef struct AVPacketList {
+#if FF_API_INIT_PACKET
 AVPacket pkt;
+#else
+AVPacket *pkt;
+#endif
 struct AVPacketList *next;
 } AVPacketList;
 
@@ -460,6 +466,7 @@ AVPacket *av_packet_clone(const AVPacket *src);
  */
 void av_packet_free(AVPacket **pkt);
 
+#if FF_API_INIT_PACKET
 /**
  * Initialize optional fields of a packet with default values.
  *
@@ -467,8 +474,16 @@ void av_packet_free(AVPacket **pkt);
  * initialized separately.
  *
  * @param pkt packet
+ *
+ * @see av_packet_alloc
+ * @see av_packet_unref
+ *
+ * @deprecated This function is deprecated. Once it's removed,
+   sizeof(AVPacket) will not be a part of the ABI anymore.
  */
+attribute_deprecated
 void av_init_packet(AVPacket *pkt);
+#endif
 
 /**
  * Allocate the payload of a packet and initialize its fields with
diff --git a/libavcodec/version.h b/libavcodec/version.h
index 1e1bedfce6..af8487a4c1 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -153,5 +153,8 @@
 #ifndef FF_API_DEBUG_MV
 #define FF_API_DEBUG_MV  (LIBAVCODEC_VERSION_MAJOR < 60)
 #endif
+#ifndef FF_API_INIT_PACKET
+#define FF_API_INIT_PACKET (LIBAVCODEC_VERSION_MAJOR < 60)
+#endif
 
 #endif /* AVCODEC_VERSION_H */
diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index 523cf34d55..d2d31e1deb 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -950,7 +950,11 @@ typedef struct AVStream {
  * decoding: set by libavformat, must not be modified by the caller.
  * encoding: unused
  */
+#if FF_API_INIT_PACKET
 AVPacket attached_pic;
+#else
+AVPacket *attached_pic;
+#en

[FFmpeg-devel] [PATCH 04/10] doc/examples/demuxing_decoding: use av_packet_alloc() to allocate packets

2021-02-01 Thread James Almer
Signed-off-by: James Almer 
---
 doc/examples/demuxing_decoding.c | 25 ++---
 1 file changed, 14 insertions(+), 11 deletions(-)

diff --git a/doc/examples/demuxing_decoding.c b/doc/examples/demuxing_decoding.c
index 803e35d25c..db5e0cb951 100644
--- a/doc/examples/demuxing_decoding.c
+++ b/doc/examples/demuxing_decoding.c
@@ -51,7 +51,7 @@ static int video_dst_bufsize;
 
 static int video_stream_idx = -1, audio_stream_idx = -1;
 static AVFrame *frame = NULL;
-static AVPacket pkt;
+static AVPacket *pkt = NULL;
 static int video_frame_count = 0;
 static int audio_frame_count = 0;
 
@@ -303,10 +303,12 @@ int main (int argc, char **argv)
 goto end;
 }
 
-/* initialize packet, set data to NULL, let the demuxer fill it */
-av_init_packet(&pkt);
-pkt.data = NULL;
-pkt.size = 0;
+pkt = av_packet_alloc();
+if (!pkt) {
+fprintf(stderr, "Could not allocate packet\n");
+ret = AVERROR(ENOMEM);
+goto end;
+}
 
 if (video_stream)
 printf("Demuxing video from file '%s' into '%s'\n", src_filename, 
video_dst_filename);
@@ -314,14 +316,14 @@ int main (int argc, char **argv)
 printf("Demuxing audio from file '%s' into '%s'\n", src_filename, 
audio_dst_filename);
 
 /* read frames from the file */
-while (av_read_frame(fmt_ctx, &pkt) >= 0) {
+while (av_read_frame(fmt_ctx, pkt) >= 0) {
 // check if the packet belongs to a stream we are interested in, 
otherwise
 // skip it
-if (pkt.stream_index == video_stream_idx)
-ret = decode_packet(video_dec_ctx, &pkt);
-else if (pkt.stream_index == audio_stream_idx)
-ret = decode_packet(audio_dec_ctx, &pkt);
-av_packet_unref(&pkt);
+if (pkt->stream_index == video_stream_idx)
+ret = decode_packet(video_dec_ctx, pkt);
+else if (pkt->stream_index == audio_stream_idx)
+ret = decode_packet(audio_dec_ctx, pkt);
+av_packet_unref(pkt);
 if (ret < 0)
 break;
 }
@@ -372,6 +374,7 @@ end:
 fclose(video_dst_file);
 if (audio_dst_file)
 fclose(audio_dst_file);
+av_packet_free(&pkt);
 av_frame_free(&frame);
 av_free(video_dst_data[0]);
 
-- 
2.30.0

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 08/10] fftools/ffmpeg: use av_packet_alloc() to allocate packets

2021-02-01 Thread James Almer
Signed-off-by: James Almer 
---
 fftools/ffmpeg.c | 318 +++
 fftools/ffmpeg.h |   4 +
 fftools/ffmpeg_opt.c |   5 +-
 3 files changed, 177 insertions(+), 150 deletions(-)

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index d7c833be63..2667f226b4 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -592,6 +592,7 @@ static void ffmpeg_cleanup(int ret)
 
 av_frame_free(&ost->filtered_frame);
 av_frame_free(&ost->last_frame);
+av_packet_free(&ost->pkt);
 av_dict_free(&ost->encoder_opts);
 
 av_freep(&ost->forced_keyframes);
@@ -610,9 +611,9 @@ static void ffmpeg_cleanup(int ret)
 
 if (ost->muxing_queue) {
 while (av_fifo_size(ost->muxing_queue)) {
-AVPacket pkt;
+AVPacket *pkt;
 av_fifo_generic_read(ost->muxing_queue, &pkt, sizeof(pkt), 
NULL);
-av_packet_unref(&pkt);
+av_packet_free(&pkt);
 }
 av_fifo_freep(&ost->muxing_queue);
 }
@@ -624,6 +625,7 @@ static void ffmpeg_cleanup(int ret)
 #endif
 for (i = 0; i < nb_input_files; i++) {
 avformat_close_input(&input_files[i]->ctx);
+av_packet_free(&input_files[i]->pkt);
 av_freep(&input_files[i]);
 }
 for (i = 0; i < nb_input_streams; i++) {
@@ -631,6 +633,7 @@ static void ffmpeg_cleanup(int ret)
 
 av_frame_free(&ist->decoded_frame);
 av_frame_free(&ist->filter_frame);
+av_packet_free(&ist->pkt);
 av_dict_free(&ist->decoder_opts);
 avsubtitle_free(&ist->prev_sub.subtitle);
 av_frame_free(&ist->sub2video.frame);
@@ -746,7 +749,7 @@ static void write_packet(OutputFile *of, AVPacket *pkt, 
OutputStream *ost, int u
 }
 
 if (!of->header_written) {
-AVPacket tmp_pkt = {0};
+AVPacket *tmp_pkt;
 /* the muxer is not initialized yet, buffer the packet */
 if (!av_fifo_space(ost->muxing_queue)) {
 unsigned int are_we_over_size =
@@ -769,8 +772,11 @@ static void write_packet(OutputFile *of, AVPacket *pkt, 
OutputStream *ost, int u
 ret = av_packet_make_refcounted(pkt);
 if (ret < 0)
 exit_program(1);
-av_packet_move_ref(&tmp_pkt, pkt);
-ost->muxing_queue_data_size += tmp_pkt.size;
+tmp_pkt = av_packet_alloc();
+if (!tmp_pkt)
+exit_program(1);
+av_packet_move_ref(tmp_pkt, pkt);
+ost->muxing_queue_data_size += tmp_pkt->size;
 av_fifo_generic_write(ost->muxing_queue, &tmp_pkt, sizeof(tmp_pkt), 
NULL);
 return;
 }
@@ -999,13 +1005,9 @@ static void do_audio_out(OutputFile *of, OutputStream 
*ost,
  AVFrame *frame)
 {
 AVCodecContext *enc = ost->enc_ctx;
-AVPacket pkt;
+AVPacket *pkt = ost->pkt;
 int ret;
 
-av_init_packet(&pkt);
-pkt.data = NULL;
-pkt.size = 0;
-
 adjust_frame_pts_to_encoder_tb(of, ost, frame);
 
 if (!check_recording_time(ost))
@@ -1017,7 +1019,6 @@ static void do_audio_out(OutputFile *of, OutputStream 
*ost,
 ost->samples_encoded += frame->nb_samples;
 ost->frames_encoded++;
 
-av_assert0(pkt.size || !pkt.data);
 update_benchmark(NULL);
 if (debug_ts) {
 av_log(NULL, AV_LOG_INFO, "encoder <- type:audio "
@@ -1031,7 +1032,8 @@ static void do_audio_out(OutputFile *of, OutputStream 
*ost,
 goto error;
 
 while (1) {
-ret = avcodec_receive_packet(enc, &pkt);
+av_packet_unref(pkt);
+ret = avcodec_receive_packet(enc, pkt);
 if (ret == AVERROR(EAGAIN))
 break;
 if (ret < 0)
@@ -1039,16 +1041,16 @@ static void do_audio_out(OutputFile *of, OutputStream 
*ost,
 
 update_benchmark("encode_audio %d.%d", ost->file_index, ost->index);
 
-av_packet_rescale_ts(&pkt, enc->time_base, ost->mux_timebase);
+av_packet_rescale_ts(pkt, enc->time_base, ost->mux_timebase);
 
 if (debug_ts) {
 av_log(NULL, AV_LOG_INFO, "encoder -> type:audio "
"pkt_pts:%s pkt_pts_time:%s pkt_dts:%s pkt_dts_time:%s\n",
-   av_ts2str(pkt.pts), av_ts2timestr(pkt.pts, &enc->time_base),
-   av_ts2str(pkt.dts), av_ts2timestr(pkt.dts, 
&enc->time_base));
+   av_ts2str(pkt->pts), av_ts2timestr(pkt->pts, 
&enc->time_base),
+   av_ts2str(pkt->dts), av_ts2timestr(pkt->dts, 
&enc->time_base));
 }
 
-output_packet(of, &pkt, ost, 0);
+output_packet(of, pkt, ost, 0);
 }
 
 return;
@@ -1064,7 +1066,7 @@ static void do_subtitle_out(OutputFile *of,
 int subtitle_out_max_size = 1024 * 1024;
 int subtitle_out_size, nb, i;
 AVCodecContext *enc;
-AVPacket pkt;
+AVPacket *pkt = ost->pkt;
 int64_t pts;
 
 if (sub->pts == AV_NOPTS_VALUE) {
@@ -1122,21 +1124,21 @@ static void do_subtitle_out(OutputFile *of,
 exit_program

[FFmpeg-devel] [PATCH 05/10] doc/examples/transcode_aac: use av_packet_alloc() to allocate packets

2021-02-01 Thread James Almer
Signed-off-by: James Almer 
---
 doc/examples/transcode_aac.c | 46 +---
 1 file changed, 27 insertions(+), 19 deletions(-)

diff --git a/doc/examples/transcode_aac.c b/doc/examples/transcode_aac.c
index e0c76f5b35..73786ab59b 100644
--- a/doc/examples/transcode_aac.c
+++ b/doc/examples/transcode_aac.c
@@ -245,14 +245,16 @@ cleanup:
 
 /**
  * Initialize one data packet for reading or writing.
- * @param packet Packet to be initialized
+ * @param[out] packet Packet to be initialized
+ * @return Error code (0 if successful)
  */
-static void init_packet(AVPacket *packet)
+static int init_packet(AVPacket **packet)
 {
-av_init_packet(packet);
-/* Set the packet data and size so that it is recognized as being empty. */
-packet->data = NULL;
-packet->size = 0;
+if (!(*packet = av_packet_alloc())) {
+fprintf(stderr, "Could not allocate packet\n");
+return AVERROR(ENOMEM);
+}
+return 0;
 }
 
 /**
@@ -371,28 +373,31 @@ static int decode_audio_frame(AVFrame *frame,
   int *data_present, int *finished)
 {
 /* Packet used for temporary storage. */
-AVPacket input_packet;
+AVPacket *input_packet;
 int error;
-init_packet(&input_packet);
+
+error = init_packet(&input_packet);
+if (error < 0)
+return error;
 
 /* Read one audio frame from the input file into a temporary packet. */
-if ((error = av_read_frame(input_format_context, &input_packet)) < 0) {
+if ((error = av_read_frame(input_format_context, input_packet)) < 0) {
 /* If we are at the end of the file, flush the decoder below. */
 if (error == AVERROR_EOF)
 *finished = 1;
 else {
 fprintf(stderr, "Could not read frame (error '%s')\n",
 av_err2str(error));
-return error;
+goto cleanup;
 }
 }
 
 /* Send the audio frame stored in the temporary packet to the decoder.
  * The input audio stream decoder is used to do this. */
-if ((error = avcodec_send_packet(input_codec_context, &input_packet)) < 0) 
{
+if ((error = avcodec_send_packet(input_codec_context, input_packet)) < 0) {
 fprintf(stderr, "Could not send packet for decoding (error '%s')\n",
 av_err2str(error));
-return error;
+goto cleanup;
 }
 
 /* Receive one frame from the decoder. */
@@ -418,7 +423,7 @@ static int decode_audio_frame(AVFrame *frame,
 }
 
 cleanup:
-av_packet_unref(&input_packet);
+av_packet_free(&input_packet);
 return error;
 }
 
@@ -661,9 +666,12 @@ static int encode_audio_frame(AVFrame *frame,
   int *data_present)
 {
 /* Packet used for temporary storage. */
-AVPacket output_packet;
+AVPacket *output_packet;
 int error;
-init_packet(&output_packet);
+
+error = init_packet(&output_packet);
+if (error < 0)
+return error;
 
 /* Set a timestamp based on the sample rate for the container. */
 if (frame) {
@@ -681,11 +689,11 @@ static int encode_audio_frame(AVFrame *frame,
 } else if (error < 0) {
 fprintf(stderr, "Could not send packet for encoding (error '%s')\n",
 av_err2str(error));
-return error;
+goto cleanup;
 }
 
 /* Receive one encoded frame from the encoder. */
-error = avcodec_receive_packet(output_codec_context, &output_packet);
+error = avcodec_receive_packet(output_codec_context, output_packet);
 /* If the encoder asks for more data to be able to provide an
  * encoded frame, return indicating that no data is present. */
 if (error == AVERROR(EAGAIN)) {
@@ -706,14 +714,14 @@ static int encode_audio_frame(AVFrame *frame,
 
 /* Write one audio frame from the temporary packet to the output file. */
 if (*data_present &&
-(error = av_write_frame(output_format_context, &output_packet)) < 0) {
+(error = av_write_frame(output_format_context, output_packet)) < 0) {
 fprintf(stderr, "Could not write frame (error '%s')\n",
 av_err2str(error));
 goto cleanup;
 }
 
 cleanup:
-av_packet_unref(&output_packet);
+av_packet_free(&output_packet);
 return error;
 }
 
-- 
2.30.0

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avformat/mxf: Establish register of local tags

2021-02-01 Thread Tomas Härdin
mån 2021-02-01 klockan 11:37 +0100 skrev Tomas Härdin:
> fre 2021-01-29 klockan 22:06 +0100 skrev Marton Balint:
> > On Thu, 28 Jan 2021, Tomas Härdin wrote:
> > 
> > > tor 2021-01-28 klockan 14:48 +0100 skrev Tomas Härdin:
> > > > tor 2021-01-28 klockan 08:56 +0100 skrev Marton Balint:
> > > > > On Thu, 28 Jan 2021, Tomas Härdin wrote:
> > > > > > ons 2021-01-27 klockan 23:50 +0100 skrev Marton Balint:
> > > > > > > On Wed, 27 Jan 2021, Tomas Härdin wrote:
> > > > > > There's not really anything to av_assert0() on in
> > > > > > mxf_lookup_local_tag(). Either way, I'm thinking replacing the 
> > > > > > return
> > > > > > NULL with either
> > > > > > 
> > > > > >av_log(NULL, AV_LOG_PANIC, "Tried to use unregistered local tag
> > > > > > 0x%04x\n", tag);
> > > > > >abort();
> > > > > > 
> > > > > > or
> > > > > > 
> > > > > >av_assert0(0 && "Tried to use unregistered local tag");
> > > > > > 
> > > > > > or maybe
> > > > > > 
> > > > > >av_log(NULL, AV_LOG_PANIC, "Tried to use unregistered local tag
> > > > > > 0x%04x\n", tag);
> > > > > >av_assert0(0);
> > > > > > 
> > > > > > to avoid explicitly calling abort()
> > > > > 
> > > > > I think we usually do av_assert0(0) in this case. I am not sure if the
> > > > > error message is particularly useful, afterall who sees it should be a
> > > > > programmer and file/line is printed by assert anyway, so a comment in 
> > > > > the
> > > > > source code before the assert makes more sense to me.
> > > > 
> > > > Maybe av_assert0(0 && "you forgot to add a local tag to the registry")?
> > > 
> > > Here's a rebased patch that does this, with a little comment also
> > 
> > LGTM, thanks.
> 
> Will push later today

Pushed

/Tomas

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 09/10] fftools/ffplay: use av_packet_alloc() to allocate packets

2021-02-01 Thread James Almer
Signed-off-by: James Almer 
---
 fftools/ffplay.c | 222 ---
 1 file changed, 135 insertions(+), 87 deletions(-)

diff --git a/fftools/ffplay.c b/fftools/ffplay.c
index 9ff0425163..ef954772ed 100644
--- a/fftools/ffplay.c
+++ b/fftools/ffplay.c
@@ -36,6 +36,7 @@
 #include "libavutil/pixdesc.h"
 #include "libavutil/imgutils.h"
 #include "libavutil/dict.h"
+#include "libavutil/fifo.h"
 #include "libavutil/parseutils.h"
 #include "libavutil/samplefmt.h"
 #include "libavutil/avassert.h"
@@ -111,13 +112,12 @@ const int program_birth_year = 2003;
 static unsigned sws_flags = SWS_BICUBIC;
 
 typedef struct MyAVPacketList {
-AVPacket pkt;
-struct MyAVPacketList *next;
+AVPacket *pkt;
 int serial;
 } MyAVPacketList;
 
 typedef struct PacketQueue {
-MyAVPacketList *first_pkt, *last_pkt;
+AVFifoBuffer *pkt_list;
 int nb_packets;
 int size;
 int64_t duration;
@@ -187,7 +187,7 @@ enum {
 };
 
 typedef struct Decoder {
-AVPacket pkt;
+AVPacket *pkt;
 PacketQueue *queue;
 AVCodecContext *avctx;
 int pkt_serial;
@@ -361,7 +361,7 @@ static int filter_nbthreads = 0;
 static int is_full_screen;
 static int64_t audio_callback_time;
 
-static AVPacket flush_pkt;
+static AVPacket *flush_pkt;
 
 #define FF_QUIT_EVENT(SDL_USEREVENT + 2)
 
@@ -427,28 +427,25 @@ int64_t get_valid_channel_layout(int64_t channel_layout, 
int channels)
 
 static int packet_queue_put_private(PacketQueue *q, AVPacket *pkt)
 {
-MyAVPacketList *pkt1;
+MyAVPacketList pkt1;
 
 if (q->abort_request)
return -1;
 
-pkt1 = av_malloc(sizeof(MyAVPacketList));
-if (!pkt1)
-return -1;
-pkt1->pkt = *pkt;
-pkt1->next = NULL;
-if (pkt == &flush_pkt)
+if (av_fifo_space(q->pkt_list) < sizeof(pkt1)) {
+if (av_fifo_grow(q->pkt_list, sizeof(pkt1)) < 0)
+return -1;
+}
+
+if (pkt->data == flush_pkt->data)
 q->serial++;
-pkt1->serial = q->serial;
+pkt1.pkt = pkt;
+pkt1.serial = q->serial;
 
-if (!q->last_pkt)
-q->first_pkt = pkt1;
-else
-q->last_pkt->next = pkt1;
-q->last_pkt = pkt1;
+av_fifo_generic_write(q->pkt_list, &pkt1, sizeof(pkt1), NULL);
 q->nb_packets++;
-q->size += pkt1->pkt.size + sizeof(*pkt1);
-q->duration += pkt1->pkt.duration;
+q->size += pkt1.pkt->size + sizeof(pkt1);
+q->duration += pkt1.pkt->duration;
 /* XXX: should duplicate packet data in DV case */
 SDL_CondSignal(q->cond);
 return 0;
@@ -456,32 +453,51 @@ static int packet_queue_put_private(PacketQueue *q, 
AVPacket *pkt)
 
 static int packet_queue_put(PacketQueue *q, AVPacket *pkt)
 {
+AVPacket *pkt1;
 int ret;
 
+pkt1 = av_packet_clone(pkt);
+if (!pkt1)
+   return -1;
+if (pkt == flush_pkt)
+pkt1->data = flush_pkt->data;
 SDL_LockMutex(q->mutex);
-ret = packet_queue_put_private(q, pkt);
+ret = packet_queue_put_private(q, pkt1);
 SDL_UnlockMutex(q->mutex);
-
-if (pkt != &flush_pkt && ret < 0)
-av_packet_unref(pkt);
+if (ret < 0) {
+av_packet_free(&pkt1);
+if (pkt != flush_pkt)
+av_packet_unref(pkt);
+}
 
 return ret;
 }
 
 static int packet_queue_put_nullpacket(PacketQueue *q, int stream_index)
 {
-AVPacket pkt1, *pkt = &pkt1;
-av_init_packet(pkt);
-pkt->data = NULL;
-pkt->size = 0;
+AVPacket *pkt;
+int ret;
+
+pkt = av_packet_alloc();
+if (!pkt)
+   return -1;
 pkt->stream_index = stream_index;
-return packet_queue_put(q, pkt);
+SDL_LockMutex(q->mutex);
+ret = packet_queue_put_private(q, pkt);
+SDL_UnlockMutex(q->mutex);
+if (ret < 0)
+av_packet_free(&pkt);
+
+return ret;
 }
 
 /* packet queue handling */
 static int packet_queue_init(PacketQueue *q)
 {
 memset(q, 0, sizeof(PacketQueue));
+q->pkt_list = av_fifo_alloc(sizeof(MyAVPacketList));
+if (!q->pkt_list)
+return AVERROR(ENOMEM);
 q->mutex = SDL_CreateMutex();
 if (!q->mutex) {
 av_log(NULL, AV_LOG_FATAL, "SDL_CreateMutex(): %s\n", SDL_GetError());
@@ -498,16 +514,13 @@ static int packet_queue_init(PacketQueue *q)
 
 static void packet_queue_flush(PacketQueue *q)
 {
-MyAVPacketList *pkt, *pkt1;
+MyAVPacketList pkt1;
 
 SDL_LockMutex(q->mutex);
-for (pkt = q->first_pkt; pkt; pkt = pkt1) {
-pkt1 = pkt->next;
-av_packet_unref(&pkt->pkt);
-av_freep(&pkt);
+while (av_fifo_size(q->pkt_list) >= sizeof(pkt1)) {
+av_fifo_generic_read(q->pkt_list, &pkt1, sizeof(pkt1), NULL);
+av_packet_free(&pkt1.pkt);
 }
-q->last_pkt = NULL;
-q->first_pkt = NULL;
 q->nb_packets = 0;
 q->size = 0;
 q->duration = 0;
@@ -517,6 +530,7 @@ static void packet_queue_flush(PacketQueue *q)
 static void packet_queue_destroy(PacketQueue *q)
 {
 packet_queue_flush(q);
+av_fifo_freep(&q->pkt_list);
 SDL_DestroyMutex(q->mutex

Re: [FFmpeg-devel] [PATCH 6/8] avcodec/cri: Use ff_set_dimensions()

2021-02-01 Thread Paul B Mahol
LGTM
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH v6 1/3] avformat/mxfdec: set toolkit version metadata

2021-02-01 Thread lance . lmwang
On Mon, Feb 01, 2021 at 08:15:33PM +0100, Marton Balint wrote:
> 
> 
> On Mon, 1 Feb 2021, lance.lmw...@gmail.com wrote:
> 
> > From: Limin Wang 
> > 
> > Please check the string of toolkit version with below command:
> > ./ffmpeg -i ../fate-suite/mxf/Sony-1.mxf -c:v copy -c:a copy out.mxf
> > ./ffmpeg -i out.mxf
> > 
> > toolkit_version : 58.65.101
> > 
> > Signed-off-by: Limin Wang 
> > ---
> > libavformat/mxfdec.c| 25 +
> > tests/ref/fate/mxf-probe-applehdr10 |  1 +
> > tests/ref/fate/mxf-probe-dnxhd  |  1 +
> > 3 files changed, 27 insertions(+)
> > 
> > diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
> > index afff204..61c8104 100644
> > --- a/libavformat/mxfdec.c
> > +++ b/libavformat/mxfdec.c
> > @@ -1970,6 +1970,18 @@ static int mxf_umid_to_str(UID ul, UID uid, char 
> > **str)
> > return 0;
> > }
> > 
> > +static int mxf_version_to_str(uint16_t major, uint16_t minor, uint16_t 
> > tertiary, char **str)
> > +{
> > +int size = sizeof(major) * 5 + 1;
> > +
> > +*str = av_mallocz(size);
> > +if (!*str)
> > +return AVERROR(ENOMEM);
> > +
> > +snprintf(*str, size, "%d.%d.%d", major, minor, tertiary);
> 
> ToolkitVersion is a ProductVersion which means it consists of 5 UInt16
> numbers, not 3. So you should present all 5 values.

OK, will add patch and release number also.

> 
> Regards,
> Marton
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

-- 
Thanks,
Limin Wang
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH v6 1/3] avformat/mxfdec: set toolkit version metadata

2021-02-01 Thread lance . lmwang
On Mon, Feb 01, 2021 at 08:14:25PM +0100, Tomas Härdin wrote:
> mån 2021-02-01 klockan 18:23 +0100 skrev Andreas Rheinhardt:
> > Tomas Härdin:
> > > mån 2021-02-01 klockan 07:50 +0800 skrev lance.lmw...@gmail.com:
> > > > From: Limin Wang 
> > > > 
> > > > Please check the string of toolkit version with below command:
> > > > ./ffmpeg -i ../fate-suite/mxf/Sony-1.mxf -c:v copy -c:a copy out.mxf
> > > > ./ffmpeg -i out.mxf
> > > > 
> > > > toolkit_version : 58.65.101
> > > > 
> > > > Signed-off-by: Limin Wang 
> > > > ---
> > > >  libavformat/mxfdec.c| 25 +
> > > >  tests/ref/fate/mxf-probe-applehdr10 |  1 +
> > > >  tests/ref/fate/mxf-probe-dnxhd  |  1 +
> > > >  3 files changed, 27 insertions(+)
> > > > 
> > > > diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
> > > > index afff204..61c8104 100644
> > > > --- a/libavformat/mxfdec.c
> > > > +++ b/libavformat/mxfdec.c
> > > > @@ -1970,6 +1970,18 @@ static int mxf_umid_to_str(UID ul, UID uid, char 
> > > > **str)
> > > >  return 0;
> > > >  }
> > > >  
> > > > +static int mxf_version_to_str(uint16_t major, uint16_t minor, uint16_t 
> > > > tertiary, char **str)
> > > > +{
> > > > +int size = sizeof(major) * 5 + 1;
> > > 
> > > This is just wrong. Should be 3*5+2+1 = 18.
> > > 
> > > > +
> > > > +*str = av_mallocz(size);
> > > > +if (!*str)
> > > > +return AVERROR(ENOMEM);
> > > > +
> > > > +snprintf(*str, size, "%d.%d.%d", major, minor, tertiary);
> > > 
> > > snprintf() is not safe - *str can end up not NUL terminated
> > > 
> > Not true -- snprintf always zero-terminates (and truncates the output if
> > it needs to do so) unless size is zero (which it is not).
> 
> Ack, you're right. I was thinking of strn*
> 
> > But nevertheless av_asprintf would be better IMO.
> 
> Yes

sure, will change to use av_asprintf.

> 
> /Tomas
> 
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

-- 
Thanks,
Limin Wang
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avdevice/xcbgrab: don't assume Xserver endianness

2021-02-01 Thread Andriy Gelman
On Sun, 31. Jan 23:28, Carl Eugen Hoyos wrote:
> Am So., 31. Jan. 2021 um 20:51 Uhr schrieb Andriy Gelman
> :
> >
> > From: Andriy Gelman 
> >
> > Xserver defines the endianness of the grabbed images. Use this information
> > to set the correct pixel format.
> 
> lgtm if tested.

Thanks, will apply in a few days.
Do you think I should keep the docker testing instructions in the commit
message?

> 
> Could you look at pal8? This used to work fine with x11grab...

Yes sure, will have a look later this week. 

-- 
Andriy
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 1/4] avformat/matroskadec: Check for EOF in resync loop

2021-02-01 Thread Andreas Rheinhardt
Michael Niedermayer:
> Fixes: Timeout (too long -> instantly)
> Fixes: 
> 29136/clusterfuzz-testcase-minimized-ffmpeg_dem_WEBM_DASH_MANIFEST_fuzzer-4586141227548672
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavformat/matroskadec.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
> index 374831baa3..1f28108887 100644
> --- a/libavformat/matroskadec.c
> +++ b/libavformat/matroskadec.c
> @@ -2895,6 +2895,8 @@ static int matroska_read_header(AVFormatContext *s)
>  goto fail;
>  pos = avio_tell(matroska->ctx->pb);
>  res = ebml_parse(matroska, matroska_segment, matroska);
> +if (res == AVERROR(EIO)) // EOF is translated to EIO, this exists 
> the loop on EOF
> +goto fail;
>  }
>  /* Set data_offset as it might be needed later by seek_frame_generic. */
>  if (matroska->current_id == MATROSKA_ID_CLUSTER)
> 

I see two types of files for which this check can be problematic: Those
with an unknown-length segment and truncated files: In both cases a
child element may extend beyond the actually existing data without this
being caught by the check for whether the element extends beyond its
parent (i.e. beyond the end of the segment). But I don't really see a
better way, so go ahead.

- Andreas
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".