summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorreimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2>2010-10-22 17:36:11 +0000
committerUoti Urpala <uau@glyph.nonexistent.invalid>2010-11-02 07:48:40 +0200
commit64ab2402e2e08cdd4f710b2278b1d67cfc74cbe6 (patch)
tree089d7616e6987bf7b114226e74acb39664425233
parent3cb3bbbddc1d09dab1471a3630f1a9aa4392ed50 (diff)
downloadmpv-64ab2402e2e08cdd4f710b2278b1d67cfc74cbe6.tar.bz2
mpv-64ab2402e2e08cdd4f710b2278b1d67cfc74cbe6.tar.xz
vd_ffmpeg: improve aspect ratio handling
Respect container aspect first if available, but change to ratio based on video codec level information if there's a resolution or pixel aspect change from the original codec values in the middle of the video. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@32525 b3059339-0415-0410-9bf9-f77b7e298cf2
-rw-r--r--libmpcodecs/vd_ffmpeg.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/libmpcodecs/vd_ffmpeg.c b/libmpcodecs/vd_ffmpeg.c
index 1bb7c2e94b..8105eb8f83 100644
--- a/libmpcodecs/vd_ffmpeg.c
+++ b/libmpcodecs/vd_ffmpeg.c
@@ -181,8 +181,6 @@ static int init(sh_video_t *sh){
ctx = sh->context = talloc_zero(NULL, vd_ffmpeg_ctx);
- ctx->last_sample_aspect_ratio = (AVRational){0, 1};
-
lavc_codec = avcodec_find_decoder_by_name(sh->codec->dll);
if(!lavc_codec){
mp_tmsg(MSGT_DECVIDEO, MSGL_ERR, "Cannot find codec '%s' in libavcodec...\n", sh->codec->dll);
@@ -476,9 +474,13 @@ static int init_vo(sh_video_t *sh, enum PixelFormat pix_fmt){
!ctx->vo_initialized)
{
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;