[FFmpeg-cvslog] avcodec/midivid: Perform lzss_uncompress() before ff_reget_buffer()

Michael Niedermayer git at videolan.org
Thu Sep 1 18:15:59 EEST 2022


ffmpeg | branch: release/5.0 | Michael Niedermayer <michael at niedermayer.cc> | Mon Aug 22 21:29:55 2022 +0200| [9e92d14dbf6ae9bbfe48dc8769fa8b30fd63bc59] | committer: Michael Niedermayer

avcodec/midivid: Perform lzss_uncompress() before ff_reget_buffer()

This would avoid regeting the frame on lzss errors

Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
(cherry picked from commit 628fb97efb0b6202e56fab89670406261bf86d85)
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9e92d14dbf6ae9bbfe48dc8769fa8b30fd63bc59
---

 libavcodec/midivid.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/libavcodec/midivid.c b/libavcodec/midivid.c
index 4a3ba33f11..e05fb4d4c6 100644
--- a/libavcodec/midivid.c
+++ b/libavcodec/midivid.c
@@ -202,12 +202,7 @@ static int decode_frame(AVCodecContext *avctx, void *data,
     bytestream2_skip(gb, 8);
     uncompressed = bytestream2_get_le32(gb);
 
-    if ((ret = ff_reget_buffer(avctx, s->frame, 0)) < 0)
-        return ret;
-
-    if (uncompressed) {
-        ret = decode_mvdv(s, avctx, frame);
-    } else {
+    if (!uncompressed) {
         av_fast_padded_malloc(&s->uncompressed, &s->uncompressed_size, 16LL * (avpkt->size - 12));
         if (!s->uncompressed)
             return AVERROR(ENOMEM);
@@ -216,9 +211,13 @@ static int decode_frame(AVCodecContext *avctx, void *data,
         if (ret < 0)
             return ret;
         bytestream2_init(gb, s->uncompressed, ret);
-        ret = decode_mvdv(s, avctx, frame);
     }
 
+    if ((ret = ff_reget_buffer(avctx, s->frame, 0)) < 0)
+        return ret;
+
+    ret = decode_mvdv(s, avctx, frame);
+
     if (ret < 0)
         return ret;
     key = ret;



More information about the ffmpeg-cvslog mailing list