comparison libswscale/yuv2rgb.c @ 29441:3b88f0acdc0b

Remove 'offset' argument from PUTRGB* macros since it's unneeded and caused pixel swapping during some YUV2RGB conversions.
author kostya
date Sun, 09 Aug 2009 15:04:17 +0000
parents 059ff1f4e280
children c080f1f5c07e
comparison
equal deleted inserted replaced
29440:0673fad0546f 29441:3b88f0acdc0b
54 V = pv[i]; \ 54 V = pv[i]; \
55 r = (void *)c->table_rV[V]; \ 55 r = (void *)c->table_rV[V]; \
56 g = (void *)(c->table_gU[U] + c->table_gV[V]); \ 56 g = (void *)(c->table_gU[U] + c->table_gV[V]); \
57 b = (void *)c->table_bU[U]; 57 b = (void *)c->table_bU[U];
58 58
59 #define PUTRGB(dst,src,i,o) \ 59 #define PUTRGB(dst,src,i) \
60 Y = src[2*i+o]; \ 60 Y = src[2*i]; \
61 dst[2*i ] = r[Y] + g[Y] + b[Y]; \ 61 dst[2*i ] = r[Y] + g[Y] + b[Y]; \
62 Y = src[2*i+1-o]; \ 62 Y = src[2*i+1]; \
63 dst[2*i+1] = r[Y] + g[Y] + b[Y]; 63 dst[2*i+1] = r[Y] + g[Y] + b[Y];
64 64
65 #define PUTRGB24(dst,src,i) \ 65 #define PUTRGB24(dst,src,i) \
66 Y = src[2*i]; \ 66 Y = src[2*i]; \
67 dst[6*i+0] = r[Y]; dst[6*i+1] = g[Y]; dst[6*i+2] = b[Y]; \ 67 dst[6*i+0] = r[Y]; dst[6*i+1] = g[Y]; dst[6*i+2] = b[Y]; \
72 Y = src[2*i]; \ 72 Y = src[2*i]; \
73 dst[6*i+0] = b[Y]; dst[6*i+1] = g[Y]; dst[6*i+2] = r[Y]; \ 73 dst[6*i+0] = b[Y]; dst[6*i+1] = g[Y]; dst[6*i+2] = r[Y]; \
74 Y = src[2*i+1]; \ 74 Y = src[2*i+1]; \
75 dst[6*i+3] = b[Y]; dst[6*i+4] = g[Y]; dst[6*i+5] = r[Y]; 75 dst[6*i+3] = b[Y]; dst[6*i+4] = g[Y]; dst[6*i+5] = r[Y];
76 76
77 #define PUTRGBA(dst,ysrc,asrc,i,o,s) \ 77 #define PUTRGBA(dst,ysrc,asrc,i,s) \
78 Y = ysrc[2*i+o]; \ 78 Y = ysrc[2*i]; \
79 dst[2*i ] = r[Y] + g[Y] + b[Y] + (asrc[2*i ]<<s); \ 79 dst[2*i ] = r[Y] + g[Y] + b[Y] + (asrc[2*i ]<<s); \
80 Y = ysrc[2*i+1-o]; \ 80 Y = ysrc[2*i+1]; \
81 dst[2*i+1] = r[Y] + g[Y] + b[Y] + (asrc[2*i+1]<<s); 81 dst[2*i+1] = r[Y] + g[Y] + b[Y] + (asrc[2*i+1]<<s);
82 82
83 #define PUTRGB48(dst,src,i) \ 83 #define PUTRGB48(dst,src,i) \
84 Y = src[2*i]; \ 84 Y = src[2*i]; \
85 dst[12*i+ 0] = dst[12*i+ 1] = r[Y]; \ 85 dst[12*i+ 0] = dst[12*i+ 1] = r[Y]; \
165 PUTRGB48(dst_1,py_1,1); 165 PUTRGB48(dst_1,py_1,1);
166 ENDYUV2RGBFUNC() 166 ENDYUV2RGBFUNC()
167 167
168 YUV2RGBFUNC(yuv2rgb_c_32, uint32_t, 0) 168 YUV2RGBFUNC(yuv2rgb_c_32, uint32_t, 0)
169 LOADCHROMA(0); 169 LOADCHROMA(0);
170 PUTRGB(dst_1,py_1,0,0); 170 PUTRGB(dst_1,py_1,0);
171 PUTRGB(dst_2,py_2,0,1); 171 PUTRGB(dst_2,py_2,0);
172 172
173 LOADCHROMA(1); 173 LOADCHROMA(1);
174 PUTRGB(dst_2,py_2,1,1); 174 PUTRGB(dst_2,py_2,1);
175 PUTRGB(dst_1,py_1,1,0); 175 PUTRGB(dst_1,py_1,1);
176 176
177 LOADCHROMA(2); 177 LOADCHROMA(2);
178 PUTRGB(dst_1,py_1,2,0); 178 PUTRGB(dst_1,py_1,2);
179 PUTRGB(dst_2,py_2,2,1); 179 PUTRGB(dst_2,py_2,2);
180 180
181 LOADCHROMA(3); 181 LOADCHROMA(3);
182 PUTRGB(dst_2,py_2,3,1); 182 PUTRGB(dst_2,py_2,3);
183 PUTRGB(dst_1,py_1,3,0); 183 PUTRGB(dst_1,py_1,3);
184 ENDYUV2RGBLINE(8) 184 ENDYUV2RGBLINE(8)
185 LOADCHROMA(0); 185 LOADCHROMA(0);
186 PUTRGB(dst_1,py_1,0,0); 186 PUTRGB(dst_1,py_1,0);
187 PUTRGB(dst_2,py_2,0,1); 187 PUTRGB(dst_2,py_2,0);
188 188
189 LOADCHROMA(1); 189 LOADCHROMA(1);
190 PUTRGB(dst_2,py_2,1,1); 190 PUTRGB(dst_2,py_2,1);
191 PUTRGB(dst_1,py_1,1,0); 191 PUTRGB(dst_1,py_1,1);
192 ENDYUV2RGBFUNC() 192 ENDYUV2RGBFUNC()
193 193
194 YUV2RGBFUNC(yuva2rgba_c, uint32_t, 1) 194 YUV2RGBFUNC(yuva2rgba_c, uint32_t, 1)
195 LOADCHROMA(0); 195 LOADCHROMA(0);
196 PUTRGBA(dst_1,py_1,pa_1,0,0,24); 196 PUTRGBA(dst_1,py_1,pa_1,0,24);
197 PUTRGBA(dst_2,py_2,pa_2,0,1,24); 197 PUTRGBA(dst_2,py_2,pa_2,0,24);
198 198
199 LOADCHROMA(1); 199 LOADCHROMA(1);
200 PUTRGBA(dst_2,py_2,pa_1,1,1,24); 200 PUTRGBA(dst_2,py_2,pa_1,1,24);
201 PUTRGBA(dst_1,py_1,pa_2,1,0,24); 201 PUTRGBA(dst_1,py_1,pa_2,1,24);
202 202
203 LOADCHROMA(2); 203 LOADCHROMA(2);
204 PUTRGBA(dst_1,py_1,pa_1,2,0,24); 204 PUTRGBA(dst_1,py_1,pa_1,2,24);
205 PUTRGBA(dst_2,py_2,pa_2,2,1,24); 205 PUTRGBA(dst_2,py_2,pa_2,2,24);
206 206
207 LOADCHROMA(3); 207 LOADCHROMA(3);
208 PUTRGBA(dst_2,py_2,pa_1,3,1,24); 208 PUTRGBA(dst_2,py_2,pa_1,3,24);
209 PUTRGBA(dst_1,py_1,pa_2,3,0,24); 209 PUTRGBA(dst_1,py_1,pa_2,3,24);
210 pa_1 += 8;\ 210 pa_1 += 8;\
211 pa_2 += 8;\ 211 pa_2 += 8;\
212 ENDYUV2RGBLINE(8) 212 ENDYUV2RGBLINE(8)
213 LOADCHROMA(0); 213 LOADCHROMA(0);
214 PUTRGBA(dst_1,py_1,pa_1,0,0,24); 214 PUTRGBA(dst_1,py_1,pa_1,0,24);
215 PUTRGBA(dst_2,py_2,pa_2,0,1,24); 215 PUTRGBA(dst_2,py_2,pa_2,0,24);
216 216
217 LOADCHROMA(1); 217 LOADCHROMA(1);
218 PUTRGBA(dst_2,py_2,pa_1,1,1,24); 218 PUTRGBA(dst_2,py_2,pa_1,1,24);
219 PUTRGBA(dst_1,py_1,pa_2,1,0,24); 219 PUTRGBA(dst_1,py_1,pa_2,1,24);
220 ENDYUV2RGBFUNC() 220 ENDYUV2RGBFUNC()
221 221
222 YUV2RGBFUNC(yuva2argb_c, uint32_t, 1) 222 YUV2RGBFUNC(yuva2argb_c, uint32_t, 1)
223 LOADCHROMA(0); 223 LOADCHROMA(0);
224 PUTRGBA(dst_1,py_1,pa_1,0,0,0); 224 PUTRGBA(dst_1,py_1,pa_1,0,0);
225 PUTRGBA(dst_2,py_2,pa_2,0,1,0); 225 PUTRGBA(dst_2,py_2,pa_2,0,0);
226 226
227 LOADCHROMA(1); 227 LOADCHROMA(1);
228 PUTRGBA(dst_2,py_2,pa_2,1,1,0); 228 PUTRGBA(dst_2,py_2,pa_2,1,0);
229 PUTRGBA(dst_1,py_1,pa_1,1,0,0); 229 PUTRGBA(dst_1,py_1,pa_1,1,0);
230 230
231 LOADCHROMA(2); 231 LOADCHROMA(2);
232 PUTRGBA(dst_1,py_1,pa_1,2,0,0); 232 PUTRGBA(dst_1,py_1,pa_1,2,0);
233 PUTRGBA(dst_2,py_2,pa_2,2,1,0); 233 PUTRGBA(dst_2,py_2,pa_2,2,0);
234 234
235 LOADCHROMA(3); 235 LOADCHROMA(3);
236 PUTRGBA(dst_2,py_2,pa_2,3,1,0); 236 PUTRGBA(dst_2,py_2,pa_2,3,0);
237 PUTRGBA(dst_1,py_1,pa_1,3,0,0); 237 PUTRGBA(dst_1,py_1,pa_1,3,0);
238 pa_1 += 8;\ 238 pa_1 += 8;\
239 pa_2 += 8;\ 239 pa_2 += 8;\
240 ENDYUV2RGBLINE(8) 240 ENDYUV2RGBLINE(8)
241 LOADCHROMA(0); 241 LOADCHROMA(0);
242 PUTRGBA(dst_1,py_1,pa_1,0,0,0); 242 PUTRGBA(dst_1,py_1,pa_1,0,0);
243 PUTRGBA(dst_2,py_2,pa_2,0,1,0); 243 PUTRGBA(dst_2,py_2,pa_2,0,0);
244 244
245 LOADCHROMA(1); 245 LOADCHROMA(1);
246 PUTRGBA(dst_2,py_2,pa_2,1,1,0); 246 PUTRGBA(dst_2,py_2,pa_2,1,0);
247 PUTRGBA(dst_1,py_1,pa_1,1,0,0); 247 PUTRGBA(dst_1,py_1,pa_1,1,0);
248 ENDYUV2RGBFUNC() 248 ENDYUV2RGBFUNC()
249 249
250 YUV2RGBFUNC(yuv2rgb_c_24_rgb, uint8_t, 0) 250 YUV2RGBFUNC(yuv2rgb_c_24_rgb, uint8_t, 0)
251 LOADCHROMA(0); 251 LOADCHROMA(0);
252 PUTRGB24(dst_1,py_1,0); 252 PUTRGB24(dst_1,py_1,0);
302 302
303 // This is exactly the same code as yuv2rgb_c_32 except for the types of 303 // This is exactly the same code as yuv2rgb_c_32 except for the types of
304 // r, g, b, dst_1, dst_2 304 // r, g, b, dst_1, dst_2
305 YUV2RGBFUNC(yuv2rgb_c_16, uint16_t, 0) 305 YUV2RGBFUNC(yuv2rgb_c_16, uint16_t, 0)
306 LOADCHROMA(0); 306 LOADCHROMA(0);
307 PUTRGB(dst_1,py_1,0,0); 307 PUTRGB(dst_1,py_1,0);
308 PUTRGB(dst_2,py_2,0,1); 308 PUTRGB(dst_2,py_2,0);
309 309
310 LOADCHROMA(1); 310 LOADCHROMA(1);
311 PUTRGB(dst_2,py_2,1,1); 311 PUTRGB(dst_2,py_2,1);
312 PUTRGB(dst_1,py_1,1,0); 312 PUTRGB(dst_1,py_1,1);
313 313
314 LOADCHROMA(2); 314 LOADCHROMA(2);
315 PUTRGB(dst_1,py_1,2,0); 315 PUTRGB(dst_1,py_1,2);
316 PUTRGB(dst_2,py_2,2,1); 316 PUTRGB(dst_2,py_2,2);
317 317
318 LOADCHROMA(3); 318 LOADCHROMA(3);
319 PUTRGB(dst_2,py_2,3,1); 319 PUTRGB(dst_2,py_2,3);
320 PUTRGB(dst_1,py_1,3,0); 320 PUTRGB(dst_1,py_1,3);
321 CLOSEYUV2RGBFUNC(8) 321 CLOSEYUV2RGBFUNC(8)
322 322
323 // This is exactly the same code as yuv2rgb_c_32 except for the types of 323 // This is exactly the same code as yuv2rgb_c_32 except for the types of
324 // r, g, b, dst_1, dst_2 324 // r, g, b, dst_1, dst_2
325 YUV2RGBFUNC(yuv2rgb_c_8, uint8_t, 0) 325 YUV2RGBFUNC(yuv2rgb_c_8, uint8_t, 0)
326 LOADCHROMA(0); 326 LOADCHROMA(0);
327 PUTRGB(dst_1,py_1,0,0); 327 PUTRGB(dst_1,py_1,0);
328 PUTRGB(dst_2,py_2,0,1); 328 PUTRGB(dst_2,py_2,0);
329 329
330 LOADCHROMA(1); 330 LOADCHROMA(1);
331 PUTRGB(dst_2,py_2,1,1); 331 PUTRGB(dst_2,py_2,1);
332 PUTRGB(dst_1,py_1,1,0); 332 PUTRGB(dst_1,py_1,1);
333 333
334 LOADCHROMA(2); 334 LOADCHROMA(2);
335 PUTRGB(dst_1,py_1,2,0); 335 PUTRGB(dst_1,py_1,2);
336 PUTRGB(dst_2,py_2,2,1); 336 PUTRGB(dst_2,py_2,2);
337 337
338 LOADCHROMA(3); 338 LOADCHROMA(3);
339 PUTRGB(dst_2,py_2,3,1); 339 PUTRGB(dst_2,py_2,3);
340 PUTRGB(dst_1,py_1,3,0); 340 PUTRGB(dst_1,py_1,3);
341 CLOSEYUV2RGBFUNC(8) 341 CLOSEYUV2RGBFUNC(8)
342 342
343 // r, g, b, dst_1, dst_2 343 // r, g, b, dst_1, dst_2
344 YUV2RGBFUNC(yuv2rgb_c_8_ordered_dither, uint8_t, 0) 344 YUV2RGBFUNC(yuv2rgb_c_8_ordered_dither, uint8_t, 0)
345 const uint8_t *d32 = dither_8x8_32[y&7]; 345 const uint8_t *d32 = dither_8x8_32[y&7];
427 427
428 // This is exactly the same code as yuv2rgb_c_32 except for the types of 428 // This is exactly the same code as yuv2rgb_c_32 except for the types of
429 // r, g, b, dst_1, dst_2 429 // r, g, b, dst_1, dst_2
430 YUV2RGBFUNC(yuv2rgb_c_4b, uint8_t, 0) 430 YUV2RGBFUNC(yuv2rgb_c_4b, uint8_t, 0)
431 LOADCHROMA(0); 431 LOADCHROMA(0);
432 PUTRGB(dst_1,py_1,0,0); 432 PUTRGB(dst_1,py_1,0);
433 PUTRGB(dst_2,py_2,0,1); 433 PUTRGB(dst_2,py_2,0);
434 434
435 LOADCHROMA(1); 435 LOADCHROMA(1);
436 PUTRGB(dst_2,py_2,1,1); 436 PUTRGB(dst_2,py_2,1);
437 PUTRGB(dst_1,py_1,1,0); 437 PUTRGB(dst_1,py_1,1);
438 438
439 LOADCHROMA(2); 439 LOADCHROMA(2);
440 PUTRGB(dst_1,py_1,2,0); 440 PUTRGB(dst_1,py_1,2);
441 PUTRGB(dst_2,py_2,2,1); 441 PUTRGB(dst_2,py_2,2);
442 442
443 LOADCHROMA(3); 443 LOADCHROMA(3);
444 PUTRGB(dst_2,py_2,3,1); 444 PUTRGB(dst_2,py_2,3);
445 PUTRGB(dst_1,py_1,3,0); 445 PUTRGB(dst_1,py_1,3);
446 CLOSEYUV2RGBFUNC(8) 446 CLOSEYUV2RGBFUNC(8)
447 447
448 YUV2RGBFUNC(yuv2rgb_c_4b_ordered_dither, uint8_t, 0) 448 YUV2RGBFUNC(yuv2rgb_c_4b_ordered_dither, uint8_t, 0)
449 const uint8_t *d64 = dither_8x8_73[y&7]; 449 const uint8_t *d64 = dither_8x8_73[y&7];
450 const uint8_t *d128 = dither_8x8_220[y&7]; 450 const uint8_t *d128 = dither_8x8_220[y&7];