| @@ -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 | |
| 1173 | +static 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 | + |
| 1194 | +static 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 | + |
| 1173 | 1213 | static av_always_inline void grayf32ToY16_c(uint8_t *_dst, const uint8_t *_src, const uint8_t *unused1, |
| 1174 | 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 |
| 1226 | 1266 | rgb9plus_planar_transparency_funcs(14) |
| 1227 | 1267 | rgb9plus_planar_transparency_funcs(16) |
| 1228 | 1268 | |
| 1229 | | −#define rgbf32_planar_funcs_endian(endian_name, endian) \ |
| 1269 | +#define rgbf32_funcs_endian(endian_name, endian) \ |
| 1230 | 1270 | static void planar_rgbf32##endian_name##_to_y(uint8_t *dst, const uint8_t *src[4], \ |
| 1231 | 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 | 1284 | planar_rgbf32_to_a(dst, src, w, endian, rgb2yuv); \ |
| 1245 | 1285 | } \ |
| 1286 | +static 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 | +} \ |
| 1292 | +static 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 | +} \ |
| 1246 | 1300 | static void grayf32##endian_name##ToY16_c(uint8_t *dst, const uint8_t *src, \ |
| 1247 | 1301 | const uint8_t *unused1, const uint8_t *unused2, \ |
| 1248 | 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 | 1304 | grayf32ToY16_c(dst, src, unused1, unused2, width, endian, unused); \ |
| 1251 | 1305 | } |
| 1252 | 1306 | |
| 1253 | | −rgbf32_planar_funcs_endian(le, 0) |
| 1254 | | −rgbf32_planar_funcs_endian(be, 1) |
| 1307 | +rgbf32_funcs_endian(le, 0) |
| 1308 | +rgbf32_funcs_endian(be, 1) |
| 1255 | 1309 | |
| 1256 | 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 | 1626 | case AV_PIX_FMT_Y212LE: |
| 1573 | 1627 | *chrToYV12 = y212le_UV_c; |
| 1574 | 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 | 1636 | if (c->chrSrcHSubSample) { |
| 1577 | 1637 | switch (srcFormat) { |
| @@ -2090,6 +2150,12 @@ av_cold void ff_sws_init_input_funcs(SwsContext *c, · 512 unmodified lines |
| 2090 | 2150 | case AV_PIX_FMT_RGBAF16LE: |
| 2091 | 2151 | *lumToYV12 = rgbaf16leToY_c; |
| 2092 | 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 | 2160 | if (c->needAlpha) { |
| 2095 | 2161 | if (is16BPS(srcFormat) || isNBPS(srcFormat)) { |