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
1283 }1283 }
1284}1284}
1285 1285
1286static 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
1297static 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
1286#undef rdpx1308#undef rdpx
1287 1309
1288#define rgb9plus_planar_funcs_endian(nbits, endian_name, endian) \1310#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
1363 int width, uint32_t *unused, void *opq) \1385 int width, uint32_t *unused, void *opq) \
1364{ \1386{ \
1365 grayf32ToY16_c(dst, src, unused1, unused2, width, endian, unused); \1387 grayf32ToY16_c(dst, src, unused1, unused2, width, endian, unused); \
1388} \
1389static 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} \
1395static 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); \
1366}1400}
1367 1401
1368rgbf32_funcs_endian(le, 0)1402rgbf32_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
1421 }1455 }
1422}1456}
1423 1457
1458static 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
1467static 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
1424static av_always_inline void rgbaf16ToUV_half_endian(uint16_t *dstU, uint16_t *dstV, int is_be,1476static av_always_inline void rgbaf16ToUV_half_endian(uint16_t *dstU, uint16_t *dstV, int is_be,
1425 const uint16_t *src, int width,1477 const uint16_t *src, int width,
1426 int32_t *rgb2yuv, Half2FloatTables *h2f_tbl)1478 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
1557{ \1609{ \
1558 grayf16ToY16_c(dst, src, unused1, unused2, width, endian, unused, opq); \1610 grayf16ToY16_c(dst, src, unused1, unused2, width, endian, unused, opq); \
1559} \1611} \
1612static 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} \
1618static 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 \
1560static void rgbaf16##endian_name##ToUV_half_c(uint8_t *_dstU, uint8_t *_dstV, const uint8_t *unused, \1625static void rgbaf16##endian_name##ToUV_half_c(uint8_t *_dstU, uint8_t *_dstV, const uint8_t *unused, \
1561 const uint8_t *src1, const uint8_t *src2, \1626 const uint8_t *src1, const uint8_t *src2, \
1562 int width, uint32_t *_rgb2yuv, void *opq) \1627 int width, uint32_t *_rgb2yuv, void *opq) \
@@ -2244,6 +2309,12 @@ av_cold void ff_sws_init_input_funcs(SwsInternal *c, · 681 unmodified lines
2244 case AV_PIX_FMT_YA16BE:2309 case AV_PIX_FMT_YA16BE:
2245 *lumToYV12 = read_ya16be_gray_c;2310 *lumToYV12 = read_ya16be_gray_c;
2246 break;2311 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;
2247 case AV_PIX_FMT_VUYA:2318 case AV_PIX_FMT_VUYA:
2248 case AV_PIX_FMT_VUYX:2319 case AV_PIX_FMT_VUYX:
2249 *lumToYV12 = read_vuyx_Y_c;2320 *lumToYV12 = read_vuyx_Y_c;
@@ -2400,6 +2471,12 @@ av_cold void ff_sws_init_input_funcs(SwsInternal *c, · 150 unmodified lines
2400 case AV_PIX_FMT_GRAYF32BE:2471 case AV_PIX_FMT_GRAYF32BE:
2401 *lumToYV12 = grayf32beToY16_c;2472 *lumToYV12 = grayf32beToY16_c;
2402 break;2473 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;
2403 case AV_PIX_FMT_GRAYF16LE:2480 case AV_PIX_FMT_GRAYF16LE:
2404 *lumToYV12 = grayf16leToY16_c;2481 *lumToYV12 = grayf16leToY16_c;
2405 break;2482 break;
@@ -2473,6 +2550,18 @@ av_cold void ff_sws_init_input_funcs(SwsInternal *c, · 67 unmodified lines
2473 case AV_PIX_FMT_YA16BE:2550 case AV_PIX_FMT_YA16BE:
2474 *alpToYV12 = read_ya16be_alpha_c;2551 *alpToYV12 = read_ya16be_alpha_c;
2475 break;2552 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;
2476 case AV_PIX_FMT_VUYA:2565 case AV_PIX_FMT_VUYA:
2477 case AV_PIX_FMT_UYVA:2566 case AV_PIX_FMT_UYVA:
2478 *alpToYV12 = read_vuya_A_c;2567 *alpToYV12 = read_vuya_A_c;
libswscale/utils.c+4−0
@@ -252,6 +252,10 @@ static const FormatEntry format_entries[] = { · 251 unmodified lines
252 [AV_PIX_FMT_GRAYF32BE] = { 1, 1 },252 [AV_PIX_FMT_GRAYF32BE] = { 1, 1 },
253 [AV_PIX_FMT_GRAYF16LE] = { 1, 0 },253 [AV_PIX_FMT_GRAYF16LE] = { 1, 0 },
254 [AV_PIX_FMT_GRAYF16BE] = { 1, 0 },254 [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 },
255 [AV_PIX_FMT_YUVA422P12BE] = { 1, 1 },259 [AV_PIX_FMT_YUVA422P12BE] = { 1, 1 },
256 [AV_PIX_FMT_YUVA422P12LE] = { 1, 1 },260 [AV_PIX_FMT_YUVA422P12LE] = { 1, 1 },
257 [AV_PIX_FMT_YUVA444P12BE] = { 1, 1 },261 [AV_PIX_FMT_YUVA444P12BE] = { 1, 1 },
libswscale/version.h+1−1
@@ -29,7 +29,7 @@ · 28 unmodified lines
29#include "version_major.h"29#include "version_major.h"
30 30
31#define LIBSWSCALE_VERSION_MINOR 1331#define LIBSWSCALE_VERSION_MINOR 13
32#define LIBSWSCALE_VERSION_MICRO 10032#define LIBSWSCALE_VERSION_MICRO 101
33 33
34#define LIBSWSCALE_VERSION_INT AV_VERSION_INT(LIBSWSCALE_VERSION_MAJOR, \34#define LIBSWSCALE_VERSION_INT AV_VERSION_INT(LIBSWSCALE_VERSION_MAJOR, \
35 LIBSWSCALE_VERSION_MINOR, \35 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