Re: [FFmpeg-devel] [PATCH] libavutil: add clean aperture (CLAP) side data.

2020-05-11 Thread Neil Birkbeck
On Wed, May 6, 2020 at 8:45 AM James Almer  wrote:

> On 5/6/2020 12:22 PM, Neil Birkbeck wrote:
> > On Tue, May 5, 2020 at 5:11 AM Kieran O Leary 
> > wrote:
> >
> >> Hi,
> >>
> >> I broke the threading with my last reply, i apologise. Here goes another
> >> attempt:
> >>
> >> On Tue, Apr 28, 2020 at 6:23 PM Neil Birkbeck 
> >> wrote:
> >>
> >>> On Tue, Apr 28, 2020 at 3:18 AM Nicolas George 
> wrote:
> >>>
>  Andreas Rheinhardt (12020-04-28):
> > That's expected. The patch provided only provides the structure in
> >>> which
> > the values are intended to be exported; it does not add any demuxing
> >> or
> > muxing capabilities for mov or mkv (as you can see from the fact that
> > none of these (de)muxers have been changed in the patch).
> 
>  Which is something I intended to comment on: adding code without users
>  is rarely a good idea. I suggest we do not commit until at least one
>  demuxer use it, preferably at least two. Otherwise, we may realize
> that
>  “oh crap, it doesn't work” because of a tiny unforeseen detail.
> >>>
> >>>
> >>> Thanks for the feedback. I also have patches for the demux (MOV/MKV)
> and
> >>> mux (MOV/MKV).
> >>>
> >>> As there is still the alternative of using the fields in the
> >>> AVCodecParameters/AVCodecContext, my intention was to keep the first
> >> patch
> >>> small to resolve discussion on that point.
> >>>
> >>> I've included the patches, if you'd like to try test it, Kieren. I see
> on
> >>> your test file that there may be some slight rounding error making
> output
> >>> crop 704 not 703 (MKV file ends up with pixel_crop_{left,right} = 8).
> >>>
> >>> /ffprobe ../testdata/clap.mov 2>&1 | grep -A1 "Side"
> >>> Side data:
> >>>   Clean aperture:[width 41472/59 height:576/1 h_offset:0/1
> >>> v_offset:0/1]
> >>> ./ffmpeg -i ../testdata/clap.mov  -vcodec copy -acodec copy
> /tmp/clap.mkv
> >>> ./ffprobe /tmp/clap.mkv 2>&1 | grep -A1 "Side"
> >>> Side data:
> >>>   Clean aperture:[width 704/1 height:576/1 h_offset:0/1
> v_offset:0/1]
> >>>
> >>
> >> I have to look deeper into the MKV side of things and most likely raise
> it
> >> with the cellar mailing list so that better minds than mine can weigh
> in. I
> >> do see that the rounding up to 704 could be an issue alright.
> >> As for MOV, your patch appears to generate the same output clap values
> as
> >> the input, so that's really great! command line and mediainfo trace
> below:
> >>
> >
> > Thanks for testing, Kieran and for linking the discussion on the cellar
> > list.
> >
> > Any additional thoughts from ffmpeg devs on container-level SideData vs
> > adding the extra fields into AVCodecParameters/AVCodecContext and
> plumbing
> > into the frame instead? I anticipate some situations where there can be
> > interaction between cropping in bitstream and container-level cropping.
> > Maybe the best way forward is for me to share some sample patches for the
> > alternative to validate whether it supports the various use cases
> > (transmux, decode+crop, any other application level handling), and to
> > confirm the interface changes for the structs.
>
> One option could be to also introduce a frame side data for this new
> struct and have it replace the AVFrame fields, which would then be
> deprecated (But of course keep working until removed).
> This would allow to either inject stream side data from clap atoms and
> Matroska crop fields into packets (Which would then be propagated to
> frames to be applied during decoding), or use and export the bitstream
> cropping information as it's the case right now, all while preventing
> the addition of new fields to AVCodecParameters.
>
>
I agree that sharing the SideData with the frame could be nice for the
above reasons. I guess any interaction or conflict between bitstream &
container cropping could then get resolved at the decoder (e.g., assuming
that say SPS from h264 and container-level cropping should be composed).


> I would like a developer that makes use of this feature to also comment,
> especially seeing how the AVFrame fields and this clap side data are
> pretty different.
>

The current CleanAperture representation was in part motivated to 1) keep
the representation capable of representing the CLAP atom (same
representation and rationals), and 2) to make it unambiguous that this was
container-level stream metadata. The representation is a tiny bit more
tedious when trying to actually perform a crop (e.g., to extract the
top-left corner offset). If sharing as AVFrame side data, a representation
closer to AVFrame's crop_{top,bottom,left,right} may be more natural.

Within ffmpeg, I see that the existing codecs using AVFrame cropping
include:
-libavcodec/h264_slice.c: propagating the crop_fields from the SPS in h264
in
-libavcodec/hevc_refs.c: (sly to h264)
-libavcodec/agm.c: crop_{left, top} inferred from
avctx->coded_{width,height} - avctx->{width,height}
-libavcodec/videotoolbox.c: crop fields explicitly 

Re: [FFmpeg-devel] [PATCH] libavutil: add clean aperture (CLAP) side data.

2020-05-11 Thread Neil Birkbeck
On Thu, May 7, 2020 at 10:21 AM Andreas Rheinhardt <
andreas.rheinha...@gmail.com> wrote:

> Neil Birkbeck:
> > On Tue, Apr 28, 2020 at 3:18 AM Nicolas George  wrote:
> >
> >> Andreas Rheinhardt (12020-04-28):
> >>> That's expected. The patch provided only provides the structure in
> which
> >>> the values are intended to be exported; it does not add any demuxing or
> >>> muxing capabilities for mov or mkv (as you can see from the fact that
> >>> none of these (de)muxers have been changed in the patch).
> >>
> >> Which is something I intended to comment on: adding code without users
> >> is rarely a good idea. I suggest we do not commit until at least one
> >> demuxer use it, preferably at least two. Otherwise, we may realize that
> >> “oh crap, it doesn't work” because of a tiny unforeseen detail.
> >
> >
> > Thanks for the feedback. I also have patches for the demux (MOV/MKV) and
> > mux (MOV/MKV).
> >
> > As there is still the alternative of using the fields in the
> > AVCodecParameters/AVCodecContext, my intention was to keep the first
> patch
> > small to resolve discussion on that point.
> >
> > I've included the patches, if you'd like to try test it, Kieren. I see on
> > your test file that there may be some slight rounding error making output
> > crop 704 not 703 (MKV file ends up with pixel_crop_{left,right} = 8).
> >
> > /ffprobe ../testdata/clap.mov 2>&1 | grep -A1 "Side"
> > Side data:
> >   Clean aperture:[width 41472/59 height:576/1 h_offset:0/1
> v_offset:0/1]
> > ./ffmpeg -i ../testdata/clap.mov  -vcodec copy -acodec copy /tmp/clap.mkv
> > ./ffprobe /tmp/clap.mkv 2>&1 | grep -A1 "Side"
> > Side data:
> >   Clean aperture:[width 704/1 height:576/1 h_offset:0/1 v_offset:0/1]
> >
> >
>
> >
> > Write out stream-level AVCleanAperture side data in the muxer.
>
> You should separate the mov and Matroska patches.


I will do this as I incorporate the rest of your suggestions.



>
> > Signed-off-by: Neil Birkbeck 
> > ---
> >  libavformat/matroskaenc.c | 37 +
> >  libavformat/movenc.c  | 28 
> >  2 files changed, 57 insertions(+), 8 deletions(-)
> >
> > diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
> > index 784973a951..19ff29853e 100644
> > --- a/libavformat/matroskaenc.c
> > +++ b/libavformat/matroskaenc.c
> > @@ -901,6 +901,38 @@ static int mkv_write_video_color(AVIOContext *pb,
> const AVCodecParameters *par,
> >  return 0;
> >  }
> >
> > +static int mkv_write_video_crop(AVIOContext *pb, AVCodecParameters
> *par, AVStream *st)
> > +{
> > +int cropb = 0, cropt = 0, cropl = 0, cropr = 0;
> > +double width, height, h_offset, v_offset;
> > +int side_data_size = 0;
> > +const AVCleanAperture *clap =
> > +(const AVCleanAperture *)av_stream_get_side_data(
> > +st, AV_PKT_DATA_CLEAN_APERTURE, _data_size);
> > +if (!clap)
> > +return 0;
> > +
> > +width = av_q2d(clap->width);
> > +height = av_q2d(clap->height);
> > +h_offset = av_q2d(clap->horizontal_offset);
> > +v_offset = av_q2d(clap->vertical_offset);
> > +cropb = (int)(par->height - (par->height / 2. + v_offset + height /
> 2));
> > +cropt = (int)(par->height / 2. + v_offset - height / 2);
> > +cropr = (int)(par->width - (par->width / 2. + h_offset + width /
> 2));
> > +cropl = (int)(par->width / 2. + h_offset - width / 2);
> > +cropb = FFMAX(cropb, 0);
> > +cropt = FFMAX(cropt, 0);
> > +cropr = FFMAX(cropr, 0);
> > +cropl = FFMAX(cropl, 0);
> > +if (!cropr && !cropl && !cropt && !cropb)
> > +return 0;
> > +put_ebml_uint(pb, MATROSKA_ID_VIDEOPIXELCROPL, cropl);
> > +put_ebml_uint(pb, MATROSKA_ID_VIDEOPIXELCROPR, cropr);
> > +put_ebml_uint(pb, MATROSKA_ID_VIDEOPIXELCROPB, cropb);
> > +put_ebml_uint(pb, MATROSKA_ID_VIDEOPIXELCROPT, cropt);
>
> There is no reason to write all four elements when only some of them are
> different from zero.
>
>
Good point. I will avoid doing this in the revised set of patches.


> > +return 0;
> > +}
> > +
> >  static int mkv_write_video_projection(AVFormatContext *s, AVIOContext
> *pb,
> >const AVStream *st)
> >  {
> > @@ -1287,6 +1319,11 @@ static int mkv_write_track(AVFormatContext *s,
> MatroskaMuxContext *mkv,
> >  } else if (mkv->mode != MODE_WEBM)
> >  put_ebml_uint(pb, MATROSKA_ID_VIDEODISPLAYUNIT,
> MATROSKA_VIDEO_DISPLAYUNIT_UNKNOWN);
> >
> > +// Write out pixel crop
> > +ret = mkv_write_video_crop(pb, par, st);
> > +if (ret < 0)
> > +return ret;
>
> This is the wrong place for this: It needs to be performed before we
> write the display dimensions and you need to return the cropped width
> and height via pointer arguments, so that the code doing display
> dimensions (which needs to be updated) knows about the cropping. This is
> necessary, because cropping is supposed to happen 

Re: [FFmpeg-devel] [PATCH 1/2] avformat/mpegtsenc: Don't use heap allocated array to store pids

2020-05-11 Thread Andriy Gelman
On Fri, 01. May 17:54, Marton Balint wrote:
> 
> 
> On Thu, 30 Apr 2020, Andriy Gelman wrote:
> 
> > From: Andriy Gelman 
> > 
> > A temporary heap array currently stores pids from all streams.  It is
> > used to make sure there are no duplicated pids. However, this array is
> > not needed because the pids from past streams are stored in the
> > MpegTSWriteStream structs.
> > 
> 
> LGTM, thanks.
> 
> Marton
> 

Hi Marton, 

Thanks for the review.
Is it ok to push both patches? 

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

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

[FFmpeg-devel] [PATCH v3 1/4] avutil/internal: add FF_ALLOC_TYPED_ARRAY_OR_GOTO & FF_ALLOCZ_TYPED_ARRAY_OR_GOTO

2020-05-11 Thread lance . lmwang
From: Limin Wang 

These are similar to the existing FF_ALLOC_ARRAY_OR_GOTO & 
FF_ALLOCZ_ARRAY_OR_GOTO,
but the elsize is calcuated by sizeof(*p)

Signed-off-by: Limin Wang 
---
 libavutil/internal.h | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/libavutil/internal.h b/libavutil/internal.h
index 4acbcf5..9d68c3f 100644
--- a/libavutil/internal.h
+++ b/libavutil/internal.h
@@ -173,6 +173,12 @@
 }\
 }
 
+#define FF_ALLOC_TYPED_ARRAY_OR_GOTO(ctx, p, nelem, label)\
+FF_ALLOC_ARRAY_OR_GOTO(ctx, p, nelem, sizeof(*(p)), label)
+
+#define FF_ALLOCZ_TYPED_ARRAY_OR_GOTO(ctx, p, nelem, label)\
+FF_ALLOCZ_ARRAY_OR_GOTO(ctx, p, nelem, sizeof(*(p)), label)
+
 #include "libm.h"
 
 /**
-- 
1.8.3.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 2/2] avcodec/mpegvideo: cosmetics

2020-05-11 Thread lance . lmwang
On Mon, May 11, 2020 at 06:59:15PM +0200, Michael Niedermayer wrote:
> On Sun, May 10, 2020 at 11:39:30PM +0800, lance.lmw...@gmail.com wrote:
> > From: Limin Wang 
> > 
> > Signed-off-by: Limin Wang 
> > ---
> >  libavcodec/mpegvideo.c | 27 ++-
> >  1 file changed, 18 insertions(+), 9 deletions(-)
> > 
> > diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
> > index 561062f..b993813 100644
> > --- a/libavcodec/mpegvideo.c
> > +++ b/libavcodec/mpegvideo.c
> > @@ -725,12 +725,18 @@ static int init_context_frame(MpegEncContext *s)
> >  
> >  if (s->encoding) {
> >  /* Allocate MV tables */
> > -FF_ALLOCZ_OR_GOTO(s->avctx, s->p_mv_table_base, 
> > mv_table_size * 2 * sizeof(*s->p_mv_table_base), fail)
> > -FF_ALLOCZ_OR_GOTO(s->avctx, s->b_forw_mv_table_base,
> > mv_table_size * 2 * sizeof(*s->b_forw_mv_table_base), fail)
> > -FF_ALLOCZ_OR_GOTO(s->avctx, s->b_back_mv_table_base,
> > mv_table_size * 2 * sizeof(*s->b_back_mv_table_base), fail)
> > -FF_ALLOCZ_OR_GOTO(s->avctx, s->b_bidir_forw_mv_table_base,  
> > mv_table_size * 2 * sizeof(*s->b_bidir_forw_mv_table_base), fail)
> > -FF_ALLOCZ_OR_GOTO(s->avctx, s->b_bidir_back_mv_table_base,  
> > mv_table_size * 2 * sizeof(*s->b_bidir_back_mv_table_base), fail)
> > -FF_ALLOCZ_OR_GOTO(s->avctx, s->b_direct_mv_table_base,  
> > mv_table_size * 2 * sizeof(*s->b_direct_mv_table_base), fail)
> > +FF_ALLOCZ_OR_GOTO(s->avctx, s->p_mv_table_base,
> > +  mv_table_size * 2 * sizeof(*s->p_mv_table_base), 
> > fail)
> > +FF_ALLOCZ_OR_GOTO(s->avctx, s->b_forw_mv_table_base,
> > +  mv_table_size * 2 * 
> > sizeof(*s->b_forw_mv_table_base), fail)
> > +FF_ALLOCZ_OR_GOTO(s->avctx, s->b_back_mv_table_base,
> > +  mv_table_size * 2 * 
> > sizeof(*s->b_back_mv_table_base), fail)
> > +FF_ALLOCZ_OR_GOTO(s->avctx, s->b_bidir_forw_mv_table_base,
> > +  mv_table_size * 2 * 
> > sizeof(*s->b_bidir_forw_mv_table_base), fail)
> > +FF_ALLOCZ_OR_GOTO(s->avctx, s->b_bidir_back_mv_table_base,
> > +  mv_table_size * 2 * 
> > sizeof(*s->b_bidir_back_mv_table_base), fail)
> > +FF_ALLOCZ_OR_GOTO(s->avctx, s->b_direct_mv_table_base,
> > +  mv_table_size * 2 * 
> > sizeof(*s->b_direct_mv_table_base), fail)
> >  s->p_mv_table= s->p_mv_table_base + s->mb_stride + 1;
> >  s->b_forw_mv_table   = s->b_forw_mv_table_base + s->mb_stride 
> > + 1;
> >  s->b_back_mv_table   = s->b_back_mv_table_base + s->mb_stride 
> > + 1;
> 
> I this this is more readable before the change
the line is too long so I split two line. Now have updated with new macro, 
please
review whether it's OK for you. I'm not keep the patch with same thread for the 
title
different.

> 
> 
> [...]
> -- 
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
> 
> While the State exists there can be no freedom; when there is freedom there
> will be no State. -- Vladimir Lenin



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


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

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

Re: [FFmpeg-devel] [PATCH v2 2/4] avcodec/mpegvideo: use FF_ALLOC{Z}_TYPED_ARRAY_OR_GOTO instead

2020-05-11 Thread lance . lmwang
On Mon, May 11, 2020 at 01:27:36PM -0300, James Almer wrote:
> On 5/11/2020 12:52 PM, lance.lmw...@gmail.com wrote:
> > From: Limin Wang 
> > 
> > Signed-off-by: Limin Wang 
> > ---
> >  libavcodec/mpegvideo.c | 60 
> > ++
> >  1 file changed, 26 insertions(+), 34 deletions(-)
> > 
> > diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
> > index 49fd1c9..6f52e75 100644
> > --- a/libavcodec/mpegvideo.c
> > +++ b/libavcodec/mpegvideo.c
> > @@ -372,16 +372,13 @@ static int init_duplicate_context(MpegEncContext *s)
> >  s->sc.obmc_scratchpad = NULL;
> >  
> >  if (s->encoding) {
> > -FF_ALLOCZ_OR_GOTO(s->avctx, s->me.map,
> > -  ME_MAP_SIZE * sizeof(uint32_t), fail)
> > -FF_ALLOCZ_OR_GOTO(s->avctx, s->me.score_map,
> > -  ME_MAP_SIZE * sizeof(uint32_t), fail)
> > +FF_ALLOCZ_TYPED_ARRAY_OR_GOTO(s->avctx, s->me.map, ME_MAP_SIZE, 
> > fail)
> > +FF_ALLOCZ_TYPED_ARRAY_OR_GOTO(s->avctx, s->me.score_map, 
> > ME_MAP_SIZE, fail)
> 
> Why not just do FF_ALLOCZ_ARRAY_OR_GOTO(s->avctx, s->me.score_map,
> ME_MAP_SIZE, sizeof(*s->me.score_map), fail)
> Same for every other case in the patchset.
> 
> I don't know if it's worth adding a new macro just to save writing one
> argument, but i have no strong feelings about it, so if others are ok
> with it then it's fine.

Now I'm prefer to the new macro, for some sizeof is too long and had to split 
two
line. But it's more fine if the macro is short name.


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

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

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

Re: [FFmpeg-devel] [PATCH v2 1/4] avutil/internal: add FF_ALLOC_TYPED_ARRAY_OR_GOTO & FF_ALLOCZ_TYPED_ARRAY_OR_GOTO

2020-05-11 Thread lance . lmwang
On Mon, May 11, 2020 at 08:34:49PM +0200, Marton Balint wrote:
> 
> 
> On Mon, 11 May 2020, lance.lmw...@gmail.com wrote:
> 
> > From: Limin Wang 
> > 
> > These are similar to the existing FF_ALLOC_ARRAY_OR_GOTO & 
> > FF_ALLOCZ_ARRAY_OR_GOTO,
> > but the elsize is calcuated by sizeof(*p)
> > 
> > Signed-off-by: Limin Wang 
> > ---
> > libavutil/internal.h | 18 ++
> > 1 file changed, 18 insertions(+)
> > 
> > diff --git a/libavutil/internal.h b/libavutil/internal.h
> > index 4acbcf5..1be9001 100644
> > --- a/libavutil/internal.h
> > +++ b/libavutil/internal.h
> > @@ -173,6 +173,24 @@
> > }\
> > }
> > 
> > +#define FF_ALLOC_TYPED_ARRAY_OR_GOTO(ctx, p, nelem, label)\
> 
> This should not duplicate functionality of FF_ALLOC_ARRAY_OR_GOTO, but it
> should be defined as
>  FF_ALLOC_ARRAY_OR_GOTO(ctx, p, nelem, sizeof(*(p)), label)
> 
> > +{\
> > +p = av_malloc_array(nelem, sizeof(*p));\
> > +if (!p) {\
> > +av_log(ctx, AV_LOG_ERROR, "Cannot allocate memory.\n");\
> > +goto label;\
> > +}\
> > +}
> > +
> > +#define FF_ALLOCZ_TYPED_ARRAY_OR_GOTO(ctx, p, nelem, label)\
> 
> Same here

OK, will fix it.

