2 * This library is free software; you can redistribute it and/or modify it
3 * under the terms of the GNU Lesser General Public License as published
4 * by the Free Software Foundation; either version 2 of the License, or
5 * (at your option) any later version.
7 * This library is distributed in the hope that it will be useful, but
8 * WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10 * Lesser General Public License for more details.
12 * You should have received a copy of the GNU Lesser General Public
13 * License along with this library; if not, write to the Free Software
14 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19 #include "cmodel_permutation.h"
23 static inline void transfer_YUV422_to_RGB8(unsigned char *(*output),
32 y = (int)(input[0]) << 16;
35 y = (int)(input[2]) << 16;
39 YUV_TO_RGB(y, u, v, r, g, b)
41 *(*output) = (unsigned char)((r & 0xc0) +
47 static inline void transfer_YUV422_to_BGR565(unsigned char *(*output),
56 y = (int)(input[0]) << 16;
59 y = (int)(input[2]) << 16;
62 YUV_TO_RGB(y, u, v, r, g, b)
64 *(uint16_t*)(*output) = ((b & 0xf8) << 8)
70 static inline void transfer_YUV422_to_RGB565(unsigned char *(*output),
79 y = (int)(input[0]) << 16;
82 y = (int)(input[2]) << 16;
85 YUV_TO_RGB(y, u, v, r, g, b)
87 *(uint16_t*)(*output) = ((r & 0xf8) << 8)
93 static inline void transfer_YUV422_to_BGR888(unsigned char *(*output),
102 y = (int)(input[0]) << 16;
105 y = (int)(input[2]) << 16;
108 YUV_TO_RGB(y, u, v, r, g, b)
116 static inline void transfer_YUV422_to_RGB888(unsigned char *(*output),
117 unsigned char *input,
125 y = (input[0] << 16) | (input[0] << 8) | input[0];
128 y = (input[2] << 16) | (input[2] << 8) | input[2];
131 YUV_TO_RGB(y, u, v, r, g, b)
139 static inline void transfer_YUV422_to_RGBA8888(unsigned char *(*output),
140 unsigned char *input,
148 y = (input[0] << 16) | (input[0] << 8) | input[0];
151 y = (input[2] << 16) | (input[2] << 8) | input[2];
154 YUV_TO_RGB(y, u, v, r, g, b)
163 static inline void transfer_YUV422_to_RGB161616(uint16_t *(*output),
164 unsigned char *input,
172 y = (input[0] << 16) | (input[0] << 8) | input[0];
175 y = (input[2] << 16) | (input[2] << 8) | input[2];
176 u = (input[1] << 8) | input[1];
177 v = (input[3] << 8) | input[3];
178 YUV_TO_RGB16(y, u, v, r, g, b)
186 static inline void transfer_YUV422_to_RGBA16161616(uint16_t *(*output),
187 unsigned char *input,
195 y = (input[0] << 16) | (input[0] << 8) | input[0];
198 y = (input[2] << 16) | (input[2] << 8) | input[2];
199 u = (input[1] << 8) | input[1];
200 v = (input[3] << 8) | input[3];
201 YUV_TO_RGB16(y, u, v, r, g, b)
206 (*output)[3] = 0xffff;
210 static inline void transfer_YUV422_to_RGB_FLOAT(float* *output,
211 unsigned char *input,
215 // Signedness is important
221 y = (float)input[0] / 0xff;
224 y = (float)input[2] / 0xff;
227 YUV_TO_FLOAT(y, u, v, r, g, b)
234 static inline void transfer_YUV422_to_RGBA_FLOAT(float* *output,
235 unsigned char *input,
239 // Signedness is important
245 y = (float)input[0] / 0xff;
248 y = (float)input[2] / 0xff;
251 YUV_TO_FLOAT(y, u, v, r, g, b)
259 static inline void transfer_YUV422_to_YUV888(unsigned char *(*output),
260 unsigned char *input,
265 (*output)[0] = input[0];
268 (*output)[0] = input[2];
270 (*output)[1] = input[1];
271 (*output)[2] = input[3];
275 static inline void transfer_YUV422_to_YUVA8888(unsigned char *(*output),
276 unsigned char *input,
281 (*output)[0] = input[0];
284 (*output)[0] = input[2];
286 (*output)[1] = input[1];
287 (*output)[2] = input[3];
292 static inline void transfer_YUV422_to_YUV161616(uint16_t *(*output),
293 unsigned char *input,
298 (*output)[0] = (input[0] << 8) | input[0];
301 (*output)[0] = (input[2] << 8) | input[2];
303 (*output)[1] = (input[1] << 8) | input[1];
304 (*output)[2] = (input[3] << 8) | input[3];
308 static inline void transfer_YUV422_to_YUVA16161616(uint16_t *(*output),
309 unsigned char *input,
314 (*output)[0] = (input[0] << 8) | input[0];
317 (*output)[0] = (input[2] << 8) | input[2];
319 (*output)[1] = (input[1] << 8) | input[1];
320 (*output)[2] = (input[3] << 8) | input[3];
321 (*output)[3] = 0xffff;
325 static inline void transfer_YUV422_to_BGR8888(unsigned char *(*output),
326 unsigned char *input,
334 y = (int)(input[0]) << 16;
337 y = (int)(input[2]) << 16;
341 YUV_TO_RGB(y, u, v, r, g, b)
350 static inline void transfer_YUV422_to_YUV422P(unsigned char *output_y,
351 unsigned char *output_u,
352 unsigned char *output_v,
353 unsigned char *input,
356 // Store U and V for even pixels only
357 if(!(output_column & 1))
359 output_y[output_column] = input[0];
360 output_u[output_column / 2] = input[1];
361 output_v[output_column / 2] = input[3];
364 // Store Y and advance output for odd pixels only
366 output_y[output_column] = input[2];
370 static inline void transfer_YUV422_to_YUV420P(unsigned char *output_y,
371 unsigned char *output_u,
372 unsigned char *output_v,
373 unsigned char *input,
378 if(!(output_column & 1))
380 output_y[output_column] = input[0];
381 // Store U and V for even columns and even rows only
382 if(!(output_row & 1))
384 output_u[output_column / 2] = input[1];
385 output_v[output_column / 2] = input[3];
391 output_y[output_column] = input[2];
395 static inline void transfer_YUV422_to_YUV422(unsigned char *(*output),
396 unsigned char *input,
399 // Store U and V for even pixels only
402 (*output)[0] = input[0];
403 (*output)[1] = input[1];
404 (*output)[3] = input[3];
407 // Store Y and advance output for odd pixels only
409 (*output)[2] = input[2];
419 #define TRANSFER_FRAME_DEFAULT(output, \
428 switch(out_colormodel) \
431 TRANSFER_FRAME_HEAD \
432 transfer_YUV422_to_RGB8((output), (input), (input_column)); \
433 TRANSFER_FRAME_TAIL \
436 TRANSFER_FRAME_HEAD \
437 transfer_YUV422_to_BGR565((output), \
440 TRANSFER_FRAME_TAIL \
443 TRANSFER_FRAME_HEAD \
444 transfer_YUV422_to_RGB565((output), (input), (input_column)); \
445 TRANSFER_FRAME_TAIL \
448 TRANSFER_FRAME_HEAD \
449 transfer_YUV422_to_RGB888((output), (input), (input_column)); \
450 TRANSFER_FRAME_TAIL \
453 TRANSFER_FRAME_HEAD \
454 transfer_YUV422_to_RGBA8888((output), (input), (input_column)); \
455 TRANSFER_FRAME_TAIL \
458 TRANSFER_FRAME_HEAD \
459 transfer_YUV422_to_YUV888((output), (input), (input_column)); \
460 TRANSFER_FRAME_TAIL \
463 TRANSFER_FRAME_HEAD \
464 transfer_YUV422_to_YUVA8888((output), (input), (input_column)); \
465 TRANSFER_FRAME_TAIL \
468 TRANSFER_FRAME_HEAD \
469 transfer_YUV422_to_RGB161616((uint16_t**)(output), (input), (input_column)); \
470 TRANSFER_FRAME_TAIL \
472 case BC_RGBA16161616: \
473 TRANSFER_FRAME_HEAD \
474 transfer_YUV422_to_RGBA16161616((uint16_t**)(output), (input), (input_column)); \
475 TRANSFER_FRAME_TAIL \
478 TRANSFER_FRAME_HEAD \
479 transfer_YUV422_to_RGB_FLOAT((float**)(output), (input), (input_column)); \
480 TRANSFER_FRAME_TAIL \
482 case BC_RGBA_FLOAT: \
483 TRANSFER_FRAME_HEAD \
484 transfer_YUV422_to_RGBA_FLOAT((float**)(output), (input), (input_column)); \
485 TRANSFER_FRAME_TAIL \
488 TRANSFER_FRAME_HEAD \
489 transfer_YUV422_to_YUV161616((uint16_t**)(output), (input), (input_column)); \
490 TRANSFER_FRAME_TAIL \
492 case BC_YUVA16161616: \
493 TRANSFER_FRAME_HEAD \
494 transfer_YUV422_to_YUVA16161616((uint16_t**)(output), (input), (input_column)); \
495 TRANSFER_FRAME_TAIL \
498 TRANSFER_FRAME_HEAD \
499 transfer_YUV422_to_BGR888((output), (input), (input_column)); \
500 TRANSFER_FRAME_TAIL \
503 TRANSFER_FRAME_HEAD \
504 transfer_YUV422_to_BGR8888((output), (input), (input_column)); \
505 TRANSFER_FRAME_TAIL \
508 TRANSFER_YUV422P_OUT_HEAD \
509 transfer_YUV422_to_YUV422P(output_y, \
514 TRANSFER_FRAME_TAIL \
517 TRANSFER_FRAME_HEAD \
518 transfer_YUV422_to_YUV422((output), \
521 TRANSFER_FRAME_TAIL \
524 TRANSFER_YUV420P_OUT_HEAD \
525 transfer_YUV422_to_YUV420P(output_y, \
531 TRANSFER_FRAME_TAIL \
536 void cmodel_yuv422(PERMUTATION_ARGS)
540 TRANSFER_FRAME_DEFAULT(&output_row,
541 input_row + ((column_table[j] * in_pixelsize) & 0xfffffffc),
549 TRANSFER_FRAME_DEFAULT(&output_row,
550 input_row + ((j * in_pixelsize) & 0xfffffffc),