summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2022-08-22 21:29:55 +0200
committerMichael Niedermayer <michael@niedermayer.cc>2022-09-01 00:41:28 +0200
commit9e92d14dbf6ae9bbfe48dc8769fa8b30fd63bc59 (patch)
tree886d2cebf4743d643df24e8e5d9437ee6d38f6b0
parentb24407a9bac37ef4d672f368211d3b855d5e4d46 (diff)
downloadffmpeg-9e92d14dbf6ae9bbfe48dc8769fa8b30fd63bc59.tar.gz
avcodec/midivid: Perform lzss_uncompress() before ff_reget_buffer()
This would avoid regeting the frame on lzss errors Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> (cherry picked from commit 628fb97efb0b6202e56fab89670406261bf86d85) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r--libavcodec/midivid.c13
1 files 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;