summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2016-08-30 23:50:57 +0200
committerwm4 <wm4@nowhere>2016-08-30 23:50:57 +0200
commitaf1379c43d6a5274b75bce0adeef9e3a9ce87bdf (patch)
treeba90dc6c885374095a1051c8dde7f983eca7b7e9
parente65a8d7b61762ddf07825c59a6ebd47b026b0ea7 (diff)
downloadmpv-af1379c43d6a5274b75bce0adeef9e3a9ce87bdf.tar.bz2
mpv-af1379c43d6a5274b75bce0adeef9e3a9ce87bdf.tar.xz
options: make mp_vo_opts options an actual sub-option group
Just a minor refactor along the planned option change. This commit will make it easier to update (i.e. copy) the VO options without copying _all_ options. For now, behavior should be equivalent, though. (The VO options were put into a separate struct quite early - when all global variables were removed from the source code. It wasn't clear whether the separate struct would have any actual purpose, but it seems it will now. Awesome, huh.)
-rw-r--r--options/options.c145
-rw-r--r--options/options.h2
-rw-r--r--player/command.c16
-rw-r--r--player/configfiles.c4
-rw-r--r--player/misc.c2
-rw-r--r--player/playloop.c2
-rw-r--r--video/filter/vf_scale.c2
-rw-r--r--video/out/vo.c4
-rw-r--r--video/out/vo_opengl_cb.c2
9 files changed, 94 insertions, 85 deletions
diff --git a/options/options.c b/options/options.c
index 129f0cc53c..dc880d3339 100644
--- a/options/options.c
+++ b/options/options.c
@@ -97,6 +97,81 @@ const struct m_opt_choice_alternatives mp_hwdec_names[] = {
{0}
};
+#define OPT_BASE_STRUCT struct mp_vo_opts
+
+static const m_option_t mp_vo_opt_list[] = {
+ OPT_SETTINGSLIST("vo", video_driver_list, 0, &vo_obj_list),
+ OPT_SETTINGSLIST("vo-defaults", vo_defs, 0, &vo_obj_list),
+ OPT_CHOICE_C("hwdec-preload", hwdec_preload_api, 0, mp_hwdec_names),
+ OPT_SUBSTRUCT("sws", sws_opts, sws_conf, 0),
+ OPT_FLAG("taskbar-progress", taskbar_progress, 0),
+ OPT_FLAG("ontop", ontop, M_OPT_FIXED),
+ OPT_FLAG("border", border, M_OPT_FIXED),
+ OPT_FLAG("fit-border", fit_border, M_OPT_FIXED),
+ OPT_FLAG("on-all-workspaces", all_workspaces, M_OPT_FIXED),
+ OPT_GEOMETRY("geometry", geometry, 0),
+ OPT_SIZE_BOX("autofit", autofit, 0),
+ OPT_SIZE_BOX("autofit-larger", autofit_larger, 0),
+ OPT_SIZE_BOX("autofit-smaller", autofit_smaller, 0),
+ OPT_FLOATRANGE("window-scale", window_scale, 0, 0.001, 100),
+ OPT_FLAG("force-window-position", force_window_position, 0),
+ OPT_STRING("x11-name", winname, 0),
+ OPT_FLOATRANGE("monitoraspect", force_monitor_aspect, 0, 0.0, 9.0),
+ OPT_FLOATRANGE("monitorpixelaspect", monitor_pixel_aspect, 0, 0.2, 9.0),
+ OPT_FLAG("fullscreen", fullscreen, M_OPT_FIXED),
+ OPT_FLAG("fs", fullscreen, M_OPT_FIXED),
+ OPT_FLAG("native-keyrepeat", native_keyrepeat, M_OPT_FIXED),
+ OPT_FLOATRANGE("panscan", panscan, 0, 0.0, 1.0),
+ OPT_FLOATRANGE("video-zoom", zoom, 0, -20.0, 20.0),
+ OPT_FLOATRANGE("video-pan-x", pan_x, 0, -3.0, 3.0),
+ OPT_FLOATRANGE("video-pan-y", pan_y, 0, -3.0, 3.0),
+ OPT_FLOATRANGE("video-align-x", align_x, 0, -1.0, 1.0),
+ OPT_FLOATRANGE("video-align-y", align_y, 0, -1.0, 1.0),
+ OPT_CHOICE("video-unscaled", unscaled, 0,
+ ({"no", 0}, {"yes", 1}, {"downscale-big", 2})),
+ OPT_INT64("wid", WinID, 0),
+ OPT_CHOICE_OR_INT("screen", screen_id, 0, 0, 32,
+ ({"default", -1})),
+ OPT_CHOICE_OR_INT("fs-screen", fsscreen_id, 0, 0, 32,
+ ({"all", -2}, {"current", -1})),
+ OPT_FLAG("fs-black-out-screens", fs_black_out_screens, 0),
+ OPT_FLAG("keepaspect", keepaspect, 0),
+ OPT_FLAG("keepaspect-window", keepaspect_window, 0),
+#if HAVE_X11
+ OPT_CHOICE("x11-netwm", x11_netwm, 0,
+ ({"auto", 0}, {"no", -1}, {"yes", 1})),
+ OPT_CHOICE("x11-bypass-compositor", x11_bypass_compositor, 0,
+ ({"no", 0}, {"yes", 1}, {"fs-only", 2}, {"never", 3})),
+#endif
+#if HAVE_WIN32
+ OPT_STRING("vo-mmcss-profile", mmcss_profile, M_OPT_FIXED),
+#endif
+
+ {0}
+};
+
+static const struct m_sub_options vo_sub_opts = {
+ .opts = mp_vo_opt_list,
+ .size = sizeof(struct mp_vo_opts),
+ .defaults = &(const struct mp_vo_opts){
+ .video_driver_list = NULL,
+ .monitor_pixel_aspect = 1.0,
+ .screen_id = -1,
+ .fsscreen_id = -1,
+ .panscan = 0.0f,
+ .keepaspect = 1,
+ .keepaspect_window = 1,
+ .taskbar_progress = 1,
+ .border = 1,
+ .fit_border = 1,
+ .WinID = -1,
+ .window_scale = 1.0,
+ .x11_bypass_compositor = 2,
+ .mmcss_profile = "Playback",
+ },
+};
+
+#undef OPT_BASE_STRUCT
#define OPT_BASE_STRUCT struct MPOpts
const m_option_t mp_opts[] = {
@@ -313,14 +388,11 @@ const m_option_t mp_opts[] = {
OPT_FLAG("ad-spdif-dtshd", dtshd, 0),
OPT_CHOICE_C("hwdec", hwdec_api, 0, mp_hwdec_names),
- OPT_CHOICE_C("hwdec-preload", vo.hwdec_preload_api, 0, mp_hwdec_names),
OPT_STRING("hwdec-codecs", hwdec_codecs, 0),
#if HAVE_VIDEOTOOLBOX_HWACCEL
OPT_IMAGEFORMAT("videotoolbox-format", videotoolbox_format, 0),
#endif
- OPT_SUBSTRUCT("sws", vo.sws_opts, sws_conf, 0),
-
// -1 means auto aspect (prefer container size until aspect change)
// 0 means square pixels
OPT_FLOATRANGE("video-aspect", movie_aspect, 0, -1.0, 10.0),
@@ -393,8 +465,6 @@ const m_option_t mp_opts[] = {
OPT_FLAG("sub-clear-on-seek", sub_clear_on_seek, 0),
//---------------------- libao/libvo options ------------------------
- OPT_SETTINGSLIST("vo", vo.video_driver_list, 0, &vo_obj_list),
- OPT_SETTINGSLIST("vo-defaults", vo.vo_defs, 0, &vo_obj_list),
OPT_SETTINGSLIST("ao", audio_driver_list, 0, &ao_obj_list),
OPT_SETTINGSLIST("ao-defaults", ao_defs, 0, &ao_obj_list),
OPT_STRING("audio-device", audio_device, 0),
@@ -404,11 +474,6 @@ const m_option_t mp_opts[] = {
OPT_FLOATRANGE("audio-wait-open", audio_wait_open, 0, 0, 60),
OPT_CHOICE("force-window", force_vo, 0,
({"no", 0}, {"yes", 1}, {"immediate", 2})),
- OPT_FLAG("taskbar-progress", vo.taskbar_progress, 0),
- OPT_FLAG("ontop", vo.ontop, M_OPT_FIXED),
- OPT_FLAG("border", vo.border, M_OPT_FIXED),
- OPT_FLAG("fit-border", vo.fit_border, M_OPT_FIXED),
- OPT_FLAG("on-all-workspaces", vo.all_workspaces, M_OPT_FIXED),
OPT_FLAG("window-dragging", allow_win_drag, CONF_GLOBAL),
@@ -431,31 +496,9 @@ const m_option_t mp_opts[] = {
.min = 0, .max = 10),
OPT_FLOATRANGE("balance", balance, 0, -1, 1),
- 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_FLOATRANGE("window-scale", vo.window_scale, 0, 0.001, 100),
- 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),
OPT_STRING("title", wintitle, 0),
OPT_STRING("force-media-title", media_title, 0),
// set aspect ratio of monitor - useful for 16:9 TV-out
- OPT_FLOATRANGE("monitoraspect", vo.force_monitor_aspect, 0, 0.0, 9.0),
- OPT_FLOATRANGE("monitorpixelaspect", vo.monitor_pixel_aspect, 0, 0.2, 9.0),
- // start in fullscreen mode:
- OPT_FLAG("fullscreen", vo.fullscreen, M_OPT_FIXED),
- OPT_FLAG("fs", vo.fullscreen, M_OPT_FIXED),
- OPT_FLAG("native-keyrepeat", vo.native_keyrepeat, M_OPT_FIXED),
- OPT_FLOATRANGE("panscan", vo.panscan, 0, 0.0, 1.0),
- OPT_FLOATRANGE("video-zoom", vo.zoom, 0, -20.0, 20.0),
- OPT_FLOATRANGE("video-pan-x", vo.pan_x, 0, -3.0, 3.0),
- OPT_FLOATRANGE("video-pan-y", vo.pan_y, 0, -3.0, 3.0),
- OPT_FLOATRANGE("video-align-x", vo.align_x, 0, -1.0, 1.0),
- OPT_FLOATRANGE("video-align-y", vo.align_y, 0, -1.0, 1.0),
- OPT_CHOICE("video-unscaled", vo.unscaled, 0,
- ({"no", 0}, {"yes", 1}, {"downscale-big", 2})),
OPT_FLAG("force-rgba-osd-rendering", force_rgba_osd, 0),
OPT_CHOICE_OR_INT("video-rotate", video_rotate, 0, 0, 359,
({"no", -1})),
@@ -466,28 +509,10 @@ const m_option_t mp_opts[] = {
OPT_FLAG("cursor-autohide-fs-only", cursor_autohide_fs, 0),
OPT_FLAG("stop-screensaver", stop_screensaver, 0),
- OPT_INT64("wid", vo.WinID, 0),
-#if HAVE_X11
- OPT_CHOICE("x11-netwm", vo.x11_netwm, 0,
- ({"auto", 0}, {"no", -1}, {"yes", 1})),
- OPT_CHOICE("x11-bypass-compositor", vo.x11_bypass_compositor, 0,
- ({"no", 0}, {"yes", 1}, {"fs-only", 2}, {"never", 3})),
-#endif
-#if HAVE_WIN32
- OPT_STRING("vo-mmcss-profile", vo.mmcss_profile, M_OPT_FIXED),
-#endif
-
OPT_STRING("heartbeat-cmd", heartbeat_cmd, 0,
.deprecation_message = "use Lua scripting instead"),
OPT_FLOAT("heartbeat-interval", heartbeat_interval, CONF_MIN, 0),
- OPT_CHOICE_OR_INT("screen", vo.screen_id, 0, 0, 32,
- ({"default", -1})),
-
- OPT_CHOICE_OR_INT("fs-screen", vo.fsscreen_id, 0, 0, 32,
- ({"all", -2}, {"current", -1})),
-
- OPT_FLAG("fs-black-out-screens", vo.fs_black_out_screens, 0),
OPT_INTRANGE("brightness", gamma_brightness, 0, -100, 100),
OPT_INTRANGE("saturation", gamma_saturation, 0, -100, 100),
OPT_INTRANGE("contrast", gamma_contrast, 0, -100, 100),
@@ -495,8 +520,6 @@ const m_option_t mp_opts[] = {
OPT_INTRANGE("gamma", gamma_gamma, 0, -100, 100),
OPT_CHOICE_C("video-output-levels", video_output_levels, 0,
mp_csp_levels_names),
- OPT_FLAG("keepaspect", vo.keepaspect, 0),
- OPT_FLAG("keepaspect-window", vo.keepaspect_window, 0),
OPT_FLAG("use-filedir-conf", use_filedir_conf, 0),
OPT_CHOICE("osd-level", osd_level, 0,
@@ -614,6 +637,8 @@ const m_option_t mp_opts[] = {
OPT_PRINT("version", print_version),
OPT_PRINT("V", print_version),
+ OPT_SUBSTRUCT("", vo, vo_sub_opts, 0),
+
#if HAVE_ENCODING
OPT_SUBSTRUCT("", encode_opts, encode_config, 0),
#endif
@@ -715,22 +740,6 @@ const struct MPOpts mp_default_opts = {
.audio_buffer = 0.2,
.audio_device = "auto",
.audio_client_name = "mpv",
- .vo = {
- .video_driver_list = NULL,
- .monitor_pixel_aspect = 1.0,
- .screen_id = -1,
- .fsscreen_id = -1,
- .panscan = 0.0f,
- .keepaspect = 1,
- .keepaspect_window = 1,
- .taskbar_progress = 1,
- .border = 1,
- .fit_border = 1,
- .WinID = -1,
- .window_scale = 1.0,
- .x11_bypass_compositor = 2,
- .mmcss_profile = "Playback",
- },
.allow_win_drag = 1,
.wintitle = "${?media-title:${media-title}}${!media-title:No file} - mpv",
.heartbeat_interval = 30.0,
diff --git a/options/options.h b/options/options.h
index 187abc2c1a..130ab4c1cf 100644
--- a/options/options.h
+++ b/options/options.h
@@ -98,7 +98,7 @@ typedef struct MPOpts {
int gapless_audio;
double audio_buffer;
- mp_vo_opts vo;
+ mp_vo_opts *vo;
int allow_win_drag;
char *wintitle;
diff --git a/player/command.c b/player/command.c
index 1c59d130ce..a59fa059b8 100644
--- a/player/command.c
+++ b/player/command.c
@@ -2371,10 +2371,10 @@ static int mp_property_fullscreen(void *ctx, struct m_property *prop,
int action, void *arg)
{
MPContext *mpctx = ctx;
- int oldval = mpctx->opts->vo.fullscreen;
+ int oldval = mpctx->opts->vo->fullscreen;
int r = mp_property_vo_flag(prop, action, arg, VOCTRL_FULLSCREEN,
- &mpctx->opts->vo.fullscreen, mpctx);
- if (oldval && oldval != mpctx->opts->vo.fullscreen)
+ &mpctx->opts->vo->fullscreen, mpctx);
+ if (oldval && oldval != mpctx->opts->vo->fullscreen)
mpctx->mouse_event_ts--; // Show mouse cursor
return r;
}
@@ -2386,9 +2386,9 @@ static int mp_property_taskbar_progress(void *ctx, struct m_property *prop,
MPContext *mpctx = ctx;
if (action == M_PROPERTY_SET) {
int desired = !!*(int *) arg;
- if (mpctx->opts->vo.taskbar_progress == desired)
+ if (mpctx->opts->vo->taskbar_progress == desired)
return M_PROPERTY_OK;
- mpctx->opts->vo.taskbar_progress = desired;
+ mpctx->opts->vo->taskbar_progress = desired;
if (mpctx->video_out)
update_vo_playback_state(mpctx);
return M_PROPERTY_OK;
@@ -2402,7 +2402,7 @@ static int mp_property_ontop(void *ctx, struct m_property *prop,
{
MPContext *mpctx = ctx;
return mp_property_vo_flag(prop, action, arg, VOCTRL_ONTOP,
- &mpctx->opts->vo.ontop, mpctx);
+ &mpctx->opts->vo->ontop, mpctx);
}
/// Show window borders (RW)
@@ -2411,7 +2411,7 @@ static int mp_property_border(void *ctx, struct m_property *prop,
{
MPContext *mpctx = ctx;
return mp_property_vo_flag(prop, action, arg, VOCTRL_BORDER,
- &mpctx->opts->vo.border, mpctx);
+ &mpctx->opts->vo->border, mpctx);
}
static int mp_property_all_workspaces(void *ctx, struct m_property *prop,
@@ -2419,7 +2419,7 @@ static int mp_property_all_workspaces(void *ctx, struct m_property *prop,
{
MPContext *mpctx = ctx;
return mp_property_vo_flag(prop, action, arg, VOCTRL_ALL_WORKSPACES,
- &mpctx->opts->vo.all_workspaces, mpctx);
+ &mpctx->opts->vo->all_workspaces, mpctx);
}
static int get_frame_count(struct MPContext *mpctx)
diff --git a/player/configfiles.c b/player/configfiles.c
index 7356a9a81b..59cb510bf8 100644
--- a/player/configfiles.c
+++ b/player/configfiles.c
@@ -152,8 +152,8 @@ void mp_load_auto_profiles(struct MPContext *mpctx)
mp_load_per_file_config(mpctx);
- if (opts->vo.video_driver_list)
- mp_auto_load_profile(mpctx, "vo", bstr0(opts->vo.video_driver_list[0].name));
+ if (opts->vo->video_driver_list)
+ mp_auto_load_profile(mpctx, "vo", bstr0(opts->vo->video_driver_list[0].name));
if (opts->audio_driver_list)
mp_auto_load_profile(mpctx, "ao", bstr0(opts->audio_driver_list[0].name));
}
diff --git a/player/misc.c b/player/misc.c
index c9e25a3966..79fad39687 100644
--- a/player/misc.c
+++ b/player/misc.c
@@ -134,7 +134,7 @@ void update_vo_playback_state(struct MPContext *mpctx)
if (mpctx->video_out) {
struct voctrl_playback_state oldstate = mpctx->vo_playback_state;
struct voctrl_playback_state newstate = {
- .taskbar_progress = mpctx->opts->vo.taskbar_progress,
+ .taskbar_progress = mpctx->opts->vo->taskbar_progress,
.playing = mpctx->playing,
.paused = mpctx->paused,
.percent_pos = get_percent_pos(mpctx),
diff --git a/player/playloop.c b/player/playloop.c
index 3bf2216962..079d3a952a 100644
--- a/player/playloop.c
+++ b/player/playloop.c
@@ -662,7 +662,7 @@ static void handle_cursor_autohide(struct MPContext *mpctx)
if (opts->cursor_autohide_delay == -2)
mouse_cursor_visible = false;
- if (opts->cursor_autohide_fs && !opts->vo.fullscreen)
+ if (opts->cursor_autohide_fs && !opts->vo->fullscreen)
mouse_cursor_visible = true;
if (mouse_cursor_visible != mpctx->mouse_cursor_visible)
diff --git a/video/filter/vf_scale.c b/video/filter/vf_scale.c
index 0b233e7098..8b1f0a1116 100644
--- a/video/filter/vf_scale.c
+++ b/video/filter/vf_scale.c
@@ -171,7 +171,7 @@ static int reconfig(struct vf_instance *vf, struct mp_image_params *in,
}
mp_image_params_guess_csp(out);
- mp_sws_set_from_cmdline(vf->priv->sws, vf->chain->opts->vo.sws_opts);
+ mp_sws_set_from_cmdline(vf->priv->sws, vf->chain->opts->vo->sws_opts);
vf->priv->sws->flags |= vf->priv->v_chr_drop << SWS_SRC_V_CHR_DROP_SHIFT;
vf->priv->sws->flags |= vf->priv->accurate_rnd * SWS_ACCURATE_RND;
vf->priv->sws->src = *in;
diff --git a/video/out/vo.c b/video/out/vo.c
index 0d70106ed8..31a1e74405 100644
--- a/video/out/vo.c
+++ b/video/out/vo.c
@@ -224,7 +224,7 @@ static struct vo *vo_create(bool probing, struct mpv_global *global,
*vo = (struct vo) {
.log = mp_log_new(vo, log, name),
.driver = desc.p,
- .opts = &global->opts->vo,
+ .opts = global->opts->vo,
.global = global,
.encode_lavc_ctx = ex->encode_lavc_ctx,
.input_ctx = ex->input_ctx,
@@ -269,7 +269,7 @@ error:
struct vo *init_best_video_out(struct mpv_global *global, struct vo_extra *ex)
{
- struct m_obj_settings *vo_list = global->opts->vo.video_driver_list;
+ struct m_obj_settings *vo_list = global->opts->vo->video_driver_list;
// first try the preferred drivers, with their optional subdevice param:
if (vo_list && vo_list[0].name) {
for (int n = 0; vo_list[n].name; n++) {
diff --git a/video/out/vo_opengl_cb.c b/video/out/vo_opengl_cb.c
index 06c90d2e5b..776d4485ba 100644
--- a/video/out/vo_opengl_cb.c
+++ b/video/out/vo_opengl_cb.c
@@ -136,7 +136,7 @@ struct mpv_opengl_cb_context *mp_opengl_create(struct mpv_global *g,
ctx->log = mp_log_new(ctx, g->log, "opengl-cb");
ctx->client_api = client_api;
- ctx->hwdec_api = g->opts->vo.hwdec_preload_api;
+ ctx->hwdec_api = g->opts->vo->hwdec_preload_api;
if (ctx->hwdec_api == HWDEC_NONE)
ctx->hwdec_api = g->opts->hwdec_api;