History

swscale/input: add support for YAF16 and YAF32

James Almer committed 1 year ago

Commit 468577d1 parent 61fc9b63 files · +94 −1Browse files

Unified · Split

3 files
  1. libswscale/input.c +89 −0
  2. libswscale/utils.c +4 −0
  3. libswscale/version.h +1 −1
libswscale/input.c+89−0
@@ -1283,6 +1283,28 @@ static av_always_inline void grayf32ToY16_c(uint8_t *_dst, const uint8_t *_src, · 1282 unmodified lines
12831283 }
12841284 }
12851285
1286+static av_always_inline void read_yaf32_gray_c(uint8_t *_dst, const uint8_t *_src, const uint8_t *unused1,
1287+ const uint8_t *unused2, int width, int is_be, uint32_t *unused)
1288+{
1289+ int i;
1290+ const float *src = (const float *)_src;
1291+ uint16_t *dst = (uint16_t *)_dst;
1292+
1293+ for (i = 0; i < width; ++i)
1294+ dst[i] = lrintf(av_clipf(65535.0f * rdpx(src + i*2), 0.0f, 65535.0f));
1295+}
1296+
1297+static av_always_inline void read_yaf32_alpha_c(uint8_t *_dst, const uint8_t *_src, const uint8_t *unused1,
1298+ const uint8_t *unused2, int width, int is_be, uint32_t *unused)
1299+{
1300+ int i;
1301+ const float *src = (const float *)_src;
1302+ uint16_t *dst = (uint16_t *)_dst;
1303+
1304+ for (i = 0; i < width; ++i)
1305+ dst[i] = lrintf(av_clipf(65535.0f * rdpx(src + i*2 + 1), 0.0f, 65535.0f));
1306+}
1307+
12861308 #undef rdpx
12871309
12881310 #define rgb9plus_planar_funcs_endian(nbits, endian_name, endian) \
@@ -1363,6 +1385,18 @@ static void grayf32##endian_name##ToY16_c(uint8_t *dst, const uint8_t *src, · 74 unmodified lines
13631385 int width, uint32_t *unused, void *opq) \
13641386 { \
13651387 grayf32ToY16_c(dst, src, unused1, unused2, width, endian, unused); \
1388+} \
1389+static void read_yaf32##endian_name##_gray_c(uint8_t *dst, const uint8_t *src, \
1390+ const uint8_t *unused1, const uint8_t *unused2, \
1391+ int width, uint32_t *unused, void *opq) \
1392+{ \
1393+ read_yaf32_gray_c(dst, src, unused1, unused2, width, endian, unused); \
1394+} \
1395+static void read_yaf32##endian_name##_alpha_c(uint8_t *dst, const uint8_t *src, \
1396+ const uint8_t *unused1, const uint8_t *unused2, \
1397+ int width, uint32_t *unused, void *opq) \
1398+{ \
1399+ read_yaf32_alpha_c(dst, src, unused1, unused2, width, endian, unused); \
13661400 }
13671401
13681402 rgbf32_funcs_endian(le, 0)
@@ -1421,6 +1455,24 @@ static av_always_inline void grayf16ToY16_c(uint8_t *dst, const uint8_t *src, co · 52 unmodified lines
14211455 }
14221456 }
14231457
1458+static av_always_inline void read_yaf16_gray_c(uint8_t *_dst, const uint8_t *src, const uint8_t *unused1,
1459+ const uint8_t *unused2, int width, int is_be, uint32_t *unused, Half2FloatTables *h2f_tbl)
1460+{
1461+ uint16_t *dst = (uint16_t *)_dst;
1462+
1463+ for (int i = 0; i < width; i++)
1464+ dst[i] = lrintf(av_clipf(65535.0f * rdpx2(src + 4*i), 0.0f, 65535.0f));
1465+}
1466+
1467+static av_always_inline void read_yaf16_alpha_c(uint8_t *_dst, const uint8_t *src, const uint8_t *unused1,
1468+ const uint8_t *unused2, int width, int is_be, uint32_t *unused, Half2FloatTables *h2f_tbl)
1469+{
1470+ uint16_t *dst = (uint16_t *)_dst;
1471+
1472+ for (int i = 0; i < width; i++)
1473+ dst[i] = lrintf(av_clipf(65535.0f * rdpx2(src + 4*i + 2), 0.0f, 65535.0f));
1474+}
1475+
14241476 static av_always_inline void rgbaf16ToUV_half_endian(uint16_t *dstU, uint16_t *dstV, int is_be,
14251477 const uint16_t *src, int width,
14261478 int32_t *rgb2yuv, Half2FloatTables *h2f_tbl)
@@ -1557,6 +1609,19 @@ static void grayf16##endian_name##ToY16_c(uint8_t *dst, const uint8_t *src, · 130 unmodified lines
15571609 { \
15581610 grayf16ToY16_c(dst, src, unused1, unused2, width, endian, unused, opq); \
15591611 } \
1612+static void read_yaf16##endian_name##_gray_c(uint8_t *dst, const uint8_t *src, \
1613+ const uint8_t *unused1, const uint8_t *unused2, \
1614+ int width, uint32_t *unused, void *opq) \
1615+{ \
1616+ read_yaf16_gray_c(dst, src, unused1, unused2, width, endian, unused, opq); \
1617+} \
1618+static void read_yaf16##endian_name##_alpha_c(uint8_t *dst, const uint8_t *src, \
1619+ const uint8_t *unused1, const uint8_t *unused2, \
1620+ int width, uint32_t *unused, void *opq) \
1621+{ \
1622+ read_yaf16_alpha_c(dst, src, unused1, unused2, width, endian, unused, opq); \
1623+} \
1624+ \
15601625 static void rgbaf16##endian_name##ToUV_half_c(uint8_t *_dstU, uint8_t *_dstV, const uint8_t *unused, \
15611626 const uint8_t *src1, const uint8_t *src2, \
15621627 int width, uint32_t *_rgb2yuv, void *opq) \
@@ -2244,6 +2309,12 @@ av_cold void ff_sws_init_input_funcs(SwsInternal *c, · 681 unmodified lines
22442309 case AV_PIX_FMT_YA16BE:
22452310 *lumToYV12 = read_ya16be_gray_c;
22462311 break;
2312+ case AV_PIX_FMT_YAF16LE:
2313+ *lumToYV12 = read_yaf16le_gray_c;
2314+ break;
2315+ case AV_PIX_FMT_YAF16BE:
2316+ *lumToYV12 = read_yaf16be_gray_c;
2317+ break;
22472318 case AV_PIX_FMT_VUYA:
22482319 case AV_PIX_FMT_VUYX:
22492320 *lumToYV12 = read_vuyx_Y_c;
@@ -2400,6 +2471,12 @@ av_cold void ff_sws_init_input_funcs(SwsInternal *c, · 150 unmodified lines
24002471 case AV_PIX_FMT_GRAYF32BE:
24012472 *lumToYV12 = grayf32beToY16_c;
24022473 break;
2474+ case AV_PIX_FMT_YAF32LE:
2475+ *lumToYV12 = read_yaf32le_gray_c;
2476+ break;
2477+ case AV_PIX_FMT_YAF32BE:
2478+ *lumToYV12 = read_yaf32be_gray_c;
2479+ break;
24032480 case AV_PIX_FMT_GRAYF16LE:
24042481 *lumToYV12 = grayf16leToY16_c;
24052482 break;
@@ -2473,6 +2550,18 @@ av_cold void ff_sws_init_input_funcs(SwsInternal *c, · 67 unmodified lines
24732550 case AV_PIX_FMT_YA16BE:
24742551 *alpToYV12 = read_ya16be_alpha_c;
24752552 break;
2553+ case AV_PIX_FMT_YAF16LE:
2554+ *alpToYV12 = read_yaf16le_alpha_c;
2555+ break;
2556+ case AV_PIX_FMT_YAF16BE:
2557+ *alpToYV12 = read_yaf16be_alpha_c;
2558+ break;
2559+ case AV_PIX_FMT_YAF32LE:
2560+ *alpToYV12 = read_yaf32le_alpha_c;
2561+ break;
2562+ case AV_PIX_FMT_YAF32BE:
2563+ *alpToYV12 = read_yaf32be_alpha_c;
2564+ break;
24762565 case AV_PIX_FMT_VUYA:
24772566 case AV_PIX_FMT_UYVA:
24782567 *alpToYV12 = read_vuya_A_c;
libswscale/utils.c+4−0
@@ -252,6 +252,10 @@ static const FormatEntry format_entries[] = { · 251 unmodified lines
252252 [AV_PIX_FMT_GRAYF32BE] = { 1, 1 },
253253 [AV_PIX_FMT_GRAYF16LE] = { 1, 0 },
254254 [AV_PIX_FMT_GRAYF16BE] = { 1, 0 },
255+ [AV_PIX_FMT_YAF32LE] = { 1, 0 },
256+ [AV_PIX_FMT_YAF32BE] = { 1, 0 },
257+ [AV_PIX_FMT_YAF16LE] = { 1, 0 },
258+ [AV_PIX_FMT_YAF16BE] = { 1, 0 },
255259 [AV_PIX_FMT_YUVA422P12BE] = { 1, 1 },
256260 [AV_PIX_FMT_YUVA422P12LE] = { 1, 1 },
257261 [AV_PIX_FMT_YUVA444P12BE] = { 1, 1 },
libswscale/version.h+1−1
@@ -29,7 +29,7 @@ · 28 unmodified lines
2929 #include "version_major.h"
3030
3131 #define LIBSWSCALE_VERSION_MINOR 13
32−#define LIBSWSCALE_VERSION_MICRO 100
32+#define LIBSWSCALE_VERSION_MICRO 101
3333
3434 #define LIBSWSCALE_VERSION_INT AV_VERSION_INT(LIBSWSCALE_VERSION_MAJOR, \
3535 LIBSWSCALE_VERSION_MINOR, \

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