diff options
author | CrystalP <CrystalP@xbmc.org> | 2011-11-05 20:09:21 -0400 |
---|---|---|
committer | CrystalP <CrystalP@xbmc.org> | 2011-11-05 21:25:55 -0400 |
commit | 438acad3bfb173786c221b1d8a1f9c6e33a96ce0 (patch) | |
tree | 0a5abaa9217fe5321a9142eab0c4fec4eb05777f /lib/ffmpeg/libavcodec | |
parent | d72e2cb9f10bdfeead59f12dec8250037e55b9bb (diff) |
Backport ffmpeg commit 29a29226bb01d8e46b731e73f637563e5c4cccfe
Set avctx->coded_width/height to uncropped h264 sizes
avctx->widht/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 decode properly
if a surface larger than needed is used during decode, so just aligning
up is not enough.
Written and submitted upstream by elupus.
Diffstat (limited to 'lib/ffmpeg/libavcodec')
-rw-r--r-- | lib/ffmpeg/libavcodec/h264.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/lib/ffmpeg/libavcodec/h264.c b/lib/ffmpeg/libavcodec/h264.c index 31d43dff6f..47b007376e 100644 --- a/lib/ffmpeg/libavcodec/h264.c +++ b/lib/ffmpeg/libavcodec/h264.c @@ -1797,15 +1797,11 @@ static int decode_slice_header(H264Context *h, H264Context *h0){ s->mb_height= h->sps.mb_height * (2 - h->sps.frame_mbs_only_flag); h->b_stride= s->mb_width*4; - - s->width = 16*s->mb_width - 2*FFMIN(h->sps.crop_right, 7); - if(h->sps.frame_mbs_only_flag) - s->height= 16*s->mb_height - 2*FFMIN(h->sps.crop_bottom, 7); - else - s->height= 16*s->mb_height - 4*FFMIN(h->sps.crop_bottom, 7); + s->width = 16*s->mb_width; + s->height= 16*s->mb_height; if (s->context_initialized - && ( s->width != s->avctx->width || s->height != s->avctx->height + && ( s->width != s->avctx->coded_width || s->height != s->avctx->coded_height || av_cmp_q(h->sps.sar, s->avctx->sample_aspect_ratio))) { if(h != h0) return -1; // width / height changed during parallelized decoding @@ -1818,6 +1814,13 @@ static int decode_slice_header(H264Context *h, H264Context *h0){ return -1; // we cant (re-)initialize context during parallel decoding avcodec_set_dimensions(s->avctx, s->width, s->height); + + s->avctx->width -= 2*FFMIN(h->sps.crop_right, 7); + if(h->sps.frame_mbs_only_flag) + s->avctx->height-=2*FFMIN(h->sps.crop_bottom, 7); + else + s->avctx->height-=4*FFMIN(h->sps.crop_bottom, 7); + s->avctx->sample_aspect_ratio= h->sps.sar; av_assert0(s->avctx->sample_aspect_ratio.den); |