summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-01-23 10:56:36 +0100
committerwm4 <wm4@nowhere>2013-01-23 10:56:36 +0100
commit7885fce7ea68d4c64e034b152f2a0b08bb648adc (patch)
tree1287161e93f05b5964347d008b82c18f0aad0ca8 /core
parentccaed5eb071319f9d412f42610302765b844f978 (diff)
downloadmpv-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')
-rw-r--r--core/cfg-mplayer.h2
-rw-r--r--core/m_option.c27
-rw-r--r--core/m_option.h3
-rw-r--r--core/options.h2
4 files changed, 34 insertions, 0 deletions
diff --git a/core/cfg-mplayer.h b/core/cfg-mplayer.h
index 5264784a56..54fa3f3ab5 100644
--- a/core/cfg-mplayer.h
+++ b/core/cfg-mplayer.h
@@ -586,6 +586,8 @@ const m_option_t mplayer_opts[]={
OPT_INTRANGE("screenw", vo_screenwidth, CONF_GLOBAL, 0, 4096),
OPT_INTRANGE("screenh", vo_screenheight, CONF_GLOBAL, 0, 4096),
OPT_GEOMETRY("geometry", vo_geometry, 0),
+ OPT_SIZE_BOX("autofit", vo_autofit, 0),
+ OPT_SIZE_BOX("autofit-larger", vo_autofit_larger, 0),
OPT_MAKE_FLAGS("force-window-position", force_window_position, 0),
// vo name (X classname) and window title strings
OPT_STRING("name", vo_winname, 0),
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"
diff --git a/core/m_option.h b/core/m_option.h
index 87fa959992..81ab73e98b 100644
--- a/core/m_option.h
+++ b/core/m_option.h
@@ -57,6 +57,7 @@ extern const m_option_type_t m_option_type_fourcc;
extern const m_option_type_t m_option_type_afmt;
extern const m_option_type_t m_option_type_color;
extern const m_option_type_t m_option_type_geometry;
+extern const m_option_type_t m_option_type_size_box;
// Callback used by m_option_type_print_func options.
typedef int (*m_opt_func_full_t)(const m_option_t *, const char *, const char *);
@@ -219,6 +220,7 @@ union m_option_value {
struct m_rel_time rel_time;
struct m_color color;
struct m_geometry geometry;
+ struct m_geometry size_box;
};
////////////////////////////////////////////////////////////////////////////
@@ -534,6 +536,7 @@ static inline void m_option_free(const m_option_t *opt, void *dst)
#define OPT_REL_TIME(...) OPT_GENERAL(__VA_ARGS__, .type = &m_option_type_rel_time)
#define OPT_COLOR(...) OPT_GENERAL(__VA_ARGS__, .type = &m_option_type_color)
#define OPT_GEOMETRY(...) OPT_GENERAL(__VA_ARGS__, .type = &m_option_type_geometry)
+#define OPT_SIZE_BOX(...) OPT_GENERAL(__VA_ARGS__, .type = &m_option_type_size_box)
#define OPT_TRACKCHOICE(name, var) OPT_CHOICE_OR_INT(name, var, 0, 0, 8190, ({"no", -2}, {"auto", -1}))
diff --git a/core/options.h b/core/options.h
index 10932a4edf..3cd0132847 100644
--- a/core/options.h
+++ b/core/options.h
@@ -21,6 +21,8 @@ typedef struct MPOpts {
int vo_screenwidth;
int vo_screenheight;
struct m_geometry vo_geometry;
+ struct m_geometry vo_autofit;
+ struct m_geometry vo_autofit_larger;
int force_window_position;
char *vo_winname;
char *vo_wintitle;