[FFmpeg-devel] [PATCH v2 5/6] avcodec/mpeg4videodec: Remove always-true checks

Andreas Rheinhardt andreas.rheinhardt at outlook.com
Wed Oct 19 02:13:12 EEST 2022


codec_id is always AV_CODEC_ID_MPEG4 for mpeg4_decode_mb(),
as the MPEG-4 decoder is the only decoder for which
ff_mpeg4_decode_picture_header() as well as decode_init()
are ever called and these are the only places where
the decode_mb function pointer is ever set to mpeg4_decode_mb().
ff_mpeg4_workaround_bugs() is also only called for the MPEG-4
decoder (the caller checks the codec id).

(ff_mpeg4_decode_picture_header() is also called for the MPEG-4
parser, but it never uses the decode_mb function pointer.)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
---
I hope this commit message is detailed enough now.

 libavcodec/mpeg4videodec.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c
index aeb0d003ec..b4e2c09706 100644
--- a/libavcodec/mpeg4videodec.c
+++ b/libavcodec/mpeg4videodec.c
@@ -1648,6 +1648,7 @@ static int mpeg4_decode_mb(MpegEncContext *s, int16_t block[6][64])
     int16_t *mot_val;
     static const int8_t quant_tab[4] = { -1, -2, 1, 2 };
     const int xy = s->mb_x + s->mb_y * s->mb_stride;
+    int next;
 
     av_assert2(s ==  (void*)ctx);
     av_assert2(s->h263_pred);
@@ -1999,8 +2000,7 @@ intra:
 
 end:
     /* per-MB end of slice check */
-    if (s->codec_id == AV_CODEC_ID_MPEG4) {
-        int next = mpeg4_is_resync(ctx);
+    next = mpeg4_is_resync(ctx);
         if (next) {
             if        (s->mb_x + s->mb_y*s->mb_width + 1 >  next && (s->avctx->err_recognition & AV_EF_AGGRESSIVE)) {
                 return AVERROR_INVALIDDATA;
@@ -2019,7 +2019,6 @@ end:
 
             return SLICE_END;
         }
-    }
 
     return SLICE_OK;
 }
@@ -3084,7 +3083,6 @@ int ff_mpeg4_workaround_bugs(AVCodecContext *avctx)
                ctx->divx_version, ctx->divx_build, s->divx_packed ? "p" : "");
 
     if (CONFIG_MPEG4_DECODER && ctx->xvid_build >= 0 &&
-        s->codec_id == AV_CODEC_ID_MPEG4 &&
         avctx->idct_algo == FF_IDCT_AUTO) {
         avctx->idct_algo = FF_IDCT_XVID;
         ff_mpv_idct_init(s);
-- 
2.34.1



More information about the ffmpeg-devel mailing list