mirror of https://git.ffmpeg.org/ffmpeg.git
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 9783749c66
)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
parent
f7c84aa4db
commit
6c6861279d
|
@ -401,20 +401,17 @@ static int decode_frame(AVCodecContext *avctx, void *data,
|
||||||
PutByteContext *pb = &s->pb;
|
PutByteContext *pb = &s->pb;
|
||||||
AVFrame *frame = data;
|
AVFrame *frame = data;
|
||||||
int ret, y, x;
|
int ret, y, x;
|
||||||
|
int key_frame;
|
||||||
|
|
||||||
if (avpkt->size < 8)
|
if (avpkt->size < 8)
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
|
|
||||||
if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
bytestream2_init(gb, avpkt->data, avpkt->size);
|
bytestream2_init(gb, avpkt->data, avpkt->size);
|
||||||
bytestream2_skip(gb, 2);
|
bytestream2_skip(gb, 2);
|
||||||
|
|
||||||
frame->key_frame = !!bytestream2_get_le16(gb);
|
key_frame = !!bytestream2_get_le16(gb);
|
||||||
frame->pict_type = frame->key_frame ? AV_PICTURE_TYPE_I : AV_PICTURE_TYPE_P;
|
|
||||||
|
|
||||||
if (frame->key_frame) {
|
if (key_frame) {
|
||||||
const uint8_t *src;
|
const uint8_t *src;
|
||||||
unsigned type, size;
|
unsigned type, size;
|
||||||
uint8_t *dst;
|
uint8_t *dst;
|
||||||
|
@ -434,6 +431,12 @@ static int decode_frame(AVCodecContext *avctx, void *data,
|
||||||
return AVERROR_PATCHWELCOME;
|
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;
|
src = s->buffer;
|
||||||
dst = frame->data[0] + (avctx->height - 1) * frame->linesize[0];
|
dst = frame->data[0] + (avctx->height - 1) * frame->linesize[0];
|
||||||
for (y = 0; y < avctx->height; y++) {
|
for (y = 0; y < avctx->height; y++) {
|
||||||
|
@ -512,6 +515,12 @@ static int decode_frame(AVCodecContext *avctx, void *data,
|
||||||
dst = &rect[block_h * s->stride];
|
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;
|
ssrc = s->buffer;
|
||||||
ddst = frame->data[0] + (avctx->height - 1) * frame->linesize[0];
|
ddst = frame->data[0] + (avctx->height - 1) * frame->linesize[0];
|
||||||
for (y = 0; y < avctx->height; y++) {
|
for (y = 0; y < avctx->height; y++) {
|
||||||
|
|
Loading…
Reference in New Issue