Unified · Split
| @@ -425,3 +425,61 @@ void rgb48to64_ ## need_bswap(const uint8_t *src, \ · 424 unmodified lines | ||
| 425 | 425 | |
| 426 | 426 | DEFINE_RGB48TO64(nobswap, 0) |
| 427 | 427 | DEFINE_RGB48TO64(bswap, 1) |
| 428 | + | |
| 429 | +#define DEFINE_X2RGB10TO16(need_bswap, swap, bits, alpha) \ | |
| 430 | +void x2rgb10to ## bits ## _ ## need_bswap(const uint8_t *src, \ | |
| 431 | + uint8_t *dst, int src_size) \ | |
| 432 | +{ \ | |
| 433 | + uint16_t *d = (uint16_t *)dst; \ | |
| 434 | + const uint32_t *s = (const uint32_t *)src; \ | |
| 435 | + int i, num_pixels = src_size >> 2; \ | |
| 436 | + unsigned component; \ | |
| 437 | + \ | |
| 438 | + for (i = 0; i < num_pixels; i++) { \ | |
| 439 | + unsigned p = AV_RL32(s + i); \ | |
| 440 | + component = (p >> 20) & 0x3FF; \ | |
| 441 | + d[(3 + alpha) * i + 0] = swap ? av_bswap16(component << 6 | component >> 4) \ | |
| 442 | + : component << 6 | component >> 4; \ | |
| 443 | + component = (p >> 10) & 0x3FF; \ | |
| 444 | + d[(3 + alpha) * i + 1] = swap ? av_bswap16(component << 6 | component >> 4) \ | |
| 445 | + : component << 6 | component >> 4; \ | |
| 446 | + component = p & 0x3FF; \ | |
| 447 | + d[(3 + alpha) * i + 2] = swap ? av_bswap16(component << 6 | component >> 4) \ | |
| 448 | + : component << 6 | component >> 4; \ | |
| 449 | + if (alpha) d[(3 + alpha) * i + 3] = 0xffff; \ | |
| 450 | + } \ | |
| 451 | +} | |
| 452 | + | |
| 453 | +DEFINE_X2RGB10TO16(nobswap, 0, 48, 0) | |
| 454 | +DEFINE_X2RGB10TO16(bswap, 1, 48, 0) | |
| 455 | +DEFINE_X2RGB10TO16(nobswap, 0, 64, 1) | |
| 456 | +DEFINE_X2RGB10TO16(bswap, 1, 64, 1) | |
| 457 | + | |
| 458 | +#define DEFINE_X2RGB10TOBGR16(need_bswap, swap, bits, alpha) \ | |
| 459 | +void x2rgb10tobgr ## bits ## _ ## need_bswap(const uint8_t *src, \ | |
| 460 | + uint8_t *dst, int src_size) \ | |
| 461 | +{ \ | |
| 462 | + uint16_t *d = (uint16_t *)dst; \ | |
| 463 | + const uint32_t *s = (const uint32_t *)src; \ | |
| 464 | + int i, num_pixels = src_size >> 2; \ | |
| 465 | + unsigned component; \ | |
| 466 | + \ | |
| 467 | + for (i = 0; i < num_pixels; i++) { \ | |
| 468 | + unsigned p = AV_RL32(s + i); \ | |
| 469 | + component = p & 0x3FF; \ | |
| 470 | + d[(3 + alpha) * i + 0] = swap ? av_bswap16(component << 6 | component >> 4) \ | |
| 471 | + : component << 6 | component >> 4; \ | |
| 472 | + component = (p >> 10) & 0x3FF; \ | |
| 473 | + d[(3 + alpha) * i + 1] = swap ? av_bswap16(component << 6 | component >> 4) \ | |
| 474 | + : component << 6 | component >> 4; \ | |
| 475 | + component = (p >> 20) & 0x3FF; \ | |
| 476 | + d[(3 + alpha) * i + 2] = swap ? av_bswap16(component << 6 | component >> 4) \ | |
| 477 | + : component << 6 | component >> 4; \ | |
| 478 | + if (alpha) d[(3 + alpha) * i + 3] = 0xffff; \ | |
| 479 | + } \ | |
| 480 | +} | |
| 481 | + | |
| 482 | +DEFINE_X2RGB10TOBGR16(nobswap, 0, 48, 0) | |
| 483 | +DEFINE_X2RGB10TOBGR16(bswap, 1, 48, 0) | |
| 484 | +DEFINE_X2RGB10TOBGR16(nobswap, 0, 64, 1) | |
| 485 | +DEFINE_X2RGB10TOBGR16(bswap, 1, 64, 1) | |
| @@ -80,6 +80,15 @@ void rgb15tobgr15(const uint8_t *src, uint8_t *dst, int src_size); · 79 unmodified lines | ||
| 80 | 80 | void rgb12tobgr12(const uint8_t *src, uint8_t *dst, int src_size); |
| 81 | 81 | void rgb12to15(const uint8_t *src, uint8_t *dst, int src_size); |
| 82 | 82 | |
| 83 | +void x2rgb10to48_nobswap(const uint8_t *src, uint8_t *dst, int src_size); | |
| 84 | +void x2rgb10to48_bswap(const uint8_t *src, uint8_t *dst, int src_size); | |
| 85 | +void x2rgb10tobgr48_nobswap(const uint8_t *src, uint8_t *dst, int src_size); | |
| 86 | +void x2rgb10tobgr48_bswap(const uint8_t *src, uint8_t *dst, int src_size); | |
| 87 | +void x2rgb10to64_nobswap(const uint8_t *src, uint8_t *dst, int src_size); | |
| 88 | +void x2rgb10to64_bswap(const uint8_t *src, uint8_t *dst, int src_size); | |
| 89 | +void x2rgb10tobgr64_nobswap(const uint8_t *src, uint8_t *dst, int src_size); | |
| 90 | +void x2rgb10tobgr64_bswap(const uint8_t *src, uint8_t *dst, int src_size); | |
| 91 | + | |
| 83 | 92 | void ff_rgb24toyv12_c(const uint8_t *src, uint8_t *ydst, uint8_t *udst, |
| 84 | 93 | uint8_t *vdst, int width, int height, int lumStride, |
| 85 | 94 | int chromStride, int srcStride, const int32_t *rgb2yuv); |
| @@ -1742,6 +1742,11 @@ static int bayer_to_yv12_wrapper(SwsInternal *c, const uint8_t *const src[], · 1741 unmodified lines | ||
| 1742 | 1742 | || (x) == AV_PIX_FMT_UYVA \ |
| 1743 | 1743 | ) |
| 1744 | 1744 | |
| 1745 | +#define isX2RGB(x) ( \ | |
| 1746 | + (x) == AV_PIX_FMT_X2RGB10LE \ | |
| 1747 | + || (x) == AV_PIX_FMT_X2BGR10LE \ | |
| 1748 | + ) | |
| 1749 | + | |
| 1745 | 1750 | /* {RGB,BGR}{15,16,24,32,32_1} -> {RGB,BGR}{15,16,24,32} */ |
| 1746 | 1751 | typedef void (* rgbConvFn) (const uint8_t *, uint8_t *, int); |
| 1747 | 1752 | static rgbConvFn findRgbConvFn(SwsInternal *c) |
| @@ -1814,6 +1819,31 @@ static rgbConvFn findRgbConvFn(SwsInternal *c) · 66 unmodified lines | ||
| 1814 | 1819 | || CONV_IS(BGRA64LE, BGR48BE) |
| 1815 | 1820 | || CONV_IS(RGBA64BE, RGB48LE) |
| 1816 | 1821 | || CONV_IS(BGRA64BE, BGR48LE)) conv = rgb64to48_bswap; |
| 1822 | + } else if (isX2RGB(srcFormat) && isRGB48(dstFormat)) { | |
| 1823 | + if (CONV_IS(X2RGB10LE, RGB48LE) | |
| 1824 | + || CONV_IS(X2BGR10LE, BGR48LE)) conv = HAVE_BIGENDIAN ? x2rgb10to48_bswap | |
| 1825 | + : x2rgb10to48_nobswap; | |
| 1826 | + else if (CONV_IS(X2RGB10LE, RGB48BE) | |
| 1827 | + || CONV_IS(X2BGR10LE, BGR48BE)) conv = HAVE_BIGENDIAN ? x2rgb10to48_nobswap | |
| 1828 | + : x2rgb10to48_bswap; | |
| 1829 | + else if (CONV_IS(X2RGB10LE, BGR48LE) | |
| 1830 | + || CONV_IS(X2BGR10LE, RGB48LE)) conv = HAVE_BIGENDIAN ? x2rgb10tobgr48_bswap | |
| 1831 | + : x2rgb10tobgr48_nobswap; | |
| 1832 | + else if (CONV_IS(X2RGB10LE, BGR48BE) | |
| 1833 | + || CONV_IS(X2BGR10LE, RGB48BE)) conv = HAVE_BIGENDIAN ? x2rgb10tobgr48_nobswap | |
| 1834 | + : x2rgb10tobgr48_bswap; | |
| 1835 | + else if (CONV_IS(X2RGB10LE, RGBA64LE) | |
| 1836 | + || CONV_IS(X2BGR10LE, BGRA64LE)) conv = HAVE_BIGENDIAN ? x2rgb10to64_bswap | |
| 1837 | + : x2rgb10to64_nobswap; | |
| 1838 | + else if (CONV_IS(X2RGB10LE, RGBA64BE) | |
| 1839 | + || CONV_IS(X2BGR10LE, BGRA64BE)) conv = HAVE_BIGENDIAN ? x2rgb10to64_nobswap | |
| 1840 | + : x2rgb10to64_bswap; | |
| 1841 | + else if (CONV_IS(X2RGB10LE, BGRA64LE) | |
| 1842 | + || CONV_IS(X2BGR10LE, RGBA64LE)) conv = HAVE_BIGENDIAN ? x2rgb10tobgr64_bswap | |
| 1843 | + : x2rgb10tobgr64_nobswap; | |
| 1844 | + else if (CONV_IS(X2RGB10LE, BGRA64BE) | |
| 1845 | + || CONV_IS(X2BGR10LE, RGBA64BE)) conv = HAVE_BIGENDIAN ? x2rgb10tobgr64_nobswap | |
| 1846 | + : x2rgb10tobgr64_bswap; | |
| 1817 | 1847 | } else if (isAYUV(srcFormat) && isAYUV(dstFormat)) { |
| 1818 | 1848 | /* VUYX only for dst, to avoid copying undefined bytes */ |
| 1819 | 1849 | if ( CONV_IS(AYUV, VUYA) |