> 
> Regards,
> Marton
> 
> > +{\
> > +p = av_mallocz_array(nelem, sizeof(*p));\
> > +if (!p) {\
> > +av_log(ctx, AV_LOG_ERROR, "Cannot allocate memory.\n");\
> > +goto label;\
> > +}\
> > +}
> > +
> > #include "libm.h"
> > 
> > /**
> > -- 
> > 1.8.3.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".

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

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

Re: [FFmpeg-devel] [PATCH] avformat/mux: Check pkt->stream_index before using it

2020-05-11 Thread Andreas Rheinhardt
Anton Khirnov:
> Quoting Andreas Rheinhardt (2020-05-10 21:35:54)
>> Anton Khirnov:
>>> Quoting Marton Balint (2020-05-10 19:45:04)


 On Sun, 10 May 2020, Anton Khirnov wrote:

> Quoting Andreas Rheinhardt (2020-05-08 00:55:00)
>> This commit fixes two recent regressions both of which are about using
>> pkt->stream_index as index in an AVFormatContext's streams array before
>> actually comparing the value with the count of streams in said array.
>> 96e5e6abb9851d7a26ba21703955d5826ac857c0 did this in
>> prepare_input_packet() and 64063512227c4c87a7d16a1076481dc6baf19841 did
>> likewise in write_packets_common().
>>
>> Signed-off-by: Andreas Rheinhardt 
>> ---
>> The same error in the same file applied on the same day by two different
>> people. How unlikely.
>
> How is it a regression? Isn't it rather invalid API use?

 Fun fact: 7b03b65bf0d02519c86750d2da33f413e11cf0c6

 Yes, it is kind of invalid API use, but since the check is already there, 
 we should make it actually worthwile.
>>>
>>> lol
>>>
>>> I agree that checking for it is a good idea, obviously, but I wouldn't
>>> call it a regression.
>>>
>> How about rephrasing the first sentence to: "This commit stops using
>> pkt->stream_index as index in an AVFormatContext's streams array before
>> actually comparing the value with the count of streams in said array."
> 
> Sure, sounds good.
> 

>
> Not that I object to having a check. But then why is check_packet()
> called so deep and not immediately on entry to the muxer?

 I guess it is not that deep, but recent factorization efforts hidden it a 
 bit.
>>>
>>> You can see in my original commit it is the very first thing done after
>>> entering the muxer. Right now it's several function calls deep.
>>>
>> I could make it the very first thing called in write_packets_common().
> 
> Why not move the check_packet() call out of prepare_packet() into
> av_[interleaved_]write_frame() instead?
> 
This would add code duplication and IMO it is nicer to only check a
packet for validity if there is actually a packet to check.

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

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

Re: [FFmpeg-devel] [PATCH 7/7] avcodec/utvideodec: Fix integer overflow in decode_plane()

2020-05-11 Thread Michael Niedermayer
On Sun, May 10, 2020 at 09:20:19PM +0200, Michael Niedermayer wrote:
> Fixes: signed integer overflow: 2147483594 + 142 cannot be represented in 
> type 'int'
> Fixes: 
> 20492/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_UTVIDEO_fuzzer-5658568101724160
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/utvideodec.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

will apply

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

What does censorship reveal? It reveals fear. -- Julian Assange


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

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

Re: [FFmpeg-devel] [PATCH 6/7] avcodec/ttadsp: Fix several integer overflows in tta_filter_process_c()

2020-05-11 Thread Michael Niedermayer
On Sun, May 10, 2020 at 09:20:18PM +0200, Michael Niedermayer wrote:
> Fixes: signed integer overflow: 1931744255 + 252497024 cannot be represented 
> in type 'int'
> Fixes: 
> 20492/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TTA_fuzzer-5763348114440192
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/ttadsp.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)

will apply

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Good people do not need laws to tell them to act responsibly, while bad
people will find a way around the laws. -- Plato


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

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

Re: [FFmpeg-devel] [PATCH 3/7] avcodec/ralf: Fix integer overflow in decode_block()

2020-05-11 Thread Michael Niedermayer
On Sun, May 10, 2020 at 09:20:15PM +0200, Michael Niedermayer wrote:
> Fixes: signed integer overflow: 289082077 - -200314 cannot be represented 
> in type 'int'
> Fixes: 
> 20492/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_RALF_fuzzer-5196077752123392
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/ralf.c | 7 ---
>  1 file changed, 4 insertions(+), 3 deletions(-)

will apply

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

He who knows, does not speak. He who speaks, does not know. -- Lao Tsu


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

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

Re: [FFmpeg-devel] [PATCH 2/7] avcodec/nuv: widen buf_size type

2020-05-11 Thread Michael Niedermayer
On Sun, May 10, 2020 at 09:20:14PM +0200, Michael Niedermayer wrote:
> Fixes: signed integer overflow: 65312 * 65312 cannot be represented in type 
> 'int'
> Fixes: 
> 20492/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_NUV_fuzzer-5740176118906880
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/nuv.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

will apply

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Into a blind darkness they enter who follow after the Ignorance,
they as if into a greater darkness enter who devote themselves
to the Knowledge alone. -- Isha Upanishad


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

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

Re: [FFmpeg-devel] [PATCH 1/4] avfilter/vf_spp: Remove unused AVCodecContext

2020-05-11 Thread Michael Niedermayer
On Sun, Apr 19, 2020 at 12:37:44AM +0200, Michael Niedermayer wrote:
> Signed-off-by: Michael Niedermayer 
> ---
>  libavfilter/vf_spp.c | 7 +--
>  libavfilter/vf_spp.h | 2 --
>  2 files changed, 1 insertion(+), 8 deletions(-)

will apply patchset

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Freedom in capitalist society always remains about the same as it was in
ancient Greek republics: Freedom for slave owners. -- Vladimir Lenin


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

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

Re: [FFmpeg-devel] [PATCH] libswscale: fix for floating point formats, require full chroma

2020-05-11 Thread Michael Niedermayer
On Sun, May 10, 2020 at 04:17:48PM -0700, mindm...@gmail.com wrote:
> From: Mark Reid 
> 
> upon more floating point testing, looks like I missed adding this bit.
> 
> ---
>  libswscale/utils.c | 2 ++
>  1 file changed, 2 insertions(+)

will apply

thx

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

During times of universal deceit, telling the truth becomes a
revolutionary act. -- George Orwell


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

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

Re: [FFmpeg-devel] [PATCH 1/6] avutil/opt: add AV_OPT_FLAG_CHILD_CONSTS

2020-05-11 Thread Michael Niedermayer
On Mon, May 11, 2020 at 09:35:17PM +0200, Marton Balint wrote:
> This will be used for AVCodecContext->profile. By specifying constants in the
> encoders we won't have to use the common AVCodecContext options table and
> different encoders can use the same profile name even with different values.
> 
> Signed-off-by: Marton Balint 
> ---
>  doc/APIchanges  | 3 +++
>  libavutil/opt.c | 3 ++-
>  libavutil/opt.h | 1 +
>  libavutil/version.h | 2 +-
>  4 files changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/doc/APIchanges b/doc/APIchanges
> index 75cfdb08b0..235888c174 100644
> --- a/doc/APIchanges
> +++ b/doc/APIchanges
> @@ -15,6 +15,9 @@ libavutil: 2017-10-21
>  
>  API changes, most recent first:
>  
> +2020-05-xx - xx - lavu 56.44.101 - opt.h
> +  Add AV_OPT_FLAG_CHILD_CONSTS.
> +
>  2020-05-10 - xx - lavu 56.44.100 - hwcontext_vulkan.h
>Add enabled_inst_extensions, num_enabled_inst_extensions, 
> enabled_dev_extensions
>and num_enabled_dev_extensions fields to AVVulkanDeviceContext
> diff --git a/libavutil/opt.c b/libavutil/opt.c
> index b792dec01c..423313bce2 100644
> --- a/libavutil/opt.c
> +++ b/libavutil/opt.c
> @@ -256,11 +256,12 @@ static int set_string_number(void *obj, void 
> *target_obj, const AVOption *o, con
>  }
>  
>  {
> -const AVOption *o_named = av_opt_find(target_obj, i ? buf : val, 
> o->unit, 0, 0);
>  int res;
>  int ci = 0;
>  double const_values[64];
>  const char * const_names[64];
> +int search_flags = (o->flags & AV_OPT_FLAG_CHILD_CONSTS) ? 
> AV_OPT_SEARCH_CHILDREN : 0;
> +const AVOption *o_named = av_opt_find(target_obj, i ? buf : val, 
> o->unit, 0, search_flags);
>  if (o_named && o_named->type == AV_OPT_TYPE_CONST)
>  d = DEFAULT_NUMVAL(o_named);
>  else {
> diff --git a/libavutil/opt.h b/libavutil/opt.h
> index 1969c984dd..e46119572a 100644
> --- a/libavutil/opt.h
> +++ b/libavutil/opt.h
> @@ -291,6 +291,7 @@ typedef struct AVOption {
>  #define AV_OPT_FLAG_RUNTIME_PARAM   (1<<15) ///< a generic parameter which 
> can be set by the user at runtime
>  #define AV_OPT_FLAG_FILTERING_PARAM (1<<16) ///< a generic parameter which 
> can be set by the user for filtering
>  #define AV_OPT_FLAG_DEPRECATED  (1<<17) ///< set if option is 
> deprecated, users should refer to AVOption.help text for more information

> +#define AV_OPT_FLAG_CHILD_CONSTS(1<<18) ///< set if option constants can 
> also reside in child objects

why is this needed and not default ?

thx

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Modern terrorism, a quick summary: Need oil, start war with country that
has oil, kill hundread thousand in war. Let country fall into chaos,
be surprised about raise of fundamantalists. Drop more bombs, kill more
people, be surprised about them taking revenge and drop even more bombs
and strip your own citizens of their rights and freedoms. to be continued


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] libavcodec/decode: Mark decode_simple_internal() as inline

2020-05-11 Thread Michael Niedermayer
This was suggested in
https://github.com/google/oss-fuzz/issues/3787
to reduce the grouping errors by oss-fuzz

Signed-off-by: Michael Niedermayer 
---
 libavcodec/decode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index 8102cf40de..48a61d5419 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -308,7 +308,7 @@ static int64_t guess_correct_pts(AVCodecContext *ctx,
  * returning any output, so this function needs to be called in a loop until it
  * returns EAGAIN.
  **/
-static int decode_simple_internal(AVCodecContext *avctx, AVFrame *frame)
+static inline int decode_simple_internal(AVCodecContext *avctx, AVFrame *frame)
 {
 AVCodecInternal   *avci = avctx->internal;
 DecodeSimpleContext *ds = >ds;
-- 
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 4/6] avcodec/options_table: remove dts profiles

2020-05-11 Thread James Almer
On 5/11/2020 6:27 PM, Marton Balint wrote:
> 
> 
> On Mon, 11 May 2020, James Almer wrote:
> 
>> On 5/11/2020 4:35 PM, Marton Balint wrote:
>>> We don't have a dts encoder.
>>
>> We do, but it's called dca, same as the decoder.
> 
> Indeed. But as far as I see it does not use avctx->profile, so it still
> seems OK to remove these, right?

I don't know if anyone has plans to improve or extend the encoder, so i
guess it's fine. They can be properly readded once that happens.
Just make sure to bump micro version as well, either in the last patch
of the set, or in this one.
___
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 4/6] avcodec/options_table: remove dts profiles

2020-05-11 Thread Marton Balint



On Mon, 11 May 2020, James Almer wrote:


On 5/11/2020 4:35 PM, Marton Balint wrote:

We don't have a dts encoder.


We do, but it's called dca, same as the decoder.


Indeed. But as far as I see it does not use avctx->profile, so it 
still seems OK to remove these, right?


Thanks,
Marton





Signed-off-by: Marton Balint 
---
 doc/codecs.texi| 10 --
 libavcodec/options_table.h |  5 -
 2 files changed, 15 deletions(-)

diff --git a/doc/codecs.texi b/doc/codecs.texi
index 8f62cfaace..c08229ba7e 100644
--- a/doc/codecs.texi
+++ b/doc/codecs.texi
@@ -849,16 +849,6 @@ Possible values:

 @item mpeg4_asp

-@item dts
-
-@item dts_es
-
-@item dts_96_24
-
-@item dts_hd_hra
-
-@item dts_hd_ma
-
 @end table

 Encoder specific profiles are documented in the relevant encoder documentation.
diff --git a/libavcodec/options_table.h b/libavcodec/options_table.h
index 6683a38f2e..cc3224b01a 100644
--- a/libavcodec/options_table.h
+++ b/libavcodec/options_table.h
@@ -262,11 +262,6 @@ static const AVOption avcodec_options[] = {
 {"skip_bottom", "number of macroblock rows at the bottom which are skipped", 
OFFSET(skip_bottom), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|D},
 {"profile", NULL, OFFSET(profile), AV_OPT_TYPE_INT, {.i64 = FF_PROFILE_UNKNOWN }, 
INT_MIN, INT_MAX, V|A|E|CC, "avctx.profile"},
 {"unknown", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_UNKNOWN }, INT_MIN, INT_MAX, 
V|A|E, "avctx.profile"},
-{"dts", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_DTS }, INT_MIN, INT_MAX, A|E, 
"avctx.profile"},
-{"dts_es", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_DTS_ES }, INT_MIN, INT_MAX, 
A|E, "avctx.profile"},
-{"dts_96_24", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_DTS_96_24 }, INT_MIN, 
INT_MAX, A|E, "avctx.profile"},
-{"dts_hd_hra", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_DTS_HD_HRA }, INT_MIN, 
INT_MAX, A|E, "avctx.profile"},
-{"dts_hd_ma", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_DTS_HD_MA }, INT_MIN, 
INT_MAX, A|E, "avctx.profile"},
 {"mpeg4_sp",   NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_MPEG4_SIMPLE }, INT_MIN, 
INT_MAX, V|E, "avctx.profile"},
 {"mpeg4_core", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_MPEG4_CORE }, INT_MIN, 
INT_MAX, V|E, "avctx.profile"},
 {"mpeg4_main", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_MPEG4_MAIN }, INT_MIN, 
INT_MAX, V|E, "avctx.profile"},



___
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/3] avcodec/cdtoons: Check sprite_offset is within the packet

2020-05-11 Thread Paul B Mahol
probably ok

On 5/11/20, Michael Niedermayer  wrote:
> Fixes: out of array read
> Fixes:
> 20659/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CDTOONS_fuzzer-5754518731227136
>
> Found-by: continuous fuzzing process
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/cdtoons.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/libavcodec/cdtoons.c b/libavcodec/cdtoons.c
> index 13f9a60f0f..a8609815c1 100644
> --- a/libavcodec/cdtoons.c
> +++ b/libavcodec/cdtoons.c
> @@ -190,6 +190,9 @@ static int cdtoons_decode_frame(AVCodecContext *avctx,
> void *data,
>  palette_set= bytestream_get_byte();
>  buf   += 5;
>
> +if (sprite_offset > buf_size)
> +return AVERROR_INVALIDDATA;
> +
>  /* read new sprites introduced in this frame */
>  buf = avpkt->data + sprite_offset;
>  while (sprite_count--) {
> --
> 2.17.1
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel 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/cdtoons: Check sprite_offset is within the packet

2020-05-11 Thread Michael Niedermayer
Fixes: out of array read
Fixes: 
20659/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CDTOONS_fuzzer-5754518731227136

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

diff --git a/libavcodec/cdtoons.c b/libavcodec/cdtoons.c
index 13f9a60f0f..a8609815c1 100644
--- a/libavcodec/cdtoons.c
+++ b/libavcodec/cdtoons.c
@@ -190,6 +190,9 @@ static int cdtoons_decode_frame(AVCodecContext *avctx, void 
*data,
 palette_set= bytestream_get_byte();
 buf   += 5;
 
+if (sprite_offset > buf_size)
+return AVERROR_INVALIDDATA;
+
 /* read new sprites introduced in this frame */
 buf = avpkt->data + sprite_offset;
 while (sprite_count--) {
-- 
2.17.1

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

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

[FFmpeg-devel] [PATCH 3/3] avcodec/ralf: Check num_blocks before use

2020-05-11 Thread Michael Niedermayer
Fixes: out of array access
Fixes: 
20659/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_RALF_fuzzer-5739471895265280

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

diff --git a/libavcodec/ralf.c b/libavcodec/ralf.c
index 831728177e..7336c87183 100644
--- a/libavcodec/ralf.c
+++ b/libavcodec/ralf.c
@@ -481,6 +481,8 @@ static int decode_frame(AVCodecContext *avctx, void *data, 
int *got_frame_ptr,
 init_get_bits(, src + 2, table_size);
 ctx->num_blocks = 0;
 while (get_bits_left() > 0) {
+if (ctx->num_blocks >= FF_ARRAY_ELEMS(ctx->block_size))
+return AVERROR_INVALIDDATA;
 ctx->block_size[ctx->num_blocks] = get_bits(, 13 + avctx->channels);
 if (get_bits1()) {
 ctx->block_pts[ctx->num_blocks] = get_bits(, 9);
-- 
2.17.1

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

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

[FFmpeg-devel] [PATCH 2/3] avcodec/iff: Test video_size being non zero

2020-05-11 Thread Michael Niedermayer
Fixes: Out of array access
Fixes: 
20659/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_IFF_ILBM_fuzzer-5658548592967680
Fixes: 
20659/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_IFF_ILBM_fuzzer-5723561177382912

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

diff --git a/libavcodec/iff.c b/libavcodec/iff.c
index b39bb2c312..66879cbf5d 100644
--- a/libavcodec/iff.c
+++ b/libavcodec/iff.c
@@ -440,6 +440,8 @@ static av_cold int decode_init(AVCodecContext *avctx)
 
 if (avctx->codec_tag == MKTAG('A', 'N', 'I', 'M')) {
 s->video_size = FFALIGN(avctx->width, 2) * avctx->height * s->bpp;
+if (!s->video_size)
+return AVERROR_INVALIDDATA;
 s->video[0] = av_calloc(FFALIGN(avctx->width, 2) * avctx->height, 
s->bpp);
 s->video[1] = av_calloc(FFALIGN(avctx->width, 2) * avctx->height, 
s->bpp);
 s->pal = av_calloc(256, sizeof(*s->pal));
-- 
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 4/6] avcodec/options_table: remove dts profiles

2020-05-11 Thread James Almer
On 5/11/2020 4:35 PM, Marton Balint wrote:
> We don't have a dts encoder.

We do, but it's called dca, same as the decoder.

> 
> Signed-off-by: Marton Balint 
> ---
>  doc/codecs.texi| 10 --
>  libavcodec/options_table.h |  5 -
>  2 files changed, 15 deletions(-)
> 
> diff --git a/doc/codecs.texi b/doc/codecs.texi
> index 8f62cfaace..c08229ba7e 100644
> --- a/doc/codecs.texi
> +++ b/doc/codecs.texi
> @@ -849,16 +849,6 @@ Possible values:
>  
>  @item mpeg4_asp
>  
> -@item dts
> -
> -@item dts_es
> -
> -@item dts_96_24
> -
> -@item dts_hd_hra
> -
> -@item dts_hd_ma
> -
>  @end table
>  
>  Encoder specific profiles are documented in the relevant encoder 
> documentation.
> diff --git a/libavcodec/options_table.h b/libavcodec/options_table.h
> index 6683a38f2e..cc3224b01a 100644
> --- a/libavcodec/options_table.h
> +++ b/libavcodec/options_table.h
> @@ -262,11 +262,6 @@ static const AVOption avcodec_options[] = {
>  {"skip_bottom", "number of macroblock rows at the bottom which are skipped", 
> OFFSET(skip_bottom), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, 
> V|D},
>  {"profile", NULL, OFFSET(profile), AV_OPT_TYPE_INT, {.i64 = 
> FF_PROFILE_UNKNOWN }, INT_MIN, INT_MAX, V|A|E|CC, "avctx.profile"},
>  {"unknown", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_UNKNOWN }, 
> INT_MIN, INT_MAX, V|A|E, "avctx.profile"},
> -{"dts", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_DTS }, INT_MIN, 
> INT_MAX, A|E, "avctx.profile"},
> -{"dts_es", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_DTS_ES }, INT_MIN, 
> INT_MAX, A|E, "avctx.profile"},
> -{"dts_96_24", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_DTS_96_24 }, 
> INT_MIN, INT_MAX, A|E, "avctx.profile"},
> -{"dts_hd_hra", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_DTS_HD_HRA }, 
> INT_MIN, INT_MAX, A|E, "avctx.profile"},
> -{"dts_hd_ma", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_DTS_HD_MA }, 
> INT_MIN, INT_MAX, A|E, "avctx.profile"},
>  {"mpeg4_sp",   NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_MPEG4_SIMPLE 
> }, INT_MIN, INT_MAX, V|E, "avctx.profile"},
>  {"mpeg4_core", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_MPEG4_CORE }, 
> INT_MIN, INT_MAX, V|E, "avctx.profile"},
>  {"mpeg4_main", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_MPEG4_MAIN }, 
> INT_MIN, INT_MAX, V|E, "avctx.profile"},
> 

___
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/6] avcodec/options_table: remove dts profiles

2020-05-11 Thread Marton Balint
We don't have a dts encoder.

Signed-off-by: Marton Balint 
---
 doc/codecs.texi| 10 --
 libavcodec/options_table.h |  5 -
 2 files changed, 15 deletions(-)

diff --git a/doc/codecs.texi b/doc/codecs.texi
index 8f62cfaace..c08229ba7e 100644
--- a/doc/codecs.texi
+++ b/doc/codecs.texi
@@ -849,16 +849,6 @@ Possible values:
 
 @item mpeg4_asp
 
