From 60aea74f4483661e34b12571add07f8e5e136660 Mon Sep 17 00:00:00 2001 From: wm4 Date: Thu, 24 Oct 2013 22:20:16 +0200 Subject: m_config: refactor option defaults handling Keep track of the default values directly, instead of creating a new instance of the option struct just to get the defaults. Also get rid of the special handling of m_obj_desc.init_options. Instead, handle it purely by the option parser. Originally, I wanted to handle --vo=opengl-hq and --vo=direct3d_shaders with this (by making them aliases to the real VOs with a different preset), but since --vo =opengl-hq=help prints the wrong values (as consequence of the simplification), I'm not doing that, and instead use something different. --- video/out/gl_video.c | 10 ++++++++++ video/out/gl_video.h | 1 + video/out/vo.c | 1 - video/out/vo.h | 3 --- video/out/vo_direct3d.c | 10 ++++++++-- video/out/vo_opengl.c | 11 +++++++---- 6 files changed, 26 insertions(+), 10 deletions(-) (limited to 'video/out') diff --git a/video/out/gl_video.c b/video/out/gl_video.c index 8bab6a5c4c..603f334c9b 100644 --- a/video/out/gl_video.c +++ b/video/out/gl_video.c @@ -275,6 +275,16 @@ static const struct gl_video_opts gl_video_opts_def = { .alpha_mode = 2, }; +const struct gl_video_opts gl_video_opts_hq_def = { + .npot = 1, + .dither_depth = 0, + .dither_size = 6, + .fbo_format = GL_RGB16, + .scale_sep = 1, + .scalers = { "lanczos2", "bilinear" }, + .scaler_params = {NAN, NAN}, + .alpha_mode = 2, +}; static int validate_scaler_opt(const m_option_t *opt, struct bstr name, struct bstr param); diff --git a/video/out/gl_video.h b/video/out/gl_video.h index 3b21edc223..dcec9f3888 100644 --- a/video/out/gl_video.h +++ b/video/out/gl_video.h @@ -49,6 +49,7 @@ struct gl_video_opts { }; extern const struct m_sub_options gl_video_conf; +extern const struct gl_video_opts gl_video_opts_hq_def; struct gl_video; diff --git a/video/out/vo.c b/video/out/vo.c index b29e3f7c95..061fc9caf3 100644 --- a/video/out/vo.c +++ b/video/out/vo.c @@ -123,7 +123,6 @@ static bool get_desc(struct m_obj_desc *dst, int index) .priv_size = vo->priv_size, .priv_defaults = vo->priv_defaults, .options = vo->options, - .init_options = vo->init_option_string, .hidden = vo->encode, .p = vo, }; diff --git a/video/out/vo.h b/video/out/vo.h index 57d5cfb6d0..1777245c96 100644 --- a/video/out/vo.h +++ b/video/out/vo.h @@ -216,9 +216,6 @@ struct vo_driver { // List of options to parse into priv struct (requires privsize to be set) const struct m_option *options; - - // Parse these options before parsing user options - const char *init_option_string; }; struct vo { diff --git a/video/out/vo_direct3d.c b/video/out/vo_direct3d.c index 9ad2322499..cd440f89f6 100644 --- a/video/out/vo_direct3d.c +++ b/video/out/vo_direct3d.c @@ -1720,6 +1720,13 @@ static const struct m_option opts[] = { {0} }; +static const d3d_priv defaults_noshaders = { + .colorspace = MP_CSP_DETAILS_DEFAULTS, + .video_eq = { MP_CSP_EQ_CAPS_COLORMATRIX }, + .opt_disable_shaders = 1, + .opt_disable_textures = 1, +}; + static const d3d_priv defaults = { .colorspace = MP_CSP_DETAILS_DEFAULTS, .video_eq = { MP_CSP_EQ_CAPS_COLORMATRIX }, @@ -1737,9 +1744,8 @@ const struct vo_driver video_out_direct3d = { .flip_page = flip_page, .uninit = uninit, .priv_size = sizeof(d3d_priv), - .priv_defaults = &defaults, + .priv_defaults = &defaults_noshaders, .options = opts, - .init_option_string = "disable-shaders:disable-textures", }; const struct vo_driver video_out_direct3d_shaders = { diff --git a/video/out/vo_opengl.c b/video/out/vo_opengl.c index e1c07d8621..cf1b3b3400 100644 --- a/video/out/vo_opengl.c +++ b/video/out/vo_opengl.c @@ -200,9 +200,10 @@ static bool reparse_cmdline(struct gl_priv *p, char *args) if (strcmp(args, "-") == 0) { opts = p->renderer_opts; } else { - cfg = m_config_new(NULL, sizeof(*opts), gl_video_conf.defaults, - gl_video_conf.opts, - p->vo->driver->init_option_string); + const struct gl_priv *vodef = p->vo->driver->priv_defaults; + const struct gl_video_opts *def = + vodef ? vodef->renderer_opts : gl_video_conf.defaults; + cfg = m_config_new(NULL, sizeof(*opts), def, gl_video_conf.opts); opts = cfg->optstruct; r = m_config_parse_suboptions(cfg, "opengl", args); } @@ -376,6 +377,8 @@ const struct vo_driver video_out_opengl_hq = { .flip_page = flip_page, .uninit = uninit, .priv_size = sizeof(struct gl_priv), + .priv_defaults = &(const struct gl_priv){ + .renderer_opts = (struct gl_video_opts *)&gl_video_opts_hq_def, + }, .options = options, - .init_option_string = "lscale=lanczos2:dither-depth=auto:fbo-format=rgb16", }; -- cgit v1.2.3