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