[FFmpeg-cvslog] Set avctx->coded_width/height to uncropped h264 sizes

Joakim Plate git at videolan.org
Sun Nov 6 02:05:28 CET 2011


ffmpeg | branch: master | Joakim Plate <elupus at ecce.se> | Sun Nov  6 00:59:37 2011 +0100| [29a29226bb01d8e46b731e73f637563e5c4cccfe] | committer: Michael Niedermayer

Set avctx->coded_width/height to uncropped h264 sizes

avctx->width/height remain right/bottom cropped as previous behaviour.

Hardware decoders need to know the uncropped data to allocate surfaces
of correct height. Some hardware is picky and fails to decoder properly
if a surface larger than needed is used during decode, so just aligning
up is not enough.

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

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

 libavcodec/h264.c |   10 ++++------
 1 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/libavcodec/h264.c b/libavcodec/h264.c
index 1b8f390..d5b9b17 100644
--- a/libavcodec/h264.c
+++ b/libavcodec/h264.c
@@ -2700,11 +2700,8 @@ static int decode_slice_header(H264Context *h, H264Context *h0){
 
     s->chroma_y_shift = h->sps.chroma_format_idc <= 1; // 400 uses yuv420p
 
-    s->width = 16*s->mb_width - (2>>CHROMA444)*FFMIN(h->sps.crop_right, (8<<CHROMA444)-1);
-    if(h->sps.frame_mbs_only_flag)
-        s->height= 16*s->mb_height - (1<<s->chroma_y_shift)*FFMIN(h->sps.crop_bottom, (16>>s->chroma_y_shift)-1);
-    else
-        s->height= 16*s->mb_height - (2<<s->chroma_y_shift)*FFMIN(h->sps.crop_bottom, (16>>s->chroma_y_shift)-1);
+    s->width = 16*s->mb_width;
+    s->height= 16*s->mb_height;
 
     if (s->context_initialized
         && (   s->width != s->avctx->coded_width || s->height != s->avctx->coded_height
@@ -2725,8 +2722,9 @@ static int decode_slice_header(H264Context *h, H264Context *h0){
             av_log(h->s.avctx, AV_LOG_ERROR, "Cannot (re-)initialize context during parallel decoding.\n");
             return -1;
         }
-
         avcodec_set_dimensions(s->avctx, s->width, s->height);
+        s->avctx->width  -= (2>>CHROMA444)*FFMIN(h->sps.crop_right, (8<<CHROMA444)-1);
+        s->avctx->height -= (1<<s->chroma_y_shift)*FFMIN(h->sps.crop_bottom, (16>>s->chroma_y_shift)-1) * (2 - h->sps.frame_mbs_only_flag);
         s->avctx->sample_aspect_ratio= h->sps.sar;
         av_assert0(s->avctx->sample_aspect_ratio.den);
 



More information about the ffmpeg-cvslog mailing list