| @@ -195,18 +195,18 @@ DECLARE_ALIGNED(8, const uint8_t, dither_8x8_220)[8][8]={ · 194 unmodified lines |
| 195 | 195 | #endif |
| 196 | 196 | |
| 197 | 197 | static av_always_inline void |
| 198 | | −yuv2yuvX16_c_template(const int16_t *lumFilter, const int16_t **lumSrc, |
| 198 | +yuv2yuvX16_c_template(const int16_t *lumFilter, const int32_t **lumSrc, |
| 199 | 199 | int lumFilterSize, const int16_t *chrFilter, |
| 200 | | − const int16_t **chrUSrc, const int16_t **chrVSrc, |
| 201 | | − int chrFilterSize, const int16_t **alpSrc, |
| 200 | + const int32_t **chrUSrc, const int32_t **chrVSrc, |
| 201 | + int chrFilterSize, const int32_t **alpSrc, |
| 202 | 202 | uint16_t *dest[4], int dstW, int chrDstW, |
| 203 | 203 | int big_endian, int output_bits) |
| 204 | 204 | { |
| 205 | 205 | //FIXME Optimize (just quickly written not optimized..) |
| 206 | 206 | int i; |
| 207 | | − int shift = 11 + 16 - output_bits; |
| 208 | 207 | uint16_t *yDest = dest[0], *uDest = dest[1], *vDest = dest[2], |
| 209 | 208 | *aDest = CONFIG_SWSCALE_ALPHA ? dest[3] : NULL; |
| 209 | + int shift = 15 + 16 - output_bits; |
| 210 | 210 | |
| 211 | 211 | #define output_pixel(pos, val) \ |
| 212 | 212 | if (big_endian) { \ |
| @@ -223,7 +223,7 @@ yuv2yuvX16_c_template(const int16_t *lumFilter, const int16_t **lumSrc, · 10 unmodified lines |
| 223 | 223 | } \ |
| 224 | 224 | } |
| 225 | 225 | for (i = 0; i < dstW; i++) { |
| 226 | | − int val = 1 << (26-output_bits); |
| 226 | + int val = 1 << (30-output_bits); |
| 227 | 227 | int j; |
| 228 | 228 | |
| 229 | 229 | for (j = 0; j < lumFilterSize; j++) |
| @@ -234,8 +234,8 @@ yuv2yuvX16_c_template(const int16_t *lumFilter, const int16_t **lumSrc, · 4 unmodified lines |
| 234 | 234 | |
| 235 | 235 | if (uDest) { |
| 236 | 236 | for (i = 0; i < chrDstW; i++) { |
| 237 | | − int u = 1 << (26-output_bits); |
| 238 | | − int v = 1 << (26-output_bits); |
| 237 | + int u = 1 << (30-output_bits); |
| 238 | + int v = 1 << (30-output_bits); |
| 239 | 239 | int j; |
| 240 | 240 | |
| 241 | 241 | for (j = 0; j < chrFilterSize; j++) { |
| @@ -250,7 +250,7 @@ yuv2yuvX16_c_template(const int16_t *lumFilter, const int16_t **lumSrc, · 8 unmodified lines |
| 250 | 250 | |
| 251 | 251 | if (CONFIG_SWSCALE_ALPHA && aDest) { |
| 252 | 252 | for (i = 0; i < dstW; i++) { |
| 253 | | − int val = 1 << (26-output_bits); |
| 253 | + int val = 1 << (30-output_bits); |
| 254 | 254 | int j; |
| 255 | 255 | |
| 256 | 256 | for (j = 0; j < lumFilterSize; j++) |
| @@ -264,12 +264,16 @@ yuv2yuvX16_c_template(const int16_t *lumFilter, const int16_t **lumSrc, · 7 unmodified lines |
| 264 | 264 | |
| 265 | 265 | #define yuv2NBPS(bits, BE_LE, is_be) \ |
| 266 | 266 | static void yuv2yuvX ## bits ## BE_LE ## _c(SwsContext *c, const int16_t *lumFilter, \ |
| 267 | | − const int16_t **lumSrc, int lumFilterSize, \ |
| 268 | | − const int16_t *chrFilter, const int16_t **chrUSrc, \ |
| 269 | | − const int16_t **chrVSrc, \ |
| 270 | | − int chrFilterSize, const int16_t **alpSrc, \ |
| 267 | + const int16_t **_lumSrc, int lumFilterSize, \ |
| 268 | + const int16_t *chrFilter, const int16_t **_chrUSrc, \ |
| 269 | + const int16_t **_chrVSrc, \ |
| 270 | + int chrFilterSize, const int16_t **_alpSrc, \ |
| 271 | 271 | uint8_t *_dest[4], int dstW, int chrDstW) \ |
| 272 | 272 | { \ |
| 273 | + const int32_t **lumSrc = (const int32_t **) _lumSrc, \ |
| 274 | + **chrUSrc = (const int32_t **) _chrUSrc, \ |
| 275 | + **chrVSrc = (const int32_t **) _chrVSrc, \ |
| 276 | + **alpSrc = (const int32_t **) _alpSrc; \ |
| 273 | 277 | yuv2yuvX16_c_template(lumFilter, lumSrc, lumFilterSize, \ |
| 274 | 278 | chrFilter, chrUSrc, chrVSrc, chrFilterSize, \ |
| 275 | 279 | alpSrc, (uint16_t **) _dest, \ |
| @@ -418,109 +422,121 @@ static void yuv2nv12X_c(SwsContext *c, const int16_t *lumFilter, · 142 unmodified lines |
| 418 | 422 | |
| 419 | 423 | static av_always_inline void |
| 420 | 424 | yuv2gray16_X_c_template(SwsContext *c, const int16_t *lumFilter, |
| 421 | | − const int16_t **lumSrc, int lumFilterSize, |
| 422 | | − const int16_t *chrFilter, const int16_t **chrUSrc, |
| 423 | | − const int16_t **chrVSrc, int chrFilterSize, |
| 424 | | − const int16_t **alpSrc, uint8_t *dest, int dstW, |
| 425 | + const int32_t **lumSrc, int lumFilterSize, |
| 426 | + const int16_t *chrFilter, const int32_t **chrUSrc, |
| 427 | + const int32_t **chrVSrc, int chrFilterSize, |
| 428 | + const int32_t **alpSrc, uint16_t *dest, int dstW, |
| 425 | 429 | int y, enum PixelFormat target) |
| 426 | 430 | { |
| 427 | 431 | int i; |
| 428 | 432 | |
| 429 | 433 | for (i = 0; i < (dstW >> 1); i++) { |
| 430 | 434 | int j; |
| 431 | | − int Y1 = 1 << 18; |
| 432 | | − int Y2 = 1 << 18; |
| 433 | | − const int i2 = 2 * i; |
| 435 | + int Y1 = 1 << 14; |
| 436 | + int Y2 = 1 << 14; |
| 434 | 437 | |
| 435 | 438 | for (j = 0; j < lumFilterSize; j++) { |
| 436 | | − Y1 += lumSrc[j][i2] * lumFilter[j]; |
| 437 | | − Y2 += lumSrc[j][i2+1] * lumFilter[j]; |
| 439 | + Y1 += lumSrc[j][i * 2] * lumFilter[j]; |
| 440 | + Y2 += lumSrc[j][i * 2 + 1] * lumFilter[j]; |
| 438 | 441 | } |
| 439 | | − Y1 >>= 11; |
| 440 | | − Y2 >>= 11; |
| 442 | + Y1 >>= 15; |
| 443 | + Y2 >>= 15; |
| 441 | 444 | if ((Y1 | Y2) & 0x10000) { |
| 442 | 445 | Y1 = av_clip_uint16(Y1); |
| 443 | 446 | Y2 = av_clip_uint16(Y2); |
| 444 | 447 | } |
| 445 | | − output_pixel(&dest[2 * i2 + 0], Y1); |
| 446 | | − output_pixel(&dest[2 * i2 + 2], Y2); |
| 448 | + output_pixel(&dest[i * 2 + 0], Y1); |
| 449 | + output_pixel(&dest[i * 2 + 1], Y2); |
| 447 | 450 | } |
| 448 | 451 | } |
| 449 | 452 | |
| 450 | 453 | static av_always_inline void |
| 451 | | −yuv2gray16_2_c_template(SwsContext *c, const int16_t *buf[2], |
| 452 | | − const int16_t *ubuf[2], const int16_t *vbuf[2], |
| 453 | | − const int16_t *abuf[2], uint8_t *dest, int dstW, |
| 454 | +yuv2gray16_2_c_template(SwsContext *c, const int32_t *buf[2], |
| 455 | + const int32_t *ubuf[2], const int32_t *vbuf[2], |
| 456 | + const int32_t *abuf[2], uint16_t *dest, int dstW, |
| 454 | 457 | int yalpha, int uvalpha, int y, |
| 455 | 458 | enum PixelFormat target) |
| 456 | 459 | { |
| 457 | 460 | int yalpha1 = 4095 - yalpha; |
| 458 | 461 | int i; |
| 459 | | − const int16_t *buf0 = buf[0], *buf1 = buf[1]; |
| 462 | + const int32_t *buf0 = buf[0], *buf1 = buf[1]; |
| 460 | 463 | |
| 461 | 464 | for (i = 0; i < (dstW >> 1); i++) { |
| 462 | | − const int i2 = 2 * i; |
| 463 | | − int Y1 = (buf0[i2 ] * yalpha1 + buf1[i2 ] * yalpha) >> 11; |
| 464 | | − int Y2 = (buf0[i2+1] * yalpha1 + buf1[i2+1] * yalpha) >> 11; |
| 465 | + int Y1 = (buf0[i * 2 ] * yalpha1 + buf1[i * 2 ] * yalpha) >> 15; |
| 466 | + int Y2 = (buf0[i * 2 + 1] * yalpha1 + buf1[i * 2 + 1] * yalpha) >> 15; |
| 465 | 467 | |
| 466 | | − output_pixel(&dest[2 * i2 + 0], Y1); |
| 467 | | − output_pixel(&dest[2 * i2 + 2], Y2); |
| 468 | + output_pixel(&dest[i * 2 + 0], Y1); |
| 469 | + output_pixel(&dest[i * 2 + 1], Y2); |
| 468 | 470 | } |
| 469 | 471 | } |
| 470 | 472 | |
| 471 | 473 | static av_always_inline void |
| 472 | | −yuv2gray16_1_c_template(SwsContext *c, const int16_t *buf0, |
| 473 | | − const int16_t *ubuf[2], const int16_t *vbuf[2], |
| 474 | | − const int16_t *abuf0, uint8_t *dest, int dstW, |
| 474 | +yuv2gray16_1_c_template(SwsContext *c, const int32_t *buf0, |
| 475 | + const int32_t *ubuf[2], const int32_t *vbuf[2], |
| 476 | + const int32_t *abuf0, uint16_t *dest, int dstW, |
| 475 | 477 | int uvalpha, int y, enum PixelFormat target) |
| 476 | 478 | { |
| 477 | 479 | int i; |
| 478 | 480 | |
| 479 | 481 | for (i = 0; i < (dstW >> 1); i++) { |
| 480 | | − const int i2 = 2 * i; |
| 481 | | − int Y1 = buf0[i2 ] << 1; |
| 482 | | − int Y2 = buf0[i2+1] << 1; |
| 482 | + int Y1 = buf0[i * 2 ] << 1; |
| 483 | + int Y2 = buf0[i * 2 + 1] << 1; |
| 483 | 484 | |
| 484 | | − output_pixel(&dest[2 * i2 + 0], Y1); |
| 485 | | − output_pixel(&dest[2 * i2 + 2], Y2); |
| 485 | + output_pixel(&dest[i * 2 + 0], Y1); |
| 486 | + output_pixel(&dest[i * 2 + 1], Y2); |
| 486 | 487 | } |
| 487 | 488 | } |
| 488 | 489 | |
| 489 | 490 | #undef output_pixel |
| 490 | 491 | |
| 491 | | −#define YUV2PACKEDWRAPPER(name, base, ext, fmt) \ |
| 492 | +#define YUV2PACKED16WRAPPER(name, base, ext, fmt) \ |
| 492 | 493 | static void name ## ext ## _X_c(SwsContext *c, const int16_t *lumFilter, \ |
| 493 | | − const int16_t **lumSrc, int lumFilterSize, \ |
| 494 | | − const int16_t *chrFilter, const int16_t **chrUSrc, \ |
| 495 | | − const int16_t **chrVSrc, int chrFilterSize, \ |
| 496 | | − const int16_t **alpSrc, uint8_t *dest, int dstW, \ |
| 494 | + const int16_t **_lumSrc, int lumFilterSize, \ |
| 495 | + const int16_t *chrFilter, const int16_t **_chrUSrc, \ |
| 496 | + const int16_t **_chrVSrc, int chrFilterSize, \ |
| 497 | + const int16_t **_alpSrc, uint8_t *_dest, int dstW, \ |
| 497 | 498 | int y) \ |
| 498 | 499 | { \ |
| 500 | + const int32_t **lumSrc = (const int32_t **) _lumSrc, \ |
| 501 | + **chrUSrc = (const int32_t **) _chrUSrc, \ |
| 502 | + **chrVSrc = (const int32_t **) _chrVSrc, \ |
| 503 | + **alpSrc = (const int32_t **) _alpSrc; \ |
| 504 | + uint16_t *dest = (uint16_t *) _dest; \ |
| 499 | 505 | name ## base ## _X_c_template(c, lumFilter, lumSrc, lumFilterSize, \ |
| 500 | 506 | chrFilter, chrUSrc, chrVSrc, chrFilterSize, \ |
| 501 | 507 | alpSrc, dest, dstW, y, fmt); \ |
| 502 | 508 | } \ |
| 503 | 509 | \ |
| 504 | | −static void name ## ext ## _2_c(SwsContext *c, const int16_t *buf[2], \ |
| 505 | | − const int16_t *ubuf[2], const int16_t *vbuf[2], \ |
| 506 | | − const int16_t *abuf[2], uint8_t *dest, int dstW, \ |
| 510 | +static void name ## ext ## _2_c(SwsContext *c, const int16_t *_buf[2], \ |
| 511 | + const int16_t *_ubuf[2], const int16_t *_vbuf[2], \ |
| 512 | + const int16_t *_abuf[2], uint8_t *_dest, int dstW, \ |
| 507 | 513 | int yalpha, int uvalpha, int y) \ |
| 508 | 514 | { \ |
| 515 | + const int32_t **buf = (const int32_t **) _buf, \ |
| 516 | + **ubuf = (const int32_t **) _ubuf, \ |
| 517 | + **vbuf = (const int32_t **) _vbuf, \ |
| 518 | + **abuf = (const int32_t **) _abuf; \ |
| 519 | + uint16_t *dest = (uint16_t *) _dest; \ |
| 509 | 520 | name ## base ## _2_c_template(c, buf, ubuf, vbuf, abuf, \ |
| 510 | 521 | dest, dstW, yalpha, uvalpha, y, fmt); \ |
| 511 | 522 | } \ |
| 512 | 523 | \ |
| 513 | | −static void name ## ext ## _1_c(SwsContext *c, const int16_t *buf0, \ |
| 514 | | − const int16_t *ubuf[2], const int16_t *vbuf[2], \ |
| 515 | | − const int16_t *abuf0, uint8_t *dest, int dstW, \ |
| 524 | +static void name ## ext ## _1_c(SwsContext *c, const int16_t *_buf0, \ |
| 525 | + const int16_t *_ubuf[2], const int16_t *_vbuf[2], \ |
| 526 | + const int16_t *_abuf0, uint8_t *_dest, int dstW, \ |
| 516 | 527 | int uvalpha, int y) \ |
| 517 | 528 | { \ |
| 529 | + const int32_t *buf0 = (const int32_t *) _buf0, \ |
| 530 | + **ubuf = (const int32_t **) _ubuf, \ |
| 531 | + **vbuf = (const int32_t **) _vbuf, \ |
| 532 | + *abuf0 = (const int32_t *) _abuf0; \ |
| 533 | + uint16_t *dest = (uint16_t *) _dest; \ |
| 518 | 534 | name ## base ## _1_c_template(c, buf0, ubuf, vbuf, abuf0, dest, \ |
| 519 | 535 | dstW, uvalpha, y, fmt); \ |
| 520 | 536 | } |
| 521 | 537 | |
| 522 | | −YUV2PACKEDWRAPPER(yuv2gray16,, LE, PIX_FMT_GRAY16LE); |
| 523 | | −YUV2PACKEDWRAPPER(yuv2gray16,, BE, PIX_FMT_GRAY16BE); |
| 538 | +YUV2PACKED16WRAPPER(yuv2gray16,, LE, PIX_FMT_GRAY16LE); |
| 539 | +YUV2PACKED16WRAPPER(yuv2gray16,, BE, PIX_FMT_GRAY16BE); |
| 524 | 540 | |
| 525 | 541 | #define output_pixel(pos, acc) \ |
| 526 | 542 | if (target == PIX_FMT_MONOBLACK) { \ |
| @@ -616,6 +632,38 @@ yuv2mono_1_c_template(SwsContext *c, const int16_t *buf0, · 89 unmodified lines |
| 616 | 632 | |
| 617 | 633 | #undef output_pixel |
| 618 | 634 | |
| 635 | +#define YUV2PACKEDWRAPPER(name, base, ext, fmt) \ |
| 636 | +static void name ## ext ## _X_c(SwsContext *c, const int16_t *lumFilter, \ |
| 637 | + const int16_t **lumSrc, int lumFilterSize, \ |
| 638 | + const int16_t *chrFilter, const int16_t **chrUSrc, \ |
| 639 | + const int16_t **chrVSrc, int chrFilterSize, \ |
| 640 | + const int16_t **alpSrc, uint8_t *dest, int dstW, \ |
| 641 | + int y) \ |
| 642 | +{ \ |
| 643 | + name ## base ## _X_c_template(c, lumFilter, lumSrc, lumFilterSize, \ |
| 644 | + chrFilter, chrUSrc, chrVSrc, chrFilterSize, \ |
| 645 | + alpSrc, dest, dstW, y, fmt); \ |
| 646 | +} \ |
| 647 | + \ |
| 648 | +static void name ## ext ## _2_c(SwsContext *c, const int16_t *buf[2], \ |
| 649 | + const int16_t *ubuf[2], const int16_t *vbuf[2], \ |
| 650 | + const int16_t *abuf[2], uint8_t *dest, int dstW, \ |
| 651 | + int yalpha, int uvalpha, int y) \ |
| 652 | +{ \ |
| 653 | + name ## base ## _2_c_template(c, buf, ubuf, vbuf, abuf, \ |
| 654 | + dest, dstW, yalpha, uvalpha, y, fmt); \ |
| 655 | +} \ |
| 656 | + \ |
| 657 | +static void name ## ext ## _1_c(SwsContext *c, const int16_t *buf0, \ |
| 658 | + const int16_t *ubuf[2], const int16_t *vbuf[2], \ |
| 659 | + const int16_t *abuf0, uint8_t *dest, int dstW, \ |
| 660 | + int uvalpha, int y) \ |
| 661 | +{ \ |
| 662 | + name ## base ## _1_c_template(c, buf0, ubuf, vbuf, \ |
| 663 | + abuf0, dest, dstW, uvalpha, \ |
| 664 | + y, fmt); \ |
| 665 | +} |
| 666 | + |
| 619 | 667 | YUV2PACKEDWRAPPER(yuv2mono,, white, PIX_FMT_MONOWHITE); |
| 620 | 668 | YUV2PACKEDWRAPPER(yuv2mono,, black, PIX_FMT_MONOBLACK); |
| 621 | 669 | |
| @@ -731,26 +779,32 @@ yuv2422_1_c_template(SwsContext *c, const int16_t *buf0, · 109 unmodified lines |
| 731 | 779 | YUV2PACKEDWRAPPER(yuv2, 422, yuyv422, PIX_FMT_YUYV422); |
| 732 | 780 | YUV2PACKEDWRAPPER(yuv2, 422, uyvy422, PIX_FMT_UYVY422); |
| 733 | 781 | |
| 734 | | −#define r_b ((target == PIX_FMT_RGB48LE || target == PIX_FMT_RGB48BE) ? r : b) |
| 735 | | −#define b_r ((target == PIX_FMT_RGB48LE || target == PIX_FMT_RGB48BE) ? b : r) |
| 782 | +#define R_B ((target == PIX_FMT_RGB48LE || target == PIX_FMT_RGB48BE) ? R : B) |
| 783 | +#define B_R ((target == PIX_FMT_RGB48LE || target == PIX_FMT_RGB48BE) ? B : R) |
| 784 | +#define output_pixel(pos, val) \ |
| 785 | + if (isBE(target)) { \ |
| 786 | + AV_WB16(pos, val); \ |
| 787 | + } else { \ |
| 788 | + AV_WL16(pos, val); \ |
| 789 | + } |
| 736 | 790 | |
| 737 | 791 | static av_always_inline void |
| 738 | 792 | yuv2rgb48_X_c_template(SwsContext *c, const int16_t *lumFilter, |
| 739 | | − const int16_t **lumSrc, int lumFilterSize, |
| 740 | | − const int16_t *chrFilter, const int16_t **chrUSrc, |
| 741 | | − const int16_t **chrVSrc, int chrFilterSize, |
| 742 | | − const int16_t **alpSrc, uint8_t *dest, int dstW, |
| 793 | + const int32_t **lumSrc, int lumFilterSize, |
| 794 | + const int16_t *chrFilter, const int32_t **chrUSrc, |
| 795 | + const int32_t **chrVSrc, int chrFilterSize, |
| 796 | + const int32_t **alpSrc, uint16_t *dest, int dstW, |
| 743 | 797 | int y, enum PixelFormat target) |
| 744 | 798 | { |
| 745 | 799 | int i; |
| 746 | 800 | |
| 747 | 801 | for (i = 0; i < (dstW >> 1); i++) { |
| 748 | 802 | int j; |
| 749 | | − int Y1 = 1 << 18; |
| 750 | | − int Y2 = 1 << 18; |
| 751 | | − int U = 1 << 18; |
| 752 | | − int V = 1 << 18; |
| 753 | | − const uint8_t *r, *g, *b; |
| 803 | + int Y1 = 0; |
| 804 | + int Y2 = 0; |
| 805 | + int U = -128 << 23; // 19 |
| 806 | + int V = -128 << 23; |
| 807 | + int R, G, B; |
| 754 | 808 | |
| 755 | 809 | for (j = 0; j < lumFilterSize; j++) { |
| 756 | 810 | Y1 += lumSrc[j][i * 2] * lumFilter[j]; |
| @@ -760,40 +814,45 @@ yuv2rgb48_X_c_template(SwsContext *c, const int16_t *lumFilter, · 3 unmodified lines |
| 760 | 814 | U += chrUSrc[j][i] * chrFilter[j]; |
| 761 | 815 | V += chrVSrc[j][i] * chrFilter[j]; |
| 762 | 816 | } |
| 763 | | − Y1 >>= 19; |
| 764 | | − Y2 >>= 19; |
| 765 | | − U >>= 19; |
| 766 | | − V >>= 19; |
| 767 | | − if ((Y1 | Y2 | U | V) & 0x100) { |
| 768 | | − Y1 = av_clip_uint8(Y1); |
| 769 | | − Y2 = av_clip_uint8(Y2); |
| 770 | | − U = av_clip_uint8(U); |
| 771 | | − V = av_clip_uint8(V); |
| 772 | | − } |
| 773 | 817 | |
| 774 | | − /* FIXME fix tables so that clipping is not needed and then use _NOCLIP*/ |
| 775 | | − r = (const uint8_t *) c->table_rV[V]; |
| 776 | | − g = (const uint8_t *)(c->table_gU[U] + c->table_gV[V]); |
| 777 | | − b = (const uint8_t *) c->table_bU[U]; |
| 818 | + // 8bit: 12+15=27; 16-bit: 12+19=31 |
| 819 | + Y1 >>= 14; // 10 |
| 820 | + Y2 >>= 14; |
| 821 | + U >>= 14; |
| 822 | + V >>= 14; |
| 823 | + |
| 824 | + // 8bit: 27 -> 17bit, 16bit: 31 - 14 = 17bit |
| 825 | + Y1 -= c->yuv2rgb_y_offset; |
| 826 | + Y2 -= c->yuv2rgb_y_offset; |
| 827 | + Y1 *= c->yuv2rgb_y_coeff; |
| 828 | + Y2 *= c->yuv2rgb_y_coeff; |
| 829 | + Y1 += 1 << 13; // 21 |
| 830 | + Y2 += 1 << 13; |
| 831 | + // 8bit: 17 + 13bit = 30bit, 16bit: 17 + 13bit = 30bit |
| 832 | + |
| 833 | + R = V * c->yuv2rgb_v2r_coeff; |
| 834 | + G = V * c->yuv2rgb_v2g_coeff + U * c->yuv2rgb_u2g_coeff; |
| 835 | + B = U * c->yuv2rgb_u2b_coeff; |
| 778 | 836 | |
| 779 | | − dest[ 0] = dest[ 1] = r_b[Y1]; |
| 780 | | − dest[ 2] = dest[ 3] = g[Y1]; |
| 781 | | − dest[ 4] = dest[ 5] = b_r[Y1]; |
| 782 | | − dest[ 6] = dest[ 7] = r_b[Y2]; |
| 783 | | − dest[ 8] = dest[ 9] = g[Y2]; |
| 784 | | − dest[10] = dest[11] = b_r[Y2]; |
| 785 | | − dest += 12; |
| 837 | + // 8bit: 30 - 22 = 8bit, 16bit: 30bit - 14 = 16bit |
| 838 | + output_pixel(&dest[0], av_clip_uintp2(R_B + Y1, 30) >> 14); |
| 839 | + output_pixel(&dest[1], av_clip_uintp2( G + Y1, 30) >> 14); |
| 840 | + output_pixel(&dest[2], av_clip_uintp2(B_R + Y1, 30) >> 14); |
| 841 | + output_pixel(&dest[3], av_clip_uintp2(R_B + Y2, 30) >> 14); |
| 842 | + output_pixel(&dest[4], av_clip_uintp2( G + Y2, 30) >> 14); |
| 843 | + output_pixel(&dest[5], av_clip_uintp2(B_R + Y2, 30) >> 14); |
| 844 | + dest += 6; |
| 786 | 845 | } |
| 787 | 846 | } |
| 788 | 847 | |
| 789 | 848 | static av_always_inline void |
| 790 | | −yuv2rgb48_2_c_template(SwsContext *c, const int16_t *buf[2], |
| 791 | | − const int16_t *ubuf[2], const int16_t *vbuf[2], |
| 792 | | − const int16_t *abuf[2], uint8_t *dest, int dstW, |
| 849 | +yuv2rgb48_2_c_template(SwsContext *c, const int32_t *buf[2], |
| 850 | + const int32_t *ubuf[2], const int32_t *vbuf[2], |
| 851 | + const int32_t *abuf[2], uint16_t *dest, int dstW, |
| 793 | 852 | int yalpha, int uvalpha, int y, |
| 794 | 853 | enum PixelFormat target) |
| 795 | 854 | { |
| 796 | | − const int16_t *buf0 = buf[0], *buf1 = buf[1], |
| 855 | + const int32_t *buf0 = buf[0], *buf1 = buf[1], |
| 797 | 856 | *ubuf0 = ubuf[0], *ubuf1 = ubuf[1], |
| 798 | 857 | *vbuf0 = vbuf[0], *vbuf1 = vbuf[1]; |
| 799 | 858 | int yalpha1 = 4095 - yalpha; |
| @@ -801,80 +860,108 @@ yuv2rgb48_2_c_template(SwsContext *c, const int16_t *buf[2], · 1 unmodified line |
| 801 | 860 | int i; |
| 802 | 861 | |
| 803 | 862 | for (i = 0; i < (dstW >> 1); i++) { |
| 804 | | − int Y1 = (buf0[i * 2] * yalpha1 + buf1[i * 2] * yalpha) >> 19; |
| 805 | | − int Y2 = (buf0[i * 2 + 1] * yalpha1 + buf1[i * 2 + 1] * yalpha) >> 19; |
| 806 | | − int U = (ubuf0[i] * uvalpha1 + ubuf1[i] * uvalpha) >> 19; |
| 807 | | − int V = (vbuf0[i] * uvalpha1 + vbuf1[i] * uvalpha) >> 19; |
| 808 | | − const uint8_t *r = (const uint8_t *) c->table_rV[V], |
| 809 | | − *g = (const uint8_t *)(c->table_gU[U] + c->table_gV[V]), |
| 810 | | − *b = (const uint8_t *) c->table_bU[U]; |
| 863 | + int Y1 = (buf0[i * 2] * yalpha1 + buf1[i * 2] * yalpha) >> 14; |
| 864 | + int Y2 = (buf0[i * 2 + 1] * yalpha1 + buf1[i * 2 + 1] * yalpha) >> 14; |
| 865 | + int U = (ubuf0[i] * uvalpha1 + ubuf1[i] * uvalpha + (-128 << 23)) >> 14; |
| 866 | + int V = (vbuf0[i] * uvalpha1 + vbuf1[i] * uvalpha + (-128 << 23)) >> 14; |
| 867 | + int R, G, B; |
| 811 | 868 | |
| 812 | | − dest[ 0] = dest[ 1] = r_b[Y1]; |
| 813 | | − dest[ 2] = dest[ 3] = g[Y1]; |
| 814 | | − dest[ 4] = dest[ 5] = b_r[Y1]; |
| 815 | | − dest[ 6] = dest[ 7] = r_b[Y2]; |
| 816 | | − dest[ 8] = dest[ 9] = g[Y2]; |
| 817 | | − dest[10] = dest[11] = b_r[Y2]; |
| 818 | | − dest += 12; |
| 869 | + Y1 -= c->yuv2rgb_y_offset; |
| 870 | + Y2 -= c->yuv2rgb_y_offset; |
| 871 | + Y1 *= c->yuv2rgb_y_coeff; |
| 872 | + Y2 *= c->yuv2rgb_y_coeff; |
| 873 | + Y1 += 1 << 13; |
| 874 | + Y2 += 1 << 13; |
| 875 | + |
| 876 | + R = V * c->yuv2rgb_v2r_coeff; |
| 877 | + G = V * c->yuv2rgb_v2g_coeff + U * c->yuv2rgb_u2g_coeff; |
| 878 | + B = U * c->yuv2rgb_u2b_coeff; |
| 879 | + |
| 880 | + output_pixel(&dest[0], av_clip_uintp2(R_B + Y1, 30) >> 14); |
| 881 | + output_pixel(&dest[1], av_clip_uintp2( G + Y1, 30) >> 14); |
| 882 | + output_pixel(&dest[2], av_clip_uintp2(B_R + Y1, 30) >> 14); |
| 883 | + output_pixel(&dest[3], av_clip_uintp2(R_B + Y2, 30) >> 14); |
| 884 | + output_pixel(&dest[4], av_clip_uintp2( G + Y2, 30) >> 14); |
| 885 | + output_pixel(&dest[5], av_clip_uintp2(B_R + Y2, 30) >> 14); |
| 886 | + dest += 6; |
| 819 | 887 | } |
| 820 | 888 | } |
| 821 | 889 | |
| 822 | 890 | static av_always_inline void |
| 823 | | −yuv2rgb48_1_c_template(SwsContext *c, const int16_t *buf0, |
| 824 | | − const int16_t *ubuf[2], const int16_t *vbuf[2], |
| 825 | | − const int16_t *abuf0, uint8_t *dest, int dstW, |
| 891 | +yuv2rgb48_1_c_template(SwsContext *c, const int32_t *buf0, |
| 892 | + const int32_t *ubuf[2], const int32_t *vbuf[2], |
| 893 | + const int32_t *abuf0, uint16_t *dest, int dstW, |
| 826 | 894 | int uvalpha, int y, enum PixelFormat target) |
| 827 | 895 | { |
| 828 | | − const int16_t *ubuf0 = ubuf[0], *ubuf1 = ubuf[1], |
| 896 | + const int32_t *ubuf0 = ubuf[0], *ubuf1 = ubuf[1], |
| 829 | 897 | *vbuf0 = vbuf[0], *vbuf1 = vbuf[1]; |
| 830 | 898 | int i; |
| 831 | 899 | |
| 832 | 900 | if (uvalpha < 2048) { |
| 833 | 901 | for (i = 0; i < (dstW >> 1); i++) { |
| 834 | | − int Y1 = buf0[i * 2] >> 7; |
| 835 | | − int Y2 = buf0[i * 2 + 1] >> 7; |
| 836 | | − int U = ubuf1[i] >> 7; |
| 837 | | − int V = vbuf1[i] >> 7; |
| 838 | | − const uint8_t *r = (const uint8_t *) c->table_rV[V], |
| 839 | | − *g = (const uint8_t *)(c->table_gU[U] + c->table_gV[V]), |
| 840 | | − *b = (const uint8_t *) c->table_bU[U]; |
| 841 | | − |
| 842 | | − dest[ 0] = dest[ 1] = r_b[Y1]; |
| 843 | | − dest[ 2] = dest[ 3] = g[Y1]; |
| 844 | | − dest[ 4] = dest[ 5] = b_r[Y1]; |
| 845 | | − dest[ 6] = dest[ 7] = r_b[Y2]; |
| 846 | | − dest[ 8] = dest[ 9] = g[Y2]; |
| 847 | | − dest[10] = dest[11] = b_r[Y2]; |
| 848 | | − dest += 12; |
| 902 | + int Y1 = (buf0[i * 2] ) >> 2; |
| 903 | + int Y2 = (buf0[i * 2 + 1]) >> 2; |
| 904 | + int U = (ubuf0[i] + (-128 << 11)) >> 2; |
| 905 | + int V = (vbuf0[i] + (-128 << 11)) >> 2; |
| 906 | + int R, G, B; |
| 907 | + |
| 908 | + Y1 -= c->yuv2rgb_y_offset; |
| 909 | + Y2 -= c->yuv2rgb_y_offset; |
| 910 | + Y1 *= c->yuv2rgb_y_coeff; |
| 911 | + Y2 *= c->yuv2rgb_y_coeff; |
| 912 | + Y1 += 1 << 13; |
| 913 | + Y2 += 1 << 13; |
| 914 | + |
| 915 | + R = V * c->yuv2rgb_v2r_coeff; |
| 916 | + G = V * c->yuv2rgb_v2g_coeff + U * c->yuv2rgb_u2g_coeff; |
| 917 | + B = U * c->yuv2rgb_u2b_coeff; |
| 918 | + |
| 919 | + output_pixel(&dest[0], av_clip_uintp2(R_B + Y1, 30) >> 14); |
| 920 | + output_pixel(&dest[1], av_clip_uintp2( G + Y1, 30) >> 14); |
| 921 | + output_pixel(&dest[2], av_clip_uintp2(B_R + Y1, 30) >> 14); |
| 922 | + output_pixel(&dest[3], av_clip_uintp2(R_B + Y2, 30) >> 14); |
| 923 | + output_pixel(&dest[4], av_clip_uintp2( G + Y2, 30) >> 14); |
| 924 | + output_pixel(&dest[5], av_clip_uintp2(B_R + Y2, 30) >> 14); |
| 925 | + dest += 6; |
| 849 | 926 | } |
| 850 | 927 | } else { |
| 851 | 928 | for (i = 0; i < (dstW >> 1); i++) { |
| 852 | | − int Y1 = buf0[i * 2] >> 7; |
| 853 | | − int Y2 = buf0[i * 2 + 1] >> 7; |
| 854 | | − int U = (ubuf0[i] + ubuf1[i]) >> 8; |
| 855 | | − int V = (vbuf0[i] + vbuf1[i]) >> 8; |
| 856 | | − const uint8_t *r = (const uint8_t *) c->table_rV[V], |
| 857 | | − *g = (const uint8_t *)(c->table_gU[U] + c->table_gV[V]), |
| 858 | | − *b = (const uint8_t *) c->table_bU[U]; |
| 859 | | − |
| 860 | | − dest[ 0] = dest[ 1] = r_b[Y1]; |
| 861 | | − dest[ 2] = dest[ 3] = g[Y1]; |
| 862 | | − dest[ 4] = dest[ 5] = b_r[Y1]; |
| 863 | | − dest[ 6] = dest[ 7] = r_b[Y2]; |
| 864 | | − dest[ 8] = dest[ 9] = g[Y2]; |
| 865 | | − dest[10] = dest[11] = b_r[Y2]; |
| 866 | | − dest += 12; |
| 929 | + int Y1 = (buf0[i * 2] ) >> 2; |
| 930 | + int Y2 = (buf0[i * 2 + 1]) >> 2; |
| 931 | + int U = (ubuf0[i] + ubuf1[i] + (-128 << 11)) >> 3; |
| 932 | + int V = (vbuf0[i] + vbuf1[i] + (-128 << 11)) >> 3; |
| 933 | + int R, G, B; |
| 934 | + |
| 935 | + Y1 -= c->yuv2rgb_y_offset; |
| 936 | + Y2 -= c->yuv2rgb_y_offset; |
| 937 | + Y1 *= c->yuv2rgb_y_coeff; |
| 938 | + Y2 *= c->yuv2rgb_y_coeff; |
| 939 | + Y1 += 1 << 13; |
| 940 | + Y2 += 1 << 13; |
| 941 | + |
| 942 | + R = V * c->yuv2rgb_v2r_coeff; |
| 943 | + G = V * c->yuv2rgb_v2g_coeff + U * c->yuv2rgb_u2g_coeff; |
| 944 | + B = U * c->yuv2rgb_u2b_coeff; |
| 945 | + |
| 946 | + output_pixel(&dest[0], av_clip_uintp2(R_B + Y1, 30) >> 14); |
| 947 | + output_pixel(&dest[1], av_clip_uintp2( G + Y1, 30) >> 14); |
| 948 | + output_pixel(&dest[2], av_clip_uintp2(B_R + Y1, 30) >> 14); |
| 949 | + output_pixel(&dest[3], av_clip_uintp2(R_B + Y2, 30) >> 14); |
| 950 | + output_pixel(&dest[4], av_clip_uintp2( G + Y2, 30) >> 14); |
| 951 | + output_pixel(&dest[5], av_clip_uintp2(B_R + Y2, 30) >> 14); |
| 952 | + dest += 6; |
| 867 | 953 | } |
| 868 | 954 | } |
| 869 | 955 | } |
| 870 | 956 | |
| 957 | +#undef output_pixel |
| 871 | 958 | #undef r_b |
| 872 | 959 | #undef b_r |
| 873 | 960 | |
| 874 | | −YUV2PACKEDWRAPPER(yuv2, rgb48, rgb48be, PIX_FMT_RGB48BE); |
| 875 | | −//YUV2PACKEDWRAPPER(yuv2, rgb48, rgb48le, PIX_FMT_RGB48LE); |
| 876 | | −YUV2PACKEDWRAPPER(yuv2, rgb48, bgr48be, PIX_FMT_BGR48BE); |
| 877 | | −//YUV2PACKEDWRAPPER(yuv2, rgb48, bgr48le, PIX_FMT_BGR48LE); |
| 961 | +YUV2PACKED16WRAPPER(yuv2, rgb48, rgb48be, PIX_FMT_RGB48BE); |
| 962 | +YUV2PACKED16WRAPPER(yuv2, rgb48, rgb48le, PIX_FMT_RGB48LE); |
| 963 | +YUV2PACKED16WRAPPER(yuv2, rgb48, bgr48be, PIX_FMT_BGR48BE); |
| 964 | +YUV2PACKED16WRAPPER(yuv2, rgb48, bgr48le, PIX_FMT_BGR48LE); |
| 878 | 965 | |
| 879 | 966 | static av_always_inline void |
| 880 | 967 | yuv2rgb_write(uint8_t *_dest, int i, int Y1, int Y2, |
| @@ -1025,7 +1112,7 @@ yuv2rgb_X_c_template(SwsContext *c, const int16_t *lumFilter, · 144 unmodified lines |
| 1025 | 1112 | U = av_clip_uint8(U); |
| 1026 | 1113 | V = av_clip_uint8(V); |
| 1027 | 1114 | } |
| 1028 | | − if (hasAlpha) {\ |
| 1115 | + if (hasAlpha) { |
| 1029 | 1116 | A1 = 1 << 18; |
| 1030 | 1117 | A2 = 1 << 18; |
| 1031 | 1118 | for (j = 0; j < lumFilterSize; j++) { |
| @@ -1318,50 +1405,50 @@ static av_always_inline void fillPlane(uint8_t* plane, int stride, · 286 unmodified lines |
| 1318 | 1405 | #define b ((origin == PIX_FMT_BGR48BE || origin == PIX_FMT_BGR48LE) ? r_b : b_r) |
| 1319 | 1406 | |
| 1320 | 1407 | static av_always_inline void |
| 1321 | | −rgb48ToY_c_template(uint8_t *dst, const uint8_t *src, int width, |
| 1408 | +rgb48ToY_c_template(uint16_t *dst, const uint16_t *src, int width, |
| 1322 | 1409 | enum PixelFormat origin) |
| 1323 | 1410 | { |
| 1324 | 1411 | int i; |
| 1325 | 1412 | for (i = 0; i < width; i++) { |
| 1326 | | − int r_b = input_pixel(&src[i*6+0]) >> 8; |
| 1327 | | − int g = input_pixel(&src[i*6+2]) >> 8; |
| 1328 | | − int b_r = input_pixel(&src[i*6+4]) >> 8; |
| 1413 | + unsigned int r_b = input_pixel(&src[i*3+0]); |
| 1414 | + unsigned int g = input_pixel(&src[i*3+1]); |
| 1415 | + unsigned int b_r = input_pixel(&src[i*3+2]); |
| 1329 | 1416 | |
| 1330 | | − dst[i] = (RY*r + GY*g + BY*b + (33<<(RGB2YUV_SHIFT-1))) >> RGB2YUV_SHIFT; |
| 1417 | + dst[i] = (RY*r + GY*g + BY*b + (0x2001<<(RGB2YUV_SHIFT-1))) >> RGB2YUV_SHIFT; |
| 1331 | 1418 | } |
| 1332 | 1419 | } |
| 1333 | 1420 | |
| 1334 | 1421 | static av_always_inline void |
| 1335 | | −rgb48ToUV_c_template(uint8_t *dstU, uint8_t *dstV, |
| 1336 | | − const uint8_t *src1, const uint8_t *src2, |
| 1422 | +rgb48ToUV_c_template(uint16_t *dstU, uint16_t *dstV, |
| 1423 | + const uint16_t *src1, const uint16_t *src2, |
| 1337 | 1424 | int width, enum PixelFormat origin) |
| 1338 | 1425 | { |
| 1339 | 1426 | int i; |
| 1340 | 1427 | assert(src1==src2); |
| 1341 | 1428 | for (i = 0; i < width; i++) { |
| 1342 | | − int r_b = input_pixel(&src1[i*6+0]) >> 8; |
| 1343 | | − int g = input_pixel(&src1[i*6+2]) >> 8; |
| 1344 | | − int b_r = input_pixel(&src1[i*6+4]) >> 8; |
| 1429 | + int r_b = input_pixel(&src1[i*3+0]); |
| 1430 | + int g = input_pixel(&src1[i*3+1]); |
| 1431 | + int b_r = input_pixel(&src1[i*3+2]); |
| 1345 | 1432 | |
| 1346 | | − dstU[i] = (RU*r + GU*g + BU*b + (257<<(RGB2YUV_SHIFT-1))) >> RGB2YUV_SHIFT; |
| 1347 | | − dstV[i] = (RV*r + GV*g + BV*b + (257<<(RGB2YUV_SHIFT-1))) >> RGB2YUV_SHIFT; |
| 1433 | + dstU[i] = (RU*r + GU*g + BU*b + (0x10001<<(RGB2YUV_SHIFT-1))) >> RGB2YUV_SHIFT; |
| 1434 | + dstV[i] = (RV*r + GV*g + BV*b + (0x10001<<(RGB2YUV_SHIFT-1))) >> RGB2YUV_SHIFT; |
| 1348 | 1435 | } |
| 1349 | 1436 | } |
| 1350 | 1437 | |
| 1351 | 1438 | static av_always_inline void |
| 1352 | | −rgb48ToUV_half_c_template(uint8_t *dstU, uint8_t *dstV, |
| 1353 | | − const uint8_t *src1, const uint8_t *src2, |
| 1439 | +rgb48ToUV_half_c_template(uint16_t *dstU, uint16_t *dstV, |
| 1440 | + const uint16_t *src1, const uint16_t *src2, |
| 1354 | 1441 | int width, enum PixelFormat origin) |
| 1355 | 1442 | { |
| 1356 | 1443 | int i; |
| 1357 | 1444 | assert(src1==src2); |
| 1358 | 1445 | for (i = 0; i < width; i++) { |
| 1359 | | − int r_b = (input_pixel(&src1[12*i + 0]) >> 8) + (input_pixel(&src1[12*i + 6]) >> 8); |
| 1360 | | − int g = (input_pixel(&src1[12*i + 2]) >> 8) + (input_pixel(&src1[12*i + 8]) >> 8); |
| 1361 | | − int b_r = (input_pixel(&src1[12*i + 4]) >> 8) + (input_pixel(&src1[12*i + 10]) >> 8); |
| 1446 | + int r_b = (input_pixel(&src1[6 * i + 0]) + input_pixel(&src1[6 * i + 3]) + 1) >> 1; |
| 1447 | + int g = (input_pixel(&src1[6 * i + 1]) + input_pixel(&src1[6 * i + 4]) + 1) >> 1; |
| 1448 | + int b_r = (input_pixel(&src1[6 * i + 2]) + input_pixel(&src1[6 * i + 5]) + 1) >> 1; |
| 1362 | 1449 | |
| 1363 | | − dstU[i]= (RU*r + GU*g + BU*b + (257<<RGB2YUV_SHIFT)) >> (RGB2YUV_SHIFT+1); |
| 1364 | | − dstV[i]= (RV*r + GV*g + BV*b + (257<<RGB2YUV_SHIFT)) >> (RGB2YUV_SHIFT+1); |
| 1450 | + dstU[i]= (RU*r + GU*g + BU*b + (0x10001<<(RGB2YUV_SHIFT-1))) >> RGB2YUV_SHIFT; |
| 1451 | + dstV[i]= (RV*r + GV*g + BV*b + (0x10001<<(RGB2YUV_SHIFT-1))) >> RGB2YUV_SHIFT; |
| 1365 | 1452 | } |
| 1366 | 1453 | } |
| 1367 | 1454 | |
| @@ -1370,23 +1457,31 @@ rgb48ToUV_half_c_template(uint8_t *dstU, uint8_t *dstV, · 2 unmodified lines |
| 1370 | 1457 | #undef input_pixel |
| 1371 | 1458 | |
| 1372 | 1459 | #define rgb48funcs(pattern, BE_LE, origin) \ |
| 1373 | | −static void pattern ## 48 ## BE_LE ## ToY_c(uint8_t *dst, const uint8_t *src, \ |
| 1460 | +static void pattern ## 48 ## BE_LE ## ToY_c(uint8_t *_dst, const uint8_t *_src, \ |
| 1374 | 1461 | int width, uint32_t *unused) \ |
| 1375 | 1462 | { \ |
| 1463 | + const uint16_t *src = (const uint16_t *) _src; \ |
| 1464 | + uint16_t *dst = (uint16_t *) _dst; \ |
| 1376 | 1465 | rgb48ToY_c_template(dst, src, width, origin); \ |
| 1377 | 1466 | } \ |
| 1378 | 1467 | \ |
| 1379 | | −static void pattern ## 48 ## BE_LE ## ToUV_c(uint8_t *dstU, uint8_t *dstV, \ |
| 1380 | | − const uint8_t *src1, const uint8_t *src2, \ |
| 1468 | +static void pattern ## 48 ## BE_LE ## ToUV_c(uint8_t *_dstU, uint8_t *_dstV, \ |
| 1469 | + const uint8_t *_src1, const uint8_t *_src2, \ |
| 1381 | 1470 | int width, uint32_t *unused) \ |
| 1382 | 1471 | { \ |
| 1472 | + const uint16_t *src1 = (const uint16_t *) _src1, \ |
| 1473 | + *src2 = (const uint16_t *) _src2; \ |
| 1474 | + uint16_t *dstU = (uint16_t *) _dstU, *dstV = (uint16_t *) _dstV; \ |
| 1383 | 1475 | rgb48ToUV_c_template(dstU, dstV, src1, src2, width, origin); \ |
| 1384 | 1476 | } \ |
| 1385 | 1477 | \ |
| 1386 | | −static void pattern ## 48 ## BE_LE ## ToUV_half_c(uint8_t *dstU, uint8_t *dstV, \ |
| 1387 | | − const uint8_t *src1, const uint8_t *src2, \ |
| 1478 | +static void pattern ## 48 ## BE_LE ## ToUV_half_c(uint8_t *_dstU, uint8_t *_dstV, \ |
| 1479 | + const uint8_t *_src1, const uint8_t *_src2, \ |
| 1388 | 1480 | int width, uint32_t *unused) \ |
| 1389 | 1481 | { \ |
| 1482 | + const uint16_t *src1 = (const uint16_t *) _src1, \ |
| 1483 | + *src2 = (const uint16_t *) _src2; \ |
| 1484 | + uint16_t *dstU = (uint16_t *) _dstU, *dstV = (uint16_t *) _dstV; \ |
| 1390 | 1485 | rgb48ToUV_half_c_template(dstU, dstV, src1, src2, width, origin); \ |
| 1391 | 1486 | } |
| 1392 | 1487 | |
| @@ -1601,13 +1696,26 @@ static void yuy2ToUV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *src1, · 208 unmodified lines |
| 1601 | 1696 | assert(src1 == src2); |
| 1602 | 1697 | } |
| 1603 | 1698 | |
| 1604 | | −static void LEToUV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *src1, |
| 1605 | | − const uint8_t *src2, int width, uint32_t *unused) |
| 1699 | +static void bswap16Y_c(uint8_t *_dst, const uint8_t *_src, int width, uint32_t *unused) |
| 1606 | 1700 | { |
| 1607 | 1701 | int i; |
| 1702 | + const uint16_t *src = (const uint16_t *) _src; |
| 1703 | + uint16_t *dst = (uint16_t *) _dst; |
| 1608 | 1704 | for (i=0; i<width; i++) { |
| 1609 | | − dstU[i]= src1[2*i + 1]; |
| 1610 | | − dstV[i]= src2[2*i + 1]; |
| 1705 | + dst[i] = av_bswap16(src[i]); |
| 1706 | + } |
| 1707 | +} |
| 1708 | + |
| 1709 | +static void bswap16UV_c(uint8_t *_dstU, uint8_t *_dstV, const uint8_t *_src1, |
| 1710 | + const uint8_t *_src2, int width, uint32_t *unused) |
| 1711 | +{ |
| 1712 | + int i; |
| 1713 | + const uint16_t *src1 = (const uint16_t *) _src1, |
| 1714 | + *src2 = (const uint16_t *) _src2; |
| 1715 | + uint16_t *dstU = (uint16_t *) _dstU, *dstV = (uint16_t *) _dstV; |
| 1716 | + for (i=0; i<width; i++) { |
| 1717 | + dstU[i] = av_bswap16(src1[i]); |
| 1718 | + dstV[i] = av_bswap16(src2[i]); |
| 1611 | 1719 | } |
| 1612 | 1720 | } |
| 1613 | 1721 | |
| @@ -1632,16 +1740,6 @@ static void uyvyToUV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *src1, · 18 unmodified lines |
| 1632 | 1740 | assert(src1 == src2); |
| 1633 | 1741 | } |
| 1634 | 1742 | |
| 1635 | | −static void BEToUV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *src1, |
| 1636 | | − const uint8_t *src2, int width, uint32_t *unused) |
| 1637 | | −{ |
| 1638 | | − int i; |
| 1639 | | − for (i=0; i<width; i++) { |
| 1640 | | − dstU[i]= src1[2*i]; |
| 1641 | | − dstV[i]= src2[2*i]; |
| 1642 | | − } |
| 1643 | | −} |
| 1644 | | − |
| 1645 | 1743 | static av_always_inline void nvXXtoUV_c(uint8_t *dst1, uint8_t *dst2, |
| 1646 | 1744 | const uint8_t *src, int width) |
| 1647 | 1745 | { |
| @@ -1670,43 +1768,49 @@ static void nv21ToUV_c(uint8_t *dstU, uint8_t *dstV, · 22 unmodified lines |
| 1670 | 1768 | |
| 1671 | 1769 | // FIXME Maybe dither instead. |
| 1672 | 1770 | static av_always_inline void |
| 1673 | | −yuv9_OR_10ToUV_c_template(uint8_t *dstU, uint8_t *dstV, |
| 1674 | | − const uint8_t *_srcU, const uint8_t *_srcV, |
| 1771 | +yuv9_OR_10ToUV_c_template(uint16_t *dstU, uint16_t *dstV, |
| 1772 | + const uint16_t *srcU, const uint16_t *srcV, |
| 1675 | 1773 | int width, enum PixelFormat origin, int depth) |
| 1676 | 1774 | { |
| 1677 | 1775 | int i; |
| 1678 | | − const uint16_t *srcU = (const uint16_t *) _srcU; |
| 1679 | | − const uint16_t *srcV = (const uint16_t *) _srcV; |
| 1680 | 1776 | |
| 1681 | 1777 | for (i = 0; i < width; i++) { |
| 1682 | | − dstU[i] = input_pixel(&srcU[i]) >> (depth - 8); |
| 1683 | | − dstV[i] = input_pixel(&srcV[i]) >> (depth - 8); |
| 1778 | + int upx = input_pixel(&srcU[i]); |
| 1779 | + int vpx = input_pixel(&srcV[i]); |
| 1780 | + dstU[i] = (upx << (16 - depth)) | (upx >> (2 * depth - 16)); |
| 1781 | + dstV[i] = (vpx << (16 - depth)) | (vpx >> (2 * depth - 16)); |
| 1684 | 1782 | } |
| 1685 | 1783 | } |
| 1686 | 1784 | |
| 1687 | 1785 | static av_always_inline void |
| 1688 | | −yuv9_or_10ToY_c_template(uint8_t *dstY, const uint8_t *_srcY, |
| 1786 | +yuv9_or_10ToY_c_template(uint16_t *dstY, const uint16_t *srcY, |
| 1689 | 1787 | int width, enum PixelFormat origin, int depth) |
| 1690 | 1788 | { |
| 1691 | 1789 | int i; |
| 1692 | | − const uint16_t *srcY = (const uint16_t*)_srcY; |
| 1693 | 1790 | |
| 1694 | | − for (i = 0; i < width; i++) |
| 1695 | | − dstY[i] = input_pixel(&srcY[i]) >> (depth - 8); |
| 1791 | + for (i = 0; i < width; i++) { |
| 1792 | + int px = input_pixel(&srcY[i]); |
| 1793 | + dstY[i] = (px << (16 - depth)) | (px >> (2 * depth - 16)); |
| 1794 | + } |
| 1696 | 1795 | } |
| 1697 | 1796 | |
| 1698 | 1797 | #undef input_pixel |
| 1699 | 1798 | |
| 1700 | 1799 | #define YUV_NBPS(depth, BE_LE, origin) \ |
| 1701 | | −static void BE_LE ## depth ## ToUV_c(uint8_t *dstU, uint8_t *dstV, \ |
| 1702 | | − const uint8_t *srcU, const uint8_t *srcV, \ |
| 1800 | +static void BE_LE ## depth ## ToUV_c(uint8_t *_dstU, uint8_t *_dstV, \ |
| 1801 | + const uint8_t *_srcU, const uint8_t *_srcV, \ |
| 1703 | 1802 | int width, uint32_t *unused) \ |
| 1704 | 1803 | { \ |
| 1804 | + uint16_t *dstU = (uint16_t *) _dstU, *dstV = (uint16_t *) _dstV; \ |
| 1805 | + const uint16_t *srcU = (const uint16_t *) _srcU, \ |
| 1806 | + *srcV = (const uint16_t *) _srcV; \ |
| 1705 | 1807 | yuv9_OR_10ToUV_c_template(dstU, dstV, srcU, srcV, width, origin, depth); \ |
| 1706 | 1808 | } \ |
| 1707 | | −static void BE_LE ## depth ## ToY_c(uint8_t *dstY, const uint8_t *srcY, \ |
| 1809 | +static void BE_LE ## depth ## ToY_c(uint8_t *_dstY, const uint8_t *_srcY, \ |
| 1708 | 1810 | int width, uint32_t *unused) \ |
| 1709 | 1811 | { \ |
| 1812 | + uint16_t *dstY = (uint16_t *) _dstY; \ |
| 1813 | + const uint16_t *srcY = (const uint16_t *) _srcY; \ |
| 1710 | 1814 | yuv9_or_10ToY_c_template(dstY, srcY, width, origin, depth); \ |
| 1711 | 1815 | } |
| 1712 | 1816 | |
| @@ -1801,6 +1905,27 @@ static void rgb24ToUV_half_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *src1, · 88 unmodified lines |
| 1801 | 1905 | } |
| 1802 | 1906 | } |
| 1803 | 1907 | |
| 1908 | +static void hScale16_c(int16_t *_dst, int dstW, const uint8_t *_src, |
| 1909 | + const int16_t *filter, |
| 1910 | + const int16_t *filterPos, int filterSize) |
| 1911 | +{ |
| 1912 | + int i; |
| 1913 | + int32_t *dst = (int32_t *) _dst; |
| 1914 | + const uint16_t *src = (const uint16_t *) _src; |
| 1915 | + |
| 1916 | + for (i = 0; i < dstW; i++) { |
| 1917 | + int j; |
| 1918 | + int srcPos = filterPos[i]; |
| 1919 | + unsigned int val = 0; |
| 1920 | + |
| 1921 | + for (j = 0; j < filterSize; j++) { |
| 1922 | + val += src[srcPos + j] * filter[filterSize * i + j]; |
| 1923 | + } |
| 1924 | + // filter=14 bit, input=16 bit, output=30 bit, >> 11 makes 19 bit |
| 1925 | + dst[i] = FFMIN(val >> 11, (1 << 19) - 1); |
| 1926 | + } |
| 1927 | +} |
| 1928 | + |
| 1804 | 1929 | // bilinear / bicubic scaling |
| 1805 | 1930 | static void hScale_c(int16_t *dst, int dstW, const uint8_t *src, |
| 1806 | 1931 | const int16_t *filter, const int16_t *filterPos, |
| @@ -1851,6 +1976,41 @@ static void lumRangeFromJpeg_c(int16_t *dst, int width) · 44 unmodified lines |
| 1851 | 1976 | dst[i] = (dst[i]*14071 + 33561947)>>14; |
| 1852 | 1977 | } |
| 1853 | 1978 | |
| 1979 | +static void chrRangeToJpeg16_c(int16_t *_dstU, int16_t *_dstV, int width) |
| 1980 | +{ |
| 1981 | + int i; |
| 1982 | + int32_t *dstU = (int32_t *) _dstU; |
| 1983 | + int32_t *dstV = (int32_t *) _dstV; |
| 1984 | + for (i = 0; i < width; i++) { |
| 1985 | + dstU[i] = (FFMIN(dstU[i],30775)*4663 - 9289992)>>12; //-264 |
| 1986 | + dstV[i] = (FFMIN(dstV[i],30775)*4663 - 9289992)>>12; //-264 |
| 1987 | + } |
| 1988 | +} |
| 1989 | +static void chrRangeFromJpeg16_c(int16_t *_dstU, int16_t *_dstV, int width) |
| 1990 | +{ |
| 1991 | + int i; |
| 1992 | + int32_t *dstU = (int32_t *) _dstU; |
| 1993 | + int32_t *dstV = (int32_t *) _dstV; |
| 1994 | + for (i = 0; i < width; i++) { |
| 1995 | + dstU[i] = (dstU[i]*1799 + 4081085)>>11; //1469 |
| 1996 | + dstV[i] = (dstV[i]*1799 + 4081085)>>11; //1469 |
| 1997 | + } |
| 1998 | +} |
| 1999 | +static void lumRangeToJpeg16_c(int16_t *_dst, int width) |
| 2000 | +{ |
| 2001 | + int i; |
| 2002 | + int32_t *dst = (int32_t *) _dst; |
| 2003 | + for (i = 0; i < width; i++) |
| 2004 | + dst[i] = (FFMIN(dst[i],30189)*19077 - 39057361)>>14; |
| 2005 | +} |
| 2006 | +static void lumRangeFromJpeg16_c(int16_t *_dst, int width) |
| 2007 | +{ |
| 2008 | + int i; |
| 2009 | + int32_t *dst = (int32_t *) _dst; |
| 2010 | + for (i = 0; i < width; i++) |
| 2011 | + dst[i] = (dst[i]*14071 + 33561947)>>14; |
| 2012 | +} |
| 2013 | + |
| 1854 | 2014 | static void hyscale_fast_c(SwsContext *c, int16_t *dst, int dstWidth, |
| 1855 | 2015 | const uint8_t *src, int srcW, int xInc) |
| 1856 | 2016 | { |
| @@ -1864,8 +2024,25 @@ static void hyscale_fast_c(SwsContext *c, int16_t *dst, int dstWidth, · 7 unmodified lines |
| 1864 | 2024 | } |
| 1865 | 2025 | } |
| 1866 | 2026 | |
| 2027 | +static void scale8To16Rv_c(uint16_t *_dst, const uint8_t *src, int len) |
| 2028 | +{ |
| 2029 | + int i; |
| 2030 | + uint8_t *dst = (uint8_t *) _dst; |
| 2031 | + for (i = len - 1; i >= 0; i--) { |
| 2032 | + dst[i * 2] = dst[i * 2 + 1] = src[i]; |
| 2033 | + } |
| 2034 | +} |
| 2035 | + |
| 2036 | +static void scale19To15Fw_c(int16_t *dst, const int32_t *src, int len) |
| 2037 | +{ |
| 2038 | + int i; |
| 2039 | + for (i = 0; i < len; i++) { |
| 2040 | + dst[i] = src[i] >> 4; |
| 2041 | + } |
| 2042 | +} |
| 2043 | + |
| 1867 | 2044 | // *** horizontal scale Y line to temp buffer |
| 1868 | | −static av_always_inline void hyscale(SwsContext *c, uint16_t *dst, int dstWidth, |
| 2045 | +static av_always_inline void hyscale(SwsContext *c, int16_t *dst, int dstWidth, |
| 1869 | 2046 | const uint8_t *src, int srcW, int xInc, |
| 1870 | 2047 | const int16_t *hLumFilter, |
| 1871 | 2048 | const int16_t *hLumFilterPos, int hLumFilterSize, |
| @@ -1880,6 +2057,11 @@ static av_always_inline void hyscale(SwsContext *c, uint16_t *dst, int dstWidth, · 8 unmodified lines |
| 1880 | 2057 | src= formatConvBuffer; |
| 1881 | 2058 | } |
| 1882 | 2059 | |
| 2060 | + if (av_pix_fmt_descriptors[c->srcFormat].comp[0].depth_minus1 < 8 && c->scalingBpp == 16) { |
| 2061 | + c->scale8To16Rv((uint16_t *) formatConvBuffer, src, srcW); |
| 2062 | + src = formatConvBuffer; |
| 2063 | + } |
| 2064 | + |
| 1883 | 2065 | if (!c->hyscale_fast) { |
| 1884 | 2066 | c->hScale(dst, dstWidth, src, hLumFilter, hLumFilterPos, hLumFilterSize); |
| 1885 | 2067 | } else { // fast bilinear upscale / crap downscale |
| @@ -1888,6 +2070,10 @@ static av_always_inline void hyscale(SwsContext *c, uint16_t *dst, int dstWidth, · 2 unmodified lines |
| 1888 | 2070 | |
| 1889 | 2071 | if (convertRange) |
| 1890 | 2072 | convertRange(dst, dstWidth); |
| 2073 | + |
| 2074 | + if (av_pix_fmt_descriptors[c->dstFormat].comp[0].depth_minus1 < 8 && c->scalingBpp == 16) { |
| 2075 | + c->scale19To15Fw(dst, (int32_t *) dst, dstWidth); |
| 2076 | + } |
| 1891 | 2077 | } |
| 1892 | 2078 | |
| 1893 | 2079 | static void hcscale_fast_c(SwsContext *c, int16_t *dst1, int16_t *dst2, |
| @@ -1905,19 +2091,27 @@ static void hcscale_fast_c(SwsContext *c, int16_t *dst1, int16_t *dst2, · 11 unmodified lines |
| 1905 | 2091 | } |
| 1906 | 2092 | } |
| 1907 | 2093 | |
| 1908 | | −static av_always_inline void hcscale(SwsContext *c, uint16_t *dst1, uint16_t *dst2, int dstWidth, |
| 2094 | +static av_always_inline void hcscale(SwsContext *c, int16_t *dst1, int16_t *dst2, int dstWidth, |
| 1909 | 2095 | const uint8_t *src1, const uint8_t *src2, |
| 1910 | 2096 | int srcW, int xInc, const int16_t *hChrFilter, |
| 1911 | 2097 | const int16_t *hChrFilterPos, int hChrFilterSize, |
| 1912 | 2098 | uint8_t *formatConvBuffer, uint32_t *pal) |
| 1913 | 2099 | { |
| 1914 | 2100 | if (c->chrToYV12) { |
| 1915 | | − uint8_t *buf2 = formatConvBuffer + FFALIGN(srcW, 16); |
| 2101 | + uint8_t *buf2 = formatConvBuffer + FFALIGN(srcW * c->scalingBpp >> 3, 16); |
| 1916 | 2102 | c->chrToYV12(formatConvBuffer, buf2, src1, src2, srcW, pal); |
| 1917 | 2103 | src1= formatConvBuffer; |
| 1918 | 2104 | src2= buf2; |
| 1919 | 2105 | } |
| 1920 | 2106 | |
| 2107 | + if (av_pix_fmt_descriptors[c->srcFormat].comp[0].depth_minus1 < 8 && c->scalingBpp == 16) { |
| 2108 | + uint8_t *buf2 = (formatConvBuffer + FFALIGN(srcW * 2, 16)); |
| 2109 | + c->scale8To16Rv((uint16_t *) formatConvBuffer, src1, srcW); |
| 2110 | + c->scale8To16Rv((uint16_t *) buf2, src2, srcW); |
| 2111 | + src1 = formatConvBuffer; |
| 2112 | + src2 = buf2; |
| 2113 | + } |
| 2114 | + |
| 1921 | 2115 | if (!c->hcscale_fast) { |
| 1922 | 2116 | c->hScale(dst1, dstWidth, src1, hChrFilter, hChrFilterPos, hChrFilterSize); |
| 1923 | 2117 | c->hScale(dst2, dstWidth, src2, hChrFilter, hChrFilterPos, hChrFilterSize); |
| @@ -1927,6 +2121,11 @@ static av_always_inline void hcscale(SwsContext *c, uint16_t *dst1, uint16_t *ds · 3 unmodified lines |
| 1927 | 2121 | |
| 1928 | 2122 | if (c->chrConvertRange) |
| 1929 | 2123 | c->chrConvertRange(dst1, dst2, dstWidth); |
| 2124 | + |
| 2125 | + if (av_pix_fmt_descriptors[c->dstFormat].comp[0].depth_minus1 < 8 && c->scalingBpp == 16) { |
| 2126 | + c->scale19To15Fw(dst1, (int32_t *) dst1, dstWidth); |
| 2127 | + c->scale19To15Fw(dst2, (int32_t *) dst2, dstWidth); |
| 2128 | + } |
| 1930 | 2129 | } |
| 1931 | 2130 | |
| 1932 | 2131 | static av_always_inline void |
| @@ -2049,20 +2248,20 @@ find_c_packed_planar_out_funcs(SwsContext *c, · 116 unmodified lines |
| 2049 | 2248 | *yuv2packedX = yuv2uyvy422_X_c; |
| 2050 | 2249 | break; |
| 2051 | 2250 | case PIX_FMT_RGB48LE: |
| 2052 | | − //*yuv2packed1 = yuv2rgb48le_1_c; |
| 2053 | | − //*yuv2packed2 = yuv2rgb48le_2_c; |
| 2054 | | − //*yuv2packedX = yuv2rgb48le_X_c; |
| 2055 | | − //break; |
| 2251 | + *yuv2packed1 = yuv2rgb48le_1_c; |
| 2252 | + *yuv2packed2 = yuv2rgb48le_2_c; |
| 2253 | + *yuv2packedX = yuv2rgb48le_X_c; |
| 2254 | + break; |
| 2056 | 2255 | case PIX_FMT_RGB48BE: |
| 2057 | 2256 | *yuv2packed1 = yuv2rgb48be_1_c; |
| 2058 | 2257 | *yuv2packed2 = yuv2rgb48be_2_c; |
| 2059 | 2258 | *yuv2packedX = yuv2rgb48be_X_c; |
| 2060 | 2259 | break; |
| 2061 | 2260 | case PIX_FMT_BGR48LE: |
| 2062 | | − //*yuv2packed1 = yuv2bgr48le_1_c; |
| 2063 | | − //*yuv2packed2 = yuv2bgr48le_2_c; |
| 2064 | | − //*yuv2packedX = yuv2bgr48le_X_c; |
| 2065 | | − //break; |
| 2261 | + *yuv2packed1 = yuv2bgr48le_1_c; |
| 2262 | + *yuv2packed2 = yuv2bgr48le_2_c; |
| 2263 | + *yuv2packedX = yuv2bgr48le_X_c; |
| 2264 | + break; |
| 2066 | 2265 | case PIX_FMT_BGR48BE: |
| 2067 | 2266 | *yuv2packed1 = yuv2bgr48be_1_c; |
| 2068 | 2267 | *yuv2packed2 = yuv2bgr48be_2_c; |
| @@ -2435,13 +2634,6 @@ static av_cold void sws_init_swScale_c(SwsContext *c) · 366 unmodified lines |
| 2435 | 2634 | &c->yuv2packed1, &c->yuv2packed2, |
| 2436 | 2635 | &c->yuv2packedX); |
| 2437 | 2636 | |
| 2438 | | − c->hScale = hScale_c; |
| 2439 | | − |
| 2440 | | − if (c->flags & SWS_FAST_BILINEAR) { |
| 2441 | | − c->hyscale_fast = hyscale_fast_c; |
| 2442 | | − c->hcscale_fast = hcscale_fast_c; |
| 2443 | | − } |
| 2444 | | − |
| 2445 | 2637 | c->chrToYV12 = NULL; |
| 2446 | 2638 | switch(srcFormat) { |
| 2447 | 2639 | case PIX_FMT_YUYV422 : c->chrToYV12 = yuy2ToUV_c; break; |
| @@ -2453,22 +2645,25 @@ static av_cold void sws_init_swScale_c(SwsContext *c) · 5 unmodified lines |
| 2453 | 2645 | case PIX_FMT_PAL8 : |
| 2454 | 2646 | case PIX_FMT_BGR4_BYTE: |
| 2455 | 2647 | case PIX_FMT_RGB4_BYTE: c->chrToYV12 = palToUV_c; break; |
| 2456 | | − case PIX_FMT_YUV444P9BE: |
| 2457 | | − case PIX_FMT_YUV420P9BE: c->chrToYV12 = BE9ToUV_c; break; |
| 2458 | 2648 | case PIX_FMT_YUV444P9LE: |
| 2459 | | − case PIX_FMT_YUV420P9LE: c->chrToYV12 = LE9ToUV_c; break; |
| 2460 | | − case PIX_FMT_YUV444P10BE: |
| 2461 | | − case PIX_FMT_YUV422P10BE: |
| 2462 | | − case PIX_FMT_YUV420P10BE: c->chrToYV12 = BE10ToUV_c; break; |
| 2649 | + case PIX_FMT_YUV420P9LE: c->chrToYV12 = LE9ToUV_c; break; |
| 2463 | 2650 | case PIX_FMT_YUV422P10LE: |
| 2464 | 2651 | case PIX_FMT_YUV444P10LE: |
| 2465 | 2652 | case PIX_FMT_YUV420P10LE: c->chrToYV12 = LE10ToUV_c; break; |
| 2466 | | − case PIX_FMT_YUV420P16BE: |
| 2467 | | − case PIX_FMT_YUV422P16BE: |
| 2468 | | − case PIX_FMT_YUV444P16BE: c->chrToYV12 = BEToUV_c; break; |
| 2653 | + case PIX_FMT_YUV444P9BE: |
| 2654 | + case PIX_FMT_YUV420P9BE: c->chrToYV12 = BE9ToUV_c; break; |
| 2655 | + case PIX_FMT_YUV444P10BE: |
| 2656 | + case PIX_FMT_YUV422P10BE: |
| 2657 | + case PIX_FMT_YUV420P10BE: c->chrToYV12 = BE10ToUV_c; break; |
| 2658 | +#if HAVE_BIGENDIAN |
| 2469 | 2659 | case PIX_FMT_YUV420P16LE: |
| 2470 | 2660 | case PIX_FMT_YUV422P16LE: |
| 2471 | | − case PIX_FMT_YUV444P16LE: c->chrToYV12 = LEToUV_c; break; |
| 2661 | + case PIX_FMT_YUV444P16LE: c->chrToYV12 = bswap16UV_c; break; |
| 2662 | +#else |
| 2663 | + case PIX_FMT_YUV420P16BE: |
| 2664 | + case PIX_FMT_YUV422P16BE: |
| 2665 | + case PIX_FMT_YUV444P16BE: c->chrToYV12 = bswap16UV_c; break; |
| 2666 | +#endif |
| 2472 | 2667 | } |
| 2473 | 2668 | if (c->chrSrcHSubSample) { |
| 2474 | 2669 | switch(srcFormat) { |
| @@ -2517,27 +2712,30 @@ static av_cold void sws_init_swScale_c(SwsContext *c) · 42 unmodified lines |
| 2517 | 2712 | c->lumToYV12 = NULL; |
| 2518 | 2713 | c->alpToYV12 = NULL; |
| 2519 | 2714 | switch (srcFormat) { |
| 2520 | | − case PIX_FMT_YUV444P9BE: |
| 2521 | | − case PIX_FMT_YUV420P9BE: c->lumToYV12 = BE9ToY_c; break; |
| 2522 | 2715 | case PIX_FMT_YUV444P9LE: |
| 2523 | | − case PIX_FMT_YUV420P9LE: c->lumToYV12 = LE9ToY_c; break; |
| 2524 | | − case PIX_FMT_YUV444P10BE: |
| 2525 | | − case PIX_FMT_YUV422P10BE: |
| 2526 | | − case PIX_FMT_YUV420P10BE: c->lumToYV12 = BE10ToY_c; break; |
| 2716 | + case PIX_FMT_YUV420P9LE: c->lumToYV12 = LE9ToY_c; break; |
| 2527 | 2717 | case PIX_FMT_YUV444P10LE: |
| 2528 | 2718 | case PIX_FMT_YUV422P10LE: |
| 2529 | 2719 | case PIX_FMT_YUV420P10LE: c->lumToYV12 = LE10ToY_c; break; |
| 2530 | | − case PIX_FMT_YUYV422 : |
| 2531 | | − case PIX_FMT_YUV420P16BE: |
| 2532 | | − case PIX_FMT_YUV422P16BE: |
| 2533 | | − case PIX_FMT_YUV444P16BE: |
| 2534 | | − case PIX_FMT_Y400A : |
| 2535 | | − case PIX_FMT_GRAY16BE : c->lumToYV12 = yuy2ToY_c; break; |
| 2536 | | − case PIX_FMT_UYVY422 : |
| 2720 | + case PIX_FMT_YUV444P9BE: |
| 2721 | + case PIX_FMT_YUV420P9BE: c->lumToYV12 = BE9ToY_c; break; |
| 2722 | + case PIX_FMT_YUV444P10BE: |
| 2723 | + case PIX_FMT_YUV422P10BE: |
| 2724 | + case PIX_FMT_YUV420P10BE: c->lumToYV12 = BE10ToY_c; break; |
| 2725 | +#if HAVE_BIGENDIAN |
| 2537 | 2726 | case PIX_FMT_YUV420P16LE: |
| 2538 | 2727 | case PIX_FMT_YUV422P16LE: |
| 2539 | 2728 | case PIX_FMT_YUV444P16LE: |
| 2540 | | − case PIX_FMT_GRAY16LE : c->lumToYV12 = uyvyToY_c; break; |
| 2729 | + case PIX_FMT_GRAY16LE: c->lumToYV12 = bswap16Y_c; break; |
| 2730 | +#else |
| 2731 | + case PIX_FMT_YUV420P16BE: |
| 2732 | + case PIX_FMT_YUV422P16BE: |
| 2733 | + case PIX_FMT_YUV444P16BE: |
| 2734 | + case PIX_FMT_GRAY16BE: c->lumToYV12 = bswap16Y_c; break; |
| 2735 | +#endif |
| 2736 | + case PIX_FMT_YUYV422 : |
| 2737 | + case PIX_FMT_Y400A : c->lumToYV12 = yuy2ToY_c; break; |
| 2738 | + case PIX_FMT_UYVY422 : c->lumToYV12 = uyvyToY_c; break; |
| 2541 | 2739 | case PIX_FMT_BGR24 : c->lumToYV12 = bgr24ToY_c; break; |
| 2542 | 2740 | case PIX_FMT_BGR565LE : c->lumToYV12 = bgr16leToY_c; break; |
| 2543 | 2741 | case PIX_FMT_BGR565BE : c->lumToYV12 = bgr16beToY_c; break; |
| @@ -2574,6 +2772,13 @@ static av_cold void sws_init_swScale_c(SwsContext *c) · 30 unmodified lines |
| 2574 | 2772 | } |
| 2575 | 2773 | } |
| 2576 | 2774 | |
| 2775 | + if (c->scalingBpp == 8) { |
| 2776 | + c->hScale = hScale_c; |
| 2777 | + if (c->flags & SWS_FAST_BILINEAR) { |
| 2778 | + c->hyscale_fast = hyscale_fast_c; |
| 2779 | + c->hcscale_fast = hcscale_fast_c; |
| 2780 | + } |
| 2781 | + |
| 2577 | 2782 | if (c->srcRange != c->dstRange && !isAnyRGB(c->dstFormat)) { |
| 2578 | 2783 | if (c->srcRange) { |
| 2579 | 2784 | c->lumConvertRange = lumRangeFromJpeg_c; |
| @@ -2583,6 +2788,21 @@ static av_cold void sws_init_swScale_c(SwsContext *c) · 3 unmodified lines |
| 2583 | 2788 | c->chrConvertRange = chrRangeToJpeg_c; |
| 2584 | 2789 | } |
| 2585 | 2790 | } |
| 2791 | + } else { |
| 2792 | + c->hScale = hScale16_c; |
| 2793 | + c->scale19To15Fw = scale19To15Fw_c; |
| 2794 | + c->scale8To16Rv = scale8To16Rv_c; |
| 2795 | + |
| 2796 | + if (c->srcRange != c->dstRange && !isAnyRGB(c->dstFormat)) { |
| 2797 | + if (c->srcRange) { |
| 2798 | + c->lumConvertRange = lumRangeFromJpeg16_c; |
| 2799 | + c->chrConvertRange = chrRangeFromJpeg16_c; |
| 2800 | + } else { |
| 2801 | + c->lumConvertRange = lumRangeToJpeg16_c; |
| 2802 | + c->chrConvertRange = chrRangeToJpeg16_c; |
| 2803 | + } |
| 2804 | + } |
| 2805 | + } |
| 2586 | 2806 | |
| 2587 | 2807 | if (!(isGray(srcFormat) || isGray(c->dstFormat) || |
| 2588 | 2808 | srcFormat == PIX_FMT_MONOBLACK || srcFormat == PIX_FMT_MONOWHITE)) |