X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Fvp6.c;h=d10a64001aed0f2955215937dc6d8c47333e7193;hb=b99ca863506f0630514921b740b78364de67a3ff;hp=b8a92287a9b42c5e6228fe58dc53d0f50a56a8ca;hpb=b2bed9325dbd6be0da1d91ffed3f513c40274fd2;p=ffmpeg diff --git a/libavcodec/vp6.c b/libavcodec/vp6.c index b8a92287a9b..d10a64001ae 100644 --- a/libavcodec/vp6.c +++ b/libavcodec/vp6.c @@ -32,6 +32,7 @@ #include "avcodec.h" #include "get_bits.h" #include "huffman.h" +#include "internal.h" #include "vp56.h" #include "vp56data.h" @@ -84,10 +85,23 @@ static int vp6_parse_header(VP56Context *s, const uint8_t *buf, int buf_size, if (!s->macroblocks || /* first frame */ 16*cols != s->avctx->coded_width || 16*rows != s->avctx->coded_height) { - avcodec_set_dimensions(s->avctx, 16*cols, 16*rows); - if (s->avctx->extradata_size == 1) { - s->avctx->width -= s->avctx->extradata[0] >> 4; - s->avctx->height -= s->avctx->extradata[0] & 0x0F; + if (s->avctx->extradata_size == 0 && + FFALIGN(s->avctx->width, 16) == 16 * cols && + FFALIGN(s->avctx->height, 16) == 16 * rows) { + // We assume this is properly signalled container cropping, + // in an F4V file. Just set the coded_width/height, don't + // touch the cropped ones. + s->avctx->coded_width = 16 * cols; + s->avctx->coded_height = 16 * rows; + } else { + int ret = ff_set_dimensions(s->avctx, 16 * cols, 16 * rows); + if (ret < 0) + return ret; + + if (s->avctx->extradata_size == 1) { + s->avctx->width -= s->avctx->extradata[0] >> 4; + s->avctx->height -= s->avctx->extradata[0] & 0x0F; + } } res = VP56_SIZE_CHANGE; } @@ -144,7 +158,7 @@ static int vp6_parse_header(VP56Context *s, const uint8_t *buf, int buf_size, buf_size -= coeff_offset; if (buf_size < 0) { if (s->frames[VP56_FRAME_CURRENT]->key_frame) - avcodec_set_dimensions(s->avctx, 0, 0); + ff_set_dimensions(s->avctx, 0, 0); return AVERROR_INVALIDDATA; } if (s->use_huffman) {