From 7686cd7f043ef5b42ade64db21ec01c8c8d6281e Mon Sep 17 00:00:00 2001 From: Alexander Preisinger Date: Mon, 4 Mar 2013 17:40:21 +0100 Subject: vo: remove and cleanup globals Removes almost every global variabel in vo.h and puts them in a special struct in MPOpts for video output related options. Also we completly remove the options/globals pts and refresh rate because they were unused. --- core/cfg-mplayer.h | 67 ++++++++++++++++++++++++------------------------- core/command.c | 40 ++++++++++++++++-------------- core/defaultopts.c | 36 ++++++++++++++++++--------- core/m_option.h | 3 +++ core/mplayer.c | 5 ++-- core/options.h | 73 +++++++++++++++++++++++++++++++++++------------------- 6 files changed, 131 insertions(+), 93 deletions(-) (limited to 'core') diff --git a/core/cfg-mplayer.h b/core/cfg-mplayer.h index 651ec61a77..32058e92b6 100644 --- a/core/cfg-mplayer.h +++ b/core/cfg-mplayer.h @@ -529,8 +529,8 @@ const m_option_t mplayer_opts[]={ OPT_STRINGLIST("vo", video_driver_list, 0), OPT_STRINGLIST("ao", audio_driver_list, 0), OPT_FLAG("fixed-vo", fixed_vo, CONF_GLOBAL), - OPT_FLAG("ontop", vo_ontop, 0), - {"border", &vo_border, CONF_TYPE_FLAG, 0, 0, 1, NULL}, + OPT_FLAG("ontop", vo.ontop, 0), + OPT_FLAG("border", vo.border, 1), OPT_STRING("mixer", mixer_device, 0), OPT_STRING("mixer-channel", mixer_channel, 0), @@ -550,30 +550,30 @@ const m_option_t mplayer_opts[]={ OPT_INT("abs", ao_buffersize, 0), // set screen dimensions (when not detectable or virtual!=visible) - 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_FLAG("force-window-position", force_window_position, 0), + 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_FLAG("force-window-position", vo.force_window_position, 0), // vo name (X classname) and window title strings - OPT_STRING("name", vo_winname, 0), - OPT_STRING("title", vo_wintitle, 0), + OPT_STRING("name", vo.winname, 0), + OPT_STRING("title", wintitle, 0), // set aspect ratio of monitor - useful for 16:9 TV-out - OPT_FLOATRANGE("monitoraspect", force_monitor_aspect, 0, 0.0, 9.0), - OPT_FLOATRANGE("monitorpixelaspect", monitor_pixel_aspect, 0, 0.2, 9.0), + 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", fullscreen, 0), OPT_FLAG("fs", fullscreen, 0), // set fullscreen switch method (workaround for buggy WMs) - {"fsmode-dontuse", &vo_fsmode, CONF_TYPE_INT, CONF_RANGE, 0, 31, NULL}, - {"colorkey", &vo_colorkey, CONF_TYPE_INT, 0, 0, 0, NULL}, - {"no-colorkey", &vo_colorkey, CONF_TYPE_STORE, 0, 0, 0x1000000, NULL}, + OPT_INTRANGE("fsmode-dontuse", vo.fsmode, 0, 31, 4096), + OPT_INT("colorkey", vo.colorkey, 0), + OPT_INT("no-colorkey", vo.colorkey, 0x1000000), // wait for v-sync (gl) - {"vsync", &vo_vsync, CONF_TYPE_FLAG, 0, 0, 1, NULL}, - {"panscan", &vo_panscan, CONF_TYPE_FLOAT, CONF_RANGE, 0, 1.0, NULL}, - OPT_FLOATRANGE("panscanrange", vo_panscanrange, 0, -19.0, 99.0), - OPT_FLAG("force-rgba-osd-rendering", vo_force_rgba_osd, 0), + OPT_FLAG("vsync", vo.vsync, 1), + OPT_FLOATRANGE("panscan", vo.panscan, 0, 1.0, 99.0), + OPT_FLOATRANGE("panscanrange", vo.panscanrange, 0, -19.0, 99.0), + OPT_FLAG("force-rgba-osd-rendering", force_rgba_osd, 0), OPT_CHOICE("colormatrix", requested_colorspace, 0, ({"auto", MP_CSP_AUTO}, {"BT.601", MP_CSP_BT_601}, @@ -588,30 +588,29 @@ const m_option_t mplayer_opts[]={ {"limited", MP_CSP_LEVELS_TV}, {"full", MP_CSP_LEVELS_PC})), - OPT_CHOICE_OR_INT("cursor-autohide", cursor_autohide_delay, 0, + OPT_CHOICE_OR_INT("cursor-autohide", vo.cursor_autohide_delay, 0, 0, 30000, ({"no", -1}, {"always", -2})), - {"refreshrate",&vo_refresh_rate,CONF_TYPE_INT,CONF_RANGE, 0,100, NULL}, - {"wid", &WinID, CONF_TYPE_INT64, 0, 0, 0, NULL}, + OPT_INT64("wid", vo.WinID, -1), #ifdef CONFIG_X11 - OPT_FLAG("stop-xscreensaver", vo_stop_screensaver, 0), - OPT_STRINGLIST("fstype", vo_fstype_list, 0), + OPT_FLAG("stop-xscreensaver", vo.stop_screensaver, 0), + OPT_STRINGLIST("fstype", vo.fstype_list, 0), #endif {"heartbeat-cmd", &heartbeat_cmd, CONF_TYPE_STRING, 0, 0, 0, NULL}, - {"mouseinput", &vo_nomouse_input, CONF_TYPE_FLAG, 0, 1, 0, NULL}, + OPT_FLAG("mouseinput", vo.nomouse_input, 0), - OPT_CHOICE_OR_INT("screen", vo_screen_id, 0, 0, 32, + 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, + OPT_CHOICE_OR_INT("fs-screen", vo.fsscreen_id, 0, 0, 32, ({"all", -2}, {"current", -1})), - OPT_INTRANGE("brightness", vo_gamma_brightness, 0, -100, 100), - OPT_INTRANGE("saturation", vo_gamma_saturation, 0, -100, 100), - OPT_INTRANGE("contrast", vo_gamma_contrast, 0, -100, 100), - OPT_INTRANGE("hue", vo_gamma_hue, 0, -100, 100), - OPT_INTRANGE("gamma", vo_gamma_gamma, 0, -100, 100), - {"keepaspect", &vo_keepaspect, CONF_TYPE_FLAG, 0, 0, 1, NULL}, + OPT_INTRANGE("brightness", gamma_brightness, 0, -100, 100), + OPT_INTRANGE("saturation", gamma_saturation, 0, -100, 100), + OPT_INTRANGE("contrast", gamma_contrast, 0, -100, 100), + OPT_INTRANGE("hue", gamma_hue, 0, -100, 100), + OPT_INTRANGE("gamma", gamma_gamma, 0, -100, 100), + OPT_FLAG("keepaspect", vo.keepaspect, 1), //---------------------- mplayer-only options ------------------------ @@ -676,7 +675,7 @@ const m_option_t mplayer_opts[]={ OPT_FLAG("idle", player_idle_mode, CONF_GLOBAL), OPT_INTRANGE("key-fifo-size", input.key_fifo_size, CONF_GLOBAL, 2, 65000), OPT_FLAG("consolecontrols", consolecontrols, CONF_GLOBAL), - {"mouse-movements", &enable_mouse_movements, CONF_TYPE_FLAG, CONF_GLOBAL, 0, 1, NULL}, + OPT_FLAG("mouse-movements", vo.enable_mouse_movements, 1), OPT_INTRANGE("doubleclick-time", doubleclick_time, 0, 0, 1000), #ifdef CONFIG_TV {"tvscan", (void *) tvscan_conf, CONF_TYPE_SUBCONFIG, 0, 0, 0, NULL}, diff --git a/core/command.c b/core/command.c index 1fe6937e6b..271db5b117 100644 --- a/core/command.c +++ b/core/command.c @@ -85,13 +85,13 @@ static void rescale_input_coordinates(struct MPContext *mpctx, int ix, int iy, struct MPOpts *opts = &mpctx->opts; struct vo *vo = mpctx->video_out; //remove the borders, if any, and rescale to the range [0,1],[0,1] - if (vo_fs) { //we are in full-screen mode - if (opts->vo_screenwidth > vo->dwidth) + if (opts->vo.fs) { //we are in full-screen mode + if (opts->vo.screenwidth > vo->dwidth) // there are borders along the x axis - ix -= (opts->vo_screenwidth - vo->dwidth) / 2; - if (opts->vo_screenheight > vo->dheight) + ix -= (opts->vo.screenwidth - vo->dwidth) / 2; + if (opts->vo.screenheight > vo->dheight) // there are borders along the y axis (usual way) - iy -= (opts->vo_screenheight - vo->dheight) / 2; + iy -= (opts->vo.screenheight - vo->dheight) / 2; if (ix < 0 || ix > vo->dwidth) { *dx = *dy = -1.0; @@ -108,8 +108,8 @@ static void rescale_input_coordinates(struct MPContext *mpctx, int ix, int iy, mp_msg(MSGT_CPLAYER, MSGL_V, "\r\nrescaled coordinates: %.3f, %.3f, screen (%d x %d), vodisplay: (%d, %d), fullscreen: %d\r\n", - *dx, *dy, opts->vo_screenwidth, opts->vo_screenheight, vo->dwidth, - vo->dheight, vo_fs); + *dx, *dy, opts->vo.screenwidth, opts->vo.screenheight, vo->dwidth, + vo->dheight, opts->vo.fs); } // Property-option bridge. @@ -845,19 +845,21 @@ static int mp_property_program(m_option_t *prop, int action, void *arg, /// Fullscreen state (RW) -static int mp_property_fullscreen(m_option_t *prop, int action, void *arg, +static int mp_property_fullscreen(m_option_t *prop, + int action, + void *arg, MPContext *mpctx) { - + struct MPOpts *opts = mpctx->video_out->opts; if (!mpctx->video_out) return M_PROPERTY_UNAVAILABLE; if (action == M_PROPERTY_SET) { - if (vo_fs == !!*(int *) arg) + if (opts->vo.fs == !!*(int *) arg) return M_PROPERTY_OK; if (mpctx->video_out->config_ok) vo_control(mpctx->video_out, VOCTRL_FULLSCREEN, 0); - mpctx->opts.fullscreen = vo_fs; + mpctx->opts.fullscreen = opts->vo.fs; return M_PROPERTY_OK; } return mp_property_generic_option(prop, action, arg, mpctx); @@ -1022,7 +1024,7 @@ static int mp_property_ontop(m_option_t *prop, int action, void *arg, MPContext *mpctx) { return mp_property_vo_flag(prop, action, arg, VOCTRL_ONTOP, - &mpctx->opts.vo_ontop, mpctx); + &mpctx->opts.vo.ontop, mpctx); } /// Show window borders (RW) @@ -1030,11 +1032,11 @@ static int mp_property_border(m_option_t *prop, int action, void *arg, MPContext *mpctx) { return mp_property_vo_flag(prop, action, arg, VOCTRL_BORDER, - &vo_border, mpctx); + &mpctx->opts.vo.border, mpctx); } static int mp_property_framedrop(m_option_t *prop, int action, - void *arg, MPContext *mpctx) + void *arg, MPContext *mpctx) { if (!mpctx->sh_video) return M_PROPERTY_UNAVAILABLE; @@ -1383,15 +1385,15 @@ static const m_option_t mp_properties[] = { M_OPTION_PROPERTY_CUSTOM("border", mp_property_border), M_OPTION_PROPERTY_CUSTOM("framedrop", mp_property_framedrop), M_OPTION_PROPERTY_CUSTOM_("gamma", mp_property_gamma, - .offset = offsetof(struct MPOpts, vo_gamma_gamma)), + .offset = offsetof(struct MPOpts, gamma_gamma)), M_OPTION_PROPERTY_CUSTOM_("brightness", mp_property_gamma, - .offset = offsetof(struct MPOpts, vo_gamma_brightness)), + .offset = offsetof(struct MPOpts, gamma_brightness)), M_OPTION_PROPERTY_CUSTOM_("contrast", mp_property_gamma, - .offset = offsetof(struct MPOpts, vo_gamma_contrast)), + .offset = offsetof(struct MPOpts, gamma_contrast)), M_OPTION_PROPERTY_CUSTOM_("saturation", mp_property_gamma, - .offset = offsetof(struct MPOpts, vo_gamma_saturation)), + .offset = offsetof(struct MPOpts, gamma_saturation)), M_OPTION_PROPERTY_CUSTOM_("hue", mp_property_gamma, - .offset = offsetof(struct MPOpts, vo_gamma_hue)), + .offset = offsetof(struct MPOpts, gamma_hue)), M_OPTION_PROPERTY_CUSTOM("panscan", mp_property_panscan), M_OPTION_PROPERTY_CUSTOM_("vsync", mp_property_vsync), { "video-format", mp_property_video_format, CONF_TYPE_STRING, diff --git a/core/defaultopts.c b/core/defaultopts.c index a3c315b186..b551f05da1 100644 --- a/core/defaultopts.c +++ b/core/defaultopts.c @@ -18,18 +18,30 @@ void set_default_mplayer_options(struct MPOpts *opts) .mixer_init_volume = -1, .mixer_init_mute = -1, .ao_buffersize = -1, - .vo_wintitle = "mpv - ${media-title}", - .monitor_pixel_aspect = 1.0, - .vo_panscanrange = 1.0, - .cursor_autohide_delay = 1000, - .vo_screen_id = -1, - .vo_fsscreen_id = -1, - .vo_gamma_gamma = 1000, - .vo_gamma_brightness = 1000, - .vo_gamma_contrast = 1000, - .vo_gamma_saturation = 1000, - .vo_gamma_hue = 1000, - .vo_stop_screensaver = 1, + .vo = { + .cursor_autohide_delay = 1000, + .monitor_pixel_aspect = 1.0, + .panscanrange = 1.0, + .fs = false, + .screen_id = -1, + .fsscreen_id = -1, + .vsync = 1, + .stop_screensaver = 1, + .nomouse_input = 0, + .fsmode = 0, + .panscan = 0.0f, + .keepaspect = 1, + .border = 1, + .colorkey = 0x0000ff00, // default colorkey is green + // (0xff000000 means that colorkey has been disabled) + .WinID = -1, + }, + .wintitle = "mpv - ${media-title}", + .gamma_gamma = 1000, + .gamma_brightness = 1000, + .gamma_contrast = 1000, + .gamma_saturation = 1000, + .gamma_hue = 1000, .osd_level = 1, .osd_duration = 1000, .loop_times = -1, diff --git a/core/m_option.h b/core/m_option.h index d06e189449..ef2df4e12c 100644 --- a/core/m_option.h +++ b/core/m_option.h @@ -544,6 +544,9 @@ static inline void m_option_free(const m_option_t *opt, void *dst) #define OPT_INT(...) \ OPT_GENERAL(int, __VA_ARGS__, .type = &m_option_type_int) +#define OPT_INT64(...) \ + OPT_GENERAL(int64_t, __VA_ARGS__, .type = &m_option_type_int64) + #define OPT_RANGE_(ctype, optname, varname, flags, minval, maxval, ...) \ OPT_GENERAL(ctype, optname, varname, (flags) | CONF_RANGE, \ .min = minval, .max = maxval, __VA_ARGS__) diff --git a/core/mplayer.c b/core/mplayer.c index a4c9c09960..b56415151d 100644 --- a/core/mplayer.c +++ b/core/mplayer.c @@ -2309,7 +2309,7 @@ static void vo_update_window_title(struct MPContext *mpctx) { if (!mpctx->video_out) return; - char *title = mp_property_expand_string(mpctx, mpctx->opts.vo_wintitle); + char *title = mp_property_expand_string(mpctx, mpctx->opts.wintitle); talloc_free(mpctx->video_out->window_title); mpctx->video_out->window_title = talloc_steal(mpctx, title); } @@ -3215,7 +3215,6 @@ static void run_playloop(struct MPContext *mpctx) double buffered_audio = -1; while (mpctx->sh_video) { // never loops, for "break;" only struct vo *vo = mpctx->video_out; - vo_pts = mpctx->sh_video->timer * 90000.0; vo_fps = mpctx->sh_video->fps; video_left = vo->hasframe || vo->frame_loaded; @@ -4262,7 +4261,7 @@ static bool handle_help_options(struct MPContext *mpctx) opt_exit = 1; } #ifdef CONFIG_X11 - if (opts->vo_fstype_list && strcmp(opts->vo_fstype_list[0], "help") == 0) { + if (opts->vo.fstype_list && strcmp(opts->vo.fstype_list[0], "help") == 0) { fstype_help(); mp_msg(MSGT_FIXME, MSGL_FIXME, "\n"); opt_exit = 1; diff --git a/core/options.h b/core/options.h index a5f4c4023b..c9517f0ead 100644 --- a/core/options.h +++ b/core/options.h @@ -1,13 +1,13 @@ #ifndef MPLAYER_OPTIONS_H #define MPLAYER_OPTIONS_H +#include #include "core/m_option.h" typedef struct MPOpts { char **video_driver_list; char **audio_driver_list; int fixed_vo; - int vo_ontop; char *mixer_device; char *mixer_channel; int softvol; @@ -16,38 +16,61 @@ typedef struct MPOpts { float softvol_max; int gapless_audio; int ao_buffersize; - int vo_screenwidth; - int vo_screenheight; - int vo_screen_id; - int vo_fsscreen_id; - 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; - float force_monitor_aspect; - float monitor_pixel_aspect; + + struct output_conf { + int screenwidth; + int screenheight; + int ontop; + bool fs; + int vsync; + int screen_id; + int fsscreen_id; + int stop_screensaver; + char *winname; + char** fstype_list; + + float panscan; + float panscanrange; + + struct m_geometry geometry; + struct m_geometry autofit; + struct m_geometry autofit_larger; + + int fsmode; + int keepaspect; + int border; + + int colorkey; + + int nomouse_input; + int enable_mouse_movements; + int cursor_autohide_delay; + + int64_t WinID; + + float force_monitor_aspect; + float monitor_pixel_aspect; + int force_window_position; + } vo; + + char *wintitle; + int force_rgba_osd; + + // ranges -100 - 100, 1000 if the vo default should be used + int gamma_gamma; + int gamma_brightness; + int gamma_contrast; + int gamma_saturation; + int gamma_hue; + int fullscreen; - float vo_panscanrange; - int vo_force_rgba_osd; int requested_colorspace; int requested_input_range; int requested_output_range; - int cursor_autohide_delay; - char** vo_fstype_list; - int vo_stop_screensaver; char *audio_decoders; char *video_decoders; - // ranges -100 - 100, 1000 if the vo default should be used - int vo_gamma_gamma; - int vo_gamma_brightness; - int vo_gamma_contrast; - int vo_gamma_saturation; - int vo_gamma_hue; - int osd_level; int osd_duration; int osd_fractions; -- cgit v1.2.3