-@item dts
-
-@item dts_es
-
-@item dts_96_24
-
-@item dts_hd_hra
-
-@item dts_hd_ma
-
 @end table
 
 Encoder specific profiles are documented in the relevant encoder documentation.
diff --git a/libavcodec/options_table.h b/libavcodec/options_table.h
index 6683a38f2e..cc3224b01a 100644
--- a/libavcodec/options_table.h
+++ b/libavcodec/options_table.h
@@ -262,11 +262,6 @@ static const AVOption avcodec_options[] = {
 {"skip_bottom", "number of macroblock rows at the bottom which are skipped", 
OFFSET(skip_bottom), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|D},
 {"profile", NULL, OFFSET(profile), AV_OPT_TYPE_INT, {.i64 = FF_PROFILE_UNKNOWN 
}, INT_MIN, INT_MAX, V|A|E|CC, "avctx.profile"},
 {"unknown", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_UNKNOWN }, INT_MIN, 
INT_MAX, V|A|E, "avctx.profile"},
-{"dts", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_DTS }, INT_MIN, 
INT_MAX, A|E, "avctx.profile"},
-{"dts_es", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_DTS_ES }, INT_MIN, 
INT_MAX, A|E, "avctx.profile"},
-{"dts_96_24", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_DTS_96_24 }, 
INT_MIN, INT_MAX, A|E, "avctx.profile"},
-{"dts_hd_hra", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_DTS_HD_HRA }, 
INT_MIN, INT_MAX, A|E, "avctx.profile"},
-{"dts_hd_ma", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_DTS_HD_MA }, 
INT_MIN, INT_MAX, A|E, "avctx.profile"},
 {"mpeg4_sp",   NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_MPEG4_SIMPLE }, 
INT_MIN, INT_MAX, V|E, "avctx.profile"},
 {"mpeg4_core", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_MPEG4_CORE }, 
INT_MIN, INT_MAX, V|E, "avctx.profile"},
 {"mpeg4_main", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_MPEG4_MAIN }, 
INT_MIN, INT_MAX, V|E, "avctx.profile"},
-- 
2.16.4

___
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/6] avcodec: move aacenc profiles to profiles.h

2020-05-11 Thread Marton Balint
Signed-off-by: Marton Balint 
---
 doc/codecs.texi| 20 
 libavcodec/aacenc.c|  2 ++
 libavcodec/libfdk-aacenc.c |  2 ++
 libavcodec/options_table.h | 10 --
 libavcodec/profiles.h  | 16 
 5 files changed, 20 insertions(+), 30 deletions(-)

diff --git a/doc/codecs.texi b/doc/codecs.texi
index 751d5df050..8f62cfaace 100644
--- a/doc/codecs.texi
+++ b/doc/codecs.texi
@@ -841,26 +841,6 @@ Possible values:
 @table @samp
 @item unknown
 
-@item aac_main
-
-@item aac_low
-
-@item aac_ssr
-
-@item aac_ltp
-
-@item aac_he
-
-@item aac_he_v2
-
-@item aac_ld
-
-@item aac_eld
-
-@item mpeg2_aac_low
-
-@item mpeg2_aac_he
-
 @item mpeg4_sp
 
 @item mpeg4_core
diff --git a/libavcodec/aacenc.c b/libavcodec/aacenc.c
index 4d0abb107f..db11e0ca29 100644
--- a/libavcodec/aacenc.c
+++ b/libavcodec/aacenc.c
@@ -39,6 +39,7 @@
 #include "mpeg4audio.h"
 #include "kbdwin.h"
 #include "sinewin.h"
+#include "profiles.h"
 
 #include "aac.h"
 #include "aactab.h"
@@ -1131,6 +1132,7 @@ static const AVOption aacenc_options[] = {
 {"aac_ltp", "Long term prediction", offsetof(AACEncContext, options.ltp), 
AV_OPT_TYPE_BOOL, {.i64 = 0}, -1, 1, AACENC_FLAGS},
 {"aac_pred", "AAC-Main prediction", offsetof(AACEncContext, options.pred), 
AV_OPT_TYPE_BOOL, {.i64 = 0}, -1, 1, AACENC_FLAGS},
 {"aac_pce", "Forces the use of PCEs", offsetof(AACEncContext, 
options.pce), AV_OPT_TYPE_BOOL, {.i64 = 0}, -1, 1, AACENC_FLAGS},
+FF_AAC_PROFILE_OPTS
 {NULL}
 };
 
diff --git a/libavcodec/libfdk-aacenc.c b/libavcodec/libfdk-aacenc.c
index 5620bb5951..6494c11ddc 100644
--- a/libavcodec/libfdk-aacenc.c
+++ b/libavcodec/libfdk-aacenc.c
@@ -25,6 +25,7 @@
 #include "avcodec.h"
 #include "audio_frame_queue.h"
 #include "internal.h"
+#include "profiles.h"
 
 #ifdef AACENCODER_LIB_VL0
 #define FDKENC_VER_AT_LEAST(vl0, vl1) \
@@ -62,6 +63,7 @@ static const AVOption aac_enc_options[] = {
 { "latm", "Output LATM/LOAS encapsulated data", offsetof(AACContext, 
latm), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, AV_OPT_FLAG_AUDIO_PARAM | 
AV_OPT_FLAG_ENCODING_PARAM },
 { "header_period", "StreamMuxConfig and PCE repetition period (in 
frames)", offsetof(AACContext, header_period), AV_OPT_TYPE_INT, { .i64 = 0 }, 
0, 0x, AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM },
 { "vbr", "VBR mode (1-5)", offsetof(AACContext, vbr), AV_OPT_TYPE_INT, { 
.i64 = 0 }, 0, 5, AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM },
+FF_AAC_PROFILE_OPTS
 { NULL }
 };
 
diff --git a/libavcodec/options_table.h b/libavcodec/options_table.h
index e498e8b844..6683a38f2e 100644
--- a/libavcodec/options_table.h
+++ b/libavcodec/options_table.h
@@ -262,16 +262,6 @@ static const AVOption avcodec_options[] = {
 {"skip_bottom", "number of macroblock rows at the bottom which are skipped", 
OFFSET(skip_bottom), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|D},
 {"profile", NULL, OFFSET(profile), AV_OPT_TYPE_INT, {.i64 = FF_PROFILE_UNKNOWN 
}, INT_MIN, INT_MAX, V|A|E|CC, "avctx.profile"},
 {"unknown", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_UNKNOWN }, INT_MIN, 
INT_MAX, V|A|E, "avctx.profile"},
-{"aac_main", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_AAC_MAIN }, 
INT_MIN, INT_MAX, A|E, "avctx.profile"},
-{"aac_low", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_AAC_LOW }, INT_MIN, 
INT_MAX, A|E, "avctx.profile"},
-{"aac_ssr", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_AAC_SSR }, INT_MIN, 
INT_MAX, A|E, "avctx.profile"},
-{"aac_ltp", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_AAC_LTP }, INT_MIN, 
INT_MAX, A|E, "avctx.profile"},
-{"aac_he", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_AAC_HE }, INT_MIN, 
INT_MAX, A|E, "avctx.profile"},
-{"aac_he_v2", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_AAC_HE_V2 }, 
INT_MIN, INT_MAX, A|E, "avctx.profile"},
-{"aac_ld", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_AAC_LD }, INT_MIN, 
INT_MAX, A|E, "avctx.profile"},
-{"aac_eld", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_AAC_ELD }, INT_MIN, 
INT_MAX, A|E, "avctx.profile"},
-{"mpeg2_aac_low", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_MPEG2_AAC_LOW 
}, INT_MIN, INT_MAX, A|E, "avctx.profile"},
-{"mpeg2_aac_he", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_MPEG2_AAC_HE 
}, INT_MIN, INT_MAX, A|E, "avctx.profile"},
 {"dts", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_DTS }, INT_MIN, 
INT_MAX, A|E, "avctx.profile"},
 {"dts_es", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_DTS_ES }, INT_MIN, 
INT_MAX, A|E, "avctx.profile"},
 {"dts_96_24", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_DTS_96_24 }, 
INT_MIN, INT_MAX, A|E, "avctx.profile"},
diff --git a/libavcodec/profiles.h b/libavcodec/profiles.h
index a53b67e7f2..d950971875 100644
--- a/libavcodec/profiles.h
+++ b/libavcodec/profiles.h
@@ -20,6 +20,22 @@
 #define AVCODEC_PROFILES_H
 
 #include "avcodec.h"
