diff mbox series

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

Message ID AS8P250MB0744B1A027BB52D2CACA93648F229@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM
State Accepted
Headers show
Series [FFmpeg-devel,1/6] avcodec/mpegvideo_motion: Move mspel/gmc motion to mpeg4videodec.c | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Andreas Rheinhardt Oct. 12, 2022, 6:06 p.m. UTC
codec_id is always AV_CODEC_ID_MPEG4 in this file.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/mpeg4videodec.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

Comments

Michael Niedermayer Oct. 13, 2022, 9:05 p.m. UTC | #1
Hi

On Wed, Oct 12, 2022 at 08:06:22PM +0200, Andreas Rheinhardt wrote:
> codec_id is always AV_CODEC_ID_MPEG4 in this file.
> 
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> ---
>  libavcodec/mpeg4videodec.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
[...]
> @@ -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 &&

should the CONFIG_MPEG4_DECODER check be removed too ?

thx

[...]
Andreas Rheinhardt Oct. 13, 2022, 9:23 p.m. UTC | #2
Michael Niedermayer:
> Hi
> 
> On Wed, Oct 12, 2022 at 08:06:22PM +0200, Andreas Rheinhardt wrote:
>> codec_id is always AV_CODEC_ID_MPEG4 in this file.
>>
>> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
>> ---
>>  libavcodec/mpeg4videodec.c | 6 ++----
>>  1 file changed, 2 insertions(+), 4 deletions(-)
> [...]
>> @@ -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 &&
> 
> should the CONFIG_MPEG4_DECODER check be removed too ?
> 

This file is also compiled if the MPEG-4 parser or the H.263 decoder is
enabled (hence if any of the H.263 decoder family is enabled); the
former is probably done because of ff_mpeg4_pred_ac() which is used by
msmpeg4dec.c (this is the only exception to what I wrote in the commit
message; will amend it). The latter could be solved by moving the code
common to mpeg4-decoder and parser out into a file of its own, say
mpeg4_parse.c. I pondered doing that; would you have any objections to
it? It would allow to cut down on the crazy list of requirements of the
mpeg4 parser.
Anyway, given that both the MPEG-4 parser as well as the H.263 decoder
already require mpegvideodec, one could remove this CONFIG_MPEG4_DECODER
without causing linking failures, but doing so would cause a tiny bit
more code to be included in case the MPEG-4 decoder is disabled (in
fact, ff_mpeg4_workaround_bugs() is completely unnecessary in this
case). So removing it has a tiny disadvantage now and I intend to deal
with this whole issue later anyway, so I don't intend to do it now
(unless you insist).

- Andreas
Michael Niedermayer Oct. 13, 2022, 10:22 p.m. UTC | #3
On Thu, Oct 13, 2022 at 11:23:33PM +0200, Andreas Rheinhardt wrote:
> Michael Niedermayer:
> > Hi
> > 
> > On Wed, Oct 12, 2022 at 08:06:22PM +0200, Andreas Rheinhardt wrote:
> >> codec_id is always AV_CODEC_ID_MPEG4 in this file.
> >>
> >> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> >> ---
> >>  libavcodec/mpeg4videodec.c | 6 ++----
> >>  1 file changed, 2 insertions(+), 4 deletions(-)
> > [...]
> >> @@ -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 &&
> > 
> > should the CONFIG_MPEG4_DECODER check be removed too ?
> > 
> 
> This file is also compiled if the MPEG-4 parser or the H.263 decoder is
> enabled (hence if any of the H.263 decoder family is enabled); the
> former is probably done because of ff_mpeg4_pred_ac() which is used by
> msmpeg4dec.c (this is the only exception to what I wrote in the commit
> message; will amend it). The latter could be solved by moving the code
> common to mpeg4-decoder and parser out into a file of its own, say
> mpeg4_parse.c. I pondered doing that; would you have any objections to
> it? It would allow to cut down on the crazy list of requirements of the
> mpeg4 parser.

really, you are doing this factorization, you decide which way it makes
most sense.
Id just say something if i see something that "feels" wrong
here it was just me seeing te compile time check and you saying its always
AV_CODEC_ID_MPEG4.
Maybe you could word the commit messsage more verbosely 

thx

[...]
diff mbox series

Patch

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