diff mbox series

[FFmpeg-devel,12/14] avcodec/mpegvideo: Only allocate coded_block when needed

Message ID GV1SPRMB0021223C3CBCBA96E0A3E5618F1B2@GV1SPRMB0021.EURP250.PROD.OUTLOOK.COM
State Superseded
Headers show
Series [FFmpeg-devel,01/14] avcodec/get_buffer: Remove redundant check | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished

Commit Message

Andreas Rheinhardt April 29, 2024, 12:35 a.m. UTC
It is only needed for msmpeg4v3, wmv1, wmv2 and VC-1.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/mpegvideo.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
index 130ccb4c97..74be22346d 100644
--- a/libavcodec/mpegvideo.c
+++ b/libavcodec/mpegvideo.c
@@ -596,11 +596,16 @@  int ff_mpv_init_context_frame(MpegEncContext *s)
     }
 
     if (s->out_format == FMT_H263) {
-        /* cbp values, cbp, ac_pred, pred_dir */
-        if (!(s->coded_block_base = av_mallocz(y_size + (s->mb_height&1)*2*s->b8_stride)) ||
-            !(s->cbp_table        = av_mallocz(mb_array_size)) ||
+        /* cbp, ac_pred, pred_dir */
+        if (!(s->cbp_table        = av_mallocz(mb_array_size)) ||
             !(s->pred_dir_table   = av_mallocz(mb_array_size)))
             return AVERROR(ENOMEM);
+    }
+
+    if (s->msmpeg4_version >= 3) {
+        s->coded_block_base = av_mallocz(y_size + (s->mb_height&1)*2*s->b8_stride);
+        if (!s->coded_block_base)
+            return AVERROR(ENOMEM);
         s->coded_block = s->coded_block_base + s->b8_stride + 1;
     }