00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include "colormodels.h"
00018 #include <stdint.h>
00019
00020
00021
00022 #define YUV_TO_RGB(y, u, v, r, g, b) \
00023 { \
00024 (r) = ((y + yuv_table->vtor_tab[v]) >> 16); \
00025 (g) = ((y + yuv_table->utog_tab[u] + yuv_table->vtog_tab[v]) >> 16); \
00026 (b) = ((y + yuv_table->utob_tab[u]) >> 16); \
00027 CLAMP(r, 0, 0xff); \
00028 CLAMP(g, 0, 0xff); \
00029 CLAMP(b, 0, 0xff); \
00030 }
00031
00032
00033
00034
00035 #define YUV_TO_FLOAT(y, u, v, r, g, b) \
00036 { \
00037 (r) = y + yuv_table->vtor_float_tab[v]; \
00038 (g) = y + yuv_table->utog_float_tab[u] + yuv_table->vtog_float_tab[v]; \
00039 (b) = y + yuv_table->utob_float_tab[u]; \
00040 }
00041
00042
00043
00044
00045 #define YUV16_TO_RGB_FLOAT(y, u, v, r, g, b) \
00046 { \
00047 (r) = y + yuv_table->v16tor_float_tab[v]; \
00048 (g) = y + yuv_table->u16tog_float_tab[u] + yuv_table->v16tog_float_tab[v]; \
00049 (b) = y + yuv_table->u16tob_float_tab[u]; \
00050 }
00051
00052
00053 #define YUV_TO_RGB16(y, u, v, r, g, b) \
00054 { \
00055 (r) = ((y + yuv_table->vtor_tab16[v]) >> 8); \
00056 (g) = ((y + yuv_table->utog_tab16[u] + yuv_table->vtog_tab16[v]) >> 8); \
00057 (b) = ((y + yuv_table->utob_tab16[u]) >> 8); \
00058 CLAMP(r, 0, 0xffff); \
00059 CLAMP(g, 0, 0xffff); \
00060 CLAMP(b, 0, 0xffff); \
00061 }
00062
00063
00064
00065
00066 #define RGB_TO_YUV(y, u, v, r, g, b) \
00067 { \
00068 y = ((yuv_table->rtoy_tab[r] + yuv_table->gtoy_tab[g] + yuv_table->btoy_tab[b]) >> 16); \
00069 u = ((yuv_table->rtou_tab[r] + yuv_table->gtou_tab[g] + yuv_table->btou_tab[b]) >> 16); \
00070 v = ((yuv_table->rtov_tab[r] + yuv_table->gtov_tab[g] + yuv_table->btov_tab[b]) >> 16); \
00071 CLAMP(y, 0, 0xff); \
00072 CLAMP(u, 0, 0xff); \
00073 CLAMP(v, 0, 0xff); \
00074 }
00075
00076
00077 #define RGB_TO_YUV16(y, u, v, r, g, b) \
00078 { \
00079 y = ((yuv_table->rtoy_tab16[r] + yuv_table->gtoy_tab16[g] + yuv_table->btoy_tab16[b]) >> 8); \
00080 u = ((yuv_table->rtou_tab16[r] + yuv_table->gtou_tab16[g] + yuv_table->btou_tab16[b]) >> 8); \
00081 v = ((yuv_table->rtov_tab16[r] + yuv_table->gtov_tab16[g] + yuv_table->btov_tab16[b]) >> 8); \
00082 CLAMP(y, 0, 0xffff); \
00083 CLAMP(u, 0, 0xffff); \
00084 CLAMP(v, 0, 0xffff); \
00085 }
00086
00087 #define WRITE_YUV101010(y, u, v) \
00088 { \
00089 uint32_t output_i = ((y & 0xffc0) << 16) | \
00090 ((u & 0xffc0) << 6) | \
00091 ((v & 0xffc0) >> 4); \
00092 *(*output)++ = (output_i & 0xff); \
00093 *(*output)++ = (output_i & 0xff00) >> 8; \
00094 *(*output)++ = (output_i & 0xff0000) >> 16; \
00095 *(*output)++ = (output_i & 0xff000000) >> 24; \
00096 }
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109 static inline void transfer_ARGB8888_to_ARGB8888(unsigned char *(*output), unsigned char *input)
00110 {
00111 (*output)[0] = input[0];
00112 (*output)[1] = input[1];
00113 (*output)[2] = input[2];
00114 (*output)[3] = input[3];
00115 (*output) += 4;
00116 }
00117
00118 static inline void transfer_ARGB8888_to_RGBA8888(unsigned char *(*output), unsigned char *input)
00119 {
00120 (*output)[0] = input[1];
00121 (*output)[1] = input[2];
00122 (*output)[2] = input[3];
00123 (*output)[3] = input[0];
00124 (*output) += 4;
00125 }
00126
00127
00128 static inline void transfer_ARGB8888_to_RGB888(unsigned char *(*output), unsigned char *input)
00129 {
00130 int a = input[0];
00131 (*output)[0] = input[1] * a / 0xff;
00132 (*output)[1] = input[2] * a / 0xff;
00133 (*output)[2] = input[3] * a / 0xff;
00134 (*output) += 3;
00135 }
00136
00137 static inline void transfer_ARGB8888_to_BGR8888(unsigned char *(*output), unsigned char *input)
00138 {
00139 int a = input[0];
00140 (*output)[0] = input[3] * a / 0xff;
00141 (*output)[1] = input[2] * a / 0xff;
00142 (*output)[2] = input[1] * a / 0xff;
00143 (*output) += 3;
00144 }
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162 static inline void transfer_RGB888_to_RGB8(unsigned char *(*output), unsigned char *input)
00163 {
00164 *(*output) = (unsigned char)((input[0] & 0xc0) +
00165 ((input[1] & 0xe0) >> 2) +
00166 ((input[2] & 0xe0) >> 5));
00167 (*output)++;
00168 }
00169
00170 static inline void transfer_RGB888_to_BGR565(unsigned char *(*output), unsigned char *input)
00171 {
00172 uint16_t r, g, b;
00173 uint16_t r_s, g_s, b_s;
00174 r = *input++;
00175 g = *input++;
00176 b = *input;
00177
00178 r_s = (r & 0x01) << 7;
00179 r_s |= (r & 0x02) << 5;
00180 r_s |= (r & 0x04) << 3;
00181 r_s |= (r & 0x08) << 1;
00182 r_s |= (r & 0x10) >> 1;
00183 r_s |= (r & 0x20) >> 3;
00184 r_s |= (r & 0x40) >> 5;
00185 r_s |= (r & 0x80) >> 7;
00186
00187 g_s = (g & 0x01) << 7;
00188 g_s |= (g & 0x02) << 5;
00189 g_s |= (g & 0x04) << 3;
00190 g_s |= (g & 0x08) << 1;
00191 g_s |= (g & 0x10) >> 1;
00192 g_s |= (g & 0x20) >> 3;
00193 g_s |= (g & 0x40) >> 5;
00194 g_s |= (g & 0x80) >> 7;
00195
00196 b_s = (b & 0x01) << 7;
00197 b_s |= (b & 0x02) << 5;
00198 b_s |= (b & 0x04) << 3;
00199 b_s |= (b & 0x08) << 1;
00200 b_s |= (b & 0x10) >> 1;
00201 b_s |= (b & 0x20) >> 3;
00202 b_s |= (b & 0x40) >> 5;
00203 b_s |= (b & 0x80) >> 7;
00204
00205 *(uint16_t*)(*output) = ((b_s & 0xf8) << 8)
00206 + ((g_s & 0xfc) << 3)
00207 + ((r_s & 0xf8) >> 3);
00208 (*output) += 2;
00209 }
00210
00211 static inline void transfer_RGB888_to_RGB565(unsigned char *(*output), unsigned char *input)
00212 {
00213 uint16_t r, g, b;
00214 r = *input++;
00215 g = *input++;
00216 b = *input;
00217 *(uint16_t*)(*output) = ((r & 0xf8) << 8)
00218 + ((g & 0xfc) << 3)
00219 + ((b & 0xf8) >> 3);
00220 (*output) += 2;
00221 }
00222
00223 static inline void transfer_RGB888_to_BGR888(unsigned char *(*output), unsigned char *input)
00224 {
00225 *(*output)++ = input[2];
00226 *(*output)++ = input[1];
00227 *(*output)++ = input[0];
00228 }
00229
00230 static inline void transfer_RGB888_to_RGB888(unsigned char *(*output), unsigned char *input)
00231 {
00232 *(*output)++ = *input++;
00233 *(*output)++ = *input++;
00234 *(*output)++ = *input;
00235 }
00236
00237 static inline void transfer_RGB888_to_RGBA8888(unsigned char *(*output), unsigned char *input)
00238 {
00239 *(*output)++ = *input++;
00240 *(*output)++ = *input++;
00241 *(*output)++ = *input;
00242 *(*output)++ = 0xff;
00243 }
00244
00245 static inline void transfer_RGB888_to_ARGB8888(unsigned char *(*output), unsigned char *input)
00246 {
00247 *(*output)++ = 0xff;
00248 *(*output)++ = *input++;
00249 *(*output)++ = *input++;
00250 *(*output)++ = *input;
00251 }
00252
00253 static inline void transfer_RGB888_to_RGB161616(uint16_t *(*output), unsigned char *input)
00254 {
00255 (*output)[0] = (input[0] << 8) | input[0];
00256 (*output)[1] = (input[1] << 8) | input[1];
00257 (*output)[2] = (input[2] << 8) | input[2];
00258 (*output) += 3;
00259 }
00260
00261 static inline void transfer_RGB888_to_RGBA16161616(uint16_t *(*output), unsigned char *input)
00262 {
00263 (*output)[0] = (input[0] << 8) | input[0];
00264 (*output)[1] = (input[1] << 8) | input[1];
00265 (*output)[2] = (input[2] << 8) | input[2];
00266 (*output)[3] = 0xffff;
00267 (*output) += 4;
00268 }
00269
00270 static inline void transfer_RGB888_to_RGB_FLOAT(float *(*output), unsigned char *input)
00271 {
00272 *(*output)++ = (float)*input++ / 0xff;
00273 *(*output)++ = (float)*input++ / 0xff;
00274 *(*output)++ = (float)*input / 0xff;
00275 }
00276
00277 static inline void transfer_RGB888_to_RGBA_FLOAT(float *(*output), unsigned char *input)
00278 {
00279 *(*output)++ = (float)*input++ / 0xff;
00280 *(*output)++ = (float)*input++ / 0xff;
00281 *(*output)++ = (float)*input / 0xff;
00282 *(*output)++ = 1.0;
00283 }
00284
00285 static inline void transfer_RGB888_to_ABGR8888(unsigned char *(*output), unsigned char *input)
00286 {
00287 *(*output)++ = 0xff;
00288 *(*output)++ = input[2];
00289 *(*output)++ = input[1];
00290 *(*output)++ = input[0];
00291 }
00292
00293 static inline void transfer_RGB888_to_BGR8888(unsigned char *(*output), unsigned char *input)
00294 {
00295 *(*output)++ = input[2];
00296 *(*output)++ = input[1];
00297 *(*output)++ = input[0];
00298 (*output)++;
00299 }
00300
00301 static inline void transfer_RGB888_to_YUV888(unsigned char *(*output), unsigned char *input)
00302 {
00303 int y, u, v;
00304
00305 RGB_TO_YUV(y, u, v, input[0], input[1], input[2]);
00306
00307 *(*output)++ = y;
00308 *(*output)++ = u;
00309 *(*output)++ = v;
00310 }
00311
00312
00313 static inline void transfer_RGB888_to_YUV101010(unsigned char *(*output), unsigned char *input)
00314 {
00315 int r, g, b;
00316 int y, u, v;
00317
00318 r = ((uint16_t)input[0]) << 8;
00319 g = ((uint16_t)input[1]) << 8;
00320 b = ((uint16_t)input[2]) << 8;
00321 RGB_TO_YUV16(y, u, v, r, g, b);
00322 WRITE_YUV101010(y, u, v);
00323 }
00324
00325 static inline void transfer_RGB888_to_VYU888(unsigned char *(*output), unsigned char *input)
00326 {
00327 int y, u, v;
00328
00329 RGB_TO_YUV(y, u, v, input[0], input[1], input[2]);
00330
00331 *(*output)++ = v;
00332 *(*output)++ = y;
00333 *(*output)++ = u;
00334 }
00335
00336 static inline void transfer_RGB888_to_UYVA8888(unsigned char *(*output), unsigned char *input)
00337 {
00338 int y, u, v;
00339
00340 RGB_TO_YUV(y, u, v, input[0], input[1], input[2]);
00341
00342 *(*output)++ = u;
00343 *(*output)++ = y;
00344 *(*output)++ = v;
00345 *(*output)++ = 0xff;
00346 }
00347
00348
00349
00350 static inline void transfer_RGB888_to_YUVA8888(unsigned char *(*output), unsigned char *input)
00351 {
00352 int y, u, v;
00353
00354 RGB_TO_YUV(y, u, v, input[0], input[1], input[2]);
00355
00356 *(*output)++ = y;
00357 *(*output)++ = u;
00358 *(*output)++ = v;
00359 *(*output)++ = 255;
00360 }
00361
00362 static inline void transfer_RGB888_to_YUV161616(uint16_t *(*output), unsigned char *input)
00363 {
00364 int y, u, v, opacity, r, g, b;
00365
00366 r = ((int)input[0] << 8) | input[0];
00367 g = ((int)input[1] << 8) | input[1];
00368 b = ((int)input[2] << 8) | input[2];
00369
00370 RGB_TO_YUV16(y, u, v, r, g, b);
00371
00372 *(*output)++ = y;
00373 *(*output)++ = u;
00374 *(*output)++ = v;
00375 }
00376
00377 static inline void transfer_RGB888_to_YUVA16161616(uint16_t *(*output), unsigned char *input)
00378 {
00379 int y, u, v, r, g, b;
00380
00381 r = (((int)input[0]) << 8) | input[0];
00382 g = (((int)input[1]) << 8) | input[1];
00383 b = (((int)input[2]) << 8) | input[2];
00384 RGB_TO_YUV16(y, u, v, r, g, b);
00385
00386 *(*output)++ = y;
00387 *(*output)++ = u;
00388 *(*output)++ = v;
00389 *(*output)++ = 0xffff;
00390 }
00391
00392 static inline void transfer_RGB888_to_YUV420P_YUV422P(unsigned char *output_y,
00393 unsigned char *output_u,
00394 unsigned char *output_v,
00395 unsigned char *input,
00396 int output_column)
00397 {
00398 int y, u, v;
00399
00400 RGB_TO_YUV(y, u, v, input[0], input[1], input[2]);
00401
00402 output_y[output_column] = y;
00403 output_u[output_column / 2] = u;
00404 output_v[output_column / 2] = v;
00405 }
00406
00407 static inline void transfer_RGB888_to_YUV444P(unsigned char *output_y,
00408 unsigned char *output_u,
00409 unsigned char *output_v,
00410 unsigned char *input,
00411 int output_column)
00412 {
00413 int y, u, v;
00414
00415 RGB_TO_YUV(y, u, v, input[0], input[1], input[2]);
00416
00417 output_y[output_column] = y;
00418 output_u[output_column] = u;
00419 output_v[output_column] = v;
00420 }
00421
00422 static inline void transfer_RGB888_to_YUV422(unsigned char *(*output),
00423 unsigned char *input,
00424 int j)
00425 {
00426 int y, u, v;
00427
00428 RGB_TO_YUV(y, u, v, input[0], input[1], input[2]);
00429
00430 if(!(j & 1))
00431 {
00432
00433 (*output)[1] = u;
00434 (*output)[3] = v;
00435 (*output)[0] = y;
00436 }
00437 else
00438 {
00439
00440 (*output)[2] = y;
00441 (*output) += 4;
00442 }
00443
00444 }
00445
00446
00447
00448
00449
00450
00451
00452
00453
00454 static inline void transfer_RGBA8888_to_TRANSPARENCY(unsigned char *(*output), unsigned char *input, int (*bit_counter))
00455 {
00456 if((*bit_counter) == 7) *(*output) = 0;
00457
00458 if(input[3] < 127)
00459 {
00460 *(*output) |= (unsigned char)1 << (7 - (*bit_counter));
00461 }
00462
00463 if((*bit_counter) == 0)
00464 {
00465 (*output)++;
00466 (*bit_counter) = 7;
00467 }
00468 else
00469 (*bit_counter)--;
00470 }
00471
00472
00473
00474
00475 static inline void transfer_RGBA8888_to_RGB8bg(unsigned char *(*output), unsigned char *input, int bg_r, int bg_g, int bg_b)
00476 {
00477 unsigned int r, g, b, a, anti_a;
00478 a = input[3];
00479 anti_a = 255 - a;
00480 r = ((unsigned int)input[0] * a + bg_r * anti_a) / 0xff;
00481 g = ((unsigned int)input[1] * a + bg_g * anti_a) / 0xff;
00482 b = ((unsigned int)input[2] * a + bg_b * anti_a) / 0xff;
00483 *(*output) = (unsigned char)((r & 0xc0) +
00484 ((g & 0xe0) >> 2) +
00485 ((b & 0xe0) >> 5));
00486 (*output)++;
00487 }
00488
00489 static inline void transfer_RGBA8888_to_BGR565bg(unsigned char *(*output), unsigned char *input, int bg_r, int bg_g, int bg_b)
00490 {
00491 unsigned int r, g, b, a, anti_a;
00492 a = input[3];
00493 anti_a = 255 - a;
00494 r = ((unsigned int)input[0] * a + bg_r * anti_a) / 0xff;
00495 g = ((unsigned int)input[1] * a + bg_g * anti_a) / 0xff;
00496 b = ((unsigned int)input[2] * a + bg_b * anti_a) / 0xff;
00497 *(uint16_t*)(*output) = (uint16_t)(((b & 0xf8) << 8) +
00498 ((g & 0xfc) << 3) +
00499 ((r & 0xf8) >> 3));
00500 (*output) += 2;
00501 }
00502
00503 static inline void transfer_RGBA8888_to_RGB565bg(unsigned char *(*output), unsigned char *input, int bg_r, int bg_g, int bg_b)
00504 {
00505 unsigned int r, g, b, a, anti_a;
00506 a = input[3];
00507 anti_a = 255 - a;
00508 r = ((unsigned int)input[0] * a + bg_r * anti_a) / 0xff;
00509 g = ((unsigned int)input[1] * a + bg_g * anti_a) / 0xff;
00510 b = ((unsigned int)input[2] * a + bg_b * anti_a) / 0xff;
00511 *(uint16_t*)(*output) = (uint16_t)(((r & 0xf8) << 8)+
00512 ((g & 0xfc) << 3) +
00513 ((b & 0xf8) >> 3));
00514 (*output) += 2;
00515 }
00516
00517 static inline void transfer_RGBA8888_to_BGR888bg(unsigned char *(*output), unsigned char *input, int bg_r, int bg_g, int bg_b)
00518 {
00519 unsigned int r, g, b, a, anti_a;
00520 a = input[3];
00521 anti_a = 255 - a;
00522 r = ((unsigned int)input[0] * a + bg_r * anti_a) / 0xff;
00523 g = ((unsigned int)input[1] * a + bg_g * anti_a) / 0xff;
00524 b = ((unsigned int)input[2] * a + bg_b * anti_a) / 0xff;
00525 *(*output)++ = b;
00526 *(*output)++ = g;
00527 *(*output)++ = r;
00528 }
00529
00530 static inline void transfer_RGBA8888_to_RGB888bg(unsigned char *(*output), unsigned char *input, int bg_r, int bg_g, int bg_b)
00531 {
00532 unsigned int r, g, b, a, anti_a;
00533 a = input[3];
00534 anti_a = 255 - a;
00535 r = ((unsigned int)input[0] * a + bg_r * anti_a) / 0xff;
00536 g = ((unsigned int)input[1] * a + bg_g * anti_a) / 0xff;
00537 b = ((unsigned int)input[2] * a + bg_b * anti_a) / 0xff;
00538 *(*output)++ = r;
00539 *(*output)++ = g;
00540 *(*output)++ = b;
00541 }
00542
00543 static inline void transfer_RGBA8888_to_BGR8888bg(unsigned char *(*output), unsigned char *input, int bg_r, int bg_g, int bg_b)
00544 {
00545 unsigned int r, g, b, a, anti_a;
00546 a = input[3];
00547 anti_a = 255 - a;
00548
00549 r = ((unsigned int)input[0] * a + bg_r * anti_a) / 0xff;
00550 g = ((unsigned int)input[1] * a + bg_g * anti_a) / 0xff;
00551 b = ((unsigned int)input[2] * a + bg_b * anti_a) / 0xff;
00552
00553 *(*output)++ = b;
00554 *(*output)++ = g;
00555 *(*output)++ = r;
00556 (*output)++;
00557 }
00558
00559
00560
00561
00562
00563
00564
00565
00566
00567 static inline void transfer_RGBA8888_to_RGB8(unsigned char *(*output), unsigned char *input)
00568 {
00569 unsigned int r, g, b, a;
00570 a = input[3];
00571 r = (unsigned int)input[0] * a;
00572 g = (unsigned int)input[1] * a;
00573 b = (unsigned int)input[2] * a;
00574 *(*output) = (unsigned char)(((r & 0xc000) >> 8) +
00575 ((g & 0xe000) >> 10) +
00576 ((b & 0xe000) >> 13));
00577 (*output)++;
00578 }
00579
00580 static inline void transfer_RGBA8888_to_BGR565(unsigned char *(*output), unsigned char *input)
00581 {
00582 unsigned int r, g, b, a;
00583 a = input[3];
00584 r = ((unsigned int)input[0] * a) / 0xff;
00585 g = ((unsigned int)input[1] * a) / 0xff;
00586 b = ((unsigned int)input[2] * a) / 0xff;
00587 *(uint16_t*)(*output) = (uint16_t)(((b & 0xf8) << 8) +
00588 ((g & 0xfc) << 3) +
00589 ((r & 0xf8) >> 3));
00590 (*output) += 2;
00591 }
00592
00593 static inline void transfer_RGBA8888_to_RGB565(unsigned char *(*output), unsigned char *input)
00594 {
00595 unsigned int r, g, b, a;
00596 a = input[3];
00597 r = ((unsigned int)input[0] * a) / 0xff;
00598 g = ((unsigned int)input[1] * a) / 0xff;
00599 b = ((unsigned int)input[2] * a) / 0xff;
00600
00601
00602 *(uint16_t*)(*output) = (uint16_t)(((r & 0xf8) << 8) +
00603 ((g & 0xfc) << 3) +
00604 ((b & 0xf8) >> 3));
00605 (*output) += 2;
00606 }
00607
00608 static inline void transfer_RGBA8888_to_BGR888(unsigned char *(*output), unsigned char *input)
00609 {
00610 unsigned int r, g, b, a;
00611 a = input[3];
00612 r = ((unsigned int)input[0] * a) / 0xff;
00613 g = ((unsigned int)input[1] * a) / 0xff;
00614 b = ((unsigned int)input[2] * a) / 0xff;
00615 *(*output)++ = b;
00616 *(*output)++ = g;
00617 *(*output)++ = r;
00618 }
00619
00620 static inline void transfer_RGBA8888_to_RGB888(unsigned char *(*output), unsigned char *input)
00621 {
00622 unsigned int r, g, b, a;
00623 a = input[3];
00624 r = ((unsigned int)input[0] * a) / 0xff;
00625 g = ((unsigned int)input[1] * a) / 0xff;
00626 b = ((unsigned int)input[2] * a) / 0xff;
00627 *(*output)++ = r;
00628 *(*output)++ = g;
00629 *(*output)++ = b;
00630 }
00631
00632 static inline void transfer_RGBA8888_to_RGBA8888(unsigned char *(*output), unsigned char *input)
00633 {
00634 (*output)[0] = input[0];
00635 (*output)[1] = input[1];
00636 (*output)[2] = input[2];
00637 (*output)[3] = input[3];
00638 (*output) += 4;
00639 }
00640
00641 static inline void transfer_RGBA8888_to_ARGB8888(unsigned char *(*output), unsigned char *input)
00642 {
00643 (*output)[0] = input[3];
00644 (*output)[1] = input[0];
00645 (*output)[2] = input[1];
00646 (*output)[3] = input[2];
00647 (*output) += 4;
00648 }
00649
00650 static inline void transfer_RGBA8888_to_RGB161616(uint16_t *(*output), unsigned char *input)
00651 {
00652 int y, u, v, opacity, r, g, b;
00653
00654 opacity = input[3];
00655 (*output)[0] = (((int)input[0] << 8) | input[0]) * opacity / 0xff;
00656 (*output)[1] = (((int)input[1] << 8) | input[1]) * opacity / 0xff;
00657 (*output)[2] = (((int)input[2] << 8) | input[2]) * opacity / 0xff;
00658 (*output) += 3;
00659 }
00660
00661 static inline void transfer_RGBA8888_to_RGBA16161616(uint16_t *(*output), unsigned char *input)
00662 {
00663 int y, u, v, r, g, b;
00664
00665 (*output)[0] = (((int)input[0]) << 8) | input[0];
00666 (*output)[1] = (((int)input[1]) << 8) | input[1];
00667 (*output)[2] = (((int)input[2]) << 8) | input[2];
00668 (*output)[3] = (((int)input[3]) << 8) | input[3];
00669 (*output) += 4;
00670 }
00671
00672 static inline void transfer_RGBA8888_to_RGB_FLOAT(float *(*output), unsigned char *input)
00673 {
00674 float opacity = (float)input[3];
00675 *(*output)++ = (float)*input++ * opacity / 0xff / 0xff;
00676 *(*output)++ = (float)*input++ * opacity / 0xff / 0xff;
00677 *(*output)++ = (float)*input * opacity / 0xff / 0xff;
00678 }
00679
00680 static inline void transfer_RGBA8888_to_RGBA_FLOAT(float *(*output), unsigned char *input)
00681 {
00682 *(*output)++ = (float)*input++ / 0xff;
00683 *(*output)++ = (float)*input++ / 0xff;
00684 *(*output)++ = (float)*input++ / 0xff;
00685 *(*output)++ = (float)*input / 0xff;
00686 }
00687
00688 static inline void transfer_RGBA8888_to_BGR8888(unsigned char *(*output), unsigned char *input)
00689 {
00690 unsigned int r, g, b, a;
00691 a = input[3];
00692 r = ((unsigned int)input[0] * a) / 0xff;
00693 g = ((unsigned int)input[1] * a) / 0xff;
00694 b = ((unsigned int)input[2] * a) / 0xff;
00695 *(*output)++ = b;
00696 *(*output)++ = g;
00697 *(*output)++ = r;
00698 (*output)++;
00699 }
00700
00701 static inline void transfer_RGBA8888_to_YUV888(unsigned char *(*output), unsigned char *input)
00702 {
00703 int y, u, v, a, r, g, b;
00704
00705 a = input[3];
00706 r = (input[0] * a) / 0xff;
00707 g = (input[1] * a) / 0xff;
00708 b = (input[2] * a) / 0xff;
00709
00710 RGB_TO_YUV(y, u, v, input[0], input[1], input[2]);
00711
00712 *(*output)++ = y;
00713 *(*output)++ = u;
00714 *(*output)++ = v;
00715 }
00716
00717 static inline void transfer_RGBA8888_to_YUVA8888(unsigned char *(*output), unsigned char *input)
00718 {
00719 int y, u, v;
00720
00721 RGB_TO_YUV(y, u, v, input[0], input[1], input[2]);
00722
00723 *(*output)++ = y;
00724 *(*output)++ = u;
00725 *(*output)++ = v;
00726 *(*output)++ = input[3];
00727 }
00728
00729 static inline void transfer_RGBA8888_to_YUV161616(uint16_t *(*output), unsigned char *input)
00730 {
00731 int y, u, v, opacity, r, g, b;
00732
00733 opacity = input[3];
00734 r = (((int)input[0] << 8) | input[0]) * opacity / 0xff;
00735 g = (((int)input[1] << 8) | input[1]) * opacity / 0xff;
00736 b = (((int)input[2] << 8) | input[2]) * opacity / 0xff;
00737
00738 RGB_TO_YUV16(y, u, v, r, g, b);
00739
00740 *(*output)++ = y;
00741 *(*output)++ = u;
00742 *(*output)++ = v;
00743 }
00744
00745 static inline void transfer_RGBA8888_to_YUVA16161616(uint16_t *(*output), unsigned char *input)
00746 {
00747 int y, u, v, r, g, b;
00748
00749 r = (((int)input[0]) << 8) | input[0];
00750 g = (((int)input[1]) << 8) | input[1];
00751 b = (((int)input[2]) << 8) | input[2];
00752 RGB_TO_YUV16(y, u, v, r, g, b);
00753
00754 *(*output)++ = y;
00755 *(*output)++ = u;
00756 *(*output)++ = v;
00757 *(*output)++ = (((int)input[3]) << 8) | input[3];
00758 }
00759
00760 static inline void transfer_RGBA8888_to_YUV101010(unsigned char *(*output), unsigned char *input)
00761 {
00762 int r, g, b;
00763 int y, u, v;
00764
00765 r = ((uint16_t)input[0] * input[3]) + 0x1fe;
00766 g = ((uint16_t)input[1] * input[3]) + 0x1fe;
00767 b = ((uint16_t)input[2] * input[3]) + 0x1fe;
00768 RGB_TO_YUV16(y, u, v, r, g, b);
00769 WRITE_YUV101010(y, u, v);
00770 }
00771
00772 static inline void transfer_RGBA8888_to_VYU888(unsigned char *(*output), unsigned char *input)
00773 {
00774 int y, u, v, a, r, g, b;
00775
00776 a = input[3];
00777 r = ((input[0] * a) >> 8) + 1;
00778 g = ((input[1] * a) >> 8) + 1;
00779 b = ((input[2] * a) >> 8) + 1;
00780
00781 RGB_TO_YUV(y, u, v, input[0], input[1], input[2]);
00782
00783 *(*output)++ = v;
00784 *(*output)++ = y;
00785 *(*output)++ = u;
00786 }
00787
00788 static inline void transfer_RGBA8888_to_UYVA8888(unsigned char *(*output), unsigned char *input)
00789 {
00790 int y, u, v;
00791
00792 RGB_TO_YUV(y, u, v, input[0], input[1], input[2]);
00793
00794 *(*output)++ = u;
00795 *(*output)++ = y;
00796 *(*output)++ = v;
00797 *(*output)++ = input[3];
00798 }
00799
00800 static inline void transfer_RGBA888_to_YUV420P_YUV422P(unsigned char *output_y,
00801 unsigned char *output_u,
00802 unsigned char *output_v,
00803 unsigned char *input,
00804 int output_column)
00805 {
00806 int y, u, v, a, r, g, b;
00807
00808 a = input[3];
00809 r = (input[0] * a) / 0xff;
00810 g = (input[1] * a) / 0xff;
00811 b = (input[2] * a) / 0xff;
00812
00813 RGB_TO_YUV(y, u, v, r, g, b);
00814
00815 output_y[output_column] = y;
00816 output_u[output_column / 2] = u;
00817 output_v[output_column / 2] = v;
00818 }
00819
00820 static inline void transfer_RGBA888_to_YUV444P(unsigned char *output_y,
00821 unsigned char *output_u,
00822 unsigned char *output_v,
00823 unsigned char *input,
00824 int output_column)
00825 {
00826 int y, u, v, a, r, g, b;
00827
00828 a = input[3];
00829 r = (input[0] * a) / 0xff;
00830 g = (input[1] * a) / 0xff;
00831 b = (input[2] * a) / 0xff;
00832
00833 RGB_TO_YUV(y, u, v, r, g, b);
00834
00835 output_y[output_column] = y;
00836 output_u[output_column] = u;
00837 output_v[output_column] = v;
00838 }
00839
00840 static inline void transfer_RGBA888_to_YUV422(unsigned char *(*output),
00841 unsigned char *input,
00842 int j)
00843 {
00844 int y, u, v, a, r, g, b;
00845
00846 a = input[3];
00847 r = (input[0] * a) / 0xff;
00848 g = (input[1] * a) / 0xff;
00849 b = (input[2] * a) / 0xff;
00850
00851 RGB_TO_YUV(y, u, v, r, g, b);
00852
00853 if(!(j & 1))
00854 {
00855
00856 (*output)[1] = u;
00857 (*output)[3] = v;
00858 (*output)[0] = y;
00859 }
00860 else
00861 {
00862
00863 (*output)[2] = y;
00864 (*output) += 4;
00865 }
00866
00867 }
00868
00869
00870
00871
00872
00873
00874
00875
00876
00877
00878
00879
00880
00881
00882
00883 static inline void transfer_RGB161616_to_RGB8(unsigned char *(*output), uint16_t *input)
00884 {
00885 *(*output) = (unsigned char)(((input[0] & 0xc000) >> 8) +
00886 ((input[1] & 0xe000) >> 10) +
00887 ((input[2] & 0xe000) >> 13));
00888 (*output)++;
00889 }
00890
00891 static inline void transfer_RGB161616_to_BGR565(unsigned char *(*output), uint16_t *input)
00892 {
00893 uint16_t r, g, b;
00894 r = *input++;
00895 g = *input++;
00896 b = *input;
00897 *(uint16_t*)(*output) = (b & 0xf800) |
00898 ((g & 0xfc00) >> 5) |
00899 ((r & 0xf800) >> 11);
00900 (*output) += 2;
00901 }
00902
00903 static inline void transfer_RGB161616_to_RGB565(unsigned char *(*output), uint16_t *input)
00904 {
00905 uint16_t r, g, b;
00906 r = *input++;
00907 g = *input++;
00908 b = *input;
00909 *(uint16_t*)(*output) = (r & 0xf800) |
00910 ((g & 0xfc00) >> 5) |
00911 ((b & 0xf800) >> 11);
00912 (*output) += 2;
00913 }
00914
00915 static inline void transfer_RGB161616_to_BGR888(unsigned char *(*output), uint16_t *input)
00916 {
00917 (*output)[0] = input[2] >> 8;
00918 (*output)[1] = input[1] >> 8;
00919 (*output)[2] = input[0] >> 8;
00920 (*output) += 3;
00921 }
00922
00923 static inline void transfer_RGB161616_to_RGB888(unsigned char *(*output), uint16_t *input)
00924 {
00925 (*output)[0] = input[0] >> 8;
00926 (*output)[1] = input[1] >> 8;
00927 (*output)[2] = input[2] >> 8;
00928 (*output) += 3;
00929 }
00930
00931 static inline void transfer_RGB161616_to_RGBA8888(unsigned char *(*output), uint16_t *input)
00932 {
00933 (*output)[0] = input[0] >> 8;
00934 (*output)[1] = input[1] >> 8;
00935 (*output)[2] = input[2] >> 8;
00936 (*output)[3] = 0xff;
00937 (*output) += 4;
00938 }
00939
00940 static inline void transfer_RGB161616_to_BGR8888(unsigned char *(*output), uint16_t *input)
00941 {
00942 (*output)[0] = input[2] >> 8;
00943 (*output)[1] = input[1] >> 8;
00944 (*output)[2] = input[0] >> 8;
00945 (*output) += 4;
00946 }
00947
00948 static inline void transfer_RGB161616_to_RGB_FLOAT(float *(*output), uint16_t *input)
00949 {
00950 *(*output)++ = (float)*input++ / 0xffff;
00951 *(*output)++ = (float)*input++ / 0xffff;
00952 *(*output)++ = (float)*input / 0xffff;
00953 }
00954
00955 static inline void transfer_RGB161616_to_RGBA_FLOAT(float *(*output), uint16_t *input)
00956 {
00957 *(*output)++ = (float)*input++ / 0xffff;
00958 *(*output)++ = (float)*input++ / 0xffff;
00959 *(*output)++ = (float)*input / 0xffff;
00960 *(*output)++ = 1.0;
00961 }
00962
00963 static inline void transfer_RGB161616_to_YUV888(unsigned char *(*output), uint16_t *input)
00964 {
00965 int y, u, v, r, g, b;
00966 r = input[0] >> 8;
00967 g = input[1] >> 8;
00968 b = input[2] >> 8;
00969
00970 RGB_TO_YUV(y, u, v, r, g, b);
00971
00972 (*output)[0] = y;
00973 (*output)[1] = u;
00974 (*output)[2] = v;
00975 (*output) += 3;
00976 }
00977
00978 static inline void transfer_RGB161616_to_YUVA8888(unsigned char *(*output), uint16_t *input)
00979 {
00980 int y, u, v, r, g, b;
00981
00982 r = input[0] >> 8;
00983 g = input[1] >> 8;
00984 b = input[2] >> 8;
00985
00986 RGB_TO_YUV(y, u, v, r, g, b);
00987
00988 (*output)[0] = y;
00989 (*output)[1] = u;
00990 (*output)[2] = v;
00991 (*output)[3] = 255;
00992 (*output) += 4;
00993 }
00994
00995 static inline void transfer_RGB161616_to_YUV161616(uint16_t *(*output), uint16_t *input)
00996 {
00997 uint32_t y, u, v, r, g, b, a;
00998
00999 r = (uint32_t)input[0];
01000 g = (uint32_t)input[1];
01001 b = (uint32_t)input[2];
01002
01003 RGB_TO_YUV16(y, u, v, r, g, b);
01004
01005 (*output)[0] = y;
01006 (*output)[1] = u;
01007 (*output)[2] = v;
01008 (*output) += 3;
01009 }
01010
01011 static inline void transfer_RGB161616_to_YUVA16161616(uint16_t *(*output), uint16_t *input)
01012 {
01013 uint32_t y, u, v, r, g, b;
01014
01015 r = (uint32_t)input[0];
01016 g = (uint32_t)input[1];
01017 b = (uint32_t)input[2];
01018
01019 RGB_TO_YUV16(y, u, v, r, g, b);
01020
01021 (*output)[0] = y;
01022 (*output)[1] = u;
01023 (*output)[2] = v;
01024 (*output)[3] = 0xffff;
01025 (*output) += 4;
01026 }
01027
01028 static inline void transfer_RGB161616_to_YUV101010(unsigned char *(*output), uint16_t *input)
01029 {
01030 int r, g, b;
01031 int y, u, v;
01032
01033 r = input[0];
01034 g = input[1];
01035 b = input[2];
01036 RGB_TO_YUV16(y, u, v, r, g, b);
01037 WRITE_YUV101010(y, u, v);
01038 }
01039
01040 static inline void transfer_RGB161616_to_VYU888(unsigned char *(*output), uint16_t *input)
01041 {
01042 int y, u, v, r, g, b;
01043 r = input[0] >> 8;
01044 g = input[1] >> 8;
01045 b = input[2] >> 8;
01046
01047 RGB_TO_YUV(y, u, v, r, g, b);
01048
01049 (*output)[0] = v;
01050 (*output)[1] = y;
01051 (*output)[2] = u;
01052 (*output) += 3;
01053 }
01054
01055 static inline void transfer_RGB161616_to_UYVA8888(unsigned char *(*output), uint16_t *input)
01056 {
01057 int y, u, v, r, g, b;
01058
01059 r = input[0] >> 8;
01060 g = input[1] >> 8;
01061 b = input[2] >> 8;
01062
01063 RGB_TO_YUV(y, u, v, r, g, b);
01064
01065 (*output)[0] = u;
01066 (*output)[1] = y;
01067 (*output)[2] = v;
01068 (*output)[3] = 0xff;
01069 (*output) += 4;
01070 }
01071
01072
01073 static inline void transfer_RGB161616_to_YUV420P_YUV422P(unsigned char *output_y,
01074 unsigned char *output_u,
01075 unsigned char *output_v,
01076 uint16_t *input,
01077 int output_column)
01078 {
01079 int y, u, v, r, g, b;
01080 r = input[0] >> 8;
01081 g = input[1] >> 8;
01082 b = input[2] >> 8;
01083
01084 RGB_TO_YUV(y, u, v, r, g, b);
01085
01086 output_y[output_column] = y;
01087 output_u[output_column / 2] = u;
01088 output_v[output_column / 2] = v;
01089 }
01090
01091 static inline void transfer_RGB161616_to_YUV444P(unsigned char *output_y,
01092 unsigned char *output_u,
01093 unsigned char *output_v,
01094 uint16_t *input,
01095 int output_column)
01096 {
01097 int y, u, v, r, g, b;
01098 r = input[0] >> 8;
01099 g = input[1] >> 8;
01100 b = input[2] >> 8;
01101
01102 RGB_TO_YUV(y, u, v, r, g, b);
01103
01104 output_y[output_column] = y;
01105 output_u[output_column] = u;
01106 output_v[output_column] = v;
01107 }
01108
01109
01110
01111
01112 static inline void transfer_RGBA16161616_to_RGB8(unsigned char *(*output), uint16_t *input)
01113 {
01114 unsigned int r, g, b, a;
01115 a = (input)[3] >> 8;
01116 r = (unsigned int)(input)[0] * a;
01117 g = (unsigned int)(input)[1] * a;
01118 b = (unsigned int)(input)[2] * a;
01119
01120 *(*output) = (unsigned char)(((r & 0xc00000) >> 16) +
01121 ((g & 0xe00000) >> 18) +
01122 ((b & 0xe00000) >> 21));
01123 (*output)++;
01124 }
01125
01126 static inline void transfer_RGBA16161616_to_BGR565(unsigned char *(*output), uint16_t *input)
01127 {
01128 unsigned int r, g, b, a;
01129 a = (input)[3] >> 8;
01130 r = (unsigned int)(input)[0] * a;
01131 g = (unsigned int)(input)[1] * a;
01132 b = (unsigned int)(input)[2] * a;
01133
01134 *(uint16_t*)(*output) = (uint16_t)(((b & 0xf80000) >> 8) +
01135 ((g & 0xfc0000) >> 13) +
01136 ((r & 0xf80000) >> 19));
01137 (*output) += 2;
01138 }
01139
01140 static inline void transfer_RGBA16161616_to_RGB565(unsigned char *(*output), uint16_t *input)
01141 {
01142 unsigned int r, g, b, a;
01143 a = (input)[3] >> 8;
01144 r = (unsigned int)(input)[0] * a;
01145 g = (unsigned int)(input)[1] * a;
01146 b = (unsigned int)(input)[2] * a;
01147
01148 *(uint16_t*)(*output) = (uint16_t)(((r & 0xf80000) >> 8) +
01149 ((g & 0xfc0000) >> 13) +
01150 ((b & 0xf80000) >> 19));
01151 (*output) += 2;
01152 }
01153
01154 static inline void transfer_RGBA16161616_to_BGR888(unsigned char *(*output), uint16_t *input)
01155 {
01156 uint32_t r, g, b, a;
01157 a = input[3];
01158 r = (uint32_t)(input)[0] * a;
01159 g = (uint32_t)(input)[1] * a;
01160 b = (uint32_t)(input)[2] * a;
01161
01162
01163 (*output)[0] = (unsigned char)(b >> 24);
01164 (*output)[1] = (unsigned char)(g >> 24);
01165 (*output)[2] = (unsigned char)(r >> 24);
01166 (*output) += 3;
01167 }
01168
01169 static inline void transfer_RGBA16161616_to_RGB888(unsigned char *(*output), uint16_t *input)
01170 {
01171 uint32_t r, g, b, a;
01172 a = input[3];
01173 r = (unsigned int)(input)[0] * a;
01174 g = (unsigned int)(input)[1] * a;
01175 b = (unsigned int)(input)[2] * a;
01176
01177 (*output)[0] = (unsigned char)(r / 0xffffff);
01178 (*output)[1] = (unsigned char)(g / 0xffffff);
01179 (*output)[2] = (unsigned char)(b / 0xffffff);
01180 (*output) += 3;
01181 }
01182
01183
01184 static inline void transfer_RGBA16161616_to_RGBA8888(unsigned char *(*output), uint16_t *input)
01185 {
01186 (*output)[0] = input[0] >> 8;
01187 (*output)[1] = input[1] >> 8;
01188 (*output)[2] = input[2] >> 8;
01189 (*output)[3] = input[3] >> 8;
01190 (*output) += 4;
01191 }
01192
01193
01194 static inline void transfer_RGBA16161616_to_BGR8888(unsigned char *(*output), uint16_t *input)
01195 {
01196 uint32_t r, g, b, a;
01197 a = input[3];
01198 r = (input)[0] * a;
01199 g = (input)[1] * a;
01200 b = (input)[2] * a;
01201
01202
01203 (*output)[0] = (unsigned char)(b >> 24);
01204 (*output)[1] = (unsigned char)(g >> 24);
01205 (*output)[2] = (unsigned char)(r >> 24);
01206 (*output) += 4;
01207 }
01208
01209 static inline void transfer_RGBA16161616_to_RGB_FLOAT(float *(*output), uint16_t *input)
01210 {
01211 float opacity = (float)input[3];
01212 *(*output)++ = (float)*input++ * opacity / 0xffff / 0xffff;
01213 *(*output)++ = (float)*input++ * opacity / 0xffff / 0xffff;
01214 *(*output)++ = (float)*input * opacity / 0xffff / 0xffff;
01215 }
01216
01217 static inline void transfer_RGBA16161616_to_RGBA_FLOAT(float *(*output), uint16_t *input)
01218 {
01219 *(*output)++ = (float)*input++ / 0xffff;
01220 *(*output)++ = (float)*input++ / 0xffff;
01221 *(*output)++ = (float)*input++ / 0xffff;
01222 *(*output)++ = (float)*input / 0xffff;
01223 }
01224
01225 static inline void transfer_RGBA16161616_to_YUV888(unsigned char *(*output), uint16_t *input)
01226 {
01227 uint32_t y, u, v, r, g, b, a;
01228
01229 a = input[3];
01230 r = (uint32_t)input[0] * a / 0xffffff;
01231 g = (uint32_t)input[1] * a / 0xffffff;
01232 b = (uint32_t)input[2] * a / 0xffffff;
01233
01234 RGB_TO_YUV(y, u, v, r, g, b);
01235
01236 (*output)[0] = y;
01237 (*output)[1] = u;
01238 (*output)[2] = v;
01239 (*output) += 3;
01240 }
01241
01242 static inline void transfer_RGBA16161616_to_YUVA8888(unsigned char *(*output), uint16_t *input)
01243 {
01244 int y, u, v, r, g, b;
01245
01246 r = input[0] >> 8;
01247 g = input[1] >> 8;
01248 b = input[2] >> 8;
01249
01250 RGB_TO_YUV(y, u, v, r, g, b);
01251
01252 (*output)[0] = y;
01253 (*output)[1] = u;
01254 (*output)[2] = v;
01255 (*output)[3] = input[3] >> 8;
01256 (*output) += 4;
01257 }
01258
01259 static inline void transfer_RGBA16161616_to_YUV161616(uint16_t *(*output), uint16_t *input)
01260 {
01261 uint32_t y, u, v, r, g, b, a;
01262
01263 a = input[3];
01264 r = (uint32_t)input[0] * a / 0xffff;
01265 g = (uint32_t)input[1] * a / 0xffff;
01266 b = (uint32_t)input[2] * a / 0xffff;
01267
01268 RGB_TO_YUV16(y, u, v, r, g, b);
01269
01270 (*output)[0] = y;
01271 (*output)[1] = u;
01272 (*output)[2] = v;
01273 (*output) += 3;
01274 }
01275
01276 static inline void transfer_RGBA16161616_to_YUVA16161616(uint16_t *(*output), uint16_t *input)
01277 {
01278 uint32_t y, u, v, r, g, b;
01279
01280 r = (uint32_t)input[0];
01281 g = (uint32_t)input[1];
01282 b = (uint32_t)input[2];
01283
01284 RGB_TO_YUV16(y, u, v, r, g, b);
01285
01286 (*output)[0] = y;
01287 (*output)[1] = u;
01288 (*output)[2] = v;
01289 (*output)[3] = input[3];
01290 (*output) += 4;
01291 }
01292
01293
01294 static inline void transfer_RGBA16161616_to_YUV101010(unsigned char *(*output), uint16_t *input)
01295 {
01296 uint32_t r, g, b, a, y, u, v;
01297
01298 a = input[3];
01299 r = (uint32_t)input[0] * a / 0xffff;
01300 g = (uint32_t)input[1] * a / 0xffff;
01301 b = (uint32_t)input[2] * a / 0xffff;
01302 RGB_TO_YUV16(y, u, v, r, g, b);
01303 WRITE_YUV101010(y, u, v);
01304 }
01305
01306
01307 static inline void transfer_RGBA16161616_to_YUV420P_YUV422P(unsigned char *output_y,
01308 unsigned char *output_u,
01309 unsigned char *output_v,
01310 uint16_t *input,
01311 int output_column)
01312 {
01313 uint32_t y, u, v, r, g, b, a;
01314 a = input[3];
01315 r = (int32_t)input[0] * a / 0xffffff;
01316 g = (int32_t)input[1] * a / 0xffffff;
01317 b = (int32_t)input[2] * a / 0xffffff;
01318
01319 RGB_TO_YUV(y, u, v, r, g, b);
01320
01321 output_y[output_column] = y;
01322 output_u[output_column / 2] = u;
01323 output_v[output_column / 2] = v;
01324 }
01325
01326 static inline void transfer_RGBA16161616_to_YUV444P(unsigned char *output_y,
01327 unsigned char *output_u,
01328 unsigned char *output_v,
01329 uint16_t *input,
01330 int output_column)
01331 {
01332 uint32_t y, u, v, r, g, b, a;
01333 a = input[3];
01334 r = (int32_t)input[0] * a / 0xffffff;
01335 g = (int32_t)input[1] * a / 0xffffff;
01336 b = (int32_t)input[2] * a / 0xffffff;
01337
01338 RGB_TO_YUV(y, u, v, r, g, b);
01339
01340 output_y[output_column] = y;
01341 output_u[output_column] = u;
01342 output_v[output_column] = v;
01343 }
01344
01345
01346
01347
01348
01349
01350
01351
01352
01353
01354
01355
01356
01357
01358
01359
01360
01361
01362
01363
01364
01365
01366
01367
01368
01369 static inline void transfer_BGR8888_to_RGB888(unsigned char *(*output), unsigned char *input)
01370 {
01371 *(*output)++ = input[2];
01372 *(*output)++ = input[1];
01373 *(*output)++ = input[0];
01374 }
01375
01376 static inline void transfer_BGR8888_to_BGR8888(unsigned char *(*output), unsigned char *input)
01377 {
01378 *(*output)++ = input[0];
01379 *(*output)++ = input[1];
01380 *(*output)++ = input[2];
01381 (*output)++;
01382 }
01383
01384 static inline void transfer_BGR888_to_RGB888(unsigned char *(*output), unsigned char *input)
01385 {
01386 *(*output)++ = input[2];
01387 *(*output)++ = input[1];
01388 *(*output)++ = input[0];
01389 }
01390
01391
01392
01393
01394
01395
01396
01397
01398
01399
01400 static inline void transfer_YUV888_to_RGB8(unsigned char *(*output), unsigned char *input)
01401 {
01402 int y, u, v;
01403 int r, g, b;
01404
01405 y = (input[0] << 16) | (input[0] << 8) | input[0];
01406 u = input[1];
01407 v = input[2];
01408 YUV_TO_RGB(y, u, v, r, g, b);
01409
01410 *(*output) = (unsigned char)((r & 0xc0) +
01411 ((g & 0xe0) >> 2) +
01412 ((b & 0xe0) >> 5));
01413 (*output)++;
01414 }
01415
01416 static inline void transfer_YUV888_to_BGR565(unsigned char *(*output), unsigned char *input)
01417 {
01418 int y, u, v;
01419 int r, g, b;
01420
01421 y = (input[0] << 16) | (input[0] << 8) | input[0];
01422 u = input[1];
01423 v = input[2];
01424 YUV_TO_RGB(y, u, v, r, g, b);
01425 *(uint16_t*)(*output) = ((b & 0xf8) << 8)
01426 + ((g & 0xfc) << 3)
01427 + ((r & 0xf8) >> 3);
01428 (*output) += 2;
01429 }
01430
01431 static inline void transfer_YUV888_to_RGB565(unsigned char *(*output), unsigned char *input)
01432 {
01433 int y, u, v;
01434 int r, g, b;
01435
01436 y = (input[0] << 16) | (input[0] << 8) | input[0];
01437 u = input[1];
01438 v = input[2];
01439 YUV_TO_RGB(y, u, v, r, g, b);
01440 *(uint16_t*)(*output) = ((r & 0xf8) << 8)
01441 + ((g & 0xfc) << 3)
01442 + ((b & 0xf8) >> 3);
01443 (*output) += 2;
01444 }
01445
01446 static inline void transfer_YUV888_to_BGR888(unsigned char *(*output), unsigned char *input)
01447 {
01448 int y, u, v;
01449 int r, g, b;
01450
01451 y = (input[0] << 16) | (input[0] << 8) | input[0];
01452 u = input[1];
01453 v = input[2];
01454 YUV_TO_RGB(y, u, v, r, g, b);
01455
01456 *(*output)++ = b;
01457 *(*output)++ = g;
01458 *(*output)++ = r;
01459 }
01460
01461 static inline void transfer_YUV888_to_BGR8888(unsigned char *(*output), unsigned char *input)
01462 {
01463 int y, u, v;
01464 int r, g, b;
01465
01466 y = (input[0] << 16) | (input[0] << 8) | input[0];
01467 u = input[1];
01468 v = input[2];
01469 YUV_TO_RGB(y, u, v, r, g, b);
01470 *(*output)++ = b;
01471 *(*output)++ = g;
01472 *(*output)++ = r;
01473 (*output)++;
01474 }
01475
01476 static inline void transfer_YUV888_to_RGB888(unsigned char *(*output), unsigned char *input)
01477 {
01478 int y, u, v;
01479 int r, g, b;
01480
01481 y = (input[0] << 16) | (input[0] << 8) | input[0];
01482 u = (int)input[1];
01483 v = (int)input[2];
01484 YUV_TO_RGB(y, u, v, r, g, b);
01485
01486 *(*output)++ = r;
01487 *(*output)++ = g;
01488 *(*output)++ = b;
01489 }
01490
01491 static inline void transfer_YUV888_to_RGBA8888(unsigned char *(*output), unsigned char *input)
01492 {
01493 int y, u, v;
01494 int r, g, b;
01495
01496 y = (input[0] << 16) | (input[0] << 8) | input[0];
01497 u = input[1];
01498 v = input[2];
01499 YUV_TO_RGB(y, u, v, r, g, b);
01500 *(*output)++ = r;
01501 *(*output)++ = g;
01502 *(*output)++ = b;
01503 *(*output)++ = 0xff;
01504 }
01505
01506 static inline void transfer_YUV888_to_ARGB8888(unsigned char *(*output), unsigned char *input)
01507 {
01508 int y, u, v;
01509 int r, g, b;
01510
01511 y = (input[0] << 16) | (input[0] << 8) | input[0];
01512 u = input[1];
01513 v = input[2];
01514 YUV_TO_RGB(y, u, v, r, g, b);
01515 *(*output)++ = 0xff;
01516 *(*output)++ = r;
01517 *(*output)++ = g;
01518 *(*output)++ = b;
01519 }
01520
01521 static inline void transfer_YUV888_to_RGB_FLOAT(float *(*output), unsigned char *input)
01522 {
01523 float y = (float)input[0] / 0xff;
01524 int u = input[1];
01525 int v = input[2];
01526 float r, g, b;
01527
01528 YUV_TO_FLOAT(y, u, v, r, g, b);
01529
01530 *(*output)++ = r;
01531 *(*output)++ = g;
01532 *(*output)++ = b;
01533 }
01534
01535 static inline void transfer_YUV888_to_RGBA_FLOAT(float *(*output), unsigned char *input)
01536 {
01537 float y = (float)input[0] / 0xff;
01538 int u = input[1];
01539 int v = input[2];
01540 float r, g, b;
01541
01542 YUV_TO_FLOAT(y, u, v, r, g, b);
01543
01544 *(*output)++ = r;
01545 *(*output)++ = g;
01546 *(*output)++ = b;
01547 *(*output)++ = 1.0;
01548 }
01549
01550 static inline void transfer_YUV888_to_YUVA8888(unsigned char *(*output), unsigned char *input)
01551 {
01552 *(*output)++ = (int)input[0];
01553 *(*output)++ = input[1];
01554 *(*output)++ = input[2];
01555 *(*output)++ = 0xff;
01556 }
01557
01558 static inline void transfer_YUV888_to_YUV888(unsigned char *(*output), unsigned char *input)
01559 {
01560 (*output)[0] = (int)input[0];
01561 (*output)[1] = input[1];
01562 (*output)[2] = input[2];
01563 (*output) += 3;
01564 }
01565
01566
01567 static inline void transfer_YUV888_to_VYU888(unsigned char *(*output), unsigned char *input)
01568 {
01569 (*output)[0] = input[2];
01570 (*output)[1] = input[0];
01571 (*output)[2] = input[1];
01572 (*output) += 3;
01573 }
01574
01575
01576 static inline void transfer_YUV888_to_UYVA8888(unsigned char *(*output), unsigned char *input)
01577 {
01578 (*output)[0] = input[1];
01579 (*output)[1] = input[0];
01580 (*output)[2] = input[2];
01581 (*output)[3] = 0xff;
01582 (*output) += 4;
01583 }
01584
01585
01586 static inline void transfer_YUV888_to_YUV101010(unsigned char *(*output), unsigned char *input)
01587 {
01588 uint16_t y_i = ((uint16_t)input[0]) << 8;
01589 uint16_t u_i = ((uint16_t)input[1]) << 8;
01590 uint16_t v_i = ((uint16_t)input[2]) << 8;
01591 WRITE_YUV101010(y_i, u_i, v_i);
01592 }
01593
01594 static inline void transfer_YUV888_to_YUV420P_YUV422P(unsigned char *output_y,
01595 unsigned char *output_u,
01596 unsigned char *output_v,
01597 unsigned char *input,
01598 int output_column)
01599 {
01600 output_y[output_column] = input[0];
01601 output_u[output_column / 2] = input[1];
01602 output_v[output_column / 2] = input[2];
01603 }
01604
01605 static inline void transfer_YUV888_to_YUV444P(unsigned char *output_y,
01606 unsigned char *output_u,
01607 unsigned char *output_v,
01608 unsigned char *input,
01609 int output_column)
01610 {
01611 output_y[output_column] = input[0];
01612 output_u[output_column] = input[1];
01613 output_v[output_column] = input[2];
01614 }
01615
01616 static inline void transfer_YUV888_to_YUV422(unsigned char *(*output),
01617 unsigned char *input,
01618 int j)
01619 {
01620
01621 if(!(j & 1))
01622 {
01623 (*output)[1] = input[1];
01624 (*output)[3] = input[2];
01625 (*output)[0] = input[0];
01626 }
01627 else
01628
01629 {
01630 (*output)[2] = input[0];
01631 (*output) += 4;
01632 }
01633 }
01634
01635
01636
01637
01638
01639
01640
01641
01642
01643
01644
01645 static inline void transfer_YUVA8888_to_RGB8(unsigned char *(*output), unsigned char *input)
01646 {
01647 int y, u, v, a;
01648 int r, g, b;
01649
01650 a = input[3];
01651 y = (input[0] << 16) | (input[0] << 8) | input[0];
01652 u = input[1];
01653 v = input[2];
01654 YUV_TO_RGB(y, u, v, r, g, b);
01655
01656 r *= a;
01657 g *= a;
01658 b *= a;
01659
01660 *(*output) = (unsigned char)(((r & 0xc000) >> 8) +
01661 ((g & 0xe000) >> 10) +
01662 ((b & 0xe000) >> 13));
01663 (*output)++;
01664 }
01665
01666 static inline void transfer_YUVA8888_to_BGR565(unsigned char *(*output), unsigned char *input)
01667 {
01668 int y, u, v, a;
01669 int r, g, b;
01670
01671 a = input[3];
01672 y = (input[0] << 16) | (input[0] << 8) | input[0];
01673 u = input[1];
01674 v = input[2];
01675 YUV_TO_RGB(y, u, v, r, g, b);
01676
01677 r *= a;
01678 g *= a;
01679 b *= a;
01680
01681 *(uint16_t*)(*output) = (uint16_t)((b & 0xf800) +
01682 ((g & 0xfc00) >> 5) +
01683 ((r & 0xf800) >> 11));
01684 (*output) += 2;
01685 }
01686
01687 static inline void transfer_YUVA8888_to_RGB565(unsigned char *(*output), unsigned char *input)
01688 {
01689 int y, u, v, a;
01690 int r, g, b;
01691
01692 a = input[3];
01693 y = (input[0] << 16) | (input[0] << 8) | input[0];
01694 u = input[1];
01695 v = input[2];
01696 YUV_TO_RGB(y, u, v, r, g, b);
01697
01698 r *= a;
01699 g *= a;
01700 b *= a;
01701
01702 *(uint16_t*)(*output) = (uint16_t)((r & 0xf800) +
01703 ((g & 0xfc00) >> 5) +
01704 ((b & 0xf800) >> 11));
01705 (*output) += 2;
01706 }
01707
01708 static inline void transfer_YUVA8888_to_BGR888(unsigned char *(*output), unsigned char *input)
01709 {
01710 int y, u, v, a;
01711 int r, g, b;
01712
01713 a = input[3];
01714 y = (input[0] << 16) | (input[0] << 8) | input[0];
01715 u = input[1];
01716 v = input[2];
01717
01718 YUV_TO_RGB(y, u, v, r, g, b);
01719
01720 r *= a;
01721 g *= a;
01722 b *= a;
01723
01724 *(*output)++ = b / 0xff;
01725 *(*output)++ = g / 0xff;
01726 *(*output)++ = r / 0xff;
01727 }
01728
01729
01730 static inline void transfer_YUVA8888_to_BGR8888(unsigned char *(*output), unsigned char *input)
01731 {
01732 int y, u, v, a;
01733 int r, g, b;
01734
01735 a = input[3];
01736 y = (input[0] << 16) | (input[0] << 8) | input[0];
01737 u = input[1];
01738 v = input[2];
01739
01740 YUV_TO_RGB(y, u, v, r, g, b);
01741
01742 r *= a;
01743 g *= a;
01744 b *= a;
01745 *(*output)++ = b / 0xff;
01746 *(*output)++ = g / 0xff;
01747 *(*output)++ = r / 0xff;
01748 (*output)++;
01749 }
01750
01751 static inline void transfer_YUVA8888_to_RGB888(unsigned char *(*output), unsigned char *input)
01752 {
01753 int y, u, v, a;
01754 int r, g, b;
01755
01756 a = input[3];
01757 y = (input[0] << 16) | (input[0] << 8) | input[0];
01758 u = input[1];
01759 v = input[2];
01760
01761 YUV_TO_RGB(y, u, v, r, g, b);
01762
01763 r *= a;
01764 g *= a;
01765 b *= a;
01766
01767 *(*output)++ = r / 0xff;
01768 *(*output)++ = g / 0xff;
01769 *(*output)++ = b / 0xff;
01770 }
01771
01772 static inline void transfer_YUVA8888_to_RGBA8888(unsigned char *(*output), unsigned char *input)
01773 {
01774 int y, u, v, a;
01775 int r, g, b;
01776
01777 a = input[3];
01778 y = (input[0] << 16) | (input[0] << 8) | input[0];
01779 u = input[1];
01780 v = input[2];
01781
01782 YUV_TO_RGB(y, u, v, r, g, b);
01783 *(*output)++ = r;
01784 *(*output)++ = g;
01785 *(*output)++ = b;
01786 *(*output)++ = a;
01787 }
01788
01789 static inline void transfer_YUVA8888_to_ARGB8888(unsigned char *(*output), unsigned char *input)
01790 {
01791 int y, u, v, a;
01792 int r, g, b;
01793
01794 a = input[3];
01795 y = (input[0] << 16) | (input[0] << 8) | input[0];
01796 u = input[1];
01797 v = input[2];
01798
01799 YUV_TO_RGB(y, u, v, r, g, b);
01800 *(*output)++ = a;
01801 *(*output)++ = r;
01802 *(*output)++ = g;
01803 *(*output)++ = b;
01804 }
01805
01806 static inline void transfer_YUVA8888_to_RGB_FLOAT(float *(*output), unsigned char *input)
01807 {
01808 float y, a;
01809 int u, v;
01810 float r, g, b;
01811
01812 a = (float)input[3] / 0xff;
01813 y = (float)input[0] / 0xff;
01814 u = input[1];
01815 v = input[2];
01816
01817 YUV_TO_FLOAT(y, u, v, r, g, b);
01818
01819 r *= a;
01820 g *= a;
01821 b *= a;
01822
01823 *(*output)++ = r;
01824 *(*output)++ = g;
01825 *(*output)++ = b;
01826 }
01827
01828 static inline void transfer_YUVA8888_to_RGBA_FLOAT(float *(*output), unsigned char *input)
01829 {
01830 float y = (float)input[0] / 0xff;
01831 int u, v;
01832 float r, g, b, a;
01833
01834 a = (float)input[3] / 0xff;
01835 u = input[1];
01836 v = input[2];
01837
01838 YUV_TO_FLOAT(y, u, v, r, g, b);
01839
01840 *(*output)++ = r;
01841 *(*output)++ = g;
01842 *(*output)++ = b;
01843 *(*output)++ = a;
01844 }
01845
01846
01847 static inline void transfer_YUVA8888_to_VYU888(unsigned char *(*output), unsigned char *input)
01848 {
01849 int y, u, v, a, anti_a;
01850 a = input[3];
01851 anti_a = 0xff - a;
01852 y = ((uint32_t)input[0] * a) / 0xff;
01853 u = ((uint32_t)input[1] * a + 0x80 * anti_a) / 0xff;
01854 v = ((uint32_t)input[2] * a + 0x80 * anti_a) / 0xff;
01855
01856 *(*output)++ = v;
01857 *(*output)++ = y;
01858 *(*output)++ = u;
01859 }
01860
01861
01862 static inline void transfer_YUVA8888_to_YUVA8888(unsigned char *(*output), unsigned char *input)
01863 {
01864 *(*output)++ = input[0];
01865 *(*output)++ = input[1];
01866 *(*output)++ = input[2];
01867 *(*output)++ = input[3];
01868 }
01869
01870 static inline void transfer_YUVA8888_to_UYVA8888(unsigned char *(*output), unsigned char *input)
01871 {
01872 *(*output)++ = input[1];
01873 *(*output)++ = input[0];
01874 *(*output)++ = input[2];
01875 *(*output)++ = input[3];
01876 }
01877
01878 static inline void transfer_YUVA8888_to_YUV101010(unsigned char *(*output), unsigned char *input)
01879 {
01880 uint16_t y_i = ((uint16_t)input[0] * input[3]) + 0x1fe;
01881 uint16_t u_i = ((uint16_t)input[1] * input[3]) + 0x1fe;
01882 uint16_t v_i = ((uint16_t)input[2] * input[3]) + 0x1fe;
01883 WRITE_YUV101010(y_i, u_i, v_i);
01884 }
01885
01886
01887 static inline void transfer_YUVA8888_to_YUV420P_YUV422P(unsigned char *output_y,
01888 unsigned char *output_u,
01889 unsigned char *output_v,
01890 unsigned char *input,
01891 int output_column)
01892 {
01893 int opacity = input[3];
01894 int transparency = 0xff - opacity;
01895
01896 output_y[output_column] = ((input[0] * opacity) >> 8) + 1;
01897 output_u[output_column / 2] = ((input[1] * opacity + 0x80 * transparency) >> 8) + 1;
01898 output_v[output_column / 2] = ((input[2] * opacity + 0x80 * transparency) >> 8) + 1;
01899 }
01900
01901 static inline void transfer_YUVA8888_to_YUV444P(unsigned char *output_y,
01902 unsigned char *output_u,
01903 unsigned char *output_v,
01904 unsigned char *input,
01905 int output_column)
01906 {
01907 int opacity = input[3];
01908 int transparency = 0xff - opacity;
01909
01910 output_y[output_column] = ((input[0] * opacity) >> 8) + 1;
01911 output_u[output_column] = ((input[1] * opacity + 0x80 * transparency) >> 8) + 1;
01912 output_v[output_column] = ((input[2] * opacity + 0x80 * transparency) >> 8) + 1;
01913 }
01914
01915 static inline void transfer_YUVA8888_to_YUV422(unsigned char *(*output),
01916 unsigned char *input,
01917 int j)
01918 {
01919 int opacity = input[3];
01920 int transparency = 0xff - opacity;
01921
01922 if(!(j & 1))
01923 {
01924 (*output)[0] = ((input[0] * opacity) >> 8) + 1;
01925 (*output)[1] = ((input[1] * opacity + 0x80 * transparency) >> 8) + 1;
01926 (*output)[3] = ((input[2] * opacity + 0x80 * transparency) >> 8) + 1;
01927 }
01928 else
01929
01930 {
01931 (*output)[2] = ((input[0] * opacity) >> 8) + 1;
01932 (*output) += 4;
01933 }
01934 }
01935
01936
01937
01938
01939
01940
01941
01942
01943
01944
01945
01946
01947
01948 static inline void transfer_YUV161616_to_RGB8(unsigned char *(*output), uint16_t *input)
01949 {
01950 int y, u, v;
01951 int r, g, b;
01952
01953 y = (((int)input[0]) << 8) | (input[0] >> 8);
01954 u = input[1] >> 8;
01955 v = input[2] >> 8;
01956 YUV_TO_RGB(y, u, v, r, g, b);
01957
01958 *(*output) = (unsigned char)((r & 0xc0) +
01959 ((g & 0xe0) >> 2) +
01960 ((b & 0xe0) >> 5));
01961 (*output)++;
01962 }
01963
01964 static inline void transfer_YUV161616_to_BGR565(unsigned char *(*output), uint16_t *input)
01965 {
01966 int y, u, v;
01967 int r, g, b;
01968
01969 y = (((int)input[0]) << 8) | (input[0] >> 8);
01970 u = input[1] >> 8;
01971 v = input[2] >> 8;
01972 YUV_TO_RGB(y, u, v, r, g, b);
01973 *(uint16_t*)(*output) = ((b & 0xf8) << 8)
01974 + ((g & 0xfc) << 3)
01975 + ((r & 0xf8) >> 3);
01976 (*output) += 2;
01977 }
01978
01979 static inline void transfer_YUV161616_to_RGB565(unsigned char *(*output), uint16_t *input)
01980 {
01981 int y, u, v;
01982 int r, g, b;
01983
01984 y = (((int)input[0]) << 8) | (input[0] >> 8);
01985 u = input[1] >> 8;
01986 v = input[2] >> 8;
01987 YUV_TO_RGB(y, u, v, r, g, b);
01988 *(uint16_t*)(*output) = ((r & 0xf8) << 8)
01989 + ((g & 0xfc) << 3)
01990 + ((b & 0xf8) >> 3);
01991 (*output) += 2;
01992 }
01993
01994 static inline void transfer_YUV161616_to_BGR888(unsigned char *(*output), uint16_t *input)
01995 {
01996 int y, u, v;
01997 int r, g, b;
01998
01999 y = (((int)input[0]) << 8) | (input[0] >> 8);
02000 u = input[1];
02001 v = input[2];
02002 YUV_TO_RGB16(y, u, v, r, g, b);
02003
02004 *(*output)++ = b >> 8;
02005 *(*output)++ = g >> 8;
02006 *(*output)++ = r >> 8;
02007 }
02008
02009 static inline void transfer_YUV161616_to_RGB888(unsigned char *(*output), uint16_t *input)
02010 {
02011 int y, u, v;
02012 int r, g, b;
02013
02014 y = (((int)input[0]) << 8) | (input[0] >> 8);
02015 u = input[1];
02016 v = input[2];
02017 YUV_TO_RGB16(y, u, v, r, g, b);
02018
02019 *(*output)++ = r >> 8;
02020 *(*output)++ = g >> 8;
02021 *(*output)++ = b >> 8;
02022 }
02023
02024 static inline void transfer_YUV161616_to_RGBA8888(unsigned char *(*output), uint16_t *input)
02025 {
02026 int y, u, v;
02027 int r, g, b;
02028
02029 y = (((int)input[0]) << 8) | (input[0] >> 8);
02030 u = input[1];
02031 v = input[2];
02032 YUV_TO_RGB16(y, u, v, r, g, b);
02033
02034 *(*output)++ = r >> 8;
02035 *(*output)++ = g >> 8;
02036 *(*output)++ = b >> 8;
02037 *(*output)++ = 0xff;
02038 }
02039
02040 static inline void transfer_YUV161616_to_ARGB8888(unsigned char *(*output), uint16_t *input)
02041 {
02042 int y, u, v;
02043 int r, g, b;
02044
02045 y = (((int)input[0]) << 8) | (input[0] >> 8);
02046 u = input[1];
02047 v = input[2];
02048 YUV_TO_RGB16(y, u, v, r, g, b);
02049
02050 *(*output)++ = 0xff;
02051 *(*output)++ = r >> 8;
02052 *(*output)++ = g >> 8;
02053 *(*output)++ = b >> 8;
02054 }
02055
02056 static inline void transfer_YUV161616_to_RGB_FLOAT(float *(*output), uint16_t *input)
02057 {
02058 float y = (float)input[0] / 0xffff;
02059 int u, v;
02060 float r, g, b;
02061
02062 u = input[1];
02063 v = input[2];
02064 YUV16_TO_RGB_FLOAT(y, u, v, r, g, b);
02065
02066 *(*output)++ = r;
02067 *(*output)++ = g;
02068 *(*output)++ = b;
02069 }
02070
02071 static inline void transfer_YUV161616_to_RGBA_FLOAT(float *(*output), uint16_t *input)
02072 {
02073 float y = (float)input[0] / 0xffff;
02074 int u, v;
02075 float r, g, b;
02076
02077 u = input[1];
02078 v = input[2];
02079 YUV16_TO_RGB_FLOAT(y, u, v, r, g, b);
02080
02081 *(*output)++ = r;
02082 *(*output)++ = g;
02083 *(*output)++ = b;
02084 *(*output)++ = 1.0;
02085 }
02086
02087 static inline void transfer_YUV161616_to_BGR8888(unsigned char *(*output), uint16_t *input)
02088 {
02089 int y, u, v;
02090 int r, g, b;
02091
02092 y = (((int)input[0]) << 8) | (input[0] >> 8);
02093 u = input[1] >> 8;
02094 v = input[2] >> 8;
02095 YUV_TO_RGB(y, u, v, r, g, b);
02096 *(*output)++ = b;
02097 *(*output)++ = g;
02098 *(*output)++ = r;
02099 (*output)++;
02100 }
02101
02102 static inline void transfer_YUV161616_to_YUV161616(uint16_t *(*output), uint16_t *input)
02103 {
02104 (*output)[0] = input[0];
02105 (*output)[1] = input[1];
02106 (*output)[2] = input[2];
02107 (*output) += 3;
02108 }
02109
02110 static inline void transfer_YUV161616_to_YUVA8888(unsigned char *(*output), uint16_t *input)
02111 {
02112 (*output)[0] = input[0] >> 8;
02113 (*output)[1] = input[1] >> 8;
02114 (*output)[2] = input[2] >> 8;
02115 (*output)[3] = 255;
02116 (*output) += 4;
02117 }
02118
02119
02120 static inline void transfer_YUV161616_to_VYU888(unsigned char *(*output), uint16_t *input)
02121 {
02122 (*output)[0] = input[2] >> 8;
02123 (*output)[1] = input[0] >> 8;
02124 (*output)[2] = input[1] >> 8;
02125 (*output) += 3;
02126 }
02127
02128
02129 static inline void transfer_YUV161616_to_UYVA8888(unsigned char *(*output), uint16_t *input)
02130 {
02131 (*output)[0] = input[1] >> 8;
02132 (*output)[1] = input[0] >> 8;
02133 (*output)[2] = input[2] >> 8;
02134 (*output)[3] = input[3] >> 8;
02135 (*output) += 4;
02136 }
02137
02138 static inline void transfer_YUV161616_to_YUV101010(unsigned char *(*output), uint16_t *input)
02139 {
02140 uint16_t y_i = input[0];
02141 uint16_t u_i = input[1];
02142 uint16_t v_i = input[2];
02143 WRITE_YUV101010(y_i, u_i, v_i);
02144 }
02145
02146 static inline void transfer_YUV161616_to_YUV420P_YUV422P(unsigned char *output_y,
02147 unsigned char *output_u,
02148 unsigned char *output_v,
02149 uint16_t *input,
02150 int output_column)
02151 {
02152 output_y[output_column] = input[0] >> 8;
02153 output_u[output_column / 2] = input[1] >> 8;
02154 output_v[output_column / 2] = input[2] >> 8;
02155 }
02156
02157 static inline void transfer_YUV161616_to_YUV444P(unsigned char *output_y,
02158 unsigned char *output_u,
02159 unsigned char *output_v,
02160 uint16_t *input,
02161 int output_column)
02162 {
02163 output_y[output_column] = input[0] >> 8;
02164 output_u[output_column] = input[1] >> 8;
02165 output_v[output_column] = input[2] >> 8;
02166 }
02167
02168 static inline void transfer_YUV161616_to_YUV422(unsigned char *(*output),
02169 uint16_t *input,
02170 int j)
02171 {
02172
02173 if(!(j & 1))
02174 {
02175 (*output)[1] = input[1] >> 8;
02176 (*output)[3] = input[2] >> 8;
02177 (*output)[0] = input[0] >> 8;
02178 }
02179 else
02180
02181 {
02182 (*output)[2] = input[0] >> 8;
02183 (*output) += 4;
02184 }
02185 }
02186
02187
02188
02189
02190
02191
02192
02193
02194
02195
02196
02197
02198
02199
02200
02201
02202 static inline void transfer_YUVA16161616_to_RGB8(unsigned char *(*output), uint16_t *input)
02203 {
02204 int y, u, v, a;
02205 int r, g, b;
02206
02207 a = input[3];
02208 y = (((int)input[0]) << 8) | (input[0] >> 8);
02209 u = input[1] >> 8;
02210 v = input[2] >> 8;
02211 YUV_TO_RGB(y, u, v, r, g, b);
02212
02213 r *= a;
02214 g *= a;
02215 b *= a;
02216
02217 *(*output) = (unsigned char)(((r & 0xc000) >> 8) +
02218 ((g & 0xe000) >> 10) +
02219 ((b & 0xe000) >> 13));
02220 (*output)++;
02221 }
02222
02223 static inline void transfer_YUVA16161616_to_BGR565(unsigned char *(*output), uint16_t *input)
02224 {
02225 int y, u, v, a;
02226 int r, g, b;
02227
02228 a = input[3] >> 8;
02229 y = (((int)input[0]) << 8) | (input[0] >> 8);
02230 u = input[1] >> 8;
02231 v = input[2] >> 8;
02232 YUV_TO_RGB(y, u, v, r, g, b);
02233
02234 r *= a;
02235 g *= a;
02236 b *= a;
02237
02238 *(uint16_t*)(*output) = (uint16_t)((b & 0xf800) +
02239 ((g & 0xfc00) >> 5) +
02240 ((r & 0xf800) >> 11));
02241 (*output) += 2;
02242 }
02243
02244 static inline void transfer_YUVA16161616_to_RGB565(unsigned char *(*output), uint16_t *input)
02245 {
02246 int y, u, v, a;
02247 int r, g, b;
02248
02249 a = input[3] >> 8;
02250 y = (((int)input[0]) << 8) | (input[0] >> 8);
02251 u = input[1] >> 8;
02252 v = input[2] >> 8;
02253 YUV_TO_RGB(y, u, v, r, g, b);
02254
02255 r *= a;
02256 g *= a;
02257 b *= a;
02258
02259 *(uint16_t*)(*output) = (uint16_t)((r & 0xf800) +
02260 ((g & 0xfc00) >> 5) +
02261 ((b & 0xf800) >> 11));
02262 (*output) += 2;
02263 }
02264
02265 static inline void transfer_YUVA16161616_to_BGR888(unsigned char *(*output), uint16_t *input)
02266 {
02267 int y, u, v, a;
02268 int r, g, b;
02269
02270 a = input[3];
02271 y = (((int)input[0]) << 8) | (input[0] >> 8);
02272 u = input[1];
02273 v = input[2];
02274
02275 YUV_TO_RGB16(y, u, v, r, g, b);
02276
02277 r *= a;
02278 g *= a;
02279 b *= a;
02280
02281 *(*output)++ = b / 0xffff00;
02282 *(*output)++ = g / 0xffff00;
02283 *(*output)++ = r / 0xffff00;
02284 }
02285
02286 static inline void transfer_YUVA16161616_to_RGB888(unsigned char *(*output), uint16_t *input)
02287 {
02288 unsigned int y, u, v, a;
02289 unsigned int r, g, b;
02290
02291 a = input[3];
02292 y = (((int)input[0]) << 8) | (input[0] >> 8);
02293 u = input[1];
02294 v = input[2];
02295
02296 YUV_TO_RGB16(y, u, v, r, g, b);
02297
02298 r *= a;
02299 g *= a;
02300 b *= a;
02301 r /= 0xffff00;
02302 g /= 0xffff00;
02303 b /= 0xffff00;
02304
02305 CLAMP(r, 0, 0xff);
02306 CLAMP(g, 0, 0xff);
02307 CLAMP(b, 0, 0xff);
02308
02309 *(*output)++ = r;
02310 *(*output)++ = g;
02311 *(*output)++ = b;
02312 }
02313
02314 static inline void transfer_YUVA16161616_to_RGBA8888(unsigned char *(*output), uint16_t *input)
02315 {
02316 unsigned int y, u, v;
02317 unsigned int r, g, b;
02318
02319 y = (((int)input[0]) << 8) | (input[0] >> 8);
02320 u = input[1];
02321 v = input[2];
02322
02323 YUV_TO_RGB16(y, u, v, r, g, b);
02324
02325 *(*output)++ = (r >> 8);
02326 *(*output)++ = (g >> 8);
02327 *(*output)++ = (b >> 8);
02328 *(*output)++ = input[3] >> 8;
02329 }
02330
02331 static inline void transfer_YUVA16161616_to_ARGB8888(unsigned char *(*output), uint16_t *input)
02332 {
02333 unsigned int y, u, v;
02334 unsigned int r, g, b;
02335
02336 y = (((int)input[0]) << 8) | (input[0] >> 8);
02337 u = input[1];
02338 v = input[2];
02339
02340 YUV_TO_RGB16(y, u, v, r, g, b);
02341
02342 *(*output)++ = input[3] >> 8;
02343 *(*output)++ = (r >> 8);
02344 *(*output)++ = (g >> 8);
02345 *(*output)++ = (b >> 8);
02346 }
02347
02348 static inline void transfer_YUVA16161616_to_RGB_FLOAT(float *(*output),
02349 uint16_t *input)
02350 {
02351 float y;
02352 int u, v;
02353 float r, g, b, a;
02354
02355 y = (float)input[0] / 0xffff;
02356 u = input[1];
02357 v = input[2];
02358 a = (float)input[3] / 0xffff;
02359
02360 YUV16_TO_RGB_FLOAT(y, u, v, r, g, b);
02361
02362 r *= a;
02363 g *= a;
02364 b *= a;
02365
02366 *(*output)++ = r;
02367 *(*output)++ = g;
02368 *(*output)++ = b;
02369 }
02370
02371 static inline void transfer_YUVA16161616_to_RGBA_FLOAT(float *(*output),
02372 uint16_t *input)
02373 {
02374 float y;
02375 int u, v;
02376 float r, g, b, a;
02377
02378 y = (float)input[0] / 0xffff;
02379 u = input[1];
02380 v = input[2];
02381 a = (float)input[3] / 0xffff;
02382
02383 YUV16_TO_RGB_FLOAT(y, u, v, r, g, b);
02384
02385 *(*output)++ = r;
02386 *(*output)++ = g;
02387 *(*output)++ = b;
02388 *(*output)++ = a;
02389 }
02390
02391 static inline void transfer_YUVA16161616_to_BGR8888(unsigned char *(*output),
02392 uint16_t *input)
02393 {
02394 int y, u, v, a;
02395 int64_t r, g, b;
02396
02397 a = input[3];
02398 y = (((int)input[0]) << 8) | (input[0] >> 8);
02399 u = input[1] >> 8;
02400 v = input[2] >> 8;
02401
02402 YUV_TO_RGB(y, u, v, r, g, b);
02403
02404 r *= a;
02405 g *= a;
02406 b *= a;
02407 b /= 0xffff;
02408 g /= 0xffff;
02409 r /= 0xffff;
02410
02411 *(*output)++ = b;
02412 *(*output)++ = g;
02413 *(*output)++ = r;
02414 (*output)++;
02415 }
02416
02417
02418 static inline void transfer_YUVA16161616_to_VYU888(unsigned char *(*output), uint16_t *input)
02419 {
02420 int y, u, v, a, anti_a;
02421 a = input[3];
02422 anti_a = 0xffff - a;
02423 y = ((uint32_t)input[0] * a) / 0xffff00;
02424 u = ((uint32_t)input[1] * a + 0x8000 * anti_a) / 0xffff00;
02425 v = ((uint32_t)input[2] * a + 0x8000 * anti_a) / 0xffff00;
02426
02427 *(*output)++ = v;
02428 *(*output)++ = y;
02429 *(*output)++ = u;
02430 }
02431
02432
02433 static inline void transfer_YUVA16161616_to_YUVA16161616(uint16_t *(*output), uint16_t *input)
02434 {
02435 (*output)[0] = input[0];
02436 (*output)[1] = input[1];
02437 (*output)[2] = input[2];
02438 (*output)[3] = input[3];
02439 (*output) += 4;
02440 }
02441
02442 static inline void transfer_YUVA16161616_to_UYVA8888(unsigned char *(*output), uint16_t *input)
02443 {
02444 (*output)[0] = input[1] >> 8;
02445 (*output)[1] = input[0] >> 8;
02446 (*output)[2] = input[2] >> 8;
02447 (*output)[3] = input[3] >> 8;
02448 (*output) += 4;
02449 }
02450
02451
02452 static inline void transfer_YUVA16161616_to_YUV101010(unsigned char *(*output), uint16_t *input)
02453 {
02454 int64_t opacity = input[3];
02455 int64_t transparency = 0xffff - opacity;
02456 uint16_t y_i = ((int64_t)input[0] * opacity + (int64_t)0x8000 * transparency) / 0xffff;
02457 uint16_t u_i = ((int64_t)input[1] * opacity + (int64_t)0x8000 * transparency) / 0xffff;
02458 uint16_t v_i = ((int64_t)input[2] * opacity + (int64_t)0x8000 * transparency) / 0xffff;
02459 WRITE_YUV101010(y_i, u_i, v_i);
02460 }
02461
02462 static inline void transfer_YUVA16161616_to_YUV420P_YUV422P(unsigned char *output_y,
02463 unsigned char *output_u,
02464 unsigned char *output_v,
02465 uint16_t *input,
02466 int output_column)
02467 {
02468 int64_t opacity = input[3];
02469 int64_t transparency = 0xffff - opacity;
02470
02471 output_y[output_column] = ((int64_t)input[0] * opacity) / 0xffff00;
02472 output_u[output_column / 2] = ((int64_t)input[1] * opacity + 0x8000 * transparency) / 0xffff00;
02473 output_v[output_column / 2] = ((int64_t)input[2] * opacity + 0x8000 * transparency) / 0xffff00;
02474 }
02475
02476 static inline void transfer_YUVA16161616_to_YUV444P(unsigned char *output_y,
02477 unsigned char *output_u,
02478 unsigned char *output_v,
02479 uint16_t *input,
02480 int output_column)
02481 {
02482 int64_t opacity = input[3];
02483 int64_t transparency = 0xffff - opacity;
02484
02485 output_y[output_column] = ((int64_t)input[0] * opacity) / 0xffff00;
02486 output_u[output_column] = ((int64_t)input[1] * opacity + 0x8000 * transparency) / 0xffff00;
02487 output_v[output_column] = ((int64_t)input[2] * opacity + 0x8000 * transparency) / 0xffff00;
02488 }
02489
02490 static inline void transfer_YUVA16161616_to_YUV422(unsigned char *(*output),
02491 uint16_t *input,
02492 int j)
02493 {
02494 int64_t opacity = input[3];
02495 int64_t transparency = 0xffff - opacity;
02496
02497
02498 if(!(j & 1))
02499 {
02500 (*output)[0] = ((int64_t)input[0] * opacity) / 0xffff00;
02501 (*output)[1] = ((int64_t)input[1] * opacity + 0x8000 * transparency) / 0xffff00;
02502 (*output)[3] = ((int64_t)input[2] * opacity + 0x8000 * transparency) / 0xffff00;
02503 }
02504 else
02505
02506 {
02507 (*output)[2] = (input[0] * opacity) / 0xffff00;
02508 (*output) += 4;
02509 }
02510 }
02511
02512
02513
02514
02515
02516
02517
02518
02519
02520
02521
02522
02523
02524
02525
02526
02527
02528
02529
02530
02531
02532
02533
02534
02535
02536
02537
02538
02539
02540
02541
02542
02543
02544
02545
02546
02547
02548
02549
02550
02551
02552
02553
02554 #define TRANSFER_FRAME_HEAD \
02555 for(i = 0; i < out_h; i++) \
02556 { \
02557 unsigned char *output_row = output_rows[i + out_y] + out_x * out_pixelsize; \
02558 unsigned char *input_row = input_rows[row_table[i]]; \
02559 int bit_counter = 7; \
02560 for(j = 0; j < out_w; j++) \
02561 {
02562
02563 #define TRANSFER_FRAME_TAIL \
02564 } \
02565 }
02566
02567 #define TRANSFER_YUV420P_OUT_HEAD \
02568 for(i = 0; i < out_h; i++) \
02569 { \
02570 unsigned char *input_row = input_rows[row_table[i]]; \
02571 unsigned char *output_y = out_y_plane + i * total_out_w + out_x; \
02572 unsigned char *output_u = out_u_plane + i / 2 * total_out_w / 2 + out_x / 2; \
02573 unsigned char *output_v = out_v_plane + i / 2 * total_out_w / 2 + out_x / 2; \
02574 for(j = 0; j < out_w; j++) \
02575 {
02576
02577 #define TRANSFER_YUV422P_OUT_HEAD \
02578 for(i = 0; i < out_h; i++) \
02579 { \
02580 unsigned char *input_row = input_rows[row_table[i]]; \
02581 unsigned char *output_y = out_y_plane + i * total_out_w + out_x; \
02582 unsigned char *output_u = out_u_plane + i * total_out_w / 2 + out_x / 2; \
02583 unsigned char *output_v = out_v_plane + i * total_out_w / 2 + out_x / 2; \
02584 for(j = 0; j < out_w; j++) \
02585 {
02586
02587 #define TRANSFER_YUV444P_OUT_HEAD \
02588 for(i = 0; i < out_h; i++) \
02589 { \
02590 unsigned char *input_row = input_rows[row_table[i]]; \
02591 unsigned char *output_y = out_y_plane + i * total_out_w + out_x; \
02592 unsigned char *output_u = out_u_plane + i * total_out_w + out_x; \
02593 unsigned char *output_v = out_v_plane + i * total_out_w + out_x; \
02594 for(j = 0; j < out_w; j++) \
02595 {
02596
02597 #define TRANSFER_YUV420P_IN_HEAD \
02598 for(i = 0; i < out_h; i++) \
02599 { \
02600 unsigned char *output_row = output_rows[i + out_y] + out_x * out_pixelsize; \
02601 unsigned char *input_y = in_y_plane + row_table[i] * total_in_w; \
02602 unsigned char *input_u = in_u_plane + (row_table[i] / 2) * (total_in_w / 2); \
02603 unsigned char *input_v = in_v_plane + (row_table[i] / 2) * (total_in_w / 2); \
02604 for(j = 0; j < out_w; j++) \
02605 {
02606
02607 #define TRANSFER_YUV9P_IN_HEAD \
02608 for(i = 0; i < out_h; i++) \
02609 { \
02610 unsigned char *output_row = output_rows[i + out_y] + out_x * out_pixelsize; \
02611 unsigned char *input_y = in_y_plane + row_table[i] * total_in_w; \
02612 unsigned char *input_u = in_u_plane + (row_table[i] / 4) * (total_in_w / 4); \
02613 unsigned char *input_v = in_v_plane + (row_table[i] / 4) * (total_in_w / 4); \
02614 for(j = 0; j < out_w; j++) \
02615 {
02616
02617
02618 #define TRANSFER_YUV422P_IN_HEAD \
02619 for(i = 0; i < out_h; i++) \
02620 { \
02621 unsigned char *output_row = output_rows[i + out_y] + out_x * out_pixelsize; \
02622 unsigned char *input_y = in_y_plane + row_table[i] * total_in_w; \
02623 unsigned char *input_u = in_u_plane + row_table[i] * (total_in_w / 2); \
02624 unsigned char *input_v = in_v_plane + row_table[i] * (total_in_w / 2); \
02625 for(j = 0; j < out_w; j++) \
02626 {
02627
02628 #define TRANSFER_YUV444P_IN_HEAD \
02629 for(i = 0; i < out_h; i++) \
02630 { \
02631 unsigned char *output_row = output_rows[i + out_y] + out_x * out_pixelsize; \
02632 unsigned char *input_y = in_y_plane + row_table[i] * total_in_w; \
02633 unsigned char *input_u = in_u_plane + row_table[i] * total_in_w; \
02634 unsigned char *input_v = in_v_plane + row_table[i] * total_in_w; \
02635 for(j = 0; j < out_w; j++) \
02636 {
02637
02638
02639 #define TRANSFER_YUV422_IN_HEAD \
02640 for(i = 0; i < out_h; i++) \
02641 { \
02642 unsigned char *output_row = output_rows[i + out_y] + ((out_x * out_pixelsize) & 0xfffffffc); \
02643 unsigned char *input_y = in_y_plane + row_table[i] * total_in_w; \
02644 unsigned char *input_u = in_u_plane + row_table[i] * (total_in_w / 2); \
02645 unsigned char *input_v = in_v_plane + row_table[i] * (total_in_w / 2); \
02646 for(j = 0; j < out_w; j++) \
02647 {
02648
02649
02650
02651
02652
02653
02654
02655
02656
02657 #define PERMUTATION_ARGS \
02658 unsigned char **output_rows, \
02659 unsigned char **input_rows, \
02660 unsigned char *out_y_plane, \
02661 unsigned char *out_u_plane, \
02662 unsigned char *out_v_plane, \
02663 unsigned char *in_y_plane, \
02664 unsigned char *in_u_plane, \
02665 unsigned char *in_v_plane, \
02666 int in_x, \
02667 int in_y, \
02668 int in_w, \
02669 int in_h, \
02670 int out_x, \
02671 int out_y, \
02672 int out_w, \
02673 int out_h, \
02674 int in_colormodel, \
02675 int out_colormodel, \
02676 int bg_color, \
02677 int total_in_w, \
02678 int total_out_w, \
02679 int scale, \
02680 int out_pixelsize, \
02681 int in_pixelsize, \
02682 int *row_table, \
02683 int *column_table, \
02684 int bg_r, \
02685 int bg_g, \
02686 int bg_b