Re: [FFmpeg-devel] [PATCH] avformat: Add check for ff_get_extradata

2022-02-22 Thread Paul B Mahol
On Tue, Feb 22, 2022 at 8:50 AM Jiasheng Jiang  wrote:

> As the potential failure of the memory allocation, the ff_get_extradata()
> could return error if fails.
> Therefore, it should be better to deal with the return value of the
> ff_get_extradata() and return error if fails.
>


Not really necessary. Does not fix anything.


>
> Fixes: 2d720069a9 ("avformat: add aix demuxer")
> Signed-off-by: Jiasheng Jiang 
> ---
>  libavformat/aixdec.c | 6 --
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/libavformat/aixdec.c b/libavformat/aixdec.c
> index 59c3d60da3..89f73b6913 100644
> --- a/libavformat/aixdec.c
> +++ b/libavformat/aixdec.c
> @@ -40,7 +40,7 @@ static int aix_read_header(AVFormatContext *s)
>  unsigned segment_list_offset = 0x20;
>  unsigned segment_list_entry_size = 0x10;
>  unsigned size;
> -int i;
> +int i, ret;
>
>  avio_skip(s->pb, 4);
>  first_offset = avio_rb32(s->pb) + 8;
> @@ -77,7 +77,9 @@ static int aix_read_header(AVFormatContext *s)
>  if (size <= 8)
>  return AVERROR_INVALIDDATA;
>  avio_skip(s->pb, 8);
> -ff_get_extradata(s, s->streams[i]->codecpar, s->pb, size - 8);
> +ret = ff_get_extradata(s, s->streams[i]->codecpar, s->pb, size -
> 8);
> +if (ret < 0)
> +return ret;
>  }
>
>  return 0;
> --
> 2.25.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 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] libavfilter: zscale performance optimization >4x

2022-02-22 Thread Paul B Mahol
On Tue, Feb 22, 2022 at 6:25 AM Lynne  wrote:

> 19 Feb 2022, 14:58 by niva...@gmail.com:
>
> > By ffmpeg threading support implementation via frame slicing and doing
> > zimg_filter_graph_build that used to take 30-60% of each frame processig
> > only if necessary (some parameters changed)
> > the performance increase vs original version
> > in video downscale and color conversion  >4x is seen
> > on 64 cores Intel Xeon, 3x on i7-6700K (4 cores with HT)
> >
> > Signed-off-by: Victoria Zhislina 
> >
>
> Can't you patch such a feature into the upstream instead?
>

zscale already have own threading ability, but is very hard to use it, last
time i tried.


> ___
> 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] [PATCH] libavfilter: zscale performance optimization >4x

2022-02-22 Thread Paul B Mahol
On Tue, Feb 22, 2022 at 9:15 AM Paul B Mahol  wrote:

>
>
> On Tue, Feb 22, 2022 at 6:25 AM Lynne  wrote:
>
>> 19 Feb 2022, 14:58 by niva...@gmail.com:
>>
>> > By ffmpeg threading support implementation via frame slicing and doing
>> > zimg_filter_graph_build that used to take 30-60% of each frame processig
>> > only if necessary (some parameters changed)
>> > the performance increase vs original version
>> > in video downscale and color conversion  >4x is seen
>> > on 64 cores Intel Xeon, 3x on i7-6700K (4 cores with HT)
>> >
>> > Signed-off-by: Victoria Zhislina 
>> >
>>
>> Can't you patch such a feature into the upstream instead?
>>
>
> zscale already have own threading ability, but is very hard to use it,
> last time i tried.
>

I mean zimg.


>
>
>> ___
>> 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] [PATCH v2 1/4] lavc/vaapi_encode_h265: Add P frame to GPB frame support for hevc_vaapi

2022-02-22 Thread Wang, Fei W
On Tue, 2022-02-22 at 05:46 +, Xiang, Haihao wrote:
> On Mon, 2022-02-21 at 12:06 +, Mark Thompson wrote:
> > On 21/02/2022 02:13, Fei Wang wrote:
> > > From: Linjie Fu 
> > > 
> > > Use GPB frames to replace regular P frames if backend driver does
> > > not
> > > support it.
> > > 
> > > - GPB:
> > >  Generalized P and B picture. P frames replaced by B frames
> > > with
> > >  forward-predict only, L0 == L1. Normal B frames still have 2
> > >  different ref_lists and allow bi-prediction
> > > 
> > > Signed-off-by: Linjie Fu 
> > > Signed-off-by: Fei Wang 
> > > ---
> > >   libavcodec/vaapi_encode.c  | 33
> > > +++--
> > >   libavcodec/vaapi_encode.h  |  1 +
> > >   libavcodec/vaapi_encode_h265.c | 15 +++
> > >   3 files changed, 47 insertions(+), 2 deletions(-)
> > 
> > This always fails immediately on current iHD
> > (7e357b4bea76b2fe2522e6af41ae02ea69cec49e):
> > 
> > $ ./ffmpeg_g -v 44 -y -hwaccel vaapi -hwaccel_output_format vaapi
> > -i in.mp4
> > -an -c:v hevc_vaapi -low_power 1 out.mp4
> > ...
> > [hevc_vaapi @ 0x560e81d45e80] Using input frames context (format
> > vaapi) with
> > hevc_vaapi encoder.
> > [hevc_vaapi @ 0x560e81d45e80] Input surface format is nv12.
> > [hevc_vaapi @ 0x560e81d45e80] Using VAAPI profile VAProfileHEVCMain
> > (17).
> > [hevc_vaapi @ 0x560e81d45e80] Using VAAPI entrypoint
> > VAEntrypointEncSliceLP
> > (8).
> > [hevc_vaapi @ 0x560e81d45e80] Using VAAPI render target format
> > YUV420 (0x1).
> > [hevc_vaapi @ 0x560e81d45e80] Using CTU size 64x64, min CB size
> > 8x8.
> > [hevc_vaapi @ 0x560e81d45e80] No quality level set; using default
> > (25).
> > [hevc_vaapi @ 0x560e81d45e80] RC mode: CQP.
> > [hevc_vaapi @ 0x560e81d45e80] RC quality: 25.
> > [hevc_vaapi @ 0x560e81d45e80] RC framerate: 3/1001 (29.97 fps).
> > [hevc_vaapi @ 0x560e81d45e80] Use GPB B frames to replace regular P
> > frames.
> > [hevc_vaapi @ 0x560e81d45e80] Using intra, GPB-B-frames and B-
> > frames
> > (supported references: 3 / 3).
> > [hevc_vaapi @ 0x560e81d45e80] All wanted packed headers available
> > (wanted 0xd,
> > found 0x1f).
> > [hevc_vaapi @ 0x560e81d45e80] Using level 4.
> > ...
> > [hevc_vaapi @ 0x560e81d45e80] Failed to end picture encode issue:
> > 24 (internal
> > encoding error).
> > [hevc_vaapi @ 0x560e81d45e80] Encode failed: -5.
> > Video encoding failed
> > ...
> > $ cat /proc/cpuinfo | grep 'model name' | head -1
> > model name  : Intel(R) Core(TM) i7-1065G7 CPU @ 1.30GHz
> > $ uname -v
> > #1 SMP PREEMPT Debian 5.16.7-2 (2022-02-09)
> > 
> > Do you get this too, or is your setup different somehow?
> 
> Hi Mark,
> 
> I tested this patchset with iHD
> (7e357b4bea76b2fe2522e6af41ae02ea69cec49e) on
> CFL (low_power=0), RKL and DG1, i965 on SKL, and didn't see this
> issue before.
> This day I reproduced this issue on ICL. It seems iHD driver doesn't
> return
> right values for ICL.  

Thanks Mark to report this issue on ICL.

I tested on TGL and CFL before submitted this patch set, all looks
good. I will check why this fail on ICL.

And will fix your other comments together in next version.

Fei
Thanks


> 
> > > diff --git a/libavcodec/vaapi_encode.c
> > > b/libavcodec/vaapi_encode.c
> > > index 3bf379b1a0..95eca7c288 100644
> > > --- a/libavcodec/vaapi_encode.c
> > > +++ b/libavcodec/vaapi_encode.c
> > > @@ -1845,6 +1845,30 @@ static av_cold int
> > > vaapi_encode_init_gop_structure(AVCodecContext *avctx)
> > >   ref_l1 = attr.value >> 16 & 0x;
> > >   }
> > >   
> > > +ctx->p_to_gpb = 0;
> > > +
> > > +#if VA_CHECK_VERSION(1, 9, 0)
> > > +attr = (VAConfigAttrib) { VAConfigAttribPredictionDirection
> > > };
> > > +vas = vaGetConfigAttributes(ctx->hwctx->display,
> > > +ctx->va_profile,
> > > +ctx->va_entrypoint,
> > > +&attr, 1);
> > 
> > This probably shouldn't be done at all if the user has selected a
> > codec
> > without B-frames or a configuration which is intra-only, because
> > the log
> > message is confusing:
> > 
> > [mjpeg_vaapi @ 0x55b90d72ee00] Driver does not report whether
> > support GPB, use
> > regular P frames.
> > [mjpeg_vaapi @ 0x55b90d72ee00] Using intra frames only.
> > 
> > > +if (vas != VA_STATUS_SUCCESS) {
> > > +av_log(avctx, AV_LOG_WARNING, "Failed to query
> > > prediction direction
> > > "
> > > +   "attribute: %d (%s).\n", vas, vaErrorStr(vas));
> > 
> > And fail?
> 
> 4/4 also ignores the error. It would be better to handle the error in
> the same
> way and update 4/4 too. 
> 
> > > +} else if (attr.value == VA_ATTRIB_NOT_SUPPORTED) {
> > > +av_log(avctx, AV_LOG_VERBOSE, "Driver does not report
> > > whether "
> > > +   "support GPB, use regular P frames.\n");
> > 
> > "support GPB" is a strange thing to say.  It's a constraint - any
> > driver which
> > supports B-frames will let you have the same thing in 

Re: [FFmpeg-devel] [PATCH] avformat: Add check for ff_get_extradata

2022-02-22 Thread Jiasheng Jiang
On Tue, Feb 22, 2022 at 04:10:51PM +0800, Paul B Mahol wrote:

>> As the potential failure of the memory allocation, the ff_get_extradata()
>> could return error if fails.
>> Therefore, it should be better to deal with the return value of the
>> ff_get_extradata() and return error if fails.
>>
> 
> 
> Not really necessary. Does not fix anything.

It is true that the 'extradata' could be NULL and have not used.
But I have checked many other callers of the ff_get_extradata(),
such as avi_read_header() in `libavformat/avidec.c`.
They all have checked the return value to guarantee the 'extradata'
to be non-NULL.
That means in the future, if the 'aix->extradata' is used, the programmer
may not notice that 'aix->extradata' is especial and needs to be checked
before use.
Therefore, I think it is necessary to add the check to guarantee the
consisitency of the code.

Thanks,
Jiang

___
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: Add check for ff_get_extradata

2022-02-22 Thread Paul B Mahol
On Tue, Feb 22, 2022 at 10:14 AM Jiasheng Jiang 
wrote:

> On Tue, Feb 22, 2022 at 04:10:51PM +0800, Paul B Mahol wrote:
>
> >> As the potential failure of the memory allocation, the
> ff_get_extradata()
> >> could return error if fails.
> >> Therefore, it should be better to deal with the return value of the
> >> ff_get_extradata() and return error if fails.
> >>
> >
> >
> > Not really necessary. Does not fix anything.
>
> It is true that the 'extradata' could be NULL and have not used.
> But I have checked many other callers of the ff_get_extradata(),
> such as avi_read_header() in `libavformat/avidec.c`.
> They all have checked the return value to guarantee the 'extradata'
> to be non-NULL.
> That means in the future, if the 'aix->extradata' is used, the programmer
> may not notice that 'aix->extradata' is especial and needs to be checked
> before use.
> Therefore, I think it is necessary to add the check to guarantee the
> consisitency of the code.
>

Nope, that does not make sense, it should always be checked.


>
> Thanks,
> Jiang
>
>
___
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] libavfilter: zscale performance optimization >4x

2022-02-22 Thread Victoria Zhislina
Paul, I've got exactly the same feelings on zing threading usage myself and
decided to go along the standard ffmpeg threading route.
It looks more consistent here.
Megathanks for reviewing my patch, I've fixed everything you've mentioned
and even more.

On Tue, Feb 22, 2022 at 11:15 AM Paul B Mahol  wrote:

> On Tue, Feb 22, 2022 at 9:15 AM Paul B Mahol  wrote:
>
> >
> >
> > On Tue, Feb 22, 2022 at 6:25 AM Lynne  wrote:
> >
> >> 19 Feb 2022, 14:58 by niva...@gmail.com:
> >>
> >> > By ffmpeg threading support implementation via frame slicing and doing
> >> > zimg_filter_graph_build that used to take 30-60% of each frame
> processig
> >> > only if necessary (some parameters changed)
> >> > the performance increase vs original version
> >> > in video downscale and color conversion  >4x is seen
> >> > on 64 cores Intel Xeon, 3x on i7-6700K (4 cores with HT)
> >> >
> >> > Signed-off-by: Victoria Zhislina 
> >> >
> >>
> >> Can't you patch such a feature into the upstream instead?
> >>
> >
> > zscale already have own threading ability, but is very hard to use it,
> > last time i tried.
> >
>
> I mean zimg.
>
>
> >
> >
> >> ___
> >> 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".
>
___
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 v1] avfilter/vf_gblur_vulkan: add sizeV option

2022-02-22 Thread Lynne
22 Feb 2022, 07:27 by jianhua.wu-at-intel@ffmpeg.org:

> Lynne:
>
>> Sent: Tuesday, February 22, 2022 1:38 PM
>> To: FFmpeg development discussions and patches > de...@ffmpeg.org>
>> Subject: Re: [FFmpeg-devel] [PATCH v1] avfilter/vf_gblur_vulkan: add sizeV
>> option
>>
>> 18 Feb 2022, 16:24 by toq...@outlook.com:
>>
>> >> 29 Jan 2022, 13:34 by toqsxw at outlook.com:
>> >>
>> >>> Ping.
>> >>>
>>  From: Wu, Jianhua
>>  Sent: 2022年1月21日 19:42
>>  To: ffmpeg-devel at ffmpeg.org
>>  Cc: Wu, Jianhua
>>  Subject: [FFmpeg-devel] [PATCH v1] avfilter/vf_gblur_vulkan: add
>>  sizeV option
>> 
>>  [PATCH 1/5] avfilter/vf_gblur_vulkan: add sizeV option [PATCH 2/5]
>>  avfilter:add shader_vulkan filter [PATCH 3/5]
>>  avfilter/vf_blend_vulkan: add multiply blend mode [PATCH 4/5]
>>  avutil/vulkan: don't use strlen as loop >condition [PATCH 5/5]
>>  avfilter/scale_vulkan: use RET for checking return value
>> 
>>  Patches attached.
>> 
>> >>>
>> >>> Hi there,
>> >>>
>> >>> Any update?
>> >>>
>> >>
>> >> Sorry, haven't forgotten, but been busy with FFTs lately.
>> >> Will try to review and test the patches soon.
>> >>
>> >
>> > Hi there,
>> >
>> > I'm sorry for bothering you. If there is any update on this thread,
>> > please do let me know.
>> >
>>
>> Pushed all except the strlen() in a loop condition and the shader filter.
>> I pushed a different, smaller version for the strlen patch.
>>
> Maybe you don't need to use strlen() at all. That patch could be applied
> separately if you preferred to apply the shader_vulkan filter in the future.
>
>> As for a shader filter, I'd like something that's a lot less minimal.
>> You should expose the frame number, framerate (with an avoption to set it),
>> pixel format to the shader. Keep in mind the API will be fixed, so we need to
>> get this right the first time hopefully.
>>
>
> Frame number and framerate are okay to set if I can get them from FFmpeg API,
> but pixel format may not be ideal to expose for there is a lot of pixel 
> formats in
> FFmpeg. Exposing a pixel format means we need to expose all values related to
> pixel formats. Instead, we could expose two functions like
>

Wrapper functions won't help, shaders would still need to know what colorspace 
to work in.
I think if you just expose the entire pixdesc flags as-is, so shaders know if 
it's RGB or YUV, and the raw colorspace/transfer/matrix integers, it'll be good 
enough.


>> You should expose alpha planes as well.
>>
> Could you elaborate it further?
>

Yes, currently for YUVA images, the alpha channel remains untouched (the size 
of all image arrays is [3]) and unexposed to the shader.


>> Finally, could you implement N-inputs and M-outputs, configurable via
>> avoptions? That way, someone could make a custom blend filter without a
>> separate avfilter which takes multiple inputs. Or a separator filter.
>> Or a simple source filter that just produces an image pattern.
>>
> Sounds great! However, at the present, I've no idea about how this could be 
> done.
> I think the current filter is already useful already for I could make some 
> great video
> effects just like Shadertoy. More extensions need further contributions.
>

Just set AVFilter.inputs and AVFilter.outputs to NULL. Then in the init 
function,
copy what e.g. af_amix does to set inputs and what e.g. af_channelsplit does for
outputs. There are probably better examples out there if you look.
I think that this should be up to the shader to initialize, rather than the 
filter user,
so perhaps, in the init function, you compile the shader, run an init function 
in
the shader which tells you what it requires and does checking, then return,
and set it up for operation.
___
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 v1] avfilter/vf_gblur_vulkan: add sizeV option

