summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-04-29 21:32:19 +0200
committerDiogo Franco (Kovensky) <diogomfranco@gmail.com>2015-05-07 10:40:35 +0900
commitaf930e2a2e3f33aa11a0fea3d6c3e3c7344b21fb (patch)
tree87284dab683d5a3e407b518f8e7b54b38f1d02b8
parent5f4e4ede895509a0c563a927932a0a908c8dafd1 (diff)
downloadmpv-af930e2a2e3f33aa11a0fea3d6c3e3c7344b21fb.tar.bz2
mpv-af930e2a2e3f33aa11a0fea3d6c3e3c7344b21fb.tar.xz
csputils: apply contrast equalizer in RGB
It's weird that this basically adjusts the contrast between luma and chroma, and not blackness. This is more in line with the behavior of libswscale, the vdpau "procamp" (which mpv doesn't use), and Xv. (cherry picked from commit 0600d378f9afb20d92e75d26c0df7d255e1df554)
-rw-r--r--video/csputils.c11
1 files changed, 3 insertions, 8 deletions
diff --git a/video/csputils.c b/video/csputils.c
index a4d896f598..f42cfb398b 100644
--- a/video/csputils.c
+++ b/video/csputils.c
@@ -671,6 +671,9 @@ void mp_get_yuv2rgb_coeffs(struct mp_csp_params *params, struct mp_cmat *m)
abort();
}
+ rgblev.min = (rgblev.min + params->brightness) * params->contrast;
+ rgblev.max = (rgblev.max + params->brightness) * params->contrast;
+
double ymul = (rgblev.max - rgblev.min) / (yuvlev.ymax - yuvlev.ymin);
double cmul = (rgblev.max - rgblev.min) / (yuvlev.cmid - yuvlev.cmin) / 2;
for (int i = 0; i < 3; i++) {
@@ -682,14 +685,6 @@ void mp_get_yuv2rgb_coeffs(struct mp_csp_params *params, struct mp_cmat *m)
-(m->m[i][1] + m->m[i][2]) * yuvlev.cmid;
}
- // Brightness adds a constant to output R,G,B.
- // Contrast scales Y around 1/2 (not 0 in this implementation).
- for (int i = 0; i < 3; i++) {
- m->c[i] += params->brightness;
- m->m[i][0] *= params->contrast;
- m->c[i] += (rgblev.max-rgblev.min) * (1 - params->contrast)/2;
- }
-
int in_bits = FFMAX(params->int_bits_in, 1);
int out_bits = FFMAX(params->int_bits_out, 1);
double in_scale = (1 << in_bits) - 1.0;