diff mbox series

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

Message ID AS8P250MB07446223CCC8816F450B12AF8F309@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM
State Accepted
Commit 20ee12c677c6f58afbae643f039ba06e7d6f070a
Headers show
Series [FFmpeg-devel,1/2] avcodec/mpegvideo: Don't initialize H264Chroma ctx unnecessarily | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Andreas Rheinhardt Oct. 26, 2022, 2:01 a.m. UTC
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@outlook.com>
---
 libavcodec/mpegvideo.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Andreas Rheinhardt Oct. 28, 2022, 1:53 p.m. UTC | #1
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@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
diff mbox series

Patch

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];