History

swscale/input: add input support for RGBF32

Martin Schitter committed 2 years ago

Commit c72a5c41 parent fd8b0dc2 files · +71 −3Browse files

Unified · Split

2 files
  1. libswscale/input.c +69 −3
  2. libswscale/utils.c +2 −0
libswscale/input.c+69−3
@@ -1170,6 +1170,46 @@ static av_always_inline void planar_rgbf32_to_y(uint8_t *_dst, const uint8_t *_s · 1169 unmodified lines
1170 }1170 }
1171}1171}
1172 1172
1173static av_always_inline void rgbf32_to_uv_c(uint8_t *_dstU, uint8_t *_dstV, const uint8_t *unused1,
1174 const uint8_t *_src, const uint8_t *unused2,
1175 int width, int is_be, int32_t *rgb2yuv)
1176{
1177 int i;
1178 const float *src = (const float *)_src;
1179 uint16_t *dstU = (uint16_t *)_dstU;
1180 uint16_t *dstV = (uint16_t *)_dstV;
1181 int32_t ru = rgb2yuv[RU_IDX], gu = rgb2yuv[GU_IDX], bu = rgb2yuv[BU_IDX];
1182 int32_t rv = rgb2yuv[RV_IDX], gv = rgb2yuv[GV_IDX], bv = rgb2yuv[BV_IDX];
1183
1184 for (i = 0; i < width; i++) {
1185 int r = lrintf(av_clipf(65535.0f * rdpx(&src[3*i]), 0.0f, 65535.0f));
1186 int g = lrintf(av_clipf(65535.0f * rdpx(&src[3*i + 1]), 0.0f, 65535.0f));
1187 int b = lrintf(av_clipf(65535.0f * rdpx(&src[3*i + 2]), 0.0f, 65535.0f));
1188
1189 dstU[i] = (ru*r + gu*g + bu*b + (0x10001 << (RGB2YUV_SHIFT - 1))) >> RGB2YUV_SHIFT;
1190 dstV[i] = (rv*r + gv*g + bv*b + (0x10001 << (RGB2YUV_SHIFT - 1))) >> RGB2YUV_SHIFT;
1191 }
1192}
1193
1194static av_always_inline void rgbf32_to_y_c(uint8_t *_dst, const uint8_t *_src,
1195 const uint8_t *unused1, const uint8_t *unused2,
1196 int width, int is_be, int32_t *rgb2yuv)
1197{
1198 int i;
1199 const float *src = (const float *)_src;
1200 uint16_t *dst = (uint16_t *)_dst;
1201
1202 int32_t ry = rgb2yuv[RY_IDX], gy = rgb2yuv[GY_IDX], by = rgb2yuv[BY_IDX];
1203
1204 for (i = 0; i < width; i++) {
1205 int r = lrintf(av_clipf(65535.0f * rdpx(&src[3*i]), 0.0f, 65535.0f));
1206 int g = lrintf(av_clipf(65535.0f * rdpx(&src[3*i + 1]), 0.0f, 65535.0f));
1207 int b = lrintf(av_clipf(65535.0f * rdpx(&src[3*i + 2]), 0.0f, 65535.0f));
1208
1209 dst[i] = (ry*r + gy*g + by*b + (0x2001 << (RGB2YUV_SHIFT - 1))) >> RGB2YUV_SHIFT;
1210 }
1211}
1212
1173static av_always_inline void grayf32ToY16_c(uint8_t *_dst, const uint8_t *_src, const uint8_t *unused1,1213static av_always_inline void grayf32ToY16_c(uint8_t *_dst, const uint8_t *_src, const uint8_t *unused1,
1174 const uint8_t *unused2, int width, int is_be, uint32_t *unused)1214 const uint8_t *unused2, int width, int is_be, uint32_t *unused)
1175{1215{
@@ -1226,7 +1266,7 @@ rgb9plus_planar_transparency_funcs(12) · 50 unmodified lines
1226rgb9plus_planar_transparency_funcs(14)1266rgb9plus_planar_transparency_funcs(14)
1227rgb9plus_planar_transparency_funcs(16)1267rgb9plus_planar_transparency_funcs(16)
1228 1268
1229#define rgbf32_planar_funcs_endian(endian_name, endian) \1269#define rgbf32_funcs_endian(endian_name, endian) \
1230static void planar_rgbf32##endian_name##_to_y(uint8_t *dst, const uint8_t *src[4], \1270static void planar_rgbf32##endian_name##_to_y(uint8_t *dst, const uint8_t *src[4], \
1231 int w, int32_t *rgb2yuv, void *opq) \1271 int w, int32_t *rgb2yuv, void *opq) \
1232{ \1272{ \
@@ -1243,6 +1283,20 @@ static void planar_rgbf32##endian_name##_to_a(uint8_t *dst, const uint8_t *src[4 · 10 unmodified lines
1243{ \1283{ \
1244 planar_rgbf32_to_a(dst, src, w, endian, rgb2yuv); \1284 planar_rgbf32_to_a(dst, src, w, endian, rgb2yuv); \
1245} \1285} \
1286static void rgbf32##endian_name##_to_y_c(uint8_t *dst, const uint8_t *src, \
1287 const uint8_t *unused1, const uint8_t *unused2, \
1288 int w, uint32_t *rgb2yuv, void *opq) \
1289{ \
1290 rgbf32_to_y_c(dst, src, unused1, unused2, w, endian, rgb2yuv); \
1291} \
1292static void rgbf32##endian_name##_to_uv_c(uint8_t *dstU, uint8_t *dstV, \
1293 const uint8_t *unused1, \
1294 const uint8_t *src, const uint8_t *unused2, \
1295 int w, uint32_t *rgb2yuv, \
1296 void *opq) \
1297{ \
1298 rgbf32_to_uv_c(dstU, dstV, unused1, src, unused2, w, endian, rgb2yuv); \
1299} \
1246static void grayf32##endian_name##ToY16_c(uint8_t *dst, const uint8_t *src, \1300static void grayf32##endian_name##ToY16_c(uint8_t *dst, const uint8_t *src, \
1247 const uint8_t *unused1, const uint8_t *unused2, \1301 const uint8_t *unused1, const uint8_t *unused2, \
1248 int width, uint32_t *unused, void *opq) \1302 int width, uint32_t *unused, void *opq) \
@@ -1250,8 +1304,8 @@ static void grayf32##endian_name##ToY16_c(uint8_t *dst, const uint8_t *src, · 1 unmodified line
1250 grayf32ToY16_c(dst, src, unused1, unused2, width, endian, unused); \1304 grayf32ToY16_c(dst, src, unused1, unused2, width, endian, unused); \
1251}1305}
1252 1306
1253rgbf32_planar_funcs_endian(le, 0)1307rgbf32_funcs_endian(le, 0)
1254rgbf32_planar_funcs_endian(be, 1)1308rgbf32_funcs_endian(be, 1)
1255 1309
1256#define rdpx(src) av_int2float(half2float(is_be ? AV_RB16(&src) : AV_RL16(&src), h2f_tbl))1310#define rdpx(src) av_int2float(half2float(is_be ? AV_RB16(&src) : AV_RL16(&src), h2f_tbl))
1257 1311
@@ -1572,6 +1626,12 @@ av_cold void ff_sws_init_input_funcs(SwsContext *c, · 314 unmodified lines
1572 case AV_PIX_FMT_Y212LE:1626 case AV_PIX_FMT_Y212LE:
1573 *chrToYV12 = y212le_UV_c;1627 *chrToYV12 = y212le_UV_c;
1574 break;1628 break;
1629 case AV_PIX_FMT_RGBF32LE:
1630 *chrToYV12 = rgbf32le_to_uv_c;
1631 break;
1632 case AV_PIX_FMT_RGBF32BE:
1633 *chrToYV12 = rgbf32be_to_uv_c;
1634 break;
1575 }1635 }
1576 if (c->chrSrcHSubSample) {1636 if (c->chrSrcHSubSample) {
1577 switch (srcFormat) {1637 switch (srcFormat) {
@@ -2090,6 +2150,12 @@ av_cold void ff_sws_init_input_funcs(SwsContext *c, · 512 unmodified lines
2090 case AV_PIX_FMT_RGBAF16LE:2150 case AV_PIX_FMT_RGBAF16LE:
2091 *lumToYV12 = rgbaf16leToY_c;2151 *lumToYV12 = rgbaf16leToY_c;
2092 break;2152 break;
2153 case AV_PIX_FMT_RGBF32LE:
2154 *lumToYV12 = rgbf32le_to_y_c;
2155 break;
2156 case AV_PIX_FMT_RGBF32BE:
2157 *lumToYV12 = rgbf32be_to_y_c;
2158 break;
2093 }2159 }
2094 if (c->needAlpha) {2160 if (c->needAlpha) {
2095 if (is16BPS(srcFormat) || isNBPS(srcFormat)) {2161 if (is16BPS(srcFormat) || isNBPS(srcFormat)) {
libswscale/utils.c+2−0
@@ -266,6 +266,8 @@ static const FormatEntry format_entries[] = { · 265 unmodified lines
266 [AV_PIX_FMT_VUYX] = { 1, 1 },266 [AV_PIX_FMT_VUYX] = { 1, 1 },
267 [AV_PIX_FMT_RGBAF16BE] = { 1, 0 },267 [AV_PIX_FMT_RGBAF16BE] = { 1, 0 },
268 [AV_PIX_FMT_RGBAF16LE] = { 1, 0 },268 [AV_PIX_FMT_RGBAF16LE] = { 1, 0 },
269 [AV_PIX_FMT_RGBF32BE] = { 1, 0 },
270 [AV_PIX_FMT_RGBF32LE] = { 1, 0 },
269 [AV_PIX_FMT_XV30LE] = { 1, 1 },271 [AV_PIX_FMT_XV30LE] = { 1, 1 },
270 [AV_PIX_FMT_XV36LE] = { 1, 1 },272 [AV_PIX_FMT_XV36LE] = { 1, 1 },
271 [AV_PIX_FMT_AYUV] = { 1, 1 },273 [AV_PIX_FMT_AYUV] = { 1, 1 },

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