[FFmpeg-cvslog] vp6: Support cropping to AVCodecContext.width/height

Martin Storsjö git at videolan.org
Thu Oct 10 11:43:36 CEST 2013


ffmpeg | branch: master | Martin Storsjö <martin at martin.st> | Wed Aug 14 12:39:29 2013 +0300| [41a10f3ba149a2012de499d0b4ad4955d81f28d5] | committer: Martin Storsjö

vp6: Support cropping to AVCodecContext.width/height

In these cases, there is no extradata but only the properly set
width/height values by the demuxer.

This makes sure VP6 in F4V files is cropped properly.

This is similar to what is done for H264 for letting the container
width/height override what's in the bitstream, since 30f515091.

Signed-off-by: Martin Storsjö <martin at martin.st>

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

 libavcodec/vp6.c |   18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/libavcodec/vp6.c b/libavcodec/vp6.c
index b8a9228..fddfc9d 100644
--- a/libavcodec/vp6.c
+++ b/libavcodec/vp6.c
@@ -84,10 +84,20 @@ 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 {
+                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;
+                }
             }
             res = VP56_SIZE_CHANGE;
         }



More information about the ffmpeg-cvslog mailing list