gl_common: minor cleanup/refactor
[mplayer.git] / libvo / csputils.h
blob434be4a9a19a5537236e1d8948b3b797608f29e4
1 /*
2 * This file is part of MPlayer.
4 * MPlayer is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * MPlayer is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 * You can alternatively redistribute this file and/or
19 * modify it under the terms of the GNU Lesser General Public
20 * License as published by the Free Software Foundation; either
21 * version 2.1 of the License, or (at your option) any later version.
24 #ifndef MPLAYER_CSPUTILS_H
25 #define MPLAYER_CSPUTILS_H
27 #include <stdint.h>
30 /* NOTE: the csp and levels AUTO values are converted to specific ones
31 * above vf/vo level. At least vf_scale relies on all valid settings being
32 * nonzero at vf/vo level.
35 enum mp_csp {
36 MP_CSP_AUTO,
37 MP_CSP_BT_601,
38 MP_CSP_BT_709,
39 MP_CSP_SMPTE_240M,
40 MP_CSP_COUNT
43 // Any enum mp_csp value is a valid index (except MP_CSP_COUNT)
44 extern char * const mp_csp_names[MP_CSP_COUNT];
46 enum mp_csp_levels {
47 MP_CSP_LEVELS_AUTO,
48 MP_CSP_LEVELS_TV,
49 MP_CSP_LEVELS_PC,
50 MP_CSP_LEVELS_COUNT,
53 struct mp_csp_details {
54 enum mp_csp format;
55 enum mp_csp_levels levels_in; // encoded video
56 enum mp_csp_levels levels_out; // output device
59 // initializer for struct mp_csp_details that contains reasonable defaults
60 #define MP_CSP_DETAILS_DEFAULTS {MP_CSP_BT_601, MP_CSP_LEVELS_TV, MP_CSP_LEVELS_PC}
62 struct mp_csp_params {
63 struct mp_csp_details colorspace;
64 float brightness;
65 float contrast;
66 float hue;
67 float saturation;
68 float rgamma;
69 float ggamma;
70 float bgamma;
71 int texture_bits;
72 int input_bits;
75 enum mp_csp_equalizer_param {
76 MP_CSP_EQ_BRIGHTNESS,
77 MP_CSP_EQ_CONTRAST,
78 MP_CSP_EQ_HUE,
79 MP_CSP_EQ_SATURATION,
80 MP_CSP_EQ_GAMMA,
81 MP_CSP_EQ_COUNT,
84 #define MP_CSP_EQ_CAPS_COLORMATRIX \
85 ( (1 << MP_CSP_EQ_BRIGHTNESS) \
86 | (1 << MP_CSP_EQ_CONTRAST) \
87 | (1 << MP_CSP_EQ_HUE) \
88 | (1 << MP_CSP_EQ_SATURATION) )
90 #define MP_CSP_EQ_CAPS_GAMMA (1 << MP_CSP_EQ_GAMMA)
92 extern char * const mp_csp_equalizer_names[MP_CSP_EQ_COUNT];
94 // Default initialization with 0 is enough, except for the capabilities field
95 struct mp_csp_equalizer {
96 // Bit field of capabilities. For example (1 << MP_CSP_EQ_HUE) means hue
97 // support is available.
98 int capabilities;
99 // Value for each property is in the range [-100, 100].
100 // 0 is default, meaning neutral or no change.
101 int values[MP_CSP_EQ_COUNT];
105 void mp_csp_copy_equalizer_values(struct mp_csp_params *params,
106 const struct mp_csp_equalizer *eq);
108 int mp_csp_equalizer_set(struct mp_csp_equalizer *eq, const char *property,
109 int value);
111 int mp_csp_equalizer_get(struct mp_csp_equalizer *eq, const char *property,
112 int *out_value);
114 enum mp_csp mp_csp_guess_colorspace(int width, int height);
116 void mp_gen_gamma_map(unsigned char *map, int size, float gamma);
117 #define ROW_R 0
118 #define ROW_G 1
119 #define ROW_B 2
120 #define COL_Y 0
121 #define COL_U 1
122 #define COL_V 2
123 #define COL_C 3
124 void mp_get_yuv2rgb_coeffs(struct mp_csp_params *params, float yuv2rgb[3][4]);
125 void mp_gen_yuv2rgb_map(struct mp_csp_params *params, uint8_t *map, int size);
127 #endif /* MPLAYER_CSPUTILS_H */