diff mbox series

[FFmpeg-devel,3/5] avcodec/mjpegdec: Avoid checks whose results are known at compile-time

Message ID GV1P250MB07371CEA092A26AE3246EE358F1A9@GV1P250MB0737.EURP250.PROD.OUTLOOK.COM
State Accepted
Commit ec2d582cb02dc3b838b2ff9efe48a5fa2ee288dd
Headers show
Series [FFmpeg-devel,1/5] avcodec/mjpegdec: Restrict AVID MJPEG to non-SMVJPEG | 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 Dec. 7, 2022, 7:02 p.m. UTC
Namely the result of the check for smv_next_frame > 0 in
smv_process_frame().

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/mjpegdec.c | 39 ++++++++++++++++++---------------------
 1 file changed, 18 insertions(+), 21 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
index b88d2ab889..2abc42a082 100644
--- a/libavcodec/mjpegdec.c
+++ b/libavcodec/mjpegdec.c
@@ -2349,24 +2349,9 @@  static void reset_icc_profile(MJpegDecodeContext *s)
 
 // SMV JPEG just stacks several output frames into one JPEG picture
 // we handle that by setting up the cropping parameters appropriately
-static int smv_process_frame(AVCodecContext *avctx, AVFrame *frame)
+static void smv_process_frame(AVCodecContext *avctx, AVFrame *frame)
 {
     MJpegDecodeContext *s = avctx->priv_data;
-    int ret;
-
-    if (s->smv_next_frame > 0) {
-        av_assert0(s->smv_frame->buf[0]);
-        av_frame_unref(frame);
-        ret = av_frame_ref(frame, s->smv_frame);
-        if (ret < 0)
-            return ret;
-    } else {
-        av_assert0(frame->buf[0]);
-        av_frame_unref(s->smv_frame);
-        ret = av_frame_ref(s->smv_frame, frame);
-        if (ret < 0)
-            return ret;
-    }
 
     av_assert0((s->smv_next_frame + 1) * avctx->height <= avctx->coded_height);
 
@@ -2379,8 +2364,6 @@  static int smv_process_frame(AVCodecContext *avctx, AVFrame *frame)
 
     if (s->smv_next_frame == 0)
         av_frame_unref(s->smv_frame);
-
-    return 0;
 }
 
 static int mjpeg_get_packet(AVCodecContext *avctx)
@@ -3055,14 +3038,28 @@  static int smvjpeg_receive_frame(AVCodecContext *avctx, AVFrame *frame)
     MJpegDecodeContext *s = avctx->priv_data;
     int ret;
 
-    if (s->smv_next_frame > 0)
-        return smv_process_frame(avctx, frame);
+    if (s->smv_next_frame > 0) {
+        av_assert0(s->smv_frame->buf[0]);
+        ret = av_frame_ref(frame, s->smv_frame);
+        if (ret < 0)
+            return ret;
+
+        smv_process_frame(avctx, frame);
+        return 0;
+    }
 
     ret = ff_mjpeg_receive_frame(avctx, frame);
     if (ret < 0)
         return ret;
 
-    return smv_process_frame(avctx, frame);
+    av_assert0(frame->buf[0]);
+    av_frame_unref(s->smv_frame);
+    ret = av_frame_ref(s->smv_frame, frame);
+    if (ret < 0)
+        return ret;
+
+    smv_process_frame(avctx, frame);
+    return 0;
 }
 
 const FFCodec ff_smvjpeg_decoder = {