Mercurial > mplayer.hg
annotate postproc/rgb2rgb.c @ 11914:47f653a0edd2
sync
author | nicolas |
---|---|
date | Mon, 02 Feb 2004 22:12:01 +0000 |
parents | 9db8700a5a16 |
children | b80f95e24c96 |
rev | line source |
---|---|
2694 | 1 /* |
2538
71320898b333
Finish mmx2, 3dnow optimiz. 15to16 should be tested. Better fix of can't compile
nick
parents:
2535
diff
changeset
|
2 * |
71320898b333
Finish mmx2, 3dnow optimiz. 15to16 should be tested. Better fix of can't compile
nick
parents:
2535
diff
changeset
|
3 * rgb2rgb.c, Software RGB to RGB convertor |
2732 | 4 * pluralize by Software PAL8 to RGB convertor |
5 * Software YUV to YUV convertor | |
6 * Software YUV to RGB convertor | |
2538
71320898b333
Finish mmx2, 3dnow optimiz. 15to16 should be tested. Better fix of can't compile
nick
parents:
2535
diff
changeset
|
7 * Written by Nick Kurshev. |
3132 | 8 * palette & yuv & runtime cpu stuff by Michael (michaelni@gmx.at) (under GPL) |
2538
71320898b333
Finish mmx2, 3dnow optimiz. 15to16 should be tested. Better fix of can't compile
nick
parents:
2535
diff
changeset
|
9 */ |
2504 | 10 #include <inttypes.h> |
11 #include "../config.h" | |
12 #include "rgb2rgb.h" | |
9987 | 13 #include "swscale.h" |
4923 | 14 #include "../mangle.h" |
7159
1df24fd752d0
added missing palette8tobgr pairs (hope it's correct)
alex
parents:
6614
diff
changeset
|
15 #include "../bswap.h" |
8123
9fc45fe0d444
*HUGE* set of compiler warning fixes, unused variables removal
arpi
parents:
7334
diff
changeset
|
16 #include "../libvo/fastmemcpy.h" |
2538
71320898b333
Finish mmx2, 3dnow optimiz. 15to16 should be tested. Better fix of can't compile
nick
parents:
2535
diff
changeset
|
17 |
4622 | 18 #define FAST_BGR2YV12 // use 7 bit coeffs instead of 15bit |
19 | |
9987 | 20 void (*rgb24to32)(const uint8_t *src,uint8_t *dst,unsigned src_size); |
21 void (*rgb24to16)(const uint8_t *src,uint8_t *dst,unsigned src_size); | |
22 void (*rgb24to15)(const uint8_t *src,uint8_t *dst,unsigned src_size); | |
23 void (*rgb32to24)(const uint8_t *src,uint8_t *dst,unsigned src_size); | |
24 void (*rgb32to16)(const uint8_t *src,uint8_t *dst,unsigned src_size); | |
25 void (*rgb32to15)(const uint8_t *src,uint8_t *dst,unsigned src_size); | |
26 void (*rgb15to16)(const uint8_t *src,uint8_t *dst,unsigned src_size); | |
27 void (*rgb15to24)(const uint8_t *src,uint8_t *dst,unsigned src_size); | |
28 void (*rgb15to32)(const uint8_t *src,uint8_t *dst,unsigned src_size); | |
29 void (*rgb16to15)(const uint8_t *src,uint8_t *dst,unsigned src_size); | |
30 void (*rgb16to24)(const uint8_t *src,uint8_t *dst,unsigned src_size); | |
31 void (*rgb16to32)(const uint8_t *src,uint8_t *dst,unsigned src_size); | |
32 //void (*rgb24tobgr32)(const uint8_t *src, uint8_t *dst, unsigned src_size); | |
33 void (*rgb24tobgr24)(const uint8_t *src, uint8_t *dst, unsigned src_size); | |
34 void (*rgb24tobgr16)(const uint8_t *src, uint8_t *dst, unsigned src_size); | |
35 void (*rgb24tobgr15)(const uint8_t *src, uint8_t *dst, unsigned src_size); | |
36 void (*rgb32tobgr32)(const uint8_t *src, uint8_t *dst, unsigned src_size); | |
37 //void (*rgb32tobgr24)(const uint8_t *src, uint8_t *dst, unsigned src_size); | |
38 void (*rgb32tobgr16)(const uint8_t *src, uint8_t *dst, unsigned src_size); | |
39 void (*rgb32tobgr15)(const uint8_t *src, uint8_t *dst, unsigned src_size); | |
40 | |
41 void (*yv12toyuy2)(const uint8_t *ysrc, const uint8_t *usrc, const uint8_t *vsrc, uint8_t *dst, | |
42 unsigned int width, unsigned int height, | |
43 int lumStride, int chromStride, int dstStride); | |
11068 | 44 void (*yv12touyvy)(const uint8_t *ysrc, const uint8_t *usrc, const uint8_t *vsrc, uint8_t *dst, |
45 unsigned int width, unsigned int height, | |
46 int lumStride, int chromStride, int dstStride); | |
9987 | 47 void (*yuv422ptoyuy2)(const uint8_t *ysrc, const uint8_t *usrc, const uint8_t *vsrc, uint8_t *dst, |
48 unsigned int width, unsigned int height, | |
49 int lumStride, int chromStride, int dstStride); | |
50 void (*yuy2toyv12)(const uint8_t *src, uint8_t *ydst, uint8_t *udst, uint8_t *vdst, | |
51 unsigned int width, unsigned int height, | |
52 int lumStride, int chromStride, int srcStride); | |
53 void (*rgb24toyv12)(const uint8_t *src, uint8_t *ydst, uint8_t *udst, uint8_t *vdst, | |
54 unsigned int width, unsigned int height, | |
55 int lumStride, int chromStride, int srcStride); | |
56 void (*planar2x)(const uint8_t *src, uint8_t *dst, int width, int height, int srcStride, int dstStride); | |
57 void (*interleaveBytes)(uint8_t *src1, uint8_t *src2, uint8_t *dst, | |
58 unsigned width, unsigned height, int src1Stride, | |
59 int src2Stride, int dstStride); | |
60 void (*vu9_to_vu12)(const uint8_t *src1, const uint8_t *src2, | |
61 uint8_t *dst1, uint8_t *dst2, | |
62 unsigned width, unsigned height, | |
63 int srcStride1, int srcStride2, | |
64 int dstStride1, int dstStride2); | |
65 void (*yvu9_to_yuy2)(const uint8_t *src1, const uint8_t *src2, const uint8_t *src3, | |
66 uint8_t *dst, | |
67 unsigned width, unsigned height, | |
68 int srcStride1, int srcStride2, | |
69 int srcStride3, int dstStride); | |
70 | |
71 #ifdef ARCH_X86 | |
6492 | 72 static const uint64_t mmx_null __attribute__((aligned(8))) = 0x0000000000000000ULL; |
73 static const uint64_t mmx_one __attribute__((aligned(8))) = 0xFFFFFFFFFFFFFFFFULL; | |
2755 | 74 static const uint64_t mask32b __attribute__((aligned(8))) = 0x000000FF000000FFULL; |
75 static const uint64_t mask32g __attribute__((aligned(8))) = 0x0000FF000000FF00ULL; | |
76 static const uint64_t mask32r __attribute__((aligned(8))) = 0x00FF000000FF0000ULL; | |
2538
71320898b333
Finish mmx2, 3dnow optimiz. 15to16 should be tested. Better fix of can't compile
nick
parents:
2535
diff
changeset
|
77 static const uint64_t mask32 __attribute__((aligned(8))) = 0x00FFFFFF00FFFFFFULL; |
9454 | 78 static const uint64_t mask3216br __attribute__((aligned(8)))=0x00F800F800F800F8ULL; |
79 static const uint64_t mask3216g __attribute__((aligned(8)))=0x0000FC000000FC00ULL; | |
80 static const uint64_t mask3215g __attribute__((aligned(8)))=0x0000F8000000F800ULL; | |
81 static const uint64_t mul3216 __attribute__((aligned(8))) = 0x2000000420000004ULL; | |
82 static const uint64_t mul3215 __attribute__((aligned(8))) = 0x2000000820000008ULL; | |
5582 | 83 static const uint64_t mask24b __attribute__((aligned(8))) = 0x00FF0000FF0000FFULL; |
84 static const uint64_t mask24g __attribute__((aligned(8))) = 0xFF0000FF0000FF00ULL; | |
85 static const uint64_t mask24r __attribute__((aligned(8))) = 0x0000FF0000FF0000ULL; | |
2538
71320898b333
Finish mmx2, 3dnow optimiz. 15to16 should be tested. Better fix of can't compile
nick
parents:
2535
diff
changeset
|
86 static const uint64_t mask24l __attribute__((aligned(8))) = 0x0000000000FFFFFFULL; |
71320898b333
Finish mmx2, 3dnow optimiz. 15to16 should be tested. Better fix of can't compile
nick
parents:
2535
diff
changeset
|
87 static const uint64_t mask24h __attribute__((aligned(8))) = 0x0000FFFFFF000000ULL; |
2746
dece635a28e3
Minor speedup of rgb32to24. (performance is not successful)
nick
parents:
2741
diff
changeset
|
88 static const uint64_t mask24hh __attribute__((aligned(8))) = 0xffff000000000000ULL; |
dece635a28e3
Minor speedup of rgb32to24. (performance is not successful)
nick
parents:
2741
diff
changeset
|
89 static const uint64_t mask24hhh __attribute__((aligned(8))) = 0xffffffff00000000ULL; |
dece635a28e3
Minor speedup of rgb32to24. (performance is not successful)
nick
parents:
2741
diff
changeset
|
90 static const uint64_t mask24hhhh __attribute__((aligned(8))) = 0xffffffffffff0000ULL; |
2538
71320898b333
Finish mmx2, 3dnow optimiz. 15to16 should be tested. Better fix of can't compile
nick
parents:
2535
diff
changeset
|
91 static const uint64_t mask15b __attribute__((aligned(8))) = 0x001F001F001F001FULL; /* 00000000 00011111 xxB */ |
71320898b333
Finish mmx2, 3dnow optimiz. 15to16 should be tested. Better fix of can't compile
nick
parents:
2535
diff
changeset
|
92 static const uint64_t mask15rg __attribute__((aligned(8))) = 0x7FE07FE07FE07FE0ULL; /* 01111111 11100000 RGx */ |
2698
22652c028692
faster 15to16 bit rgb (the mmx routine is limited by memory speed so there is no difference ): but the c routine is faster
michael
parents:
2697
diff
changeset
|
93 static const uint64_t mask15s __attribute__((aligned(8))) = 0xFFE0FFE0FFE0FFE0ULL; |
6492 | 94 static const uint64_t mask15g __attribute__((aligned(8))) = 0x03E003E003E003E0ULL; |
95 static const uint64_t mask15r __attribute__((aligned(8))) = 0x7C007C007C007C00ULL; | |
96 #define mask16b mask15b | |
97 static const uint64_t mask16g __attribute__((aligned(8))) = 0x07E007E007E007E0ULL; | |
98 static const uint64_t mask16r __attribute__((aligned(8))) = 0xF800F800F800F800ULL; | |
2741 | 99 static const uint64_t red_16mask __attribute__((aligned(8))) = 0x0000f8000000f800ULL; |
100 static const uint64_t green_16mask __attribute__((aligned(8)))= 0x000007e0000007e0ULL; | |
101 static const uint64_t blue_16mask __attribute__((aligned(8))) = 0x0000001f0000001fULL; | |
102 static const uint64_t red_15mask __attribute__((aligned(8))) = 0x00007c000000f800ULL; | |
103 static const uint64_t green_15mask __attribute__((aligned(8)))= 0x000003e0000007e0ULL; | |
104 static const uint64_t blue_15mask __attribute__((aligned(8))) = 0x0000001f0000001fULL; | |
4622 | 105 |
106 #ifdef FAST_BGR2YV12 | |
107 static const uint64_t bgr2YCoeff __attribute__((aligned(8))) = 0x000000210041000DULL; | |
108 static const uint64_t bgr2UCoeff __attribute__((aligned(8))) = 0x0000FFEEFFDC0038ULL; | |
109 static const uint64_t bgr2VCoeff __attribute__((aligned(8))) = 0x00000038FFD2FFF8ULL; | |
110 #else | |
111 static const uint64_t bgr2YCoeff __attribute__((aligned(8))) = 0x000020E540830C8BULL; | |
112 static const uint64_t bgr2UCoeff __attribute__((aligned(8))) = 0x0000ED0FDAC23831ULL; | |
113 static const uint64_t bgr2VCoeff __attribute__((aligned(8))) = 0x00003831D0E6F6EAULL; | |
114 #endif | |
115 static const uint64_t bgr2YOffset __attribute__((aligned(8))) = 0x1010101010101010ULL; | |
116 static const uint64_t bgr2UVOffset __attribute__((aligned(8)))= 0x8080808080808080ULL; | |
117 static const uint64_t w1111 __attribute__((aligned(8))) = 0x0001000100010001ULL; | |
118 | |
2755 | 119 #if 0 |
120 static volatile uint64_t __attribute__((aligned(8))) b5Dither; | |
121 static volatile uint64_t __attribute__((aligned(8))) g5Dither; | |
122 static volatile uint64_t __attribute__((aligned(8))) g6Dither; | |
123 static volatile uint64_t __attribute__((aligned(8))) r5Dither; | |
124 | |
125 static uint64_t __attribute__((aligned(8))) dither4[2]={ | |
126 0x0103010301030103LL, | |
127 0x0200020002000200LL,}; | |
128 | |
129 static uint64_t __attribute__((aligned(8))) dither8[2]={ | |
130 0x0602060206020602LL, | |
131 0x0004000400040004LL,}; | |
132 #endif | |
2535 | 133 #endif |
2513 | 134 |
3132 | 135 #define RGB2YUV_SHIFT 8 |
136 #define BY ((int)( 0.098*(1<<RGB2YUV_SHIFT)+0.5)) | |
137 #define BV ((int)(-0.071*(1<<RGB2YUV_SHIFT)+0.5)) | |
138 #define BU ((int)( 0.439*(1<<RGB2YUV_SHIFT)+0.5)) | |
139 #define GY ((int)( 0.504*(1<<RGB2YUV_SHIFT)+0.5)) | |
140 #define GV ((int)(-0.368*(1<<RGB2YUV_SHIFT)+0.5)) | |
141 #define GU ((int)(-0.291*(1<<RGB2YUV_SHIFT)+0.5)) | |
142 #define RY ((int)( 0.257*(1<<RGB2YUV_SHIFT)+0.5)) | |
143 #define RV ((int)( 0.439*(1<<RGB2YUV_SHIFT)+0.5)) | |
144 #define RU ((int)(-0.148*(1<<RGB2YUV_SHIFT)+0.5)) | |
145 | |
146 //Note: we have C, MMX, MMX2, 3DNOW version therse no 3DNOW+MMX2 one | |
147 //Plain C versions | |
148 #undef HAVE_MMX | |
149 #undef HAVE_MMX2 | |
150 #undef HAVE_3DNOW | |
5338 | 151 #undef HAVE_SSE2 |
3132 | 152 #define RENAME(a) a ## _C |
153 #include "rgb2rgb_template.c" | |
154 | |
9987 | 155 #ifdef ARCH_X86 |
3132 | 156 |
157 //MMX versions | |
158 #undef RENAME | |
159 #define HAVE_MMX | |
160 #undef HAVE_MMX2 | |
161 #undef HAVE_3DNOW | |
5338 | 162 #undef HAVE_SSE2 |
3132 | 163 #define RENAME(a) a ## _MMX |
164 #include "rgb2rgb_template.c" | |
165 | |
166 //MMX2 versions | |
167 #undef RENAME | |
168 #define HAVE_MMX | |
169 #define HAVE_MMX2 | |
170 #undef HAVE_3DNOW | |
5338 | 171 #undef HAVE_SSE2 |
3132 | 172 #define RENAME(a) a ## _MMX2 |
173 #include "rgb2rgb_template.c" | |
174 | |
175 //3DNOW versions | |
176 #undef RENAME | |
177 #define HAVE_MMX | |
178 #undef HAVE_MMX2 | |
179 #define HAVE_3DNOW | |
5338 | 180 #undef HAVE_SSE2 |
11071 | 181 #define RENAME(a) a ## _3DNOW |
3132 | 182 #include "rgb2rgb_template.c" |
183 | |
9987 | 184 #endif //ARCH_X86 |
2506 | 185 |
2538
71320898b333
Finish mmx2, 3dnow optimiz. 15to16 should be tested. Better fix of can't compile
nick
parents:
2535
diff
changeset
|
186 /* |
9987 | 187 rgb15->rgb16 Original by Strepto/Astral |
2538
71320898b333
Finish mmx2, 3dnow optimiz. 15to16 should be tested. Better fix of can't compile
nick
parents:
2535
diff
changeset
|
188 ported to gcc & bugfixed : A'rpi |
2564 | 189 MMX2, 3DNOW optimization by Nick Kurshev |
2698
22652c028692
faster 15to16 bit rgb (the mmx routine is limited by memory speed so there is no difference ): but the c routine is faster
michael
parents:
2697
diff
changeset
|
190 32bit c version, and and&add trick by Michael Niedermayer |
2538
71320898b333
Finish mmx2, 3dnow optimiz. 15to16 should be tested. Better fix of can't compile
nick
parents:
2535
diff
changeset
|
191 */ |
9987 | 192 |
193 void sws_rgb2rgb_init(int flags){ | |
194 #ifdef ARCH_X86 | |
195 if(flags & SWS_CPU_CAPS_MMX2){ | |
196 rgb15to16= rgb15to16_MMX2; | |
197 rgb15to24= rgb15to24_MMX2; | |
198 rgb15to32= rgb15to32_MMX2; | |
199 rgb16to24= rgb16to24_MMX2; | |
200 rgb16to32= rgb16to32_MMX2; | |
201 rgb16to15= rgb16to15_MMX2; | |
202 rgb24to16= rgb24to16_MMX2; | |
203 rgb24to15= rgb24to15_MMX2; | |
204 rgb24to32= rgb24to32_MMX2; | |
205 rgb32to16= rgb32to16_MMX2; | |
206 rgb32to15= rgb32to15_MMX2; | |
207 rgb32to24= rgb32to24_MMX2; | |
208 rgb24tobgr15= rgb24tobgr15_MMX2; | |
209 rgb24tobgr16= rgb24tobgr16_MMX2; | |
210 rgb24tobgr24= rgb24tobgr24_MMX2; | |
211 rgb32tobgr32= rgb32tobgr32_MMX2; | |
212 rgb32tobgr16= rgb32tobgr16_MMX2; | |
213 rgb32tobgr15= rgb32tobgr15_MMX2; | |
214 yv12toyuy2= yv12toyuy2_MMX2; | |
11068 | 215 yv12touyvy= yv12touyvy_MMX2; |
9987 | 216 yuv422ptoyuy2= yuv422ptoyuy2_MMX2; |
217 yuy2toyv12= yuy2toyv12_MMX2; | |
11071 | 218 // uyvytoyv12= uyvytoyv12_MMX2; |
219 // yvu9toyv12= yvu9toyv12_MMX2; | |
9987 | 220 planar2x= planar2x_MMX2; |
221 rgb24toyv12= rgb24toyv12_MMX2; | |
222 interleaveBytes= interleaveBytes_MMX2; | |
223 vu9_to_vu12= vu9_to_vu12_MMX2; | |
224 yvu9_to_yuy2= yvu9_to_yuy2_MMX2; | |
225 }else if(flags & SWS_CPU_CAPS_3DNOW){ | |
226 rgb15to16= rgb15to16_3DNOW; | |
227 rgb15to24= rgb15to24_3DNOW; | |
228 rgb15to32= rgb15to32_3DNOW; | |
229 rgb16to24= rgb16to24_3DNOW; | |
230 rgb16to32= rgb16to32_3DNOW; | |
231 rgb16to15= rgb16to15_3DNOW; | |
232 rgb24to16= rgb24to16_3DNOW; | |
233 rgb24to15= rgb24to15_3DNOW; | |
234 rgb24to32= rgb24to32_3DNOW; | |
235 rgb32to16= rgb32to16_3DNOW; | |
236 rgb32to15= rgb32to15_3DNOW; | |
237 rgb32to24= rgb32to24_3DNOW; | |
238 rgb24tobgr15= rgb24tobgr15_3DNOW; | |
239 rgb24tobgr16= rgb24tobgr16_3DNOW; | |
240 rgb24tobgr24= rgb24tobgr24_3DNOW; | |
241 rgb32tobgr32= rgb32tobgr32_3DNOW; | |
242 rgb32tobgr16= rgb32tobgr16_3DNOW; | |
243 rgb32tobgr15= rgb32tobgr15_3DNOW; | |
244 yv12toyuy2= yv12toyuy2_3DNOW; | |
11068 | 245 yv12touyvy= yv12touyvy_3DNOW; |
9987 | 246 yuv422ptoyuy2= yuv422ptoyuy2_3DNOW; |
247 yuy2toyv12= yuy2toyv12_3DNOW; | |
11071 | 248 // uyvytoyv12= uyvytoyv12_3DNOW; |
249 // yvu9toyv12= yvu9toyv12_3DNOW; | |
9987 | 250 planar2x= planar2x_3DNOW; |
251 rgb24toyv12= rgb24toyv12_3DNOW; | |
252 interleaveBytes= interleaveBytes_3DNOW; | |
253 vu9_to_vu12= vu9_to_vu12_3DNOW; | |
254 yvu9_to_yuy2= yvu9_to_yuy2_3DNOW; | |
255 }else if(flags & SWS_CPU_CAPS_MMX){ | |
256 rgb15to16= rgb15to16_MMX; | |
257 rgb15to24= rgb15to24_MMX; | |
258 rgb15to32= rgb15to32_MMX; | |
259 rgb16to24= rgb16to24_MMX; | |
260 rgb16to32= rgb16to32_MMX; | |
261 rgb16to15= rgb16to15_MMX; | |
262 rgb24to16= rgb24to16_MMX; | |
263 rgb24to15= rgb24to15_MMX; | |
264 rgb24to32= rgb24to32_MMX; | |
265 rgb32to16= rgb32to16_MMX; | |
266 rgb32to15= rgb32to15_MMX; | |
267 rgb32to24= rgb32to24_MMX; | |
268 rgb24tobgr15= rgb24tobgr15_MMX; | |
269 rgb24tobgr16= rgb24tobgr16_MMX; | |
270 rgb24tobgr24= rgb24tobgr24_MMX; | |
271 rgb32tobgr32= rgb32tobgr32_MMX; | |
272 rgb32tobgr16= rgb32tobgr16_MMX; | |
273 rgb32tobgr15= rgb32tobgr15_MMX; | |
274 yv12toyuy2= yv12toyuy2_MMX; | |
11068 | 275 yv12touyvy= yv12touyvy_MMX; |
9987 | 276 yuv422ptoyuy2= yuv422ptoyuy2_MMX; |
277 yuy2toyv12= yuy2toyv12_MMX; | |
11071 | 278 // uyvytoyv12= uyvytoyv12_MMX; |
279 // yvu9toyv12= yvu9toyv12_MMX; | |
9987 | 280 planar2x= planar2x_MMX; |
281 rgb24toyv12= rgb24toyv12_MMX; | |
282 interleaveBytes= interleaveBytes_MMX; | |
283 vu9_to_vu12= vu9_to_vu12_MMX; | |
284 yvu9_to_yuy2= yvu9_to_yuy2_MMX; | |
285 }else | |
6492 | 286 #endif |
9987 | 287 { |
288 rgb15to16= rgb15to16_C; | |
289 rgb15to24= rgb15to24_C; | |
290 rgb15to32= rgb15to32_C; | |
291 rgb16to24= rgb16to24_C; | |
292 rgb16to32= rgb16to32_C; | |
293 rgb16to15= rgb16to15_C; | |
294 rgb24to16= rgb24to16_C; | |
295 rgb24to15= rgb24to15_C; | |
296 rgb24to32= rgb24to32_C; | |
297 rgb32to16= rgb32to16_C; | |
298 rgb32to15= rgb32to15_C; | |
299 rgb32to24= rgb32to24_C; | |
300 rgb24tobgr15= rgb24tobgr15_C; | |
301 rgb24tobgr16= rgb24tobgr16_C; | |
302 rgb24tobgr24= rgb24tobgr24_C; | |
303 rgb32tobgr32= rgb32tobgr32_C; | |
304 rgb32tobgr16= rgb32tobgr16_C; | |
305 rgb32tobgr15= rgb32tobgr15_C; | |
306 yv12toyuy2= yv12toyuy2_C; | |
11068 | 307 yv12touyvy= yv12touyvy_C; |
9987 | 308 yuv422ptoyuy2= yuv422ptoyuy2_C; |
309 yuy2toyv12= yuy2toyv12_C; | |
310 // uyvytoyv12= uyvytoyv12_C; | |
311 // yvu9toyv12= yvu9toyv12_C; | |
312 planar2x= planar2x_C; | |
313 rgb24toyv12= rgb24toyv12_C; | |
314 interleaveBytes= interleaveBytes_C; | |
315 vu9_to_vu12= vu9_to_vu12_C; | |
316 yvu9_to_yuy2= yvu9_to_yuy2_C; | |
317 } | |
2506 | 318 } |
2694 | 319 |
320 /** | |
321 * Pallete is assumed to contain bgr32 | |
322 */ | |
2718 | 323 void palette8torgb32(const uint8_t *src, uint8_t *dst, unsigned num_pixels, const uint8_t *palette) |
2694 | 324 { |
2718 | 325 unsigned i; |
7334 | 326 |
327 /* | |
2702 | 328 for(i=0; i<num_pixels; i++) |
2718 | 329 ((unsigned *)dst)[i] = ((unsigned *)palette)[ src[i] ]; |
7334 | 330 */ |
331 | |
332 for(i=0; i<num_pixels; i++) | |
333 { | |
334 //FIXME slow? | |
335 dst[0]= palette[ src[i]*4+2 ]; | |
336 dst[1]= palette[ src[i]*4+1 ]; | |
337 dst[2]= palette[ src[i]*4+0 ]; | |
338 // dst[3]= 0; /* do we need this cleansing? */ | |
339 dst+= 4; | |
340 } | |
2694 | 341 } |
342 | |
7159
1df24fd752d0
added missing palette8tobgr pairs (hope it's correct)
alex
parents:
6614
diff
changeset
|
343 void palette8tobgr32(const uint8_t *src, uint8_t *dst, unsigned num_pixels, const uint8_t *palette) |
1df24fd752d0
added missing palette8tobgr pairs (hope it's correct)
alex
parents:
6614
diff
changeset
|
344 { |
1df24fd752d0
added missing palette8tobgr pairs (hope it's correct)
alex
parents:
6614
diff
changeset
|
345 unsigned i; |
1df24fd752d0
added missing palette8tobgr pairs (hope it's correct)
alex
parents:
6614
diff
changeset
|
346 for(i=0; i<num_pixels; i++) |
1df24fd752d0
added missing palette8tobgr pairs (hope it's correct)
alex
parents:
6614
diff
changeset
|
347 { |
1df24fd752d0
added missing palette8tobgr pairs (hope it's correct)
alex
parents:
6614
diff
changeset
|
348 //FIXME slow? |
7334 | 349 dst[0]= palette[ src[i]*4+0 ]; |
350 dst[1]= palette[ src[i]*4+1 ]; | |
351 dst[2]= palette[ src[i]*4+2 ]; | |
352 // dst[3]= 0; /* do we need this cleansing? */ | |
7159
1df24fd752d0
added missing palette8tobgr pairs (hope it's correct)
alex
parents:
6614
diff
changeset
|
353 dst+= 4; |
1df24fd752d0
added missing palette8tobgr pairs (hope it's correct)
alex
parents:
6614
diff
changeset
|
354 } |
1df24fd752d0
added missing palette8tobgr pairs (hope it's correct)
alex
parents:
6614
diff
changeset
|
355 } |
1df24fd752d0
added missing palette8tobgr pairs (hope it's correct)
alex
parents:
6614
diff
changeset
|
356 |
2697 | 357 /** |
358 * Pallete is assumed to contain bgr32 | |
359 */ | |
2718 | 360 void palette8torgb24(const uint8_t *src, uint8_t *dst, unsigned num_pixels, const uint8_t *palette) |
2697 | 361 { |
2718 | 362 unsigned i; |
2697 | 363 /* |
364 writes 1 byte o much and might cause alignment issues on some architectures? | |
2702 | 365 for(i=0; i<num_pixels; i++) |
2718 | 366 ((unsigned *)(&dst[i*3])) = ((unsigned *)palette)[ src[i] ]; |
2697 | 367 */ |
2702 | 368 for(i=0; i<num_pixels; i++) |
2697 | 369 { |
370 //FIXME slow? | |
7334 | 371 dst[0]= palette[ src[i]*4+2 ]; |
2697 | 372 dst[1]= palette[ src[i]*4+1 ]; |
7334 | 373 dst[2]= palette[ src[i]*4+0 ]; |
2697 | 374 dst+= 3; |
375 } | |
376 } | |
377 | |
7159
1df24fd752d0
added missing palette8tobgr pairs (hope it's correct)
alex
parents:
6614
diff
changeset
|
378 void palette8tobgr24(const uint8_t *src, uint8_t *dst, unsigned num_pixels, const uint8_t *palette) |
1df24fd752d0
added missing palette8tobgr pairs (hope it's correct)
alex
parents:
6614
diff
changeset
|
379 { |
1df24fd752d0
added missing palette8tobgr pairs (hope it's correct)
alex
parents:
6614
diff
changeset
|
380 unsigned i; |
1df24fd752d0
added missing palette8tobgr pairs (hope it's correct)
alex
parents:
6614
diff
changeset
|
381 /* |
1df24fd752d0
added missing palette8tobgr pairs (hope it's correct)
alex
parents:
6614
diff
changeset
|
382 writes 1 byte o much and might cause alignment issues on some architectures? |
1df24fd752d0
added missing palette8tobgr pairs (hope it's correct)
alex
parents:
6614
diff
changeset
|
383 for(i=0; i<num_pixels; i++) |
1df24fd752d0
added missing palette8tobgr pairs (hope it's correct)
alex
parents:
6614
diff
changeset
|
384 ((unsigned *)(&dst[i*3])) = ((unsigned *)palette)[ src[i] ]; |
1df24fd752d0
added missing palette8tobgr pairs (hope it's correct)
alex
parents:
6614
diff
changeset
|
385 */ |
1df24fd752d0
added missing palette8tobgr pairs (hope it's correct)
alex
parents:
6614
diff
changeset
|
386 for(i=0; i<num_pixels; i++) |
1df24fd752d0
added missing palette8tobgr pairs (hope it's correct)
alex
parents:
6614
diff
changeset
|
387 { |
1df24fd752d0
added missing palette8tobgr pairs (hope it's correct)
alex
parents:
6614
diff
changeset
|
388 //FIXME slow? |
7334 | 389 dst[0]= palette[ src[i]*4+0 ]; |
390 dst[1]= palette[ src[i]*4+1 ]; | |
391 dst[2]= palette[ src[i]*4+2 ]; | |
7159
1df24fd752d0
added missing palette8tobgr pairs (hope it's correct)
alex
parents:
6614
diff
changeset
|
392 dst+= 3; |
1df24fd752d0
added missing palette8tobgr pairs (hope it's correct)
alex
parents:
6614
diff
changeset
|
393 } |
1df24fd752d0
added missing palette8tobgr pairs (hope it's correct)
alex
parents:
6614
diff
changeset
|
394 } |
1df24fd752d0
added missing palette8tobgr pairs (hope it's correct)
alex
parents:
6614
diff
changeset
|
395 |
2694 | 396 /** |
397 * Palette is assumed to contain bgr16, see rgb32to16 to convert the palette | |
398 */ | |
2718 | 399 void palette8torgb16(const uint8_t *src, uint8_t *dst, unsigned num_pixels, const uint8_t *palette) |
2694 | 400 { |
2718 | 401 unsigned i; |
2702 | 402 for(i=0; i<num_pixels; i++) |
2694 | 403 ((uint16_t *)dst)[i] = ((uint16_t *)palette)[ src[i] ]; |
404 } | |
7159
1df24fd752d0
added missing palette8tobgr pairs (hope it's correct)
alex
parents:
6614
diff
changeset
|
405 void palette8tobgr16(const uint8_t *src, uint8_t *dst, unsigned num_pixels, const uint8_t *palette) |
1df24fd752d0
added missing palette8tobgr pairs (hope it's correct)
alex
parents:
6614
diff
changeset
|
406 { |
1df24fd752d0
added missing palette8tobgr pairs (hope it's correct)
alex
parents:
6614
diff
changeset
|
407 unsigned i; |
1df24fd752d0
added missing palette8tobgr pairs (hope it's correct)
alex
parents:
6614
diff
changeset
|
408 for(i=0; i<num_pixels; i++) |
1df24fd752d0
added missing palette8tobgr pairs (hope it's correct)
alex
parents:
6614
diff
changeset
|
409 ((uint16_t *)dst)[i] = bswap_16(((uint16_t *)palette)[ src[i] ]); |
1df24fd752d0
added missing palette8tobgr pairs (hope it's correct)
alex
parents:
6614
diff
changeset
|
410 } |
2694 | 411 |
412 /** | |
413 * Pallete is assumed to contain bgr15, see rgb32to15 to convert the palette | |
414 */ | |
2718 | 415 void palette8torgb15(const uint8_t *src, uint8_t *dst, unsigned num_pixels, const uint8_t *palette) |
2694 | 416 { |
2718 | 417 unsigned i; |
2702 | 418 for(i=0; i<num_pixels; i++) |
2694 | 419 ((uint16_t *)dst)[i] = ((uint16_t *)palette)[ src[i] ]; |
2697 | 420 } |
7159
1df24fd752d0
added missing palette8tobgr pairs (hope it's correct)
alex
parents:
6614
diff
changeset
|
421 void palette8tobgr15(const uint8_t *src, uint8_t *dst, unsigned num_pixels, const uint8_t *palette) |
1df24fd752d0
added missing palette8tobgr pairs (hope it's correct)
alex
parents:
6614
diff
changeset
|
422 { |
1df24fd752d0
added missing palette8tobgr pairs (hope it's correct)
alex
parents:
6614
diff
changeset
|
423 unsigned i; |
1df24fd752d0
added missing palette8tobgr pairs (hope it's correct)
alex
parents:
6614
diff
changeset
|
424 for(i=0; i<num_pixels; i++) |
1df24fd752d0
added missing palette8tobgr pairs (hope it's correct)
alex
parents:
6614
diff
changeset
|
425 ((uint16_t *)dst)[i] = bswap_16(((uint16_t *)palette)[ src[i] ]); |
1df24fd752d0
added missing palette8tobgr pairs (hope it's correct)
alex
parents:
6614
diff
changeset
|
426 } |
2755 | 427 |
6606
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
428 void rgb32tobgr24(const uint8_t *src, uint8_t *dst, unsigned int src_size) |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
429 { |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
430 unsigned i; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
431 unsigned num_pixels = src_size >> 2; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
432 for(i=0; i<num_pixels; i++) |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
433 { |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
434 dst[3*i + 0] = src[4*i + 2]; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
435 dst[3*i + 1] = src[4*i + 1]; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
436 dst[3*i + 2] = src[4*i + 0]; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
437 } |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
438 } |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
439 |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
440 void rgb24tobgr32(const uint8_t *src, uint8_t *dst, unsigned int src_size) |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
441 { |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
442 unsigned i; |
6614 | 443 for(i=0; 3*i<src_size; i++) |
6606
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
444 { |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
445 dst[4*i + 0] = src[3*i + 2]; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
446 dst[4*i + 1] = src[3*i + 1]; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
447 dst[4*i + 2] = src[3*i + 0]; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
448 dst[4*i + 3] = 0; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
449 } |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
450 } |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
451 |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
452 void rgb16tobgr32(const uint8_t *src, uint8_t *dst, unsigned int src_size) |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
453 { |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
454 const uint16_t *end; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
455 uint8_t *d = (uint8_t *)dst; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
456 const uint16_t *s = (uint16_t *)src; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
457 end = s + src_size/2; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
458 while(s < end) |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
459 { |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
460 register uint16_t bgr; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
461 bgr = *s++; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
462 *d++ = (bgr&0xF800)>>8; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
463 *d++ = (bgr&0x7E0)>>3; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
464 *d++ = (bgr&0x1F)<<3; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
465 *d++ = 0; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
466 } |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
467 } |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
468 |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
469 void rgb16tobgr24(const uint8_t *src, uint8_t *dst, unsigned int src_size) |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
470 { |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
471 const uint16_t *end; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
472 uint8_t *d = (uint8_t *)dst; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
473 const uint16_t *s = (const uint16_t *)src; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
474 end = s + src_size/2; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
475 while(s < end) |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
476 { |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
477 register uint16_t bgr; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
478 bgr = *s++; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
479 *d++ = (bgr&0xF800)>>8; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
480 *d++ = (bgr&0x7E0)>>3; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
481 *d++ = (bgr&0x1F)<<3; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
482 } |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
483 } |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
484 |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
485 void rgb16tobgr16(const uint8_t *src, uint8_t *dst, unsigned int src_size) |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
486 { |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
487 unsigned i; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
488 unsigned num_pixels = src_size >> 1; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
489 |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
490 for(i=0; i<num_pixels; i++) |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
491 { |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
492 unsigned b,g,r; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
493 register uint16_t rgb; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
494 rgb = src[2*i]; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
495 r = rgb&0x1F; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
496 g = (rgb&0x7E0)>>5; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
497 b = (rgb&0xF800)>>11; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
498 dst[2*i] = (b&0x1F) | ((g&0x3F)<<5) | ((r&0x1F)<<11); |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
499 } |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
500 } |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
501 |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
502 void rgb16tobgr15(const uint8_t *src, uint8_t *dst, unsigned int src_size) |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
503 { |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
504 unsigned i; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
505 unsigned num_pixels = src_size >> 1; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
506 |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
507 for(i=0; i<num_pixels; i++) |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
508 { |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
509 unsigned b,g,r; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
510 register uint16_t rgb; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
511 rgb = src[2*i]; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
512 r = rgb&0x1F; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
513 g = (rgb&0x7E0)>>5; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
514 b = (rgb&0xF800)>>11; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
515 dst[2*i] = (b&0x1F) | ((g&0x1F)<<5) | ((r&0x1F)<<10); |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
516 } |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
517 } |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
518 |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
519 void rgb15tobgr32(const uint8_t *src, uint8_t *dst, unsigned int src_size) |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
520 { |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
521 const uint16_t *end; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
522 uint8_t *d = (uint8_t *)dst; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
523 const uint16_t *s = (const uint16_t *)src; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
524 end = s + src_size/2; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
525 while(s < end) |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
526 { |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
527 register uint16_t bgr; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
528 bgr = *s++; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
529 *d++ = (bgr&0x7C00)>>7; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
530 *d++ = (bgr&0x3E0)>>2; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
531 *d++ = (bgr&0x1F)<<3; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
532 *d++ = 0; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
533 } |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
534 } |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
535 |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
536 void rgb15tobgr24(const uint8_t *src, uint8_t *dst, unsigned int src_size) |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
537 { |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
538 const uint16_t *end; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
539 uint8_t *d = (uint8_t *)dst; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
540 const uint16_t *s = (uint16_t *)src; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
541 end = s + src_size/2; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
542 while(s < end) |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
543 { |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
544 register uint16_t bgr; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
545 bgr = *s++; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
546 *d++ = (bgr&0x7C00)>>7; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
547 *d++ = (bgr&0x3E0)>>2; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
548 *d++ = (bgr&0x1F)<<3; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
549 } |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
550 } |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
551 |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
552 void rgb15tobgr16(const uint8_t *src, uint8_t *dst, unsigned int src_size) |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
553 { |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
554 unsigned i; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
555 unsigned num_pixels = src_size >> 1; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
556 |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
557 for(i=0; i<num_pixels; i++) |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
558 { |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
559 unsigned b,g,r; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
560 register uint16_t rgb; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
561 rgb = src[2*i]; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
562 r = rgb&0x1F; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
563 g = (rgb&0x3E0)>>5; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
564 b = (rgb&0x7C00)>>10; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
565 dst[2*i] = (b&0x1F) | ((g&0x3F)<<5) | ((r&0x1F)<<11); |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
566 } |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
567 } |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
568 |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
569 void rgb15tobgr15(const uint8_t *src, uint8_t *dst, unsigned int src_size) |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
570 { |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
571 unsigned i; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
572 unsigned num_pixels = src_size >> 1; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
573 |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
574 for(i=0; i<num_pixels; i++) |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
575 { |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
576 unsigned b,g,r; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
577 register uint16_t rgb; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
578 rgb = src[2*i]; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
579 r = rgb&0x1F; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
580 g = (rgb&0x3E0)>>5; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
581 b = (rgb&0x7C00)>>10; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
582 dst[2*i] = (b&0x1F) | ((g&0x1F)<<5) | ((r&0x1F)<<10); |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
583 } |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
584 } |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
585 |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
586 void rgb8tobgr8(const uint8_t *src, uint8_t *dst, unsigned int src_size) |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
587 { |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
588 unsigned i; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
589 unsigned num_pixels = src_size; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
590 for(i=0; i<num_pixels; i++) |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
591 { |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
592 unsigned b,g,r; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
593 register uint8_t rgb; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
594 rgb = src[i]; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
595 r = (rgb&0x07); |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
596 g = (rgb&0x38)>>3; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
597 b = (rgb&0xC0)>>6; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
598 dst[i] = ((b<<1)&0x07) | ((g&0x07)<<3) | ((r&0x03)<<6); |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
599 } |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6582
diff
changeset
|
600 } |