History

swscale/swscale_unscaled: add unscaled x2rgb10le to packed RGB

James Almer committed 2 years ago

Commit e7382b41 parent ae8ef643 files · +97 −0Browse files

Unified · Split

3 files
  1. libswscale/rgb2rgb.c +58 −0
  2. libswscale/rgb2rgb.h +9 −0
  3. libswscale/swscale_unscaled.c +30 −0
libswscale/rgb2rgb.c+58−0
@@ -425,3 +425,61 @@ void rgb48to64_ ## need_bswap(const uint8_t *src, \ · 424 unmodified lines
425 425
426DEFINE_RGB48TO64(nobswap, 0)426DEFINE_RGB48TO64(nobswap, 0)
427DEFINE_RGB48TO64(bswap, 1)427DEFINE_RGB48TO64(bswap, 1)
428
429#define DEFINE_X2RGB10TO16(need_bswap, swap, bits, alpha) \
430void 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
453DEFINE_X2RGB10TO16(nobswap, 0, 48, 0)
454DEFINE_X2RGB10TO16(bswap, 1, 48, 0)
455DEFINE_X2RGB10TO16(nobswap, 0, 64, 1)
456DEFINE_X2RGB10TO16(bswap, 1, 64, 1)
457
458#define DEFINE_X2RGB10TOBGR16(need_bswap, swap, bits, alpha) \
459void 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
482DEFINE_X2RGB10TOBGR16(nobswap, 0, 48, 0)
483DEFINE_X2RGB10TOBGR16(bswap, 1, 48, 0)
484DEFINE_X2RGB10TOBGR16(nobswap, 0, 64, 1)
485DEFINE_X2RGB10TOBGR16(bswap, 1, 64, 1)
libswscale/rgb2rgb.h+9−0
@@ -80,6 +80,15 @@ void rgb15tobgr15(const uint8_t *src, uint8_t *dst, int src_size); · 79 unmodified lines
80void rgb12tobgr12(const uint8_t *src, uint8_t *dst, int src_size);80void rgb12tobgr12(const uint8_t *src, uint8_t *dst, int src_size);
81void rgb12to15(const uint8_t *src, uint8_t *dst, int src_size);81void rgb12to15(const uint8_t *src, uint8_t *dst, int src_size);
82 82
83void x2rgb10to48_nobswap(const uint8_t *src, uint8_t *dst, int src_size);
84void x2rgb10to48_bswap(const uint8_t *src, uint8_t *dst, int src_size);
85void x2rgb10tobgr48_nobswap(const uint8_t *src, uint8_t *dst, int src_size);
86void x2rgb10tobgr48_bswap(const uint8_t *src, uint8_t *dst, int src_size);
87void x2rgb10to64_nobswap(const uint8_t *src, uint8_t *dst, int src_size);
88void x2rgb10to64_bswap(const uint8_t *src, uint8_t *dst, int src_size);
89void x2rgb10tobgr64_nobswap(const uint8_t *src, uint8_t *dst, int src_size);
90void x2rgb10tobgr64_bswap(const uint8_t *src, uint8_t *dst, int src_size);
91
83void ff_rgb24toyv12_c(const uint8_t *src, uint8_t *ydst, uint8_t *udst,92void ff_rgb24toyv12_c(const uint8_t *src, uint8_t *ydst, uint8_t *udst,
84 uint8_t *vdst, int width, int height, int lumStride,93 uint8_t *vdst, int width, int height, int lumStride,
85 int chromStride, int srcStride, const int32_t *rgb2yuv);94 int chromStride, int srcStride, const int32_t *rgb2yuv);
libswscale/swscale_unscaled.c+30−0
@@ -1742,6 +1742,11 @@ static int bayer_to_yv12_wrapper(SwsInternal *c, const uint8_t *const src[], · 1741 unmodified lines
1742 || (x) == AV_PIX_FMT_UYVA \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/* {RGB,BGR}{15,16,24,32,32_1} -> {RGB,BGR}{15,16,24,32} */1750/* {RGB,BGR}{15,16,24,32,32_1} -> {RGB,BGR}{15,16,24,32} */
1746typedef void (* rgbConvFn) (const uint8_t *, uint8_t *, int);1751typedef void (* rgbConvFn) (const uint8_t *, uint8_t *, int);
1747static rgbConvFn findRgbConvFn(SwsInternal *c)1752static rgbConvFn findRgbConvFn(SwsInternal *c)
@@ -1814,6 +1819,31 @@ static rgbConvFn findRgbConvFn(SwsInternal *c) · 66 unmodified lines
1814 || CONV_IS(BGRA64LE, BGR48BE)1819 || CONV_IS(BGRA64LE, BGR48BE)
1815 || CONV_IS(RGBA64BE, RGB48LE)1820 || CONV_IS(RGBA64BE, RGB48LE)
1816 || CONV_IS(BGRA64BE, BGR48LE)) conv = rgb64to48_bswap;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 } else if (isAYUV(srcFormat) && isAYUV(dstFormat)) {1847 } else if (isAYUV(srcFormat) && isAYUV(dstFormat)) {
1818 /* VUYX only for dst, to avoid copying undefined bytes */1848 /* VUYX only for dst, to avoid copying undefined bytes */
1819 if ( CONV_IS(AYUV, VUYA)1849 if ( CONV_IS(AYUV, VUYA)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t