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