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

lance.lmwang at gmail.com lance.lmwang at gmail.com
Tue May 12 03:10:35 EEST 2020


On Mon, May 11, 2020 at 01:27:36PM -0300, James Almer wrote:
> On 5/11/2020 12:52 PM, lance.lmwang at gmail.com wrote:
> > From: Limin Wang <lance.lmwang at gmail.com>
> > 
> > Signed-off-by: Limin Wang <lance.lmwang at gmail.com>
> > ---
> >  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 at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".

-- 
Thanks,
Limin Wang


More information about the ffmpeg-devel mailing list