diff options
author | wm4 <wm4@nowhere> | 2013-01-22 13:28:31 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2013-01-23 10:55:00 +0100 |
commit | f2dcdca0c2dc5f904323659b65b29a2b6f00fd88 (patch) | |
tree | 0ae1f6d9f1ef82e34795965327bb8ab076eb7b2c /video/decode | |
parent | c9396c0aabb6c1b710e1cdaa3fb123182dc91279 (diff) | |
download | mpv-f2dcdca0c2dc5f904323659b65b29a2b6f00fd88.tar.bz2 mpv-f2dcdca0c2dc5f904323659b65b29a2b6f00fd88.tar.xz |
video: move handling of -x/-y/-xy options to VO
Now the calculations of the final display size are done after the filter
chain. This makes the difference between display aspect ratio and window
size a bit more clear, especially in the -xy case.
With an empty filter chain, the behavior of the options should be the
same, except that they don't affect vo_image and vo_lavc anymore.
Diffstat (limited to 'video/decode')
-rw-r--r-- | video/decode/vd.c | 71 |
1 files changed, 20 insertions, 51 deletions
diff --git a/video/decode/vd.c b/video/decode/vd.c index 7cdd25f55a..a9c0d21821 100644 --- a/video/decode/vd.c +++ b/video/decode/vd.c @@ -55,8 +55,6 @@ const vd_functions_t * const mpcodecs_vd_drivers[] = { int mpcodecs_config_vo(sh_video_t *sh, int w, int h, unsigned int out_fmt) { struct MPOpts *opts = sh->opts; - int screen_size_x = 0; - int screen_size_y = 0; vf_instance_t *vf = sh->vfilter; int vocfg_flags = 0; @@ -130,53 +128,25 @@ int mpcodecs_config_vo(sh_video_t *sh, int w, int h, unsigned int out_fmt) else if (sh->stream_aspect != 0.0) sh->aspect = sh->stream_aspect; - if (opts->screen_size_x || opts->screen_size_y) { - screen_size_x = opts->screen_size_x; - screen_size_y = opts->screen_size_y; - if (!opts->vidmode) { - if (!screen_size_x) - screen_size_x = 1; - if (!screen_size_y) - screen_size_y = 1; - if (screen_size_x <= 8) - screen_size_x *= sh->disp_w; - if (screen_size_y <= 8) - screen_size_y *= sh->disp_h; - } - } else { - // check source format aspect, calculate prescale ::atmos - screen_size_x = sh->disp_w; - screen_size_y = sh->disp_h; - if (opts->screen_size_xy >= 0.001) { - if (opts->screen_size_xy <= 8) { - // -xy means x+y scale - screen_size_x *= opts->screen_size_xy; - screen_size_y *= opts->screen_size_xy; - } else { - // -xy means forced width while keeping correct aspect - screen_size_x = opts->screen_size_xy; - screen_size_y = opts->screen_size_xy * sh->disp_h / sh->disp_w; - } + int d_w = sh->disp_w; + int d_h = sh->disp_h; + + if (sh->aspect > 0.01) { + int new_w = d_h * sh->aspect; + int new_h = d_h; + // we don't like horizontal downscale + if (new_w < d_w) { + new_w = d_w; + new_h = d_w / sh->aspect; } - if (sh->aspect > 0.01) { - mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_VIDEO_ASPECT=%1.4f\n", - sh->aspect); - int w = screen_size_y * sh->aspect; - int h = screen_size_y; - // we don't like horizontal downscale || user forced width: - if (w < screen_size_x || opts->screen_size_xy > 8) { - w = screen_size_x; - h = screen_size_x / sh->aspect; - } - if (abs(screen_size_x - w) >= 4 || abs(screen_size_y - h) >= 4) { - screen_size_x = w; - screen_size_y = h; - mp_tmsg(MSGT_CPLAYER, MSGL_V, "Aspect ratio is %.2f:1 - " - "scaling to correct movie aspect.\n", sh->aspect); - } - } else { - mp_tmsg(MSGT_CPLAYER, MSGL_V, "Movie-Aspect is undefined - no prescaling applied.\n"); + if (abs(d_w - new_w) >= 4 || abs(d_h - new_h) >= 4) { + d_w = new_w; + d_h = new_h; + mp_tmsg(MSGT_CPLAYER, MSGL_V, "Aspect ratio is %.2f:1 - " + "scaling to correct movie aspect.\n", sh->aspect); } + + mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_VIDEO_ASPECT=%1.4f\n", sh->aspect); } vocfg_flags = (opts->fullscreen ? VOFLAG_FULLSCREEN : 0) @@ -186,11 +156,10 @@ int mpcodecs_config_vo(sh_video_t *sh, int w, int h, unsigned int out_fmt) // Time to config libvo! mp_msg(MSGT_CPLAYER, MSGL_V, "VO Config (%dx%d->%dx%d,flags=%d,0x%X)\n", sh->disp_w, - sh->disp_h, screen_size_x, screen_size_y, vocfg_flags, out_fmt); + sh->disp_h, d_w, d_h, vocfg_flags, out_fmt); - if (vf_config_wrapper - (vf, sh->disp_w, sh->disp_h, screen_size_x, screen_size_y, vocfg_flags, - out_fmt) == 0) { + if (vf_config_wrapper(vf, sh->disp_w, sh->disp_h, d_w, d_h, vocfg_flags, + out_fmt) == 0) { mp_tmsg(MSGT_CPLAYER, MSGL_WARN, "FATAL: Cannot initialize video driver.\n"); sh->vf_initialized = -1; return 0; |