summaryrefslogtreecommitdiffstats
path: root/libvo
diff options
context:
space:
mode:
Diffstat (limited to 'libvo')
-rw-r--r--libvo/csputils.c14
-rw-r--r--libvo/csputils.h8
2 files changed, 22 insertions, 0 deletions
diff --git a/libvo/csputils.c b/libvo/csputils.c
index b894a2f869..b0255a00dc 100644
--- a/libvo/csputils.c
+++ b/libvo/csputils.c
@@ -361,3 +361,17 @@ void mp_invert_yuv2rgb(float out[3][4], float in[3][4])
out[1][3] = -(out[1][0] * m03 + out[1][1] * m13 + out[1][2] * m23);
out[2][3] = -(out[2][0] * m03 + out[2][1] * m13 + out[2][2] * m23);
}
+
+// Multiply the color in c with the given matrix.
+// c is {R, G, B} or {Y, U, V} (depending on input/output and matrix).
+void mp_map_color(float matrix[3][4], uint8_t c[3])
+{
+ uint8_t in[3] = {c[0], c[1], c[2]};
+ for (int i = 0; i < 3; i++) {
+ double val = matrix[i][3] * 255;
+ for (int x = 0; x < 3; x++)
+ val += matrix[i][x] * in[x];
+ int ival = lrint(val);
+ c[i] = FFMIN(FFMAX(ival, 0), 255);
+ }
+}
diff --git a/libvo/csputils.h b/libvo/csputils.h
index 0dd75b0549..e4fb32e156 100644
--- a/libvo/csputils.h
+++ b/libvo/csputils.h
@@ -73,6 +73,12 @@ struct mp_csp_params {
int input_bits;
};
+#define MP_CSP_PARAMS_DEFAULTS { \
+ .colorspace = MP_CSP_DETAILS_DEFAULTS, \
+ .brightness = 0, .contrast = 1, .hue = 0, .saturation = 1, \
+ .rgamma = 1, .ggamma = 1, .bgamma = 1, \
+ .texture_bits = 8, .input_bits = 8}
+
enum mp_csp_equalizer_param {
MP_CSP_EQ_BRIGHTNESS,
MP_CSP_EQ_CONTRAST,
@@ -143,4 +149,6 @@ void mp_gen_yuv2rgb_map(struct mp_csp_params *params, uint8_t *map, int size);
(minv)[c][3] * (scale))
void mp_invert_yuv2rgb(float out[3][4], float in[3][4]);
+void mp_map_color(float matrix[3][4], uint8_t c[3]);
+
#endif /* MPLAYER_CSPUTILS_H */