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 \
437 TRANSFER_FRAME_HEAD \
438 transfer_YUV422_to_RGB565((output), (input), (input_column)); \
439 TRANSFER_FRAME_TAIL \
442 TRANSFER_FRAME_HEAD \
443 transfer_YUV422_to_RGB888((output), (input), (input_column)); \
444 TRANSFER_FRAME_TAIL \
447 TRANSFER_FRAME_HEAD \
448 transfer_YUV422_to_RGBA8888((output), (input), (input_column)); \
449 TRANSFER_FRAME_TAIL \
452 TRANSFER_FRAME_HEAD \
453 transfer_YUV422_to_YUV888((output), (input), (input_column)); \
454 TRANSFER_FRAME_TAIL \
457 TRANSFER_FRAME_HEAD \
458 transfer_YUV422_to_YUVA8888((output), (input), (input_column)); \
459 TRANSFER_FRAME_TAIL \
462 TRANSFER_FRAME_HEAD \
463 transfer_YUV422_to_RGB161616((uint16_t**)(output), (input), (input_column)); \
464 TRANSFER_FRAME_TAIL \
466 case BC_RGBA16161616: \
467 TRANSFER_FRAME_HEAD \
468 transfer_YUV422_to_RGBA16161616((uint16_t**)(output), (input), (input_column)); \
469 TRANSFER_FRAME_TAIL \
472 TRANSFER_FRAME_HEAD \
473 transfer_YUV422_to_RGB_FLOAT((float**)(output), (input), (input_column)); \
474 TRANSFER_FRAME_TAIL \
476 case BC_RGBA_FLOAT: \
477 TRANSFER_FRAME_HEAD \
478 transfer_YUV422_to_RGBA_FLOAT((float**)(output), (input), (input_column)); \
479 TRANSFER_FRAME_TAIL \
482 TRANSFER_FRAME_HEAD \
483 transfer_YUV422_to_YUV161616((uint16_t**)(output), (input), (input_column)); \
484 TRANSFER_FRAME_TAIL \
486 case BC_YUVA16161616: \
487 TRANSFER_FRAME_HEAD \
488 transfer_YUV422_to_YUVA16161616((uint16_t**)(output), (input), (input_column)); \
489 TRANSFER_FRAME_TAIL \
492 TRANSFER_FRAME_HEAD \
493 transfer_YUV422_to_BGR888((output), (input), (input_column)); \
494 TRANSFER_FRAME_TAIL \
497 TRANSFER_FRAME_HEAD \
498 transfer_YUV422_to_BGR8888((output), (input), (input_column)); \
499 TRANSFER_FRAME_TAIL \
502 TRANSFER_YUV422P_OUT_HEAD \
503 transfer_YUV422_to_YUV422P(output_y, \
508 TRANSFER_FRAME_TAIL \
511 TRANSFER_FRAME_HEAD \
512 transfer_YUV422_to_YUV422((output), \
515 TRANSFER_FRAME_TAIL \
518 TRANSFER_YUV420P_OUT_HEAD \
519 transfer_YUV422_to_YUV420P(output_y, \
525 TRANSFER_FRAME_TAIL \
530 void cmodel_yuv422(PERMUTATION_ARGS
)
534 TRANSFER_FRAME_DEFAULT(&output_row
,
535 input_row
+ ((column_table
[j
] * in_pixelsize
) & 0xfffffffc),
543 TRANSFER_FRAME_DEFAULT(&output_row
,
544 input_row
+ ((j
* in_pixelsize
) & 0xfffffffc),