[FFmpeg-devel] [PATCH 3/7] avcodec/mpegvideo: Don't overallocate buffer

Andreas Rheinhardt andreas.rheinhardt at outlook.com
Fri Oct 28 16:53:12 EEST 2022


Andreas Rheinhardt:
> Only encoders need two sets of int16_t [12][64]
> (one to save the current best state and one for the current
> working state); decoders need only one. This saves 1.5KiB
> per slice context for a decoder.
> 
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
> ---
>  libavcodec/mpegvideo.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
> index 697438fa6f..0cd7c86ff6 100644
> --- a/libavcodec/mpegvideo.c
> +++ b/libavcodec/mpegvideo.c
> @@ -382,7 +382,7 @@ static int init_duplicate_context(MpegEncContext *s)
>                  return AVERROR(ENOMEM);
>          }
>      }
> -    if (!FF_ALLOCZ_TYPED_ARRAY(s->blocks,  2))
> +    if (!FF_ALLOCZ_TYPED_ARRAY(s->blocks,  1 + s->encoding))
>          return AVERROR(ENOMEM);
>      s->block = s->blocks[0];
>  

Will apply the rest of this patchset tomorrow unless there are objections.

- Andreas



More information about the ffmpeg-devel mailing list