diff options
author | Niklas Haas <git@haasn.xyz> | 2018-02-10 22:42:11 +0100 |
---|---|---|
committer | Kevin Mitchell <kevmitch@gmail.com> | 2018-02-11 16:45:20 -0800 |
commit | 4c2edecd7dc83caaaa37c797d66d9077e105eaee (patch) | |
tree | 04cbd92fce8cf35c91245eec0f2dbc146909fa77 /video/out/gpu/video.h | |
parent | 20df21746add582e703b71b4ec63ce64c0e055d4 (diff) | |
download | mpv-4c2edecd7dc83caaaa37c797d66d9077e105eaee.tar.bz2 mpv-4c2edecd7dc83caaaa37c797d66d9077e105eaee.tar.xz |
vo_gpu: refactor HDR peak detection algorithm
The major changes are as follows:
1. Use `uint32_t` instead of `unsigned int` for the SSBO size
calculation. This doesn't really matter, since a too-big buffer will
still work just fine, but since `uint` is a 32-bit integer by
definition this is the correct way to do it.
2. Pre-divide the frame_sum by the num_wg immediately at the end of a
frame. This change was made to prevent overflow. At 4K screen size,
this code is currently already very at risk of overflow, especially
once I started playing with longer averaging sizes. Pre-dividing this
out makes it just about fit into 32-bit even for worst-case PQ
content. (It's technically also faster and easier this way, so I
should have done it to begin with). Rename `frame_sum` to `frame_avg`
to clearly signal the change in semantics.
3. Implement a scene transition detection algorithm. This basically
compares the current frame's average brightness against the
(averaged) value of the past frames. If it exceeds a threshold, which
I experimentally configured, we reset the peak detection SSBO's state
immediately - so that it just contains the current frame. This
prevents annoying "eye adaptation"-like effects on scene transitions.
4. As a result of the previous change, we can now use a much larger
buffer size by default, which results in a more stable and less
flickery result. I experimented with values between 20 and 256 and
settled on the new value of 64. (I also switched to a power-of-2
array size, because I like powers of two)
Diffstat (limited to 'video/out/gpu/video.h')
-rw-r--r-- | video/out/gpu/video.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/video/out/gpu/video.h b/video/out/gpu/video.h index 71666059f9..dad6d447f6 100644 --- a/video/out/gpu/video.h +++ b/video/out/gpu/video.h @@ -96,7 +96,7 @@ enum tone_mapping { }; // How many frames to average over for HDR peak detection -#define PEAK_DETECT_FRAMES 20 +#define PEAK_DETECT_FRAMES 63 struct gl_video_opts { int dumb_mode; |