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 +++++++++++++------- sub/sub.c | 2 +- video/decode/vd.c | 20 +++--- video/out/aspect.c | 18 ++--- video/out/cocoa_common.m | 51 +++++++------- video/out/vo.c | 40 ++++------- video/out/vo.h | 27 ++------ video/out/vo_caca.c | 4 +- video/out/vo_corevideo.m | 4 +- video/out/vo_opengl.c | 2 +- video/out/vo_opengl_old.c | 8 +-- video/out/vo_sdl.c | 28 ++++---- video/out/vo_vdpau.c | 5 +- video/out/vo_x11.c | 10 +-- video/out/vo_xv.c | 8 +-- video/out/w32_common.c | 91 ++++++++++++------------ video/out/wayland_common.c | 26 ++++--- video/out/x11_common.c | 168 +++++++++++++++++++++++---------------------- 23 files changed, 375 insertions(+), 361 deletions(-) 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; diff --git a/sub/sub.c b/sub/sub.c index 2f51b7a8a5..b0c9e22d7a 100644 --- a/sub/sub.c +++ b/sub/sub.c @@ -158,7 +158,7 @@ static void render_object(struct osd_state *osd, struct osd_object *obj, bool formats[SUBBITMAP_COUNT]; memcpy(formats, sub_formats, sizeof(formats)); - if (opts->vo_force_rgba_osd) + if (opts->force_rgba_osd) formats[SUBBITMAP_LIBASS] = false; *out_imgs = (struct sub_bitmaps) {0}; diff --git a/video/decode/vd.c b/video/decode/vd.c index b43570f0ad..0ca685e2bb 100644 --- a/video/decode/vd.c +++ b/video/decode/vd.c @@ -169,16 +169,16 @@ int mpcodecs_config_vo(sh_video_t *sh, int w, int h, unsigned int out_fmt) set_video_colorspace(sh); - if (opts->vo_gamma_gamma != 1000) - set_video_colors(sh, "gamma", opts->vo_gamma_gamma); - if (opts->vo_gamma_brightness != 1000) - set_video_colors(sh, "brightness", opts->vo_gamma_brightness); - if (opts->vo_gamma_contrast != 1000) - set_video_colors(sh, "contrast", opts->vo_gamma_contrast); - if (opts->vo_gamma_saturation != 1000) - set_video_colors(sh, "saturation", opts->vo_gamma_saturation); - if (opts->vo_gamma_hue != 1000) - set_video_colors(sh, "hue", opts->vo_gamma_hue); + if (opts->gamma_gamma != 1000) + set_video_colors(sh, "gamma", opts->gamma_gamma); + if (opts->gamma_brightness != 1000) + set_video_colors(sh, "brightness", opts->gamma_brightness); + if (opts->gamma_contrast != 1000) + set_video_colors(sh, "contrast", opts->gamma_contrast); + if (opts->gamma_saturation != 1000) + set_video_colors(sh, "saturation", opts->gamma_saturation); + if (opts->gamma_hue != 1000) + set_video_colors(sh, "hue", opts->gamma_hue); return 1; } diff --git a/video/out/aspect.c b/video/out/aspect.c index 05e40a73e9..e7ca37a82d 100644 --- a/video/out/aspect.c +++ b/video/out/aspect.c @@ -45,10 +45,10 @@ void aspect_save_screenres(struct vo *vo, int scrw, int scrh) scrw = (scrh * 4 + 2) / 3; vo->aspdat.scrw = scrw; vo->aspdat.scrh = scrh; - if (opts->force_monitor_aspect) - vo->monitor_par = opts->force_monitor_aspect * scrh / scrw; + if (opts->vo.force_monitor_aspect) + vo->monitor_par = opts->vo.force_monitor_aspect * scrh / scrw; else - vo->monitor_par = 1.0 / opts->monitor_pixel_aspect; + vo->monitor_par = 1.0 / opts->vo.monitor_pixel_aspect; } /* aspect is called with the source resolution and the @@ -88,7 +88,7 @@ static void get_max_dims(struct vo *vo, int *w, int *h, int zoom) struct aspect_data *aspdat = &vo->aspdat; *w = zoom ? aspdat->scrw : aspdat->prew; *h = zoom ? aspdat->scrh : aspdat->preh; - if (zoom && WinID >= 0) + if (zoom && vo->opts->vo.WinID >= 0) zoom = A_WINZOOM; if (zoom == A_WINZOOM) { *w = vo->dwidth; @@ -101,7 +101,7 @@ void aspect(struct vo *vo, int *srcw, int *srch, int zoom) int fitw; int fith; get_max_dims(vo, &fitw, &fith, zoom); - if (!zoom && vo->opts->vo_geometry.wh_valid) { + if (!zoom && vo->opts->vo.geometry.wh_valid) { mp_msg(MSGT_VO, MSGL_DBG2, "aspect(0) no aspect forced!\n"); return; // the user doesn't want to fix aspect } @@ -123,16 +123,16 @@ static void panscan_calc_internal(struct vo *vo, int zoom) get_max_dims(vo, &max_w, &max_h, zoom); struct MPOpts *opts = vo->opts; - if (opts->vo_panscanrange > 0) { + if (opts->vo.panscanrange > 0) { aspect(vo, &fwidth, &fheight, zoom); vo_panscan_area = max_h - fheight; if (!vo_panscan_area) vo_panscan_area = max_w - fwidth; - vo_panscan_area *= opts->vo_panscanrange; + vo_panscan_area *= opts->vo.panscanrange; } else - vo_panscan_area = -opts->vo_panscanrange * max_h; + vo_panscan_area = -opts->vo.panscanrange * max_h; - vo->panscan_amount = vo_fs || zoom == A_WINZOOM ? vo_panscan : 0; + vo->panscan_amount = opts->vo.fs || zoom == A_WINZOOM ? opts->vo.panscan : 0; vo->panscan_x = vo_panscan_area * vo->panscan_amount * vo->aspdat.asp; vo->panscan_y = vo_panscan_area * vo->panscan_amount; } diff --git a/video/out/cocoa_common.m b/video/out/cocoa_common.m index add42de953..b376e392c0 100644 --- a/video/out/cocoa_common.m +++ b/video/out/cocoa_common.m @@ -122,7 +122,7 @@ struct vo_cocoa_state { int display_cursor; int cursor_timer; - int cursor_autohide_delay; + int vo.cursor_autohide_delay; bool did_resize; bool out_fs_resize; @@ -150,7 +150,7 @@ static struct vo_cocoa_state *vo_cocoa_init_state(struct vo *vo) .windowed_frame = {{0,0},{0,0}}, .out_fs_resize = NO, .display_cursor = 1, - .cursor_autohide_delay = vo->opts->cursor_autohide_delay, + .vo.cursor_autohide_delay = vo->opts->vo.cursor_autohide_delay, .power_mgmt_assertion = kIOPMNullAssertionID, .accumulated_scroll = 0, }; @@ -281,10 +281,10 @@ static void update_screen_info(struct vo *vo) struct MPOpts *opts = vo->opts; NSScreen *ws, *fss; - get_screen_handle(opts->vo_screen_id, s->window, &ws); + get_screen_handle(opts->vo.screen_id, s->window, &ws); s->screen_frame = [ws frame]; - get_screen_handle(opts->vo_fsscreen_id, s->window, &fss); + get_screen_handle(opts->vo.fsscreen_id, s->window, &fss); s->fsscreen_frame = [fss frame]; } @@ -296,10 +296,10 @@ void vo_cocoa_update_xinerama_info(struct vo *vo) update_screen_info(vo); aspect_save_screenres(vo, s->screen_frame.size.width, s->screen_frame.size.height); - opts->vo_screenwidth = s->screen_frame.size.width; - opts->vo_screenheight = s->screen_frame.size.height; - xinerama_x = s->screen_frame.origin.x; - xinerama_y = s->screen_frame.origin.y; + opts->vo.screenwidth = s->screen_frame.size.width; + opts->vo.screenheight = s->screen_frame.size.height; + vo->xinerama_x = s->screen_frame.origin.x; + vo->xinerama_y = s->screen_frame.origin.y; } int vo_cocoa_change_attributes(struct vo *vo) @@ -339,8 +339,8 @@ static void vo_set_level(struct vo *vo, int ontop) void vo_cocoa_ontop(struct vo *vo) { struct MPOpts *opts = vo->opts; - opts->vo_ontop = !opts->vo_ontop; - vo_set_level(vo, opts->vo_ontop); + opts->vo.ontop = !opts->vo.ontop; + vo_set_level(vo, opts->vo.ontop); } static void update_state_sizes(struct vo_cocoa_state *s, @@ -355,7 +355,7 @@ static int create_window(struct vo *vo, uint32_t d_width, uint32_t d_height, uint32_t flags, int gl3profile) { struct vo_cocoa_state *s = vo->cocoa; - const NSRect window_rect = NSMakeRect(xinerama_x, xinerama_y, + const NSRect window_rect = NSMakeRect(vo->xinerama_x, vo->xinerama_y, d_width, d_height); const NSRect glview_rect = NSMakeRect(0, 0, 100, 100); @@ -418,7 +418,7 @@ static void update_window(struct vo *vo) if (s->current_video_size.width != s->previous_video_size.width || s->current_video_size.height != s->previous_video_size.height) { - if (vo_fs) { + if (vo->opts->vo.fs) { // we will resize as soon as we get out of fullscreen s->out_fs_resize = YES; } else { @@ -463,7 +463,7 @@ int vo_cocoa_config_window(struct vo *vo, uint32_t d_width, if (flags & VOFLAG_FULLSCREEN) vo_cocoa_fullscreen(vo); - vo_set_level(vo, opts->vo_ontop); + vo_set_level(vo, opts->vo.ontop); [s->window setContentSize:s->current_video_size]; [s->window setContentAspectRatio:s->current_video_size]; @@ -491,12 +491,12 @@ static void vo_cocoa_display_cursor(struct vo *vo, int requested_state) { struct vo_cocoa_state *s = vo->cocoa; if (requested_state) { - if (!vo_fs || s->cursor_autohide_delay > -2) { + if (!vo->opts->vo.fs || s->vo.cursor_autohide_delay > -2) { s->display_cursor = requested_state; CGDisplayShowCursor(kCGDirectMainDisplay); } } else { - if (s->cursor_autohide_delay != -1) { + if (s->vo.cursor_autohide_delay != -1) { s->display_cursor = requested_state; CGDisplayHideCursor(kCGDirectMainDisplay); } @@ -510,8 +510,8 @@ int vo_cocoa_check_events(struct vo *vo) int ms_time = (int) ([[NSProcessInfo processInfo] systemUptime] * 1000); // automatically hide mouse cursor - if (vo_fs && s->display_cursor && - (ms_time - s->cursor_timer >= s->cursor_autohide_delay)) { + if (vo->opts->vo.fs && s->display_cursor && + (ms_time - s->cursor_timer >= s->vo.cursor_autohide_delay)) { vo_cocoa_display_cursor(vo, 0); s->cursor_timer = ms_time; } @@ -648,7 +648,8 @@ void create_menu() - (void)fullscreen { struct vo_cocoa_state *s = _vo->cocoa; - if (!vo_fs) { + struct MPOpts *opts = _vo->opts; + if (!opts->vo.fs) { update_screen_info(_vo); if (current_screen_has_dock_or_menubar(_vo)) [NSApp setPresentationOptions:NSApplicationPresentationHideDock| @@ -657,7 +658,7 @@ void create_menu() [self setHasShadow:NO]; [self setStyleMask:s->fullscreen_mask]; [self setFrame:s->fsscreen_frame display:YES animate:NO]; - vo_fs = VO_TRUE; + opts->vo.fs = true; vo_cocoa_display_cursor(_vo, 0); [self setMovableByWindowBackground: NO]; } else { @@ -671,7 +672,7 @@ void create_menu() s->out_fs_resize = NO; } [self setContentAspectRatio:s->current_video_size]; - vo_fs = VO_FALSE; + opts->vo.fs = false; vo_cocoa_display_cursor(_vo, 1); [self setMovableByWindowBackground: YES]; } @@ -695,7 +696,7 @@ void create_menu() { // this is only valid as a starting value. it will be rewritten in the // -fullscreen method. - return !vo_fs; + return !_vo->opts->o_fs; } - (void)handleQuitEvent:(NSAppleEventDescriptor*)e @@ -730,7 +731,7 @@ void create_menu() - (void)mouseMoved: (NSEvent *) theEvent { - if (vo_fs) + if (_vo->opts->vo.fs) vo_cocoa_display_cursor(_vo, 1); } @@ -851,7 +852,7 @@ void create_menu() - (void)applicationWillBecomeActive:(NSNotification *)aNotification { - if (vo_fs && current_screen_has_dock_or_menubar(_vo)) { + if (_vo->opts->vo.fs && current_screen_has_dock_or_menubar(_vo)) { struct vo_cocoa_state *s = _vo->cocoa; [self setLevel:s->window_level]; [NSApp setPresentationOptions:NSApplicationPresentationHideDock| @@ -861,7 +862,7 @@ void create_menu() - (void)applicationWillResignActive:(NSNotification *)aNotification { - if (vo_fs) { + if (_vo->opts->vo.fs) { [self setLevel:NSNormalWindowLevel]; [NSApp setPresentationOptions:NSApplicationPresentationDefault]; } @@ -888,7 +889,7 @@ void create_menu() - (void)mulSize:(float)multiplier { - if (!vo_fs) { + if (!_vo->opts->vo.fs) { NSSize size = { .width = _vo->aspdat.prew * multiplier, .height = _vo->aspdat.preh * multiplier diff --git a/video/out/vo.c b/video/out/vo.c index 52ed04d3b5..5841d6fd52 100644 --- a/video/out/vo.c +++ b/video/out/vo.c @@ -42,25 +42,8 @@ #include "video/vfcap.h" #include "sub/sub.h" -int xinerama_x; -int xinerama_y; - -int vo_nomouse_input = 0; -int vo_vsync = 1; -int vo_fs = 0; -int vo_fsmode = 0; -float vo_panscan = 0.0f; -int vo_refresh_rate=0; -int vo_keepaspect=1; -int vo_border=1; -int64_t WinID = -1; - -int vo_pts=0; // for hw decoding float vo_fps=0; -int vo_colorkey = 0x0000ff00; // default colorkey is green - // (0xff000000 means that colorkey has been disabled) - // // Externally visible list of all vo drivers // @@ -407,22 +390,22 @@ static void determine_window_geometry(struct vo *vo, int d_w, int d_h) { struct MPOpts *opts = vo->opts; - int scr_w = opts->vo_screenwidth; - int scr_h = opts->vo_screenheight; + int scr_w = opts->vo.screenwidth; + int scr_h = opts->vo.screenheight; // This is only for applying monitor pixel aspect aspect(vo, &d_w, &d_h, A_NOZOOM); - apply_autofit(&d_w, &d_h, scr_w, scr_h, &opts->vo_autofit, true); - apply_autofit(&d_w, &d_h, scr_w, scr_h, &opts->vo_autofit_larger, false); + apply_autofit(&d_w, &d_h, scr_w, scr_h, &opts->vo.autofit, true); + apply_autofit(&d_w, &d_h, scr_w, scr_h, &opts->vo.autofit_larger, false); - vo->dx = (int)(opts->vo_screenwidth - d_w) / 2; - vo->dy = (int)(opts->vo_screenheight - d_h) / 2; + vo->dx = (int)(opts->vo.screenwidth - d_w) / 2; + vo->dy = (int)(opts->vo.screenheight - d_h) / 2; m_geometry_apply(&vo->dx, &vo->dy, &d_w, &d_h, scr_w, scr_h, - &opts->vo_geometry); + &opts->vo.geometry); - vo->dx += xinerama_x; - vo->dy += xinerama_y; + vo->dx += vo->xinerama_x; + vo->dy += vo->xinerama_y; vo->dwidth = d_w; vo->dheight = d_h; } @@ -536,7 +519,7 @@ void vo_get_src_dst_rects(struct vo *vo, struct mp_rect *out_src, .display_par = vo->monitor_par, .video_par = vo->aspdat.par, }; - if (aspect_scaling()) { + if (aspect_scaling(vo)) { int scaled_width = 0, scaled_height = 0; aspect(vo, &scaled_width, &scaled_height, A_WINZOOM); panscan_calc_windowed(vo); @@ -581,8 +564,9 @@ const char *vo_get_window_title(struct vo *vo) void vo_mouse_movement(struct vo *vo, int posx, int posy) { char cmd_str[40]; - if (!enable_mouse_movements) + if (!vo->opts->vo.enable_mouse_movements) return; snprintf(cmd_str, sizeof(cmd_str), "set_mouse_pos %i %i", posx, posy); mp_input_queue_cmd(vo->input_ctx, mp_input_parse_cmd(bstr0(cmd_str), "")); } + diff --git a/video/out/vo.h b/video/out/vo.h index ca252337b1..ed3be652bd 100644 --- a/video/out/vo.h +++ b/video/out/vo.h @@ -28,6 +28,7 @@ #include "video/img_format.h" #include "core/mp_common.h" +#include "core/options.h" #define VO_EVENT_EXPOSE 1 #define VO_EVENT_RESIZE 2 @@ -260,6 +261,9 @@ struct vo { int dwidth; int dheight; + int xinerama_x; + int xinerama_y; + int panscan_x; int panscan_y; float panscan_amount; @@ -306,27 +310,8 @@ const char *vo_get_window_title(struct vo *vo); // NULL terminated array of all drivers extern const struct vo_driver *video_out_drivers[]; -extern int xinerama_x; -extern int xinerama_y; - -extern int vo_vsync; -extern int vo_fs; -extern int vo_fsmode; -extern float vo_panscan; -extern int vo_refresh_rate; -extern int vo_keepaspect; -extern int vo_border; - -extern int vo_nomouse_input; -extern int enable_mouse_movements; - -extern int vo_pts; extern float vo_fps; -extern int vo_colorkey; - -extern int64_t WinID; - struct mp_keymap { int from; int to; @@ -339,9 +324,9 @@ struct mp_osd_res; void vo_get_src_dst_rects(struct vo *vo, struct mp_rect *out_src, struct mp_rect *out_dst, struct mp_osd_res *out_osd); -static inline int aspect_scaling(void) +static inline int aspect_scaling(struct vo *vo) { - return vo_keepaspect || vo_fs; + return vo->opts->vo.keepaspect || vo->opts->vo.fs; } #endif /* MPLAYER_VIDEO_OUT_H */ diff --git a/video/out/vo_caca.c b/video/out/vo_caca.c index 3a07f57152..885a6c6e9a 100644 --- a/video/out/vo_caca.c +++ b/video/out/vo_caca.c @@ -175,12 +175,12 @@ static void check_events(struct vo *vo) vo_mouse_movement(vo, cev.data.mouse.x, cev.data.mouse.y); break; case CACA_EVENT_MOUSE_PRESS: - if (!vo_nomouse_input) + if (!vo->opts->vo.nomouse_input) mplayer_put_key(vo->key_fifo, (MP_MOUSE_BTN0 + cev.data.mouse.button - 1) | MP_KEY_STATE_DOWN); break; case CACA_EVENT_MOUSE_RELEASE: - if (!vo_nomouse_input) + if (!vo->opts->vo.nomouse_input) mplayer_put_key(vo->key_fifo, MP_MOUSE_BTN0 + cev.data.mouse.button - 1); break; diff --git a/video/out/vo_corevideo.m b/video/out/vo_corevideo.m index a1b5036dbf..08dd8e8a25 100644 --- a/video/out/vo_corevideo.m +++ b/video/out/vo_corevideo.m @@ -70,7 +70,7 @@ static void resize(struct vo *vo, int width, int height) gl->MatrixMode(GL_PROJECTION); gl->LoadIdentity(); p->ass_border_x = p->ass_border_y = 0; - if (aspect_scaling()) { + if (aspect_scaling(vo)) { int new_w, new_h; GLdouble scale_x, scale_y; @@ -307,7 +307,7 @@ static void draw_osd(struct vo *vo, struct osd_state *osd) .video_par = vo->aspdat.par, }; - if (aspect_scaling()) { + if (aspect_scaling(vo)) { res.ml = res.mr = p->ass_border_x; res.mt = res.mb = p->ass_border_y; } diff --git a/video/out/vo_opengl.c b/video/out/vo_opengl.c index 98406ecad4..6170852132 100644 --- a/video/out/vo_opengl.c +++ b/video/out/vo_opengl.c @@ -2085,7 +2085,7 @@ static int preinit(struct vo *vo, const char *arg) .colorspace = MP_CSP_DETAILS_DEFAULTS, .use_npot = 1, .use_pbo = hq, - .swap_interval = vo_vsync, + .swap_interval = vo->opts->vo.vsync, .dither_depth = hq ? 0 : -1, .fbo_format = hq ? GL_RGB16 : GL_RGB, .use_scale_sep = 1, diff --git a/video/out/vo_opengl_old.c b/video/out/vo_opengl_old.c index 30a0467d46..d41a547847 100644 --- a/video/out/vo_opengl_old.c +++ b/video/out/vo_opengl_old.c @@ -1361,7 +1361,7 @@ static void resize(struct vo *vo, int x, int y) gl->MatrixMode(GL_PROJECTION); gl->LoadIdentity(); p->ass_border_x = p->ass_border_y = 0; - if (aspect_scaling()) { + if (aspect_scaling(vo)) { int new_w, new_h; GLdouble scale_x, scale_y; aspect(vo, &new_w, &new_h, A_WINZOOM); @@ -1490,7 +1490,7 @@ static void draw_osd(struct vo *vo, struct osd_state *osd) if (p->scaled_osd) { res.w = p->image_width; res.h = p->image_height; - } else if (aspect_scaling()) { + } else if (aspect_scaling(vo)) { res.ml = res.mr = p->ass_border_x; res.mt = res.mb = p->ass_border_y; } @@ -1821,7 +1821,7 @@ static void flip_page(struct vo *vo) if (p->use_glFinish) gl->Finish(); p->glctx->swapGlBuffers(p->glctx); - if (aspect_scaling()) + if (aspect_scaling(vo)) gl->Clear(GL_COLOR_BUFFER_BIT); } @@ -2113,7 +2113,7 @@ static int preinit(struct vo *vo, const char *arg) .use_rectangle = -1, .ati_hack = -1, .force_pbo = -1, - .swap_interval = vo_vsync, + .swap_interval = vo->opts->vo.vsync, .custom_prog = NULL, .custom_tex = NULL, .custom_tlin = 1, diff --git a/video/out/vo_sdl.c b/video/out/vo_sdl.c index 5f1e4317ed..b10a237b19 100644 --- a/video/out/vo_sdl.c +++ b/video/out/vo_sdl.c @@ -271,7 +271,7 @@ static bool try_create_renderer(struct vo *vo, int i, const char *driver, if (!is_good_renderer(&ri, driver, vc->allow_sw, NULL)) return false; - bool xy_valid = vo->opts->vo_geometry.xy_valid; + bool xy_valid = vo->opts->vo.geometry.xy_valid; // then actually try vc->window = SDL_CreateWindow("MPV", @@ -387,7 +387,7 @@ static void set_fullscreen(struct vo *vo, int fs) // toggling fullscreen might recreate the window, so better guard for this SDL_DisableScreenSaver(); - vo_fs = fs; + vo->opts->vo.fs = fs; force_resize(vo); } @@ -473,18 +473,18 @@ static void check_events(struct vo *vo) struct MPOpts *opts = vo->opts; SDL_Event ev; - if (opts->cursor_autohide_delay >= 0) { + if (opts->vo.cursor_autohide_delay >= 0) { if (!vc->mouse_hidden && - (GetTimerMS() - vc->mouse_timer >= opts->cursor_autohide_delay)) { + (GetTimerMS() - vc->mouse_timer >= opts->vo.cursor_autohide_delay)) { SDL_ShowCursor(0); vc->mouse_hidden = 1; } - } else if (opts->cursor_autohide_delay == -1) { + } else if (opts->vo.cursor_autohide_delay == -1) { if (vc->mouse_hidden) { SDL_ShowCursor(1); vc->mouse_hidden = 0; } - } else if (opts->cursor_autohide_delay == -2) { + } else if (opts->vo.cursor_autohide_delay == -2) { if (!vc->mouse_hidden) { SDL_ShowCursor(0); vc->mouse_hidden = 1; @@ -553,7 +553,7 @@ static void check_events(struct vo *vo) break; } case SDL_MOUSEMOTION: - if (opts->cursor_autohide_delay >= 0) { + if (opts->vo.cursor_autohide_delay >= 0) { SDL_ShowCursor(1); vc->mouse_hidden = 0; vc->mouse_timer = GetTimerMS(); @@ -561,7 +561,7 @@ static void check_events(struct vo *vo) vo_mouse_movement(vo, ev.motion.x, ev.motion.y); break; case SDL_MOUSEBUTTONDOWN: - if (opts->cursor_autohide_delay >= 0) { + if (opts->vo.cursor_autohide_delay >= 0) { SDL_ShowCursor(1); vc->mouse_hidden = 0; vc->mouse_timer = GetTimerMS(); @@ -570,7 +570,7 @@ static void check_events(struct vo *vo) (MP_MOUSE_BTN0 + ev.button.button - 1) | MP_KEY_STATE_DOWN); break; case SDL_MOUSEBUTTONUP: - if (opts->cursor_autohide_delay >= 0) { + if (opts->vo.cursor_autohide_delay >= 0) { SDL_ShowCursor(1); vc->mouse_hidden = 0; vc->mouse_timer = GetTimerMS(); @@ -771,7 +771,7 @@ static int preinit(struct vo *vo, const char *arg) SDL_HINT_DEFAULT); // predefine MPV options (SDL env vars shall be overridden) - if (vo_vsync) + if (vo->opts->vo.vsync) SDL_SetHintWithPriority(SDL_HINT_RENDER_VSYNC, "1", SDL_HINT_OVERRIDE); else @@ -922,9 +922,9 @@ static void update_screeninfo(struct vo *vo) return; } struct MPOpts *opts = vo->opts; - opts->vo_screenwidth = mode.w; - opts->vo_screenheight = mode.h; - aspect_save_screenres(vo, opts->vo_screenwidth, opts->vo_screenheight); + opts->vo.screenwidth = mode.w; + opts->vo.screenheight = mode.h; + aspect_save_screenres(vo, opts->vo.screenwidth, opts->vo.screenheight); } static struct mp_image *get_screenshot(struct vo *vo) @@ -981,7 +981,7 @@ static int control(struct vo *vo, uint32_t request, void *data) { switch (request) { case VOCTRL_FULLSCREEN: - set_fullscreen(vo, !vo_fs); + set_fullscreen(vo, !vo->opts->vo.fs); return 1; case VOCTRL_REDRAW_FRAME: draw_image(vo, NULL); diff --git a/video/out/vo_vdpau.c b/video/out/vo_vdpau.c index 6b35176bfb..02163f70bf 100644 --- a/video/out/vo_vdpau.c +++ b/video/out/vo_vdpau.c @@ -377,7 +377,10 @@ static void resize(struct vo *vo) vc->src_rect_vid.y0 = vc->flip ? src_rect.y1 : src_rect.y0; vc->src_rect_vid.y1 = vc->flip ? src_rect.y0 : src_rect.y1; - int flip_offset_ms = vo_fs ? vc->flip_offset_fs : vc->flip_offset_window; + int flip_offset_ms = vo->opts->vo.fs ? + vc->flip_offset_fs : + vc->flip_offset_window; + vo->flip_queue_offset = flip_offset_ms / 1000.; if (vc->output_surface_width < vo->dwidth diff --git a/video/out/vo_x11.c b/video/out/vo_x11.c index 34c23523ef..9e5f4dc64d 100644 --- a/video/out/vo_x11.c +++ b/video/out/vo_x11.c @@ -49,6 +49,7 @@ #define MODE_BGR 0x2 #include "core/mp_msg.h" +#include "core/options.h" #include "osdep/timer.h" extern int sws_flags; @@ -348,7 +349,7 @@ static int config(struct vo *vo, uint32_t width, uint32_t height, } if (!XMatchVisualInfo(vo->x11->display, vo->x11->screen, p->depth, DirectColor, &p->vinfo) - || (WinID > 0 + || (vo->opts->vo.WinID > 0 && p->vinfo.visualid != XVisualIDFromVisual(p->attribs.visual))) { XMatchVisualInfo(vo->x11->display, vo->x11->screen, p->depth, TrueColor, @@ -365,7 +366,7 @@ static int config(struct vo *vo, uint32_t width, uint32_t height, vo_x11_config_vo_window(vo, &p->vinfo, vo->dx, vo->dy, vo->dwidth, vo->dheight, flags, "x11"); - if (WinID > 0) { + if (vo->opts->vo.WinID > 0) { unsigned depth, dummy_uint; int dummy_int; Window dummy_win; @@ -444,7 +445,7 @@ static void Display_Image(struct priv *p, XImage *myximage, uint8_t *ImageData) p->old_vo_dheight != vo->dheight) && p->zoomFlag) return; - if (WinID == 0) { + if (vo->opts->vo.WinID == 0) { x = vo->dx; y = vo->dy; } @@ -538,6 +539,7 @@ static void flip_page(struct vo *vo) static void draw_image(struct vo *vo, mp_image_t *mpi) { struct priv *p = vo->priv; + struct MPOpts *opts = vo->opts; uint8_t *dst[MP_MAX_PLANES] = {NULL}; int dstStride[MP_MAX_PLANES] = {0}; @@ -553,7 +555,7 @@ static void draw_image(struct vo *vo, mp_image_t *mpi) p->old_vo_dwidth = vo->dwidth; p->old_vo_dheight = vo->dheight; - if (vo_fs) + if (opts->vo.fs) aspect(vo, &newW, &newH, A_ZOOM); if (sws_flags == 0) newW &= (~31); // not needed but, if the user wants the FAST_BILINEAR SCALER, then its needed diff --git a/video/out/vo_xv.c b/video/out/vo_xv.c index bc0920c2eb..46079aaf5f 100644 --- a/video/out/vo_xv.c +++ b/video/out/vo_xv.c @@ -317,7 +317,7 @@ static void xv_print_ck_info(struct xvctx *xv) } } -/* NOTE: If vo_colorkey has bits set after the first 3 low order bytes +/* NOTE: If vo.colorkey has bits set after the first 3 low order bytes * we don't draw anything as this means it was forced to off. */ static int xv_init_colorkey(struct vo *vo) { @@ -328,7 +328,7 @@ static int xv_init_colorkey(struct vo *vo) /* check if colorkeying is needed */ xv_atom = xv_intern_atom_if_exists(vo, "XV_COLORKEY"); - if (xv_atom != None && !(vo_colorkey & 0xFF000000)) { + if (xv_atom != None && !(vo->opts->vo.colorkey & 0xFF000000)) { if (ctx->xv_ck_info.source == CK_SRC_CUR) { int colorkey_ret; @@ -342,14 +342,14 @@ static int xv_init_colorkey(struct vo *vo) return 0; // error getting colorkey } } else { - ctx->xv_colorkey = vo_colorkey; + ctx->xv_colorkey = vo->opts->vo.colorkey; /* check if we have to set the colorkey too */ if (ctx->xv_ck_info.source == CK_SRC_SET) { xv_atom = XInternAtom(display, "XV_COLORKEY", False); rez = XvSetPortAttribute(display, ctx->xv_port, xv_atom, - vo_colorkey); + vo->opts->vo.colorkey); if (rez != Success) { mp_msg(MSGT_VO, MSGL_FATAL, "[xv] Couldn't set colorkey!\n"); return 0; // error setting colorkey diff --git a/video/out/w32_common.c b/video/out/w32_common.c index ab467135cc..3c882de625 100644 --- a/video/out/w32_common.c +++ b/video/out/w32_common.c @@ -150,7 +150,7 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, break; } case WM_SIZING: - if (vo_keepaspect && !vo_fs && WinID < 0) { + if (vo_keepaspect && !vo->opts->vo.fs && vo->otps->vo.WinID < 0) { RECT *rc = (RECT*)lParam; // get client area of the windows if it had the rect rc // (subtracting the window borders) @@ -215,11 +215,11 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, break; } case WM_LBUTTONDOWN: - if (!vo_nomouse_input && (vo_fs || (wParam & MK_CONTROL))) { + if (!vo_nomouse_input && (vo->opts->vo.fs || (wParam & MK_CONTROL))) { mplayer_put_key(vo->key_fifo, MP_MOUSE_BTN0 | mod_state(vo)); break; } - if (!vo_fs) { + if (!vo->opts->vo.fs) { ReleaseCapture(); SendMessage(hWnd, WM_NCLBUTTONDOWN, HTCAPTION, 0); return 0; @@ -281,7 +281,7 @@ int vo_w32_check_events(struct vo *vo) TranslateMessage(&msg); DispatchMessageW(&msg); } - if (WinID >= 0) { + if (vo->opts->vo.WinID >= 0) { BOOL res; RECT r; POINT p; @@ -295,10 +295,10 @@ int vo_w32_check_events(struct vo *vo) if (p.x != w32->window_x || p.y != w32->window_y) { w32->window_x = p.x; w32->window_y = p.y; } - res = GetClientRect(WIN_ID_TO_HWND(WinID), &r); + res = GetClientRect(WIN_ID_TO_HWND(vo->opts->vo.WinID), &r); if (res && (r.right != vo->dwidth || r.bottom != vo->dheight)) MoveWindow(w32->window, 0, 0, r.right, r.bottom, FALSE); - if (!IsWindow(WIN_ID_TO_HWND(WinID))) + if (!IsWindow(WIN_ID_TO_HWND(vo->otps->vo.WinID))) // Window has probably been closed, e.g. due to program crash mplayer_put_key(vo->key_fifo, MP_KEY_CLOSE_WIN); } @@ -311,10 +311,10 @@ static BOOL CALLBACK mon_enum(HMONITOR hmon, HDC hdc, LPRECT r, LPARAM p) struct vo *vo = (void*)p; struct vo_w32_state *w32 = vo->w32; // this defaults to the last screen if specified number does not exist - xinerama_x = r->left; - xinerama_y = r->top; - vo->opts->vo_screenwidth = r->right - r->left; - vo->opts->vo_screenheight = r->bottom - r->top; + vo->xinerama_x = r->left; + vo->xinerama_y = r->top; + vo->opts->vo.screenwidth = r->right - r->left; + vo->opts->vo.screenheight = r->bottom - r->top; if (w32->mon_cnt == w32->mon_id) return FALSE; w32->mon_cnt++; @@ -339,32 +339,32 @@ void w32_update_xinerama_info(struct vo *vo) { struct vo_w32_state *w32 = vo->w32; struct MPOpts *opts = vo->opts; - int screen = vo_fs ? opts->vo_fsscreen_id : opts->vo_screen_id; - xinerama_x = xinerama_y = 0; - if (vo_fs && screen == -2) { + int screen = opts->vo.fs ? opts->vo.fsscreen_id : opts->vo.screen_id; + vo->xinerama_x = vo->xinerama_y = 0; + if (opts->vo.fs && screen == -2) { int tmp; - xinerama_x = GetSystemMetrics(SM_XVIRTUALSCREEN); - xinerama_y = GetSystemMetrics(SM_YVIRTUALSCREEN); + vo->xinerama_x = GetSystemMetrics(SM_XVIRTUALSCREEN); + vo->xinerama_y = GetSystemMetrics(SM_YVIRTUALSCREEN); tmp = GetSystemMetrics(SM_CXVIRTUALSCREEN); - if (tmp) vo->opts->vo_screenwidth = tmp; + if (tmp) vo->opts->vo.screenwidth = tmp; tmp = GetSystemMetrics(SM_CYVIRTUALSCREEN); - if (tmp) vo->opts->vo_screenheight = tmp; + if (tmp) vo->opts->vo.screenheight = tmp; } else if (screen == -1) { MONITORINFO mi; HMONITOR m = MonitorFromWindow(w32->window, MONITOR_DEFAULTTOPRIMARY); mi.cbSize = sizeof(mi); GetMonitorInfoW(m, &mi); - xinerama_x = mi.rcMonitor.left; - xinerama_y = mi.rcMonitor.top; - vo->opts->vo_screenwidth = mi.rcMonitor.right - mi.rcMonitor.left; - vo->opts->vo_screenheight = mi.rcMonitor.bottom - mi.rcMonitor.top; + vo->xinerama_x = mi.rcMonitor.left; + vo->xinerama_y = mi.rcMonitor.top; + vo->opts->vo.screenwidth = mi.rcMonitor.right - mi.rcMonitor.left; + vo->opts->vo.screenheight = mi.rcMonitor.bottom - mi.rcMonitor.top; } else if (screen >= 0) { w32->mon_cnt = 0; w32->mon_id = screen; EnumDisplayMonitors(NULL, NULL, mon_enum, (LONG_PTR)vo); } - aspect_save_screenres(vo, vo->opts->vo_screenwidth, - vo->opts->vo_screenheight); + aspect_save_screenres(vo, vo->opts->vo.screenwidth, + vo->opts->vo.screenheight); } static void updateScreenProperties(struct vo *vo) @@ -380,8 +380,8 @@ static void updateScreenProperties(struct vo *vo) return; } - vo->opts->vo_screenwidth = dm.dmPelsWidth; - vo->opts->vo_screenheight = dm.dmPelsHeight; + vo->opts->vo.screenwidth = dm.dmPelsWidth; + vo->opts->vo.screenheight = dm.dmPelsHeight; w32_update_xinerama_info(vo); } @@ -390,7 +390,7 @@ static DWORD update_style(struct vo *vo, DWORD style) const DWORD NO_FRAME = WS_POPUP; const DWORD FRAME = WS_OVERLAPPEDWINDOW | WS_SIZEBOX; style &= ~(NO_FRAME | FRAME); - style |= (vo_border && !vo_fs) ? FRAME : NO_FRAME; + style |= (vo_border && !vo->opts->vo.fs) ? FRAME : NO_FRAME; return style; } @@ -401,30 +401,30 @@ static int reinit_window_state(struct vo *vo) HWND layer = HWND_NOTOPMOST; RECT r; - if (WinID >= 0) + if (vo->opts->vo.WinID >= 0) return 1; wchar_t *title = mp_from_utf8(NULL, vo_get_window_title(vo)); SetWindowTextW(w32->window, title); talloc_free(title); - bool toggle_fs = w32->current_fs != vo_fs; - w32->current_fs = vo_fs; + bool toggle_fs = w32->current_fs != vo->opts->vo.fs; + w32->current_fs = vo->opts->vo.fs; DWORD style = update_style(vo, GetWindowLong(w32->window, GWL_STYLE)); - if (vo_fs || vo->opts->vo_ontop) + if (vo->opts->vo.fs || vo->opts->vo.ontop) layer = HWND_TOPMOST; // xxx not sure if this can trigger any unwanted messages (WM_MOVE/WM_SIZE) - if (vo_fs) { + if (vo->opts->vo.fs) { while (ShowCursor(0) >= 0) /**/ ; } else { while (ShowCursor(1) < 0) /**/ ; } updateScreenProperties(vo); - if (vo_fs) { + if (vo->opts->vo.fs) { // Save window position and size when switching to fullscreen. if (toggle_fs) { w32->prev_width = vo->dwidth; @@ -434,10 +434,10 @@ static int reinit_window_state(struct vo *vo) mp_msg(MSGT_VO, MSGL_V, "[vo] save window bounds: %d:%d:%d:%d\n", w32->prev_x, w32->prev_y, w32->prev_width, w32->prev_height); } - vo->dwidth = vo->opts->vo_screenwidth; - vo->dheight = vo->opts->vo_screenheight; - w32->window_x = xinerama_x; - w32->window_y = xinerama_y; + vo->dwidth = vo->opts->vo.screenwidth; + vo->dheight = vo->opts->vo.screenheight; + w32->window_x = vo->xinerama_x; + w32->window_y = vo->xinerama_y; } else { if (toggle_fs) { // Restore window position and size when switching from fullscreen. @@ -519,7 +519,7 @@ int vo_w32_config(struct vo *vo, uint32_t width, uint32_t height, w32->o_dheight = height; // the desired size is ignored in wid mode, it always matches the window size. - if (WinID < 0) { + if (vo->opts->vo.WinID < 0) { if (w32->window_bounds_initialized) { // restore vo_dwidth/vo_dheight, which are reset against our will // in vo_config() @@ -544,7 +544,7 @@ int vo_w32_config(struct vo *vo, uint32_t width, uint32_t height, } } - vo_fs = flags & VOFLAG_FULLSCREEN; + vo->opts->vo.fs = flags & VOFLAG_FULLSCREEN; return reinit_window_state(vo); } @@ -594,15 +594,16 @@ int vo_w32_init(struct vo *vo) return 0; } - if (WinID >= 0) { + if (vo->opts->vo.WinID >= 0) { RECT r; - GetClientRect(WIN_ID_TO_HWND(WinID), &r); + GetClientRect(WIN_ID_TO_HWND(vo->opts->vo.WinID), &r); vo->dwidth = r.right; vo->dheight = r.bottom; w32->window = CreateWindowExW(WS_EX_NOPARENTNOTIFY, classname, classname, WS_CHILD | WS_VISIBLE, 0, 0, vo->dwidth, vo->dheight, - WIN_ID_TO_HWND(WinID), 0, hInstance, vo); + WIN_ID_TO_HWND(vo->opts->vo.WinID), + 0, hInstance, vo); } else { w32->window = CreateWindowExW(0, classname, classname, @@ -616,7 +617,7 @@ int vo_w32_init(struct vo *vo) return 0; } - if (WinID >= 0) + if (vo->opts->vo.WinID >= 0) EnableWindow(w32->window, 0); // we don't have proper event handling @@ -625,7 +626,7 @@ int vo_w32_init(struct vo *vo) updateScreenProperties(vo); mp_msg(MSGT_VO, MSGL_V, "vo: win32: running at %dx%d\n", - vo->opts->vo_screenwidth, vo->opts->vo_screenheight); + vo->opts->vo.screenwidth, vo->opts->vo.screenheight); return 1; } @@ -642,7 +643,7 @@ int vo_w32_init(struct vo *vo) void vo_w32_fullscreen(struct vo *vo) { - vo_fs = !vo_fs; + vo->opts->vo.fs = !vo->opts->vo.fs; reinit_window_state(vo); } @@ -664,7 +665,7 @@ void vo_w32_border(struct vo *vo) */ void vo_w32_ontop(struct vo *vo) { - vo->opts->vo_ontop = !vo->opts->vo_ontop; + vo->opts->vo.ontop = !vo->opts->vo.ontop; reinit_window_state(vo); } diff --git a/video/out/wayland_common.c b/video/out/wayland_common.c index 149e304956..319a9abab1 100644 --- a/video/out/wayland_common.c +++ b/video/out/wayland_common.c @@ -770,8 +770,6 @@ static void destroy_display (struct vo_wayland_state *wl) wl_registry_destroy(wl->display->registry); wl_display_flush(wl->display->display); wl_display_disconnect(wl->display->display); - vo_fs = VO_FALSE; - } static void create_window (struct vo_wayland_state *wl) @@ -891,9 +889,9 @@ void vo_wayland_ontop (struct vo *vo) { struct vo_wayland_state *wl = vo->wayland; - vo->opts->vo_ontop = !vo->opts->vo_ontop; + vo->opts->vo.ontop = !vo->opts->vo.ontop; - if (vo_fs) + if (vo->opts->vo.fs) vo_wayland_fullscreen(vo); /* use the already existing code to leave fullscreen mode and go into * toplevel mode */ @@ -920,7 +918,7 @@ void vo_wayland_fullscreen (struct vo *vo) struct wl_output *fs_output = wl->display->fs_output; - if (!vo_fs) { + if (!vo->opts->vo.fs) { wl->window->p_width = wl->window->width; wl->window->p_height = wl->window->height; wl_shell_surface_set_fullscreen(wl->window->shell_surface, @@ -928,7 +926,7 @@ void vo_wayland_fullscreen (struct vo *vo) 0, fs_output); wl->window->type = TYPE_FULLSCREEN; - vo_fs = VO_TRUE; + vo->opts->vo.fs = true; hide_cursor(wl->display); } @@ -938,7 +936,7 @@ void vo_wayland_fullscreen (struct vo *vo) ssurface_schedule_resize(wl->window, wl->window->p_width, wl->window->p_height); wl->window->type = TYPE_TOPLEVEL; - vo_fs = VO_FALSE; + vo->opts->vo.fs = false; show_cursor(wl->display); } @@ -989,7 +987,7 @@ void vo_wayland_update_screeninfo (struct vo *vo) if (!wl->display->output_mode_received) mp_msg(MSGT_VO, MSGL_ERR, "[wayland] no output mode detected\n"); - xinerama_x = xinerama_y = 0; + vo->xinerama_x = vo->xinerama_y = 0; int screen_id = 0; @@ -998,7 +996,7 @@ void vo_wayland_update_screeninfo (struct vo *vo) struct vo_wayland_output *fsscreen_output = NULL; wl_list_for_each_reverse(output, &wl->display->output_list, link) { - if (opts->vo_fsscreen_id == screen_id) + if (opts->vo.fsscreen_id == screen_id) fsscreen_output = output; if (!first_output) @@ -1009,19 +1007,19 @@ void vo_wayland_update_screeninfo (struct vo *vo) if (fsscreen_output) { wl->display->fs_output = fsscreen_output->output; - opts->vo_screenwidth = fsscreen_output->width; - opts->vo_screenheight = fsscreen_output->height; + opts->vo.screenwidth = fsscreen_output->width; + opts->vo.screenheight = fsscreen_output->height; } else { wl->display->fs_output = NULL; /* current output is always 0 */ if (first_output) { - opts->vo_screenwidth = first_output->width; - opts->vo_screenheight = first_output->height; + opts->vo.screenwidth = first_output->width; + opts->vo.screenheight = first_output->height; } } - aspect_save_screenres(vo, opts->vo_screenwidth, opts->vo_screenheight); + aspect_save_screenres(vo, opts->vo.screenwidth, opts->vo.screenheight); } void vo_wayland_update_window_title(struct vo *vo) diff --git a/video/out/x11_common.c b/video/out/x11_common.c index 0fa8f2ad47..52550f469a 100644 --- a/video/out/x11_common.c +++ b/video/out/x11_common.c @@ -131,8 +131,8 @@ static int vo_x11_get_fs_type(struct vo *vo); static void xscreensaver_heartbeat(struct vo_x11_state *x11); static void saver_on(struct vo_x11_state *x11); static void saver_off(struct vo_x11_state *x11); -static void vo_x11_selectinput_witherr(Display *display, Window w, - long event_mask); +static void vo_x11_selectinput_witherr(struct vo *vo, Display *display, + Window w, long event_mask); static void vo_x11_setlayer(struct vo *vo, Window vo_window, int layer); static void vo_x11_create_colormap(struct vo_x11_state *x11, XVisualInfo *vinfo); @@ -175,7 +175,7 @@ static void vo_x11_ewmh_fullscreen(struct vo_x11_state *x11, int action) } } -static void vo_hidecursor(Display *disp, Window win) +static void vo_hidecursor(struct vo *vo, Display *disp, Window win) { Cursor no_ptr; Pixmap bm_no; @@ -183,7 +183,7 @@ static void vo_hidecursor(Display *disp, Window win) Colormap colormap; const char bm_no_data[] = {0, 0, 0, 0, 0, 0, 0, 0}; - if (WinID == 0) + if (vo->opts->vo.WinID == 0) return; // do not hide if playing on the root window colormap = DefaultColormap(disp, DefaultScreen(disp)); @@ -198,9 +198,9 @@ static void vo_hidecursor(Display *disp, Window win) XFreeColors(disp, colormap, &black.pixel, 1, 0); } -static void vo_showcursor(Display *disp, Window win) +static void vo_showcursor(struct vo *vo, Display *disp, Window win) { - if (WinID == 0) + if (vo->opts->vo.WinID == 0) return; XDefineCursor(disp, win, 0); } @@ -308,7 +308,7 @@ static int vo_wm_detect(struct vo *vo) unsigned long nitems; Atom *args = NULL; - if (WinID >= 0) + if (vo->opts->vo.WinID >= 0) return 0; // -- supports layers @@ -374,17 +374,17 @@ void vo_x11_update_screeninfo(struct vo *vo) { struct MPOpts *opts = vo->opts; struct vo_x11_state *x11 = vo->x11; - bool all_screens = vo_fs && opts->vo_fsscreen_id == -2; - xinerama_x = xinerama_y = 0; + bool all_screens = opts->vo.fs && opts->vo.fsscreen_id == -2; + vo->xinerama_x = vo->xinerama_y = 0; if (all_screens) { - opts->vo_screenwidth = x11->ws_width; - opts->vo_screenheight = x11->ws_height; + opts->vo.screenwidth = x11->ws_width; + opts->vo.screenheight = x11->ws_height; } #ifdef CONFIG_XINERAMA - if (opts->vo_screen_id >= -1 && XineramaIsActive(x11->display) && + if (opts->vo.screen_id >= -1 && XineramaIsActive(x11->display) && !all_screens) { - int screen = vo_fs ? opts->vo_fsscreen_id : opts->vo_screen_id; + int screen = opts->vo.fs ? opts->vo.fsscreen_id : opts->vo.screen_id; XineramaScreenInfo *screens; int num_screens; @@ -405,15 +405,15 @@ void vo_x11_update_screeninfo(struct vo *vo) } if (screen < 0) screen = 0; - opts->vo_screenwidth = screens[screen].width; - opts->vo_screenheight = screens[screen].height; - xinerama_x = screens[screen].x_org; - xinerama_y = screens[screen].y_org; + opts->vo.screenwidth = screens[screen].width; + opts->vo.screenheight = screens[screen].height; + vo->xinerama_x = screens[screen].x_org; + vo->xinerama_y = screens[screen].y_org; XFree(screens); } #endif - aspect_save_screenres(vo, opts->vo_screenwidth, opts->vo_screenheight); + aspect_save_screenres(vo, opts->vo.screenwidth, opts->vo.screenheight); } int vo_x11_init(struct vo *vo) @@ -454,16 +454,16 @@ int vo_x11_init(struct vo *vo) init_atoms(vo->x11); - x11->ws_width = opts->vo_screenwidth; - x11->ws_height = opts->vo_screenheight; + x11->ws_width = opts->vo.screenwidth; + x11->ws_height = opts->vo.screenheight; if (!x11->ws_width) x11->ws_width = DisplayWidth(x11->display, x11->screen); if (!x11->ws_height) x11->ws_height = DisplayHeight(x11->display, x11->screen); - opts->vo_screenwidth = x11->ws_width; - opts->vo_screenheight = x11->ws_height; + opts->vo.screenwidth = x11->ws_width; + opts->vo.screenheight = x11->ws_height; if (strncmp(dispName, "unix:", 5) == 0) dispName += 4; @@ -474,7 +474,7 @@ int vo_x11_init(struct vo *vo) else x11->display_is_local = 0; mp_msg(MSGT_VO, MSGL_V, "vo: X11 running at %dx%d (\"%s\" => %s display)\n", - opts->vo_screenwidth, opts->vo_screenheight, dispName, + opts->vo.screenwidth, opts->vo.screenheight, dispName, x11->display_is_local ? "local" : "remote"); x11->wm_type = vo_wm_detect(vo); @@ -483,7 +483,7 @@ int vo_x11_init(struct vo *vo) fstype_dump(x11->fs_type); - if (opts->vo_stop_screensaver) + if (opts->vo.stop_screensaver) saver_off(x11); vo->event_fd = ConnectionNumber(x11->display); @@ -567,10 +567,10 @@ static void vo_x11_decoration(struct vo *vo, int d) Atom vo_MotifHints; MotifWmHints vo_MotifWmHints; - if (!WinID) + if (!vo->opts->vo.WinID) return; - if (vo_fsmode & 8) { + if (vo->opts->vo.fsmode & 8) { XSetTransientForHint(x11->display, x11->window, RootWindow(x11->display, x11->screen)); } @@ -601,12 +601,12 @@ static void vo_x11_decoration(struct vo *vo, int d) d = x11->olddecor; } vo_MotifWmHints.decorations = - d | ((vo_fsmode & 2) ? MWM_DECOR_MENU : 0); + d | ((vo->opts->vo.fsmode & 2) ? MWM_DECOR_MENU : 0); XChangeProperty(x11->display, x11->window, vo_MotifHints,