00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef RGB_OUT
00023 #define RGB_OUT(d, r, g, b) RGBA_OUT(d, r, g, b, 0xff)
00024 #endif
00025
00026 static void glue(yuv420p_to_, RGB_NAME)(AVPicture *dst, const AVPicture *src,
00027 int width, int height)
00028 {
00029 const uint8_t *y1_ptr, *y2_ptr, *cb_ptr, *cr_ptr;
00030 uint8_t *d, *d1, *d2;
00031 int w, y, cb, cr, r_add, g_add, b_add, width2;
00032 uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
00033 unsigned int r, g, b;
00034
00035 d = dst->data[0];
00036 y1_ptr = src->data[0];
00037 cb_ptr = src->data[1];
00038 cr_ptr = src->data[2];
00039 width2 = (width + 1) >> 1;
00040 for(;height >= 2; height -= 2) {
00041 d1 = d;
00042 d2 = d + dst->linesize[0];
00043 y2_ptr = y1_ptr + src->linesize[0];
00044 for(w = width; w >= 2; w -= 2) {
00045 YUV_TO_RGB1_CCIR(cb_ptr[0], cr_ptr[0]);
00046
00047 YUV_TO_RGB2_CCIR(r, g, b, y1_ptr[0]);
00048 RGB_OUT(d1, r, g, b);
00049
00050 YUV_TO_RGB2_CCIR(r, g, b, y1_ptr[1]);
00051 RGB_OUT(d1 + BPP, r, g, b);
00052
00053 YUV_TO_RGB2_CCIR(r, g, b, y2_ptr[0]);
00054 RGB_OUT(d2, r, g, b);
00055
00056 YUV_TO_RGB2_CCIR(r, g, b, y2_ptr[1]);
00057 RGB_OUT(d2 + BPP, r, g, b);
00058
00059 d1 += 2 * BPP;
00060 d2 += 2 * BPP;
00061
00062 y1_ptr += 2;
00063 y2_ptr += 2;
00064 cb_ptr++;
00065 cr_ptr++;
00066 }
00067
00068 if (w) {
00069 YUV_TO_RGB1_CCIR(cb_ptr[0], cr_ptr[0]);
00070 YUV_TO_RGB2_CCIR(r, g, b, y1_ptr[0]);
00071 RGB_OUT(d1, r, g, b);
00072
00073 YUV_TO_RGB2_CCIR(r, g, b, y2_ptr[0]);
00074 RGB_OUT(d2, r, g, b);
00075 d1 += BPP;
00076 d2 += BPP;
00077 y1_ptr++;
00078 y2_ptr++;
00079 cb_ptr++;
00080 cr_ptr++;
00081 }
00082 d += 2 * dst->linesize[0];
00083 y1_ptr += 2 * src->linesize[0] - width;
00084 cb_ptr += src->linesize[1] - width2;
00085 cr_ptr += src->linesize[2] - width2;
00086 }
00087
00088 if (height) {
00089 d1 = d;
00090 for(w = width; w >= 2; w -= 2) {
00091 YUV_TO_RGB1_CCIR(cb_ptr[0], cr_ptr[0]);
00092
00093 YUV_TO_RGB2_CCIR(r, g, b, y1_ptr[0]);
00094 RGB_OUT(d1, r, g, b);
00095
00096 YUV_TO_RGB2_CCIR(r, g, b, y1_ptr[1]);
00097 RGB_OUT(d1 + BPP, r, g, b);
00098
00099 d1 += 2 * BPP;
00100
00101 y1_ptr += 2;
00102 cb_ptr++;
00103 cr_ptr++;
00104 }
00105
00106 if (w) {
00107 YUV_TO_RGB1_CCIR(cb_ptr[0], cr_ptr[0]);
00108
00109 YUV_TO_RGB2_CCIR(r, g, b, y1_ptr[0]);
00110 RGB_OUT(d1, r, g, b);
00111 d1 += BPP;
00112
00113 y1_ptr++;
00114 cb_ptr++;
00115 cr_ptr++;
00116 }
00117 }
00118 }
00119
00120 static void glue(yuvj420p_to_, RGB_NAME)(AVPicture *dst, const AVPicture *src,
00121 int width, int height)
00122 {
00123 const uint8_t *y1_ptr, *y2_ptr, *cb_ptr, *cr_ptr;
00124 uint8_t *d, *d1, *d2;
00125 int w, y, cb, cr, r_add, g_add, b_add, width2;
00126 uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
00127 unsigned int r, g, b;
00128
00129 d = dst->data[0];
00130 y1_ptr = src->data[0];
00131 cb_ptr = src->data[1];
00132 cr_ptr = src->data[2];
00133 width2 = (width + 1) >> 1;
00134 for(;height >= 2; height -= 2) {
00135 d1 = d;
00136 d2 = d + dst->linesize[0];
00137 y2_ptr = y1_ptr + src->linesize[0];
00138 for(w = width; w >= 2; w -= 2) {
00139 YUV_TO_RGB1(cb_ptr[0], cr_ptr[0]);
00140
00141 YUV_TO_RGB2(r, g, b, y1_ptr[0]);
00142 RGB_OUT(d1, r, g, b);
00143
00144 YUV_TO_RGB2(r, g, b, y1_ptr[1]);
00145 RGB_OUT(d1 + BPP, r, g, b);
00146
00147 YUV_TO_RGB2(r, g, b, y2_ptr[0]);
00148 RGB_OUT(d2, r, g, b);
00149
00150 YUV_TO_RGB2(r, g, b, y2_ptr[1]);
00151 RGB_OUT(d2 + BPP, r, g, b);
00152
00153 d1 += 2 * BPP;
00154 d2 += 2 * BPP;
00155
00156 y1_ptr += 2;
00157 y2_ptr += 2;
00158 cb_ptr++;
00159 cr_ptr++;
00160 }
00161
00162 if (w) {
00163 YUV_TO_RGB1(cb_ptr[0], cr_ptr[0]);
00164 YUV_TO_RGB2(r, g, b, y1_ptr[0]);
00165 RGB_OUT(d1, r, g, b);
00166
00167 YUV_TO_RGB2(r, g, b, y2_ptr[0]);
00168 RGB_OUT(d2, r, g, b);
00169 d1 += BPP;
00170 d2 += BPP;
00171 y1_ptr++;
00172 y2_ptr++;
00173 cb_ptr++;
00174 cr_ptr++;
00175 }
00176 d += 2 * dst->linesize[0];
00177 y1_ptr += 2 * src->linesize[0] - width;
00178 cb_ptr += src->linesize[1] - width2;
00179 cr_ptr += src->linesize[2] - width2;
00180 }
00181
00182 if (height) {
00183 d1 = d;
00184 for(w = width; w >= 2; w -= 2) {
00185 YUV_TO_RGB1(cb_ptr[0], cr_ptr[0]);
00186
00187 YUV_TO_RGB2(r, g, b, y1_ptr[0]);
00188 RGB_OUT(d1, r, g, b);
00189
00190 YUV_TO_RGB2(r, g, b, y1_ptr[1]);
00191 RGB_OUT(d1 + BPP, r, g, b);
00192
00193 d1 += 2 * BPP;
00194
00195 y1_ptr += 2;
00196 cb_ptr++;
00197 cr_ptr++;
00198 }
00199
00200 if (w) {
00201 YUV_TO_RGB1(cb_ptr[0], cr_ptr[0]);
00202
00203 YUV_TO_RGB2(r, g, b, y1_ptr[0]);
00204 RGB_OUT(d1, r, g, b);
00205 d1 += BPP;
00206
00207 y1_ptr++;
00208 cb_ptr++;
00209 cr_ptr++;
00210 }
00211 }
00212 }
00213
00214 static void glue(RGB_NAME, _to_yuv420p)(AVPicture *dst, const AVPicture *src,
00215 int width, int height)
00216 {
00217 int wrap, wrap3, width2;
00218 int r, g, b, r1, g1, b1, w;
00219 uint8_t *lum, *cb, *cr;
00220 const uint8_t *p;
00221
00222 lum = dst->data[0];
00223 cb = dst->data[1];
00224 cr = dst->data[2];
00225
00226 width2 = (width + 1) >> 1;
00227 wrap = dst->linesize[0];
00228 wrap3 = src->linesize[0];
00229 p = src->data[0];
00230 for(;height>=2;height -= 2) {
00231 for(w = width; w >= 2; w -= 2) {
00232 RGB_IN(r, g, b, p);
00233 r1 = r;
00234 g1 = g;
00235 b1 = b;
00236 lum[0] = RGB_TO_Y_CCIR(r, g, b);
00237
00238 RGB_IN(r, g, b, p + BPP);
00239 r1 += r;
00240 g1 += g;
00241 b1 += b;
00242 lum[1] = RGB_TO_Y_CCIR(r, g, b);
00243 p += wrap3;
00244 lum += wrap;
00245
00246 RGB_IN(r, g, b, p);
00247 r1 += r;
00248 g1 += g;
00249 b1 += b;
00250 lum[0] = RGB_TO_Y_CCIR(r, g, b);
00251
00252 RGB_IN(r, g, b, p + BPP);
00253 r1 += r;
00254 g1 += g;
00255 b1 += b;
00256 lum[1] = RGB_TO_Y_CCIR(r, g, b);
00257
00258 cb[0] = RGB_TO_U_CCIR(r1, g1, b1, 2);
00259 cr[0] = RGB_TO_V_CCIR(r1, g1, b1, 2);
00260
00261 cb++;
00262 cr++;
00263 p += -wrap3 + 2 * BPP;
00264 lum += -wrap + 2;
00265 }
00266 if (w) {
00267 RGB_IN(r, g, b, p);
00268 r1 = r;
00269 g1 = g;
00270 b1 = b;
00271 lum[0] = RGB_TO_Y_CCIR(r, g, b);
00272 p += wrap3;
00273 lum += wrap;
00274 RGB_IN(r, g, b, p);
00275 r1 += r;
00276 g1 += g;
00277 b1 += b;
00278 lum[0] = RGB_TO_Y_CCIR(r, g, b);
00279 cb[0] = RGB_TO_U_CCIR(r1, g1, b1, 1);
00280 cr[0] = RGB_TO_V_CCIR(r1, g1, b1, 1);
00281 cb++;
00282 cr++;
00283 p += -wrap3 + BPP;
00284 lum += -wrap + 1;
00285 }
00286 p += wrap3 + (wrap3 - width * BPP);
00287 lum += wrap + (wrap - width);
00288 cb += dst->linesize[1] - width2;
00289 cr += dst->linesize[2] - width2;
00290 }
00291
00292 if (height) {
00293 for(w = width; w >= 2; w -= 2) {
00294 RGB_IN(r, g, b, p);
00295 r1 = r;
00296 g1 = g;
00297 b1 = b;
00298 lum[0] = RGB_TO_Y_CCIR(r, g, b);
00299
00300 RGB_IN(r, g, b, p + BPP);
00301 r1 += r;
00302 g1 += g;
00303 b1 += b;
00304 lum[1] = RGB_TO_Y_CCIR(r, g, b);
00305 cb[0] = RGB_TO_U_CCIR(r1, g1, b1, 1);
00306 cr[0] = RGB_TO_V_CCIR(r1, g1, b1, 1);
00307 cb++;
00308 cr++;
00309 p += 2 * BPP;
00310 lum += 2;
00311 }
00312 if (w) {
00313 RGB_IN(r, g, b, p);
00314 lum[0] = RGB_TO_Y_CCIR(r, g, b);
00315 cb[0] = RGB_TO_U_CCIR(r, g, b, 0);
00316 cr[0] = RGB_TO_V_CCIR(r, g, b, 0);
00317 }
00318 }
00319 }
00320
00321 static void glue(RGB_NAME, _to_gray)(AVPicture *dst, const AVPicture *src,
00322 int width, int height)
00323 {
00324 const unsigned char *p;
00325 unsigned char *q;
00326 int r, g, b, dst_wrap, src_wrap;
00327 int x, y;
00328
00329 p = src->data[0];
00330 src_wrap = src->linesize[0] - BPP * width;
00331
00332 q = dst->data[0];
00333 dst_wrap = dst->linesize[0] - width;
00334
00335 for(y=0;y<height;y++) {
00336 for(x=0;x<width;x++) {
00337 RGB_IN(r, g, b, p);
00338 q[0] = RGB_TO_Y(r, g, b);
00339 q++;
00340 p += BPP;
00341 }
00342 p += src_wrap;
00343 q += dst_wrap;
00344 }
00345 }
00346
00347 static void glue(gray_to_, RGB_NAME)(AVPicture *dst, const AVPicture *src,
00348 int width, int height)
00349 {
00350 const unsigned char *p;
00351 unsigned char *q;
00352 int r, dst_wrap, src_wrap;
00353 int x, y;
00354
00355 p = src->data[0];
00356 src_wrap = src->linesize[0] - width;
00357
00358 q = dst->data[0];
00359 dst_wrap = dst->linesize[0] - BPP * width;
00360
00361 for(y=0;y<height;y++) {
00362 for(x=0;x<width;x++) {
00363 r = p[0];
00364 RGB_OUT(q, r, r, r);
00365 q += BPP;
00366 p ++;
00367 }
00368 p += src_wrap;
00369 q += dst_wrap;
00370 }
00371 }
00372
00373 static void glue(pal8_to_, RGB_NAME)(AVPicture *dst, const AVPicture *src,
00374 int width, int height)
00375 {
00376 const unsigned char *p;
00377 unsigned char *q;
00378 int r, g, b, dst_wrap, src_wrap;
00379 int x, y;
00380 uint32_t v;
00381 const uint32_t *palette;
00382
00383 p = src->data[0];
00384 src_wrap = src->linesize[0] - width;
00385 palette = (uint32_t *)src->data[1];
00386
00387 q = dst->data[0];
00388 dst_wrap = dst->linesize[0] - BPP * width;
00389
00390 for(y=0;y<height;y++) {
00391 for(x=0;x<width;x++) {
00392 v = palette[p[0]];
00393 r = (v >> 16) & 0xff;
00394 g = (v >> 8) & 0xff;
00395 b = (v) & 0xff;
00396 #ifdef RGBA_OUT
00397 {
00398 int a;
00399 a = (v >> 24) & 0xff;
00400 RGBA_OUT(q, r, g, b, a);
00401 }
00402 #else
00403 RGB_OUT(q, r, g, b);
00404 #endif
00405 q += BPP;
00406 p ++;
00407 }
00408 p += src_wrap;
00409 q += dst_wrap;
00410 }
00411 }
00412
00413
00414 #if !defined(FMT_RGB32) && !defined(FMT_RGB24)
00415
00416
00417 static void glue(rgb32_to_, RGB_NAME)(AVPicture *dst, const AVPicture *src,
00418 int width, int height)
00419 {
00420 const uint8_t *s;
00421 uint8_t *d;
00422 int src_wrap, dst_wrap, j, y;
00423 unsigned int v, r, g, b;
00424 #ifdef RGBA_OUT
00425 unsigned int a;
00426 #endif
00427
00428 s = src->data[0];
00429 src_wrap = src->linesize[0] - width * 4;
00430
00431 d = dst->data[0];
00432 dst_wrap = dst->linesize[0] - width * BPP;
00433
00434 for(y=0;y<height;y++) {
00435 for(j = 0;j < width; j++) {
00436 v = ((const uint32_t *)(s))[0];
00437 r = (v >> 16) & 0xff;
00438 g = (v >> 8) & 0xff;
00439 b = v & 0xff;
00440 #ifdef RGBA_OUT
00441 a = (v >> 24) & 0xff;
00442 RGBA_OUT(d, r, g, b, a);
00443 #else
00444 RGB_OUT(d, r, g, b);
00445 #endif
00446 s += 4;
00447 d += BPP;
00448 }
00449 s += src_wrap;
00450 d += dst_wrap;
00451 }
00452 }
00453
00454 static void glue(RGB_NAME, _to_rgb32)(AVPicture *dst, const AVPicture *src,
00455 int width, int height)
00456 {
00457 const uint8_t *s;
00458 uint8_t *d;
00459 int src_wrap, dst_wrap, j, y;
00460 unsigned int r, g, b;
00461 #ifdef RGBA_IN
00462 unsigned int a;
00463 #endif
00464
00465 s = src->data[0];
00466 src_wrap = src->linesize[0] - width * BPP;
00467
00468 d = dst->data[0];
00469 dst_wrap = dst->linesize[0] - width * 4;
00470
00471 for(y=0;y<height;y++) {
00472 for(j = 0;j < width; j++) {
00473 #ifdef RGBA_IN
00474 RGBA_IN(r, g, b, a, s);
00475 ((uint32_t *)(d))[0] = (a << 24) | (r << 16) | (g << 8) | b;
00476 #else
00477 RGB_IN(r, g, b, s);
00478 ((uint32_t *)(d))[0] = (0xff << 24) | (r << 16) | (g << 8) | b;
00479 #endif
00480 d += 4;
00481 s += BPP;
00482 }
00483 s += src_wrap;
00484 d += dst_wrap;
00485 }
00486 }
00487
00488 #endif
00489
00490 #ifndef FMT_RGB24
00491
00492 static void glue(rgb24_to_, RGB_NAME)(AVPicture *dst, const AVPicture *src,
00493 int width, int height)
00494 {
00495 const uint8_t *s;
00496 uint8_t *d;
00497 int src_wrap, dst_wrap, j, y;
00498 unsigned int r, g, b;
00499
00500 s = src->data[0];
00501 src_wrap = src->linesize[0] - width * 3;
00502
00503 d = dst->data[0];
00504 dst_wrap = dst->linesize[0] - width * BPP;
00505
00506 for(y=0;y<height;y++) {
00507 for(j = 0;j < width; j++) {
00508 r = s[0];
00509 g = s[1];
00510 b = s[2];
00511 RGB_OUT(d, r, g, b);
00512 s += 3;
00513 d += BPP;
00514 }
00515 s += src_wrap;
00516 d += dst_wrap;
00517 }
00518 }
00519
00520 static void glue(RGB_NAME, _to_rgb24)(AVPicture *dst, const AVPicture *src,
00521 int width, int height)
00522 {
00523 const uint8_t *s;
00524 uint8_t *d;
00525 int src_wrap, dst_wrap, j, y;
00526 unsigned int r, g , b;
00527
00528 s = src->data[0];
00529 src_wrap = src->linesize[0] - width * BPP;
00530
00531 d = dst->data[0];
00532 dst_wrap = dst->linesize[0] - width * 3;
00533
00534 for(y=0;y<height;y++) {
00535 for(j = 0;j < width; j++) {
00536 RGB_IN(r, g, b, s)
00537 d[0] = r;
00538 d[1] = g;
00539 d[2] = b;
00540 d += 3;
00541 s += BPP;
00542 }
00543 s += src_wrap;
00544 d += dst_wrap;
00545 }
00546 }
00547
00548 #endif
00549
00550 #ifdef FMT_RGB24
00551
00552 static void yuv444p_to_rgb24(AVPicture *dst, const AVPicture *src,
00553 int width, int height)
00554 {
00555 const uint8_t *y1_ptr, *cb_ptr, *cr_ptr;
00556 uint8_t *d, *d1;
00557 int w, y, cb, cr, r_add, g_add, b_add;
00558 uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
00559 unsigned int r, g, b;
00560
00561 d = dst->data[0];
00562 y1_ptr = src->data[0];
00563 cb_ptr = src->data[1];
00564 cr_ptr = src->data[2];
00565 for(;height > 0; height --) {
00566 d1 = d;
00567 for(w = width; w > 0; w--) {
00568 YUV_TO_RGB1_CCIR(cb_ptr[0], cr_ptr[0]);
00569
00570 YUV_TO_RGB2_CCIR(r, g, b, y1_ptr[0]);
00571 RGB_OUT(d1, r, g, b);
00572 d1 += BPP;
00573
00574 y1_ptr++;
00575 cb_ptr++;
00576 cr_ptr++;
00577 }
00578 d += dst->linesize[0];
00579 y1_ptr += src->linesize[0] - width;
00580 cb_ptr += src->linesize[1] - width;
00581 cr_ptr += src->linesize[2] - width;
00582 }
00583 }
00584
00585 static void yuvj444p_to_rgb24(AVPicture *dst, const AVPicture *src,
00586 int width, int height)
00587 {
00588 const uint8_t *y1_ptr, *cb_ptr, *cr_ptr;
00589 uint8_t *d, *d1;
00590 int w, y, cb, cr, r_add, g_add, b_add;
00591 uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
00592 unsigned int r, g, b;
00593
00594 d = dst->data[0];
00595 y1_ptr = src->data[0];
00596 cb_ptr = src->data[1];
00597 cr_ptr = src->data[2];
00598 for(;height > 0; height --) {
00599 d1 = d;
00600 for(w = width; w > 0; w--) {
00601 YUV_TO_RGB1(cb_ptr[0], cr_ptr[0]);
00602
00603 YUV_TO_RGB2(r, g, b, y1_ptr[0]);
00604 RGB_OUT(d1, r, g, b);
00605 d1 += BPP;
00606
00607 y1_ptr++;
00608 cb_ptr++;
00609 cr_ptr++;
00610 }
00611 d += dst->linesize[0];
00612 y1_ptr += src->linesize[0] - width;
00613 cb_ptr += src->linesize[1] - width;
00614 cr_ptr += src->linesize[2] - width;
00615 }
00616 }
00617
00618 static void rgb24_to_yuv444p(AVPicture *dst, const AVPicture *src,
00619 int width, int height)
00620 {
00621 int src_wrap, x, y;
00622 int r, g, b;
00623 uint8_t *lum, *cb, *cr;
00624 const uint8_t *p;
00625
00626 lum = dst->data[0];
00627 cb = dst->data[1];
00628 cr = dst->data[2];
00629
00630 src_wrap = src->linesize[0] - width * BPP;
00631 p = src->data[0];
00632 for(y=0;y<height;y++) {
00633 for(x=0;x<width;x++) {
00634 RGB_IN(r, g, b, p);
00635 lum[0] = RGB_TO_Y_CCIR(r, g, b);
00636 cb[0] = RGB_TO_U_CCIR(r, g, b, 0);
00637 cr[0] = RGB_TO_V_CCIR(r, g, b, 0);
00638 p += BPP;
00639 cb++;
00640 cr++;
00641 lum++;
00642 }
00643 p += src_wrap;
00644 lum += dst->linesize[0] - width;
00645 cb += dst->linesize[1] - width;
00646 cr += dst->linesize[2] - width;
00647 }
00648 }
00649
00650 static void rgb24_to_yuvj420p(AVPicture *dst, const AVPicture *src,
00651 int width, int height)
00652 {
00653 int wrap, wrap3, width2;
00654 int r, g, b, r1, g1, b1, w;
00655 uint8_t *lum, *cb, *cr;
00656 const uint8_t *p;
00657
00658 lum = dst->data[0];
00659 cb = dst->data[1];
00660 cr = dst->data[2];
00661
00662 width2 = (width + 1) >> 1;
00663 wrap = dst->linesize[0];
00664 wrap3 = src->linesize[0];
00665 p = src->data[0];
00666 for(;height>=2;height -= 2) {
00667 for(w = width; w >= 2; w -= 2) {
00668 RGB_IN(r, g, b, p);
00669 r1 = r;
00670 g1 = g;
00671 b1 = b;
00672 lum[0] = RGB_TO_Y(r, g, b);
00673
00674 RGB_IN(r, g, b, p + BPP);
00675 r1 += r;
00676 g1 += g;
00677 b1 += b;
00678 lum[1] = RGB_TO_Y(r, g, b);
00679 p += wrap3;
00680 lum += wrap;
00681
00682 RGB_IN(r, g, b, p);
00683 r1 += r;
00684 g1 += g;
00685 b1 += b;
00686 lum[0] = RGB_TO_Y(r, g, b);
00687
00688 RGB_IN(r, g, b, p + BPP);
00689 r1 += r;
00690 g1 += g;
00691 b1 += b;
00692 lum[1] = RGB_TO_Y(r, g, b);
00693
00694 cb[0] = RGB_TO_U(r1, g1, b1, 2);
00695 cr[0] = RGB_TO_V(r1, g1, b1, 2);
00696
00697 cb++;
00698 cr++;
00699 p += -wrap3 + 2 * BPP;
00700 lum += -wrap + 2;
00701 }
00702 if (w) {
00703 RGB_IN(r, g, b, p);
00704 r1 = r;
00705 g1 = g;
00706 b1 = b;
00707 lum[0] = RGB_TO_Y(r, g, b);
00708 p += wrap3;
00709 lum += wrap;
00710 RGB_IN(r, g, b, p);
00711 r1 += r;
00712 g1 += g;
00713 b1 += b;
00714 lum[0] = RGB_TO_Y(r, g, b);
00715 cb[0] = RGB_TO_U(r1, g1, b1, 1);
00716 cr[0] = RGB_TO_V(r1, g1, b1, 1);
00717 cb++;
00718 cr++;
00719 p += -wrap3 + BPP;
00720 lum += -wrap + 1;
00721 }
00722 p += wrap3 + (wrap3 - width * BPP);
00723 lum += wrap + (wrap - width);
00724 cb += dst->linesize[1] - width2;
00725 cr += dst->linesize[2] - width2;
00726 }
00727
00728 if (height) {
00729 for(w = width; w >= 2; w -= 2) {
00730 RGB_IN(r, g, b, p);
00731 r1 = r;
00732 g1 = g;
00733 b1 = b;
00734 lum[0] = RGB_TO_Y(r, g, b);
00735
00736 RGB_IN(r, g, b, p + BPP);
00737 r1 += r;
00738 g1 += g;
00739 b1 += b;
00740 lum[1] = RGB_TO_Y(r, g, b);
00741 cb[0] = RGB_TO_U(r1, g1, b1, 1);
00742 cr[0] = RGB_TO_V(r1, g1, b1, 1);
00743 cb++;
00744 cr++;
00745 p += 2 * BPP;
00746 lum += 2;
00747 }
00748 if (w) {
00749 RGB_IN(r, g, b, p);
00750 lum[0] = RGB_TO_Y(r, g, b);
00751 cb[0] = RGB_TO_U(r, g, b, 0);
00752 cr[0] = RGB_TO_V(r, g, b, 0);
00753 }
00754 }
00755 }
00756
00757 static void rgb24_to_yuvj444p(AVPicture *dst, const AVPicture *src,
00758 int width, int height)
00759 {
00760 int src_wrap, x, y;
00761 int r, g, b;
00762 uint8_t *lum, *cb, *cr;
00763 const uint8_t *p;
00764
00765 lum = dst->data[0];
00766 cb = dst->data[1];
00767 cr = dst->data[2];
00768
00769 src_wrap = src->linesize[0] - width * BPP;
00770 p = src->data[0];
00771 for(y=0;y<height;y++) {
00772 for(x=0;x<width;x++) {
00773 RGB_IN(r, g, b, p);
00774 lum[0] = RGB_TO_Y(r, g, b);
00775 cb[0] = RGB_TO_U(r, g, b, 0);
00776 cr[0] = RGB_TO_V(r, g, b, 0);
00777 p += BPP;
00778 cb++;
00779 cr++;
00780 lum++;
00781 }
00782 p += src_wrap;
00783 lum += dst->linesize[0] - width;
00784 cb += dst->linesize[1] - width;
00785 cr += dst->linesize[2] - width;
00786 }
00787 }
00788
00789 #endif
00790
00791 #if defined(FMT_RGB24) || defined(FMT_RGB32)
00792
00793 static void glue(RGB_NAME, _to_pal8)(AVPicture *dst, const AVPicture *src,
00794 int width, int height)
00795 {
00796 const unsigned char *p;
00797 unsigned char *q;
00798 int dst_wrap, src_wrap;
00799 int x, y, has_alpha;
00800 unsigned int r, g, b;
00801
00802 p = src->data[0];
00803 src_wrap = src->linesize[0] - BPP * width;
00804
00805 q = dst->data[0];
00806 dst_wrap = dst->linesize[0] - width;
00807 has_alpha = 0;
00808
00809 for(y=0;y<height;y++) {
00810 for(x=0;x<width;x++) {
00811 #ifdef RGBA_IN
00812 {
00813 unsigned int a;
00814 RGBA_IN(r, g, b, a, p);
00815
00816 if (a < 0x80) {
00817 has_alpha = 1;
00818 q[0] = TRANSP_INDEX;
00819 } else {
00820 q[0] = gif_clut_index(r, g, b);
00821 }
00822 }
00823 #else
00824 RGB_IN(r, g, b, p);
00825 q[0] = gif_clut_index(r, g, b);
00826 #endif
00827 q++;
00828 p += BPP;
00829 }
00830 p += src_wrap;
00831 q += dst_wrap;
00832 }
00833
00834 build_rgb_palette(dst->data[1], has_alpha);
00835 }
00836
00837 #endif
00838
00839 #ifdef RGBA_IN
00840
00841 static int glue(get_alpha_info_, RGB_NAME)(const AVPicture *src,
00842 int width, int height)
00843 {
00844 const unsigned char *p;
00845 int src_wrap, ret, x, y;
00846 unsigned int r, g, b, a;
00847
00848 p = src->data[0];
00849 src_wrap = src->linesize[0] - BPP * width;
00850 ret = 0;
00851 for(y=0;y<height;y++) {
00852 for(x=0;x<width;x++) {
00853 RGBA_IN(r, g, b, a, p);
00854 if (a == 0x00) {
00855 ret |= FF_ALPHA_TRANSP;
00856 } else if (a != 0xff) {
00857 ret |= FF_ALPHA_SEMI_TRANSP;
00858 }
00859 p += BPP;
00860 }
00861 p += src_wrap;
00862 }
00863 return ret;
00864 }
00865
00866 #endif
00867
00868 #undef RGB_IN
00869 #undef RGBA_IN
00870 #undef RGB_OUT
00871 #undef RGBA_OUT
00872 #undef BPP
00873 #undef RGB_NAME
00874 #undef FMT_RGB24
00875 #undef FMT_RGB32