History

swscale/swscale_unscaled: add unscaled conversion for AYUV/VUYA/UYVA

James Almer committed 2 years ago

Commit a686d341 parent d6b2d084 files · +37 −0Browse files

Unified · Split

4 files
  1. libswscale/rgb2rgb.c +4 −0
  2. libswscale/rgb2rgb.h +4 −0
  3. libswscale/rgb2rgb_template.c +8 −0
  4. libswscale/swscale_unscaled.c +21 −0
libswscale/rgb2rgb.c+4−0
@@ -56,6 +56,10 @@ void (*shuffle_bytes_2103)(const uint8_t *src, uint8_t *dst, int src_size); · 55 unmodified lines
56void (*shuffle_bytes_1230)(const uint8_t *src, uint8_t *dst, int src_size);56void (*shuffle_bytes_1230)(const uint8_t *src, uint8_t *dst, int src_size);
57void (*shuffle_bytes_3012)(const uint8_t *src, uint8_t *dst, int src_size);57void (*shuffle_bytes_3012)(const uint8_t *src, uint8_t *dst, int src_size);
58void (*shuffle_bytes_3210)(const uint8_t *src, uint8_t *dst, int src_size);58void (*shuffle_bytes_3210)(const uint8_t *src, uint8_t *dst, int src_size);
59void (*shuffle_bytes_3102)(const uint8_t *src, uint8_t *dst, int src_size);
60void (*shuffle_bytes_2013)(const uint8_t *src, uint8_t *dst, int src_size);
61void (*shuffle_bytes_2130)(const uint8_t *src, uint8_t *dst, int src_size);
62void (*shuffle_bytes_1203)(const uint8_t *src, uint8_t *dst, int src_size);
59 63
60 64
61void (*yv12toyuy2)(const uint8_t *ysrc, const uint8_t *usrc,65void (*yv12toyuy2)(const uint8_t *ysrc, const uint8_t *usrc,
libswscale/rgb2rgb.h+4−0
@@ -52,6 +52,10 @@ extern void (*shuffle_bytes_2103)(const uint8_t *src, uint8_t *dst, int src_size · 51 unmodified lines
52extern void (*shuffle_bytes_1230)(const uint8_t *src, uint8_t *dst, int src_size);52extern void (*shuffle_bytes_1230)(const uint8_t *src, uint8_t *dst, int src_size);
53extern void (*shuffle_bytes_3012)(const uint8_t *src, uint8_t *dst, int src_size);53extern void (*shuffle_bytes_3012)(const uint8_t *src, uint8_t *dst, int src_size);
54extern void (*shuffle_bytes_3210)(const uint8_t *src, uint8_t *dst, int src_size);54extern void (*shuffle_bytes_3210)(const uint8_t *src, uint8_t *dst, int src_size);
55extern void (*shuffle_bytes_3102)(const uint8_t *src, uint8_t *dst, int src_size);
56extern void (*shuffle_bytes_2013)(const uint8_t *src, uint8_t *dst, int src_size);
57extern void (*shuffle_bytes_2130)(const uint8_t *src, uint8_t *dst, int src_size);
58extern void (*shuffle_bytes_1203)(const uint8_t *src, uint8_t *dst, int src_size);
55 59
56void rgb64tobgr48_nobswap(const uint8_t *src, uint8_t *dst, int src_size);60void rgb64tobgr48_nobswap(const uint8_t *src, uint8_t *dst, int src_size);
57void rgb64tobgr48_bswap(const uint8_t *src, uint8_t *dst, int src_size);61void rgb64tobgr48_bswap(const uint8_t *src, uint8_t *dst, int src_size);
libswscale/rgb2rgb_template.c+8−0
@@ -359,6 +359,10 @@ static void shuffle_bytes_##name (const uint8_t *src, \ · 358 unmodified lines
359DEFINE_SHUFFLE_BYTES(1230_c, 1, 2, 3, 0)359DEFINE_SHUFFLE_BYTES(1230_c, 1, 2, 3, 0)
360DEFINE_SHUFFLE_BYTES(3012_c, 3, 0, 1, 2)360DEFINE_SHUFFLE_BYTES(3012_c, 3, 0, 1, 2)
361DEFINE_SHUFFLE_BYTES(3210_c, 3, 2, 1, 0)361DEFINE_SHUFFLE_BYTES(3210_c, 3, 2, 1, 0)
362DEFINE_SHUFFLE_BYTES(3102_c, 3, 1, 0, 2)
363DEFINE_SHUFFLE_BYTES(2013_c, 2, 0, 1, 3)
364DEFINE_SHUFFLE_BYTES(2130_c, 2, 1, 3, 0)
365DEFINE_SHUFFLE_BYTES(1203_c, 1, 2, 0, 3)
362 366
363static inline void rgb24tobgr24_c(const uint8_t *src, uint8_t *dst, int src_size)367static inline void rgb24tobgr24_c(const uint8_t *src, uint8_t *dst, int src_size)
364{368{
@@ -970,6 +974,10 @@ static av_cold void rgb2rgb_init_c(void) · 605 unmodified lines
970 shuffle_bytes_1230 = shuffle_bytes_1230_c;974 shuffle_bytes_1230 = shuffle_bytes_1230_c;
971 shuffle_bytes_3012 = shuffle_bytes_3012_c;975 shuffle_bytes_3012 = shuffle_bytes_3012_c;
972 shuffle_bytes_3210 = shuffle_bytes_3210_c;976 shuffle_bytes_3210 = shuffle_bytes_3210_c;
977 shuffle_bytes_3102 = shuffle_bytes_3102_c;
978 shuffle_bytes_2013 = shuffle_bytes_2013_c;
979 shuffle_bytes_2130 = shuffle_bytes_2130_c;
980 shuffle_bytes_1203 = shuffle_bytes_1203_c;
973 rgb32tobgr16 = rgb32tobgr16_c;981 rgb32tobgr16 = rgb32tobgr16_c;
974 rgb32tobgr15 = rgb32tobgr15_c;982 rgb32tobgr15 = rgb32tobgr15_c;
975 yv12toyuy2 = yv12toyuy2_c;983 yv12toyuy2 = yv12toyuy2_c;
libswscale/swscale_unscaled.c+21−0
@@ -1497,6 +1497,13 @@ static int bayer_to_yv12_wrapper(SwsInternal *c, const uint8_t *const src[], · 1496 unmodified lines
1497 || (x) == AV_PIX_FMT_BGR48BE \1497 || (x) == AV_PIX_FMT_BGR48BE \
1498 )1498 )
1499 1499
1500#define isAYUV(x) ( \
1501 (x) == AV_PIX_FMT_AYUV \
1502 || (x) == AV_PIX_FMT_VUYA \
1503 || (x) == AV_PIX_FMT_VUYX \
1504 || (x) == AV_PIX_FMT_UYVA \
1505 )
1506
1500/* {RGB,BGR}{15,16,24,32,32_1} -> {RGB,BGR}{15,16,24,32} */1507/* {RGB,BGR}{15,16,24,32,32_1} -> {RGB,BGR}{15,16,24,32} */
1501typedef void (* rgbConvFn) (const uint8_t *, uint8_t *, int);1508typedef void (* rgbConvFn) (const uint8_t *, uint8_t *, int);
1502static rgbConvFn findRgbConvFn(SwsInternal *c)1509static rgbConvFn findRgbConvFn(SwsInternal *c)
@@ -1569,6 +1576,16 @@ static rgbConvFn findRgbConvFn(SwsInternal *c) · 66 unmodified lines
1569 || CONV_IS(BGRA64LE, BGR48BE)1576 || CONV_IS(BGRA64LE, BGR48BE)
1570 || CONV_IS(RGBA64BE, RGB48LE)1577 || CONV_IS(RGBA64BE, RGB48LE)
1571 || CONV_IS(BGRA64BE, BGR48LE)) conv = rgb64to48_bswap;1578 || CONV_IS(BGRA64BE, BGR48LE)) conv = rgb64to48_bswap;
1579 } else if (isAYUV(srcFormat) && isAYUV(dstFormat)) {
1580 /* VUYX only for dst, to avoid copying undefined bytes */
1581 if ( CONV_IS(AYUV, VUYA)
1582 || CONV_IS(AYUV, VUYX)
1583 || CONV_IS(VUYA, AYUV)) conv = shuffle_bytes_3210;
1584 else if (CONV_IS(AYUV, UYVA)) conv = shuffle_bytes_2130;
1585 else if (CONV_IS(VUYA, UYVA)) conv = shuffle_bytes_1203;
1586 else if (CONV_IS(UYVA, AYUV)) conv = shuffle_bytes_3102;
1587 else if (CONV_IS(UYVA, VUYA)
1588 || CONV_IS(UYVA, VUYX)) conv = shuffle_bytes_2013;
1572 } else1589 } else
1573 /* BGR -> BGR */1590 /* BGR -> BGR */
1574 if ((isBGRinInt(srcFormat) && isBGRinInt(dstFormat)) ||1591 if ((isBGRinInt(srcFormat) && isBGRinInt(dstFormat)) ||
@@ -2086,6 +2103,10 @@ void ff_get_unscaled_swscale(SwsInternal *c) · 511 unmodified lines
2086 !(flags & SWS_ACCURATE_RND) && !(dstW&1))2103 !(flags & SWS_ACCURATE_RND) && !(dstW&1))
2087 c->convert_unscaled = bgr24ToYv12Wrapper;2104 c->convert_unscaled = bgr24ToYv12Wrapper;
2088 2105
2106 /* AYUV/VUYA/UYVA -> AYUV/VUYA/UYVA */
2107 if (isAYUV(srcFormat) && isAYUV(dstFormat) && findRgbConvFn(c))
2108 c->convert_unscaled = rgbToRgbWrapper;
2109
2089 /* RGB/BGR -> RGB/BGR (no dither needed forms) */2110 /* RGB/BGR -> RGB/BGR (no dither needed forms) */
2090 if (isAnyRGB(srcFormat) && isAnyRGB(dstFormat) && findRgbConvFn(c)2111 if (isAnyRGB(srcFormat) && isAnyRGB(dstFormat) && findRgbConvFn(c)
2091 && (!needsDither || (c->flags&(SWS_FAST_BILINEAR|SWS_POINT))))2112 && (!needsDither || (c->flags&(SWS_FAST_BILINEAR|SWS_POINT))))

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