00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include <stddef.h>
00028
00029 static inline void rgb24tobgr32_c(const uint8_t *src, uint8_t *dst,
00030 int src_size)
00031 {
00032 uint8_t *dest = dst;
00033 const uint8_t *s = src;
00034 const uint8_t *end = s + src_size;
00035
00036 while (s < end) {
00037 #if HAVE_BIGENDIAN
00038
00039 *dest++ = 255;
00040 *dest++ = s[2];
00041 *dest++ = s[1];
00042 *dest++ = s[0];
00043 s += 3;
00044 #else
00045 *dest++ = *s++;
00046 *dest++ = *s++;
00047 *dest++ = *s++;
00048 *dest++ = 255;
00049 #endif
00050 }
00051 }
00052
00053 static inline void rgb32tobgr24_c(const uint8_t *src, uint8_t *dst,
00054 int src_size)
00055 {
00056 uint8_t *dest = dst;
00057 const uint8_t *s = src;
00058 const uint8_t *end = s + src_size;
00059
00060 while (s < end) {
00061 #if HAVE_BIGENDIAN
00062
00063 s++;
00064 dest[2] = *s++;
00065 dest[1] = *s++;
00066 dest[0] = *s++;
00067 dest += 3;
00068 #else
00069 *dest++ = *s++;
00070 *dest++ = *s++;
00071 *dest++ = *s++;
00072 s++;
00073 #endif
00074 }
00075 }
00076
00077
00078
00079
00080
00081
00082
00083 static inline void rgb15to16_c(const uint8_t *src, uint8_t *dst, int src_size)
00084 {
00085 register uint8_t *d = dst;
00086 register const uint8_t *s = src;
00087 register const uint8_t *end = s + src_size;
00088 const uint8_t *mm_end = end - 3;
00089
00090 while (s < mm_end) {
00091 register unsigned x = *((const uint32_t *)s);
00092 *((uint32_t *)d) = (x & 0x7FFF7FFF) + (x & 0x7FE07FE0);
00093 d += 4;
00094 s += 4;
00095 }
00096 if (s < end) {
00097 register unsigned short x = *((const uint16_t *)s);
00098 *((uint16_t *)d) = (x & 0x7FFF) + (x & 0x7FE0);
00099 }
00100 }
00101
00102 static inline void rgb16to15_c(const uint8_t *src, uint8_t *dst, int src_size)
00103 {
00104 register uint8_t *d = dst;
00105 register const uint8_t *s = src;
00106 register const uint8_t *end = s + src_size;
00107 const uint8_t *mm_end = end - 3;
00108
00109 while (s < mm_end) {
00110 register uint32_t x = *((const uint32_t *)s);
00111 *((uint32_t *)d) = ((x >> 1) & 0x7FE07FE0) | (x & 0x001F001F);
00112 s += 4;
00113 d += 4;
00114 }
00115 if (s < end) {
00116 register uint16_t x = *((const uint16_t *)s);
00117 *((uint16_t *)d) = ((x >> 1) & 0x7FE0) | (x & 0x001F);
00118 }
00119 }
00120
00121 static inline void rgb32to16_c(const uint8_t *src, uint8_t *dst, int src_size)
00122 {
00123 uint16_t *d = (uint16_t *)dst;
00124 const uint8_t *s = src;
00125 const uint8_t *end = s + src_size;
00126
00127 while (s < end) {
00128 register int rgb = *(const uint32_t *)s;
00129 s += 4;
00130 *d++ = ((rgb & 0xFF) >> 3) +
00131 ((rgb & 0xFC00) >> 5) +
00132 ((rgb & 0xF80000) >> 8);
00133 }
00134 }
00135
00136 static inline void rgb32tobgr16_c(const uint8_t *src, uint8_t *dst,
00137 int src_size)
00138 {
00139 uint16_t *d = (uint16_t *)dst;
00140 const uint8_t *s = src;
00141 const uint8_t *end = s + src_size;
00142
00143 while (s < end) {
00144 register int rgb = *(const uint32_t *)s;
00145 s += 4;
00146 *d++ = ((rgb & 0xF8) << 8) +
00147 ((rgb & 0xFC00) >> 5) +
00148 ((rgb & 0xF80000) >> 19);
00149 }
00150 }
00151
00152 static inline void rgb32to15_c(const uint8_t *src, uint8_t *dst, int src_size)
00153 {
00154 uint16_t *d = (uint16_t *)dst;
00155 const uint8_t *s = src;
00156 const uint8_t *end = s + src_size;
00157
00158 while (s < end) {
00159 register int rgb = *(const uint32_t *)s;
00160 s += 4;
00161 *d++ = ((rgb & 0xFF) >> 3) +
00162 ((rgb & 0xF800) >> 6) +
00163 ((rgb & 0xF80000) >> 9);
00164 }
00165 }
00166
00167 static inline void rgb32tobgr15_c(const uint8_t *src, uint8_t *dst,
00168 int src_size)
00169 {
00170 uint16_t *d = (uint16_t *)dst;
00171 const uint8_t *s = src;
00172 const uint8_t *end = s + src_size;
00173
00174 while (s < end) {
00175 register int rgb = *(const uint32_t *)s;
00176 s += 4;
00177 *d++ = ((rgb & 0xF8) << 7) +
00178 ((rgb & 0xF800) >> 6) +
00179 ((rgb & 0xF80000) >> 19);
00180 }
00181 }
00182
00183 static inline void rgb24tobgr16_c(const uint8_t *src, uint8_t *dst,
00184 int src_size)
00185 {
00186 uint16_t *d = (uint16_t *)dst;
00187 const uint8_t *s = src;
00188 const uint8_t *end = s + src_size;
00189
00190 while (s < end) {
00191 const int b = *s++;
00192 const int g = *s++;
00193 const int r = *s++;
00194 *d++ = (b >> 3) | ((g & 0xFC) << 3) | ((r & 0xF8) << 8);
00195 }
00196 }
00197
00198 static inline void rgb24to16_c(const uint8_t *src, uint8_t *dst, int src_size)
00199 {
00200 uint16_t *d = (uint16_t *)dst;
00201 const uint8_t *s = src;
00202 const uint8_t *end = s + src_size;
00203
00204 while (s < end) {
00205 const int r = *s++;
00206 const int g = *s++;
00207 const int b = *s++;
00208 *d++ = (b >> 3) | ((g & 0xFC) << 3) | ((r & 0xF8) << 8);
00209 }
00210 }
00211
00212 static inline void rgb24tobgr15_c(const uint8_t *src, uint8_t *dst,
00213 int src_size)
00214 {
00215 uint16_t *d = (uint16_t *)dst;
00216 const uint8_t *s = src;
00217 const uint8_t *end = s + src_size;
00218
00219 while (s < end) {
00220 const int b = *s++;
00221 const int g = *s++;
00222 const int r = *s++;
00223 *d++ = (b >> 3) | ((g & 0xF8) << 2) | ((r & 0xF8) << 7);
00224 }
00225 }
00226
00227 static inline void rgb24to15_c(const uint8_t *src, uint8_t *dst, int src_size)
00228 {
00229 uint16_t *d = (uint16_t *)dst;
00230 const uint8_t *s = src;
00231 const uint8_t *end = s + src_size;
00232
00233 while (s < end) {
00234 const int r = *s++;
00235 const int g = *s++;
00236 const int b = *s++;
00237 *d++ = (b >> 3) | ((g & 0xF8) << 2) | ((r & 0xF8) << 7);
00238 }
00239 }
00240
00241 static inline void rgb15tobgr24_c(const uint8_t *src, uint8_t *dst,
00242 int src_size)
00243 {
00244 uint8_t *d = dst;
00245 const uint16_t *s = (const uint16_t *)src;
00246 const uint16_t *end = s + src_size / 2;
00247
00248 while (s < end) {
00249 register uint16_t bgr = *s++;
00250 *d++ = ((bgr&0x001F)<<3) | ((bgr&0x001F)>> 2);
00251 *d++ = ((bgr&0x03E0)>>2) | ((bgr&0x03E0)>> 7);
00252 *d++ = ((bgr&0x7C00)>>7) | ((bgr&0x7C00)>>12);
00253 }
00254 }
00255
00256 static inline void rgb16tobgr24_c(const uint8_t *src, uint8_t *dst,
00257 int src_size)
00258 {
00259 uint8_t *d = (uint8_t *)dst;
00260 const uint16_t *s = (const uint16_t *)src;
00261 const uint16_t *end = s + src_size / 2;
00262
00263 while (s < end) {
00264 register uint16_t bgr = *s++;
00265 *d++ = ((bgr&0x001F)<<3) | ((bgr&0x001F)>> 2);
00266 *d++ = ((bgr&0x07E0)>>3) | ((bgr&0x07E0)>> 9);
00267 *d++ = ((bgr&0xF800)>>8) | ((bgr&0xF800)>>13);
00268 }
00269 }
00270
00271 static inline void rgb15to32_c(const uint8_t *src, uint8_t *dst, int src_size)
00272 {
00273 uint8_t *d = dst;
00274 const uint16_t *s = (const uint16_t *)src;
00275 const uint16_t *end = s + src_size / 2;
00276
00277 while (s < end) {
00278 register uint16_t bgr = *s++;
00279 #if HAVE_BIGENDIAN
00280 *d++ = 255;
00281 *d++ = ((bgr&0x7C00)>>7) | ((bgr&0x7C00)>>12);
00282 *d++ = ((bgr&0x03E0)>>2) | ((bgr&0x03E0)>> 7);
00283 *d++ = ((bgr&0x001F)<<3) | ((bgr&0x001F)>> 2);
00284 #else
00285 *d++ = ((bgr&0x001F)<<3) | ((bgr&0x001F)>> 2);
00286 *d++ = ((bgr&0x03E0)>>2) | ((bgr&0x03E0)>> 7);
00287 *d++ = ((bgr&0x7C00)>>7) | ((bgr&0x7C00)>>12);
00288 *d++ = 255;
00289 #endif
00290 }
00291 }
00292
00293 static inline void rgb16to32_c(const uint8_t *src, uint8_t *dst, int src_size)
00294 {
00295 uint8_t *d = dst;
00296 const uint16_t *s = (const uint16_t *)src;
00297 const uint16_t *end = s + src_size / 2;
00298
00299 while (s < end) {
00300 register uint16_t bgr = *s++;
00301 #if HAVE_BIGENDIAN
00302 *d++ = 255;
00303 *d++ = ((bgr&0xF800)>>8) | ((bgr&0xF800)>>13);
00304 *d++ = ((bgr&0x07E0)>>3) | ((bgr&0x07E0)>> 9);
00305 *d++ = ((bgr&0x001F)<<3) | ((bgr&0x001F)>> 2);
00306 #else
00307 *d++ = ((bgr&0x001F)<<3) | ((bgr&0x001F)>> 2);
00308 *d++ = ((bgr&0x07E0)>>3) | ((bgr&0x07E0)>> 9);
00309 *d++ = ((bgr&0xF800)>>8) | ((bgr&0xF800)>>13);
00310 *d++ = 255;
00311 #endif
00312 }
00313 }
00314
00315 static inline void shuffle_bytes_2103_c(const uint8_t *src, uint8_t *dst,
00316 int src_size)
00317 {
00318 int idx = 15 - src_size;
00319 const uint8_t *s = src - idx;
00320 uint8_t *d = dst - idx;
00321
00322 for (; idx < 15; idx += 4) {
00323 register int v = *(const uint32_t *)&s[idx], g = v & 0xff00ff00;
00324 v &= 0xff00ff;
00325 *(uint32_t *)&d[idx] = (v >> 16) + g + (v << 16);
00326 }
00327 }
00328
00329 static inline void rgb24tobgr24_c(const uint8_t *src, uint8_t *dst, int src_size)
00330 {
00331 unsigned i;
00332
00333 for (i = 0; i < src_size; i += 3) {
00334 register uint8_t x = src[i + 2];
00335 dst[i + 1] = src[i + 1];
00336 dst[i + 2] = src[i + 0];
00337 dst[i + 0] = x;
00338 }
00339 }
00340
00341 static inline void yuvPlanartoyuy2_c(const uint8_t *ysrc, const uint8_t *usrc,
00342 const uint8_t *vsrc, uint8_t *dst,
00343 int width, int height,
00344 int lumStride, int chromStride,
00345 int dstStride, int vertLumPerChroma)
00346 {
00347 int y, i;
00348 const int chromWidth = width >> 1;
00349
00350 for (y = 0; y < height; y++) {
00351 #if HAVE_FAST_64BIT
00352 uint64_t *ldst = (uint64_t *)dst;
00353 const uint8_t *yc = ysrc, *uc = usrc, *vc = vsrc;
00354 for (i = 0; i < chromWidth; i += 2) {
00355 uint64_t k = yc[0] + (uc[0] << 8) +
00356 (yc[1] << 16) + (vc[0] << 24);
00357 uint64_t l = yc[2] + (uc[1] << 8) +
00358 (yc[3] << 16) + (vc[1] << 24);
00359 *ldst++ = k + (l << 32);
00360 yc += 4;
00361 uc += 2;
00362 vc += 2;
00363 }
00364
00365 #else
00366 int *idst = (int32_t *)dst;
00367 const uint8_t *yc = ysrc, *uc = usrc, *vc = vsrc;
00368
00369 for (i = 0; i < chromWidth; i++) {
00370 #if HAVE_BIGENDIAN
00371 *idst++ = (yc[0] << 24) + (uc[0] << 16) +
00372 (yc[1] << 8) + (vc[0] << 0);
00373 #else
00374 *idst++ = yc[0] + (uc[0] << 8) +
00375 (yc[1] << 16) + (vc[0] << 24);
00376 #endif
00377 yc += 2;
00378 uc++;
00379 vc++;
00380 }
00381 #endif
00382 if ((y & (vertLumPerChroma - 1)) == vertLumPerChroma - 1) {
00383 usrc += chromStride;
00384 vsrc += chromStride;
00385 }
00386 ysrc += lumStride;
00387 dst += dstStride;
00388 }
00389 }
00390
00395 static inline void yv12toyuy2_c(const uint8_t *ysrc, const uint8_t *usrc,
00396 const uint8_t *vsrc, uint8_t *dst,
00397 int width, int height, int lumStride,
00398 int chromStride, int dstStride)
00399 {
00400
00401 yuvPlanartoyuy2_c(ysrc, usrc, vsrc, dst, width, height, lumStride,
00402 chromStride, dstStride, 2);
00403 }
00404
00405 static inline void yuvPlanartouyvy_c(const uint8_t *ysrc, const uint8_t *usrc,
00406 const uint8_t *vsrc, uint8_t *dst,
00407 int width, int height,
00408 int lumStride, int chromStride,
00409 int dstStride, int vertLumPerChroma)
00410 {
00411 int y, i;
00412 const int chromWidth = width >> 1;
00413
00414 for (y = 0; y < height; y++) {
00415 #if HAVE_FAST_64BIT
00416 uint64_t *ldst = (uint64_t *)dst;
00417 const uint8_t *yc = ysrc, *uc = usrc, *vc = vsrc;
00418 for (i = 0; i < chromWidth; i += 2) {
00419 uint64_t k = uc[0] + (yc[0] << 8) +
00420 (vc[0] << 16) + (yc[1] << 24);
00421 uint64_t l = uc[1] + (yc[2] << 8) +
00422 (vc[1] << 16) + (yc[3] << 24);
00423 *ldst++ = k + (l << 32);
00424 yc += 4;
00425 uc += 2;
00426 vc += 2;
00427 }
00428
00429 #else
00430 int *idst = (int32_t *)dst;
00431 const uint8_t *yc = ysrc, *uc = usrc, *vc = vsrc;
00432
00433 for (i = 0; i < chromWidth; i++) {
00434 #if HAVE_BIGENDIAN
00435 *idst++ = (uc[0] << 24) + (yc[0] << 16) +
00436 (vc[0] << 8) + (yc[1] << 0);
00437 #else
00438 *idst++ = uc[0] + (yc[0] << 8) +
00439 (vc[0] << 16) + (yc[1] << 24);
00440 #endif
00441 yc += 2;
00442 uc++;
00443 vc++;
00444 }
00445 #endif
00446 if ((y & (vertLumPerChroma - 1)) == vertLumPerChroma - 1) {
00447 usrc += chromStride;
00448 vsrc += chromStride;
00449 }
00450 ysrc += lumStride;
00451 dst += dstStride;
00452 }
00453 }
00454
00459 static inline void yv12touyvy_c(const uint8_t *ysrc, const uint8_t *usrc,
00460 const uint8_t *vsrc, uint8_t *dst,
00461 int width, int height, int lumStride,
00462 int chromStride, int dstStride)
00463 {
00464
00465 yuvPlanartouyvy_c(ysrc, usrc, vsrc, dst, width, height, lumStride,
00466 chromStride, dstStride, 2);
00467 }
00468
00472 static inline void yuv422ptouyvy_c(const uint8_t *ysrc, const uint8_t *usrc,
00473 const uint8_t *vsrc, uint8_t *dst,
00474 int width, int height, int lumStride,
00475 int chromStride, int dstStride)
00476 {
00477 yuvPlanartouyvy_c(ysrc, usrc, vsrc, dst, width, height, lumStride,
00478 chromStride, dstStride, 1);
00479 }
00480
00484 static inline void yuv422ptoyuy2_c(const uint8_t *ysrc, const uint8_t *usrc,
00485 const uint8_t *vsrc, uint8_t *dst,
00486 int width, int height, int lumStride,
00487 int chromStride, int dstStride)
00488 {
00489 yuvPlanartoyuy2_c(ysrc, usrc, vsrc, dst, width, height, lumStride,
00490 chromStride, dstStride, 1);
00491 }
00492
00497 static inline void yuy2toyv12_c(const uint8_t *src, uint8_t *ydst,
00498 uint8_t *udst, uint8_t *vdst,
00499 int width, int height, int lumStride,
00500 int chromStride, int srcStride)
00501 {
00502 int y;
00503 const int chromWidth = width >> 1;
00504
00505 for (y = 0; y < height; y += 2) {
00506 int i;
00507 for (i = 0; i < chromWidth; i++) {
00508 ydst[2 * i + 0] = src[4 * i + 0];
00509 udst[i] = src[4 * i + 1];
00510 ydst[2 * i + 1] = src[4 * i + 2];
00511 vdst[i] = src[4 * i + 3];
00512 }
00513 ydst += lumStride;
00514 src += srcStride;
00515
00516 for (i = 0; i < chromWidth; i++) {
00517 ydst[2 * i + 0] = src[4 * i + 0];
00518 ydst[2 * i + 1] = src[4 * i + 2];
00519 }
00520 udst += chromStride;
00521 vdst += chromStride;
00522 ydst += lumStride;
00523 src += srcStride;
00524 }
00525 }
00526
00527 static inline void planar2x_c(const uint8_t *src, uint8_t *dst, int srcWidth,
00528 int srcHeight, int srcStride, int dstStride)
00529 {
00530 int x, y;
00531
00532 dst[0] = src[0];
00533
00534
00535 for (x = 0; x < srcWidth - 1; x++) {
00536 dst[2 * x + 1] = (3 * src[x] + src[x + 1]) >> 2;
00537 dst[2 * x + 2] = (src[x] + 3 * src[x + 1]) >> 2;
00538 }
00539 dst[2 * srcWidth - 1] = src[srcWidth - 1];
00540
00541 dst += dstStride;
00542
00543 for (y = 1; y < srcHeight; y++) {
00544 const int mmxSize = 1;
00545
00546 dst[0] = (src[0] * 3 + src[srcStride]) >> 2;
00547 dst[dstStride] = (src[0] + 3 * src[srcStride]) >> 2;
00548
00549 for (x = mmxSize - 1; x < srcWidth - 1; x++) {
00550 dst[2 * x + 1] = (src[x + 0] * 3 + src[x + srcStride + 1]) >> 2;
00551 dst[2 * x + dstStride + 2] = (src[x + 0] + 3 * src[x + srcStride + 1]) >> 2;
00552 dst[2 * x + dstStride + 1] = (src[x + 1] + 3 * src[x + srcStride]) >> 2;
00553 dst[2 * x + 2] = (src[x + 1] * 3 + src[x + srcStride]) >> 2;
00554 }
00555 dst[srcWidth * 2 - 1] = (src[srcWidth - 1] * 3 + src[srcWidth - 1 + srcStride]) >> 2;
00556 dst[srcWidth * 2 - 1 + dstStride] = (src[srcWidth - 1] + 3 * src[srcWidth - 1 + srcStride]) >> 2;
00557
00558 dst += dstStride * 2;
00559 src += srcStride;
00560 }
00561
00562
00563 dst[0] = src[0];
00564
00565 for (x = 0; x < srcWidth - 1; x++) {
00566 dst[2 * x + 1] = (src[x] * 3 + src[x + 1]) >> 2;
00567 dst[2 * x + 2] = (src[x] + 3 * src[x + 1]) >> 2;
00568 }
00569 dst[2 * srcWidth - 1] = src[srcWidth - 1];
00570 }
00571
00578 static inline void uyvytoyv12_c(const uint8_t *src, uint8_t *ydst,
00579 uint8_t *udst, uint8_t *vdst,
00580 int width, int height, int lumStride,
00581 int chromStride, int srcStride)
00582 {
00583 int y;
00584 const int chromWidth = width >> 1;
00585
00586 for (y = 0; y < height; y += 2) {
00587 int i;
00588 for (i = 0; i < chromWidth; i++) {
00589 udst[i] = src[4 * i + 0];
00590 ydst[2 * i + 0] = src[4 * i + 1];
00591 vdst[i] = src[4 * i + 2];
00592 ydst[2 * i + 1] = src[4 * i + 3];
00593 }
00594 ydst += lumStride;
00595 src += srcStride;
00596
00597 for (i = 0; i < chromWidth; i++) {
00598 ydst[2 * i + 0] = src[4 * i + 1];
00599 ydst[2 * i + 1] = src[4 * i + 3];
00600 }
00601 udst += chromStride;
00602 vdst += chromStride;
00603 ydst += lumStride;
00604 src += srcStride;
00605 }
00606 }
00607
00615 void rgb24toyv12_c(const uint8_t *src, uint8_t *ydst, uint8_t *udst,
00616 uint8_t *vdst, int width, int height, int lumStride,
00617 int chromStride, int srcStride)
00618 {
00619 int y;
00620 const int chromWidth = width >> 1;
00621
00622 for (y = 0; y < height; y += 2) {
00623 int i;
00624 for (i = 0; i < chromWidth; i++) {
00625 unsigned int b = src[6 * i + 0];
00626 unsigned int g = src[6 * i + 1];
00627 unsigned int r = src[6 * i + 2];
00628
00629 unsigned int Y = ((RY * r + GY * g + BY * b) >> RGB2YUV_SHIFT) + 16;
00630 unsigned int V = ((RV * r + GV * g + BV * b) >> RGB2YUV_SHIFT) + 128;
00631 unsigned int U = ((RU * r + GU * g + BU * b) >> RGB2YUV_SHIFT) + 128;
00632
00633 udst[i] = U;
00634 vdst[i] = V;
00635 ydst[2 * i] = Y;
00636
00637 b = src[6 * i + 3];
00638 g = src[6 * i + 4];
00639 r = src[6 * i + 5];
00640
00641 Y = ((RY * r + GY * g + BY * b) >> RGB2YUV_SHIFT) + 16;
00642 ydst[2 * i + 1] = Y;
00643 }
00644 ydst += lumStride;
00645 src += srcStride;
00646
00647 if (y+1 == height)
00648 break;
00649
00650 for (i = 0; i < chromWidth; i++) {
00651 unsigned int b = src[6 * i + 0];
00652 unsigned int g = src[6 * i + 1];
00653 unsigned int r = src[6 * i + 2];
00654
00655 unsigned int Y = ((RY * r + GY * g + BY * b) >> RGB2YUV_SHIFT) + 16;
00656
00657 ydst[2 * i] = Y;
00658
00659 b = src[6 * i + 3];
00660 g = src[6 * i + 4];
00661 r = src[6 * i + 5];
00662
00663 Y = ((RY * r + GY * g + BY * b) >> RGB2YUV_SHIFT) + 16;
00664 ydst[2 * i + 1] = Y;
00665 }
00666 udst += chromStride;
00667 vdst += chromStride;
00668 ydst += lumStride;
00669 src += srcStride;
00670 }
00671 }
00672
00673 static void interleaveBytes_c(const uint8_t *src1, const uint8_t *src2,
00674 uint8_t *dest, int width, int height,
00675 int src1Stride, int src2Stride, int dstStride)
00676 {
00677 int h;
00678
00679 for (h = 0; h < height; h++) {
00680 int w;
00681 for (w = 0; w < width; w++) {
00682 dest[2 * w + 0] = src1[w];
00683 dest[2 * w + 1] = src2[w];
00684 }
00685 dest += dstStride;
00686 src1 += src1Stride;
00687 src2 += src2Stride;
00688 }
00689 }
00690
00691 static inline void vu9_to_vu12_c(const uint8_t *src1, const uint8_t *src2,
00692 uint8_t *dst1, uint8_t *dst2,
00693 int width, int height,
00694 int srcStride1, int srcStride2,
00695 int dstStride1, int dstStride2)
00696 {
00697 int x, y;
00698 int w = width / 2;
00699 int h = height / 2;
00700
00701 for (y = 0; y < h; y++) {
00702 const uint8_t *s1 = src1 + srcStride1 * (y >> 1);
00703 uint8_t *d = dst1 + dstStride1 * y;
00704 for (x = 0; x < w; x++)
00705 d[2 * x] = d[2 * x + 1] = s1[x];
00706 }
00707 for (y = 0; y < h; y++) {
00708 const uint8_t *s2 = src2 + srcStride2 * (y >> 1);
00709 uint8_t *d = dst2 + dstStride2 * y;
00710 for (x = 0; x < w; x++)
00711 d[2 * x] = d[2 * x + 1] = s2[x];
00712 }
00713 }
00714
00715 static inline void yvu9_to_yuy2_c(const uint8_t *src1, const uint8_t *src2,
00716 const uint8_t *src3, uint8_t *dst,
00717 int width, int height,
00718 int srcStride1, int srcStride2,
00719 int srcStride3, int dstStride)
00720 {
00721 int x, y;
00722 int w = width / 2;
00723 int h = height;
00724
00725 for (y = 0; y < h; y++) {
00726 const uint8_t *yp = src1 + srcStride1 * y;
00727 const uint8_t *up = src2 + srcStride2 * (y >> 2);
00728 const uint8_t *vp = src3 + srcStride3 * (y >> 2);
00729 uint8_t *d = dst + dstStride * y;
00730 for (x = 0; x < w; x++) {
00731 const int x2 = x << 2;
00732 d[8 * x + 0] = yp[x2];
00733 d[8 * x + 1] = up[x];
00734 d[8 * x + 2] = yp[x2 + 1];
00735 d[8 * x + 3] = vp[x];
00736 d[8 * x + 4] = yp[x2 + 2];
00737 d[8 * x + 5] = up[x];
00738 d[8 * x + 6] = yp[x2 + 3];
00739 d[8 * x + 7] = vp[x];
00740 }
00741 }
00742 }
00743
00744 static void extract_even_c(const uint8_t *src, uint8_t *dst, int count)
00745 {
00746 dst += count;
00747 src += count * 2;
00748 count = -count;
00749 while (count < 0) {
00750 dst[count] = src[2 * count];
00751 count++;
00752 }
00753 }
00754
00755 static void extract_even2_c(const uint8_t *src, uint8_t *dst0, uint8_t *dst1,
00756 int count)
00757 {
00758 dst0 += count;
00759 dst1 += count;
00760 src += count * 4;
00761 count = -count;
00762 while (count < 0) {
00763 dst0[count] = src[4 * count + 0];
00764 dst1[count] = src[4 * count + 2];
00765 count++;
00766 }
00767 }
00768
00769 static void extract_even2avg_c(const uint8_t *src0, const uint8_t *src1,
00770 uint8_t *dst0, uint8_t *dst1, int count)
00771 {
00772 dst0 += count;
00773 dst1 += count;
00774 src0 += count * 4;
00775 src1 += count * 4;
00776 count = -count;
00777 while (count < 0) {
00778 dst0[count] = (src0[4 * count + 0] + src1[4 * count + 0]) >> 1;
00779 dst1[count] = (src0[4 * count + 2] + src1[4 * count + 2]) >> 1;
00780 count++;
00781 }
00782 }
00783
00784 static void extract_odd2_c(const uint8_t *src, uint8_t *dst0, uint8_t *dst1,
00785 int count)
00786 {
00787 dst0 += count;
00788 dst1 += count;
00789 src += count * 4;
00790 count = -count;
00791 src++;
00792 while (count < 0) {
00793 dst0[count] = src[4 * count + 0];
00794 dst1[count] = src[4 * count + 2];
00795 count++;
00796 }
00797 }
00798
00799 static void extract_odd2avg_c(const uint8_t *src0, const uint8_t *src1,
00800 uint8_t *dst0, uint8_t *dst1, int count)
00801 {
00802 dst0 += count;
00803 dst1 += count;
00804 src0 += count * 4;
00805 src1 += count * 4;
00806 count = -count;
00807 src0++;
00808 src1++;
00809 while (count < 0) {
00810 dst0[count] = (src0[4 * count + 0] + src1[4 * count + 0]) >> 1;
00811 dst1[count] = (src0[4 * count + 2] + src1[4 * count + 2]) >> 1;
00812 count++;
00813 }
00814 }
00815
00816 static void yuyvtoyuv420_c(uint8_t *ydst, uint8_t *udst, uint8_t *vdst,
00817 const uint8_t *src, int width, int height,
00818 int lumStride, int chromStride, int srcStride)
00819 {
00820 int y;
00821 const int chromWidth = -((-width) >> 1);
00822
00823 for (y = 0; y < height; y++) {
00824 extract_even_c(src, ydst, width);
00825 if (y & 1) {
00826 extract_odd2avg_c(src - srcStride, src, udst, vdst, chromWidth);
00827 udst += chromStride;
00828 vdst += chromStride;
00829 }
00830
00831 src += srcStride;
00832 ydst += lumStride;
00833 }
00834 }
00835
00836 static void yuyvtoyuv422_c(uint8_t *ydst, uint8_t *udst, uint8_t *vdst,
00837 const uint8_t *src, int width, int height,
00838 int lumStride, int chromStride, int srcStride)
00839 {
00840 int y;
00841 const int chromWidth = -((-width) >> 1);
00842
00843 for (y = 0; y < height; y++) {
00844 extract_even_c(src, ydst, width);
00845 extract_odd2_c(src, udst, vdst, chromWidth);
00846
00847 src += srcStride;
00848 ydst += lumStride;
00849 udst += chromStride;
00850 vdst += chromStride;
00851 }
00852 }
00853
00854 static void uyvytoyuv420_c(uint8_t *ydst, uint8_t *udst, uint8_t *vdst,
00855 const uint8_t *src, int width, int height,
00856 int lumStride, int chromStride, int srcStride)
00857 {
00858 int y;
00859 const int chromWidth = -((-width) >> 1);
00860
00861 for (y = 0; y < height; y++) {
00862 extract_even_c(src + 1, ydst, width);
00863 if (y & 1) {
00864 extract_even2avg_c(src - srcStride, src, udst, vdst, chromWidth);
00865 udst += chromStride;
00866 vdst += chromStride;
00867 }
00868
00869 src += srcStride;
00870 ydst += lumStride;
00871 }
00872 }
00873
00874 static void uyvytoyuv422_c(uint8_t *ydst, uint8_t *udst, uint8_t *vdst,
00875 const uint8_t *src, int width, int height,
00876 int lumStride, int chromStride, int srcStride)
00877 {
00878 int y;
00879 const int chromWidth = -((-width) >> 1);
00880
00881 for (y = 0; y < height; y++) {
00882 extract_even_c(src + 1, ydst, width);
00883 extract_even2_c(src, udst, vdst, chromWidth);
00884
00885 src += srcStride;
00886 ydst += lumStride;
00887 udst += chromStride;
00888 vdst += chromStride;
00889 }
00890 }
00891
00892 static inline void rgb2rgb_init_c(void)
00893 {
00894 rgb15to16 = rgb15to16_c;
00895 rgb15tobgr24 = rgb15tobgr24_c;
00896 rgb15to32 = rgb15to32_c;
00897 rgb16tobgr24 = rgb16tobgr24_c;
00898 rgb16to32 = rgb16to32_c;
00899 rgb16to15 = rgb16to15_c;
00900 rgb24tobgr16 = rgb24tobgr16_c;
00901 rgb24tobgr15 = rgb24tobgr15_c;
00902 rgb24tobgr32 = rgb24tobgr32_c;
00903 rgb32to16 = rgb32to16_c;
00904 rgb32to15 = rgb32to15_c;
00905 rgb32tobgr24 = rgb32tobgr24_c;
00906 rgb24to15 = rgb24to15_c;
00907 rgb24to16 = rgb24to16_c;
00908 rgb24tobgr24 = rgb24tobgr24_c;
00909 shuffle_bytes_2103 = shuffle_bytes_2103_c;
00910 rgb32tobgr16 = rgb32tobgr16_c;
00911 rgb32tobgr15 = rgb32tobgr15_c;
00912 yv12toyuy2 = yv12toyuy2_c;
00913 yv12touyvy = yv12touyvy_c;
00914 yuv422ptoyuy2 = yuv422ptoyuy2_c;
00915 yuv422ptouyvy = yuv422ptouyvy_c;
00916 yuy2toyv12 = yuy2toyv12_c;
00917 planar2x = planar2x_c;
00918 rgb24toyv12 = rgb24toyv12_c;
00919 interleaveBytes = interleaveBytes_c;
00920 vu9_to_vu12 = vu9_to_vu12_c;
00921 yvu9_to_yuy2 = yvu9_to_yuy2_c;
00922
00923 uyvytoyuv420 = uyvytoyuv420_c;
00924 uyvytoyuv422 = uyvytoyuv422_c;
00925 yuyvtoyuv420 = yuyvtoyuv420_c;
00926 yuyvtoyuv422 = yuyvtoyuv422_c;
00927 }