# HG changeset patch # User reimar # Date 1387744612 0 # Node ID b72daec4e223dab1baaeb153e6b3549c1d000a1e # Parent ed153683310d0d16906e3b7f26cf04294d3281e3 Only update aspect when there was an actual change. Fixes playback of e.g. mkv files where SPS/stream and mkv header aspect information mismatch (or actually even if the SPS/stream aspect value is simply missing). diff -r ed153683310d -r b72daec4e223 libmpcodecs/vd_ffmpeg.c --- a/libmpcodecs/vd_ffmpeg.c Tue Dec 17 22:57:00 2013 +0000 +++ b/libmpcodecs/vd_ffmpeg.c Sun Dec 22 20:36:52 2013 +0000 @@ -570,13 +570,14 @@ static void update_configuration(sh_video_t *sh, enum AVPixelFormat pix_fmt) { vd_ffmpeg_ctx *ctx = sh->context; AVCodecContext *avctx = ctx->avctx; + int aspect_change = av_cmp_q(avctx->sample_aspect_ratio, ctx->last_sample_aspect_ratio); if (!avctx->sample_aspect_ratio.den) { mp_msg(MSGT_DECVIDEO, MSGL_WARN, "FFmpeg bug: Invalid aspect\n"); avctx->sample_aspect_ratio.den = 1; } // it is possible another vo buffers to be used after vo config() // lavc reset its buffers on width/heigh change but not on aspect change!!! - if (av_cmp_q(avctx->sample_aspect_ratio, ctx->last_sample_aspect_ratio) || + if (aspect_change || pix_fmt != ctx->pix_fmt || !ctx->vo_initialized) { @@ -592,7 +593,7 @@ // 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->original_aspect == 0 || ctx->last_sample_aspect_ratio.den) + if (sh->original_aspect == 0 || (aspect_change && ctx->last_sample_aspect_ratio.den)) sh->original_aspect = aspect; ctx->last_sample_aspect_ratio = avctx->sample_aspect_ratio; ctx->pix_fmt = pix_fmt;