From 77f309c94ff17f5627290a7a5a4477db714ecd1e Mon Sep 17 00:00:00 2001 From: wm4 Date: Fri, 25 Oct 2019 00:25:05 +0200 Subject: 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 --- video/out/gpu/video.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'video/out') 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", -- cgit v1.2.3