2022-02-22 Thread Wu, Jianhua
Lynne:
> Sent: Tuesday, February 22, 2022 5:36 PM
> To: FFmpeg development discussions and patches  de...@ffmpeg.org>
> Subject: Re: [FFmpeg-devel] [PATCH v1] avfilter/vf_gblur_vulkan: add sizeV
> option
> 
> 22 Feb 2022, 07:27 by jianhua.wu-at-intel@ffmpeg.org:
> 
> > Lynne:
> >
> >> Sent: Tuesday, February 22, 2022 1:38 PM
> >> To: FFmpeg development discussions and patches  >> de...@ffmpeg.org>
> >> Subject: Re: [FFmpeg-devel] [PATCH v1] avfilter/vf_gblur_vulkan: add
> >> sizeV option
> >>
> >> 18 Feb 2022, 16:24 by toq...@outlook.com:
> >>
> >> >> 29 Jan 2022, 13:34 by toqsxw at outlook.com:
> >> >>
> >> >>> Ping.
> >> >>>
> >>  From: Wu, Jianhua
> >>  Sent: 2022年1月21日 19:42
> >>  To: ffmpeg-devel at ffmpeg.org >>  ffmpeg.org>
> >>  Cc: Wu, Jianhua
> >>  Subject: [FFmpeg-devel] [PATCH v1] avfilter/vf_gblur_vulkan: add
> >>  sizeV option
> >> 
> >>  [PATCH 1/5] avfilter/vf_gblur_vulkan: add sizeV option [PATCH
> >>  2/5] avfilter:add shader_vulkan filter [PATCH 3/5]
> >>  avfilter/vf_blend_vulkan: add multiply blend mode [PATCH 4/5]
> >>  avutil/vulkan: don't use strlen as loop >condition [PATCH 5/5]
> >>  avfilter/scale_vulkan: use RET for checking return value
> >> 
> >>  Patches attached.
> >> 
> >> >>>
> >> >>> Hi there,
> >> >>>
> >> >>> Any update?
> >> >>>
> >> >>
> >> >> Sorry, haven't forgotten, but been busy with FFTs lately.
> >> >> Will try to review and test the patches soon.
> >> >>
> >> >
> >> > Hi there,
> >> >
> >> > I'm sorry for bothering you. If there is any update on this thread,
> >> > please do let me know.
> >> >
> >>
> >> Pushed all except the strlen() in a loop condition and the shader filter.
> >> I pushed a different, smaller version for the strlen patch.
> >>
> > Maybe you don't need to use strlen() at all. That patch could be
> > applied separately if you preferred to apply the shader_vulkan filter in the
> future.
> >
> >> As for a shader filter, I'd like something that's a lot less minimal.
> >> You should expose the frame number, framerate (with an avoption to
> >> set it), pixel format to the shader. Keep in mind the API will be
> >> fixed, so we need to get this right the first time hopefully.
> >>
> >
> > Frame number and framerate are okay to set if I can get them from
> > FFmpeg API, but pixel format may not be ideal to expose for there is a
> > lot of pixel formats in FFmpeg. Exposing a pixel format means we need
> > to expose all values related to pixel formats. Instead, we could
> > expose two functions like
> >
> 
> Wrapper functions won't help, shaders would still need to know what
> colorspace to work in.
> I think if you just expose the entire pixdesc flags as-is, so shaders know if 
> it's
> RGB or YUV, and the raw colorspace/transfer/matrix integers, it'll be good
> enough.
> 
> 
> >> You should expose alpha planes as well.
> >>
> > Could you elaborate it further?
> >
> 
> Yes, currently for YUVA images, the alpha channel remains untouched (the
> size of all image arrays is [3]) and unexposed to the shader.
> 
> 
> >> Finally, could you implement N-inputs and M-outputs, configurable via
> >> avoptions? That way, someone could make a custom blend filter without
> >> a separate avfilter which takes multiple inputs. Or a separator filter.
> >> Or a simple source filter that just produces an image pattern.
> >>
> > Sounds great! However, at the present, I've no idea about how this could
> be done.
> > I think the current filter is already useful already for I could make
> > some great video effects just like Shadertoy. More extensions need
> further contributions.
> >
> 
> Just set AVFilter.inputs and AVFilter.outputs to NULL. Then in the init
> function, copy what e.g. af_amix does to set inputs and what e.g.
> af_channelsplit does for outputs. There are probably better examples out
> there if you look.
> I think that this should be up to the shader to initialize, rather than the 
> filter
> user, so perhaps, in the init function, you compile the shader, run an init
> function in the shader which tells you what it requires and does checking,
> then return, and set it up for operation.
> 

I suppose you mean there is a init function in the shader source file and 
execute
it to read back some configuration data, don't you? If so, looks like a great 
feature.
And I think, isn't these characteristics should be only added when there is 
someone
who has the relative requirements?

___
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] Playback issue on Sony TVs caused by btrt box

2022-02-22 Thread Jan Ekström
On Tue, Feb 22, 2022 at 9:55 AM Marton Balint  wrote:
>
>
>
> On Mon, 21 Feb 2022, Eran Kornblau wrote:
>
> >>
> >> On Mon, Feb 21, 2022 at 5:07 PM Eran Kornblau  
> >> wrote:
> >>>
> >>> Hi all,
> >>>
> >>> We've recently upgraded our ffmpeg version, and we got a playback issue 
> >>> on some Sony TV models that are playing HBBTV/DASH+DRM - video plays 
> >>> fine, audio doesn't play at all.
> >>> Listing here some of the affected models (not pasting all, the list is 
> >>> long...) - KDL-32W600D, KDL-40W650D, KDL-48W650D, KDL-43W750D, 
> >>> KDL-49W750D, KDL-55W650D.
> >>>
> >>> After some investigation, we found the cause was the addition of the
> >>> 'btrt' atom to the mp4 –
> >>> https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgith
> >>> ub.com%2FFFmpeg%2FFFmpeg%2Fcommit%2F3838e8fc210aa09a9f9058506c0ce80b6a
> >>> d9b9c3&data=04%7C01%7C%7Cc96aade7b4354115844508d9f5665925%7C0c5037
> >>> 48de3f4e2597e26819d53a42b6%7C1%7C0%7C637810642206022682%7CUnknown%7CTW
> >>> FpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6
> >>> Mn0%3D%7C3000&sdata=Na7ZxDQTby8Xq9CjB51lJyP1IOMdwLqoRLNODUC4nX0%3D
> >>> &reserved=0 The TV decoder expects to get the sinf atom right
> >>> after esds, and doesn't properly handle the btrt atom in between (our
> >>> packager adds the sinf atom at the end of the original stsd entry that 
> >>> was read from the mp4 file).
> >>>
> >>> Since, in my understanding, the btrt atom was added mostly for reporting 
> >>> reasons, IMHO, it should be a config option - off by default.
> >>> I would happily submit a patch for it, but sending this first, in case 
> >>> there are any concerns/objections.
> >>>
> >>
> >> In case the use case was unknown, the primary reason for adding this was 
> >> to utilize this box to inform a media server of an incoming live stream's 
> >> bit rate, since the overall bit rate cannot be calculated for something 
> >> that isn't done yet
> >> (https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fdashif-documents.azurewebsites.net%2FIngest%2Fmaster%2FDASH-IF-Ingest.html&data=04%7C01%7C%7Cc96aade7b4354115844508d9f5665925%7C0c503748de3f4e2597e26819d53a42b6%7C1%7C0%7C637810642206178898%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=auOsZ4L7jR35BZxi45Onk9UQWoio2xOzJ%2BqcdN7yASk%3D&reserved=0
> >> as an example of one such use case). This being an alternative to 
> >> nonstandard things such as ISML manifests.
> >>
> >> Additionally, since it seemed to be specified at the end of the given 
> >> structures, I added it at the end of these given boxes. Apparently thus it 
> >> made your live patching of that box no longer compatible with these 
> >> parsers, since you just append your required things to the end of it. Am I 
> >> understanding things correctly?
> >>
> >
> > Our code adds the sinf box after the existing stsd entry, it is correct 
> > also when btrt is present, as an evidence to this - playback works fine on 
> > all other devices.
> > The problem, in my understanding, is in the decoder present on the affected 
> > Sony TV models - it seems the decoder is making an assumption that the sinf 
> > box should come right after the esds box,
> > while AFAIK, the spec does not mandate any order. Verbatim response we got 
> > from Sony: "btrt box in the audio chunk is causing the TV decoder to fail. 
> > TV decoder is expecting sinf box after esds box.".
> >
> > So, even though it seems the TV decoder is the culprit, since the btrt atom 
> > can cause such failures, IMHO it should be omitted by default.
> > Users who need the benefits this atom provides, will be able to enable this 
> > functionality, of course.
>
> Ability to turn it off is OK, changing default to not write it does not
> seem right.
>
> Also you are poiting at btrt atom, but in fact sony said: "TV decoder
> expecting sinf box after sdds box", so the proper fix seems to be to
> change the order of the atoms, and add a big fat warning to the code that
> because of some sony TV models, sinf box must be immediately after esds
> box. Is this doable?
>

My understanding (feel free to correct me if I understood it
incorrectly) is that they are patching the written box structures
afterwards, and that is now failing. So what libavformat itself is
writing out in movenc actually works.

Which is what the expected result should be, since I think this code
has been in movenc since release 4.4, I think? I would have expected
that if movenc's output was not working by itself that we would have
issues spawning regarding that.

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] avfilter: Added siti filter

2022-02-22 Thread Thilo Borgmann

Am 15.02.22 um 09:54 schrieb Anton Khirnov:

Quoting Thilo Borgmann (2022-02-12 11:55:39)

Am 31.01.22 um 12:55 schrieb James Almer:
+static int config_input(AVFilterLink *inlink)
+{
+// Video input data avilable
+AVFilterContext *ctx = inlink->dst;
+SiTiContext *s = ctx->priv;
+int max_pixsteps[4];
+size_t pixel_sz;
+size_t data_sz;
+size_t gradient_sz;
+size_t motion_sz;
+
+const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format);
+av_image_fill_max_pixsteps(max_pixsteps, NULL, desc);
+
+s->pixel_depth = max_pixsteps[0];
+s->width = inlink->w;
+s->height = inlink->h;
+pixel_sz = s->pixel_depth == 1 ? sizeof(uint8_t) : sizeof(uint16_t);
+data_sz = s->width * pixel_sz * s->height;
+
+s->prev_frame = av_malloc(data_sz);
+
+gradient_sz = (s->width - 2) * sizeof(double) * (s->height - 2);
+s->gradient_matrix = (double*)av_malloc(gradient_sz);
+
+motion_sz = s->width * sizeof(double) * s->height;
+s->motion_matrix = (double*)av_malloc(motion_sz);


useless casts


