[FFmpeg-devel,V3] lavc: Don't overwrite previously setup dimensions for all codecs

Submitted by Zhong Li on Jan. 27, 2018, 3:51 a.m.

Details

Message ID 1517025114-20080-1-git-send-email-zhong.li@intel.com
State New
Headers show

Commit Message

Zhong Li Jan. 27, 2018, 3:51 a.m.
Currently a hacky way is used for some specific codecs such as
H264/VP6F/DXV.
Replace with a more generic way(an evolution based on a libav commit
9de9b828 but hasn't been merged since it breaks lowres).
Verified it won't introduce regression of original ticket #1386 fixing.

V2: add "lowres" handle code
V3: fix the typo

Signed-off-by: Zhong Li <zhong.li@intel.com>
---
 libavcodec/utils.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

Patch hide | download patch | download mbox

diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 4c71843..8fe20d9 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -684,16 +684,12 @@  int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *code
         goto free_and_end;
     }
 
-    // only call ff_set_dimensions() for non H.264/VP6F/DXV codecs so as not to overwrite previously setup dimensions
-    if (!(avctx->coded_width && avctx->coded_height && avctx->width && avctx->height &&
-          (avctx->codec_id == AV_CODEC_ID_H264 || avctx->codec_id == AV_CODEC_ID_VP6F || avctx->codec_id == AV_CODEC_ID_DXV))) {
-    if (avctx->coded_width && avctx->coded_height)
+    if (avctx->coded_width && avctx->coded_height && (!avctx->width && !avctx->height || avctx->lowres))
         ret = ff_set_dimensions(avctx, avctx->coded_width, avctx->coded_height);
-    else if (avctx->width && avctx->height)
+    else if (avctx->width && avctx->height && (!avctx->coded_width && !avctx->coded_height || avctx->lowres))
         ret = ff_set_dimensions(avctx, avctx->width, avctx->height);
     if (ret < 0)
         goto free_and_end;
-    }
 
     if ((avctx->coded_width || avctx->coded_height || avctx->width || avctx->height)
         && (  av_image_check_size2(avctx->coded_width, avctx->coded_height, avctx->max_pixels, AV_PIX_FMT_NONE, 0, avctx) < 0