h264: allow cropping to AVCodecContext.width/height
authorMans Rullgard <mans@mansr.com>
Wed, 30 May 2012 03:04:54 +0000 (04:04 +0100)
committerReinhard Tartler <siretart@tauware.de>
Sun, 10 Jun 2012 07:47:45 +0000 (09:47 +0200)
Override the frame size from the SPS with AVCodecContext values
if the latter specify a size smaller by less than one macroblock.
This is required for correct cropping of MOV files from Canon cameras.

Signed-off-by: Mans Rullgard <mans@mansr.com>
(cherry picked from commit 30f515091c323da59c0f1b533703dedca2f4b95d)

Conflicts:

libavcodec/h264.c

libavcodec/h264.c

index b229510..79298d7 100644 (file)
@@ -2720,6 +2720,12 @@ static int decode_slice_header(H264Context *h, H264Context *h0){
     else
         s->height= 16*s->mb_height - (2<<s->chroma_y_shift)*FFMIN(h->sps.crop_bottom, (16>>s->chroma_y_shift)-1);
 
+    if (FFALIGN(s->avctx->width,  16) == s->width &&
+        FFALIGN(s->avctx->height, 16) == s->height) {
+        s->width  = s->avctx->width;
+        s->height = s->avctx->height;
+    }
+
     if (s->context_initialized
         && (   s->width != s->avctx->width || s->height != s->avctx->height
             || av_cmp_q(h->sps.sar, s->avctx->sample_aspect_ratio))) {