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

James Almer jamrial at gmail.com
Mon May 11 19:27:36 EEST 2020


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.


More information about the ffmpeg-devel mailing list