From 2d6edb2b7ebc400d1a4fd5b95a30e4b4415b94f9 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Fri, 22 Mar 2013 08:20:27 +0100 Subject: [PATCH 1/2] lavc: extend / update the [coded_]{width,height} doxy --- libavcodec/avcodec.h | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 316d30a656..84a685986b 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -1148,16 +1148,20 @@ typedef struct AVCodecContext { /** * picture width / height. * - encoding: MUST be set by user. - * - decoding: Set by libavcodec. - * Note: For compatibility it is possible to set this instead of - * coded_width/height before decoding. + * - decoding: May be set by the user before opening the decoder if known e.g. + * from the container. Some decoders will require the dimensions + * to be set by the caller. During decoding, the decoder may + * overwrite those values as required. */ int width, height; /** - * Bitstream width / height, may be different from width/height. + * Bitstream width / height, may be different from width/height e.g. when + * the decoded frame is cropped before being output. * - encoding: unused - * - decoding: Set by user before init if known. Codec should override / dynamically change if needed. + * - decoding: May be set by the user before opening the decoder if known + * e.g. from the container. During decoding, the decoder may + * overwrite those values as required. */ int coded_width, coded_height; From 9de9b828ef005dec37052548c195a6b4f18fc701 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Fri, 22 Mar 2013 07:59:10 +0100 Subject: [PATCH 2/2] lavc: don't overwrite display dimensions with coded dimensions. --- libavcodec/utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/utils.c b/libavcodec/utils.c index 46486a2ff7..dfb2f541e7 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -905,7 +905,7 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *code if ((ret = av_opt_set_dict(avctx, &tmp)) < 0) goto free_and_end; - if (avctx->coded_width && avctx->coded_height) + if (avctx->coded_width && avctx->coded_height && !avctx->width && !avctx->height) avcodec_set_dimensions(avctx, avctx->coded_width, avctx->coded_height); else if (avctx->width && avctx->height) avcodec_set_dimensions(avctx, avctx->width, avctx->height);