diff mbox series

[FFmpeg-devel,14/14] avcodec/mpegvideo: Only allocate cbp_table, pred_dir_table when needed

Message ID GV1SPRMB0021A102D40603817F2E90058F1B2@GV1SPRMB0021.EURP250.PROD.OUTLOOK.COM
State New
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
Namely for the MPEG-4 decoder.

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

Patch

diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
index ca6e637920..2ef69a5224 100644
--- a/libavcodec/mpegvideo.c
+++ b/libavcodec/mpegvideo.c
@@ -593,13 +593,12 @@  int ff_mpv_init_context_frame(MpegEncContext *s)
                 tmp += mv_table_size;
             }
         }
-    }
-
-    if (s->out_format == FMT_H263) {
-        /* 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->codec_id == AV_CODEC_ID_MPEG4 && !s->encoding) {
+            /* cbp, 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) {