+
+if (!s->prev_frame || ! s->gradient_matrix || !s->motion_matrix) {
+av_freep(&s->prev_frame);
+av_freep(&s->gradient_matrix);
+av_freep(&s->motion_matrix);


You don't need to free them on failure, that will be done in uninit. But
you should free them at the beginning of this function, because
config_input can be called multiple times.


Always freep'd and fail on alloc error.



+// Applies sobel convolution
+static void convolve_sobel(SiTiContext *s, const uint8_t *src, double *dst, 
int linesize)
+{
+double x_conv_sum;
+double y_conv_sum;
+double gradient;
+int ki;
+int kj;
+int index;
+uint16_t data;
+int filter_width = 3;
+int filter_size = filter_width * filter_width;
+int stride = linesize / s->pixel_depth;
+
+// Dst matrix is smaller than src since we ignore edges that can't be 
convolved
+#define CONVOLVE(bps)   \
+{   \
+uint##bps##_t *vsrc = (uint##bps##_t*)src;  \
+for (int j = 1; j < s->height - 1; j++) {   \
+for (int i = 1; i < s->width - 1; i++) {\
+x_conv_sum = 0.0;   \
+y_conv_sum = 0.0;   \
+for (int k = 0; k < filter_size; k++) { \
+ki = k % filter_width - 1;  \
+kj = floor(k / filter_width) - 1;   \
+index = (j + kj) * stride + (i + ki);   \
+data = convert_full_range(s, vsrc[index]);  \


Pass bps as a parameter to convert_full_range() instead of accessing
s->pixel_depth, so the compiler can optimize the branch away.


I am not sure if the changes I did here suit the optimization you had in 
mind... pls check if v4 does this right.





+// Calculate pixel difference between current and previous frame, and update 
previous
+static void calculate_motion(SiTiContext *s, const uint8_t *curr,
+ double *motion_matrix, int linesize)
+{
+int stride = linesize / s->pixel_depth;
+double motion;
+int curr_index;
+int prev_index;
+uint16_t curr_data;
+
+// Previous frame is already converted to full range
+#define CALCULATE(bps)   \
+{\
+uint##bps##_t *vsrc = (uint##bps##_t*)curr;  \
+for (int j = 0; j < s->height; j++) {\
+for (int i = 0; i < s->width; i++) { \
+motion = 0;  \
+curr_index = j * stride + i; \
+prev_index = j * s->width + i;   \
+curr_data = convert_full_range(s, vsrc[curr_index]); \
+if (s->nb_frames > 1)\
+motion = curr_data - s->prev_frame[prev_index];  \
+s->prev_frame[prev_index] = curr_data;   \


previous code accessed this as uint8_t or uint16_t based on bps



Fixed in v4. Attached.

Thanks,
ThiloFrom 8f2c410dbfc7e8651c6654ce57efe144dba62592 Mon Sep 17 00:00:00 2001
From: Boris Baracaldo 
Date: Tue, 22 Feb 2022 12:23:07 +0100
Subject: [PATCH v4] lavfilter: Add SITI filter

Calculate Spatial Info (SI) and Temporal Info (TI) scores for a video, as 
defined
in ITU-T P.910: Subjective video quality assessment methods for multimedia
applications.
---
 Changelog|   1 +
 doc/filters.texi |  23 +++
 libavfilter/Makefile |   1 +
 libavfilter/allfilters.c |   1 +
 libavfilter/version.h|   2 +-
 libavfilter/vf_siti.c   

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

2022-02-22 Thread Thilo Borgmann

Am 18.02.22 um 17:08 schrieb Paul B Mahol:

On Sat, Feb 12, 2022 at 11:55 AM Thilo Borgmann 
wrote:


Am 31.01.22 um 12:55 schrieb James Almer:



On 1/31/2022 8:53 AM, Anton Khirnov wrote:

Quoting Thilo Borgmann (2022-01-18 14:58:07)

Violations of code style.


Enhanced.


Not enough. There are still many remaining, e.g.
* opening brace of a function definition should be on its own line
* the context should generally be the first argument
* unsigned char* should be uint8_t*
* mixed declarations and code (the compiler should warn about that)


I think someone said that clang (or some versions) is apparently not

warning about this, hence why so many of these end up being missed in
reviews or even by the patch author.

This and all of Anton's comments in v3. Also removed some more obviously
useless doubles.



Why it uses doubles in so many places?
Is there any real benefit in that, except extra slowdown?


I guess because it's originating in some c&p Matlab code.
I did %s#double#float#g for v4, loosing some precision we can ignore IMHO.



v3:

Total frames: 2

Spatial Information:
Average: 165.451985
Max: 165.817542
Min: 165.086427

Temporal Information:
Average: 1.007263
Max: 2.014525
Min: 0.00



v4:

Total frames: 2

Spatial Information:
Average: 164.385895
Max: 164.742325
Min: 164.029480

Temporal Information:
Average: 1.007241
Max: 2.014483
Min: 0.00

-Thilo
___
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] lavfi/drawtext: Add localtime_ms for millisecond precision

2022-02-22 Thread Thilo Borgmann

Am 08.02.22 um 11:41 schrieb Thilo Borgmann:

Am 08.02.22 um 10:27 schrieb Andreas Rheinhardt:

Thilo Borgmann:

Am 01.02.22 um 00:40 schrieb Andreas Rheinhardt:

Thilo Borgmann:

Am 31.01.22 um 14:08 schrieb Nicolas George:

Thilo Borgman (12022-01-31):

v10 attached.


Also going to apply soon if there are no more comments.


I think you neglected to attach the file.


omg stupid me. Here it is...

-Thilo



Seems like I misunderstood your code and ignored the outer while. Your
code can leak if there are multiple 'N', because (as I said)



+
+    if (fmt_new && fmt_new != argv[0] && fmt_new !=
fmt_default)
+    av_freep(&fmt_new);
+


does not free fmt if it is already allocated. It is possible to fix this
by adding an char *fmt_allocated = NULL; at outer scope and a fmt_new in
the block that is executed if a 'N' is executed. (You have to free
fmt_allocated immediately after av_asprintf().)



But maybe it would be best to use an AVBPrint to write the new string
instead of allocating a new string for every %N encountered.


v11 does it that way.





+    av_bprintf(&fmt_bp, "%s", fmt_begin);
+    av_bprint_finalize(&fmt_bp, (char**)&fmt);
+    if (!fmt)
+    return AVERROR(ENOMEM);
+
  av_bprint_strftime(bp, fmt, &tm);
+    av_freep(&fmt);
+


This is not how one uses an AVBPrint: You are loosing the
small-string-optimization that way.
Furthermore, you do not check for truncation.


v12 including IRC comments.


Ping.

-Thilo
___
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/2] avdevice/avfoundation: fix memleak

2022-02-22 Thread Thilo Borgmann

Am 19.02.22 um 09:45 schrieb "zhilizhao(赵志立)":




On Feb 8, 2022, at 9:05 PM, Andreas Rheinhardt  
wrote:

Thilo Borgmann:

Am 08.02.22 um 13:50 schrieb Andreas Rheinhardt:

Thilo Borgmann:

Am 04.02.22 um 17:19 schrieb Zhao Zhili:

---
libavdevice/avfoundation.m | 10 ++
1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/libavdevice/avfoundation.m b/libavdevice/avfoundation.m
index 0cd6e646d5..2078c4879c 100644
--- a/libavdevice/avfoundation.m
+++ b/libavdevice/avfoundation.m
@@ -106,6 +106,7 @@ typedef struct
int audio_device_index;
int audio_stream_index;
+char*url;
char*video_filename;
char*audio_filename;
@@ -299,6 +300,7 @@ static void destroy_context(AVFContext* ctx)
ctx->avf_delegate= NULL;
ctx->avf_audio_delegate = NULL;
+av_freep(&ctx->url);
av_freep(&ctx->audio_buffer);


Why carry it in the context instead of adding the missing av_freep() in
parse_device_name() ?



Because video_filename and audio_filename point into it.


Wondering if we couldn't skip av_strdup() and operate on s->url directly
then.



This would trash s->url.


Ping. Can this patch set be applied?


Pushed, thanks!

-Thilo

___
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/2] avdevice/avfoundation: check strdup

2022-02-22 Thread Thilo Borgmann

Am 04.02.22 um 17:19 schrieb Zhao Zhili:

---
  libavdevice/avfoundation.m | 12 ++--
  1 file changed, 10 insertions(+), 2 deletions(-)


Pushed, thanks!

-Thilo
___
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 0/7] Add UUID functionality to libavutil

2022-02-22 Thread Zane van Iperen
This patchset adds functions for handling UUIDs to libavutil, under the 
av_uuid_*
prefix, and refactors the various ad-hoc handling to use it. This was
proposed in [1].

This is _heavily_ based off libuuid with various parts of the code
simplified to remove unnecessary functionality (e.g. generation, and v1
UUIDs).

Why not use libuuid directly?
* It introduces yet another external dependency,
* has issues building on Windows, and
* the code is relatively small, stable, and unlikely to change.

[1]: https://ffmpeg.org/pipermail/ffmpeg-devel/2022-January/291917.html


Pierre-Anthony Lemieux (6):
  avutil/tests/uuid: add uuid tests
  avformat/mov: refactor to use avutil/uuid
  avformat/smoothstreamingenc: refactor to use avutil/uuid
  avcodec/cbs_sei: refactor to use avutil/uuid
  avformat/imf: refactor to use avutil/uuid
  avfilter/showinfo: refactor to use avutil/uuid

Zane van Iperen (1):
  avutil/uuid: add utility library for manipulating UUIDs as specified
in RFC 4122

 libavcodec/cbs_sei.h |   3 +-
 libavcodec/vaapi_encode_h264.c   |   8 +-
 libavfilter/vf_showinfo.c|  17 +---
 libavformat/imf.h|  18 +---
 libavformat/imf_cpl.c|  60 ---
 libavformat/imfdec.c |  34 +++
 libavformat/mov.c|  25 ++---
 libavformat/movenc.c |   9 +-
 libavformat/smoothstreamingenc.c |   7 +-
 libavformat/tests/imf.c  |  18 ++--
 libavutil/Makefile   |   3 +
 libavutil/tests/.gitignore   |   1 +
 libavutil/tests/uuid.c   | 139 +
 libavutil/uuid.c | 156 +
 libavutil/uuid.h | 167 +++
 tests/fate/libavutil.mak |   5 +
 16 files changed, 556 insertions(+), 114 deletions(-)
 create mode 100644 libavutil/tests/uuid.c
 create mode 100644 libavutil/uuid.c
 create mode 100644 libavutil/uuid.h

-- 
2.35.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/7] avutil/uuid: add utility library for manipulating UUIDs as specified in RFC 4122

2022-02-22 Thread Zane van Iperen
Loosely based on libuuid

Co-authored-by: Pierre-Anthony Lemieux 
Signed-off-by: Pierre-Anthony Lemieux 
Signed-off-by: Zane van Iperen 
---
 libavutil/Makefile |   2 +
 libavutil/uuid.c   | 156 ++
 libavutil/uuid.h   | 167 +
 3 files changed, 325 insertions(+)
 create mode 100644 libavutil/uuid.c
 create mode 100644 libavutil/uuid.h

diff --git a/libavutil/Makefile b/libavutil/Makefile
index d17876df1a..e0f40412d0 100644
--- a/libavutil/Makefile
+++ b/libavutil/Makefile
@@ -80,6 +80,7 @@ HEADERS = adler32.h   
  \
   timestamp.h   \
   tree.h\
   twofish.h \
+  uuid.h\
   version.h \
   video_enc_params.h\
   xtea.h\
@@ -172,6 +173,7 @@ OBJS = adler32.o
\
tx_float.o   \
tx_double.o  \
tx_int32.o   \
+   uuid.o   \
video_enc_params.o   \
film_grain_params.o  \
 
diff --git a/libavutil/uuid.c b/libavutil/uuid.c
new file mode 100644
index 00..7bcbbe487f
--- /dev/null
+++ b/libavutil/uuid.c
@@ -0,0 +1,156 @@
+/*
+ * Copyright (c) 2022 Pierre-Anthony Lemieux 
+ *Zane van Iperen 
+ *
+ * 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
+ */
+
+/*
+ * Copyright (C) 1996, 1997 Theodore Ts'o.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, and the entire permission notice in its entirety,
+ *including the disclaimer of warranties.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ *products derived from this software without specific prior
+ *written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF
+ * WHICH ARE HEREBY DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF NOT ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ */
+
+/**
+ * @file
+ * UUID parsing and serialization utilities.
+ * The library treat the UUID as an opaque sequence of 16 unsigned bytes,
+ * i.e. ignoring the internal layout of the UUID, which depends on the type
+ * of the UUID.
+ *
+ * @author Pierre-Anthony Lemieux 
+ * @author Zane van Iperen 
+ */
+
+#include "uuid.h"
+#include "error.h"
+#include "avstring.h"
+#include 
+#include 
+
+int av_uuid_parse(const char *in, AVUUID uu)
+{
+size_t len = strlen(in);
+if (len != 36)
+return -1;
+
+return av_uuid_parse_range(in, in + len, uu);
+}
+
+int av_uuid_parse_range(const char *in_start, const char *in_end, AVUUID uu)
+{
+int i;
+const char *cp;
+char buf[3

[FFmpeg-devel] [PATCH 2/7] avutil/tests/uuid: add uuid tests

2022-02-22 Thread Zane van Iperen
From: Pierre-Anthony Lemieux 

Signed-off-by: Pierre-Anthony Lemieux 
Signed-off-by: Zane van Iperen 
---
 libavutil/Makefile |   1 +
 libavutil/tests/.gitignore |   1 +
 libavutil/tests/uuid.c | 139 +
 tests/fate/libavutil.mak   |   5 ++
 4 files changed, 146 insertions(+)
 create mode 100644 libavutil/tests/uuid.c

diff --git a/libavutil/Makefile b/libavutil/Makefile
index e0f40412d0..76f8023ce2 100644
--- a/libavutil/Makefile
+++ b/libavutil/Makefile
@@ -258,6 +258,7 @@ TESTPROGS = adler32 
\
 tree\
 twofish \
 utf8\
+uuid\
 xtea\
 tea \
 
diff --git a/libavutil/tests/.gitignore b/libavutil/tests/.gitignore
index 9d90827954..919010e4fc 100644
--- a/libavutil/tests/.gitignore
+++ b/libavutil/tests/.gitignore
@@ -48,4 +48,5 @@
 /tree
 /twofish
 /utf8
+/uuid
 /xtea
diff --git a/libavutil/tests/uuid.c b/libavutil/tests/uuid.c
new file mode 100644
index 00..0a7a0eb07d
--- /dev/null
+++ b/libavutil/tests/uuid.c
@@ -0,0 +1,139 @@
+/*
+ * Copyright (c) 2022 Pierre-Anthony Lemieux 
+ *Zane van Iperen 
+ *
+ * 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 "libavutil/uuid.h"
+#include "libavutil/log.h"
+
+static const char *UUID_1= "6021b21e-894e-43ff-8317-1ca891c1c49b";
+static const char *UUID_1_UC = "6021B21E-894E-43FF-8317-1CA891C1C49B";
+static const char *UUID_1_MIXED  = "6021b21e-894E-43fF-8317-1CA891C1c49b";
+static const char *UUID_1_URN= 
"urn:uuid:6021b21e-894e-43ff-8317-1ca891c1c49b";
+static const AVUUID UUID_1_BYTES = {0x60, 0x21, 0xb2, 0x1e, 0x89, 0x4e, 0x43, 
0xff,
+0x83, 0x17, 0x1c, 0xa8, 0x91, 0xc1, 0xc4, 
0x9b};
+
+static const AVUUID UUID_NIL = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
0x00};
+
+static const char *UUID_BAD_1 = "16a2c9f8-afbc-4767-8621-8cb2b27599";
+static const char *UUID_BAD_2 = "75df62c2999b4bd38c9d8058fcde9123";
+static const char *UUID_BAD_3 = "a1b9a05e-f1d1-464g-a951-1ba0a374f02";
+static const char *UUID_BAD_4 = "279c66d432-7b39-41d5-966f-5e8138265c20";
+
+int main(int argc, char **argv)
+{
+AVUUID uuid;
+AVUUID uuid2 = {0x32, 0xc7, 0x00, 0xc4, 0xd5, 0xd7, 0x42, 0x0,
+0x93, 0xc0, 0x3b, 0x6d, 0xea, 0x1b, 0x20, 0x5b};
+
+/* test parsing */
+
+if (av_uuid_parse(UUID_1, uuid))
+return 1;
+
+if (!av_uuid_equal(uuid, UUID_1_BYTES))
+return 1;
+
+/* test nil */
+
+av_uuid_nil_set(uuid);
+
+if (!av_uuid_equal(uuid, UUID_NIL))
+return 1;
+
+/* test equality */
+
+if (av_uuid_equal(UUID_1_BYTES, uuid2))
+return 1;
+
+/* test copy */
+
+av_uuid_copy(uuid2, UUID_1_BYTES);
+
+if (!av_uuid_equal(uuid2, UUID_1_BYTES))
+return 1;
+
+/* test uppercase parsing */
+
+if (av_uuid_parse(UUID_1_UC, uuid))
+return 1;
+
+if (!av_uuid_equal(uuid, UUID_1_BYTES))
+return 1;
+
+/* test mixed-case parsing */
+
+if (av_uuid_parse(UUID_1_MIXED, uuid))
+return 1;
+
+if (!av_uuid_equal(uuid, UUID_1_BYTES))
+return 1;
+
+/* test URN uuid parse */
+
+if (av_uuid_urn_parse(UUID_1_URN, uuid))
+return 1;
+
+if (!av_uuid_equal(uuid, UUID_1_BYTES))
+return 1;
+
+/* test parse range */
+
+if (av_uuid_parse_range(UUID_1_URN + 9, UUID_1_URN + 45, uuid))
+return 1;
+
+if (!av_uuid_equal(uuid, UUID_1_BYTES))
+return 1;
+
+/* test bad parse range */
+
+if (!av_uuid_parse_range(UUID_1_URN + 9, UUID_1_URN + 44, uuid))
+return 1;
+
+/* test bad parse range 2 */
+
+if (!av_uuid_parse_range(UUID_1_URN + 8, UUID_1_URN + 44, uuid))
+return 1;
+
+/* test bad parse range 2 */
+
+if (!av_uu

[FFmpeg-devel] [PATCH 3/7] avformat/mov: refactor to use avutil/uuid

2022-02-22 Thread Zane van Iperen
From: Pierre-Anthony Lemieux 

Signed-off-by: Pierre-Anthony Lemieux 
Signed-off-by: Zane van Iperen 
---
 libavformat/mov.c| 25 +
 libavformat/movenc.c |  9 +
 2 files changed, 18 insertions(+), 16 deletions(-)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 5e26267810..728d44b19d 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -48,6 +48,7 @@
 #include "libavutil/stereo3d.h"
 #include "libavutil/timecode.h"
 #include "libavutil/dovi_meta.h"
+#include "libavutil/uuid.h"
 #include "libavcodec/ac3tab.h"
 #include "libavcodec/flac.h"
 #include "libavcodec/mpegaudiodecheader.h"
@@ -5796,21 +5797,21 @@ static int mov_read_uuid(MOVContext *c, AVIOContext 
*pb, MOVAtom atom)
 AVStream *st;
 MOVStreamContext *sc;
 int64_t ret;
-uint8_t uuid[16];
-static const uint8_t uuid_isml_manifest[] = {
+AVUUID uuid;
+static const AVUUID uuid_isml_manifest = {
 0xa5, 0xd4, 0x0b, 0x30, 0xe8, 0x14, 0x11, 0xdd,
 0xba, 0x2f, 0x08, 0x00, 0x20, 0x0c, 0x9a, 0x66
 };
-static const uint8_t uuid_xmp[] = {
+static const AVUUID uuid_xmp = {
 0xbe, 0x7a, 0xcf, 0xcb, 0x97, 0xa9, 0x42, 0xe8,
 0x9c, 0x71, 0x99, 0x94, 0x91, 0xe3, 0xaf, 0xac
 };
-static const uint8_t uuid_spherical[] = {
+static const AVUUID uuid_spherical = {
 0xff, 0xcc, 0x82, 0x63, 0xf8, 0x55, 0x4a, 0x93,
 0x88, 0x14, 0x58, 0x7a, 0x02, 0x52, 0x1f, 0xdd,
 };
 
-if (atom.size < sizeof(uuid) || atom.size >= FFMIN(INT_MAX, SIZE_MAX))
+if (atom.size < AV_UUID_LEN || atom.size >= FFMIN(INT_MAX, SIZE_MAX))
 return AVERROR_INVALIDDATA;
 
 if (c->fc->nb_streams < 1)
@@ -5818,13 +5819,13 @@ static int mov_read_uuid(MOVContext *c, AVIOContext 
*pb, MOVAtom atom)
 st = c->fc->streams[c->fc->nb_streams - 1];
 sc = st->priv_data;
 
-ret = ffio_read_size(pb, uuid, sizeof(uuid));
+ret = ffio_read_size(pb, uuid, AV_UUID_LEN);
 if (ret < 0)
 return ret;
-if (!memcmp(uuid, uuid_isml_manifest, sizeof(uuid))) {
+if (av_uuid_equal(uuid, uuid_isml_manifest)) {
 uint8_t *buffer, *ptr;
 char *endptr;
-size_t len = atom.size - sizeof(uuid);
+size_t len = atom.size - AV_UUID_LEN;
 
 if (len < 4) {
 return AVERROR_INVALIDDATA;
@@ -5862,9 +5863,9 @@ static int mov_read_uuid(MOVContext *c, AVIOContext *pb, 
MOVAtom atom)
 }
 
 av_free(buffer);
-} else if (!memcmp(uuid, uuid_xmp, sizeof(uuid))) {
+} else if (av_uuid_equal(uuid, uuid_xmp)) {
 uint8_t *buffer;
-size_t len = atom.size - sizeof(uuid);
+size_t len = atom.size - AV_UUID_LEN;
 if (c->export_xmp) {
 buffer = av_mallocz(len + 1);
 if (!buffer) {
@@ -5884,8 +5885,8 @@ static int mov_read_uuid(MOVContext *c, AVIOContext *pb, 
MOVAtom atom)
 if (ret < 0)
 return ret;
 }
-} else if (!memcmp(uuid, uuid_spherical, sizeof(uuid))) {
-size_t len = atom.size - sizeof(uuid);
+} else if (av_uuid_equal(uuid, uuid_spherical)) {
+size_t len = atom.size - AV_UUID_LEN;
 ret = mov_parse_uuid_spherical(sc, pb, len);
 if (ret < 0)
 return ret;
diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 4c868919ae..a3bb9b9af8 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -55,6 +55,7 @@
 #include "libavutil/timecode.h"
 #include "libavutil/dovi_meta.h"
 #include "libavutil/color_utils.h"
+#include "libavutil/uuid.h"
 #include "hevc.h"
 #include "rtpenc.h"
 #include "mov_chan.h"
@@ -4288,14 +4289,14 @@ static int mov_write_isml_manifest(AVIOContext *pb, 
MOVMuxContext *mov, AVFormat
 int64_t pos = avio_tell(pb);
 int i;
 
-static const uint8_t uuid[] = {
+static const AVUUID uuid = {
 0xa5, 0xd4, 0x0b, 0x30, 0xe8, 0x14, 0x11, 0xdd,
 0xba, 0x2f, 0x08, 0x00, 0x20, 0x0c, 0x9a, 0x66
 };
 
 avio_wb32(pb, 0);
 ffio_wfourcc(pb, "uuid");
-avio_write(pb, uuid, sizeof(uuid));
+avio_write(pb, uuid, AV_UUID_LEN);
 avio_wb32(pb, 0);
 
 avio_printf(pb, "\n");
@@ -4554,7 +4555,7 @@ static int mov_write_tfxd_tag(AVIOContext *pb, MOVTrack 
*track)
 
 avio_wb32(pb, 0); /* size placeholder */
 ffio_wfourcc(pb, "uuid");
-avio_write(pb, uuid, sizeof(uuid));
+avio_write(pb, uuid, AV_UUID_LEN);
 avio_w8(pb, 1);
 avio_wb24(pb, 0);
 avio_wb64(pb, track->cluster[0].dts + track->cluster[0].cts);
@@ -4580,7 +4581,7 @@ static int mov_write_tfrf_tag(AVIOContext *pb, 
MOVMuxContext *mov,
 avio_seek(pb, track->frag_info[entry].tfrf_offset, SEEK_SET);
 avio_wb32(pb, size);
 ffio_wfourcc(pb, "uuid");
-avio_write(pb, uuid, sizeof(uuid));
+avio_write(pb, uuid, AV_UUID_LEN);
 avio_w8(pb, 1);
 avio_wb24(pb, 0);
 avio_w8(pb, n);
-- 
2.35.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http

[FFmpeg-devel] [PATCH 4/7] avformat/smoothstreamingenc: refactor to use avutil/uuid

2022-02-22 Thread Zane van Iperen
From: Pierre-Anthony Lemieux 

Signed-off-by: Pierre-Anthony Lemieux 
Signed-off-by: Zane van Iperen 
---
 libavformat/smoothstreamingenc.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/libavformat/smoothstreamingenc.c b/libavformat/smoothstreamingenc.c
index a0ea5b8fa8..6c36ae2eaa 100644
--- a/libavformat/smoothstreamingenc.c
+++ b/libavformat/smoothstreamingenc.c
@@ -38,6 +38,7 @@
 #include "libavutil/file.h"
 #include "libavutil/mathematics.h"
 #include "libavutil/intreadwrite.h"
+#include "libavutil/uuid.h"
 
 typedef struct Fragment {
 int64_t start_time, duration;
@@ -418,13 +419,13 @@ static int parse_fragment(AVFormatContext *s, const char 
*filename, int64_t *sta
 if (len < 8 || len >= *moof_size)
 goto fail;
 if (tag == MKTAG('u','u','i','d')) {
-static const uint8_t tfxd[] = {
+static const AVUUID tfxd = {
 0x6d, 0x1d, 0x9b, 0x05, 0x42, 0xd5, 0x44, 0xe6,
 0x80, 0xe2, 0x14, 0x1d, 0xaf, 0xf7, 0x57, 0xb2
 };
-uint8_t uuid[16];
+AVUUID uuid;
 avio_read(in, uuid, 16);
-if (!memcmp(uuid, tfxd, 16) && len >= 8 + 16 + 4 + 16) {
+if (av_uuid_equal(uuid, tfxd) && len >= 8 + 16 + 4 + 16) {
 avio_seek(in, 4, SEEK_CUR);
 *start_ts = avio_rb64(in);
 *duration = avio_rb64(in);
-- 
2.35.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/7] avcodec/cbs_sei: refactor to use avutil/uuid

2022-02-22 Thread Zane van Iperen
From: Pierre-Anthony Lemieux 

Signed-off-by: Pierre-Anthony Lemieux 
Signed-off-by: Zane van Iperen 
---
 libavcodec/cbs_sei.h   | 3 ++-
 libavcodec/vaapi_encode_h264.c | 8 
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/libavcodec/cbs_sei.h b/libavcodec/cbs_sei.h
index c7a7a95be0..67c6e6cbbd 100644
--- a/libavcodec/cbs_sei.h
+++ b/libavcodec/cbs_sei.h
@@ -23,6 +23,7 @@
 #include 
 
 #include "libavutil/buffer.h"
+#include "libavutil/uuid.h"
 
 #include "cbs.h"
 #include "sei.h"
@@ -41,7 +42,7 @@ typedef struct SEIRawUserDataRegistered {
 } SEIRawUserDataRegistered;
 
 typedef struct SEIRawUserDataUnregistered {
-uint8_t  uuid_iso_iec_11578[16];
+AVUUID  uuid_iso_iec_11578;
 uint8_t *data;
 AVBufferRef *data_ref;
 size_t   data_length;
diff --git a/libavcodec/vaapi_encode_h264.c b/libavcodec/vaapi_encode_h264.c
index ff37de1f7e..8d216b2595 100644
--- a/libavcodec/vaapi_encode_h264.c
+++ b/libavcodec/vaapi_encode_h264.c
@@ -25,6 +25,7 @@
 #include "libavutil/common.h"
 #include "libavutil/internal.h"
 #include "libavutil/opt.h"
+#include "libavutil/uuid.h"
 
 #include "avcodec.h"
 #include "cbs.h"
@@ -42,7 +43,7 @@ enum {
 };
 
 // Random (version 4) ISO 11578 UUID.
-static const uint8_t vaapi_encode_h264_sei_identifier_uuid[16] = {
+static const AVUUID vaapi_encode_h264_sei_identifier_uuid = {
 0x59, 0x94, 0x8b, 0x28, 0x11, 0xec, 0x45, 0xaf,
 0x96, 0x75, 0x19, 0xd4, 0x1f, 0xea, 0xa9, 0x4d,
 };
@@ -1088,9 +1089,8 @@ static av_cold int 
vaapi_encode_h264_configure(AVCodecContext *avctx)
 const char *driver;
 int len;
 
-memcpy(priv->sei_identifier.uuid_iso_iec_11578,
-   vaapi_encode_h264_sei_identifier_uuid,
-   sizeof(priv->sei_identifier.uuid_iso_iec_11578));
+av_uuid_copy(priv->sei_identifier.uuid_iso_iec_11578,
+ vaapi_encode_h264_sei_identifier_uuid);
 
 driver = vaQueryVendorString(ctx->hwctx->display);
 if (!driver)
-- 
2.35.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/7] avformat/imf: refactor to use avutil/uuid

2022-02-22 Thread Zane van Iperen
From: Pierre-Anthony Lemieux 

Signed-off-by: Pierre-Anthony Lemieux 
Signed-off-by: Zane van Iperen 
---
 libavformat/imf.h   | 18 -
 libavformat/imf_cpl.c   | 60 +++--
 libavformat/imfdec.c| 34 +++
 libavformat/tests/imf.c | 18 ++---
 4 files changed, 52 insertions(+), 78 deletions(-)

diff --git a/libavformat/imf.h b/libavformat/imf.h
index 62c4468ce9..4271cd9582 100644
--- a/libavformat/imf.h
+++ b/libavformat/imf.h
@@ -58,17 +58,9 @@
 #include "avformat.h"
 #include "libavformat/avio.h"
 #include "libavutil/rational.h"
+#include "libavutil/uuid.h"
 #include 
 
-#define FF_IMF_UUID_FORMAT\
-"urn:uuid:%02hhx%02hhx%02hhx%02hhx-%02hhx%02hhx-" \
-"%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx"
-
-/**
- * UUID as defined in IETF RFC 422
- */
-typedef uint8_t FFIMFUUID[16];
-
 /**
  * IMF Composition Playlist Base Resource
  */
@@ -84,7 +76,7 @@ typedef struct FFIMFBaseResource {
  */
 typedef struct FFIMFTrackFileResource {
 FFIMFBaseResource base;
-FFIMFUUID track_file_uuid; /**< TrackFileResourceType/TrackFileId */
+AVUUID track_file_uuid; /**< TrackFileResourceType/TrackFileId */
 } FFIMFTrackFileResource;
 
 /**
@@ -109,7 +101,7 @@ typedef struct FFIMFMarkerResource {
  * IMF Composition Playlist Virtual Track
  */
 typedef struct FFIMFBaseVirtualTrack {
-FFIMFUUID id_uuid; /**< TrackId associated with the Virtual Track */
+AVUUID id_uuid; /**< TrackId associated with the Virtual Track */
 } FFIMFBaseVirtualTrack;
 
 /**
@@ -135,7 +127,7 @@ typedef struct FFIMFMarkerVirtualTrack {
  * IMF Composition Playlist
  */
 typedef struct FFIMFCPL {
-FFIMFUUID id_uuid;   /**< 
CompositionPlaylist/Id element */
+AVUUID id_uuid;   /**< CompositionPlaylist/Id 
element */
 xmlChar *content_title_utf8; /**< 
CompositionPlaylist/ContentTitle element */
 AVRational edit_rate;/**< 
CompositionPlaylist/EditRate element */
 FFIMFMarkerVirtualTrack *main_markers_track; /**< Main Marker Virtual 
Track */
@@ -196,7 +188,7 @@ int ff_imf_xml_read_rational(xmlNodePtr element, AVRational 
*rational);
  * Reads a UUID from an XML element
  * @return 0 on success, < 0 AVERROR code on error.
  */
-int ff_imf_xml_read_uuid(xmlNodePtr element, uint8_t uuid[16]);
+int ff_imf_xml_read_uuid(xmlNodePtr element, AVUUID uuid);
 
 /**
  * Returns the first child element with the specified local name
diff --git a/libavformat/imf_cpl.c b/libavformat/imf_cpl.c
index 102a6b4549..c0d43cbfad 100644
--- a/libavformat/imf_cpl.c
+++ b/libavformat/imf_cpl.c
@@ -70,32 +70,14 @@ xmlNodePtr ff_imf_xml_get_child_element_by_name(xmlNodePtr 
parent, const char *n
 return NULL;
 }
 
-int ff_imf_xml_read_uuid(xmlNodePtr element, uint8_t uuid[16])
+int ff_imf_xml_read_uuid(xmlNodePtr element, AVUUID uuid)
 {
 xmlChar *element_text = NULL;
-int scanf_ret;
 int ret = 0;
 
 element_text = xmlNodeListGetString(element->doc, 
element->xmlChildrenNode, 1);
-scanf_ret = sscanf(element_text,
-   FF_IMF_UUID_FORMAT,
-   &uuid[0],
-   &uuid[1],
-   &uuid[2],
-   &uuid[3],
-   &uuid[4],
-   &uuid[5],
-   &uuid[6],
-   &uuid[7],
-   &uuid[8],
-   &uuid[9],
-   &uuid[10],
-   &uuid[11],
-   &uuid[12],
-   &uuid[13],
-   &uuid[14],
-   &uuid[15]);
-if (scanf_ret != 16) {
+ret = av_uuid_urn_parse(element_text, uuid);
+if (ret) {
 av_log(NULL, AV_LOG_ERROR, "Invalid UUID\n");
 ret = AVERROR_INVALIDDATA;
 }
@@ -370,7 +352,7 @@ static int fill_marker_resource(xmlNodePtr 
marker_resource_elem,
 static int push_marker_sequence(xmlNodePtr marker_sequence_elem, FFIMFCPL *cpl)
 {
 int ret = 0;
-uint8_t uuid[16];
+AVUUID uuid;
 xmlNodePtr resource_list_elem = NULL;
 xmlNodePtr resource_elem = NULL;
 xmlNodePtr track_id_elem = NULL;
@@ -388,8 +370,8 @@ static int push_marker_sequence(xmlNodePtr 
marker_sequence_elem, FFIMFCPL *cpl)
 }
 av_log(NULL,
AV_LOG_DEBUG,
-   "Processing IMF CPL Marker Sequence for Virtual Track " 
FF_IMF_UUID_FORMAT "\n",
-   UID_ARG(uuid));
+   "Processing IMF CPL Marker Sequence for Virtual Track " AV_PRI_UUID 
"\n",
+   AV_UUID_ARG(uuid));
 
 /* create main marker virtual track if it does not exist */
 if (!cpl->main_markers_track) {
@@ -397,9 +379,9 @@ static int push_marker_sequence(xmlNodePtr 
marker_sequence_elem, FFIMFCPL *cpl)
 if (!cpl->main_markers_track)
 return AVERROR(ENOMEM)

[FFmpeg-devel] [PATCH 7/7] avfilter/showinfo: refactor to use avutil/uuid

2022-02-22 Thread Zane van Iperen
From: Pierre-Anthony Lemieux 

Signed-off-by: Pierre-Anthony Lemieux 
Signed-off-by: Zane van Iperen 
---
 libavfilter/vf_showinfo.c | 17 +
 1 file changed, 5 insertions(+), 12 deletions(-)

diff --git a/libavfilter/vf_showinfo.c b/libavfilter/vf_showinfo.c
index 71728bced4..395e87c486 100644
--- a/libavfilter/vf_showinfo.c
+++ b/libavfilter/vf_showinfo.c
@@ -41,6 +41,7 @@
 #include "libavutil/mastering_display_metadata.h"
 #include "libavutil/video_enc_params.h"
 #include "libavutil/detection_bbox.h"
+#include "libavutil/uuid.h"
 
 #include "avfilter.h"
 #include "internal.h"
@@ -337,29 +338,21 @@ static void dump_video_enc_params(AVFilterContext *ctx, 
const AVFrameSideData *s
 
 static void dump_sei_unregistered_metadata(AVFilterContext *ctx, const 
AVFrameSideData *sd)
 {
-const int uuid_size = 16;
 const uint8_t *user_data = sd->data;
 int i;
 
-if (sd->size < uuid_size) {
+if (sd->size < AV_UUID_LEN) {
 av_log(ctx, AV_LOG_ERROR, "invalid data(%"SIZE_SPECIFIER" < "
-   "UUID(%d-bytes))\n", sd->size, uuid_size);
+   "UUID(%d-bytes))\n", sd->size, AV_UUID_LEN);
 return;
 }
 
 av_log(ctx, AV_LOG_INFO, "User Data Unregistered:\n");
-av_log(ctx, AV_LOG_INFO, "UUID=");
-for (i = 0; i < uuid_size; i++) {
-av_log(ctx, AV_LOG_INFO, "%02x", user_data[i]);
-if (i == 3 || i == 5 || i == 7 || i == 9)
-av_log(ctx, AV_LOG_INFO, "-");
-}
-av_log(ctx, AV_LOG_INFO, "\n");
+av_log(ctx, AV_LOG_INFO, "UUID=" AV_PRI_UUID "\n", AV_UUID_ARG(user_data));
 
 av_log(ctx, AV_LOG_INFO, "User Data=");
-for (; i < sd->size; i++) {
+for (i = 16; i < sd->size; i++)
 av_log(ctx, AV_LOG_INFO, "%02x", user_data[i]);
-}
 av_log(ctx, AV_LOG_INFO, "\n");
 }
 
-- 
2.35.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".


Re: [FFmpeg-devel] [PATCH] arm64: Add Armv8.3-A PAC support to assembly files

2022-02-22 Thread Martin Storsjö

On Mon, 14 Feb 2022, Andre Kempe wrote:


This patch adds optional support for Arm Pointer Authentication Codes.

PAC support is turned on or off at compile time using additional
compiler flags. Unless any of these is enabled explicitly, no additional
code will be emitted at all.

Signed-off-by: André Kempe 
---
libavcodec/aarch64/fft_neon.S  |   3 +-
libavcodec/aarch64/mdct_neon.S |  17 -
libavcodec/aarch64/synth_filter_neon.S |   2 +
libavutil/aarch64/asm.S| 102 +++--
4 files changed, 113 insertions(+), 11 deletions(-)


LGTM, this looks generally correct and consistent to me.

But I realized one thing (which probably should be fixed both here and in 
dav1d, but which I guess we can fix separately afterwards too) - I guess 
we should only output the .note.gnu.property section if we're targeting 
ELF. (I guess that PAC/BTI aren't used on other platforms yet, but it's 
plausible that they will be, and then they won't use ELF note sections to 
signal it.)


// Martin
___
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/7] avutil/uuid: add utility library for manipulating UUIDs as specified in RFC 4122

2022-02-22 Thread James Almer




On 2/22/2022 10:01 AM, Zane van Iperen wrote:

Loosely based on libuuid

Co-authored-by: Pierre-Anthony Lemieux 
Signed-off-by: Pierre-Anthony Lemieux 
Signed-off-by: Zane van Iperen 
---
  libavutil/Makefile |   2 +
  libavutil/uuid.c   | 156 ++
  libavutil/uuid.h   | 167 +
  3 files changed, 325 insertions(+)
  create mode 100644 libavutil/uuid.c
  create mode 100644 libavutil/uuid.h

diff --git a/libavutil/Makefile b/libavutil/Makefile
index d17876df1a..e0f40412d0 100644
--- a/libavutil/Makefile
+++ b/libavutil/Makefile
@@ -80,6 +80,7 @@ HEADERS = adler32.h   
  \
timestamp.h   \
tree.h\
twofish.h \
+  uuid.h\
version.h \
video_enc_params.h\
xtea.h\
@@ -172,6 +173,7 @@ OBJS = adler32.o
\
 tx_float.o   \
 tx_double.o  \
 tx_int32.o   \
+   uuid.o   \
 video_enc_params.o   \
 film_grain_params.o  \
  
diff --git a/libavutil/uuid.c b/libavutil/uuid.c

new file mode 100644
index 00..7bcbbe487f
--- /dev/null
+++ b/libavutil/uuid.c
@@ -0,0 +1,156 @@
+/*
+ * Copyright (c) 2022 Pierre-Anthony Lemieux 
+ *Zane van Iperen 
+ *
+ * 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
+ */
+
+/*
+ * Copyright (C) 1996, 1997 Theodore Ts'o.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, and the entire permission notice in its entirety,
+ *including the disclaimer of warranties.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ *products derived from this software without specific prior
+ *written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF
+ * WHICH ARE HEREBY DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF NOT ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ */
+
+/**
+ * @file
+ * UUID parsing and serialization utilities.
+ * The library treat the UUID as an opaque sequence of 16 unsigned bytes,
+ * i.e. ignoring the internal layout of the UUID, which depends on the type
+ * of the UUID.
+ *
+ * @author Pierre-Anthony Lemieux 
+ * @author Zane van Iperen 
+ */
+
+#include "uuid.h"
+#include "error.h"
+#include "avstring.h"
+#include 
+#include 
+
+int av_uuid_parse(const char *in, AVUUID uu)
+{
+size_t len = strlen(in);
+if (len != 36)
+return -1;
+
+return av_uuid_parse_range(in, in + len, uu);
+}
+
+int av_uuid_parse_range(const char *in_start, const char *

Re: [FFmpeg-devel] [PATCH 1/7] avutil/uuid: add utility library for manipulating UUIDs as specified in RFC 4122

2022-02-22 Thread Zane van Iperen




On 22/2/22 23:01, Zane van Iperen wrote:


+int av_uuid_urn_parse(const char *in, AVUUID uu)
+{
+return av_uuid_parse(in + 9, uu);


Self-review: this should check if "strlen(in) == 45", then simply
return av_uuid_parse_range(in + 9).
___
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 v3] avformat/nutdec: Add check for avformat_new_stream

2022-02-22 Thread Michael Niedermayer
On Tue, Feb 22, 2022 at 10:41:51AM +0800, Jiasheng Jiang wrote:
> As the potential failure of the memory allocation,
> the avformat_new_stream() could return NULL pointer.
> Therefore, it should be better to check it and return
> error if fails.
> Also, the caller, nut_read_header(), needs to deal with
> the return value of the decode_main_header() and return
> error if memory allocation fails.
> And 'time_base_count' has already checked and it
> will return AVERROR_INVALIDDATA if fails, which is different
> from ENOMEM.
> 
> Fixes: 619d8e2e58 ("updating nut demuxer to latest spec no muxing yet no 
> index yet no seeking yet libnuts crcs dont match mine (didnt investigate yet) 
> samplerate is stored wrong by libnut (demuxer has a workaround) code is not 
> clean or beautifull yet, but i thought its better to commit early before 
> someone unneccesarily wastes his time duplicating the work demuxer split from 
> muxer")
> 
> Signed-off-by: Jiasheng Jiang 
> ---
> Changelog:
> 
> v1 -> v2
> 
> * Change 1. Add the error handling for ENOMEM from decode_main_header()
> in nut_read_header().
> * Change 2. Check for the 'time_base_count'.
> 
> v2 -> v3
> 
> * Change 1. Remove the check for 'time_base_count'.
> * Change 2. Change the av_free to av_freep.
> ---
>  libavformat/nutdec.c | 17 +
>  1 file changed, 13 insertions(+), 4 deletions(-)
> 
> diff --git a/libavformat/nutdec.c b/libavformat/nutdec.c
> index 0a8a700acf..32a4f6bbcb 100644
> --- a/libavformat/nutdec.c
> +++ b/libavformat/nutdec.c
> @@ -351,8 +351,13 @@ static int decode_main_header(NUTContext *nut)
>  ret = AVERROR(ENOMEM);
>  goto fail;
>  }
> -for (i = 0; i < stream_count; i++)
> -avformat_new_stream(s, NULL);
> +for (i = 0; i < stream_count; i++) {
> +if (!avformat_new_stream(s, NULL)) {
> +av_freep(nut->stream);

is this actually needed or isnt this freed anyway ?
also if needed thats the wrong pointer 
av_freep(&nut->stream)

[...]

thx

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

In fact, the RIAA has been known to suggest that students drop out
of college or go to community college in order to be able to afford
settlements. -- The RIAA


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 1/3] avfilter/af_loudnorm: switch to activate

2022-02-22 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 libavfilter/af_loudnorm.c | 62 ++-
 1 file changed, 48 insertions(+), 14 deletions(-)

diff --git a/libavfilter/af_loudnorm.c b/libavfilter/af_loudnorm.c
index dbe7fba986..5b4b6e8548 100644
--- a/libavfilter/af_loudnorm.c
+++ b/libavfilter/af_loudnorm.c
@@ -22,6 +22,7 @@
 
 #include "libavutil/opt.h"
 #include "avfilter.h"
+#include "filters.h"
 #include "internal.h"
 #include "audio.h"
 #include "ebur128.h"
@@ -502,9 +503,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
 ff_ebur128_add_frames_double(s->r128_out, dst, subframe_length);
 
 s->pts +=
-out->nb_samples =
-inlink->min_samples =
-inlink->max_samples = subframe_length;
+out->nb_samples = subframe_length;
 
 s->frame_type = INNER_FRAME;
 break;
@@ -636,15 +635,14 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
 return ff_filter_frame(outlink, out);
 }
 
-static int request_frame(AVFilterLink *outlink)
+static int flush_frame(AVFilterLink *outlink)
 {
-int ret;
 AVFilterContext *ctx = outlink->src;
 AVFilterLink *inlink = ctx->inputs[0];
 LoudNormContext *s = ctx->priv;
+int ret = 0;
 
-ret = ff_request_frame(inlink);
-if (ret == AVERROR_EOF && s->frame_type == INNER_FRAME) {
+if (s->frame_type == INNER_FRAME) {
 double *src;
 double *buf;
 int nb_samples, n, c, offset;
@@ -681,6 +679,48 @@ static int request_frame(AVFilterLink *outlink)
 return ret;
 }
 
+static int activate(AVFilterContext *ctx)
+{
+AVFilterLink *inlink = ctx->inputs[0];
+AVFilterLink *outlink = ctx->outputs[0];
+LoudNormContext *s = ctx->priv;
+AVFrame *in = NULL;
+int ret = 0, status;
+int64_t pts;
+
+FF_FILTER_FORWARD_STATUS_BACK(outlink, inlink);
+
+if (s->frame_type != LINEAR_MODE) {
+int nb_samples;
+
+if (s->frame_type == FIRST_FRAME) {
+nb_samples = frame_size(inlink->sample_rate, 3000);
+} else {
+nb_samples = frame_size(inlink->sample_rate, 100);
+}
+
+ret = ff_inlink_consume_samples(inlink, nb_samples, nb_samples, &in);
+} else {
+ret = ff_inlink_consume_frame(inlink, &in);
+}
+
+if (ret < 0)
+return ret;
+if (ret > 0)
+ret = filter_frame(inlink, in);
+if (ret < 0)
+return ret;
+
+if (ff_inlink_acknowledge_status(inlink, &status, &pts)) {
+ff_outlink_set_status(outlink, status, pts);
+return flush_frame(outlink);
+}
+
+FF_FILTER_FORWARD_WANTED(outlink, inlink);
+
+return FFERROR_NOT_READY;
+}
+
 static int query_formats(AVFilterContext *ctx)
 {
 LoudNormContext *s = ctx->priv;
@@ -749,11 +789,6 @@ static int config_input(AVFilterLink *inlink)
 
 init_gaussian_filter(s);
 
-if (s->frame_type != LINEAR_MODE) {
-inlink->min_samples =
-inlink->max_samples = frame_size(inlink->sample_rate, 3000);
-}
-
 s->pts = AV_NOPTS_VALUE;
 s->buf_index =
 s->prev_buf_index =
@@ -894,14 +929,12 @@ static const AVFilterPad avfilter_af_loudnorm_inputs[] = {
 .name = "default",
 .type = AVMEDIA_TYPE_AUDIO,
 .config_props = config_input,
-.filter_frame = filter_frame,
 },
 };
 
 static const AVFilterPad avfilter_af_loudnorm_outputs[] = {
 {
 .name  = "default",
-.request_frame = request_frame,
 .type  = AVMEDIA_TYPE_AUDIO,
 },
 };
@@ -912,6 +945,7 @@ const AVFilter ff_af_loudnorm = {
 .priv_size = sizeof(LoudNormContext),
 .priv_class= &loudnorm_class,
 .init  = init,
+.activate  = activate,
 .uninit= uninit,
 FILTER_INPUTS(avfilter_af_loudnorm_inputs),
 FILTER_OUTPUTS(avfilter_af_loudnorm_outputs),
-- 
2.33.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 2/3] avfilter/af_loudnorm: stop rewritting pts

2022-02-22 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 libavfilter/af_loudnorm.c | 23 +--
 1 file changed, 13 insertions(+), 10 deletions(-)

diff --git a/libavfilter/af_loudnorm.c b/libavfilter/af_loudnorm.c
index 5b4b6e8548..7c8ac3a39d 100644
--- a/libavfilter/af_loudnorm.c
+++ b/libavfilter/af_loudnorm.c
@@ -86,7 +86,7 @@ typedef struct LoudNormContext {
 int attack_length;
 int release_length;
 
-int64_t pts;
+int64_t pts[30];
 enum FrameType frame_type;
 int above_threshold;
 int prev_nb_samples;
@@ -432,10 +432,9 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
 av_frame_copy_props(out, in);
 }
 
-if (s->pts == AV_NOPTS_VALUE)
-s->pts = in->pts;
+out->pts = s->pts[0];
+memmove(s->pts, &s->pts[1], (FF_ARRAY_ELEMS(s->pts) - 1) * 
sizeof(s->pts[0]));
 
-out->pts = s->pts;
 src = (const double *)in->data[0];
 dst = (double *)out->data[0];
 buf = s->buf;
@@ -502,7 +501,6 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
 true_peak_limiter(s, dst, subframe_length, inlink->channels);
 ff_ebur128_add_frames_double(s->r128_out, dst, subframe_length);
 
-s->pts +=
 out->nb_samples = subframe_length;
 
 s->frame_type = INNER_FRAME;
@@ -567,7 +565,6 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
 if (s->index >= 30)
 s->index -= 30;
 s->prev_nb_samples = in->nb_samples;
-s->pts += in->nb_samples;
 break;
 
 case FINAL_FRAME:
@@ -625,13 +622,11 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
 
 dst = (double *)out->data[0];
 ff_ebur128_add_frames_double(s->r128_out, dst, in->nb_samples);
-s->pts += in->nb_samples;
 break;
 }
 
 if (in != out)
 av_frame_free(&in);
-
 return ff_filter_frame(outlink, out);
 }
 
@@ -706,8 +701,17 @@ static int activate(AVFilterContext *ctx)
 
 if (ret < 0)
 return ret;
-if (ret > 0)
+if (ret > 0) {
+if (s->frame_type == FIRST_FRAME) {
+const int nb_samples = frame_size(inlink->sample_rate, 100);
+
+for (int i = 0; i < FF_ARRAY_ELEMS(s->pts); i++)
+s->pts[i] = in->pts + i * nb_samples;
+} else {
+s->pts[29] = in->pts;
+}
 ret = filter_frame(inlink, in);
+}
 if (ret < 0)
 return ret;
 
@@ -789,7 +793,6 @@ static int config_input(AVFilterLink *inlink)
 
 init_gaussian_filter(s);
 
-s->pts = AV_NOPTS_VALUE;
 s->buf_index =
 s->prev_buf_index =
 s->limiter_buf_index = 0;
-- 
2.33.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 3/3] avfilter/af_loudnorm: remove hard clipping of samples

2022-02-22 Thread Paul B Mahol
It can cause unpleasant artifacts.

Signed-off-by: Paul B Mahol 
---
 libavfilter/af_loudnorm.c | 6 +-
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/libavfilter/af_loudnorm.c b/libavfilter/af_loudnorm.c
index 7c8ac3a39d..9bb0c65bb7 100644
--- a/libavfilter/af_loudnorm.c
+++ b/libavfilter/af_loudnorm.c
@@ -394,12 +394,8 @@ static void true_peak_limiter(LoudNormContext *s, double 
*out, int nb_samples, i
 } while (smp_cnt < nb_samples);
 
 for (n = 0; n < nb_samples; n++) {
-for (c = 0; c < channels; c++) {
+for (c = 0; c < channels; c++)
 out[c] = buf[index + c];
-if (fabs(out[c]) > ceiling) {
-out[c] = ceiling * (out[c] < 0 ? -1 : 1);
-}
-}
 out += channels;
 index += channels;
 if (index >= s->limiter_buf_size)
-- 
2.33.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 6/6] avcodec/setts_bsf: add constants to modify packet duration

2022-02-22 Thread James Almer

On 2/14/2022 7:41 PM, James Almer wrote:

Signed-off-by: James Almer 
---
Missing doc changes.

  libavcodec/setts_bsf.c | 25 -
  1 file changed, 24 insertions(+), 1 deletion(-)


Ping for set.

Original patches 2, 3 and 4 are withdrawn, so the set is:
[PATCH 1/6] ffmpeg: flush delayed frames in codec copy scenarios
[PATCH 2/4] ffmpeg: ensure a keyframe was not seen before skipping packets
[PATCH 5/6] avcodec/setts_bsf: add NEXT_PTS/DTS expression constants
[PATCH 6/6] avcodec/setts_bsf: add constants to modify packet duration
___
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 6/6] avcodec/setts_bsf: add constants to modify packet duration

2022-02-22 Thread Paul B Mahol
On Tue, Feb 22, 2022 at 5:50 PM James Almer  wrote:

> On 2/14/2022 7:41 PM, James Almer wrote:
> > Signed-off-by: James Almer 
> > ---
> > Missing doc changes.
> >
> >   libavcodec/setts_bsf.c | 25 -
> >   1 file changed, 24 insertions(+), 1 deletion(-)
>
> Ping for set.
>
> Original patches 2, 3 and 4 are withdrawn, so the set is:
> [PATCH 1/6] ffmpeg: flush delayed frames in codec copy scenarios
> [PATCH 2/4] ffmpeg: ensure a keyframe was not seen before skipping packets
> [PATCH 5/6] avcodec/setts_bsf: add NEXT_PTS/DTS expression constants
> [PATCH 6/6] avcodec/setts_bsf: add constants to modify packet duration
>

setts_bsf changes 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".
>
___
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/2] lavc/bsf: add general documentation

2022-02-22 Thread James Almer




On 2/22/2022 3:27 AM, Anton Khirnov wrote:

Also, place the BSF api docs in their own doxygen group.
---
  libavcodec/bsf.h | 23 ++-
  1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/libavcodec/bsf.h b/libavcodec/bsf.h
index 8c5355d186..ba8b48f222 100644
--- a/libavcodec/bsf.h
+++ b/libavcodec/bsf.h
@@ -30,7 +30,28 @@
  #include "packet.h"
  
  /**

- * @addtogroup lavc_core
+ * @defgroup lavc_bsf Bitstream filters
+ * @ingroup libavc
+ *
+ * Bitstream filters transform encoded media data without decoding it. This
+ * allows e.g. manipulating various header values. Bitstream filters operate on
+ * @ref AVPacket "AVPackets".
+ *
+ * The bitstream filtering API is centered around two structures:
+ * AVBitStreamFilter and AVBSFContext. The former represents a bitstream filter


Could use @ref here and below, too.


+ * in abstract, the latter a specific filtering process. Obtain an
+ * AVBitStreamFilter using av_bsf_get_by_name() or av_bsf_iterate(), then pass
+ * it to av_bsf_alloc() to create an AVBSFContext. Fill in the user-settable
+ * AVBSFContext fields, as described in its documentation, then call
+ * av_bsf_init() to prepare the filter context for use.
+ *
+ * Submit packets for filtering using av_bsf_send_packet(), obtain filtered
+ * results with av_bsf_receive_packet(). When no more input packets will be
+ * sent, submit a NULL AVPacket to signal the end of the stream to the filter.


The doxy for av_bsf_send_packet() states the packet must be "empty", 
meaning either "NULL, or pkt->data is NULL and pkt->side_data_elems 
zero", so probably mention the same here so it's consistent.



+ * av_bsf_receive_packet() will then return trailing packets, if any are
+ * produced by the filter.
+ *
+ * Finally, free the filter context with av_bsf_free().
   * @{
   */


LGTM otherwise.
___
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] avcodec/h263dec: Avoid copying data when flipping image

2022-02-22 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/h263dec.c | 14 --
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c
index e940b7f7c7..423036e97b 100644
--- a/libavcodec/h263dec.c
+++ b/libavcodec/h263dec.c
@@ -703,17 +703,11 @@ frame_end:
 if (s->last_picture_ptr || s->low_delay) {
 if (   pict->format == AV_PIX_FMT_YUV420P
 && (s->codec_tag == AV_RL32("GEOV") || s->codec_tag == 
AV_RL32("GEOX"))) {
-int x, y, p;
-av_frame_make_writable(pict);
-for (p=0; p<3; p++) {
-int w = AV_CEIL_RSHIFT(pict-> width, !!p);
+for (int p = 0; p < 3; p++) {
 int h = AV_CEIL_RSHIFT(pict->height, !!p);
-int linesize = pict->linesize[p];
-for (y=0; y<(h>>1); y++)
-for (x=0; xdata[p][x + y*linesize],
-   pict->data[p][x + (h-1-y)*linesize]);
+
+pict->data[p] += (h - 1) * pict->linesize[p];
+pict->linesize[p] *= -1;
 }
 }
 *got_frame = 1;
-- 
2.32.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 3/3] avformat/movenc: Add support for AVIF muxing

2022-02-22 Thread Vignesh Venkatasubramanian
Add an AVIF muxer by re-using the existing the mov/mp4 muxer.

AVIF Specifiation: https://aomediacodec.github.io/av1-avif

Sample usage for still image:
ffmpeg -i image.png -c:v libaom-av1 -avif-image 1 image.avif

Sample usage for animated AVIF image:
ffmpeg -i video.mp4 animated.avif

We can re-use any of the AV1 encoding options that will make
sense for image encoding (like bitrate, tiles, encoding speed,
etc).

The files generated by this muxer has been verified to be valid
AVIF files by the following:
1) Displays on Chrome (both still and animated images).
2) Displays on Firefox (only still images, firefox does not support
   animated AVIF yet).
3) Verfied to be valid by Compliance Warden:
   https://github.com/gpac/ComplianceWarden

Fixes the encoder/muxer part of Trac Ticket #7621

Signed-off-by: Vignesh Venkatasubramanian 
---
 configure|   1 +
 libavformat/allformats.c |   1 +
 libavformat/movenc.c | 300 +++
 libavformat/movenc.h |   5 +
 4 files changed, 283 insertions(+), 24 deletions(-)

diff --git a/configure b/configure
index 1535dc3c5b..87b380fe3a 100755
--- a/configure
+++ b/configure
@@ -3393,6 +3393,7 @@ asf_stream_muxer_select="asf_muxer"
 av1_demuxer_select="av1_frame_merge_bsf av1_parser"
 avi_demuxer_select="riffdec exif"
 avi_muxer_select="riffenc"
+avif_muxer_select="mov_muxer"
 caf_demuxer_select="iso_media"
 caf_muxer_select="iso_media"
 dash_muxer_select="mp4_muxer"
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index d066a7745b..400c17afbd 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -81,6 +81,7 @@ extern const AVOutputFormat ff_au_muxer;
 extern const AVInputFormat  ff_av1_demuxer;
 extern const AVInputFormat  ff_avi_demuxer;
 extern const AVOutputFormat ff_avi_muxer;
+extern const AVOutputFormat ff_avif_muxer;
 extern const AVInputFormat  ff_avisynth_demuxer;
 extern const AVOutputFormat ff_avm2_muxer;
 extern const AVInputFormat  ff_avr_demuxer;
diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 1a746a67fd..05537d1e78 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -1303,7 +1303,7 @@ static int mov_write_av1c_tag(AVIOContext *pb, MOVTrack 
*track)
 
 avio_wb32(pb, 0);
 ffio_wfourcc(pb, "av1C");
-ff_isom_write_av1c(pb, track->vos_data, track->vos_len, 1);
+ff_isom_write_av1c(pb, track->vos_data, track->vos_len, track->mode != 
MODE_AVIF);
 return update_size(pb, pos);
 }
 
@@ -2004,12 +2004,13 @@ static int mov_write_colr_tag(AVIOContext *pb, MOVTrack 
*track, int prefer_icc)
 }
 }
 
-/* We should only ever be called by MOV or MP4. */
-av_assert0(track->mode == MODE_MOV || track->mode == MODE_MP4);
+/* We should only ever be called for MOV, MP4 and AVIF. */
+av_assert0(track->mode == MODE_MOV || track->mode == MODE_MP4 ||
+   track->mode == MODE_AVIF);
 
 avio_wb32(pb, 0); /* size */
 ffio_wfourcc(pb, "colr");
-if (track->mode == MODE_MP4)
+if (track->mode == MODE_MP4 || track->mode == MODE_AVIF)
 ffio_wfourcc(pb, "nclx");
 else
 ffio_wfourcc(pb, "nclc");
@@ -2019,7 +2020,7 @@ static int mov_write_colr_tag(AVIOContext *pb, MOVTrack 
*track, int prefer_icc)
 avio_wb16(pb, track->par->color_primaries);
 avio_wb16(pb, track->par->color_trc);
 avio_wb16(pb, track->par->color_space);
-if (track->mode == MODE_MP4) {
+if (track->mode == MODE_MP4 || track->mode == MODE_AVIF) {
 int full_range = track->par->color_range == AVCOL_RANGE_JPEG;
 avio_w8(pb, full_range << 7);
 }
@@ -2103,6 +2104,8 @@ static void find_compressor(char * compressor_name, int 
len, MOVTrack *track)
 av_strlcatf(compressor_name, len, " %d%c", track->par->height, 
interlaced ? 'i' : 'p');
 
 av_strlcatf(compressor_name, len, "%d", rate * (interlaced + 1));
+} else if (track->par->codec_id == AV_CODEC_ID_AV1 && track->mode == 
MODE_AVIF) {
+av_strlcatf(compressor_name, len, "libaom Encoder");
 }
 }
 
@@ -2123,6 +2126,8 @@ static int mov_write_video_tag(AVFormatContext *s, 
AVIOContext *pb, MOVMuxContex
 avio_wb32(pb, 0); /* size */
 if (mov->encryption_scheme != MOV_ENC_NONE) {
 ffio_wfourcc(pb, "encv");
+} else if (track->mode == MODE_AVIF) {
+ffio_wfourcc(pb, "av01");
 } else {
 avio_wl32(pb, track->tag); // store it byteswapped
 }
@@ -2239,7 +2244,7 @@ static int mov_write_video_tag(AVFormatContext *s, 
AVIOContext *pb, MOVMuxContex
 else
 av_log(mov->fc, AV_LOG_WARNING, "Not writing 'gama' atom. Format 
is not MOV.\n");
 }
-if (track->mode == MODE_MOV || track->mode == MODE_MP4) {
+if (track->mode == MODE_MOV || track->mode == MODE_MP4 || track->mode == 
MODE_AVIF) {
 int has_color_info = track->par->color_primaries != 
AVCOL_PRI_UNSPECIFIED &&
  track->par->color_trc != AVCOL_TRC_UNSPECIFIED &&
  

Re: [FFmpeg-devel] [PATCH 3/3] avformat/movenc: Add support for AVIF muxing

2022-02-22 Thread James Almer




On 2/22/2022 3:40 PM, Vignesh Venkatasubramanian wrote:

Add an AVIF muxer by re-using the existing the mov/mp4 muxer.

AVIF Specifiation: https://aomediacodec.github.io/av1-avif

Sample usage for still image:
ffmpeg -i image.png -c:v libaom-av1 -avif-image 1 image.avif

Sample usage for animated AVIF image:
ffmpeg -i video.mp4 animated.avif

We can re-use any of the AV1 encoding options that will make
sense for image encoding (like bitrate, tiles, encoding speed,
etc).

The files generated by this muxer has been verified to be valid
AVIF files by the following:
1) Displays on Chrome (both still and animated images).
2) Displays on Firefox (only still images, firefox does not support
animated AVIF yet).
3) Verfied to be valid by Compliance Warden:
https://github.com/gpac/ComplianceWarden

Fixes the encoder/muxer part of Trac Ticket #7621

Signed-off-by: Vignesh Venkatasubramanian 
---
  configure|   1 +
  libavformat/allformats.c |   1 +
  libavformat/movenc.c | 300 +++
  libavformat/movenc.h |   5 +
  4 files changed, 283 insertions(+), 24 deletions(-)

diff --git a/configure b/configure
index 1535dc3c5b..87b380fe3a 100755
--- a/configure
+++ b/configure
@@ -3393,6 +3393,7 @@ asf_stream_muxer_select="asf_muxer"
  av1_demuxer_select="av1_frame_merge_bsf av1_parser"
  avi_demuxer_select="riffdec exif"
  avi_muxer_select="riffenc"
+avif_muxer_select="mov_muxer"
  caf_demuxer_select="iso_media"
  caf_muxer_select="iso_media"
  dash_muxer_select="mp4_muxer"
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index d066a7745b..400c17afbd 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -81,6 +81,7 @@ extern const AVOutputFormat ff_au_muxer;
  extern const AVInputFormat  ff_av1_demuxer;
  extern const AVInputFormat  ff_avi_demuxer;
  extern const AVOutputFormat ff_avi_muxer;
+extern const AVOutputFormat ff_avif_muxer;
  extern const AVInputFormat  ff_avisynth_demuxer;
  extern const AVOutputFormat ff_avm2_muxer;
  extern const AVInputFormat  ff_avr_demuxer;
diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 1a746a67fd..05537d1e78 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -1303,7 +1303,7 @@ static int mov_write_av1c_tag(AVIOContext *pb, MOVTrack 
*track)
  
  avio_wb32(pb, 0);

  ffio_wfourcc(pb, "av1C");
-ff_isom_write_av1c(pb, track->vos_data, track->vos_len, 1);
+ff_isom_write_av1c(pb, track->vos_data, track->vos_len, track->mode != 
MODE_AVIF);
  return update_size(pb, pos);
  }
  
@@ -2004,12 +2004,13 @@ static int mov_write_colr_tag(AVIOContext *pb, MOVTrack *track, int prefer_icc)

  }
  }
  
-/* We should only ever be called by MOV or MP4. */

-av_assert0(track->mode == MODE_MOV || track->mode == MODE_MP4);
+/* We should only ever be called for MOV, MP4 and AVIF. */
+av_assert0(track->mode == MODE_MOV || track->mode == MODE_MP4 ||
+   track->mode == MODE_AVIF);
  
  avio_wb32(pb, 0); /* size */

  ffio_wfourcc(pb, "colr");
-if (track->mode == MODE_MP4)
+if (track->mode == MODE_MP4 || track->mode == MODE_AVIF)
  ffio_wfourcc(pb, "nclx");
  else
  ffio_wfourcc(pb, "nclc");
@@ -2019,7 +2020,7 @@ static int mov_write_colr_tag(AVIOContext *pb, MOVTrack 
*track, int prefer_icc)
  avio_wb16(pb, track->par->color_primaries);
  avio_wb16(pb, track->par->color_trc);
  avio_wb16(pb, track->par->color_space);
-if (track->mode == MODE_MP4) {
+if (track->mode == MODE_MP4 || track->mode == MODE_AVIF) {
  int full_range = track->par->color_range == AVCOL_RANGE_JPEG;
  avio_w8(pb, full_range << 7);
  }
@@ -2103,6 +2104,8 @@ static void find_compressor(char * compressor_name, int 
len, MOVTrack *track)
  av_strlcatf(compressor_name, len, " %d%c", track->par->height, 
interlaced ? 'i' : 'p');
  
  av_strlcatf(compressor_name, len, "%d", rate * (interlaced + 1));

+} else if (track->par->codec_id == AV_CODEC_ID_AV1 && track->mode == 
MODE_AVIF) {
+av_strlcatf(compressor_name, len, "libaom Encoder");
libaom is not the only AV1 encoder supported by libavcodec, a 
libavformat user could even not use a libavcodec based encoder to begin 
with, and then there's also the codec copy scenario where no encoder is 
used at all.


This should probably use the same path as MODE_MOV above if there's a 
key "encoder" in track->st->metadata, and write it.

___
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/3] avcodec/libaomenc: Add parameter for avif single image encoding

2022-02-22 Thread Vignesh Venkatasubramanian
Add a parameter to libaom-av1 encoder to enforce some of the single
image constraints in the AV1 encoder. Setting this flag will limit
the encoder to producing exactly one frame and the sequence header
that is produced by the encoder will be conformant to the AVIF
specification [1].

Part of Fixing Trac ticket #7621

[1] https://aomediacodec.github.io/av1-avif

Signed-off-by:: Vignesh Venkatasubramanian 
---
 libavcodec/libaomenc.c | 14 ++
 1 file changed, 14 insertions(+)

diff --git a/libavcodec/libaomenc.c b/libavcodec/libaomenc.c
index 963cc1bcbc..a6d752ab4a 100644
--- a/libavcodec/libaomenc.c
+++ b/libavcodec/libaomenc.c
@@ -99,6 +99,7 @@ typedef struct AOMEncoderContext {
 int enable_restoration;
 int usage;
 int tune;
+int still_picture;
 int enable_rect_partitions;
 int enable_1to4_partitions;
 int enable_ab_partitions;
@@ -746,6 +747,18 @@ static av_cold int aom_init(AVCodecContext *avctx,
 if (res < 0)
 return res;
 
+if (ctx->still_picture) {
+// Set the maximum number of frames to 1. This will let libaom set
+// still_picture and reduced_still_picture_header to 1 in the Sequence
+// Header as required by AVIF still images.
+enccfg.g_limit = 1;
+// Reduce memory usage for still images.
+enccfg.g_lag_in_frames = 0;
+// All frames will be key frames.
+enccfg.kf_max_dist = 0;
+enccfg.kf_mode = AOM_KF_DISABLED;
+}
+
 /* Construct Encoder Context */
 res = aom_codec_enc_init(&ctx->encoder, iface, &enccfg, flags);
 if (res != AOM_CODEC_OK) {
@@ -1290,6 +1303,7 @@ static const AVOption options[] = {
 { "psnr",NULL, 0, AV_OPT_TYPE_CONST, {.i64 = 
AOM_TUNE_PSNR}, 0, 0, VE, "tune"},
 { "ssim",NULL, 0, AV_OPT_TYPE_CONST, {.i64 = 
AOM_TUNE_SSIM}, 0, 0, VE, "tune"},
 FF_AV1_PROFILE_OPTS
+{ "still-picture", "Encode in single frame mode (typically used for still 
AVIF images).", OFFSET(still_picture), AV_OPT_TYPE_BOOL, {.i64 = 0}, -1, 1, VE 
},
 { "enable-rect-partitions", "Enable rectangular partitions", 
OFFSET(enable_rect_partitions), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE},
 { "enable-1to4-partitions", "Enable 1:4/4:1 partitions", 
OFFSET(enable_1to4_partitions), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE},
 { "enable-ab-partitions",   "Enable ab shape partitions",
OFFSET(enable_ab_partitions),   AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE},
-- 
2.35.1.473.g83b2b277ed-goog

___
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/3] avformat/movenc: Add support for AVIF muxing

2022-02-22 Thread Vignesh Venkatasubramanian
Add an AVIF muxer by re-using the existing the mov/mp4 muxer.

AVIF Specifiation: https://aomediacodec.github.io/av1-avif

Sample usage for still image:
ffmpeg -i image.png -c:v libaom-av1 -avif-image 1 image.avif

Sample usage for animated AVIF image:
ffmpeg -i video.mp4 animated.avif

We can re-use any of the AV1 encoding options that will make
sense for image encoding (like bitrate, tiles, encoding speed,
etc).

The files generated by this muxer has been verified to be valid
AVIF files by the following:
1) Displays on Chrome (both still and animated images).
2) Displays on Firefox (only still images, firefox does not support
   animated AVIF yet).
3) Verfied to be valid by Compliance Warden:
   https://github.com/gpac/ComplianceWarden

Fixes the encoder/muxer part of Trac Ticket #7621

Signed-off-by: Vignesh Venkatasubramanian 
---
 configure|   1 +
 libavformat/allformats.c |   1 +
 libavformat/movenc.c | 302 +++
 libavformat/movenc.h |   5 +
 4 files changed, 284 insertions(+), 25 deletions(-)

diff --git a/configure b/configure
index 1535dc3c5b..87b380fe3a 100755
--- a/configure
+++ b/configure
@@ -3393,6 +3393,7 @@ asf_stream_muxer_select="asf_muxer"
 av1_demuxer_select="av1_frame_merge_bsf av1_parser"
 avi_demuxer_select="riffdec exif"
 avi_muxer_select="riffenc"
+avif_muxer_select="mov_muxer"
 caf_demuxer_select="iso_media"
 caf_muxer_select="iso_media"
 dash_muxer_select="mp4_muxer"
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index d066a7745b..400c17afbd 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -81,6 +81,7 @@ extern const AVOutputFormat ff_au_muxer;
 extern const AVInputFormat  ff_av1_demuxer;
 extern const AVInputFormat  ff_avi_demuxer;
 extern const AVOutputFormat ff_avi_muxer;
+extern const AVOutputFormat ff_avif_muxer;
 extern const AVInputFormat  ff_avisynth_demuxer;
 extern const AVOutputFormat ff_avm2_muxer;
 extern const AVInputFormat  ff_avr_demuxer;
diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 1a746a67fd..9575f8cc6f 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -1303,7 +1303,7 @@ static int mov_write_av1c_tag(AVIOContext *pb, MOVTrack 
*track)
 
 avio_wb32(pb, 0);
 ffio_wfourcc(pb, "av1C");
-ff_isom_write_av1c(pb, track->vos_data, track->vos_len, 1);
+ff_isom_write_av1c(pb, track->vos_data, track->vos_len, track->mode != 
MODE_AVIF);
 return update_size(pb, pos);
 }
 
@@ -2004,12 +2004,13 @@ static int mov_write_colr_tag(AVIOContext *pb, MOVTrack 
*track, int prefer_icc)
 }
 }
 
-/* We should only ever be called by MOV or MP4. */
-av_assert0(track->mode == MODE_MOV || track->mode == MODE_MP4);
+/* We should only ever be called for MOV, MP4 and AVIF. */
+av_assert0(track->mode == MODE_MOV || track->mode == MODE_MP4 ||
+   track->mode == MODE_AVIF);
 
 avio_wb32(pb, 0); /* size */
 ffio_wfourcc(pb, "colr");
-if (track->mode == MODE_MP4)
+if (track->mode == MODE_MP4 || track->mode == MODE_AVIF)
 ffio_wfourcc(pb, "nclx");
 else
 ffio_wfourcc(pb, "nclc");
@@ -2019,7 +2020,7 @@ static int mov_write_colr_tag(AVIOContext *pb, MOVTrack 
*track, int prefer_icc)
 avio_wb16(pb, track->par->color_primaries);
 avio_wb16(pb, track->par->color_trc);
 avio_wb16(pb, track->par->color_space);
-if (track->mode == MODE_MP4) {
+if (track->mode == MODE_MP4 || track->mode == MODE_AVIF) {
 int full_range = track->par->color_range == AVCOL_RANGE_JPEG;
 avio_w8(pb, full_range << 7);
 }
@@ -2085,7 +2086,7 @@ static void find_compressor(char * compressor_name, int 
len, MOVTrack *track)
   || (track->par->width == 1440 && track->par->height == 1080)
   || (track->par->width == 1920 && track->par->height == 1080);
 
-if (track->mode == MODE_MOV &&
+if ((track->mode == MODE_AVIF || track->mode == MODE_MOV) &&
 (encoder = av_dict_get(track->st->metadata, "encoder", NULL, 0))) {
 av_strlcpy(compressor_name, encoder->value, 32);
 } else if (track->par->codec_id == AV_CODEC_ID_MPEG2VIDEO && xdcam_res) {
@@ -2103,6 +2104,8 @@ static void find_compressor(char * compressor_name, int 
len, MOVTrack *track)
 av_strlcatf(compressor_name, len, " %d%c", track->par->height, 
interlaced ? 'i' : 'p');
 
 av_strlcatf(compressor_name, len, "%d", rate * (interlaced + 1));
+} else if (track->par->codec_id == AV_CODEC_ID_AV1 && track->mode == 
MODE_AVIF) {
+av_strlcatf(compressor_name, len, "libaom Encoder");
 }
 }
 
@@ -2123,6 +2126,8 @@ static int mov_write_video_tag(AVFormatContext *s, 
AVIOContext *pb, MOVMuxContex
 avio_wb32(pb, 0); /* size */
 if (mov->encryption_scheme != MOV_ENC_NONE) {
 ffio_wfourcc(pb, "encv");
+} else if (track->mode == MODE_AVIF) {
+ffio_wfourcc(pb, "av01");
 } else {
 avio_wl32(pb, track->tag); // s

Re: [FFmpeg-devel] [PATCH 3/3] avformat/movenc: Add support for AVIF muxing

2022-02-22 Thread Vignesh Venkatasubramanian
On Tue, Feb 22, 2022 at 12:03 PM James Almer  wrote:

>
>
> On 2/22/2022 3:40 PM, Vignesh Venkatasubramanian wrote:
> > Add an AVIF muxer by re-using the existing the mov/mp4 muxer.
> >
> > AVIF Specifiation: https://aomediacodec.github.io/av1-avif
> >
> > Sample usage for still image:
> > ffmpeg -i image.png -c:v libaom-av1 -avif-image 1 image.avif
> >
> > Sample usage for animated AVIF image:
> > ffmpeg -i video.mp4 animated.avif
> >
> > We can re-use any of the AV1 encoding options that will make
> > sense for image encoding (like bitrate, tiles, encoding speed,
> > etc).
> >
> > The files generated by this muxer has been verified to be valid
> > AVIF files by the following:
> > 1) Displays on Chrome (both still and animated images).
> > 2) Displays on Firefox (only still images, firefox does not support
> > animated AVIF yet).
> > 3) Verfied to be valid by Compliance Warden:
> > https://github.com/gpac/ComplianceWarden
> >
> > Fixes the encoder/muxer part of Trac Ticket #7621
> >
> > Signed-off-by: Vignesh Venkatasubramanian 
> > ---
> >   configure|   1 +
> >   libavformat/allformats.c |   1 +
> >   libavformat/movenc.c | 300 +++
> >   libavformat/movenc.h |   5 +
> >   4 files changed, 283 insertions(+), 24 deletions(-)
> >
> > diff --git a/configure b/configure
> > index 1535dc3c5b..87b380fe3a 100755
> > --- a/configure
> > +++ b/configure
> > @@ -3393,6 +3393,7 @@ asf_stream_muxer_select="asf_muxer"
> >   av1_demuxer_select="av1_frame_merge_bsf av1_parser"
> >   avi_demuxer_select="riffdec exif"
> >   avi_muxer_select="riffenc"
> > +avif_muxer_select="mov_muxer"
> >   caf_demuxer_select="iso_media"
> >   caf_muxer_select="iso_media"
> >   dash_muxer_select="mp4_muxer"
> > diff --git a/libavformat/allformats.c b/libavformat/allformats.c
> > index d066a7745b..400c17afbd 100644
> > --- a/libavformat/allformats.c
> > +++ b/libavformat/allformats.c
> > @@ -81,6 +81,7 @@ extern const AVOutputFormat ff_au_muxer;
> >   extern const AVInputFormat  ff_av1_demuxer;
> >   extern const AVInputFormat  ff_avi_demuxer;
> >   extern const AVOutputFormat ff_avi_muxer;
> > +extern const AVOutputFormat ff_avif_muxer;
> >   extern const AVInputFormat  ff_avisynth_demuxer;
> >   extern const AVOutputFormat ff_avm2_muxer;
> >   extern const AVInputFormat  ff_avr_demuxer;
> > diff --git a/libavformat/movenc.c b/libavformat/movenc.c
> > index 1a746a67fd..05537d1e78 100644
> > --- a/libavformat/movenc.c
> > +++ b/libavformat/movenc.c
> > @@ -1303,7 +1303,7 @@ static int mov_write_av1c_tag(AVIOContext *pb,
> MOVTrack *track)
> >
> >   avio_wb32(pb, 0);
> >   ffio_wfourcc(pb, "av1C");
> > -ff_isom_write_av1c(pb, track->vos_data, track->vos_len, 1);
> > +ff_isom_write_av1c(pb, track->vos_data, track->vos_len, track->mode
> != MODE_AVIF);
> >   return update_size(pb, pos);
> >   }
> >
> > @@ -2004,12 +2004,13 @@ static int mov_write_colr_tag(AVIOContext *pb,
> MOVTrack *track, int prefer_icc)
> >   }
> >   }
> >
> > -/* We should only ever be called by MOV or MP4. */
> > -av_assert0(track->mode == MODE_MOV || track->mode == MODE_MP4);
> > +/* We should only ever be called for MOV, MP4 and AVIF. */
> > +av_assert0(track->mode == MODE_MOV || track->mode == MODE_MP4 ||
> > +   track->mode == MODE_AVIF);
> >
> >   avio_wb32(pb, 0); /* size */
> >   ffio_wfourcc(pb, "colr");
> > -if (track->mode == MODE_MP4)
> > +if (track->mode == MODE_MP4 || track->mode == MODE_AVIF)
> >   ffio_wfourcc(pb, "nclx");
> >   else
> >   ffio_wfourcc(pb, "nclc");
> > @@ -2019,7 +2020,7 @@ static int mov_write_colr_tag(AVIOContext *pb,
> MOVTrack *track, int prefer_icc)
> >   avio_wb16(pb, track->par->color_primaries);
> >   avio_wb16(pb, track->par->color_trc);
> >   avio_wb16(pb, track->par->color_space);
> > -if (track->mode == MODE_MP4) {
> > +if (track->mode == MODE_MP4 || track->mode == MODE_AVIF) {
> >   int full_range = track->par->color_range == AVCOL_RANGE_JPEG;
> >   avio_w8(pb, full_range << 7);
> >   }
> > @@ -2103,6 +2104,8 @@ static void find_compressor(char *
> compressor_name, int len, MOVTrack *track)
> >   av_strlcatf(compressor_name, len, " %d%c", track->par->height,
> interlaced ? 'i' : 'p');
> >
> >   av_strlcatf(compressor_name, len, "%d", rate * (interlaced +
> 1));
> > +} else if (track->par->codec_id == AV_CODEC_ID_AV1 && track->mode
> == MODE_AVIF) {
> > +av_strlcatf(compressor_name, len, "libaom Encoder");
> libaom is not the only AV1 encoder supported by libavcodec, a
> libavformat user could even not use a libavcodec based encoder to begin
> with, and then there's also the codec copy scenario where no encoder is
> used at all.
>
> This should probably use the same path as MODE_MOV above if there's a
> key "encoder" in track->st->metadata, and write it.
>

Done.


> 

[FFmpeg-devel] [PATCH 3/3] avformat/movenc: Add support for AVIF muxing

2022-02-22 Thread Vignesh Venkatasubramanian
Add an AVIF muxer by re-using the existing the mov/mp4 muxer.

AVIF Specifiation: https://aomediacodec.github.io/av1-avif

Sample usage for still image:
ffmpeg -i image.png -c:v libaom-av1 -avif-image 1 image.avif

Sample usage for animated AVIF image:
ffmpeg -i video.mp4 animated.avif

We can re-use any of the AV1 encoding options that will make
sense for image encoding (like bitrate, tiles, encoding speed,
etc).

The files generated by this muxer has been verified to be valid
AVIF files by the following:
1) Displays on Chrome (both still and animated images).
2) Displays on Firefox (only still images, firefox does not support
   animated AVIF yet).
3) Verfied to be valid by Compliance Warden:
   https://github.com/gpac/ComplianceWarden

Fixes the encoder/muxer part of Trac Ticket #7621

Signed-off-by: Vignesh Venkatasubramanian 
---
 configure|   1 +
 libavformat/allformats.c |   1 +
 libavformat/movenc.c | 300 +++
 libavformat/movenc.h |   5 +
 4 files changed, 282 insertions(+), 25 deletions(-)

diff --git a/configure b/configure
index 1535dc3c5b..87b380fe3a 100755
--- a/configure
+++ b/configure
@@ -3393,6 +3393,7 @@ asf_stream_muxer_select="asf_muxer"
 av1_demuxer_select="av1_frame_merge_bsf av1_parser"
 avi_demuxer_select="riffdec exif"
 avi_muxer_select="riffenc"
+avif_muxer_select="mov_muxer"
 caf_demuxer_select="iso_media"
 caf_muxer_select="iso_media"
 dash_muxer_select="mp4_muxer"
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index d066a7745b..400c17afbd 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -81,6 +81,7 @@ extern const AVOutputFormat ff_au_muxer;
 extern const AVInputFormat  ff_av1_demuxer;
 extern const AVInputFormat  ff_avi_demuxer;
 extern const AVOutputFormat ff_avi_muxer;
+extern const AVOutputFormat ff_avif_muxer;
 extern const AVInputFormat  ff_avisynth_demuxer;
 extern const AVOutputFormat ff_avm2_muxer;
 extern const AVInputFormat  ff_avr_demuxer;
diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 1a746a67fd..53258f0d11 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -1303,7 +1303,7 @@ static int mov_write_av1c_tag(AVIOContext *pb, MOVTrack 
*track)
 
 avio_wb32(pb, 0);
 ffio_wfourcc(pb, "av1C");
-ff_isom_write_av1c(pb, track->vos_data, track->vos_len, 1);
+ff_isom_write_av1c(pb, track->vos_data, track->vos_len, track->mode != 
MODE_AVIF);
 return update_size(pb, pos);
 }
 
@@ -2004,12 +2004,13 @@ static int mov_write_colr_tag(AVIOContext *pb, MOVTrack 
*track, int prefer_icc)
 }
 }
 
-/* We should only ever be called by MOV or MP4. */
-av_assert0(track->mode == MODE_MOV || track->mode == MODE_MP4);
+/* We should only ever be called for MOV, MP4 and AVIF. */
+av_assert0(track->mode == MODE_MOV || track->mode == MODE_MP4 ||
+   track->mode == MODE_AVIF);
 
 avio_wb32(pb, 0); /* size */
 ffio_wfourcc(pb, "colr");
-if (track->mode == MODE_MP4)
+if (track->mode == MODE_MP4 || track->mode == MODE_AVIF)
 ffio_wfourcc(pb, "nclx");
 else
 ffio_wfourcc(pb, "nclc");
@@ -2019,7 +2020,7 @@ static int mov_write_colr_tag(AVIOContext *pb, MOVTrack 
*track, int prefer_icc)
 avio_wb16(pb, track->par->color_primaries);
 avio_wb16(pb, track->par->color_trc);
 avio_wb16(pb, track->par->color_space);
-if (track->mode == MODE_MP4) {
+if (track->mode == MODE_MP4 || track->mode == MODE_AVIF) {
 int full_range = track->par->color_range == AVCOL_RANGE_JPEG;
 avio_w8(pb, full_range << 7);
 }
@@ -2085,7 +2086,7 @@ static void find_compressor(char * compressor_name, int 
len, MOVTrack *track)
   || (track->par->width == 1440 && track->par->height == 1080)
   || (track->par->width == 1920 && track->par->height == 1080);
 
-if (track->mode == MODE_MOV &&
+if ((track->mode == MODE_AVIF || track->mode == MODE_MOV) &&
 (encoder = av_dict_get(track->st->metadata, "encoder", NULL, 0))) {
 av_strlcpy(compressor_name, encoder->value, 32);
 } else if (track->par->codec_id == AV_CODEC_ID_MPEG2VIDEO && xdcam_res) {
@@ -2123,6 +2124,8 @@ static int mov_write_video_tag(AVFormatContext *s, 
AVIOContext *pb, MOVMuxContex
 avio_wb32(pb, 0); /* size */
 if (mov->encryption_scheme != MOV_ENC_NONE) {
 ffio_wfourcc(pb, "encv");
+} else if (track->mode == MODE_AVIF) {
+ffio_wfourcc(pb, "av01");
 } else {
 avio_wl32(pb, track->tag); // store it byteswapped
 }
@@ -2239,7 +2242,7 @@ static int mov_write_video_tag(AVFormatContext *s, 
AVIOContext *pb, MOVMuxContex
 else
 av_log(mov->fc, AV_LOG_WARNING, "Not writing 'gama' atom. Format 
is not MOV.\n");
 }
-if (track->mode == MODE_MOV || track->mode == MODE_MP4) {
+if (track->mode == MODE_MOV || track->mode == MODE_MP4 || track->mode == 
MODE_AVIF) {
 int has_color_info = track

Re: [FFmpeg-devel] [PATCH 1/2] fftools/ffprobe: Flush decoder after draining

2022-02-22 Thread Andreas Rheinhardt
Andreas Rheinhardt:
> This is a prerequisite to continue using the decoder at all
> to decode the next interval (if any).
> This fixes a regression introduced in commit
> 2a88ebd096f3c748a2d99ed1b60b22879b3c567c and reported in ticket #8657.
> 
> Signed-off-by: Andreas Rheinhardt 
> ---
> I wonder whether it would not be simpler to let users reuse a decoder
> after draining simply by sending new packets (without flushing).
> 
>  fftools/ffprobe.c | 5 -
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c
> index 8a8e3de540..4205ddedda 100644
> --- a/fftools/ffprobe.c
> +++ b/fftools/ffprobe.c
> @@ -2730,8 +2730,11 @@ static int read_interval_packets(WriterContext *w, 
> InputFile *ifile,
>  //Flush remaining frames that are cached in the decoder
>  for (i = 0; i < fmt_ctx->nb_streams; i++) {
>  pkt->stream_index = i;
> -if (do_read_frames)
> +if (do_read_frames) {
>  while (process_frame(w, ifile, frame, pkt, &(int){1}) > 0);
> +if (ifile->streams[i].dec_ctx)
> +avcodec_flush_buffers(ifile->streams[i].dec_ctx);
> +}
>  }
>  
>  end:

Will apply 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".


[FFmpeg-devel] [PATCH 1/5] avcodec/magicyuvenc: Avoid unnecessary av_frame_clone()

2022-02-22 Thread Andreas Rheinhardt
It is unnecessary and unchecked; the intention seems to be to ensure
that the frame's data is writable, but it does not provide this.
This will be fixed in a latter commit.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/magicyuvenc.c | 26 --
 1 file changed, 12 insertions(+), 14 deletions(-)

diff --git a/libavcodec/magicyuvenc.c b/libavcodec/magicyuvenc.c
index ab32d4cee3..4440ab3ce2 100644
--- a/libavcodec/magicyuvenc.c
+++ b/libavcodec/magicyuvenc.c
@@ -452,32 +452,30 @@ static int magy_encode_frame(AVCodecContext *avctx, 
AVPacket *pkt,
 }
 
 if (s->correlate) {
+uint8_t *const data[4] = { frame->data[1], frame->data[0],
+   frame->data[2], frame->data[3] };
+const int linesize[4]  = { frame->linesize[1], frame->linesize[0],
+   frame->linesize[2], frame->linesize[3] };
 uint8_t *r, *g, *b;
-AVFrame *p = av_frame_clone(frame);
 
-g = p->data[0];
-b = p->data[1];
-r = p->data[2];
+g = frame->data[0];
+b = frame->data[1];
+r = frame->data[2];
 
 for (i = 0; i < height; i++) {
 s->llvidencdsp.diff_bytes(b, b, g, width);
 s->llvidencdsp.diff_bytes(r, r, g, width);
-g += p->linesize[0];
-b += p->linesize[1];
-r += p->linesize[2];
+g += frame->linesize[0];
+b += frame->linesize[1];
+r += frame->linesize[2];
 }
 
-FFSWAP(uint8_t*, p->data[0], p->data[1]);
-FFSWAP(int, p->linesize[0], p->linesize[1]);
-
 for (i = 0; i < s->planes; i++) {
 for (slice = 0; slice < s->nb_slices; slice++) {
-s->predict(s, p->data[i], s->slices[i], p->linesize[i],
-   p->width, p->height);
+s->predict(s, data[i], s->slices[i], linesize[i],
+   frame->width, frame->height);
 }
 }
-
-av_frame_free(&p);
 } else {
 for (i = 0; i < s->planes; i++) {
 for (slice = 0; slice < s->nb_slices; slice++) {
-- 
2.32.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 2/5] avcodec/magicyuvenc: Add const where appropriate

2022-02-22 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/magicyuvenc.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/libavcodec/magicyuvenc.c b/libavcodec/magicyuvenc.c
index 4440ab3ce2..ffb0be1d14 100644
--- a/libavcodec/magicyuvenc.c
+++ b/libavcodec/magicyuvenc.c
@@ -69,12 +69,12 @@ typedef struct MagicYUVContext {
 unsigned tables_size;
 HuffEntryhe[4][256];
 LLVidEncDSPContext   llvidencdsp;
-void (*predict)(struct MagicYUVContext *s, uint8_t *src, uint8_t *dst,
+void (*predict)(struct MagicYUVContext *s, const uint8_t *src, uint8_t 
*dst,
 ptrdiff_t stride, int width, int height);
 } MagicYUVContext;
 
 static void left_predict(MagicYUVContext *s,
- uint8_t *src, uint8_t *dst, ptrdiff_t stride,
+ const uint8_t *src, uint8_t *dst, ptrdiff_t stride,
  int width, int height)
 {
 uint8_t prev = 0;
@@ -98,7 +98,7 @@ static void left_predict(MagicYUVContext *s,
 }
 
 static void gradient_predict(MagicYUVContext *s,
- uint8_t *src, uint8_t *dst, ptrdiff_t stride,
+ const uint8_t *src, uint8_t *dst, ptrdiff_t 
stride,
  int width, int height)
 {
 int left = 0, top, lefttop;
@@ -126,7 +126,7 @@ static void gradient_predict(MagicYUVContext *s,
 }
 
 static void median_predict(MagicYUVContext *s,
-   uint8_t *src, uint8_t *dst, ptrdiff_t stride,
+   const uint8_t *src, uint8_t *dst, ptrdiff_t stride,
int width, int height)
 {
 int left = 0, lefttop;
-- 
2.32.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 3/5] avcodec/magicyuvenc: Don't modify input frame

2022-02-22 Thread Andreas Rheinhardt
It need not be writable at all. Instead, use temporary buffers
for decorrelation.

Signed-off-by: Andreas Rheinhardt 
---
The prediction functions could be rewritten to allow src and dst
to alias each other; yet LLVidEncDSPContext.diff_bytes has the
requirement that dst has an alignment of 16.

 libavcodec/magicyuvenc.c | 26 +++---
 1 file changed, 19 insertions(+), 7 deletions(-)

diff --git a/libavcodec/magicyuvenc.c b/libavcodec/magicyuvenc.c
index ffb0be1d14..5a37a49d63 100644
--- a/libavcodec/magicyuvenc.c
+++ b/libavcodec/magicyuvenc.c
@@ -67,6 +67,7 @@ typedef struct MagicYUVContext {
 uint8_t *slices[4];
 unsigned slice_pos[4];
 unsigned tables_size;
+uint8_t *decorrelate_buf[2];
 HuffEntryhe[4][256];
 LLVidEncDSPContext   llvidencdsp;
 void (*predict)(struct MagicYUVContext *s, const uint8_t *src, uint8_t 
*dst,
@@ -190,6 +191,12 @@ static av_cold int magy_encode_init(AVCodecContext *avctx)
 s->format = 0x6b;
 break;
 }
+if (s->correlate) {
+s->decorrelate_buf[0] = av_calloc(2U * avctx->height, 
FFALIGN(avctx->width, 16));
+if (!s->decorrelate_buf[0])
+return AVERROR(ENOMEM);
+s->decorrelate_buf[1] = s->decorrelate_buf[0] + avctx->height * 
FFALIGN(avctx->width, 16);
+}
 
 ff_llvidencdsp_init(&s->llvidencdsp);
 
@@ -452,22 +459,26 @@ static int magy_encode_frame(AVCodecContext *avctx, 
AVPacket *pkt,
 }
 
 if (s->correlate) {
-uint8_t *const data[4] = { frame->data[1], frame->data[0],
-   frame->data[2], frame->data[3] };
-const int linesize[4]  = { frame->linesize[1], frame->linesize[0],
-   frame->linesize[2], frame->linesize[3] };
-uint8_t *r, *g, *b;
+uint8_t *r, *g, *b, *decorrelated[2] = { s->decorrelate_buf[0],
+ s->decorrelate_buf[1] };
+const int decorrelate_linesize = FFALIGN(width, 16);
+const uint8_t *const data[4] = { decorrelated[0], frame->data[0],
+ decorrelated[1], frame->data[3] };
+const int linesize[4]  = { decorrelate_linesize, frame->linesize[0],
+   decorrelate_linesize, frame->linesize[3] };
 
 g = frame->data[0];
 b = frame->data[1];
 r = frame->data[2];
 
 for (i = 0; i < height; i++) {
-s->llvidencdsp.diff_bytes(b, b, g, width);
-s->llvidencdsp.diff_bytes(r, r, g, width);
+s->llvidencdsp.diff_bytes(decorrelated[0], b, g, width);
+s->llvidencdsp.diff_bytes(decorrelated[1], r, g, width);
 g += frame->linesize[0];
 b += frame->linesize[1];
 r += frame->linesize[2];
+decorrelated[0] += decorrelate_linesize;
+decorrelated[1] += decorrelate_linesize;
 }
 
 for (i = 0; i < s->planes; i++) {
@@ -531,6 +542,7 @@ static av_cold int magy_encode_close(AVCodecContext *avctx)
 
 for (i = 0; i < s->planes; i++)
 av_freep(&s->slices[i]);
+av_freep(&s->decorrelate_buf);
 
 return 0;
 }
-- 
2.32.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 4/5] avcodec/libopenjpegenc: Don't clone AVFrame unnecessarily

2022-02-22 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/libopenjpegenc.c | 83 +++--
 1 file changed, 42 insertions(+), 41 deletions(-)

diff --git a/libavcodec/libopenjpegenc.c b/libavcodec/libopenjpegenc.c
index 3e52bcd4e9..08b7b6a152 100644
--- a/libavcodec/libopenjpegenc.c
+++ b/libavcodec/libopenjpegenc.c
@@ -345,7 +345,8 @@ static av_cold int libopenjpeg_encode_init(AVCodecContext 
*avctx)
 return 0;
 }
 
-static int libopenjpeg_copy_packed8(AVCodecContext *avctx, const AVFrame 
*frame, opj_image_t *image)
+static int libopenjpeg_copy_packed8(AVCodecContext *avctx, const uint8_t 
*src[4],
+const int linesize[4], opj_image_t *image)
 {
 int compno;
 int x;
@@ -355,7 +356,7 @@ static int libopenjpeg_copy_packed8(AVCodecContext *avctx, 
const AVFrame *frame,
 const int numcomps = image->numcomps;
 
 for (compno = 0; compno < numcomps; ++compno) {
-if (image->comps[compno].w > frame->linesize[0] / numcomps) {
+if (image->comps[compno].w > linesize[0] / numcomps) {
 av_log(avctx, AV_LOG_ERROR, "Error: frame's linesize is too small 
for the image\n");
 return 0;
 }
@@ -364,9 +365,9 @@ static int libopenjpeg_copy_packed8(AVCodecContext *avctx, 
const AVFrame *frame,
 for (compno = 0; compno < numcomps; ++compno) {
 for (y = 0; y < avctx->height; ++y) {
 image_line = image->comps[compno].data + y * 
image->comps[compno].w;
-frame_index = y * frame->linesize[0] + compno;
+frame_index = y * linesize[0] + compno;
 for (x = 0; x < avctx->width; ++x) {
-image_line[x] = frame->data[0][frame_index];
+image_line[x] = src[0][frame_index];
 frame_index += numcomps;
 }
 for (; x < image->comps[compno].w; ++x) {
@@ -385,17 +386,18 @@ static int libopenjpeg_copy_packed8(AVCodecContext 
*avctx, const AVFrame *frame,
 }
 
 // for XYZ 12 bit
-static int libopenjpeg_copy_packed12(AVCodecContext *avctx, const AVFrame 
*frame, opj_image_t *image)
+static int libopenjpeg_copy_packed12(AVCodecContext *avctx, const uint8_t 
*src[4],
+const int linesize[4], opj_image_t *image)
 {
 int compno;
 int x, y;
 int *image_line;
 int frame_index;
 const int numcomps  = image->numcomps;
-uint16_t *frame_ptr = (uint16_t *)frame->data[0];
+const uint16_t *frame_ptr = (const uint16_t *)src[0];
 
 for (compno = 0; compno < numcomps; ++compno) {
-if (image->comps[compno].w > frame->linesize[0] / numcomps) {
+if (image->comps[compno].w > linesize[0] / numcomps) {
 av_log(avctx, AV_LOG_ERROR, "Error: frame's linesize is too small 
for the image\n");
 return 0;
 }
@@ -404,7 +406,7 @@ static int libopenjpeg_copy_packed12(AVCodecContext *avctx, 
const AVFrame *frame
 for (compno = 0; compno < numcomps; ++compno) {
 for (y = 0; y < avctx->height; ++y) {
 image_line = image->comps[compno].data + y * 
image->comps[compno].w;
-frame_index = y * (frame->linesize[0] / 2) + compno;
+frame_index = y * (linesize[0] / 2) + compno;
 for (x = 0; x < avctx->width; ++x) {
 image_line[x] = frame_ptr[frame_index] >> 4;
 frame_index += numcomps;
@@ -424,7 +426,8 @@ static int libopenjpeg_copy_packed12(AVCodecContext *avctx, 
const AVFrame *frame
 return 1;
 }
 
-static int libopenjpeg_copy_packed16(AVCodecContext *avctx, const AVFrame 
*frame, opj_image_t *image)
+static int libopenjpeg_copy_packed16(AVCodecContext *avctx, const uint8_t 
*src[4],
+const int linesize[4], opj_image_t *image)
 {
 int compno;
 int x;
@@ -432,10 +435,10 @@ static int libopenjpeg_copy_packed16(AVCodecContext 
*avctx, const AVFrame *frame
 int *image_line;
 int frame_index;
 const int numcomps = image->numcomps;
-uint16_t *frame_ptr = (uint16_t*)frame->data[0];
+const uint16_t *frame_ptr = (const uint16_t*)src[0];
 
 for (compno = 0; compno < numcomps; ++compno) {
-if (image->comps[compno].w > frame->linesize[0] / numcomps) {
+if (image->comps[compno].w > linesize[0] / numcomps) {
 av_log(avctx, AV_LOG_ERROR, "Error: frame's linesize is too small 
for the image\n");
 return 0;
 }
@@ -444,7 +447,7 @@ static int libopenjpeg_copy_packed16(AVCodecContext *avctx, 
const AVFrame *frame
 for (compno = 0; compno < numcomps; ++compno) {
 for (y = 0; y < avctx->height; ++y) {
 image_line = image->comps[compno].data + y * 
image->comps[compno].w;
-frame_index = y * (frame->linesize[0] / 2) + compno;
+frame_index = y * (linesize[0] / 2) + compno;
 for (x = 0; x < avctx->width; ++x) {
 image_line[x] = frame_ptr[frame_index];
 frame_i

[FFmpeg-devel] [PATCH 5/5] avcodec/magicyuvenc: Remove unused context variable

2022-02-22 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/magicyuvenc.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/libavcodec/magicyuvenc.c b/libavcodec/magicyuvenc.c
index 5a37a49d63..7fb7578327 100644
--- a/libavcodec/magicyuvenc.c
+++ b/libavcodec/magicyuvenc.c
@@ -58,7 +58,6 @@ typedef struct MagicYUVContext {
 PutBitContextpb;
 int  planes;
 uint8_t  format;
-AVFrame *p;
 int  slice_height;
 int  nb_slices;
 int  correlate;
-- 
2.32.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] tools/target_dec_fuzzer: Adjust threshold for DSICINVIDEO

2022-02-22 Thread Michael Niedermayer
Fixes: Timeout
Fixes: 
44829/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_DSICINVIDEO_fuzzer-6190334340628480

Signed-off-by: Michael Niedermayer 
---
 tools/target_dec_fuzzer.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tools/target_dec_fuzzer.c b/tools/target_dec_fuzzer.c
index 13766d22b9..bba219579d 100644
--- a/tools/target_dec_fuzzer.c
+++ b/tools/target_dec_fuzzer.c
@@ -158,6 +158,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t 
size) {
 case AV_CODEC_ID_CFHD:maxpixels  /= 128;   break;
 case AV_CODEC_ID_COOK:maxsamples /= 1<<20; break;
 case AV_CODEC_ID_DIRAC:   maxpixels  /= 8192;  break;
+case AV_CODEC_ID_DSICINVIDEO: maxpixels  /= 1024;  break;
 case AV_CODEC_ID_DST: maxsamples /= 1<<20; break;
 case AV_CODEC_ID_DVB_SUBTITLE: av_dict_set_int(&opts, "compute_clut", -2, 
0); break;
 case AV_CODEC_ID_DXA: maxpixels  /= 32;break;
-- 
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".


Re: [FFmpeg-devel] [PATCH v3] avformat/nutdec: Add check for avformat_new_stream

2022-02-22 Thread Jiasheng Jiang
Michael Niedermayer:
>> diff --git a/libavformat/nutdec.c b/libavformat/nutdec.c
>> index 0a8a700acf..32a4f6bbcb 100644
>> --- a/libavformat/nutdec.c
>> +++ b/libavformat/nutdec.c
>> @@ -351,8 +351,13 @@ static int decode_main_header(NUTContext *nut)
>>  ret = AVERROR(ENOMEM);
>>  goto fail;
>>  }
>> -for (i = 0; i < stream_count; i++)
>> -avformat_new_stream(s, NULL);
>> +for (i = 0; i < stream_count; i++) {
>> +if (!avformat_new_stream(s, NULL)) {
>> +av_freep(nut->stream);
> 
> is this actually needed or isnt this freed anyway ?
> also if needed thats the wrong pointer 
> av_freep(&nut->stream)

OK, I will remove it and submit v4.

Jiang

___
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 v4] avformat/nutdec: Add check for avformat_new_stream

2022-02-22 Thread Jiasheng Jiang
As the potential failure of the memory allocation,
the avformat_new_stream() could return NULL pointer.
Therefore, it should be better to check it and return
error if fails.
Also, the caller, nut_read_header(), needs to deal with
the return value of the decode_main_header() and return
error if memory allocation fails.
And 'time_base_count' has already checked and it
will return AVERROR_INVALIDDATA if fails, which is different
from ENOMEM.

Fixes: 619d8e2e58 ("updating nut demuxer to latest spec no muxing yet no index 
yet no seeking yet libnuts crcs dont match mine (didnt investigate yet) 
samplerate is stored wrong by libnut (demuxer has a workaround) code is not 
clean or beautifull yet, but i thought its better to commit early before 
someone unneccesarily wastes his time duplicating the work demuxer split from 
muxer")
Signed-off-by: Jiasheng Jiang 
---
Changelog:

v1 -> v2

* Change 1. Add the error handling for ENOMEM from decode_main_header()
in nut_read_header().
* Change 2. Check for the 'time_base_count'.

v2 -> v3

* Change 1. Remove the check for 'time_base_count'.
* Change 2. Change the av_free to av_freep.

v3 -> v4

* Change 1. Remove the av_freep.
---
 libavformat/nutdec.c | 16 
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/libavformat/nutdec.c b/libavformat/nutdec.c
index 0a8a700acf..f9ad2c0af1 100644
--- a/libavformat/nutdec.c
+++ b/libavformat/nutdec.c
@@ -351,8 +351,12 @@ static int decode_main_header(NUTContext *nut)
 ret = AVERROR(ENOMEM);
 goto fail;
 }
-for (i = 0; i < stream_count; i++)
-avformat_new_stream(s, NULL);
+for (i = 0; i < stream_count; i++) {
+if (!avformat_new_stream(s, NULL)) {
+ret = AVERROR(ENOMEM);
+goto fail;
+}
+}
 
 return 0;
 fail:
@@ -800,19 +804,23 @@ static int nut_read_header(AVFormatContext *s)
 NUTContext *nut = s->priv_data;
 AVIOContext *bc = s->pb;
 int64_t pos;
-int initialized_stream_count;
+int initialized_stream_count, ret;
 
 nut->avf = s;
 
 /* main header */
 pos = 0;
+ret = 0;
 do {
+if (ret == AVERROR(ENOMEM))
+return ret;
+
 pos = find_startcode(bc, MAIN_STARTCODE, pos) + 1;
 if (pos < 0 + 1) {
 av_log(s, AV_LOG_ERROR, "No main startcode found.\n");
 return AVERROR_INVALIDDATA;
 }
-} while (decode_main_header(nut) < 0);
+} while ((ret = decode_main_header(nut)) < 0);
 
 /* stream headers */
 pos = 0;
-- 
2.25.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".


Re: [FFmpeg-devel] [PATCH 1/7] avutil/uuid: add utility library for manipulating UUIDs as specified in RFC 4122

2022-02-22 Thread Lynne
22 Feb 2022, 14:01 by z...@zanevaniperen.com:

> Loosely based on libuuid
>
> Co-authored-by: Pierre-Anthony Lemieux 
> Signed-off-by: Pierre-Anthony Lemieux 
> Signed-off-by: Zane van Iperen 
> --- 
> +int av_uuid_parse(const char *in, AVUUID uu)
> +{
> +size_t len = strlen(in);
> +if (len != 36)
> +return -1;
> +
> +return av_uuid_parse_range(in, in + len, uu);
> +}
> +
> +int av_uuid_parse_range(const char *in_start, const char *in_end, AVUUID uu)
> +{
> +int i;
> +const char *cp;
> +char buf[3];
> +
> +if ((in_end - in_start) != 36)
> +return -1;
> +
> +for (i = 0, cp = in_start; i < 36; i++, cp++) {
> +
> +if (i == 8 || i == 13 || i == 18 || i == 23) {
> +if (*cp == '-')
> +continue;
> +return AVERROR(EINVAL);
> +}
> +
> +if (!av_isxdigit(*cp))
> +return AVERROR(EINVAL);
> +}
> +
> +buf[2] = '\0';
> +for (i = 0, cp = in_start; i < 16; i++) {
> +
> +if (i == 4 || i == 6 || i == 8 || i == 10)
> +cp++;
> +
> +buf[0] = *cp++;
>

What's up with all those whitespace newlines?


> +buf[1] = *cp++;
> +
> +errno = 0;
> +uu[i] = strtoul(buf, NULL, 16);
> +if (errno)
> +return AVERROR(errno);
> +}
> +
> +return 0;
> +}
> +
> +void av_uuid_unparse(const AVUUID uuid, char *out)
> +{
> +static char const hexdigits_lower[16] = "0123456789abcdef";
> +
> +char *p = out;
> +
> +for (int i = 0; i < 16; i++) {
> +size_t tmp;
> +
> +if (i == 4 || i == 6 || i == 8 || i == 10) {
> +*p++ = '-';
> +}
>

Code style


> +
> +tmp = uuid[i];
> +*p++ = hexdigits_lower[tmp >> 4];
> +*p++ = hexdigits_lower[tmp & 15];
> +}
> +
> +*p = '\0';
> +}
> +
> +int av_uuid_urn_parse(const char *in, AVUUID uu)
> +{
> +return av_uuid_parse(in + 9, uu);
> +}
> +
> +int av_uuid_equal(const AVUUID uu1, const AVUUID uu2)
> +{
> +return memcmp(uu1, uu2, AV_UUID_LEN) == 0;
> +}
> +
> +void av_uuid_copy(AVUUID dest, const AVUUID src)
> +{
> +memcpy(dest, src, AV_UUID_LEN);
> +}
> +
> +void av_uuid_nil_set(AVUUID uu)
> +{
> +memset(uu, 0, AV_UUID_LEN);
> +}
> diff --git a/libavutil/uuid.h b/libavutil/uuid.h
> new file mode 100644
> index 00..b5d8166898
> --- /dev/null
> +++ b/libavutil/uuid.h
> @@ -0,0 +1,167 @@
> +/*
> + * Copyright (c) 2022 Pierre-Anthony Lemieux 
> + *Zane van Iperen 
> + *
> + * 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
> + */
> +
> +/*
> + * Copyright (C) 1996, 1997 Theodore Ts'o.
> + *
> + * Redistribution and use in source and binary forms, with or without
> + * modification, are permitted provided that the following conditions
> + * are met:
> + * 1. Redistributions of source code must retain the above copyright
> + *notice, and the entire permission notice in its entirety,
> + *including the disclaimer of warranties.
> + * 2. Redistributions in binary form must reproduce the above copyright
> + *notice, this list of conditions and the following disclaimer in the
> + *documentation and/or other materials provided with the distribution.
> + * 3. The name of the author may not be used to endorse or promote
> + *products derived from this software without specific prior
> + *written permission.
> + *
> + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
> + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
> + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF
> + * WHICH ARE HEREBY DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE
> + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
> + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
> + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
> + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
> + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
> + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
> + * USE OF THIS SOFTWARE, EVEN IF NOT ADVISED OF THE POSSIBILITY OF SUCH
> + * DAMAGE.
> + */
>

Why the double header in the header file? It doesn

Re: [FFmpeg-devel] [PATCH 1/7] avutil/uuid: add utility library for manipulating UUIDs as specified in RFC 4122

2022-02-22 Thread Zane van Iperen




On 23/2/22 16:01, Lynne wrote:


Code style



Mostly fixed, do these changes look right?
https://github.com/vs49688/FFmpeg/commit/867fffe04ffedf0609260557d1db0ebbc519c4d2



Why the double header in the header file? It doesn't contain
any libuuid code.


It does, this was copy/pasted from libuuid, then had things stripped from it.
Some examples:
- 
https://github.com/util-linux/util-linux/blob/d65eb48039a03cdacd5450e644af917a0f08bc88/libuuid/src/unparse.c#L43
- 
https://github.com/util-linux/util-linux/blob/d65eb48039a03cdacd5450e644af917a0f08bc88/libuuid/src/parse.c#L52
___
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/7] avutil/uuid: add utility library for manipulating UUIDs as specified in RFC 4122

2022-02-22 Thread Zane van Iperen



On 23/2/22 00:21, James Almer wrote:

+int av_uuid_equal(const AVUUID uu1, const AVUUID uu2)
+{
+    return memcmp(uu1, uu2, AV_UUID_LEN) == 0;
+}
+
+void av_uuid_copy(AVUUID dest, const AVUUID src)
+{
+    memcpy(dest, src, AV_UUID_LEN);
+}
+
+void av_uuid_nil_set(AVUUID uu)
+{
+    memset(uu, 0, AV_UUID_LEN);


These three seem unnecessary. We don't need new public symbols for this when we 
can just state in the doxy that you can copy, compare or zero by assignment or 
zeroing or any such standard method.



Personally, I think it makes the intent clearer, I'd be interested in other's 
opinions on this.

Alternatively, if AVUUID is changed to a struct we could remove av_uuid_copy() 
and av_uuid_nil_set():

typedef struct AVUUID {
uint8_t v[AV_UUID_LEN];
} AVUUID;

AVUUID a;
AVUUID b = {0};
a = b;


___
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/7] avutil/uuid: add utility library for manipulating UUIDs as specified in RFC 4122

2022-02-22 Thread Zane van Iperen




On 23/2/22 16:48, Zane van Iperen wrote:



On 23/2/22 16:01, Lynne wrote:


Code style



Mostly fixed, do these changes look right?
https://github.com/vs49688/FFmpeg/commit/867fffe04ffedf0609260557d1db0ebbc519c4d2


Uhh, wrong one:
https://github.com/vs49688/FFmpeg/commit/58af67b9bee0b9b235b8be9973b15e3635ad8b96
___
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] lavu: make av_get_media_type_string() never return NULL

2022-02-22 Thread Anton Khirnov
Quoting Andreas Rheinhardt (2022-02-02 03:13:12)
> Who sets invalid media types?
> (In case of fftools/*: If they don't set it themselves, they (and all
> our users) should be able to rely on our libraries to not set invalid
> values. The same goes for all demuxers (as they set this value
> themselves). Checks are only necessary where the media type comes from
> the user; this means muxers (where the check should be done generically)
> and possibly avfiltergraph.c (I am pretty sure that the type has already
> been checked earlier for filters).)

Some demuxer code in lavf looks like it might result in a TYPE_UNKNOWN
AVStream. E.g. argo_brp, avi, both asfdecs, gxf.

-- 
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".