summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-01-16 22:30:32 +0100
committerwm4 <wm4@nowhere>2015-01-16 22:30:41 +0100
commit1883b7cc0c2844a903d51042861fca16eb3fad02 (patch)
treecbedbd3ecb96a6573d20b771e51ba04124d3a7ee
parentc8052da7decba4cbada6c240f2b21c09e385818c (diff)
downloadmpv-1883b7cc0c2844a903d51042861fca16eb3fad02.tar.bz2
mpv-1883b7cc0c2844a903d51042861fca16eb3fad02.tar.xz
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.)
-rw-r--r--DOCS/man/options.rst11
-rw-r--r--options/options.c1
-rw-r--r--options/options.h1
-rw-r--r--video/out/win_state.c14
4 files changed, 22 insertions, 5 deletions
diff --git a/DOCS/man/options.rst b/DOCS/man/options.rst
index e372627712..b8d521eca6 100644
--- a/DOCS/man/options.rst
+++ b/DOCS/man/options.rst
@@ -1650,6 +1650,17 @@ Window
screen height, make the window smaller until either its width is 90%
of the screen, or its height is 80% of the screen.
+``--autofit-smaller=<[W[xH]]>``
+ This option behaves exactly like ``--autofit``, except that it sets the
+ minimum size of the window (just as ``--autofit-larger`` sets the maximum).
+
+ .. admonition:: Example
+
+ ``500x500``
+ Make the window at least 500 pixels wide and 500 pixels high
+ (depending on the video aspect ratio, the width or height will be
+ larger than 500 in order to keep the aspect ratio the same).
+
``--autosync=<factor>``
Gradually adjusts the A/V sync based on audio delay measurements.
Specifying ``--autosync=0``, the default, will cause frame timing to be
diff --git a/options/options.c b/options/options.c
index 0875e6ded5..9033241605 100644
--- a/options/options.c
+++ b/options/options.c
@@ -394,6 +394,7 @@ const m_option_t mp_opts[] = {
OPT_GEOMETRY("geometry", vo.geometry, 0),
OPT_SIZE_BOX("autofit", vo.autofit, 0),
OPT_SIZE_BOX("autofit-larger", vo.autofit_larger, 0),
+ OPT_SIZE_BOX("autofit-smaller", vo.autofit_smaller, 0),
OPT_FLAG("force-window-position", vo.force_window_position, 0),
// vo name (X classname) and window title strings
OPT_STRING("x11-name", vo.winname, 0),
diff --git a/options/options.h b/options/options.h
index 1664c3a443..3784cf5546 100644
--- a/options/options.h
+++ b/options/options.h
@@ -26,6 +26,7 @@ typedef struct mp_vo_opts {
struct m_geometry geometry;
struct m_geometry autofit;
struct m_geometry autofit_larger;
+ struct m_geometry autofit_smaller;
int keepaspect;
int keepaspect_window;
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;