diff options
author | wm4 <wm4@nowhere> | 2019-10-25 00:25:05 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2019-10-25 00:25:05 +0200 |
commit | 77f309c94ff17f5627290a7a5a4477db714ecd1e (patch) | |
tree | 196c04befa3756aa12906634be6fa2c2e136a205 /video/out/gpu | |
parent | b0827b4dc4417de36e596c5adde9cd28605fdf81 (diff) | |
download | mpv-77f309c94ff17f5627290a7a5a4477db714ecd1e.tar.bz2 mpv-77f309c94ff17f5627290a7a5a4477db714ecd1e.tar.xz |
vo_gpu, options: don't return NaN through API
Internally, vo_gpu uses NaN for some options to indicate a default value
that is different depending on the context (e.g. different scalers).
There are 2 problems with this:
1. you couldn't reset the options to their defaults
2. NaN is a damn mess and shouldn't be part of the API
The option parser already rejected NaN explicitly, which is why 1.
didn't work. Regarding 2., JSON might be a good example, and actually
caused a bug report.
Fix this by mapping NaN to the special value "default". I think I'd
prefer other mechanisms (maybe just having every scaler expose separate
options?), but for now this will do. See you in a future commit, which
painfully deprecates this and replaces it with something else.
I refrained from using "no" (my favorite magic value for "unset" etc.)
because then I'd have e.g. make --no-scale-param1 work, which in
addition to a lot of effort looks dumb and nobody will use it.
Here's also an apology for the shitty added test script.
Fixes: #6691
Diffstat (limited to 'video/out/gpu')
-rw-r--r-- | video/out/gpu/video.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/video/out/gpu/video.c b/video/out/gpu/video.c index ea47b308d3..08cd08ebe4 100644 --- a/video/out/gpu/video.c +++ b/video/out/gpu/video.c @@ -342,14 +342,18 @@ static int validate_error_diffusion_opt(struct mp_log *log, const m_option_t *op #define OPT_BASE_STRUCT struct gl_video_opts +// Use for options which use NAN for defaults. +#define OPT_FLOATDEF(name, var, flags) \ + OPT_FLOAT(name, var, (flags) | M_OPT_DEFAULT_NAN) + #define SCALER_OPTS(n, i) \ OPT_STRING_VALIDATE(n, scaler[i].kernel.name, 0, validate_scaler_opt), \ - OPT_FLOAT(n"-param1", scaler[i].kernel.params[0], 0), \ - OPT_FLOAT(n"-param2", scaler[i].kernel.params[1], 0), \ + OPT_FLOATDEF(n"-param1", scaler[i].kernel.params[0], 0), \ + OPT_FLOATDEF(n"-param2", scaler[i].kernel.params[1], 0), \ OPT_FLOAT(n"-blur", scaler[i].kernel.blur, 0), \ OPT_FLOATRANGE(n"-cutoff", scaler[i].cutoff, 0, 0.0, 1.0), \ OPT_FLOATRANGE(n"-taper", scaler[i].kernel.taper, 0, 0.0, 1.0), \ - OPT_FLOAT(n"-wparam", scaler[i].window.params[0], 0), \ + OPT_FLOATDEF(n"-wparam", scaler[i].window.params[0], 0), \ OPT_FLOAT(n"-wblur", scaler[i].window.blur, 0), \ OPT_FLOATRANGE(n"-wtaper", scaler[i].window.taper, 0, 0.0, 1.0), \ OPT_FLOATRANGE(n"-clamp", scaler[i].clamp, 0, 0.0, 1.0), \ @@ -383,7 +387,7 @@ const struct m_sub_options gl_video_conf = { tone_map.scene_threshold_low, 0, 0, 20.0), OPT_FLOATRANGE("hdr-scene-threshold-high", tone_map.scene_threshold_high, 0, 0, 20.0), - OPT_FLOAT("tone-mapping-param", tone_map.curve_param, 0), + OPT_FLOATDEF("tone-mapping-param", tone_map.curve_param, 0), OPT_FLOATRANGE("tone-mapping-max-boost", tone_map.max_boost, 0, 1.0, 10.0), OPT_FLOAT("tone-mapping-desaturate", tone_map.desat, 0), OPT_FLOATRANGE("tone-mapping-desaturate-exponent", |