mirror of
https://github.com/mpv-player/mpv
synced 2025-01-15 11:31:02 +00:00
vo_gpu: use dB units for scene change detection
Rather than the linear cd/m^2 units, these (relative) logarithmic units lend themselves much better to actually detecting scene changes, especially since the scene averaging was changed to also work logarithmically.
This commit is contained in:
parent
b4b719e337
commit
3f1bc25d4d
@ -5264,9 +5264,9 @@ The following video options are currently all specific to ``--vo=gpu`` and
|
||||
to excessive flicker. (In signal theory terms, this controls the time
|
||||
constant "tau" of an IIR low pass filter)
|
||||
|
||||
``--hdr-scene-threshold-low=<0..10000>``, ``--hdr-scene-threshold-high=<0..10000>``
|
||||
The lower and upper thresholds (in cd/m^2) for a brightness difference to
|
||||
be considered a scene change (default: 50 low, 200 high). This is only
|
||||
``--hdr-scene-threshold-low=<0.0..100.0>``, ``--hdr-scene-threshold-high=<0.0..100.0>``
|
||||
The lower and upper thresholds (in dB) for a brightness difference
|
||||
to be considered a scene change (default: 5.5 low, 10.0 high). This is only
|
||||
relevant when ``--hdr-compute-peak`` is enabled. Normally, small
|
||||
fluctuations in the frame brightness are compensated for by the peak
|
||||
averaging mechanism, but for large jumps in the brightness this can result
|
||||
|
@ -318,8 +318,8 @@ static const struct gl_video_opts gl_video_opts_def = {
|
||||
.curve_param = NAN,
|
||||
.max_boost = 1.0,
|
||||
.decay_rate = 100.0,
|
||||
.scene_threshold_low = 50,
|
||||
.scene_threshold_high = 200,
|
||||
.scene_threshold_low = 5.5,
|
||||
.scene_threshold_high = 10.0,
|
||||
.desat = 0.75,
|
||||
.desat_exp = 1.5,
|
||||
},
|
||||
@ -372,10 +372,10 @@ const struct m_sub_options gl_video_conf = {
|
||||
{"yes", 1},
|
||||
{"no", -1})),
|
||||
OPT_FLOATRANGE("hdr-peak-decay-rate", tone_map.decay_rate, 0, 1.0, 1000.0),
|
||||
OPT_INTRANGE("hdr-scene-threshold-low",
|
||||
tone_map.scene_threshold_low, 0, 0, 10000),
|
||||
OPT_INTRANGE("hdr-scene-threshold-high",
|
||||
tone_map.scene_threshold_high, 0, 0, 10000),
|
||||
OPT_FLOATRANGE("hdr-scene-threshold-low",
|
||||
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_FLOATRANGE("tone-mapping-max-boost", tone_map.max_boost, 0, 1.0, 10.0),
|
||||
OPT_FLOAT("tone-mapping-desaturate", tone_map.desat, 0),
|
||||
|
@ -101,8 +101,8 @@ struct gl_tone_map_opts {
|
||||
float max_boost;
|
||||
int compute_peak;
|
||||
float decay_rate;
|
||||
int scene_threshold_low;
|
||||
int scene_threshold_high;
|
||||
float scene_threshold_low;
|
||||
float scene_threshold_high;
|
||||
float desat;
|
||||
float desat_exp;
|
||||
int gamut_warning; // bool
|
||||
|
@ -613,9 +613,10 @@ static void hdr_update_peak(struct gl_shader_cache *sc,
|
||||
GLSLF(" average += %f * (cur - average);\n", decay);
|
||||
|
||||
// Scene change hysteresis
|
||||
GLSLF(" float weight = smoothstep(%f, %f, abs(cur.x - average.x));\n",
|
||||
(float) opts->scene_threshold_low / MP_REF_WHITE,
|
||||
(float) opts->scene_threshold_high / MP_REF_WHITE);
|
||||
float log_db = 10.0 / log(10.0);
|
||||
GLSLF(" float weight = smoothstep(%f, %f, abs(log(cur.x / average.x)));\n",
|
||||
opts->scene_threshold_low / log_db,
|
||||
opts->scene_threshold_high / log_db);
|
||||
GLSL( average = mix(average, cur, weight);)
|
||||
|
||||
// Reset SSBO state for the next frame
|
||||
|
Loading…
Reference in New Issue
Block a user