Mercurial > mplayer.hg
annotate libvo/csputils.c @ 30163:257ef2adfd66
Add multiple inclusion guards to all mp3lib headers.
author | diego |
---|---|
date | Mon, 04 Jan 2010 14:42:59 +0000 |
parents | 28cbec606cbb |
children | 51ee44af067b |
rev | line source |
---|---|
30108
0898adc64a6f
Extract functions to generate yuv->rgb matrices and lookup tables into a
reimar
parents:
diff
changeset
|
1 /* |
0898adc64a6f
Extract functions to generate yuv->rgb matrices and lookup tables into a
reimar
parents:
diff
changeset
|
2 * Common code related to colorspaces and conversion |
0898adc64a6f
Extract functions to generate yuv->rgb matrices and lookup tables into a
reimar
parents:
diff
changeset
|
3 * |
0898adc64a6f
Extract functions to generate yuv->rgb matrices and lookup tables into a
reimar
parents:
diff
changeset
|
4 * Copyleft (C) 2009 Reimar Döffinger <Reimar.Doeffinger@gmx.de> |
0898adc64a6f
Extract functions to generate yuv->rgb matrices and lookup tables into a
reimar
parents:
diff
changeset
|
5 * |
0898adc64a6f
Extract functions to generate yuv->rgb matrices and lookup tables into a
reimar
parents:
diff
changeset
|
6 * This file is part of MPlayer. |
0898adc64a6f
Extract functions to generate yuv->rgb matrices and lookup tables into a
reimar
parents:
diff
changeset
|
7 * |
0898adc64a6f
Extract functions to generate yuv->rgb matrices and lookup tables into a
reimar
parents:
diff
changeset
|
8 * MPlayer is free software; you can redistribute it and/or modify |
0898adc64a6f
Extract functions to generate yuv->rgb matrices and lookup tables into a
reimar
parents:
diff
changeset
|
9 * it under the terms of the GNU General Public License as published by |
0898adc64a6f
Extract functions to generate yuv->rgb matrices and lookup tables into a
reimar
parents:
diff
changeset
|
10 * the Free Software Foundation; either version 2 of the License, or |
0898adc64a6f
Extract functions to generate yuv->rgb matrices and lookup tables into a
reimar
parents:
diff
changeset
|
11 * (at your option) any later version. |
0898adc64a6f
Extract functions to generate yuv->rgb matrices and lookup tables into a
reimar
parents:
diff
changeset
|
12 * |
0898adc64a6f
Extract functions to generate yuv->rgb matrices and lookup tables into a
reimar
parents:
diff
changeset
|
13 * MPlayer is distributed in the hope that it will be useful, |
0898adc64a6f
Extract functions to generate yuv->rgb matrices and lookup tables into a
reimar
parents:
diff
changeset
|
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
0898adc64a6f
Extract functions to generate yuv->rgb matrices and lookup tables into a
reimar
parents:
diff
changeset
|
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
0898adc64a6f
Extract functions to generate yuv->rgb matrices and lookup tables into a
reimar
parents:
diff
changeset
|
16 * GNU General Public License for more details. |
0898adc64a6f
Extract functions to generate yuv->rgb matrices and lookup tables into a
reimar
parents:
diff
changeset
|
17 * |
0898adc64a6f
Extract functions to generate yuv->rgb matrices and lookup tables into a
reimar
parents:
diff
changeset
|
18 * You should have received a copy of the GNU General Public License along |
0898adc64a6f
Extract functions to generate yuv->rgb matrices and lookup tables into a
reimar
parents:
diff
changeset
|
19 * with MPlayer; if not, write to the Free Software Foundation, Inc., |
0898adc64a6f
Extract functions to generate yuv->rgb matrices and lookup tables into a
reimar
parents:
diff
changeset
|
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
0898adc64a6f
Extract functions to generate yuv->rgb matrices and lookup tables into a
reimar
parents:
diff
changeset
|
21 */ |
0898adc64a6f
Extract functions to generate yuv->rgb matrices and lookup tables into a
reimar
parents:
diff
changeset
|
22 |
0898adc64a6f
Extract functions to generate yuv->rgb matrices and lookup tables into a
reimar
parents:
diff
changeset
|
23 #include <stdint.h> |
0898adc64a6f
Extract functions to generate yuv->rgb matrices and lookup tables into a
reimar
parents:
diff
changeset
|
24 #include <math.h> |
0898adc64a6f
Extract functions to generate yuv->rgb matrices and lookup tables into a
reimar
parents:
diff
changeset
|
25 #include "libavutil/common.h" |
0898adc64a6f
Extract functions to generate yuv->rgb matrices and lookup tables into a
reimar
parents:
diff
changeset
|
26 #include "csputils.h" |
0898adc64a6f
Extract functions to generate yuv->rgb matrices and lookup tables into a
reimar
parents:
diff
changeset
|
27 |
0898adc64a6f
Extract functions to generate yuv->rgb matrices and lookup tables into a
reimar
parents:
diff
changeset
|
28 /** |
0898adc64a6f
Extract functions to generate yuv->rgb matrices and lookup tables into a
reimar
parents:
diff
changeset
|
29 * \brief little helper function to create a lookup table for gamma |
0898adc64a6f
Extract functions to generate yuv->rgb matrices and lookup tables into a
reimar
parents:
diff
changeset
|
30 * \param map buffer to create map into |
0898adc64a6f
Extract functions to generate yuv->rgb matrices and lookup tables into a
reimar
parents:
diff
changeset
|
31 * \param size size of buffer |
0898adc64a6f
Extract functions to generate yuv->rgb matrices and lookup tables into a
reimar
parents:
diff
changeset
|
32 * \param gamma gamma value |
0898adc64a6f
Extract functions to generate yuv->rgb matrices and lookup tables into a
reimar
parents:
diff
changeset
|
33 */ |
0898adc64a6f
Extract functions to generate yuv->rgb matrices and lookup tables into a
reimar
parents:
diff
changeset
|
34 void mp_gen_gamma_map(uint8_t *map, int size, float gamma) { |
0898adc64a6f
Extract functions to generate yuv->rgb matrices and lookup tables into a
reimar
parents:
diff
changeset
|
35 int i; |
0898adc64a6f
Extract functions to generate yuv->rgb matrices and lookup tables into a
reimar
parents:
diff
changeset
|
36 if (gamma == 1.0) { |
0898adc64a6f
Extract functions to generate yuv->rgb matrices and lookup tables into a
reimar
parents:
diff
changeset
|
37 for (i = 0; i < size; i++) |
0898adc64a6f
Extract functions to generate yuv->rgb matrices and lookup tables into a
reimar
parents:
diff
changeset
|
38 map[i] = 255 * i / (size - 1); |
0898adc64a6f
Extract functions to generate yuv->rgb matrices and lookup tables into a
reimar
parents:
diff
changeset
|
39 return; |
0898adc64a6f
Extract functions to generate yuv->rgb matrices and lookup tables into a
reimar
parents:
diff
changeset
|
40 } |
0898adc64a6f
Extract functions to generate yuv->rgb matrices and lookup tables into a
reimar
parents:
diff
changeset
|
41 gamma = 1.0 / gamma; |
0898adc64a6f
Extract functions to generate yuv->rgb matrices and lookup tables into a
reimar
parents:
diff
changeset
|
42 for (i = 0; i < size; i++) { |
0898adc64a6f
Extract functions to generate yuv->rgb matrices and lookup tables into a
reimar
parents:
diff
changeset
|
43 float tmp = (float)i / (size - 1.0); |
0898adc64a6f
Extract functions to generate yuv->rgb matrices and lookup tables into a
reimar
parents:
diff
changeset
|
44 tmp = pow(tmp, gamma); |
0898adc64a6f
Extract functions to generate yuv->rgb matrices and lookup tables into a
reimar
parents:
diff
changeset
|
45 if (tmp > 1.0) tmp = 1.0; |
0898adc64a6f
Extract functions to generate yuv->rgb matrices and lookup tables into a
reimar
parents:
diff
changeset
|
46 if (tmp < 0.0) tmp = 0.0; |
0898adc64a6f
Extract functions to generate yuv->rgb matrices and lookup tables into a
reimar
parents:
diff
changeset
|
47 map[i] = 255 * tmp; |
0898adc64a6f
Extract functions to generate yuv->rgb matrices and lookup tables into a
reimar
parents:
diff
changeset
|
48 } |
0898adc64a6f
Extract functions to generate yuv->rgb matrices and lookup tables into a
reimar
parents:
diff
changeset
|
49 } |
0898adc64a6f
Extract functions to generate yuv->rgb matrices and lookup tables into a
reimar
parents:
diff
changeset
|
50 |
0898adc64a6f
Extract functions to generate yuv->rgb matrices and lookup tables into a
reimar
parents:
diff
changeset
|
51 /** |
0898adc64a6f
Extract functions to generate yuv->rgb matrices and lookup tables into a
reimar
parents:
diff
changeset
|
52 * \brief get the coefficients of the yuv -> rgb conversion matrix |
0898adc64a6f
Extract functions to generate yuv->rgb matrices and lookup tables into a
reimar
parents:
diff
changeset
|
53 * \param params struct specifying the properties of the conversion like brightness, ... |
0898adc64a6f
Extract functions to generate yuv->rgb matrices and lookup tables into a
reimar
parents:
diff
changeset
|
54 * \param yuv2rgb array to store coefficients into |
30121
28cbec606cbb
Slightly generalize code to generate YUV->RGB conversion table and add
reimar
parents:
30109
diff
changeset
|
55 * |
28cbec606cbb
Slightly generalize code to generate YUV->RGB conversion table and add
reimar
parents:
30109
diff
changeset
|
56 * Note: contrast, hue and saturation will only work as expected with YUV formats, |
28cbec606cbb
Slightly generalize code to generate YUV->RGB conversion table and add
reimar
parents:
30109
diff
changeset
|
57 * not with e.g. MP_CSP_XYZ |
30108
0898adc64a6f
Extract functions to generate yuv->rgb matrices and lookup tables into a
reimar
parents:
diff
changeset
|
58 */ |
0898adc64a6f
Extract functions to generate yuv->rgb matrices and lookup tables into a
reimar
parents:
diff
changeset
|
59 void mp_get_yuv2rgb_coeffs(struct mp_csp_params *params, float yuv2rgb[3][4]) { |
0898adc64a6f
Extract functions to generate yuv->rgb matrices and lookup tables into a
reimar
parents:
diff
changeset
|
60 float uvcos = params->saturation * cos(params->hue); |
0898adc64a6f
Extract functions to generate yuv->rgb matrices and lookup tables into a
reimar
parents:
diff
changeset
|
61 float uvsin = params->saturation * sin(params->hue); |
30109
0f25d3062987
First steps to supporting different YUV->RGB conversion definitions.
reimar
parents:
30108
diff
changeset
|
62 int format = params->format; |
30108
0898adc64a6f
Extract functions to generate yuv->rgb matrices and lookup tables into a
reimar
parents:
diff
changeset
|
63 int i; |
30121
28cbec606cbb
Slightly generalize code to generate YUV->RGB conversion table and add
reimar
parents:
30109
diff
changeset
|
64 const float (*uv_coeffs)[3]; |
28cbec606cbb
Slightly generalize code to generate YUV->RGB conversion table and add
reimar
parents:
30109
diff
changeset
|
65 const float *level_adjust; |
28cbec606cbb
Slightly generalize code to generate YUV->RGB conversion table and add
reimar
parents:
30109
diff
changeset
|
66 static const float yuv_pc_level_adjust[4] = {-16 / 255.0, -128 / 255.0, -128 / 255.0, 1.164}; |
28cbec606cbb
Slightly generalize code to generate YUV->RGB conversion table and add
reimar
parents:
30109
diff
changeset
|
67 static const float yuv_tv_level_adjust[4] = {0, -128 / 255.0, -128 / 255.0, 0}; |
28cbec606cbb
Slightly generalize code to generate YUV->RGB conversion table and add
reimar
parents:
30109
diff
changeset
|
68 static const float xyz_level_adjust[4] = {0, 0, 0, 0}; |
28cbec606cbb
Slightly generalize code to generate YUV->RGB conversion table and add
reimar
parents:
30109
diff
changeset
|
69 static const float uv_coeffs_table[MP_CSP_COUNT][3][3] = { |
30109
0f25d3062987
First steps to supporting different YUV->RGB conversion definitions.
reimar
parents:
30108
diff
changeset
|
70 [MP_CSP_DEFAULT] = { |
30121
28cbec606cbb
Slightly generalize code to generate YUV->RGB conversion table and add
reimar
parents:
30109
diff
changeset
|
71 {1, 0.000, 1.596}, |
28cbec606cbb
Slightly generalize code to generate YUV->RGB conversion table and add
reimar
parents:
30109
diff
changeset
|
72 {1, -0.391, -0.813}, |
28cbec606cbb
Slightly generalize code to generate YUV->RGB conversion table and add
reimar
parents:
30109
diff
changeset
|
73 {1, 2.018, 0.000} |
30109
0f25d3062987
First steps to supporting different YUV->RGB conversion definitions.
reimar
parents:
30108
diff
changeset
|
74 }, |
0f25d3062987
First steps to supporting different YUV->RGB conversion definitions.
reimar
parents:
30108
diff
changeset
|
75 [MP_CSP_BT_601] = { |
30121
28cbec606cbb
Slightly generalize code to generate YUV->RGB conversion table and add
reimar
parents:
30109
diff
changeset
|
76 {1, 0.000, 1.403}, |
28cbec606cbb
Slightly generalize code to generate YUV->RGB conversion table and add
reimar
parents:
30109
diff
changeset
|
77 {1, -0.344, -0.714}, |
28cbec606cbb
Slightly generalize code to generate YUV->RGB conversion table and add
reimar
parents:
30109
diff
changeset
|
78 {1, 1.773, 0.000} |
30109
0f25d3062987
First steps to supporting different YUV->RGB conversion definitions.
reimar
parents:
30108
diff
changeset
|
79 }, |
0f25d3062987
First steps to supporting different YUV->RGB conversion definitions.
reimar
parents:
30108
diff
changeset
|
80 [MP_CSP_BT_709] = { |
30121
28cbec606cbb
Slightly generalize code to generate YUV->RGB conversion table and add
reimar
parents:
30109
diff
changeset
|
81 {1, 0.0000, 1.5701}, |
28cbec606cbb
Slightly generalize code to generate YUV->RGB conversion table and add
reimar
parents:
30109
diff
changeset
|
82 {1, -0.1870, -0.4664}, |
28cbec606cbb
Slightly generalize code to generate YUV->RGB conversion table and add
reimar
parents:
30109
diff
changeset
|
83 {1, 1.8556, 0.0000} |
30109
0f25d3062987
First steps to supporting different YUV->RGB conversion definitions.
reimar
parents:
30108
diff
changeset
|
84 }, |
0f25d3062987
First steps to supporting different YUV->RGB conversion definitions.
reimar
parents:
30108
diff
changeset
|
85 [MP_CSP_SMPTE_240M] = { |
30121
28cbec606cbb
Slightly generalize code to generate YUV->RGB conversion table and add
reimar
parents:
30109
diff
changeset
|
86 {1, 0.0000, 1.5756}, |
28cbec606cbb
Slightly generalize code to generate YUV->RGB conversion table and add
reimar
parents:
30109
diff
changeset
|
87 {1, -0.2253, -0.5000}, |
28cbec606cbb
Slightly generalize code to generate YUV->RGB conversion table and add
reimar
parents:
30109
diff
changeset
|
88 {1, 1.8270, 0.0000} |
30109
0f25d3062987
First steps to supporting different YUV->RGB conversion definitions.
reimar
parents:
30108
diff
changeset
|
89 }, |
0f25d3062987
First steps to supporting different YUV->RGB conversion definitions.
reimar
parents:
30108
diff
changeset
|
90 [MP_CSP_EBU] = { |
30121
28cbec606cbb
Slightly generalize code to generate YUV->RGB conversion table and add
reimar
parents:
30109
diff
changeset
|
91 {1, 0.000, 1.140}, |
28cbec606cbb
Slightly generalize code to generate YUV->RGB conversion table and add
reimar
parents:
30109
diff
changeset
|
92 {1, -0.396, -0.581}, |
28cbec606cbb
Slightly generalize code to generate YUV->RGB conversion table and add
reimar
parents:
30109
diff
changeset
|
93 {1, 2.029, 0.000} |
28cbec606cbb
Slightly generalize code to generate YUV->RGB conversion table and add
reimar
parents:
30109
diff
changeset
|
94 }, |
28cbec606cbb
Slightly generalize code to generate YUV->RGB conversion table and add
reimar
parents:
30109
diff
changeset
|
95 [MP_CSP_XYZ] = { |
28cbec606cbb
Slightly generalize code to generate YUV->RGB conversion table and add
reimar
parents:
30109
diff
changeset
|
96 { 3.2404542, -1.5371385, -0.4985314}, |
28cbec606cbb
Slightly generalize code to generate YUV->RGB conversion table and add
reimar
parents:
30109
diff
changeset
|
97 {-0.9692660, 1.8760108, 0.0415560}, |
28cbec606cbb
Slightly generalize code to generate YUV->RGB conversion table and add
reimar
parents:
30109
diff
changeset
|
98 { 0.0556434, -0.2040259, 1.0572252} |
30109
0f25d3062987
First steps to supporting different YUV->RGB conversion definitions.
reimar
parents:
30108
diff
changeset
|
99 }, |
30108
0898adc64a6f
Extract functions to generate yuv->rgb matrices and lookup tables into a
reimar
parents:
diff
changeset
|
100 }; |
30109
0f25d3062987
First steps to supporting different YUV->RGB conversion definitions.
reimar
parents:
30108
diff
changeset
|
101 |
0f25d3062987
First steps to supporting different YUV->RGB conversion definitions.
reimar
parents:
30108
diff
changeset
|
102 if (format < 0 || format >= MP_CSP_COUNT) |
0f25d3062987
First steps to supporting different YUV->RGB conversion definitions.
reimar
parents:
30108
diff
changeset
|
103 format = MP_CSP_DEFAULT; |
0f25d3062987
First steps to supporting different YUV->RGB conversion definitions.
reimar
parents:
30108
diff
changeset
|
104 uv_coeffs = uv_coeffs_table[format]; |
30121
28cbec606cbb
Slightly generalize code to generate YUV->RGB conversion table and add
reimar
parents:
30109
diff
changeset
|
105 level_adjust = yuv_pc_level_adjust; |
28cbec606cbb
Slightly generalize code to generate YUV->RGB conversion table and add
reimar
parents:
30109
diff
changeset
|
106 if (format == MP_CSP_XYZ) |
28cbec606cbb
Slightly generalize code to generate YUV->RGB conversion table and add
reimar
parents:
30109
diff
changeset
|
107 level_adjust = xyz_level_adjust; |
30109
0f25d3062987
First steps to supporting different YUV->RGB conversion definitions.
reimar
parents:
30108
diff
changeset
|
108 |
30108
0898adc64a6f
Extract functions to generate yuv->rgb matrices and lookup tables into a
reimar
parents:
diff
changeset
|
109 for (i = 0; i < 3; i++) { |
0898adc64a6f
Extract functions to generate yuv->rgb matrices and lookup tables into a
reimar
parents:
diff
changeset
|
110 yuv2rgb[i][COL_C] = params->brightness; |
30121
28cbec606cbb
Slightly generalize code to generate YUV->RGB conversion table and add
reimar
parents:
30109
diff
changeset
|
111 yuv2rgb[i][COL_Y] = uv_coeffs[i][COL_Y] * level_adjust[COL_C] * params->contrast; |
30109
0f25d3062987
First steps to supporting different YUV->RGB conversion definitions.
reimar
parents:
30108
diff
changeset
|
112 yuv2rgb[i][COL_C] += level_adjust[COL_Y] * yuv2rgb[i][COL_Y]; |
30121
28cbec606cbb
Slightly generalize code to generate YUV->RGB conversion table and add
reimar
parents:
30109
diff
changeset
|
113 yuv2rgb[i][COL_U] = uv_coeffs[i][COL_U] * uvcos + uv_coeffs[i][COL_V] * uvsin; |
30109
0f25d3062987
First steps to supporting different YUV->RGB conversion definitions.
reimar
parents:
30108
diff
changeset
|
114 yuv2rgb[i][COL_C] += level_adjust[COL_U] * yuv2rgb[i][COL_U]; |
30121
28cbec606cbb
Slightly generalize code to generate YUV->RGB conversion table and add
reimar
parents:
30109
diff
changeset
|
115 yuv2rgb[i][COL_V] = uv_coeffs[i][COL_U] * uvsin + uv_coeffs[i][COL_V] * uvcos; |
30109
0f25d3062987
First steps to supporting different YUV->RGB conversion definitions.
reimar
parents:
30108
diff
changeset
|
116 yuv2rgb[i][COL_C] += level_adjust[COL_V] * yuv2rgb[i][COL_V]; |
30108
0898adc64a6f
Extract functions to generate yuv->rgb matrices and lookup tables into a
reimar
parents:
diff
changeset
|
117 // this "centers" contrast control so that e.g. a contrast of 0 |
0898adc64a6f
Extract functions to generate yuv->rgb matrices and lookup tables into a
reimar
parents:
diff
changeset
|
118 // leads to a grey image, not a black one |
0898adc64a6f
Extract functions to generate yuv->rgb matrices and lookup tables into a
reimar
parents:
diff
changeset
|
119 yuv2rgb[i][COL_C] += 0.5 - params->contrast / 2.0; |
0898adc64a6f
Extract functions to generate yuv->rgb matrices and lookup tables into a
reimar
parents:
diff
changeset
|
120 } |
0898adc64a6f
Extract functions to generate yuv->rgb matrices and lookup tables into a
reimar
parents:
diff
changeset
|
121 } |
0898adc64a6f
Extract functions to generate yuv->rgb matrices and lookup tables into a
reimar
parents:
diff
changeset
|
122 |
0898adc64a6f
Extract functions to generate yuv->rgb matrices and lookup tables into a
reimar
parents:
diff
changeset
|
123 //! size of gamma map use to avoid slow exp function in gen_yuv2rgb_map |
0898adc64a6f
Extract functions to generate yuv->rgb matrices and lookup tables into a
reimar
parents:
diff
changeset
|
124 #define GMAP_SIZE (1024) |
0898adc64a6f
Extract functions to generate yuv->rgb matrices and lookup tables into a
reimar
parents:
diff
changeset
|
125 /** |
0898adc64a6f
Extract functions to generate yuv->rgb matrices and lookup tables into a
reimar
parents:
diff
changeset
|
126 * \brief generate a 3D YUV -> RGB map |
0898adc64a6f
Extract functions to generate yuv->rgb matrices and lookup tables into a
reimar
parents:
diff
changeset
|
127 * \param params struct containing parameters like brightness, gamma, ... |
0898adc64a6f
Extract functions to generate yuv->rgb matrices and lookup tables into a
reimar
parents:
diff
changeset
|
128 * \param map where to store map. Must provide space for (size + 2)^3 elements |
0898adc64a6f
Extract functions to generate yuv->rgb matrices and lookup tables into a
reimar
parents:
diff
changeset
|
129 * \param size size of the map, excluding border |
0898adc64a6f
Extract functions to generate yuv->rgb matrices and lookup tables into a
reimar
parents:
diff
changeset
|
130 */ |
0898adc64a6f
Extract functions to generate yuv->rgb matrices and lookup tables into a
reimar
parents:
diff
changeset
|
131 void mp_gen_yuv2rgb_map(struct mp_csp_params *params, unsigned char *map, int size) { |
0898adc64a6f
Extract functions to generate yuv->rgb matrices and lookup tables into a
reimar
parents:
diff
changeset
|
132 int i, j, k, l; |
0898adc64a6f
Extract functions to generate yuv->rgb matrices and lookup tables into a
reimar
parents:
diff
changeset
|
133 float step = 1.0 / size; |
0898adc64a6f
Extract functions to generate yuv->rgb matrices and lookup tables into a
reimar
parents:
diff
changeset
|
134 float y, u, v; |
0898adc64a6f
Extract functions to generate yuv->rgb matrices and lookup tables into a
reimar
parents:
diff
changeset
|
135 float yuv2rgb[3][4]; |
0898adc64a6f
Extract functions to generate yuv->rgb matrices and lookup tables into a
reimar
parents:
diff
changeset
|
136 unsigned char gmaps[3][GMAP_SIZE]; |
0898adc64a6f
Extract functions to generate yuv->rgb matrices and lookup tables into a
reimar
parents:
diff
changeset
|
137 mp_gen_gamma_map(gmaps[0], GMAP_SIZE, params->rgamma); |
0898adc64a6f
Extract functions to generate yuv->rgb matrices and lookup tables into a
reimar
parents:
diff
changeset
|
138 mp_gen_gamma_map(gmaps[1], GMAP_SIZE, params->ggamma); |
0898adc64a6f
Extract functions to generate yuv->rgb matrices and lookup tables into a
reimar
parents:
diff
changeset
|
139 mp_gen_gamma_map(gmaps[2], GMAP_SIZE, params->bgamma); |
0898adc64a6f
Extract functions to generate yuv->rgb matrices and lookup tables into a
reimar
parents:
diff
changeset
|
140 mp_get_yuv2rgb_coeffs(params, yuv2rgb); |
0898adc64a6f
Extract functions to generate yuv->rgb matrices and lookup tables into a
reimar
parents:
diff
changeset
|
141 for (i = 0; i < 3; i++) |
0898adc64a6f
Extract functions to generate yuv->rgb matrices and lookup tables into a
reimar
parents:
diff
changeset
|
142 for (j = 0; j < 4; j++) |
0898adc64a6f
Extract functions to generate yuv->rgb matrices and lookup tables into a
reimar
parents:
diff
changeset
|
143 yuv2rgb[i][j] *= GMAP_SIZE - 1; |
0898adc64a6f
Extract functions to generate yuv->rgb matrices and lookup tables into a
reimar
parents:
diff
changeset
|
144 v = 0; |
0898adc64a6f
Extract functions to generate yuv->rgb matrices and lookup tables into a
reimar
parents:
diff
changeset
|
145 for (i = -1; i <= size; i++) { |
0898adc64a6f
Extract functions to generate yuv->rgb matrices and lookup tables into a
reimar
parents:
diff
changeset
|
146 u = 0; |
0898adc64a6f
Extract functions to generate yuv->rgb matrices and lookup tables into a
reimar
parents:
diff
changeset
|
147 for (j = -1; j <= size; j++) { |
0898adc64a6f
Extract functions to generate yuv->rgb matrices and lookup tables into a
reimar
parents:
diff
changeset
|
148 y = 0; |
0898adc64a6f
Extract functions to generate yuv->rgb matrices and lookup tables into a
reimar
parents:
diff
changeset
|
149 for (k = -1; k <= size; k++) { |
0898adc64a6f
Extract functions to generate yuv->rgb matrices and lookup tables into a
reimar
parents:
diff
changeset
|
150 for (l = 0; l < 3; l++) { |
0898adc64a6f
Extract functions to generate yuv->rgb matrices and lookup tables into a
reimar
parents:
diff
changeset
|
151 float rgb = yuv2rgb[l][COL_Y] * y + yuv2rgb[l][COL_U] * u + yuv2rgb[l][COL_V] * v + yuv2rgb[l][COL_C]; |
0898adc64a6f
Extract functions to generate yuv->rgb matrices and lookup tables into a
reimar
parents:
diff
changeset
|
152 *map++ = gmaps[l][av_clip(rgb, 0, GMAP_SIZE - 1)]; |
0898adc64a6f
Extract functions to generate yuv->rgb matrices and lookup tables into a
reimar
parents:
diff
changeset
|
153 } |
0898adc64a6f
Extract functions to generate yuv->rgb matrices and lookup tables into a
reimar
parents:
diff
changeset
|
154 y += (k == -1 || k == size - 1) ? step / 2 : step; |
0898adc64a6f
Extract functions to generate yuv->rgb matrices and lookup tables into a
reimar
parents:
diff
changeset
|
155 } |
0898adc64a6f
Extract functions to generate yuv->rgb matrices and lookup tables into a
reimar
parents:
diff
changeset
|
156 u += (j == -1 || j == size - 1) ? step / 2 : step; |
0898adc64a6f
Extract functions to generate yuv->rgb matrices and lookup tables into a
reimar
parents:
diff
changeset
|
157 } |
0898adc64a6f
Extract functions to generate yuv->rgb matrices and lookup tables into a
reimar
parents:
diff
changeset
|
158 v += (i == -1 || i == size - 1) ? step / 2 : step; |
0898adc64a6f
Extract functions to generate yuv->rgb matrices and lookup tables into a
reimar
parents:
diff
changeset
|
159 } |
0898adc64a6f
Extract functions to generate yuv->rgb matrices and lookup tables into a
reimar
parents:
diff
changeset
|
160 } |