diff options
author | wm4 <wm4@nowhere> | 2013-01-23 10:56:36 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2013-01-23 10:56:36 +0100 |
commit | 7885fce7ea68d4c64e034b152f2a0b08bb648adc (patch) | |
tree | 1287161e93f05b5964347d008b82c18f0aad0ca8 /core/m_option.c | |
parent | ccaed5eb071319f9d412f42610302765b844f978 (diff) | |
download | mpv-7885fce7ea68d4c64e034b152f2a0b08bb648adc.tar.bz2 mpv-7885fce7ea68d4c64e034b152f2a0b08bb648adc.tar.xz |
video: add --autofit and --autofit-larger options
--autofit=WxH sets the window size to a maximum width and/or height,
without changing the window's aspect ratio.
--autofit-larger=WxH does the same, but only if the video size is
actually larger than the window size that would result when using
the --autofit=WxH option with the same arguments.
Diffstat (limited to 'core/m_option.c')
-rw-r--r-- | core/m_option.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/core/m_option.c b/core/m_option.c index a55e87a5d3..c1d2ee4fbe 100644 --- a/core/m_option.c +++ b/core/m_option.c @@ -1309,7 +1309,34 @@ const m_option_type_t m_option_type_geometry = { .parse = parse_geometry, }; +static int parse_size_box(const m_option_t *opt, struct bstr name, + struct bstr param, void *dst) +{ + struct m_geometry gm; + if (!parse_geometry_str(&gm, param)) + goto error; + + if (gm.xy_valid) + goto error; + + if (dst) + *((struct m_geometry *)dst) = gm; + return 1; + +error: + mp_msg(MSGT_CFGPARSER, MSGL_ERR, "Option %.*s: invalid size: '%.*s'\n", + BSTR_P(name), BSTR_P(param)); + mp_msg(MSGT_CFGPARSER, MSGL_ERR, + "Valid format: W[%%][xH[%%]] or empty string\n"); + return M_OPT_INVALID; +} + +const m_option_type_t m_option_type_size_box = { + .name = "Window size", + .size = sizeof(struct m_geometry), + .parse = parse_size_box, +}; #include "video/img_format.h" |