[FFmpeg-cvslog] h264: use externally provided dimensions when they appear to be more correct.
Michael Niedermayer
git at videolan.org
Sun Jun 10 02:25:33 CEST 2012
ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Sun Jun 10 02:12:20 2012 +0200| [dfaf2dd956b0de1ec4c8c4bdf44fb9a689da643a] | committer: Michael Niedermayer
h264: use externally provided dimensions when they appear to be more correct.
This is based on:
commit 30f515091c323da59c0f1b533703dedca2f4b95d
Author: Mans Rullgard <mans at mansr.com>
h264: allow cropping to AVCodecContext.width/height
The above commit is not taken as is as its buggy (incorrect handling of
the interlaced case) and didnt apply cleanly.
Fixes ticket156
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=dfaf2dd956b0de1ec4c8c4bdf44fb9a689da643a
---
libavcodec/h264.c | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/libavcodec/h264.c b/libavcodec/h264.c
index e0d62e3..cb05508 100644
--- a/libavcodec/h264.c
+++ b/libavcodec/h264.c
@@ -2982,9 +2982,19 @@ static int decode_slice_header(H264Context *h, H264Context *h0)
"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);
+ if( FFALIGN(s->avctx->width , 16 ) == s->width
+ && FFALIGN(s->avctx->height, 16*(2 - h->sps.frame_mbs_only_flag)) == s->height
+ && !h->sps.crop_right && !h->sps.crop_bottom
+ && (s->avctx->width != s->width || s->avctx->height && s->height)
+ ) {
+ av_log(h->s.avctx, AV_LOG_DEBUG, "Using externally provided dimensions\n");
+ s->avctx->coded_width = s->width;
+ s->avctx->coded_height = s->height;
+ } else{
+ 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