Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FFmpeg/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2022-06-11 00:09:09 +0300
committerMichael Niedermayer <michael@niedermayer.cc>2022-09-24 23:38:37 +0300
commitd10b5d96dd2f5002cc4264cc57f60a3aae040a14 (patch)
treea150ec78dee781504155bbb7700913606e3cbe43
parentad107f99b606bf2fb41a201565ca5300e31ae1e9 (diff)
avcodec/fmvc: Move frame allocation to a later stage
This way more things are checked before allocation Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> (cherry picked from commit 9783749c66bf6ca2ce7a6db4c74957fe77cbe803) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r--libavcodec/fmvc.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/libavcodec/fmvc.c b/libavcodec/fmvc.c
index 9bbe8c6ccf..112b2d4714 100644
--- a/libavcodec/fmvc.c
+++ b/libavcodec/fmvc.c
@@ -402,20 +402,17 @@ static int decode_frame(AVCodecContext *avctx,
PutByteContext *pb = &s->pb;
AVFrame *frame = data;
int ret, y, x;
+ int key_frame;
if (avpkt->size < 8)
return AVERROR_INVALIDDATA;
- if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
- return ret;
-
bytestream2_init(gb, avpkt->data, avpkt->size);
bytestream2_skip(gb, 2);
- frame->key_frame = !!bytestream2_get_le16(gb);
- frame->pict_type = frame->key_frame ? AV_PICTURE_TYPE_I : AV_PICTURE_TYPE_P;
+ key_frame = !!bytestream2_get_le16(gb);
- if (frame->key_frame) {
+ if (key_frame) {
const uint8_t *src;
int type, size;
uint8_t *dst;
@@ -435,6 +432,12 @@ static int decode_frame(AVCodecContext *avctx,
return AVERROR_PATCHWELCOME;
}
+ if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
+ return ret;
+
+ frame->key_frame = 1;
+ frame->pict_type = AV_PICTURE_TYPE_I;
+
src = s->buffer;
dst = frame->data[0] + (avctx->height - 1) * frame->linesize[0];
for (y = 0; y < avctx->height; y++) {
@@ -512,6 +515,12 @@ static int decode_frame(AVCodecContext *avctx,
dst = &rect[block_h * s->stride];
}
+ if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
+ return ret;
+
+ frame->key_frame = 0;
+ frame->pict_type = AV_PICTURE_TYPE_P;
+
ssrc = s->buffer;
ddst = frame->data[0] + (avctx->height - 1) * frame->linesize[0];
for (y = 0; y < avctx->height; y++) {