changeset 32439:2f1ccd169a7f

Improve vd_ffmpeg aspect handling to respect container aspect if possible (i.e. until the first resolution or aspect change) and to use correct aspect if only resolution changes but not the pixel aspect.
author reimar
date Fri, 22 Oct 2010 17:36:11 +0000
parents faefba58f413
children e7e0da7ab4d4
files libmpcodecs/vd_ffmpeg.c
diffstat 1 files changed, 7 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/libmpcodecs/vd_ffmpeg.c	Thu Oct 21 18:19:30 2010 +0000
+++ b/libmpcodecs/vd_ffmpeg.c	Fri Oct 22 17:36:11 2010 +0000
@@ -559,9 +559,13 @@
         // sets the value correctly in avcodec_open.
         set_format_params(avctx, avctx->pix_fmt);
         mp_msg(MSGT_DECVIDEO, MSGL_V, "[ffmpeg] aspect_ratio: %f\n", aspect);
-        if (sh->aspect == 0 ||
-            av_cmp_q(avctx->sample_aspect_ratio,
-                     ctx->last_sample_aspect_ratio))
+
+        // Do not overwrite s->aspect on the first call, so that a container
+        // aspect if available is preferred.
+        // But set it even if the sample aspect did not change, since a
+        // resolution change can cause an aspect change even if the
+        // _sample_ aspect is unchanged.
+        if (sh->aspect == 0 || ctx->last_sample_aspect_ratio.den)
             sh->aspect = aspect;
         ctx->last_sample_aspect_ratio = avctx->sample_aspect_ratio;
         sh->disp_w = width;