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 static inline void rgb15tobgr24_c(const uint8_t *src, uint8_t *dst, int src_size)
00231 {
00232 const uint16_t *end;
00233 uint8_t *d = dst;
00234 const uint16_t *s = (const uint16_t*)src;
00235 end = s + src_size/2;
00236 while (s < end) {
00237 register uint16_t bgr;
00238 bgr = *s++;
00239 *d++ = ((bgr&0x1F)<<3) | ((bgr&0x1F)>>2);
00240 *d++ = ((bgr&0x3E0)>>2) | ((bgr&0x3E0)>>7);
00241 *d++ = ((bgr&0x7C00)>>7) | ((bgr&0x7C00)>>12);
00242 }
00243 }
00244
00245 static inline void rgb16tobgr24_c(const uint8_t *src, uint8_t *dst, int src_size)
00246 {
00247 const uint16_t *end;
00248 uint8_t *d = (uint8_t *)dst;
00249 const uint16_t *s = (const uint16_t *)src;
00250 end = s + src_size/2;
00251 while (s < end) {
00252 register uint16_t bgr;
00253 bgr = *s++;
00254 *d++ = ((bgr&0x1F)<<3) | ((bgr&0x1F)>>2);
00255 *d++ = ((bgr&0x7E0)>>3) | ((bgr&0x7E0)>>9);
00256 *d++ = ((bgr&0xF800)>>8) | ((bgr&0xF800)>>13);
00257 }
00258 }
00259
00260 static inline void rgb15to32_c(const uint8_t *src, uint8_t *dst, int src_size)
00261 {
00262 const uint16_t *end;
00263 uint8_t *d = dst;
00264 const uint16_t *s = (const uint16_t *)src;
00265 end = s + src_size/2;
00266 while (s < end) {
00267 register uint16_t bgr;
00268 bgr = *s++;
00269 #if HAVE_BIGENDIAN
00270 *d++ = 255;
00271 *d++ = ((bgr&0x7C00)>>7) | ((bgr&0x7C00)>>12);
00272 *d++ = ((bgr&0x3E0)>>2) | ((bgr&0x3E0)>>7);
00273 *d++ = ((bgr&0x1F)<<3) | ((bgr&0x1F)>>2);
00274 #else
00275 *d++ = ((bgr&0x1F)<<3) | ((bgr&0x1F)>>2);
00276 *d++ = ((bgr&0x3E0)>>2) | ((bgr&0x3E0)>>7);
00277 *d++ = ((bgr&0x7C00)>>7) | ((bgr&0x7C00)>>12);
00278 *d++ = 255;
00279 #endif
00280 }
00281 }
00282
00283 static inline void rgb16to32_c(const uint8_t *src, uint8_t *dst, int src_size)
00284 {
00285 const uint16_t *end;
00286 uint8_t *d = dst;
00287 const uint16_t *s = (const uint16_t*)src;
00288 end = s + src_size/2;
00289 while (s < end) {
00290 register uint16_t bgr;
00291 bgr = *s++;
00292 #if HAVE_BIGENDIAN
00293 *d++ = 255;
00294 *d++ = ((bgr&0xF800)>>8) | ((bgr&0xF800)>>13);
00295 *d++ = ((bgr&0x7E0)>>3) | ((bgr&0x7E0)>>9);
00296 *d++ = ((bgr&0x1F)<<3) | ((bgr&0x1F)>>2);
00297 #else
00298 *d++ = ((bgr&0x1F)<<3) | ((bgr&0x1F)>>2);
00299 *d++ = ((bgr&0x7E0)>>3) | ((bgr&0x7E0)>>9);
00300 *d++ = ((bgr&0xF800)>>8) | ((bgr&0xF800)>>13);
00301 *d++ = 255;
00302 #endif
00303 }
00304 }
00305
00306 static inline void shuffle_bytes_2103_c(const uint8_t *src, uint8_t *dst, int src_size)
00307 {
00308 int idx = 15 - src_size;
00309 const uint8_t *s = src-idx;
00310 uint8_t *d = dst-idx;
00311 for (; idx<15; idx+=4) {
00312 register int v = *(const uint32_t *)&s[idx], g = v & 0xff00ff00;
00313 v &= 0xff00ff;
00314 *(uint32_t *)&d[idx] = (v>>16) + g + (v<<16);
00315 }
00316 }
00317
00318 static inline void rgb24tobgr24_c(const uint8_t *src, uint8_t *dst, int src_size)
00319 {
00320 unsigned i;
00321 for (i=0; i<src_size; i+=3) {
00322 register uint8_t x;
00323 x = src[i + 2];
00324 dst[i + 1] = src[i + 1];
00325 dst[i + 2] = src[i + 0];
00326 dst[i + 0] = x;
00327 }
00328 }
00329
00330 static inline void yuvPlanartoyuy2_c(const uint8_t *ysrc, const uint8_t *usrc,
00331 const uint8_t *vsrc, uint8_t *dst,
00332 int width, int height,
00333 int lumStride, int chromStride,
00334 int dstStride, int vertLumPerChroma)
00335 {
00336 int y;
00337 const int chromWidth = width >> 1;
00338 for (y=0; y<height; y++) {
00339 #if HAVE_FAST_64BIT
00340 int i;
00341 uint64_t *ldst = (uint64_t *) dst;
00342 const uint8_t *yc = ysrc, *uc = usrc, *vc = vsrc;
00343 for (i = 0; i < chromWidth; i += 2) {
00344 uint64_t k, l;
00345 k = yc[0] + (uc[0] << 8) +
00346 (yc[1] << 16) + (vc[0] << 24);
00347 l = yc[2] + (uc[1] << 8) +
00348 (yc[3] << 16) + (vc[1] << 24);
00349 *ldst++ = k + (l << 32);
00350 yc += 4;
00351 uc += 2;
00352 vc += 2;
00353 }
00354
00355 #else
00356 int i, *idst = (int32_t *) dst;
00357 const uint8_t *yc = ysrc, *uc = usrc, *vc = vsrc;
00358 for (i = 0; i < chromWidth; i++) {
00359 #if HAVE_BIGENDIAN
00360 *idst++ = (yc[0] << 24)+ (uc[0] << 16) +
00361 (yc[1] << 8) + (vc[0] << 0);
00362 #else
00363 *idst++ = yc[0] + (uc[0] << 8) +
00364 (yc[1] << 16) + (vc[0] << 24);
00365 #endif
00366 yc += 2;
00367 uc++;
00368 vc++;
00369 }
00370 #endif
00371 if ((y&(vertLumPerChroma-1)) == vertLumPerChroma-1) {
00372 usrc += chromStride;
00373 vsrc += chromStride;
00374 }
00375 ysrc += lumStride;
00376 dst += dstStride;
00377 }
00378 }
00379
00384 static inline void yv12toyuy2_c(const uint8_t *ysrc, const uint8_t *usrc,
00385 const uint8_t *vsrc, uint8_t *dst,
00386 int width, int height,
00387 int lumStride, int chromStride,
00388 int dstStride)
00389 {
00390
00391 yuvPlanartoyuy2_c(ysrc, usrc, vsrc, dst, width, height, lumStride,
00392 chromStride, dstStride, 2);
00393 }
00394
00395 static inline void yuvPlanartouyvy_c(const uint8_t *ysrc, const uint8_t *usrc,
00396 const uint8_t *vsrc, uint8_t *dst,
00397 int width, int height,
00398 int lumStride, int chromStride,
00399 int dstStride, int vertLumPerChroma)
00400 {
00401 int y;
00402 const int chromWidth = width >> 1;
00403 for (y=0; y<height; y++) {
00404 #if HAVE_FAST_64BIT
00405 int i;
00406 uint64_t *ldst = (uint64_t *) dst;
00407 const uint8_t *yc = ysrc, *uc = usrc, *vc = vsrc;
00408 for (i = 0; i < chromWidth; i += 2) {
00409 uint64_t k, l;
00410 k = uc[0] + (yc[0] << 8) +
00411 (vc[0] << 16) + (yc[1] << 24);
00412 l = uc[1] + (yc[2] << 8) +
00413 (vc[1] << 16) + (yc[3] << 24);
00414 *ldst++ = k + (l << 32);
00415 yc += 4;
00416 uc += 2;
00417 vc += 2;
00418 }
00419
00420 #else
00421 int i, *idst = (int32_t *) dst;
00422 const uint8_t *yc = ysrc, *uc = usrc, *vc = vsrc;
00423 for (i = 0; i < chromWidth; i++) {
00424 #if HAVE_BIGENDIAN
00425 *idst++ = (uc[0] << 24)+ (yc[0] << 16) +
00426 (vc[0] << 8) + (yc[1] << 0);
00427 #else
00428 *idst++ = uc[0] + (yc[0] << 8) +
00429 (vc[0] << 16) + (yc[1] << 24);
00430 #endif
00431 yc += 2;
00432 uc++;
00433 vc++;
00434 }
00435 #endif
00436 if ((y&(vertLumPerChroma-1)) == vertLumPerChroma-1) {
00437 usrc += chromStride;
00438 vsrc += chromStride;
00439 }
00440 ysrc += lumStride;
00441 dst += dstStride;
00442 }
00443 }
00444
00449 static inline void yv12touyvy_c(const uint8_t *ysrc, const uint8_t *usrc,
00450 const uint8_t *vsrc, uint8_t *dst,
00451 int width, int height,
00452 int lumStride, int chromStride,
00453 int dstStride)
00454 {
00455
00456 yuvPlanartouyvy_c(ysrc, usrc, vsrc, dst, width, height, lumStride,
00457 chromStride, dstStride, 2);
00458 }
00459
00463 static inline void yuv422ptouyvy_c(const uint8_t *ysrc, const uint8_t *usrc,
00464 const uint8_t *vsrc, uint8_t *dst,
00465 int width, int height,
00466 int lumStride, int chromStride,
00467 int dstStride)
00468 {
00469 yuvPlanartouyvy_c(ysrc, usrc, vsrc, dst, width, height, lumStride,
00470 chromStride, dstStride, 1);
00471 }
00472
00476 static inline void yuv422ptoyuy2_c(const uint8_t *ysrc, const uint8_t *usrc,
00477 const uint8_t *vsrc, uint8_t *dst,
00478 int width, int height,
00479 int lumStride, int chromStride,
00480 int dstStride)
00481 {
00482 yuvPlanartoyuy2_c(ysrc, usrc, vsrc, dst, width, height, lumStride,
00483 chromStride, dstStride, 1);
00484 }
00485
00490 static inline void yuy2toyv12_c(const uint8_t *src, uint8_t *ydst,
00491 uint8_t *udst, uint8_t *vdst,
00492 int width, int height,
00493 int lumStride, int chromStride,
00494 int srcStride)
00495 {
00496 int y;
00497 const int chromWidth = width >> 1;
00498 for (y=0; y<height; y+=2) {
00499 int i;
00500 for (i=0; i<chromWidth; i++) {
00501 ydst[2*i+0] = src[4*i+0];
00502 udst[i] = src[4*i+1];
00503 ydst[2*i+1] = src[4*i+2];
00504 vdst[i] = src[4*i+3];
00505 }
00506 ydst += lumStride;
00507 src += srcStride;
00508
00509 for (i=0; i<chromWidth; i++) {
00510 ydst[2*i+0] = src[4*i+0];
00511 ydst[2*i+1] = src[4*i+2];
00512 }
00513 udst += chromStride;
00514 vdst += chromStride;
00515 ydst += lumStride;
00516 src += srcStride;
00517 }
00518 }
00519
00520 static inline void planar2x_c(const uint8_t *src, uint8_t *dst, int srcWidth,
00521 int srcHeight, int srcStride, int dstStride)
00522 {
00523 int x,y;
00524
00525 dst[0]= src[0];
00526
00527
00528 for (x=0; x<srcWidth-1; x++) {
00529 dst[2*x+1]= (3*src[x] + src[x+1])>>2;
00530 dst[2*x+2]= ( src[x] + 3*src[x+1])>>2;
00531 }
00532 dst[2*srcWidth-1]= src[srcWidth-1];
00533
00534 dst+= dstStride;
00535
00536 for (y=1; y<srcHeight; y++) {
00537 const int mmxSize = 1;
00538
00539 dst[0 ]= (3*src[0] + src[srcStride])>>2;
00540 dst[dstStride]= ( src[0] + 3*src[srcStride])>>2;
00541
00542 for (x=mmxSize-1; x<srcWidth-1; x++) {
00543 dst[2*x +1]= (3*src[x+0] + src[x+srcStride+1])>>2;
00544 dst[2*x+dstStride+2]= ( src[x+0] + 3*src[x+srcStride+1])>>2;
00545 dst[2*x+dstStride+1]= ( src[x+1] + 3*src[x+srcStride ])>>2;
00546 dst[2*x +2]= (3*src[x+1] + src[x+srcStride ])>>2;
00547 }
00548 dst[srcWidth*2 -1 ]= (3*src[srcWidth-1] + src[srcWidth-1 + srcStride])>>2;
00549 dst[srcWidth*2 -1 + dstStride]= ( src[srcWidth-1] + 3*src[srcWidth-1 + srcStride])>>2;
00550
00551 dst+=dstStride*2;
00552 src+=srcStride;
00553 }
00554
00555
00556 dst[0]= src[0];
00557
00558 for (x=0; x<srcWidth-1; x++) {
00559 dst[2*x+1]= (3*src[x] + src[x+1])>>2;
00560 dst[2*x+2]= ( src[x] + 3*src[x+1])>>2;
00561 }
00562 dst[2*srcWidth-1]= src[srcWidth-1];
00563 }
00564
00571 static inline void uyvytoyv12_c(const uint8_t *src, uint8_t *ydst,
00572 uint8_t *udst, uint8_t *vdst,
00573 int width, int height,
00574 int lumStride, int chromStride,
00575 int srcStride)
00576 {
00577 int y;
00578 const int chromWidth = width >> 1;
00579 for (y=0; y<height; y+=2) {
00580 int i;
00581 for (i=0; i<chromWidth; i++) {
00582 udst[i] = src[4*i+0];
00583 ydst[2*i+0] = src[4*i+1];
00584 vdst[i] = src[4*i+2];
00585 ydst[2*i+1] = src[4*i+3];
00586 }
00587 ydst += lumStride;
00588 src += srcStride;
00589
00590 for (i=0; i<chromWidth; i++) {
00591 ydst[2*i+0] = src[4*i+1];
00592 ydst[2*i+1] = src[4*i+3];
00593 }
00594 udst += chromStride;
00595 vdst += chromStride;
00596 ydst += lumStride;
00597 src += srcStride;
00598 }
00599 }
00600
00608 void rgb24toyv12_c(const uint8_t *src, uint8_t *ydst, uint8_t *udst,
00609 uint8_t *vdst, int width, int height, int lumStride,
00610 int chromStride, int srcStride)
00611 {
00612 int y;
00613 const int chromWidth = width >> 1;
00614 y=0;
00615 for (; y<height; y+=2) {
00616 int i;
00617 for (i=0; i<chromWidth; i++) {
00618 unsigned int b = src[6*i+0];
00619 unsigned int g = src[6*i+1];
00620 unsigned int r = src[6*i+2];
00621
00622 unsigned int Y = ((RY*r + GY*g + BY*b)>>RGB2YUV_SHIFT) + 16;
00623 unsigned int V = ((RV*r + GV*g + BV*b)>>RGB2YUV_SHIFT) + 128;
00624 unsigned int U = ((RU*r + GU*g + BU*b)>>RGB2YUV_SHIFT) + 128;
00625
00626 udst[i] = U;
00627 vdst[i] = V;
00628 ydst[2*i] = Y;
00629
00630 b = src[6*i+3];
00631 g = src[6*i+4];
00632 r = src[6*i+5];
00633
00634 Y = ((RY*r + GY*g + BY*b)>>RGB2YUV_SHIFT) + 16;
00635 ydst[2*i+1] = Y;
00636 }
00637 ydst += lumStride;
00638 src += srcStride;
00639
00640 if(y+1 == height)
00641 break;
00642
00643 for (i=0; i<chromWidth; i++) {
00644 unsigned int b = src[6*i+0];
00645 unsigned int g = src[6*i+1];
00646 unsigned int r = src[6*i+2];
00647
00648 unsigned int Y = ((RY*r + GY*g + BY*b)>>RGB2YUV_SHIFT) + 16;
00649
00650 ydst[2*i] = Y;
00651
00652 b = src[6*i+3];
00653 g = src[6*i+4];
00654 r = src[6*i+5];
00655
00656 Y = ((RY*r + GY*g + BY*b)>>RGB2YUV_SHIFT) + 16;
00657 ydst[2*i+1] = Y;
00658 }
00659 udst += chromStride;
00660 vdst += chromStride;
00661 ydst += lumStride;
00662 src += srcStride;
00663 }
00664 }
00665
00666 static void interleaveBytes_c(const uint8_t *src1, const uint8_t *src2,
00667 uint8_t *dest, int width,
00668 int height, int src1Stride,
00669 int src2Stride, int dstStride)
00670 {
00671 int h;
00672
00673 for (h=0; h < height; h++) {
00674 int w;
00675 for (w=0; w < width; w++) {
00676 dest[2*w+0] = src1[w];
00677 dest[2*w+1] = src2[w];
00678 }
00679 dest += dstStride;
00680 src1 += src1Stride;
00681 src2 += src2Stride;
00682 }
00683 }
00684
00685 static inline void vu9_to_vu12_c(const uint8_t *src1, const uint8_t *src2,
00686 uint8_t *dst1, uint8_t *dst2,
00687 int width, int height,
00688 int srcStride1, int srcStride2,
00689 int dstStride1, int dstStride2)
00690 {
00691 int y;
00692 int x,w,h;
00693 w=width/2; h=height/2;
00694 for (y=0;y<h;y++) {
00695 const uint8_t* s1=src1+srcStride1*(y>>1);
00696 uint8_t* d=dst1+dstStride1*y;
00697 x=0;
00698 for (;x<w;x++) d[2*x]=d[2*x+1]=s1[x];
00699 }
00700 for (y=0;y<h;y++) {
00701 const uint8_t* s2=src2+srcStride2*(y>>1);
00702 uint8_t* d=dst2+dstStride2*y;
00703 x=0;
00704 for (;x<w;x++) d[2*x]=d[2*x+1]=s2[x];
00705 }
00706 }
00707
00708 static inline void yvu9_to_yuy2_c(const uint8_t *src1, const uint8_t *src2,
00709 const uint8_t *src3, uint8_t *dst,
00710 int width, int height,
00711 int srcStride1, int srcStride2,
00712 int srcStride3, int dstStride)
00713 {
00714 int x;
00715 int y,w,h;
00716 w=width/2; h=height;
00717 for (y=0;y<h;y++) {
00718 const uint8_t* yp=src1+srcStride1*y;
00719 const uint8_t* up=src2+srcStride2*(y>>2);
00720 const uint8_t* vp=src3+srcStride3*(y>>2);
00721 uint8_t* d=dst+dstStride*y;
00722 x=0;
00723 for (; x<w; x++) {
00724 const int x2 = x<<2;
00725 d[8*x+0] = yp[x2];
00726 d[8*x+1] = up[x];
00727 d[8*x+2] = yp[x2+1];
00728 d[8*x+3] = vp[x];
00729 d[8*x+4] = yp[x2+2];
00730 d[8*x+5] = up[x];
00731 d[8*x+6] = yp[x2+3];
00732 d[8*x+7] = vp[x];
00733 }
00734 }
00735 }
00736
00737 static void extract_even_c(const uint8_t *src, uint8_t *dst, int count)
00738 {
00739 dst += count;
00740 src += 2*count;
00741 count= - count;
00742
00743 while(count<0) {
00744 dst[count]= src[2*count];
00745 count++;
00746 }
00747 }
00748
00749 static void extract_even2_c(const uint8_t *src, uint8_t *dst0, uint8_t *dst1,
00750 int count)
00751 {
00752 dst0+= count;
00753 dst1+= count;
00754 src += 4*count;
00755 count= - count;
00756 while(count<0) {
00757 dst0[count]= src[4*count+0];
00758 dst1[count]= src[4*count+2];
00759 count++;
00760 }
00761 }
00762
00763 static void extract_even2avg_c(const uint8_t *src0, const uint8_t *src1,
00764 uint8_t *dst0, uint8_t *dst1, int count)
00765 {
00766 dst0 += count;
00767 dst1 += count;
00768 src0 += 4*count;
00769 src1 += 4*count;
00770 count= - count;
00771 while(count<0) {
00772 dst0[count]= (src0[4*count+0]+src1[4*count+0])>>1;
00773 dst1[count]= (src0[4*count+2]+src1[4*count+2])>>1;
00774 count++;
00775 }
00776 }
00777
00778 static void extract_odd2_c(const uint8_t *src, uint8_t *dst0, uint8_t *dst1,
00779 int count)
00780 {
00781 dst0+= count;
00782 dst1+= count;
00783 src += 4*count;
00784 count= - count;
00785 src++;
00786 while(count<0) {
00787 dst0[count]= src[4*count+0];
00788 dst1[count]= src[4*count+2];
00789 count++;
00790 }
00791 }
00792
00793 static void extract_odd2avg_c(const uint8_t *src0, const uint8_t *src1,
00794 uint8_t *dst0, uint8_t *dst1, int count)
00795 {
00796 dst0 += count;
00797 dst1 += count;
00798 src0 += 4*count;
00799 src1 += 4*count;
00800 count= - count;
00801 src0++;
00802 src1++;
00803 while(count<0) {
00804 dst0[count]= (src0[4*count+0]+src1[4*count+0])>>1;
00805 dst1[count]= (src0[4*count+2]+src1[4*count+2])>>1;
00806 count++;
00807 }
00808 }
00809
00810 static void yuyvtoyuv420_c(uint8_t *ydst, uint8_t *udst, uint8_t *vdst,
00811 const uint8_t *src, int width, int height,
00812 int lumStride, int chromStride, int srcStride)
00813 {
00814 int y;
00815 const int chromWidth= -((-width)>>1);
00816
00817 for (y=0; y<height; y++) {
00818 extract_even_c(src, ydst, width);
00819 if(y&1) {
00820 extract_odd2avg_c(src - srcStride, src, udst, vdst, chromWidth);
00821 udst+= chromStride;
00822 vdst+= chromStride;
00823 }
00824
00825 src += srcStride;
00826 ydst+= lumStride;
00827 }
00828 }
00829
00830 static void yuyvtoyuv422_c(uint8_t *ydst, uint8_t *udst, uint8_t *vdst,
00831 const uint8_t *src, int width, int height,
00832 int lumStride, int chromStride, int srcStride)
00833 {
00834 int y;
00835 const int chromWidth= -((-width)>>1);
00836
00837 for (y=0; y<height; y++) {
00838 extract_even_c(src, ydst, width);
00839 extract_odd2_c(src, udst, vdst, chromWidth);
00840
00841 src += srcStride;
00842 ydst+= lumStride;
00843 udst+= chromStride;
00844 vdst+= chromStride;
00845 }
00846 }
00847
00848 static void uyvytoyuv420_c(uint8_t *ydst, uint8_t *udst, uint8_t *vdst,
00849 const uint8_t *src, int width, int height,
00850 int lumStride, int chromStride, int srcStride)
00851 {
00852 int y;
00853 const int chromWidth= -((-width)>>1);
00854
00855 for (y=0; y<height; y++) {
00856 extract_even_c(src + 1, ydst, width);
00857 if(y&1) {
00858 extract_even2avg_c(src - srcStride, src, udst, vdst, chromWidth);
00859 udst+= chromStride;
00860 vdst+= chromStride;
00861 }
00862
00863 src += srcStride;
00864 ydst+= lumStride;
00865 }
00866 }
00867
00868 static void uyvytoyuv422_c(uint8_t *ydst, uint8_t *udst, uint8_t *vdst,
00869 const uint8_t *src, int width, int height,
00870 int lumStride, int chromStride, int srcStride)
00871 {
00872 int y;
00873 const int chromWidth= -((-width)>>1);
00874
00875 for (y=0; y<height; y++) {
00876 extract_even_c(src + 1, ydst, width);
00877 extract_even2_c(src, udst, vdst, chromWidth);
00878
00879 src += srcStride;
00880 ydst+= lumStride;
00881 udst+= chromStride;
00882 vdst+= chromStride;
00883 }
00884 }
00885
00886 static inline void rgb2rgb_init_c(void)
00887 {
00888 rgb15to16 = rgb15to16_c;
00889 rgb15tobgr24 = rgb15tobgr24_c;
00890 rgb15to32 = rgb15to32_c;
00891 rgb16tobgr24 = rgb16tobgr24_c;
00892 rgb16to32 = rgb16to32_c;
00893 rgb16to15 = rgb16to15_c;
00894 rgb24tobgr16 = rgb24tobgr16_c;
00895 rgb24tobgr15 = rgb24tobgr15_c;
00896 rgb24tobgr32 = rgb24tobgr32_c;
00897 rgb32to16 = rgb32to16_c;
00898 rgb32to15 = rgb32to15_c;
00899 rgb32tobgr24 = rgb32tobgr24_c;
00900 rgb24to15 = rgb24to15_c;
00901 rgb24to16 = rgb24to16_c;
00902 rgb24tobgr24 = rgb24tobgr24_c;
00903 shuffle_bytes_2103 = shuffle_bytes_2103_c;
00904 rgb32tobgr16 = rgb32tobgr16_c;
00905 rgb32tobgr15 = rgb32tobgr15_c;
00906 yv12toyuy2 = yv12toyuy2_c;
00907 yv12touyvy = yv12touyvy_c;
00908 yuv422ptoyuy2 = yuv422ptoyuy2_c;
00909 yuv422ptouyvy = yuv422ptouyvy_c;
00910 yuy2toyv12 = yuy2toyv12_c;
00911 planar2x = planar2x_c;
00912 rgb24toyv12 = rgb24toyv12_c;
00913 interleaveBytes = interleaveBytes_c;
00914 vu9_to_vu12 = vu9_to_vu12_c;
00915 yvu9_to_yuy2 = yvu9_to_yuy2_c;
00916
00917 uyvytoyuv420 = uyvytoyuv420_c;
00918 uyvytoyuv422 = uyvytoyuv422_c;
00919 yuyvtoyuv420 = yuyvtoyuv420_c;
00920 yuyvtoyuv422 = yuyvtoyuv422_c;
00921 }