diff options
author | wm4 <wm4@nowhere> | 2017-08-22 17:01:35 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2017-08-22 17:01:35 +0200 |
commit | 03cf150ff3516789d581214177f291d46310aaf4 (patch) | |
tree | 2f352bf9c6d36e10001accdb72cef2d7683ab04a /video/csputils.c | |
parent | d67aa6da6bbd3cba9eabd12cda4703821fecc7a1 (diff) | |
download | mpv-03cf150ff3516789d581214177f291d46310aaf4.tar.bz2 mpv-03cf150ff3516789d581214177f291d46310aaf4.tar.xz |
video: redo video equalizer option handling
I really wouldn't care much about this, but some parts of the core code
are under HAVE_GPL, so there's some need to get rid of it. Simply turn
the video equalizer from its current fine-grained handling with vf/vo
fallbacks into global options. This makes updating them much simpler.
This removes any possibility of applying video equalizers in filters,
which affects vf_scale, and the previously removed vf_eq. Not a big
loss, since the preferred VOs have this builtin.
Remove video equalizer handling from vo_direct3d, vo_sdl, vo_vaapi, and
vo_xv. I'm not going to waste my time on these legacy VOs.
vo.eq_opts_cache exists _only_ to send a VOCTRL_SET_EQUALIZER, which
exists _only_ to trigger a redraw. This seems silly, but for now I feel
like this is less of a pain. The rest of the equalizer using code is
self-updating.
See commit 96b906a51d5 for how some video equalizer code was GPL only.
Some command line option names and ranges can probably be traced back to
a GPL only committer, but we don't consider these copyrightable.
Diffstat (limited to 'video/csputils.c')
-rw-r--r-- | video/csputils.c | 67 |
1 files changed, 33 insertions, 34 deletions
diff --git a/video/csputils.c b/video/csputils.c index e9dc8e654d..d9a5c29491 100644 --- a/video/csputils.c +++ b/video/csputils.c @@ -31,6 +31,7 @@ #include "mp_image.h" #include "csputils.h" +#include "options/m_config.h" #include "options/m_option.h" const struct m_opt_choice_alternatives mp_csp_names[] = { @@ -96,15 +97,6 @@ const struct m_opt_choice_alternatives mp_csp_light_names[] = { {0} }; -const char *const mp_csp_equalizer_names[MP_CSP_EQ_COUNT] = { - "brightness", - "contrast", - "hue", - "saturation", - "gamma", - "output-levels", -}; - const struct m_opt_choice_alternatives mp_chroma_names[] = { {"unknown", MP_CHROMA_AUTO}, {"mpeg2/4/h264",MP_CHROMA_LEFT}, @@ -817,9 +809,25 @@ bool mp_colorspace_equal(struct mp_colorspace c1, struct mp_colorspace c2) c1.sig_peak == c2.sig_peak; } +#define OPT_BASE_STRUCT struct mp_csp_equalizer_opts + +const struct m_sub_options mp_csp_equalizer_conf = { + .opts = (const m_option_t[]) { + OPT_INTRANGE("brightness", values[MP_CSP_EQ_BRIGHTNESS], 0, -100, 100), + OPT_INTRANGE("saturation", values[MP_CSP_EQ_SATURATION], 0, -100, 100), + OPT_INTRANGE("contrast", values[MP_CSP_EQ_CONTRAST], 0, -100, 100), + OPT_INTRANGE("hue", values[MP_CSP_EQ_HUE], 0, -100, 100), + OPT_INTRANGE("gamma", values[MP_CSP_EQ_GAMMA], 0, -100, 100), + OPT_CHOICE_C("video-output-levels", values[MP_CSP_EQ_OUTPUT_LEVELS], 0, + mp_csp_levels_names), + {0} + }, + .size = sizeof(struct mp_csp_equalizer_opts), +}; + // Copy settings from eq into params. void mp_csp_copy_equalizer_values(struct mp_csp_params *params, - const struct mp_csp_equalizer *eq) + const struct mp_csp_equalizer_opts *eq) { params->brightness = eq->values[MP_CSP_EQ_BRIGHTNESS] / 100.0; params->contrast = (eq->values[MP_CSP_EQ_CONTRAST] + 100) / 100.0; @@ -829,37 +837,28 @@ void mp_csp_copy_equalizer_values(struct mp_csp_params *params, params->levels_out = eq->values[MP_CSP_EQ_OUTPUT_LEVELS]; } -static int find_eq(int capabilities, const char *name) +struct mp_csp_equalizer_state *mp_csp_equalizer_create(void *ta_parent, + struct mpv_global *global) { - for (int i = 0; i < MP_CSP_EQ_COUNT; i++) { - if (strcmp(name, mp_csp_equalizer_names[i]) == 0) - return ((1 << i) & capabilities) ? i : -1; - } - return -1; + struct m_config_cache *c = m_config_cache_alloc(ta_parent, global, + &mp_csp_equalizer_conf); + // The terrible, terrible truth. + return (struct mp_csp_equalizer_state *)c; } -int mp_csp_equalizer_get(struct mp_csp_equalizer *eq, const char *property, - int *out_value) +bool mp_csp_equalizer_state_changed(struct mp_csp_equalizer_state *state) { - int index = find_eq(eq->capabilities, property); - if (index < 0) - return -1; - - *out_value = eq->values[index]; - - return 0; + struct m_config_cache *c = (struct m_config_cache *)state; + return m_config_cache_update(c); } -int mp_csp_equalizer_set(struct mp_csp_equalizer *eq, const char *property, - int value) +void mp_csp_equalizer_state_get(struct mp_csp_equalizer_state *state, + struct mp_csp_params *params) { - int index = find_eq(eq->capabilities, property); - if (index < 0) - return 0; - - eq->values[index] = value; - - return 1; + struct m_config_cache *c = (struct m_config_cache *)state; + m_config_cache_update(c); + struct mp_csp_equalizer_opts *opts = c->opts; + mp_csp_copy_equalizer_values(params, opts); } void mp_invert_cmat(struct mp_cmat *out, struct mp_cmat *in) |