+#include "libavutil/opt.h"
+
+#define FF_AVCTX_PROFILE_OPTION(name, description, type, value) \
+{name, 

[FFmpeg-devel] [PATCH 6/6] avcodec: move mpeg4 profiles to profiles.h

2020-05-11 Thread Marton Balint
Signed-off-by: Marton Balint 
---
 doc/codecs.texi| 17 ++---
 libavcodec/mpeg4videoenc.c |  2 ++
 libavcodec/options_table.h |  4 
 libavcodec/profiles.h  |  6 ++
 libavcodec/v4l2_m2m_enc.c  | 34 ++
 5 files changed, 32 insertions(+), 31 deletions(-)

diff --git a/doc/codecs.texi b/doc/codecs.texi
index c08229ba7e..ece8d50edd 100644
--- a/doc/codecs.texi
+++ b/doc/codecs.texi
@@ -837,21 +837,8 @@ Set number of macroblock rows at the bottom which are 
skipped.
 
 @item profile @var{integer} (@emph{encoding,audio,video})
 
-Possible values:
-@table @samp
-@item unknown
-
-@item mpeg4_sp
-
-@item mpeg4_core
-
-@item mpeg4_main
-
-@item mpeg4_asp
-
-@end table
-
-Encoder specific profiles are documented in the relevant encoder documentation.
+Set encoder codec profile. Default value is @samp{unknown}. Encoder specific
+profiles are documented in the relevant encoder documentation.
 
 @item level @var{integer} (@emph{encoding,audio,video})
 
diff --git a/libavcodec/mpeg4videoenc.c b/libavcodec/mpeg4videoenc.c
index 2cd5a8c015..2e0b119d7f 100644
--- a/libavcodec/mpeg4videoenc.c
+++ b/libavcodec/mpeg4videoenc.c
@@ -27,6 +27,7 @@
 #include "mpegvideo.h"
 #include "h263.h"
 #include "mpeg4video.h"
+#include "profiles.h"
 
 /* The uni_DCtab_* tables below contain unified bits+length tables to encode DC
  * differences in MPEG-4. Unified in the sense that the specification specifies
@@ -1376,6 +1377,7 @@ static const AVOption options[] = {
 { "data_partitioning", "Use data partitioning.",  
OFFSET(data_partitioning), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE },
 { "alternate_scan","Enable alternate scantable.", 
OFFSET(alternate_scan),AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE },
 FF_MPV_COMMON_OPTS
+FF_MPEG4_PROFILE_OPTS
 { NULL },
 };
 
diff --git a/libavcodec/options_table.h b/libavcodec/options_table.h
index 4c7dca696b..6db8facff6 100644
--- a/libavcodec/options_table.h
+++ b/libavcodec/options_table.h
@@ -262,10 +262,6 @@ static const AVOption avcodec_options[] = {
 {"skip_bottom", "number of macroblock rows at the bottom which are skipped", 
OFFSET(skip_bottom), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|D},
 {"profile", NULL, OFFSET(profile), AV_OPT_TYPE_INT, {.i64 = FF_PROFILE_UNKNOWN 
}, INT_MIN, INT_MAX, V|A|E|CC, "avctx.profile"},
 {"unknown", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_UNKNOWN }, INT_MIN, 
INT_MAX, V|A|E, "avctx.profile"},
-{"mpeg4_sp",   NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_MPEG4_SIMPLE }, 
INT_MIN, INT_MAX, V|E, "avctx.profile"},
-{"mpeg4_core", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_MPEG4_CORE }, 
INT_MIN, INT_MAX, V|E, "avctx.profile"},
-{"mpeg4_main", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_MPEG4_MAIN }, 
INT_MIN, INT_MAX, V|E, "avctx.profile"},
-{"mpeg4_asp",  NULL, 0, AV_OPT_TYPE_CONST, {.i64 = 
FF_PROFILE_MPEG4_ADVANCED_SIMPLE }, INT_MIN, INT_MAX, V|E, "avctx.profile"},
 {"main10",  NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_HEVC_MAIN_10 }, 
INT_MIN, INT_MAX, V|E, "avctx.profile"},
 {"level", NULL, OFFSET(level), AV_OPT_TYPE_INT, {.i64 = FF_LEVEL_UNKNOWN }, 
INT_MIN, INT_MAX, V|A|E, "level"},
 {"unknown", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_LEVEL_UNKNOWN }, INT_MIN, 
INT_MAX, V|A|E, "level"},
diff --git a/libavcodec/profiles.h b/libavcodec/profiles.h
index d950971875..e414ea77a7 100644
--- a/libavcodec/profiles.h
+++ b/libavcodec/profiles.h
@@ -37,6 +37,12 @@
 FF_AVCTX_PROFILE_OPTION("mpeg2_aac_low", NULL, AUDIO, 
FF_PROFILE_MPEG2_AAC_LOW)\
 FF_AVCTX_PROFILE_OPTION("mpeg2_aac_he",  NULL, AUDIO, 
FF_PROFILE_MPEG2_AAC_HE)\
 
+#define FF_MPEG4_PROFILE_OPTS \
+FF_AVCTX_PROFILE_OPTION("mpeg4_sp",  NULL, VIDEO, 
FF_PROFILE_MPEG4_SIMPLE)\
+FF_AVCTX_PROFILE_OPTION("mpeg4_core",NULL, VIDEO, 
FF_PROFILE_MPEG4_CORE)\
+FF_AVCTX_PROFILE_OPTION("mpeg4_main",NULL, VIDEO, 
FF_PROFILE_MPEG4_MAIN)\
+FF_AVCTX_PROFILE_OPTION("mpeg4_asp", NULL, VIDEO, 
FF_PROFILE_MPEG4_ADVANCED_SIMPLE)\
+
 extern const AVProfile ff_aac_profiles[];
 extern const AVProfile ff_dca_profiles[];
 extern const AVProfile ff_dnxhd_profiles[];
diff --git a/libavcodec/v4l2_m2m_enc.c b/libavcodec/v4l2_m2m_enc.c
index ebb575f349..a21a7b6c65 100644
--- a/libavcodec/v4l2_m2m_enc.c
+++ b/libavcodec/v4l2_m2m_enc.c
@@ -29,6 +29,7 @@
 #include "libavutil/pixdesc.h"
 #include "libavutil/pixfmt.h"
 #include "libavutil/opt.h"
+#include "profiles.h"
 #include "v4l2_context.h"
 #include "v4l2_m2m.h"
 #include "v4l2_fmt.h"
@@ -370,10 +371,19 @@ static av_cold int v4l2_encode_close(AVCodecContext 
*avctx)
 #define OFFSET(x) offsetof(V4L2m2mPriv, x)
 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
 
+#define V4L_M2M_CAPTURE_OPTS \
+V4L_M2M_DEFAULT_OPTS,\
+{ "num_capture_buffers", "Number of buffers in the capture context", \
+OFFSET(num_capture_buffers), AV_OPT_TYPE_INT, {.i64 = 4 }, 4, INT_MAX, 
FLAGS }
+
+static const 

[FFmpeg-devel] [PATCH 5/6] avcodec: move msbc profile to encoder

2020-05-11 Thread Marton Balint
Signed-off-by: Marton Balint 
---
 libavcodec/options_table.h | 1 -
 libavcodec/sbcenc.c| 1 +
 2 files changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/options_table.h b/libavcodec/options_table.h
index cc3224b01a..4c7dca696b 100644
--- a/libavcodec/options_table.h
+++ b/libavcodec/options_table.h
@@ -267,7 +267,6 @@ static const AVOption avcodec_options[] = {
 {"mpeg4_main", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_MPEG4_MAIN }, 
INT_MIN, INT_MAX, V|E, "avctx.profile"},
 {"mpeg4_asp",  NULL, 0, AV_OPT_TYPE_CONST, {.i64 = 
FF_PROFILE_MPEG4_ADVANCED_SIMPLE }, INT_MIN, INT_MAX, V|E, "avctx.profile"},
 {"main10",  NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_HEVC_MAIN_10 }, 
INT_MIN, INT_MAX, V|E, "avctx.profile"},
-{"msbc",  NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_SBC_MSBC }, INT_MIN, 
INT_MAX, A|E, "avctx.profile"},
 {"level", NULL, OFFSET(level), AV_OPT_TYPE_INT, {.i64 = FF_LEVEL_UNKNOWN }, 
INT_MIN, INT_MAX, V|A|E, "level"},
 {"unknown", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_LEVEL_UNKNOWN }, INT_MIN, 
INT_MAX, V|A|E, "level"},
 {"lowres", "decode at 1= 1/2, 2=1/4, 3=1/8 resolutions", OFFSET(lowres), 
AV_OPT_TYPE_INT, {.i64 = 0 }, 0, INT_MAX, V|A|D},
diff --git a/libavcodec/sbcenc.c b/libavcodec/sbcenc.c
index 631acf7905..47a136e4e5 100644
--- a/libavcodec/sbcenc.c
+++ b/libavcodec/sbcenc.c
@@ -330,6 +330,7 @@ static const AVOption options[] = {
   OFFSET(max_delay), AV_OPT_TYPE_DURATION, {.i64 = 13000}, 1000,13000, AE 
},
 { "msbc",  "use mSBC mode (wideband speech mono SBC)",
   OFFSET(msbc),  AV_OPT_TYPE_BOOL, {.i64 = 0},0,1, AE 
},
+FF_AVCTX_PROFILE_OPTION("msbc", NULL, AUDIO, FF_PROFILE_SBC_MSBC)
 { NULL },
 };
 
-- 
2.16.4

___
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/6] avcodec/options_table: make AVCodecContext->profile search for child constants

2020-05-11 Thread Marton Balint
This change makes it possible for child encoders to define custom profile
option names which can be used for setting the AVCodecContext->profile.

Also rename unit name to something rather unique, so it won't be used elsewhere.

Signed-off-by: Marton Balint 
---
 doc/codecs.texi|  2 ++
 libavcodec/options_table.h | 47 +++---
 2 files changed, 26 insertions(+), 23 deletions(-)

diff --git a/doc/codecs.texi b/doc/codecs.texi
index 2112ce5f46..751d5df050 100644
--- a/doc/codecs.texi
+++ b/doc/codecs.texi
@@ -881,6 +881,8 @@ Possible values:
 
 @end table
 
+Encoder specific profiles are documented in the relevant encoder documentation.
+
 @item level @var{integer} (@emph{encoding,audio,video})
 
 Possible values:
diff --git a/libavcodec/options_table.h b/libavcodec/options_table.h
index 54366747ca..e498e8b844 100644
--- a/libavcodec/options_table.h
+++ b/libavcodec/options_table.h
@@ -38,6 +38,7 @@
 #define S AV_OPT_FLAG_SUBTITLE_PARAM
 #define E AV_OPT_FLAG_ENCODING_PARAM
 #define D AV_OPT_FLAG_DECODING_PARAM
+#define CC AV_OPT_FLAG_CHILD_CONSTS
 
 #define AV_CODEC_DEFAULT_BITRATE 200*1000
 
@@ -259,29 +260,29 @@ static const AVOption avcodec_options[] = {
 {"nssew", "nsse weight", OFFSET(nsse_weight), AV_OPT_TYPE_INT, {.i64 = 8 }, 
INT_MIN, INT_MAX, V|E},
 {"skip_top", "number of macroblock rows at the top which are skipped", 
OFFSET(skip_top), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|D},
 {"skip_bottom", "number of macroblock rows at the bottom which are skipped", 
OFFSET(skip_bottom), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|D},
-{"profile", NULL, OFFSET(profile), AV_OPT_TYPE_INT, {.i64 = FF_PROFILE_UNKNOWN 
}, INT_MIN, INT_MAX, V|A|E, "profile"},
-{"unknown", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_UNKNOWN }, INT_MIN, 
INT_MAX, V|A|E, "profile"},
-{"aac_main", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_AAC_MAIN }, 
INT_MIN, INT_MAX, A|E, "profile"},
-{"aac_low", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_AAC_LOW }, INT_MIN, 
INT_MAX, A|E, "profile"},
-{"aac_ssr", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_AAC_SSR }, INT_MIN, 
INT_MAX, A|E, "profile"},
-{"aac_ltp", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_AAC_LTP }, INT_MIN, 
INT_MAX, A|E, "profile"},
-{"aac_he", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_AAC_HE }, INT_MIN, 
INT_MAX, A|E, "profile"},
-{"aac_he_v2", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_AAC_HE_V2 }, 
INT_MIN, INT_MAX, A|E, "profile"},
-{"aac_ld", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_AAC_LD }, INT_MIN, 
INT_MAX, A|E, "profile"},
-{"aac_eld", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_AAC_ELD }, INT_MIN, 
INT_MAX, A|E, "profile"},
-{"mpeg2_aac_low", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_MPEG2_AAC_LOW 
}, INT_MIN, INT_MAX, A|E, "profile"},
-{"mpeg2_aac_he", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_MPEG2_AAC_HE 
}, INT_MIN, INT_MAX, A|E, "profile"},
-{"dts", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_DTS }, INT_MIN, 
INT_MAX, A|E, "profile"},
-{"dts_es", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_DTS_ES }, INT_MIN, 
INT_MAX, A|E, "profile"},
-{"dts_96_24", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_DTS_96_24 }, 
INT_MIN, INT_MAX, A|E, "profile"},
-{"dts_hd_hra", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_DTS_HD_HRA }, 
INT_MIN, INT_MAX, A|E, "profile"},
-{"dts_hd_ma", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_DTS_HD_MA }, 
INT_MIN, INT_MAX, A|E, "profile"},
-{"mpeg4_sp",   NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_MPEG4_SIMPLE }, 
INT_MIN, INT_MAX, V|E, "profile"},
-{"mpeg4_core", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_MPEG4_CORE }, 
INT_MIN, INT_MAX, V|E, "profile"},
-{"mpeg4_main", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_MPEG4_MAIN }, 
INT_MIN, INT_MAX, V|E, "profile"},
-{"mpeg4_asp",  NULL, 0, AV_OPT_TYPE_CONST, {.i64 = 
FF_PROFILE_MPEG4_ADVANCED_SIMPLE }, INT_MIN, INT_MAX, V|E, "profile"},
-{"main10",  NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_HEVC_MAIN_10 }, 
INT_MIN, INT_MAX, V|E, "profile"},
-{"msbc",  NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_SBC_MSBC }, INT_MIN, 
INT_MAX, A|E, "profile"},
+{"profile", NULL, OFFSET(profile), AV_OPT_TYPE_INT, {.i64 = FF_PROFILE_UNKNOWN 
}, INT_MIN, INT_MAX, V|A|E|CC, "avctx.profile"},
+{"unknown", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_UNKNOWN }, INT_MIN, 
INT_MAX, V|A|E, "avctx.profile"},
+{"aac_main", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_AAC_MAIN }, 
INT_MIN, INT_MAX, A|E, "avctx.profile"},
+{"aac_low", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_AAC_LOW }, INT_MIN, 
INT_MAX, A|E, "avctx.profile"},
+{"aac_ssr", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_AAC_SSR }, INT_MIN, 
INT_MAX, A|E, "avctx.profile"},
+{"aac_ltp", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_AAC_LTP }, INT_MIN, 
INT_MAX, A|E, "avctx.profile"},
+{"aac_he", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_AAC_HE }, INT_MIN, 
INT_MAX, A|E, "avctx.profile"},

[FFmpeg-devel] [PATCH 1/6] avutil/opt: add AV_OPT_FLAG_CHILD_CONSTS

2020-05-11 Thread Marton Balint
This will be used for AVCodecContext->profile. By specifying constants in the
encoders we won't have to use the common AVCodecContext options table and
different encoders can use the same profile name even with different values.

Signed-off-by: Marton Balint 
---
 doc/APIchanges  | 3 +++
 libavutil/opt.c | 3 ++-
 libavutil/opt.h | 1 +
 libavutil/version.h | 2 +-
 4 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index 75cfdb08b0..235888c174 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -15,6 +15,9 @@ libavutil: 2017-10-21
 
 API changes, most recent first:
 
+2020-05-xx - xx - lavu 56.44.101 - opt.h
+  Add AV_OPT_FLAG_CHILD_CONSTS.
+
 2020-05-10 - xx - lavu 56.44.100 - hwcontext_vulkan.h
   Add enabled_inst_extensions, num_enabled_inst_extensions, 
enabled_dev_extensions
   and num_enabled_dev_extensions fields to AVVulkanDeviceContext
diff --git a/libavutil/opt.c b/libavutil/opt.c
index b792dec01c..423313bce2 100644
--- a/libavutil/opt.c
+++ b/libavutil/opt.c
@@ -256,11 +256,12 @@ static int set_string_number(void *obj, void *target_obj, 
const AVOption *o, con
 }
 
 {
-const AVOption *o_named = av_opt_find(target_obj, i ? buf : val, 
o->unit, 0, 0);
 int res;
 int ci = 0;
 double const_values[64];
 const char * const_names[64];
+int search_flags = (o->flags & AV_OPT_FLAG_CHILD_CONSTS) ? 
AV_OPT_SEARCH_CHILDREN : 0;
+const AVOption *o_named = av_opt_find(target_obj, i ? buf : val, 
o->unit, 0, search_flags);
 if (o_named && o_named->type == AV_OPT_TYPE_CONST)
 d = DEFAULT_NUMVAL(o_named);
 else {
diff --git a/libavutil/opt.h b/libavutil/opt.h
index 1969c984dd..e46119572a 100644
--- a/libavutil/opt.h
+++ b/libavutil/opt.h
@@ -291,6 +291,7 @@ typedef struct AVOption {
 #define AV_OPT_FLAG_RUNTIME_PARAM   (1<<15) ///< a generic parameter which can 
be set by the user at runtime
 #define AV_OPT_FLAG_FILTERING_PARAM (1<<16) ///< a generic parameter which can 
be set by the user for filtering
 #define AV_OPT_FLAG_DEPRECATED  (1<<17) ///< set if option is deprecated, 
users should refer to AVOption.help text for more information
+#define AV_OPT_FLAG_CHILD_CONSTS(1<<18) ///< set if option constants can 
also reside in child objects
 //FIXME think about enc-audio, ... style flags
 
 /**
diff --git a/libavutil/version.h b/libavutil/version.h
index 48d8a38c42..c4946c1c7e 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -80,7 +80,7 @@
 
 #define LIBAVUTIL_VERSION_MAJOR  56
 #define LIBAVUTIL_VERSION_MINOR  44
-#define LIBAVUTIL_VERSION_MICRO 100
+#define LIBAVUTIL_VERSION_MICRO 101
 
 #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
LIBAVUTIL_VERSION_MINOR, \
-- 
2.16.4

___
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] avutil/internal: add FF_ALLOC_TYPED_ARRAY_OR_GOTO & FF_ALLOCZ_TYPED_ARRAY_OR_GOTO

2020-05-11 Thread Marton Balint



On Mon, 11 May 2020, lance.lmw...@gmail.com wrote:


From: Limin Wang 

These are similar to the existing FF_ALLOC_ARRAY_OR_GOTO & 
FF_ALLOCZ_ARRAY_OR_GOTO,
but the elsize is calcuated by sizeof(*p)

Signed-off-by: Limin Wang 
---
libavutil/internal.h | 18 ++
1 file changed, 18 insertions(+)

diff --git a/libavutil/internal.h b/libavutil/internal.h
index 4acbcf5..1be9001 100644
--- a/libavutil/internal.h
+++ b/libavutil/internal.h
@@ -173,6 +173,24 @@
}\
}

+#define FF_ALLOC_TYPED_ARRAY_OR_GOTO(ctx, p, nelem, label)\


This should not duplicate functionality of FF_ALLOC_ARRAY_OR_GOTO, but it 
should be defined as

 FF_ALLOC_ARRAY_OR_GOTO(ctx, p, nelem, sizeof(*(p)), label)


+{\
+p = av_malloc_array(nelem, sizeof(*p));\
+if (!p) {\
+av_log(ctx, AV_LOG_ERROR, "Cannot allocate memory.\n");\
+goto label;\
+}\
+}
+
+#define FF_ALLOCZ_TYPED_ARRAY_OR_GOTO(ctx, p, nelem, label)\


Same here

Regards,
Marton


+{\
+p = av_mallocz_array(nelem, sizeof(*p));\
+if (!p) {\
+av_log(ctx, AV_LOG_ERROR, "Cannot allocate memory.\n");\
+goto label;\
+}\
+}
+
#include "libm.h"

/**
--
1.8.3.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] doc/encoders: ffaacenc does not output CBR

2020-05-11 Thread Lynne
May 11, 2020, 14:34 by guillaume.kh@gmail.com:

> The documentation and wiki imply the native AAC encoder can output CBR and 
> VBR files :
> >b
> >Set bit rate in bits/s. Setting this automatically activates constant bit 
> >rate (CBR) mode. If this option is unspecified it is set to 128kbps.
>
>>
>>
> >q
> >Set quality for variable bit rate (VBR) mode. This option is valid only 
> >using the ffmpeg command-line tool. For library interface users, use 
> >global_quality.
>

The twoloop coder (not the default) does CBR. The fast coder for now tries to 
approximate it.
So the documentation is correct. If you do need more accurate CBR just use the 
twoloop coder for now.
I'm working on the encoder now and that should improve its CBR constraints with 
the fast coder.

___
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] hwcontext: add av_hwdevice_ctx_create_derived2

2020-05-11 Thread Lynne
May 11, 2020, 13:55 by jamr...@gmail.com:

> On 5/11/2020 7:25 AM, Lynne wrote:
>
>> This allows for users who derive devices to set options for the 
>> new device context they derive.
>> The main use case of this is to allow users to enable extensions
>> (such as surface drawing extensions) in Vulkan while deriving from
>> the device their frames are on. That way, users don't need to write
>> any initialization code themselves, since currently Vulkan prevents
>> mixing instances and devices.
>> Also, with this, users can also set custom OpenCL extensions such
>> as cl_khr_gl_sharing and cl_khr_gl_depth_images.
>> Apart from OpenCL and Vulkan, other hwcontexts ignore the opts
>> argument since they don't support options at all (or in VAAPI's case,
>> options are only used for device selection, which device_derive overrides).
>>
>> Patch attached.
>>
>
> Could this be av_hwdevice_ctx_create_derived_dict() or similar, please?
> The 2 suffix is pretty ugly and it would be nice if we can avoid adding
> more of them.
>

Sure, changed locally to av_hwdevice_ctx_create_derived_opts.

___
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] [libavformat/mov.c] Read the QT Metadata Keys only once

2020-05-11 Thread Thierry Foucu
If you have a file with multiple Metadata Keys, the second time you parse
the keys, you will re-alloc c->meta_keys without freeing the old one.
This change will avoid parsing all the consecutive Metadata keys.
---
 libavformat/mov.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index ad718cdaa2..062a62d93b 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -7022,7 +7022,8 @@ static int mov_read_default(MOVContext *c, AVIOContext 
*pb, MOVAtom atom)
 // 
https://developer.apple.com/library/mac/documentation/QuickTime/QTFF/Metadata/Metadata.html
 if (!parse && c->found_hdlr_mdta &&
 atom.type == MKTAG('m','e','t','a') &&
-a.type == MKTAG('k','e','y','s')) {
+a.type == MKTAG('k','e','y','s') &&
+c->meta_keys_count == 0) {
 parse = mov_read_keys;
 }
 
-- 
2.26.2.526.g744177e7f7-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".

Re: [FFmpeg-devel] [PATCH 1/4] avcodec/adpcm: Clip predictor for IMA_APM

2020-05-11 Thread Michael Niedermayer
On Sun, May 10, 2020 at 12:40:55PM +0200, Michael Niedermayer wrote:
> Fixes: signed integer overflow: -2147483647 - 61436 cannot be represented in 
> type 'int'
> Fixes: 
> 20492/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ADPCM_IMA_APM_fuzzer-5092176004644864
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/adpcm.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

will apply patchset

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

it is not once nor twice but times without number that the same ideas make
their appearance in the world. -- Aristotle


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

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

Re: [FFmpeg-devel] [PATCH 2/2] avcodec/mpegvideo: cosmetics

2020-05-11 Thread Michael Niedermayer
On Sun, May 10, 2020 at 11:39:30PM +0800, lance.lmw...@gmail.com wrote:
> From: Limin Wang 
> 
> Signed-off-by: Limin Wang 
> ---
>  libavcodec/mpegvideo.c | 27 ++-
>  1 file changed, 18 insertions(+), 9 deletions(-)
> 
> diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
> index 561062f..b993813 100644
> --- a/libavcodec/mpegvideo.c
> +++ b/libavcodec/mpegvideo.c
> @@ -725,12 +725,18 @@ static int init_context_frame(MpegEncContext *s)
>  
>  if (s->encoding) {
>  /* Allocate MV tables */
> -FF_ALLOCZ_OR_GOTO(s->avctx, s->p_mv_table_base, 
> mv_table_size * 2 * sizeof(*s->p_mv_table_base), fail)
> -FF_ALLOCZ_OR_GOTO(s->avctx, s->b_forw_mv_table_base,
> mv_table_size * 2 * sizeof(*s->b_forw_mv_table_base), fail)
> -FF_ALLOCZ_OR_GOTO(s->avctx, s->b_back_mv_table_base,
> mv_table_size * 2 * sizeof(*s->b_back_mv_table_base), fail)
> -FF_ALLOCZ_OR_GOTO(s->avctx, s->b_bidir_forw_mv_table_base,  
> mv_table_size * 2 * sizeof(*s->b_bidir_forw_mv_table_base), fail)
> -FF_ALLOCZ_OR_GOTO(s->avctx, s->b_bidir_back_mv_table_base,  
> mv_table_size * 2 * sizeof(*s->b_bidir_back_mv_table_base), fail)
> -FF_ALLOCZ_OR_GOTO(s->avctx, s->b_direct_mv_table_base,  
> mv_table_size * 2 * sizeof(*s->b_direct_mv_table_base), fail)
> +FF_ALLOCZ_OR_GOTO(s->avctx, s->p_mv_table_base,
> +  mv_table_size * 2 * sizeof(*s->p_mv_table_base), 
> fail)
> +FF_ALLOCZ_OR_GOTO(s->avctx, s->b_forw_mv_table_base,
> +  mv_table_size * 2 * 
> sizeof(*s->b_forw_mv_table_base), fail)
> +FF_ALLOCZ_OR_GOTO(s->avctx, s->b_back_mv_table_base,
> +  mv_table_size * 2 * 
> sizeof(*s->b_back_mv_table_base), fail)
> +FF_ALLOCZ_OR_GOTO(s->avctx, s->b_bidir_forw_mv_table_base,
> +  mv_table_size * 2 * 
> sizeof(*s->b_bidir_forw_mv_table_base), fail)
> +FF_ALLOCZ_OR_GOTO(s->avctx, s->b_bidir_back_mv_table_base,
> +  mv_table_size * 2 * 
> sizeof(*s->b_bidir_back_mv_table_base), fail)
> +FF_ALLOCZ_OR_GOTO(s->avctx, s->b_direct_mv_table_base,
> +  mv_table_size * 2 * 
> sizeof(*s->b_direct_mv_table_base), fail)
>  s->p_mv_table= s->p_mv_table_base + s->mb_stride + 1;
>  s->b_forw_mv_table   = s->b_forw_mv_table_base + s->mb_stride + 
> 1;
>  s->b_back_mv_table   = s->b_back_mv_table_base + s->mb_stride + 
> 1;

I this this is more readable before the change


[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

While the State exists there can be no freedom; when there is freedom there
will be no State. -- Vladimir Lenin


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

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

Re: [FFmpeg-devel] [PATCH 2/2] avformat/ivfenc: move bsf insertion to the init function

2020-05-11 Thread James Almer
On 5/11/2020 8:59 AM, Andreas Rheinhardt wrote:
> James Almer:
>> Signed-off-by: James Almer 
>> ---
>>  libavformat/ivfenc.c | 24 ++--
>>  1 file changed, 10 insertions(+), 14 deletions(-)
>>
>> diff --git a/libavformat/ivfenc.c b/libavformat/ivfenc.c
>> index 0ce4a85171..0951f56c92 100644
>> --- a/libavformat/ivfenc.c
>> +++ b/libavformat/ivfenc.c
>> @@ -43,6 +43,16 @@ static int ivf_init(AVFormatContext *s)
>>  return AVERROR(EINVAL);
>>  }
>>  
>> +if (par->codec_id == AV_CODEC_ID_VP9) {
>> +int ret = ff_stream_add_bitstream_filter(s->streams[0], 
>> "vp9_superframe", NULL);
>> +if (ret < 0)
>> +return ret;
>> +} else if (par->codec_id == AV_CODEC_ID_AV1) {
>> +int ret = ff_stream_add_bitstream_filter(s->streams[0], 
>> "av1_metadata", "td=insert");
>> +if (ret < 0)
>> +return ret;
>> +}
>> +
>>  return 0;
>>  }
>>  
>> @@ -100,19 +110,6 @@ static int ivf_write_trailer(AVFormatContext *s)
>>  return 0;
>>  }
>>  
>> -static int ivf_check_bitstream(struct AVFormatContext *s, const AVPacket 
>> *pkt)
>> -{
>> -int ret = 1;
>> -AVStream *st = s->streams[pkt->stream_index];
>> -
>> -if (st->codecpar->codec_id == AV_CODEC_ID_VP9)
>> -ret = ff_stream_add_bitstream_filter(st, "vp9_superframe", NULL);
>> -else if (st->codecpar->codec_id == AV_CODEC_ID_AV1)
>> -ret = ff_stream_add_bitstream_filter(st, "av1_metadata", 
>> "td=insert");
>> -
>> -return ret;
>> -}
>> -
>>  static const AVCodecTag codec_ivf_tags[] = {
>>  { AV_CODEC_ID_VP8,  MKTAG('V', 'P', '8', '0') },
>>  { AV_CODEC_ID_VP9,  MKTAG('V', 'P', '9', '0') },
>> @@ -131,6 +128,5 @@ AVOutputFormat ff_ivf_muxer = {
>>  .write_header = ivf_write_header,
>>  .write_packet = ivf_write_packet,
>>  .write_trailer = ivf_write_trailer,
>> -.check_bitstream = ivf_check_bitstream,
>>  .codec_tag= (const AVCodecTag* const []){ codec_ivf_tags, 0 },
>>  };
>>
> LGTM. (Would it actually make sense/be possible to replace st->codecpar
> with the output codecparameters of the bsf if the bsf is initialized in
> the init function, so that it is easier for the muxer to locate the
> right codecparameters when writing the header?)

It's possible, but i don't know if that's expected behavior or not.
Editing the codecpar is done by some muxers, true, but the doxy stats
it's "filled by the caller before avformat_write_header()".
An option could be to have a copy of the AVCodecParameters that can be
edited in st->internal instead, and leave the caller one in st alone.

Will apply, thanks.
___
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 2/4] avcodec/mpegvideo: use FF_ALLOC{Z}_TYPED_ARRAY_OR_GOTO instead

2020-05-11 Thread James Almer
On 5/11/2020 12:52 PM, lance.lmw...@gmail.com wrote:
> From: Limin Wang 
> 
> Signed-off-by: Limin Wang 
> ---
>  libavcodec/mpegvideo.c | 60 
> ++
>  1 file changed, 26 insertions(+), 34 deletions(-)
> 
> diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
> index 49fd1c9..6f52e75 100644
> --- a/libavcodec/mpegvideo.c
> +++ b/libavcodec/mpegvideo.c
> @@ -372,16 +372,13 @@ static int init_duplicate_context(MpegEncContext *s)
>  s->sc.obmc_scratchpad = NULL;
>  
>  if (s->encoding) {
> -FF_ALLOCZ_OR_GOTO(s->avctx, s->me.map,
> -  ME_MAP_SIZE * sizeof(uint32_t), fail)
> -FF_ALLOCZ_OR_GOTO(s->avctx, s->me.score_map,
> -  ME_MAP_SIZE * sizeof(uint32_t), fail)
> +FF_ALLOCZ_TYPED_ARRAY_OR_GOTO(s->avctx, s->me.map, ME_MAP_SIZE, fail)
> +FF_ALLOCZ_TYPED_ARRAY_OR_GOTO(s->avctx, s->me.score_map, 
> ME_MAP_SIZE, fail)

Why not just do FF_ALLOCZ_ARRAY_OR_GOTO(s->avctx, s->me.score_map,
ME_MAP_SIZE, sizeof(*s->me.score_map), fail)
Same for every other case in the patchset.

I don't know if it's worth adding a new macro just to save writing one
argument, but i have no strong feelings about it, so if others are ok
with it then it's fine.
___
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 v2 2/4] avcodec/mpegvideo: use FF_ALLOC{Z}_TYPED_ARRAY_OR_GOTO instead

2020-05-11 Thread lance . lmwang
From: Limin Wang 

Signed-off-by: Limin Wang 
---
 libavcodec/mpegvideo.c | 60 ++
 1 file changed, 26 insertions(+), 34 deletions(-)

diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
index 49fd1c9..6f52e75 100644
--- a/libavcodec/mpegvideo.c
+++ b/libavcodec/mpegvideo.c
@@ -372,16 +372,13 @@ static int init_duplicate_context(MpegEncContext *s)
 s->sc.obmc_scratchpad = NULL;
 
 if (s->encoding) {
-FF_ALLOCZ_OR_GOTO(s->avctx, s->me.map,
-  ME_MAP_SIZE * sizeof(uint32_t), fail)
-FF_ALLOCZ_OR_GOTO(s->avctx, s->me.score_map,
-  ME_MAP_SIZE * sizeof(uint32_t), fail)
+FF_ALLOCZ_TYPED_ARRAY_OR_GOTO(s->avctx, s->me.map, ME_MAP_SIZE, fail)
+FF_ALLOCZ_TYPED_ARRAY_OR_GOTO(s->avctx, s->me.score_map, ME_MAP_SIZE, 
fail)
 if (s->noise_reduction) {
-FF_ALLOCZ_OR_GOTO(s->avctx, s->dct_error_sum,
-  2 * 64 * sizeof(int), fail)
+FF_ALLOCZ_TYPED_ARRAY_OR_GOTO(s->avctx, s->dct_error_sum, 2 * 64, 
fail)
 }
 }
