mirror of
https://github.com/mpv-player/mpv
synced 2025-01-20 21:07:29 +01:00
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
This commit is contained in:
parent
3cb3bbbddc
commit
64ab2402e2
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user