summaryrefslogtreecommitdiffstats
path: root/video/out/gl_video_shaders.glsl
diff options
context:
space:
mode:
authorNiklas Haas <git@nand.wakku.to>2015-01-06 10:47:26 +0100
committerwm4 <wm4@nowhere>2015-01-09 03:18:21 +0100
commit286340d7d09f72f471d5d1bddcf4d242ed22f4ed (patch)
treee14517963f60820eb38a58dac0d97556dc3e50d0 /video/out/gl_video_shaders.glsl
parent33dd9147ae859b712c52eecfadc8ff97e3d07575 (diff)
downloadmpv-286340d7d09f72f471d5d1bddcf4d242ed22f4ed.tar.bz2
mpv-286340d7d09f72f471d5d1bddcf4d242ed22f4ed.tar.xz
video: Add sigmoidal upscaling to avoid ringing artifacts
This avoids issues when upscaling directly in linear light, and is the recommended way to upscale images according to imagemagick. The default slope of 6.5 offers a reasonable compromise between ringing artifacts eliminated and ringing artifacts introduced by sigmoid-upscaling. Same goes for the default center of 0.75.
Diffstat (limited to 'video/out/gl_video_shaders.glsl')
-rw-r--r--video/out/gl_video_shaders.glsl11
1 files changed, 11 insertions, 0 deletions
diff --git a/video/out/gl_video_shaders.glsl b/video/out/gl_video_shaders.glsl
index 2f5940c26f..4037e42449 100644
--- a/video/out/gl_video_shaders.glsl
+++ b/video/out/gl_video_shaders.glsl
@@ -179,6 +179,10 @@ uniform mat2 dither_trafo;
uniform vec3 inv_gamma;
uniform float input_gamma;
uniform float conv_gamma;
+uniform float sig_center;
+uniform float sig_slope;
+uniform float sig_scale;
+uniform float sig_offset;
uniform float dither_quantization;
uniform float dither_center;
uniform float filter_param1_l;
@@ -425,7 +429,14 @@ void main() {
// The BT.2020 specification says Yc = 0.2627*R + 0.6780*G + 0.0593*B
color.g = (color.g - 0.2627*color.r - 0.0593*color.b)/0.6780;
#endif
+#ifdef USE_SIGMOID
+ color = sig_center - log(1.0/(color * sig_scale + sig_offset) - 1.0)/sig_slope;
+#endif
// Image upscaling happens roughly here
+#ifdef USE_SIGMOID_INV
+ // Inverse of USE_SIGMOID
+ color = (1.0/(1.0 + exp(sig_slope * (sig_center - color))) - sig_offset) / sig_scale;
+#endif
#ifdef USE_GAMMA_POW
// User-defined gamma correction factor (via the gamma sub-option)
color = pow(color, inv_gamma);