-FF_ALLOCZ_OR_GOTO(s->avctx, s->blocks, 64 * 12 * 2 * sizeof(int16_t), fail)
+FF_ALLOCZ_TYPED_ARRAY_OR_GOTO(s->avctx, s->blocks, 64 * 12 * 2, fail)
 s->block = s->blocks[0];
 
 for (i = 0; i < 12; i++) {
@@ -399,8 +396,7 @@ static int init_duplicate_context(MpegEncContext *s)
 
 if (s->out_format == FMT_H263) {
 /* ac values */
-FF_ALLOCZ_OR_GOTO(s->avctx, s->ac_val_base,
-  yc_size * sizeof(int16_t) * 16, fail);
+FF_ALLOCZ_TYPED_ARRAY_OR_GOTO(s->avctx, s->ac_val_base, yc_size * 16, 
fail);
 s->ac_val[0] = s->ac_val_base + s->b8_stride + 1;
 s->ac_val[1] = s->ac_val_base + y_size + s->mb_stride + 1;
 s->ac_val[2] = s->ac_val[1] + c_size;
@@ -715,7 +711,7 @@ static int init_context_frame(MpegEncContext *s)
 if (s->mb_height & 1)
 yc_size += 2*s->b8_stride + 2*s->mb_stride;
 
-FF_ALLOCZ_OR_GOTO(s->avctx, s->mb_index2xy, (s->mb_num + 1) * sizeof(int),
+FF_ALLOCZ_TYPED_ARRAY_OR_GOTO(s->avctx, s->mb_index2xy, s->mb_num + 1,
   fail); // error resilience code looks cleaner with this
 for (y = 0; y < s->mb_height; y++)
 for (x = 0; x < s->mb_width; x++)
@@ -725,12 +721,12 @@ static int init_context_frame(MpegEncContext *s)
 
 if (s->encoding) {
 /* Allocate MV tables */
-FF_ALLOCZ_OR_GOTO(s->avctx, s->p_mv_table_base, 
mv_table_size * 2 * sizeof(int16_t), fail)
-FF_ALLOCZ_OR_GOTO(s->avctx, s->b_forw_mv_table_base,
mv_table_size * 2 * sizeof(int16_t), fail)
-FF_ALLOCZ_OR_GOTO(s->avctx, s->b_back_mv_table_base,
mv_table_size * 2 * sizeof(int16_t), fail)
-FF_ALLOCZ_OR_GOTO(s->avctx, s->b_bidir_forw_mv_table_base,  
mv_table_size * 2 * sizeof(int16_t), fail)
-FF_ALLOCZ_OR_GOTO(s->avctx, s->b_bidir_back_mv_table_base,  
mv_table_size * 2 * sizeof(int16_t), fail)
-FF_ALLOCZ_OR_GOTO(s->avctx, s->b_direct_mv_table_base,  
mv_table_size * 2 * sizeof(int16_t), fail)
+FF_ALLOCZ_TYPED_ARRAY_OR_GOTO(s->avctx, s->p_mv_table_base,
 mv_table_size, fail)
+FF_ALLOCZ_TYPED_ARRAY_OR_GOTO(s->avctx, s->b_forw_mv_table_base,   
 mv_table_size, fail)
+FF_ALLOCZ_TYPED_ARRAY_OR_GOTO(s->avctx, s->b_back_mv_table_base,   
 mv_table_size, fail)
+FF_ALLOCZ_TYPED_ARRAY_OR_GOTO(s->avctx, s->b_bidir_forw_mv_table_base, 
 mv_table_size, fail)
+FF_ALLOCZ_TYPED_ARRAY_OR_GOTO(s->avctx, s->b_bidir_back_mv_table_base, 
 mv_table_size, fail)
+FF_ALLOCZ_TYPED_ARRAY_OR_GOTO(s->avctx, s->b_direct_mv_table_base, 
 mv_table_size, fail)
 s->p_mv_table= s->p_mv_table_base + s->mb_stride + 1;
 s->b_forw_mv_table   = s->b_forw_mv_table_base + s->mb_stride + 1;
 s->b_back_mv_table   = s->b_back_mv_table_base + s->mb_stride + 1;
@@ -739,14 +735,12 @@ static int init_context_frame(MpegEncContext *s)
 s->b_direct_mv_table = s->b_direct_mv_table_base + s->mb_stride + 
1;
 
 /* Allocate MB type table */
-FF_ALLOCZ_OR_GOTO(s->avctx, s->mb_type, mb_array_size * 
sizeof(uint16_t), fail) // needed for encoding
+FF_ALLOCZ_TYPED_ARRAY_OR_GOTO(s->avctx, s->mb_type, mb_array_size, 
fail) // needed for encoding
 
-FF_ALLOCZ_OR_GOTO(s->avctx, s->lambda_table, mb_array_size * 
sizeof(int), fail)
+FF_ALLOCZ_TYPED_ARRAY_OR_GOTO(s->avctx, s->lambda_table, 
mb_array_size, fail)
 
-FF_ALLOC_OR_GOTO(s->avctx, s->cplx_tab,
- mb_array_size * sizeof(float), fail);
-FF_ALLOC_OR_GOTO(s->avctx, s->bits_tab,
- mb_array_size * sizeof(float), fail);
+FF_ALLOC_TYPED_ARRAY_OR_GOTO(s->avctx, s->cplx_tab, mb_array_size, 
fail);
+FF_ALLOC_TYPED_ARRAY_OR_GOTO(s->avctx, 

[FFmpeg-devel] [PATCH v2 1/4] avutil/internal: add FF_ALLOC_TYPED_ARRAY_OR_GOTO & FF_ALLOCZ_TYPED_ARRAY_OR_GOTO

2020-05-11 Thread lance . lmwang
From: Limin Wang 

These are similar to the existing FF_ALLOC_ARRAY_OR_GOTO & 
FF_ALLOCZ_ARRAY_OR_GOTO,
but the elsize is calcuated by sizeof(*p)

Signed-off-by: Limin Wang 
---
 libavutil/internal.h | 18 ++
 1 file changed, 18 insertions(+)

diff --git a/libavutil/internal.h b/libavutil/internal.h
index 4acbcf5..1be9001 100644
--- a/libavutil/internal.h
+++ b/libavutil/internal.h
@@ -173,6 +173,24 @@
 }\
 }
 
+#define FF_ALLOC_TYPED_ARRAY_OR_GOTO(ctx, p, nelem, label)\
+{\
+p = av_malloc_array(nelem, sizeof(*p));\
+if (!p) {\
+av_log(ctx, AV_LOG_ERROR, "Cannot allocate memory.\n");\
+goto label;\
+}\
+}
+
+#define FF_ALLOCZ_TYPED_ARRAY_OR_GOTO(ctx, p, nelem, label)\
+{\
+p = av_mallocz_array(nelem, sizeof(*p));\
+if (!p) {\
+av_log(ctx, AV_LOG_ERROR, "Cannot allocate memory.\n");\
+goto label;\
+}\
+}
+
 #include "libm.h"
 
 /**
-- 
1.8.3.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 v2 4/4] avcodec/h264dec: use FF_ALLOCZ_TYPED_ARRAY_OR_GOTO instead

2020-05-11 Thread lance . lmwang
From: Limin Wang 

Signed-off-by: Limin Wang 
---
 libavcodec/h264dec.c | 48 ++--
 1 file changed, 22 insertions(+), 26 deletions(-)

diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c
index 4c355fe..4e223c1 100644
--- a/libavcodec/h264dec.c
+++ b/libavcodec/h264dec.c
@@ -186,34 +186,32 @@ int ff_h264_alloc_tables(H264Context *h)
   row_mb_num, 8 * sizeof(uint8_t), fail)
 h->slice_ctx[0].intra4x4_pred_mode = h->intra4x4_pred_mode;
 
-FF_ALLOCZ_OR_GOTO(h->avctx, h->non_zero_count,
-  big_mb_num * 48 * sizeof(uint8_t), fail)
-FF_ALLOCZ_OR_GOTO(h->avctx, h->slice_table_base,
-  (big_mb_num + h->mb_stride) * 
sizeof(*h->slice_table_base), fail)
-FF_ALLOCZ_OR_GOTO(h->avctx, h->cbp_table,
-  big_mb_num * sizeof(uint16_t), fail)
-FF_ALLOCZ_OR_GOTO(h->avctx, h->chroma_pred_mode_table,
-  big_mb_num * sizeof(uint8_t), fail)
-FF_ALLOCZ_ARRAY_OR_GOTO(h->avctx, h->mvd_table[0],
-  row_mb_num, 16 * sizeof(uint8_t), fail);
-FF_ALLOCZ_ARRAY_OR_GOTO(h->avctx, h->mvd_table[1],
-  row_mb_num, 16 * sizeof(uint8_t), fail);
+FF_ALLOCZ_TYPED_ARRAY_OR_GOTO(h->avctx, h->non_zero_count,
+  big_mb_num * 48, fail)
+FF_ALLOCZ_TYPED_ARRAY_OR_GOTO(h->avctx, h->slice_table_base,
+  big_mb_num + h->mb_stride, fail)
+FF_ALLOCZ_TYPED_ARRAY_OR_GOTO(h->avctx, h->cbp_table,
+  big_mb_num, fail)
+FF_ALLOCZ_TYPED_ARRAY_OR_GOTO(h->avctx, h->chroma_pred_mode_table,
+  big_mb_num, fail)
+FF_ALLOCZ_TYPED_ARRAY_OR_GOTO(h->avctx, h->mvd_table[0],
+  row_mb_num * 16, fail);
+FF_ALLOCZ_TYPED_ARRAY_OR_GOTO(h->avctx, h->mvd_table[1],
+  row_mb_num * 16, fail);
 h->slice_ctx[0].mvd_table[0] = h->mvd_table[0];
 h->slice_ctx[0].mvd_table[1] = h->mvd_table[1];
 
-FF_ALLOCZ_OR_GOTO(h->avctx, h->direct_table,
-  4 * big_mb_num * sizeof(uint8_t), fail);
-FF_ALLOCZ_OR_GOTO(h->avctx, h->list_counts,
-  big_mb_num * sizeof(uint8_t), fail)
+FF_ALLOCZ_TYPED_ARRAY_OR_GOTO(h->avctx, h->direct_table,
+  4 * big_mb_num, fail);
+FF_ALLOCZ_TYPED_ARRAY_OR_GOTO(h->avctx, h->list_counts,
+  big_mb_num, fail)
 
 memset(h->slice_table_base, -1,
(big_mb_num + h->mb_stride) * sizeof(*h->slice_table_base));
 h->slice_table = h->slice_table_base + h->mb_stride * 2 + 1;
 
-FF_ALLOCZ_OR_GOTO(h->avctx, h->mb2b_xy,
-  big_mb_num * sizeof(uint32_t), fail);
-FF_ALLOCZ_OR_GOTO(h->avctx, h->mb2br_xy,
-  big_mb_num * sizeof(uint32_t), fail);
+FF_ALLOCZ_TYPED_ARRAY_OR_GOTO(h->avctx, h->mb2b_xy, big_mb_num, fail);
+FF_ALLOCZ_TYPED_ARRAY_OR_GOTO(h->avctx, h->mb2br_xy, big_mb_num, fail);
 for (y = 0; y < h->mb_height; y++)
 for (x = 0; x < h->mb_width; x++) {
 const int mb_xy = x + y * h->mb_stride;
@@ -268,8 +266,7 @@ int ff_h264_slice_context_init(H264Context *h, 
H264SliceContext *sl)
 er->b8_stride   = h->mb_width * 2 + 1;
 
 // error resilience code looks cleaner with this
-FF_ALLOCZ_OR_GOTO(h->avctx, er->mb_index2xy,
-  (h->mb_num + 1) * sizeof(int), fail);
+FF_ALLOCZ_TYPED_ARRAY_OR_GOTO(h->avctx, er->mb_index2xy, h->mb_num + 
1, fail);
 
 for (y = 0; y < h->mb_height; y++)
 for (x = 0; x < h->mb_width; x++)
@@ -278,14 +275,13 @@ int ff_h264_slice_context_init(H264Context *h, 
H264SliceContext *sl)
 er->mb_index2xy[h->mb_height * h->mb_width] = (h->mb_height - 1) *
   h->mb_stride + 
h->mb_width;
 
-FF_ALLOCZ_OR_GOTO(h->avctx, er->error_status_table,
-  mb_array_size * sizeof(uint8_t), fail);
+FF_ALLOCZ_TYPED_ARRAY_OR_GOTO(h->avctx, er->error_status_table,
+  mb_array_size, fail);
 
 FF_ALLOC_OR_GOTO(h->avctx, er->er_temp_buffer,
  h->mb_height * h->mb_stride * (4*sizeof(int) + 1), 
fail);
 
-FF_ALLOCZ_OR_GOTO(h->avctx, sl->dc_val_base,
-  yc_size * sizeof(int16_t), fail);
+FF_ALLOCZ_TYPED_ARRAY_OR_GOTO(h->avctx, sl->dc_val_base, yc_size, 
fail);
 er->dc_val[0] = sl->dc_val_base + h->mb_width * 2 + 2;
 er->dc_val[1] = sl->dc_val_base + y_size + h->mb_stride + 1;
 er->dc_val[2] = er->dc_val[1] + c_size;
-- 
1.8.3.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 v2 3/4] avcodec/mpegvideo_enc: use FF_ALLOCZ_TYPED_ARRAY_OR_GOTO instead

2020-05-11 Thread lance . lmwang
From: Limin Wang 

Signed-off-by: Limin Wang 
---
 libavcodec/mpegvideo_enc.c | 23 ++-
 1 file changed, 10 insertions(+), 13 deletions(-)

diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index 50ae57e..81542b8 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -928,23 +928,20 @@ FF_ENABLE_DEPRECATION_WARNINGS
   2 * 2 * (MAX_LEVEL + 1) *
   (MAX_RUN + 1) * 2 * sizeof(int), fail);
 }
-FF_ALLOCZ_OR_GOTO(s->avctx, s->avctx->stats_out, 256, fail);
+FF_ALLOCZ_TYPED_ARRAY_OR_GOTO(s->avctx, s->avctx->stats_out, 256, fail);
 
-FF_ALLOCZ_OR_GOTO(s->avctx, s->q_intra_matrix,   64 * 32 * sizeof(int), 
fail);
-FF_ALLOCZ_OR_GOTO(s->avctx, s->q_chroma_intra_matrix, 64 * 32 * 
sizeof(int), fail);
-FF_ALLOCZ_OR_GOTO(s->avctx, s->q_inter_matrix,   64 * 32 * sizeof(int), 
fail);
-FF_ALLOCZ_OR_GOTO(s->avctx, s->q_intra_matrix16, 64 * 32 * 2 * 
sizeof(uint16_t), fail);
-FF_ALLOCZ_OR_GOTO(s->avctx, s->q_chroma_intra_matrix16, 64 * 32 * 2 * 
sizeof(uint16_t), fail);
-FF_ALLOCZ_OR_GOTO(s->avctx, s->q_inter_matrix16, 64 * 32 * 2 * 
sizeof(uint16_t), fail);
-FF_ALLOCZ_OR_GOTO(s->avctx, s->input_picture,
-  MAX_PICTURE_COUNT * sizeof(Picture *), fail);
-FF_ALLOCZ_OR_GOTO(s->avctx, s->reordered_input_picture,
-  MAX_PICTURE_COUNT * sizeof(Picture *), fail);
+FF_ALLOCZ_TYPED_ARRAY_OR_GOTO(s->avctx, s->q_intra_matrix,   64 * 32, 
fail);
+FF_ALLOCZ_TYPED_ARRAY_OR_GOTO(s->avctx, s->q_chroma_intra_matrix, 64 * 32, 
fail);
+FF_ALLOCZ_TYPED_ARRAY_OR_GOTO(s->avctx, s->q_inter_matrix,   64 * 32, 
fail);
+FF_ALLOCZ_TYPED_ARRAY_OR_GOTO(s->avctx, s->q_intra_matrix16, 64 * 32 * 2, 
fail);
+FF_ALLOCZ_TYPED_ARRAY_OR_GOTO(s->avctx, s->q_chroma_intra_matrix16, 64 * 
32 * 2, fail);
+FF_ALLOCZ_TYPED_ARRAY_OR_GOTO(s->avctx, s->q_inter_matrix16, 64 * 32 * 2, 
fail);
+FF_ALLOCZ_TYPED_ARRAY_OR_GOTO(s->avctx, s->input_picture, 
MAX_PICTURE_COUNT, fail);
+FF_ALLOCZ_TYPED_ARRAY_OR_GOTO(s->avctx, s->reordered_input_picture, 
MAX_PICTURE_COUNT, fail);
 
 
 if (s->noise_reduction) {
-FF_ALLOCZ_OR_GOTO(s->avctx, s->dct_offset,
-  2 * 64 * sizeof(uint16_t), fail);
+FF_ALLOCZ_TYPED_ARRAY_OR_GOTO(s->avctx, s->dct_offset, 2 * 64, fail);
 }
 
 ff_dct_encode_init(s);
-- 
1.8.3.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 0/2] avformat movenc add flag to allow disabling limit on timescale

2020-05-11 Thread Gyan Doshi



On 11-05-2020 06:44 pm, vectronic wrote:



On 5 May 2020, at 06:19, Gyan Doshi  wrote:



On 05-05-2020 03:16 am, vectronic wrote:

On 4 May 2020, at 17:56, Gyan Doshi  wrote:



On 04-05-2020 09:54 pm, vectronic wrote:

I needed to encode to mov/mp4 with a timebase of 1/600 and the output was not 
as expected.

What was the unexpected output?

You can use video_track_timescale to set any custom scale.

Gyan

The unexpected output is that if you request a timebase of 600 as an argument 
for ffmpeg on the command line, the output timebase is forced to be greater 
than 1.

As far as I can see there is no documentation or message logged that the 
following logic is applied which means the output differs to what a user has 
requested and expects:

while(track->timescale < 1)
 track->timescale *= 2;

I believe video_track_timescale applies to all tracks - so you unable to 
specify timescales per track?

I believe your flag also disables the scale clamping for all video tracks. In 
that case, better to extend the min value of video_track_timescale  to -1 to 
implement this instead of a new flag.

Gyan


Hello Gyan,

I updated the patch with your feedback here: 
https://patchwork.ffmpeg.org/project/ffmpeg/list/?series=1138

Do you have any further feedback?


Give me  a couple of days to test.

Thanks,,
Gyan
___
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 1/2] avfilter/vf_colorbalance:: Fix for framecrc bitexact for 32bit and 64bit system

2020-05-11 Thread lance . lmwang
On Fri, Nov 15, 2019 at 11:12:48PM +0800, lance.lmw...@gmail.com wrote:
> Signed-off-by: Limin Wang 
> ---
>  libavfilter/vf_colorbalance.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavfilter/vf_colorbalance.c b/libavfilter/vf_colorbalance.c
> index cc90dc08c7..56f9d5c49c 100644
> --- a/libavfilter/vf_colorbalance.c
> +++ b/libavfilter/vf_colorbalance.c
> @@ -111,7 +111,7 @@ static float get_component(float v, float l,
>  v += m;
>  v += h;
>  
> -return av_clipf(v, 0, 1);
> +return av_clipf(v + 0.5f, 0, 1);
>  }

ping the old patchset, plan to push it if no comments after 3-4 day.

>  
>  static float hfun(float n, float h, float s, float l)
> -- 
> 2.21.0
> 

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

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

[FFmpeg-devel] [PATCH] fate: add a test for vp9 video enc parameters export

2020-05-11 Thread Anton Khirnov
---
 libavformat/Makefile |1 +
 tests/fate/vpx.mak   |4 +
 tests/ref/fate/vp9-encparams | 3279 ++
 tools/venc_data_dump.c   |  186 ++
 4 files changed, 3470 insertions(+)
 create mode 100644 tests/ref/fate/vp9-encparams
 create mode 100644 tools/venc_data_dump.c

diff --git a/libavformat/Makefile b/libavformat/Makefile
index 5fa24cef16..67778ff798 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -670,3 +670,4 @@ TOOLS = aviocat 
\
 probetest   \
 seek_print  \
 sidxindex   \
+venc_data_dump
diff --git a/tests/fate/vpx.mak b/tests/fate/vpx.mak
index c65959f133..49a2c6f230 100644
--- a/tests/fate/vpx.mak
+++ b/tests/fate/vpx.mak
@@ -163,5 +163,9 @@ FATE_VP9-$(CONFIG_IVF_DEMUXER) += fate-vp9-05-resize
 fate-vp9-05-resize: CMD = framemd5 -i 
$(TARGET_SAMPLES)/vp9-test-vectors/vp90-2-05-resize.ivf -s 352x288 -sws_flags 
bitexact+bilinear
 fate-vp9-05-resize: REF = $(SRC_PATH)/tests/ref/fate/vp9-05-resize
 
+FATE_VP9-$(CONFIG_MATROSKA_DEMUXER) += fate-vp9-encparams
+fate-vp9-encparams: CMD = run tools/venc_data_dump$(EXESUF) 
$(TARGET_SAMPLES)/vp9-test-vectors/vp90-2-segmentation-aq-akiyo.webm 0 \
+ $(THREADS) $(THREAD_TYPE)
+
 FATE_SAMPLES_AVCONV-$(CONFIG_VP9_DECODER) += $(FATE_VP9-yes)
 fate-vp9: $(FATE_VP9-yes)
diff --git a/tests/ref/fate/vp9-encparams b/tests/ref/fate/vp9-encparams
new file mode 100644
index 00..515f390cf3
--- /dev/null
+++ b/tests/ref/fate/vp9-encparams
@@ -0,0 +1,3279 @@
+frame 0
+AVVideoEncParams 0
+qp 65
+nb_blocks 731
+block 0 0:0 64x64 33
+block 1 64:0 16x16 -12
+block 2 80:0 16x16 -12
+block 3 64:16 16x8 0
+block 4 64:24 16x8 0
+block 5 80:16 8x16 0
+block 6 88:16 8x16 0
+block 7 96:0 32x16 -23
+block 8 96:16 32x16 0
+block 9 64:32 16x32 0
+block 10 80:32 16x32 0
+block 11 96:32 16x32 16
+block 12 112:32 16x32 -32
+block 13 128:0 32x16 -32
+block 14 128:16 32x16 -32
+block 15 160:0 32x16 -23
+block 16 160:16 32x16 -32
+block 17 128:32 16x16 -32
+block 18 144:32 16x8 16
+block 19 144:40 16x8 16
+block 20 128:48 8x8 -12
+block 21 136:48 8x8 -12
+block 22 128:56 8x8 -12
+block 23 136:56 8x8 -12
+block 24 144:48 16x16 16
+block 25 160:32 8x8 33
+block 26 168:32 8x8 33
+block 27 160:40 8x8 33
+block 28 168:40 8x8 33
+block 29 176:32 8x8 33
+block 30 184:32 8x8 33
+block 31 176:40 8x8 33
+block 32 184:40 8x8 33
+block 33 160:48 8x16 0
+block 34 168:48 8x16 0
+block 35 176:48 16x8 0
+block 36 176:56 16x8 0
+block 37 192:0 8x16 -23
+block 38 200:0 8x16 -23
+block 39 208:0 16x8 -23
+block 40 208:8 16x8 -23
+block 41 192:16 16x16 0
+block 42 208:16 16x16 16
+block 43 224:0 16x32 16
+block 44 240:0 16x32 16
+block 45 192:32 8x8 33
+block 46 200:32 8x8 33
+block 47 192:40 8x8 33
+block 48 200:40 8x8 33
+block 49 208:32 16x16 -12
+block 50 192:48 8x8 33
+block 51 200:48 8x8 33
+block 52 192:56 8x8 33
+block 53 200:56 8x8 33
+block 54 208:48 8x8 16
+block 55 216:48 8x8 16
+block 56 208:56 8x8 16
+block 57 216:56 8x8 16
+block 58 224:32 16x16 -32
+block 59 240:32 16x16 -23
+block 60 224:48 16x16 16
+block 61 240:48 16x16 16
+block 62 256:0 16x16 -12
+block 63 272:0 16x16 -23
+block 64 256:16 16x16 16
+block 65 272:16 16x16 16
+block 66 288:0 32x16 -23
+block 67 288:16 32x16 0
+block 68 256:32 16x16 -23
+block 69 272:32 16x16 -32
+block 70 256:48 16x16 16
+block 71 272:48 16x16 33
+block 72 288:32 32x32 16
+block 73 320:0 8x8 -23
+block 74 328:0 8x8 -23
+block 75 320:8 8x8 -23
+block 76 328:8 8x8 -23
+block 77 336:0 8x8 -12
+block 78 344:0 8x8 -12
+block 79 336:8 8x8 -12
+block 80 344:8 8x8 -12
+block 81 320:16 8x8 -12
+block 82 328:16 8x8 -12
+block 83 320:24 8x8 -12
+block 84 328:24 8x8 -12
+block 85 336:16 16x16 -12
+block 86 320:32 8x8 0
+block 87 328:32 8x8 0
+block 88 320:40 8x8 0
+block 89 328:40 8x8 0
+block 90 336:32 16x16 -12
+block 91 320:48 16x16 16
+block 92 336:48 16x16 -12
+block 93 0:64 16x32 -23
+block 94 16:64 16x32 -23
+block 95 32:64 8x8 0
+block 96 40:64 8x8 0
+block 97 32:72 8x8 0
+block 98 40:72 8x8 0
+block 99 48:64 8x8 16
+block 100 56:64 8x8 16
+block 101 48:72 8x8 16
+block 102 56:72 8x8 16
+block 103 32:80 16x16 -32
+block 104 48:80 16x16 -32
+block 105 0:96 16x16 -32
+block 106 16:96 16x16 -32
+block 107 0:112 16x16 -32
+block 108 16:112 16x16 -32
+block 109 32:96 16x16 -12
+block 110 48:96 16x16 -12
+block 111 32:112 16x16 -12
+block 112 48:112 16x16 -32
+block 113 64:64 16x16 16
+block 114 80:64 8x8 0
+block 115 88:64 8x8 0
+block 116 80:72 8x8 0
+block 117 88:72 8x8 0
+block 118 64:80 16x16 -32
+block 119 80:80 16x16 -32
+block 120 96:64 16x16 16
+block 121 112:64 16x16 -32
+block 122 96:80 16x16 16
+block 123 112:80 16x16 -32
+block 124 64:96 16x16 -12
+block 125 80:96 8x16 -12
+block 126 88:96 8x16 -12
+block 127 64:112 16x16 -12
+block 128 

Re: [FFmpeg-devel] [PATCH] avformat/mux: Check pkt->stream_index before using it

2020-05-11 Thread Anton Khirnov
Quoting Andreas Rheinhardt (2020-05-10 21:35:54)
> Anton Khirnov:
> > Quoting Marton Balint (2020-05-10 19:45:04)
> >>
> >>
> >> On Sun, 10 May 2020, Anton Khirnov wrote:
> >>
> >>> Quoting Andreas Rheinhardt (2020-05-08 00:55:00)
>  This commit fixes two recent regressions both of which are about using
>  pkt->stream_index as index in an AVFormatContext's streams array before
>  actually comparing the value with the count of streams in said array.
>  96e5e6abb9851d7a26ba21703955d5826ac857c0 did this in
>  prepare_input_packet() and 64063512227c4c87a7d16a1076481dc6baf19841 did
>  likewise in write_packets_common().
> 
>  Signed-off-by: Andreas Rheinhardt 
>  ---
>  The same error in the same file applied on the same day by two different
>  people. How unlikely.
> >>>
> >>> How is it a regression? Isn't it rather invalid API use?
> >>
> >> Fun fact: 7b03b65bf0d02519c86750d2da33f413e11cf0c6
> >>
> >> Yes, it is kind of invalid API use, but since the check is already there, 
> >> we should make it actually worthwile.
> > 
> > lol
> > 
> > I agree that checking for it is a good idea, obviously, but I wouldn't
> > call it a regression.
> > 
> How about rephrasing the first sentence to: "This commit stops using
> pkt->stream_index as index in an AVFormatContext's streams array before
> actually comparing the value with the count of streams in said array."

Sure, sounds good.

> >>
> >>>
> >>> Not that I object to having a check. But then why is check_packet()
> >>> called so deep and not immediately on entry to the muxer?
> >>
> >> I guess it is not that deep, but recent factorization efforts hidden it a 
> >> bit.
> > 
> > You can see in my original commit it is the very first thing done after
> > entering the muxer. Right now it's several function calls deep.
> > 
> I could make it the very first thing called in write_packets_common().

Why not move the check_packet() call out of prepare_packet() into
av_[interleaved_]write_frame() instead?

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

[FFmpeg-devel] [PATCH] drawtext: Allow textfile path to be expanded per frame

2020-05-11 Thread David Andreoletti
drawtext allows a file to be reloaded per frame. However,
the file to be reloaded is constant across frame. With
textfile now supporting text expansion, a different file can
be reloaded per frame. Eg: textfile=/path/fo/file{frame_num}.txt

Signed-off-by: David Andreoletti 
---
 doc/filters.texi  | 16 +---
 libavfilter/vf_drawtext.c | 19 ---
 2 files changed, 29 insertions(+), 6 deletions(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index d19fd346ae..460d65dd88 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -9659,13 +9659,13 @@ The default value of @var{borderw} is 0.
 Set the color to be used for drawing border around text. For the syntax of this
 option, check the @ref{color syntax,,"Color" section in the ffmpeg-utils 
manual,ffmpeg-utils}.
 
 The default value of @var{bordercolor} is "black".
 
 @item expansion
-Select how the @var{text} is expanded. Can be either @code{none},
+Select how the @var{text} and @var{textfile} are expanded. Can be either 
@code{none},
 @code{strftime} (deprecated) or
 @code{normal} (default). See the @ref{drawtext_expansion, Text expansion} 
section
 below for details.
 
 @item basetime
 Set a start time for the count. Value is in microseconds. Only applied
@@ -9786,15 +9786,19 @@ of UTF-8 encoded characters.
 
 This parameter is mandatory if no text string is specified with the
 parameter @var{text}.
 
 If both @var{text} and @var{textfile} are specified, an error is thrown.
 
+This parameter supports (per frame) variable expansion. Per frame variable 
+expansion requires @code{reload=1}. See @var{expansion} for details.
+
+
 @item reload
-If set to 1, the @var{textfile} will be reloaded before each frame.
-Be sure to update it atomically, or it may be read partially, or even fail.
+If set to 1, then before each frame, @var{textfile} file path will be expanded 
and then the file at said path will be reloaded.
+Be sure to update the file atomically, or it may be read partially, or even 
fail.
 
 @item x
 @item y
 The expressions which specify the offsets where text will be drawn
 within the video frame. They are relative to the top/left border of the
 output image.
@@ -10060,12 +10064,18 @@ 
drawtext="fontsize=15:fontfile=FreeSerif.ttf:text=LONG_LINE:y=h-line_h:x=-50*t"
 @item
 Show the content of file @file{CREDITS} off the bottom of the frame and scroll 
up.
 @example
 drawtext="fontsize=20:fontfile=FreeSerif.ttf:textfile=CREDITS:y=h-20*t"
 @end example
 
+@item
+Each frame, reload a different text file at /path/to/frameX.txt, where X is 
replaced with the frame number being processed by the filter
+@example
+drawtext="expansion:normal:textfile=/path/to/frame%@{frame_num@}.txt:reload=1"
+@end example
+
 @item
 Draw a single green letter "g", at the center of the input video.
 The glyph baseline is placed at half screen height.
 @example
 
drawtext="fontsize=60:fontfile=FreeSerif.ttf:fontcolor=green:text=g:x=(w-max_glyph_w)/2:y=h/2-ascent"
 @end example
diff --git a/libavfilter/vf_drawtext.c b/libavfilter/vf_drawtext.c
index abe1ca6c35..ffb1ff2330 100644
--- a/libavfilter/vf_drawtext.c
+++ b/libavfilter/vf_drawtext.c
@@ -152,13 +152,14 @@ typedef struct DrawTextContext {
 AVBPrint expanded_text; ///< used to contain the expanded text
 uint8_t *fontcolor_expr;///< fontcolor expression to evaluate
 AVBPrint expanded_fontcolor;///< used to contain the expanded 
fontcolor spec
 int ft_load_flags;  ///< flags used for loading fonts, see 
FT_LOAD_*
 FT_Vector *positions;   ///< positions for each element in the text
 size_t nb_positions;///< number of elements of positions array
-char *textfile; ///< file with text to be drawn
+char *textfile; ///< filename with text to be drawn
+AVBPrint expanded_textfile; ///< Same as textfile, except the filename 
can be expanded
 int x;  ///< x position to start drawing text
 int y;  ///< y position to start drawing text
 int max_glyph_w;///< max glyph width
 int max_glyph_h;///< max glyph height
 int shadowx, shadowy;
 int borderw;///< border width
@@ -565,24 +566,33 @@ static int load_font(AVFilterContext *ctx)
 if (!err)
 return 0;
 #endif
 return err;
 }
 
+static int expand_text(AVFilterContext *ctx, char *text, AVBPrint *bp);
 static int load_textfile(AVFilterContext *ctx)
 {
 DrawTextContext *s = ctx->priv;
 int err;
 uint8_t *textbuf;
 uint8_t *tmp;
 size_t textbuf_size;
 
-if ((err = av_file_map(s->textfile, , _size, 0, ctx)) < 0) 
{
+if ((err = expand_text(ctx, s->textfile, >expanded_textfile)) < 0) {
+av_log(ctx, AV_LOG_ERROR, "The text file path '%s' is not 
expandable\n",
+s->textfile);
+return err;
+}
+
+av_log(ctx, AV_LOG_DEBUG, "expanded_textfile:%s\n", 

[FFmpeg-devel] [PATCH 2/2] avcodec/libdav1d: export frame sample aspect ratio

2020-05-11 Thread James Almer
Signed-off-by: James Almer 
---
 libavcodec/libdav1d.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/libavcodec/libdav1d.c b/libavcodec/libdav1d.c
index 72f06c550e..a265a487d8 100644
--- a/libavcodec/libdav1d.c
+++ b/libavcodec/libdav1d.c
@@ -335,6 +335,12 @@ static int libdav1d_receive_frame(AVCodecContext *c, 
AVFrame *frame)
 goto fail;
 }
 
+av_reduce(>sample_aspect_ratio.num,
+  >sample_aspect_ratio.den,
+  frame->height * (int64_t)p->frame_hdr->render_width,
+  frame->width  * (int64_t)p->frame_hdr->render_height,
+  INT_MAX);
+
 if (p->m.user_data.data)
 memcpy(>reordered_opaque, p->m.user_data.data, 
sizeof(frame->reordered_opaque));
 else
-- 
2.26.2

___
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/2] avcodec/libdav1d: try to set decoder context parameters during init()

2020-05-11 Thread James Almer
If extradata is available, use it to initialize the AVCodecContext before
packet data is seen. Also, don't constantly overwrite it after it's set.

Signed-off-by: James Almer 
---
The main benefit from this is using ff_decode_frame_props() to fill frame
props, which includes copying any relevant side data that may be present in
packets, like for example container mastering metadata propagated by a demuxer.

 libavcodec/libdav1d.c | 102 +-
 1 file changed, 71 insertions(+), 31 deletions(-)

diff --git a/libavcodec/libdav1d.c b/libavcodec/libdav1d.c
index 5248e3f9f5..72f06c550e 100644
--- a/libavcodec/libdav1d.c
+++ b/libavcodec/libdav1d.c
@@ -42,6 +42,8 @@ typedef struct Libdav1dContext {
 int apply_grain;
 int operating_point;
 int all_layers;
+
+int inited;
 } Libdav1dContext;
 
 static const enum AVPixelFormat pix_fmt[][3] = {
@@ -117,9 +119,59 @@ static void libdav1d_picture_release(Dav1dPicture *p, void 
*cookie)
 av_buffer_unref();
 }
 
+static int libdav1d_init_params(AVCodecContext *c, Dav1dSequenceHeader *seq)
+{
+Libdav1dContext *dav1d = c->priv_data;
+int res;
+
+if (dav1d->inited)
+return 0;
+
+c->profile = seq->profile;
+c->level = ((seq->operating_points[0].major_level - 2) << 2)
+   | seq->operating_points[0].minor_level;
+
+res = ff_set_dimensions(c, seq->max_width, seq->max_height);
+if (res < 0)
+return res;
+
+switch (seq->chr) {
+case DAV1D_CHR_VERTICAL:
+c->chroma_sample_location = AVCHROMA_LOC_LEFT;
+break;
+case DAV1D_CHR_COLOCATED:
+c->chroma_sample_location = AVCHROMA_LOC_TOPLEFT;
+break;
+}
+c->colorspace = (enum AVColorSpace) seq->mtrx;
+c->color_primaries = (enum AVColorPrimaries) seq->pri;
+c->color_trc = (enum AVColorTransferCharacteristic) seq->trc;
+c->color_range = seq->color_range ? AVCOL_RANGE_JPEG : AVCOL_RANGE_MPEG;
+
+if (seq->layout == DAV1D_PIXEL_LAYOUT_I444 &&
+seq->mtrx == DAV1D_MC_IDENTITY &&
+seq->pri  == DAV1D_COLOR_PRI_BT709 &&
+seq->trc  == DAV1D_TRC_SRGB)
+c->pix_fmt = pix_fmt_rgb[seq->hbd];
+else
+c->pix_fmt = pix_fmt[seq->layout][seq->hbd];
+
+if (seq->num_units_in_tick && seq->time_scale) {
+av_reduce(>framerate.den, >framerate.num,
+  seq->num_units_in_tick, seq->time_scale, INT_MAX);
+if (seq->equal_picture_interval)
+c->ticks_per_frame = seq->num_ticks_per_picture;
+}
+
+dav1d->inited = 1;
+
+return 0;
+}
+
 static av_cold int libdav1d_init(AVCodecContext *c)
 {
 Libdav1dContext *dav1d = c->priv_data;
+Dav1dSequenceHeader seq;
 Dav1dSettings s;
 int threads = (c->thread_count ? c->thread_count : av_cpu_count()) * 3 / 2;
 int res;
@@ -153,6 +205,16 @@ static av_cold int libdav1d_init(AVCodecContext *c)
 if (res < 0)
 return AVERROR(ENOMEM);
 
+if (c->extradata && c->extradata_size) {
+res = dav1d_parse_sequence_header(, c->extradata, 
c->extradata_size);
+if (res < 0)
+return AVERROR_INVALIDDATA;
+
+res = libdav1d_init_params(c, );
+if (res < 0)
+return res;
+}
+
 return 0;
 }
 
@@ -162,6 +224,7 @@ static void libdav1d_flush(AVCodecContext *c)
 
 dav1d_data_unref(>data);
 dav1d_flush(dav1d->c);
+dav1d->inited = 0;
 }
 
 static void libdav1d_data_free(const uint8_t *data, void *opaque) {
@@ -256,9 +319,14 @@ static int libdav1d_receive_frame(AVCodecContext *c, 
AVFrame *frame)
 frame->linesize[1] = p->stride[1];
 frame->linesize[2] = p->stride[1];
 
-c->profile = p->seq_hdr->profile;
-c->level = ((p->seq_hdr->operating_points[0].major_level - 2) << 2)
-   | p->seq_hdr->operating_points[0].minor_level;
+res = libdav1d_init_params(c, p->seq_hdr);
+if (res < 0)
+return res;
+
+res = ff_decode_frame_props(c, frame);
+if (res < 0)
+return res;
+
 frame->width = p->p.w;
 frame->height = p->p.h;
 if (c->width != p->p.w || c->height != p->p.h) {
@@ -267,39 +335,11 @@ static int libdav1d_receive_frame(AVCodecContext *c, 
AVFrame *frame)
 goto fail;
 }
 
-switch (p->seq_hdr->chr) {
-case DAV1D_CHR_VERTICAL:
-frame->chroma_location = c->chroma_sample_location = AVCHROMA_LOC_LEFT;
-break;
-case DAV1D_CHR_COLOCATED:
-frame->chroma_location = c->chroma_sample_location = 
AVCHROMA_LOC_TOPLEFT;
-break;
-}
-frame->colorspace = c->colorspace = (enum AVColorSpace) p->seq_hdr->mtrx;
-frame->color_primaries = c->color_primaries = (enum AVColorPrimaries) 
p->seq_hdr->pri;
-frame->color_trc = c->color_trc = (enum AVColorTransferCharacteristic) 
p->seq_hdr->trc;
-frame->color_range = c->color_range = p->seq_hdr->color_range ? 
AVCOL_RANGE_JPEG : AVCOL_RANGE_MPEG;
-
-if (p->p.layout == DAV1D_PIXEL_LAYOUT_I444 &&
-

[FFmpeg-devel] [PATCH] hwcontext: add av_hwdevice_ctx_create_derived2

2020-05-11 Thread Lynne
This allows for users who derive devices to set options for the 
new device context they derive.
The main use case of this is to allow users to enable extensions
(such as surface drawing extensions) in Vulkan while deriving from
the device their frames are on. That way, users don't need to write
any initialization code themselves, since currently Vulkan prevents
mixing instances and devices.
Also, with this, users can also set custom OpenCL extensions such
as cl_khr_gl_sharing and cl_khr_gl_depth_images.
Apart from OpenCL and Vulkan, other hwcontexts ignore the opts
argument since they don't support options at all (or in VAAPI's case,
options are only used for device selection, which device_derive overrides).

Patch attached.

>From bd8bfb7f29dd6218ae199802e53b242b26e4feb2 Mon Sep 17 00:00:00 2001
From: Lynne 
Date: Mon, 11 May 2020 11:02:19 +0100
Subject: [PATCH] hwcontext: add av_hwdevice_ctx_create_derived2

This allows for users who derive devices to set options for the
new device context they derive.
The main use case of this is to allow users to enable extensions
(such as surface drawing extensions) in Vulkan while deriving from
the device their frames are on. That way, users don't need to write
any initialization code themselves, since currently Vulkan prevents
mixing instances and devices.
Also, with this, users can also set custom OpenCL extensions such
as cl_khr_gl_sharing and cl_khr_gl_depth_images.
Apart from OpenCL and Vulkan, other hwcontexts ignore the opts
argument since they don't support options at all (or in VAAPI's case,
options are only used for device selection, which device_derive overrides).
---
 doc/APIchanges |  3 +++
 libavutil/hwcontext.c  | 16 +---
 libavutil/hwcontext.h  | 20 
 libavutil/hwcontext_cuda.c |  1 +
 libavutil/hwcontext_internal.h |  2 +-
 libavutil/hwcontext_opencl.c   | 13 +++--
 libavutil/hwcontext_qsv.c  |  2 +-
 libavutil/hwcontext_vaapi.c|  2 +-
 libavutil/hwcontext_vulkan.c   |  8 
 libavutil/version.h|  2 +-
 10 files changed, 52 insertions(+), 17 deletions(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index 75cfdb08b0..1bb0677142 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -15,6 +15,9 @@ libavutil: 2017-10-21
 
 API changes, most recent first:
 
+2020-05-11 - xx - lavu 56.45.100 - hwcontext.h
+  Add av_hwdevice_ctx_create_derived2.
+
 2020-05-10 - xx - lavu 56.44.100 - hwcontext_vulkan.h
   Add enabled_inst_extensions, num_enabled_inst_extensions, enabled_dev_extensions
   and num_enabled_dev_extensions fields to AVVulkanDeviceContext
diff --git a/libavutil/hwcontext.c b/libavutil/hwcontext.c
index b01612de05..77b7014c39 100644
--- a/libavutil/hwcontext.c
+++ b/libavutil/hwcontext.c
@@ -643,9 +643,10 @@ fail:
 return ret;
 }
 
-int av_hwdevice_ctx_create_derived(AVBufferRef **dst_ref_ptr,
-   enum AVHWDeviceType type,
-   AVBufferRef *src_ref, int flags)
+int av_hwdevice_ctx_create_derived2(AVBufferRef **dst_ref_ptr,
+enum AVHWDeviceType type,
+AVDictionary *options,
+AVBufferRef *src_ref, int flags)
 {
 AVBufferRef *dst_ref = NULL, *tmp_ref;
 AVHWDeviceContext *dst_ctx, *tmp_ctx;
@@ -677,6 +678,7 @@ int av_hwdevice_ctx_create_derived(AVBufferRef **dst_ref_ptr,
 tmp_ctx = (AVHWDeviceContext*)tmp_ref->data;
 if (dst_ctx->internal->hw_type->device_derive) {
 ret = dst_ctx->internal->hw_type->device_derive(dst_ctx,
+options,
 tmp_ctx,
 flags);
 if (ret == 0) {
@@ -709,6 +711,14 @@ fail:
 return ret;
 }
 
+int av_hwdevice_ctx_create_derived(AVBufferRef **dst_ref_ptr,
+   enum AVHWDeviceType type,
+   AVBufferRef *src_ref, int flags)
+{
+return av_hwdevice_ctx_create_derived2(dst_ref_ptr, type, NULL,
+   src_ref, flags);
+}
+
 static void ff_hwframe_unmap(void *opaque, uint8_t *data)
 {
 HWMapDescriptor *hwmap = (HWMapDescriptor*)data;
diff --git a/libavutil/hwcontext.h b/libavutil/hwcontext.h
index f874af9f8f..4a94a2a8e4 100644
--- a/libavutil/hwcontext.h
+++ b/libavutil/hwcontext.h
@@ -328,6 +328,26 @@ int av_hwdevice_ctx_create_derived(AVBufferRef **dst_ctx,
enum AVHWDeviceType type,
AVBufferRef *src_ctx, int flags);
 
+/**
+ * Create a new device of the specified type from an existing device.
+ *
+ * This function performs the same action as av_hwdevice_ctx_create_derived,
+ * however, it is able to set options for the new device to be 

Re: [FFmpeg-devel] [PATCH 0/2] avformat movenc add flag to allow disabling limit on timescale

2020-05-11 Thread vectronic


> On 5 May 2020, at 06:19, Gyan Doshi  wrote:
> 
> 
> 
> On 05-05-2020 03:16 am, vectronic wrote:
>> 
>>> On 4 May 2020, at 17:56, Gyan Doshi  wrote:
>>> 
>>> 
>>> 
>>> On 04-05-2020 09:54 pm, vectronic wrote:
 I needed to encode to mov/mp4 with a timebase of 1/600 and the output was 
 not as expected.
>>> What was the unexpected output?
>>> 
>>> You can use video_track_timescale to set any custom scale.
>>> 
>>> Gyan
>> The unexpected output is that if you request a timebase of 600 as an 
>> argument for ffmpeg on the command line, the output timebase is forced to be 
>> greater than 1.
>> 
>> As far as I can see there is no documentation or message logged that the 
>> following logic is applied which means the output differs to what a user has 
>> requested and expects:
>> 
>> while(track->timescale < 1)
>> track->timescale *= 2;
>> 
>> I believe video_track_timescale applies to all tracks - so you unable to 
>> specify timescales per track?
> 
> I believe your flag also disables the scale clamping for all video tracks. In 
> that case, better to extend the min value of video_track_timescale  to -1 to 
> implement this instead of a new flag.
> 
> Gyan
> 

Hello Gyan,

I updated the patch with your feedback here: 
https://patchwork.ffmpeg.org/project/ffmpeg/list/?series=1138

Do you have any further feedback?

Thanks,

Nick


___
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] fate: add adpcm_ima_cunning tests

2020-05-11 Thread Zane van Iperen
On Sat, 09 May 2020 14:00:04 +
"Zane van Iperen"  wrote:

> 
> single:   Single-track
> track{0,1}:   Dual-track
> trunc-t1: Truncated track 1
> trunc-t2-track{0,1}:  Fully-truncated track 2
> trunc-t2a-track{0,1}: Partially-truncated track 2
> trunc-h2: Truncated track 2 header
> 
> Signed-off-by: Zane van Iperen 
> ---
>  tests/fate/adpcm.mak  | 27
> +++ tests/ref/fate/adpcm-ima-cunning-single   |
> 1 + tests/ref/fate/adpcm-ima-cunning-track0   |  1 +
>  tests/ref/fate/adpcm-ima-cunning-track1   |  1 +
>  tests/ref/fate/adpcm-ima-cunning-trunc-h2 |  1 +
>  tests/ref/fate/adpcm-ima-cunning-trunc-t1 |  1 +
>  .../fate/adpcm-ima-cunning-trunc-t2-track0|  1 +
>  .../fate/adpcm-ima-cunning-trunc-t2-track1|  1 +
>  .../fate/adpcm-ima-cunning-trunc-t2a-track0   |  1 +
>  .../fate/adpcm-ima-cunning-trunc-t2a-track1   |  1 +
>  10 files changed, 36 insertions(+)
>  create mode 100644 tests/ref/fate/adpcm-ima-cunning-single
>  create mode 100644 tests/ref/fate/adpcm-ima-cunning-track0
>  create mode 100644 tests/ref/fate/adpcm-ima-cunning-track1
>  create mode 100644 tests/ref/fate/adpcm-ima-cunning-trunc-h2
>  create mode 100644 tests/ref/fate/adpcm-ima-cunning-trunc-t1
>  create mode 100644 tests/ref/fate/adpcm-ima-cunning-trunc-t2-track0
>  create mode 100644 tests/ref/fate/adpcm-ima-cunning-trunc-t2-track1
>  create mode 100644 tests/ref/fate/adpcm-ima-cunning-trunc-t2a-track0
>  create mode 100644 tests/ref/fate/adpcm-ima-cunning-trunc-t2a-track1
> 

Ping.

Sample upload request sent several days prior to submission.

Zane

___
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] doc/encoders: ffaacenc does not output CBR

2020-05-11 Thread Guillaume Khayat
The documentation and wiki imply the native AAC encoder can output CBR and VBR 
files :
>b
>Set bit rate in bits/s. Setting this automatically activates constant bit rate 
>(CBR) mode. If this option is unspecified it is set to 128kbps.
>
>q
>Set quality for variable bit rate (VBR) mode. This option is valid only using 
>the ffmpeg command-line tool. For library interface users, use global_quality.

Sources:
- https://ffmpeg.org/ffmpeg-all.html#Options-7
- https://trac.ffmpeg.org/wiki/Encode/AAC#NativeFFmpegAACEncoder

But testing the CBR mode gives out unexpected results
1. `ffmpeg -f lavfi -i sine=d=10 -c:a aac -b:a 128k out.m4a`
=> outputs a variable bit rate file, with an average bitrate of 85kbps 
file, and a max bitrate of 128kbps
2. `ffmpeg -i someMusicMp3File -c:a aac -b:a 128k out.m4a`
=> outputs a variable bit rate file, with an average bitrate of 122kbps 
file, and a max bitrate of 128kbps

I think the advertised "CBR" mode is instead a “constrained VBR” mode, where 
the provided bitrate is used as a target and/or a maximum allowed bitrate.

Signed-off-by: Guillaume Khayat 
---
 doc/encoders.texi | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/doc/encoders.texi b/doc/encoders.texi
index aa3a6eeb66..44ff5e469b 100644
--- a/doc/encoders.texi
+++ b/doc/encoders.texi
@@ -30,17 +30,19 @@ follows.
 
 Advanced Audio Coding (AAC) encoder.
 
-This encoder is the default AAC encoder, natively implemented into FFmpeg.
+This encoder is the default AAC encoder, natively implemented into FFmpeg. It
+supports a constrained variable bit rate mode and a true variable bit (VBR)
+rate mode.
 
 @subsection Options
 
 @table @option
 @item b
-Set bit rate in bits/s. Setting this automatically activates constant bit rate
-(CBR) mode. If this option is unspecified it is set to 128kbps.
+Set maxmimum bit rate in bits/s. Setting this automatically activates 
constrained
+variable bit rate mode. If this option is unspecified it is set to 128kbps.
 
 @item q
-Set quality for variable bit rate (VBR) mode. This option is valid only using
+Set quality for true variable bit rate (VBR) mode. This option is valid only 
using
 the @command{ffmpeg} command-line tool. For library interface users, use
 @option{global_quality}.
 
-- 
2.24.2 (Apple Git-127)

___
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] avcodec/mpegvideo: prefer to use variable instead of type for sizeof

2020-05-11 Thread lance . lmwang
On Mon, May 11, 2020 at 09:16:39AM +0200, Marton Balint wrote:
> 
> 
> On Mon, 11 May 2020, lance.lmw...@gmail.com wrote:
> 
> > On Mon, May 11, 2020 at 01:22:24AM +0200, Marton Balint wrote:
> > > 
> > > 
> > > On Mon, 11 May 2020, lance.lmw...@gmail.com wrote:
> > > 
> > > > On Sun, May 10, 2020 at 06:30:41PM +0200, Marton Balint wrote:
> > > > > > > > > On Sun, 10 May 2020, lance.lmw...@gmail.com wrote:
> > > > > > > > From: Limin Wang 
> > > > > > > Signed-off-by: Limin Wang 
> > > > > > ---
> > > > > > libavcodec/mpegvideo.c | 48 
> > > > > > 
> > > > > > 1 file changed, 24 insertions(+), 24 deletions(-)
> > > > > > > If you find these cosmetics interesting, then I suggest you
> > > introduce a new
> > > > > macro instead: FF_ALLOCZ_ARRAY_OR_GOTO().
> > > > > > > E.g.:
> > > > > > > FF_ALLOCZ_ARRAY_OR_GOTO(s->avctx, s->me.map, ME_MAP_SIZE,
> > > fail)
> > > > > Yeah, I have considered it so I change the type to use use
> > > variable first and
> > > > submit one typical for review. If the change is OK, then I'll go ahead 
> > > > next.
> > > 
> > > No need to do it in two steps, better touch the code once. E.g. patch 2
> > > might not even be needed if you do this in a single patch.
> > 
> > Sorry, now for array alloc, you had to input the one elemeay size and its 
> > count
> > always. internal.h have defined it already:
> > FF_ALLOCZ_ARRAY_OR_GOTO(ctx, p, nelem, elsize, label)
> > 
> > You don't want to input elsize? isn't general usage?
> 
> I just found out that there is already an FF_ALLOCZ_ARRAY_OR_GOTO with
> elsize. So you should add a new macro which uses FF_ALLOCZ_ARRAY_OR_GOTO and
> calculates elszize automatically. I am not sure about the name:
> FF_ALLOCZ_TYPED_ARRAY_OR_GOTO ?

OK, I'll add the new macro FF_ALLOCZ_TYPED_ARRAY_OR_GOTO.

> 
> Regards,
> Marton
> 
> > 
> > > 
> > > Regards,
> > > Marton
> > > 
> > > > > > > > Regards,
> > > > > Marton
> > > > > > > > > diff --git a/libavcodec/mpegvideo.c
> > > b/libavcodec/mpegvideo.c
> > > > > > index 49fd1c9..561062f 100644
> > > > > > --- a/libavcodec/mpegvideo.c
> > > > > > +++ b/libavcodec/mpegvideo.c
> > > > > > @@ -373,15 +373,15 @@ static int 
> > > > > > init_duplicate_context(MpegEncContext *s)
> > > > > > > if (s->encoding) {
> > > > > > FF_ALLOCZ_OR_GOTO(s->avctx, s->me.map,
> > > > > > -  ME_MAP_SIZE * sizeof(uint32_t), fail)
> > > > > > +  ME_MAP_SIZE * sizeof(*s->me.map), fail)
> > > > > > FF_ALLOCZ_OR_GOTO(s->avctx, s->me.score_map,
> > > > > > -  ME_MAP_SIZE * sizeof(uint32_t), fail)
> > > > > > +  ME_MAP_SIZE * sizeof(*s->me.score_map), 
> > > > > > fail)
> > > > > > if (s->noise_reduction) {
> > > > > > FF_ALLOCZ_OR_GOTO(s->avctx, s->dct_error_sum,
> > > > > > -  2 * 64 * sizeof(int), fail)
> > > > > > +  2 * 64 * sizeof(*s->dct_error_sum), 
> > > > > > fail)
> > > > > > }
> > > > > > }
> > > > > > -FF_ALLOCZ_OR_GOTO(s->avctx, s->blocks, 64 * 12 * 2 * 
> > > > > > sizeof(int16_t), fail)
> > > > > > +FF_ALLOCZ_OR_GOTO(s->avctx, s->blocks, 64 * 12 * 2 * 
> > > > > > sizeof(*s->blocks), fail)
> > > > > > s->block = s->blocks[0];
> > > > > > > for (i = 0; i < 12; i++) {
> > > > > > @@ -400,7 +400,7 @@ static int 
> > > > > > init_duplicate_context(MpegEncContext *s)
> > > > > > if (s->out_format == FMT_H263) {
> > > > > > /* ac values */
> > > > > > FF_ALLOCZ_OR_GOTO(s->avctx, s->ac_val_base,
> > > > > > -  yc_size * sizeof(int16_t) * 16, fail);
> > > > > > +  yc_size * sizeof(*s->ac_val_base) * 16, 
> > > > > > fail);
> > > > > > s->ac_val[0] = s->ac_val_base + s->b8_stride + 1;
> > > > > > s->ac_val[1] = s->ac_val_base + y_size + s->mb_stride + 1;
> > > > > > s->ac_val[2] = s->ac_val[1] + c_size;
> > > > > > @@ -715,7 +715,7 @@ static int init_context_frame(MpegEncContext *s)
> > > > > > if (s->mb_height & 1)
> > > > > > yc_size += 2*s->b8_stride + 2*s->mb_stride;
> > > > > > > -FF_ALLOCZ_OR_GOTO(s->avctx, s->mb_index2xy, (s->mb_num + 1)
> > > > > * sizeof(int),
> > > > > > +FF_ALLOCZ_OR_GOTO(s->avctx, s->mb_index2xy, (s->mb_num + 1) * 
> > > > > > sizeof(*s->mb_index2xy),
> > > > > >   fail); // error resilience code looks cleaner 
> > > > > > with this
> > > > > > for (y = 0; y < s->mb_height; y++)
> > > > > > for (x = 0; x < s->mb_width; x++)
> > > > > > @@ -725,12 +725,12 @@ static int init_context_frame(MpegEncContext 
> > > > > > *s)
> > > > > > > if (s->encoding) {
> > > > > > /* Allocate MV tables */
> > > > > > -FF_ALLOCZ_OR_GOTO(s->avctx, s->p_mv_table_base,
> > > > > >  mv_table_size * 2 * sizeof(int16_t), fail)
> > > > > > -FF_ALLOCZ_OR_GOTO(s->avctx, 

Re: [FFmpeg-devel] [PATCH] hwcontext: add av_hwdevice_ctx_create_derived2

2020-05-11 Thread James Almer
On 5/11/2020 7:25 AM, Lynne wrote:
> This allows for users who derive devices to set options for the 
> new device context they derive.
> The main use case of this is to allow users to enable extensions
> (such as surface drawing extensions) in Vulkan while deriving from
> the device their frames are on. That way, users don't need to write
> any initialization code themselves, since currently Vulkan prevents
> mixing instances and devices.
> Also, with this, users can also set custom OpenCL extensions such
> as cl_khr_gl_sharing and cl_khr_gl_depth_images.
> Apart from OpenCL and Vulkan, other hwcontexts ignore the opts
> argument since they don't support options at all (or in VAAPI's case,
> options are only used for device selection, which device_derive overrides).
> 
> Patch attached.

Could this be av_hwdevice_ctx_create_derived_dict() or similar, please?
The 2 suffix is pretty ugly and it would be nice if we can avoid adding
more of them.
___
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] drawtext: Allow textfile path to be expanded (and then reloaded) every frame

2020-05-11 Thread David Andreoletti
Signed-off-by: David Andreoletti 
---
 doc/filters.texi  | 16 +---
 libavfilter/vf_drawtext.c | 19 ---
 2 files changed, 29 insertions(+), 6 deletions(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index d19fd346ae..3a127369ea 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -9659,13 +9659,13 @@ The default value of @var{borderw} is 0.
 Set the color to be used for drawing border around text. For the syntax of this
 option, check the @ref{color syntax,,"Color" section in the ffmpeg-utils 
manual,ffmpeg-utils}.
 
 The default value of @var{bordercolor} is "black".
 
 @item expansion
-Select how the @var{text} is expanded. Can be either @code{none},
+Select how the @var{text} and @var{textfile} are expanded. Can be either 
@code{none},
 @code{strftime} (deprecated) or
 @code{normal} (default). See the @ref{drawtext_expansion, Text expansion} 
section
 below for details.
 
 @item basetime
 Set a start time for the count. Value is in microseconds. Only applied
@@ -9786,15 +9786,19 @@ of UTF-8 encoded characters.
 
 This parameter is mandatory if no text string is specified with the
 parameter @var{text}.
 
 If both @var{text} and @var{textfile} are specified, an error is thrown.
 
+This parameter supports (per frame) variable expansion. Per frame variable 
+expansion requires @code{reload=1}. See @var{expansion} for details.
+
+
 @item reload
-If set to 1, the @var{textfile} will be reloaded before each frame.
-Be sure to update it atomically, or it may be read partially, or even fail.
+If set to 1, then before each frame, @var{textfile} file path will be expanded 
and then the file at said path will be reloaded.
+Be sure to update the file atomically, or it may be read partially, or even 
fail.
 
 @item x
 @item y
 The expressions which specify the offsets where text will be drawn
 within the video frame. They are relative to the top/left border of the
 output image.
@@ -10060,12 +10064,18 @@ 
drawtext="fontsize=15:fontfile=FreeSerif.ttf:text=LONG_LINE:y=h-line_h:x=-50*t"
 @item
 Show the content of file @file{CREDITS} off the bottom of the frame and scroll 
up.
 @example
 drawtext="fontsize=20:fontfile=FreeSerif.ttf:textfile=CREDITS:y=h-20*t"
 @end example
 
+@item
+Each frame, reload a different text file at /path/to/frameX.txt, where X is 
replaced with the frame number being processed by the filter
+@example
+drawtext="expansion:normal:textfile=/path/to/frame%{frame_num}.txt:reload=1"
+@end example
+
 @item
 Draw a single green letter "g", at the center of the input video.
 The glyph baseline is placed at half screen height.
 @example
 
drawtext="fontsize=60:fontfile=FreeSerif.ttf:fontcolor=green:text=g:x=(w-max_glyph_w)/2:y=h/2-ascent"
 @end example
diff --git a/libavfilter/vf_drawtext.c b/libavfilter/vf_drawtext.c
index abe1ca6c35..ffb1ff2330 100644
--- a/libavfilter/vf_drawtext.c
+++ b/libavfilter/vf_drawtext.c
@@ -152,13 +152,14 @@ typedef struct DrawTextContext {
 AVBPrint expanded_text; ///< used to contain the expanded text
 uint8_t *fontcolor_expr;///< fontcolor expression to evaluate
 AVBPrint expanded_fontcolor;///< used to contain the expanded 
fontcolor spec
 int ft_load_flags;  ///< flags used for loading fonts, see 
FT_LOAD_*
 FT_Vector *positions;   ///< positions for each element in the text
 size_t nb_positions;///< number of elements of positions array
-char *textfile; ///< file with text to be drawn
+char *textfile; ///< filename with text to be drawn
+AVBPrint expanded_textfile; ///< Same as textfile, except the filename 
can be expanded
 int x;  ///< x position to start drawing text
 int y;  ///< y position to start drawing text
 int max_glyph_w;///< max glyph width
 int max_glyph_h;///< max glyph height
 int shadowx, shadowy;
 int borderw;///< border width
@@ -565,24 +566,33 @@ static int load_font(AVFilterContext *ctx)
 if (!err)
 return 0;
 #endif
 return err;
 }
 
+static int expand_text(AVFilterContext *ctx, char *text, AVBPrint *bp);
 static int load_textfile(AVFilterContext *ctx)
 {
 DrawTextContext *s = ctx->priv;
 int err;
 uint8_t *textbuf;
 uint8_t *tmp;
 size_t textbuf_size;
 
-if ((err = av_file_map(s->textfile, , _size, 0, ctx)) < 0) 
{
+if ((err = expand_text(ctx, s->textfile, >expanded_textfile)) < 0) {
+av_log(ctx, AV_LOG_ERROR, "The text file path '%s' is not 
expandable\n",
+s->textfile);
+return err;
+}
+
+av_log(ctx, AV_LOG_DEBUG, "expanded_textfile:%s\n", 
s->expanded_textfile.str);
+
+if ((err = av_file_map(s->expanded_textfile.str, , _size, 
0, ctx)) < 0) {
 av_log(ctx, AV_LOG_ERROR,
"The text file '%s' could not be read or is empty\n",
-   

Re: [FFmpeg-devel] [PATCH 2/2] avformat/ivfenc: move bsf insertion to the init function

2020-05-11 Thread Anton Khirnov
Quoting Andreas Rheinhardt (2020-05-11 13:59:27)
> James Almer:
> > Signed-off-by: James Almer 
> > ---
> >  libavformat/ivfenc.c | 24 ++--
> >  1 file changed, 10 insertions(+), 14 deletions(-)
> > 
> > diff --git a/libavformat/ivfenc.c b/libavformat/ivfenc.c
> > index 0ce4a85171..0951f56c92 100644
> > --- a/libavformat/ivfenc.c
> > +++ b/libavformat/ivfenc.c
> > @@ -43,6 +43,16 @@ static int ivf_init(AVFormatContext *s)
> >  return AVERROR(EINVAL);
> >  }
> >  
> > +if (par->codec_id == AV_CODEC_ID_VP9) {
> > +int ret = ff_stream_add_bitstream_filter(s->streams[0], 
> > "vp9_superframe", NULL);
> > +if (ret < 0)
> > +return ret;
> > +} else if (par->codec_id == AV_CODEC_ID_AV1) {
> > +int ret = ff_stream_add_bitstream_filter(s->streams[0], 
> > "av1_metadata", "td=insert");
> > +if (ret < 0)
> > +return ret;
> > +}
> > +
> >  return 0;
> >  }
> >  
> > @@ -100,19 +110,6 @@ static int ivf_write_trailer(AVFormatContext *s)
> >  return 0;
> >  }
> >  
> > -static int ivf_check_bitstream(struct AVFormatContext *s, const AVPacket 
> > *pkt)
> > -{
> > -int ret = 1;
> > -AVStream *st = s->streams[pkt->stream_index];
> > -
> > -if (st->codecpar->codec_id == AV_CODEC_ID_VP9)
> > -ret = ff_stream_add_bitstream_filter(st, "vp9_superframe", NULL);
> > -else if (st->codecpar->codec_id == AV_CODEC_ID_AV1)
> > -ret = ff_stream_add_bitstream_filter(st, "av1_metadata", 
> > "td=insert");
> > -
> > -return ret;
> > -}
> > -
> >  static const AVCodecTag codec_ivf_tags[] = {
> >  { AV_CODEC_ID_VP8,  MKTAG('V', 'P', '8', '0') },
> >  { AV_CODEC_ID_VP9,  MKTAG('V', 'P', '9', '0') },
> > @@ -131,6 +128,5 @@ AVOutputFormat ff_ivf_muxer = {
> >  .write_header = ivf_write_header,
> >  .write_packet = ivf_write_packet,
> >  .write_trailer = ivf_write_trailer,
> > -.check_bitstream = ivf_check_bitstream,
> >  .codec_tag= (const AVCodecTag* const []){ codec_ivf_tags, 0 },
> >  };
> > 
> LGTM. (Would it actually make sense/be possible to replace st->codecpar
> with the output codecparameters of the bsf if the bsf is initialized in
> the init function, so that it is easier for the muxer to locate the
> right codecparameters when writing the header?)

I'd say ideally the muxer internals should be decoupled from the
outwards user-facing AVFormatContext/AVStream and not touch them
directly. Same for the codecs.
It would probably take a lot of work to implement though.

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

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

Re: [FFmpeg-devel] [PATCH 2/2] avformat/ivfenc: move bsf insertion to the init function

2020-05-11 Thread Andreas Rheinhardt
James Almer:
> Signed-off-by: James Almer 
> ---
>  libavformat/ivfenc.c | 24 ++--
>  1 file changed, 10 insertions(+), 14 deletions(-)
> 
> diff --git a/libavformat/ivfenc.c b/libavformat/ivfenc.c
> index 0ce4a85171..0951f56c92 100644
> --- a/libavformat/ivfenc.c
> +++ b/libavformat/ivfenc.c
> @@ -43,6 +43,16 @@ static int ivf_init(AVFormatContext *s)
>  return AVERROR(EINVAL);
>  }
>  
> +if (par->codec_id == AV_CODEC_ID_VP9) {
> +int ret = ff_stream_add_bitstream_filter(s->streams[0], 
> "vp9_superframe", NULL);
> +if (ret < 0)
> +return ret;
> +} else if (par->codec_id == AV_CODEC_ID_AV1) {
> +int ret = ff_stream_add_bitstream_filter(s->streams[0], 
> "av1_metadata", "td=insert");
> +if (ret < 0)
> +return ret;
> +}
> +
>  return 0;
>  }
>  
> @@ -100,19 +110,6 @@ static int ivf_write_trailer(AVFormatContext *s)
>  return 0;
>  }
>  
> -static int ivf_check_bitstream(struct AVFormatContext *s, const AVPacket 
> *pkt)
> -{
> -int ret = 1;
> -AVStream *st = s->streams[pkt->stream_index];
> -
> -if (st->codecpar->codec_id == AV_CODEC_ID_VP9)
> -ret = ff_stream_add_bitstream_filter(st, "vp9_superframe", NULL);
> -else if (st->codecpar->codec_id == AV_CODEC_ID_AV1)
> -ret = ff_stream_add_bitstream_filter(st, "av1_metadata", 
> "td=insert");
> -
> -return ret;
> -}
> -
>  static const AVCodecTag codec_ivf_tags[] = {
>  { AV_CODEC_ID_VP8,  MKTAG('V', 'P', '8', '0') },
>  { AV_CODEC_ID_VP9,  MKTAG('V', 'P', '9', '0') },
> @@ -131,6 +128,5 @@ AVOutputFormat ff_ivf_muxer = {
>  .write_header = ivf_write_header,
>  .write_packet = ivf_write_packet,
>  .write_trailer = ivf_write_trailer,
> -.check_bitstream = ivf_check_bitstream,
>  .codec_tag= (const AVCodecTag* const []){ codec_ivf_tags, 0 },
>  };
> 
LGTM. (Would it actually make sense/be possible to replace st->codecpar
with the output codecparameters of the bsf if the bsf is initialized in
the init function, so that it is easier for the muxer to locate the
right codecparameters when writing the header?)

- 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] vp9dec: support exporting QP tables through the AVVideoEncParams API

2020-05-11 Thread Anton Khirnov
---
Now the nb_block_structure reset is moved to decode_frame_header(),
which fixes block-structure export with frame threading. No idea how I
didn't notice this before
---
 libavcodec/vp9.c | 72 
 libavcodec/vp9block.c|  8 
 libavcodec/vp9dec.h  |  7 
 libavutil/video_enc_params.h | 15 
 4 files changed, 102 insertions(+)

diff --git a/libavcodec/vp9.c b/libavcodec/vp9.c
index 6c72168deb..fd0bab14a2 100644
--- a/libavcodec/vp9.c
+++ b/libavcodec/vp9.c
@@ -34,6 +34,7 @@
 #include "vp9dec.h"
 #include "libavutil/avassert.h"
 #include "libavutil/pixdesc.h"
+#include "libavutil/video_enc_params.h"
 
 #define VP9_SYNCCODE 0x498342
 
@@ -97,6 +98,7 @@ static void vp9_tile_data_free(VP9TileData *td)
 {
 av_freep(>b_base);
 av_freep(>block_base);
+av_freep(>block_structure);
 }
 
 static void vp9_frame_unref(AVCodecContext *avctx, VP9Frame *f)
@@ -326,6 +328,12 @@ static int update_block_buffers(AVCodecContext *avctx)
 td->eob_base = (uint8_t *) (td->uvblock_base[1] + sbs * chroma_blocks 
* bytesperpixel);
 td->uveob_base[0] = td->eob_base + 16 * 16 * sbs;
 td->uveob_base[1] = td->uveob_base[0] + chroma_eobs * sbs;
+
+if (avctx->export_side_data & AV_CODEC_EXPORT_DATA_VIDEO_ENC_PARAMS) {
+td->block_structure = av_malloc_array(s->cols * s->rows, 
sizeof(*td->block_structure));
+if (!td->block_structure)
+return AVERROR(ENOMEM);
+}
 } else {
 for (i = 1; i < s->active_tile_cols; i++)
 vp9_tile_data_free(>td[i]);
@@ -341,6 +349,12 @@ static int update_block_buffers(AVCodecContext *avctx)
 s->td[i].eob_base = (uint8_t *) (s->td[i].uvblock_base[1] + 
chroma_blocks * bytesperpixel);
 s->td[i].uveob_base[0] = s->td[i].eob_base + 16 * 16;
 s->td[i].uveob_base[1] = s->td[i].uveob_base[0] + chroma_eobs;
+
+if (avctx->export_side_data & 
AV_CODEC_EXPORT_DATA_VIDEO_ENC_PARAMS) {
+s->td[i].block_structure = av_malloc_array(s->cols * s->rows, 
sizeof(*td->block_structure));
+if (!s->td[i].block_structure)
+return AVERROR(ENOMEM);
+}
 }
 }
 s->block_alloc_using_2pass = s->s.frames[CUR_FRAME].uses_2pass;
@@ -880,6 +894,7 @@ static int decode_frame_header(AVCodecContext *avctx,
 } else {
 memset(>td[i].counts, 0, sizeof(s->td[0].counts));
 }
+s->td[i].nb_block_structure = 0;
 }
 
 /* FIXME is it faster to not copy here, but do it down in the fw updates
@@ -1481,6 +1496,58 @@ int loopfilter_proc(AVCodecContext *avctx)
 }
 #endif
 
+static int vp9_export_enc_params(VP9Context *s, VP9Frame *frame)
+{
+AVVideoEncParams *par;
+unsigned int tile, nb_blocks = 0;
+
+if (s->s.h.segmentation.enabled) {
+for (tile = 0; tile < s->active_tile_cols; tile++)
+nb_blocks += s->td[tile].nb_block_structure;
+}
+
+par = av_video_enc_params_create_side_data(frame->tf.f,
+AV_VIDEO_ENC_PARAMS_VP9, nb_blocks);
+if (!par)
+return AVERROR(ENOMEM);
+
+par->qp = s->s.h.yac_qi;
+par->delta_qp[0][0] = s->s.h.ydc_qdelta;
+par->delta_qp[1][0] = s->s.h.uvdc_qdelta;
+par->delta_qp[2][0] = s->s.h.uvdc_qdelta;
+par->delta_qp[1][1] = s->s.h.uvac_qdelta;
+par->delta_qp[2][1] = s->s.h.uvac_qdelta;
+
+if (nb_blocks) {
+unsigned int block = 0;
+unsigned int tile, block_tile;
+
+for (tile = 0; tile < s->active_tile_cols; tile++) {
+VP9TileData *td = >td[tile];
+
+for (block_tile = 0; block_tile < td->nb_block_structure; 
block_tile++) {
+AVVideoBlockParams *b = av_video_enc_params_block(par, 
block++);
+unsigned int  row = td->block_structure[block_tile].row;
+unsigned int  col = td->block_structure[block_tile].col;
+uint8_tseg_id = frame->segmentation_map[row * 8 * 
s->sb_cols + col];
+
+b->src_x = col * 8;
+b->src_y = row * 8;
+b->w = 1 << (3 + 
td->block_structure[block_tile].block_size_idx_x);
+b->h = 1 << (3 + 
td->block_structure[block_tile].block_size_idx_y);
+
+if (s->s.h.segmentation.feat[seg_id].q_enabled) {
+b->delta_qp = s->s.h.segmentation.feat[seg_id].q_val;
+if (s->s.h.segmentation.absolute_vals)
+b->delta_qp -= par->qp;
+}
+}
+}
+}
+
+return 0;
+}
+
 static int vp9_decode_frame(AVCodecContext *avctx, void *frame,
 int *got_frame, AVPacket *pkt)
 {
@@ -1689,6 +1756,11 @@ FF_ENABLE_DEPRECATION_WARNINGS
 s->td->error_info = 0;
 return AVERROR_INVALIDDATA;
 }
+if (avctx->export_side_data & AV_CODEC_EXPORT_DATA_VIDEO_ENC_PARAMS) {

Re: [FFmpeg-devel] [PATCH 1/9] libavutil: add API for exporting video frame quantizers

2020-05-11 Thread Anton Khirnov
Quoting Thierry Foucu (2020-05-07 21:14:15)
> On Sat, Apr 18, 2020 at 5:02 AM Lynne  wrote:
> 
> > Apr 18, 2020, 11:14 by an...@khirnov.net:
> >
> > > From: Juan De León 
> > >
> > > This is intended to replace the deprecated the AV_FRAME_DATA_QP_TABLE*
> > > API and extend it to a wider range of codecs.
> > >
> > > In the future, it may also be extended to support other encoding
> > > parameters such as motion vectors.
> > >
> > > Additional changes by Anton Khirnov  with suggestions
> > > by Lynne .
> > >
> > > Signed-off-by: Juan De León 
> > > Signed-off-by: Michael Niedermayer 
> > > Signed-off-by: Anton Khirnov 
> > >
> >
> > API looks good, patchset LGTM.
> >
> 
> Any chance to have this patch set applied?

Sure, guess I don't need to wait for the legacy filters to be resolved
and can push everything else.

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

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

Re: [FFmpeg-devel] [PATCH 1/2] avcodec/mpegvideo: prefer to use variable instead of type for sizeof

2020-05-11 Thread Marton Balint



On Mon, 11 May 2020, lance.lmw...@gmail.com wrote:


On Mon, May 11, 2020 at 01:22:24AM +0200, Marton Balint wrote:



On Mon, 11 May 2020, lance.lmw...@gmail.com wrote:

> On Sun, May 10, 2020 at 06:30:41PM +0200, Marton Balint wrote:
> > 
> > 
> > On Sun, 10 May 2020, lance.lmw...@gmail.com wrote:
> > 
> > > From: Limin Wang 

> > > > Signed-off-by: Limin Wang 
> > > ---
> > > libavcodec/mpegvideo.c | 48 

> > > 1 file changed, 24 insertions(+), 24 deletions(-)
> > 
> > If you find these cosmetics interesting, then I suggest you introduce a new

> > macro instead: FF_ALLOCZ_ARRAY_OR_GOTO().
> > 
> > E.g.:
> > 
> > FF_ALLOCZ_ARRAY_OR_GOTO(s->avctx, s->me.map, ME_MAP_SIZE, fail)
> 
> Yeah, I have considered it so I change the type to use use variable first and

> submit one typical for review. If the change is OK, then I'll go ahead next.

No need to do it in two steps, better touch the code once. E.g. patch 2
might not even be needed if you do this in a single patch.


Sorry, now for array alloc, you had to input the one elemeay size and its count
always. internal.h have defined it already:
FF_ALLOCZ_ARRAY_OR_GOTO(ctx, p, nelem, elsize, label)

You don't want to input elsize? isn't general usage?


I just found out that there is already an FF_ALLOCZ_ARRAY_OR_GOTO with 
elsize. So you should add a new macro which uses FF_ALLOCZ_ARRAY_OR_GOTO 
and calculates elszize automatically. I am not sure about the name:

FF_ALLOCZ_TYPED_ARRAY_OR_GOTO ?

Regards,
Marton





Regards,
Marton

> 
> > 
> > Regards,

> > Marton
> > 
> > > > diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c

> > > index 49fd1c9..561062f 100644
> > > --- a/libavcodec/mpegvideo.c
> > > +++ b/libavcodec/mpegvideo.c
> > > @@ -373,15 +373,15 @@ static int init_duplicate_context(MpegEncContext *s)
> > > > if (s->encoding) {
> > > FF_ALLOCZ_OR_GOTO(s->avctx, s->me.map,
> > > -  ME_MAP_SIZE * sizeof(uint32_t), fail)
> > > +  ME_MAP_SIZE * sizeof(*s->me.map), fail)
> > > FF_ALLOCZ_OR_GOTO(s->avctx, s->me.score_map,
> > > -  ME_MAP_SIZE * sizeof(uint32_t), fail)
> > > +  ME_MAP_SIZE * sizeof(*s->me.score_map), fail)
> > > if (s->noise_reduction) {
> > > FF_ALLOCZ_OR_GOTO(s->avctx, s->dct_error_sum,
> > > -  2 * 64 * sizeof(int), fail)
> > > +  2 * 64 * sizeof(*s->dct_error_sum), fail)
> > > }
> > > }
> > > -FF_ALLOCZ_OR_GOTO(s->avctx, s->blocks, 64 * 12 * 2 * 
sizeof(int16_t), fail)
> > > +FF_ALLOCZ_OR_GOTO(s->avctx, s->blocks, 64 * 12 * 2 * 
sizeof(*s->blocks), fail)
> > > s->block = s->blocks[0];
> > > > for (i = 0; i < 12; i++) {
> > > @@ -400,7 +400,7 @@ static int init_duplicate_context(MpegEncContext *s)
> > > if (s->out_format == FMT_H263) {
> > > /* ac values */
> > > FF_ALLOCZ_OR_GOTO(s->avctx, s->ac_val_base,
> > > -  yc_size * sizeof(int16_t) * 16, fail);
> > > +  yc_size * sizeof(*s->ac_val_base) * 16, fail);
> > > s->ac_val[0] = s->ac_val_base + s->b8_stride + 1;
> > > s->ac_val[1] = s->ac_val_base + y_size + s->mb_stride + 1;
> > > s->ac_val[2] = s->ac_val[1] + c_size;
> > > @@ -715,7 +715,7 @@ static int init_context_frame(MpegEncContext *s)
> > > if (s->mb_height & 1)
> > > yc_size += 2*s->b8_stride + 2*s->mb_stride;
> > > > -FF_ALLOCZ_OR_GOTO(s->avctx, s->mb_index2xy, (s->mb_num + 1)
> > * sizeof(int),
> > > +FF_ALLOCZ_OR_GOTO(s->avctx, s->mb_index2xy, (s->mb_num + 1) * 
sizeof(*s->mb_index2xy),
> > >   fail); // error resilience code looks cleaner with 
this
> > > for (y = 0; y < s->mb_height; y++)
> > > for (x = 0; x < s->mb_width; x++)
> > > @@ -725,12 +725,12 @@ static int init_context_frame(MpegEncContext *s)
> > > > if (s->encoding) {
> > > /* Allocate MV tables */
> > > -FF_ALLOCZ_OR_GOTO(s->avctx, s->p_mv_table_base, 
mv_table_size * 2 * sizeof(int16_t), fail)
> > > -FF_ALLOCZ_OR_GOTO(s->avctx, s->b_forw_mv_table_base,
mv_table_size * 2 * sizeof(int16_t), fail)
> > > -FF_ALLOCZ_OR_GOTO(s->avctx, s->b_back_mv_table_base,
mv_table_size * 2 * sizeof(int16_t), fail)
> > > -FF_ALLOCZ_OR_GOTO(s->avctx, s->b_bidir_forw_mv_table_base,  
mv_table_size * 2 * sizeof(int16_t), fail)
> > > -FF_ALLOCZ_OR_GOTO(s->avctx, s->b_bidir_back_mv_table_base,  
mv_table_size * 2 * sizeof(int16_t), fail)
> > > -FF_ALLOCZ_OR_GOTO(s->avctx, s->b_direct_mv_table_base,  
mv_table_size * 2 * sizeof(int16_t), fail)
> > > +FF_ALLOCZ_OR_GOTO(s->avctx, s->p_mv_table_base, 
mv_table_size * 2 * sizeof(*s->p_mv_table_base), fail)
> > > +FF_ALLOCZ_OR_GOTO(s->avctx, s->b_forw_mv_table_base,