From 1883b7cc0c2844a903d51042861fca16eb3fad02 Mon Sep 17 00:00:00 2001 From: wm4 Date: Fri, 16 Jan 2015 22:30:32 +0100 Subject: player: add --autofit-smaller option Fixes #1472. (Maybe these options should have been named --autofit-max and --autofit-min, but since --autofit-larger already exists, use --autofit-smaller for symmetry.) --- video/out/win_state.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'video/out') diff --git a/video/out/win_state.c b/video/out/win_state.c index a7404cfa5b..af54f8215f 100644 --- a/video/out/win_state.c +++ b/video/out/win_state.c @@ -37,7 +37,7 @@ static void calc_monitor_aspect(struct mp_vo_opts *opts, int scr_w, int scr_h, // Fit *w/*h into the size specified by geo. static void apply_autofit(int *w, int *h, int scr_w, int scr_h, - struct m_geometry *geo, bool allow_upscale) + struct m_geometry *geo, bool allow_up, bool allow_down) { if (!geo->wh_valid) return; @@ -46,13 +46,16 @@ static void apply_autofit(int *w, int *h, int scr_w, int scr_h, int n_w = *w, n_h = *h; m_geometry_apply(&dummy, &dummy, &n_w, &n_h, scr_w, scr_h, geo); - if (!allow_upscale && *w <= n_w && *h <= n_h) + if (!allow_up && *w <= n_w && *h <= n_h) + return; + if (!allow_down && *w >= n_w && *h >= n_h) return; // If aspect mismatches, always make the window smaller than the fit box + // (Or larger, if allow_down==false.) double asp = (double)*w / *h; double n_asp = (double)n_w / n_h; - if (n_asp <= asp) { + if ((n_asp <= asp) == allow_down) { *w = n_w; *h = n_w / asp; } else { @@ -95,8 +98,9 @@ void vo_calc_window_geometry(struct vo *vo, const struct mp_rect *screen, calc_monitor_aspect(opts, scr_w, scr_h, &out_geo->monitor_par, &d_w, &d_h); - apply_autofit(&d_w, &d_h, scr_w, scr_h, &opts->autofit, true); - apply_autofit(&d_w, &d_h, scr_w, scr_h, &opts->autofit_larger, false); + apply_autofit(&d_w, &d_h, scr_w, scr_h, &opts->autofit, true, true); + apply_autofit(&d_w, &d_h, scr_w, scr_h, &opts->autofit_larger, false, true); + apply_autofit(&d_w, &d_h, scr_w, scr_h, &opts->autofit_smaller, true, false); out_geo->win.x0 = (int)(scr_w - d_w) / 2; out_geo->win.y0 = (int)(scr_h - d_h) / 2; -- cgit v1.2.3