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