Commit 743841e71c for ffmpeg

commit 743841e71c0c3714984547df78941b9a0a7d6878
Author: James Almer <jamrial@gmail.com>
Date:   Sun Nov 8 23:25:48 2026 -0300

    swscale/output: add support for RGBF32

    Signed-off-by: James Almer <jamrial@gmail.com>

diff --git a/libswscale/format.c b/libswscale/format.c
index ffa9fda56e..5482982c0d 100644
--- a/libswscale/format.c
+++ b/libswscale/format.c
@@ -269,8 +269,8 @@ static const LegacyFormatEntry legacy_format_entries[] = {
     [AV_PIX_FMT_RGBAF16LE]      = { 1, 0 },
     [AV_PIX_FMT_RGBF16BE]       = { 1, 0 },
     [AV_PIX_FMT_RGBF16LE]       = { 1, 0 },
-    [AV_PIX_FMT_RGBF32BE]       = { 1, 0 },
-    [AV_PIX_FMT_RGBF32LE]       = { 1, 0 },
+    [AV_PIX_FMT_RGBF32BE]       = { 1, 1 },
+    [AV_PIX_FMT_RGBF32LE]       = { 1, 1 },
     [AV_PIX_FMT_RGBAF32BE]      = { 1, 0 },
     [AV_PIX_FMT_RGBAF32LE]      = { 1, 0 },
     [AV_PIX_FMT_XV30LE]         = { 1, 1 },
diff --git a/libswscale/output.c b/libswscale/output.c
index 97f8960938..faf3ea4fa1 100644
--- a/libswscale/output.c
+++ b/libswscale/output.c
@@ -1009,8 +1009,8 @@ YUV2PACKEDWRAPPER(yuv2, 422, yuyv422, AV_PIX_FMT_YUYV422)
 YUV2PACKEDWRAPPER(yuv2, 422, yvyu422, AV_PIX_FMT_YVYU422)
 YUV2PACKEDWRAPPER(yuv2, 422, uyvy422, AV_PIX_FMT_UYVY422)

-#define R_B ((target == AV_PIX_FMT_RGB48LE || target == AV_PIX_FMT_RGB48BE || target == AV_PIX_FMT_RGBA64LE || target == AV_PIX_FMT_RGBA64BE) ? R : B)
-#define B_R ((target == AV_PIX_FMT_RGB48LE || target == AV_PIX_FMT_RGB48BE || target == AV_PIX_FMT_RGBA64LE || target == AV_PIX_FMT_RGBA64BE) ? B : R)
+#define R_B ((target == AV_PIX_FMT_RGB48LE || target == AV_PIX_FMT_RGB48BE || target == AV_PIX_FMT_RGBA64LE || target == AV_PIX_FMT_RGBA64BE || target == AV_PIX_FMT_RGBF32LE || target == AV_PIX_FMT_RGBF32BE) ? R : B)
+#define B_R ((target == AV_PIX_FMT_RGB48LE || target == AV_PIX_FMT_RGB48BE || target == AV_PIX_FMT_RGBA64LE || target == AV_PIX_FMT_RGBA64BE || target == AV_PIX_FMT_RGBF32LE || target == AV_PIX_FMT_RGBF32BE) ? B : R)
 #define output_pixel(pos, val) \
     if (is_be) { \
         AV_WB16(pos, val); \
@@ -1135,6 +1135,59 @@ yuv2ya16_1_c_template(SwsInternal *c, const int32_t *buf0,
     }
 }

+static av_always_inline void
+output_pixel_rgba(uint16_t *dest, int i, unsigned Y1, unsigned Y2,
+                  int R, int G, int B, int A1, int A2,
+                  enum AVPixelFormat target, int eightbytes, int is_be)
+{
+    if (target == AV_PIX_FMT_RGBF32LE || target == AV_PIX_FMT_RGBF32BE) {
+        static const float float_mult = 1.0f / 65535.0f;
+        ptrdiff_t stride = 12;
+        output_pixel32(&dest[stride * i     ], av_float2int(float_mult * av_clip_uintp2(((int)(R + Y1) >> 14) + (1<<15), 16)));
+        output_pixel32(&dest[stride * i +  2], av_float2int(float_mult * av_clip_uintp2(((int)(G + Y1) >> 14) + (1<<15), 16)));
+        output_pixel32(&dest[stride * i +  4], av_float2int(float_mult * av_clip_uintp2(((int)(B + Y1) >> 14) + (1<<15), 16)));
+        output_pixel32(&dest[stride * i +  6], av_float2int(float_mult * av_clip_uintp2(((int)(R + Y2) >> 14) + (1<<15), 16)));
+        output_pixel32(&dest[stride * i +  8], av_float2int(float_mult * av_clip_uintp2(((int)(G + Y2) >> 14) + (1<<15), 16)));
+        output_pixel32(&dest[stride * i + 10], av_float2int(float_mult * av_clip_uintp2(((int)(B + Y2) >> 14) + (1<<15), 16)));
+    } else {
+        ptrdiff_t stride = eightbytes ? 8 : 6;
+        output_pixel(&dest[stride * i    ], av_clip_uintp2(((int)(R + Y1) >> 14) + (1<<15), 16));
+        output_pixel(&dest[stride * i + 1], av_clip_uintp2(((int)(G + Y1) >> 14) + (1<<15), 16));
+        output_pixel(&dest[stride * i + 2], av_clip_uintp2(((int)(B + Y1) >> 14) + (1<<15), 16));
+        if (eightbytes) {
+            output_pixel(&dest[stride * i + 3], av_clip_uintp2(A1, 30) >> 14);
+            output_pixel(&dest[stride * i + 4], av_clip_uintp2(((int)(R + Y2) >> 14) + (1<<15), 16));
+            output_pixel(&dest[stride * i + 5], av_clip_uintp2(((int)(G + Y2) >> 14) + (1<<15), 16));
+            output_pixel(&dest[stride * i + 6], av_clip_uintp2(((int)(B + Y2) >> 14) + (1<<15), 16));
+            output_pixel(&dest[stride * i + 7], av_clip_uintp2(A2, 30) >> 14);
+        } else {
+            output_pixel(&dest[stride * i + 3], av_clip_uintp2(((int)(R + Y2) >> 14) + (1<<15), 16));
+            output_pixel(&dest[stride * i + 4], av_clip_uintp2(((int)(G + Y2) >> 14) + (1<<15), 16));
+            output_pixel(&dest[stride * i + 5], av_clip_uintp2(((int)(B + Y2) >> 14) + (1<<15), 16));
+        }
+    }
+}
+
+static av_always_inline void
+output_pixel_rgba_full(uint16_t *dest, int i, unsigned Y, int R, int G, int B, int A,
+                       enum AVPixelFormat target, int eightbytes, int is_be)
+{
+    if (target == AV_PIX_FMT_RGBF32LE || target == AV_PIX_FMT_RGBF32BE) {
+        static const float float_mult = 1.0f / 65535.0f;
+        ptrdiff_t stride = 6;
+        output_pixel32(&dest[stride * i     ], av_float2int(float_mult * av_clip_uintp2(((int)(R + Y) >> 14) + (1<<15), 16)));
+        output_pixel32(&dest[stride * i +  2], av_float2int(float_mult * av_clip_uintp2(((int)(G + Y) >> 14) + (1<<15), 16)));
+        output_pixel32(&dest[stride * i +  4], av_float2int(float_mult * av_clip_uintp2(((int)(B + Y) >> 14) + (1<<15), 16)));
+    } else {
+        ptrdiff_t stride = eightbytes ? 4 : 3;
+        output_pixel(&dest[stride * i    ], av_clip_uintp2(((int)(R + (unsigned)Y) >> 14) + (1<<15), 16));
+        output_pixel(&dest[stride * i + 1], av_clip_uintp2(((int)(G + (unsigned)Y) >> 14) + (1<<15), 16));
+        output_pixel(&dest[stride * i + 2], av_clip_uintp2(((int)(B + (unsigned)Y) >> 14) + (1<<15), 16));
+        if (eightbytes)
+            output_pixel(&dest[stride * i + 3], av_clip_uintp2(A, 30) >> 14);
+    }
+}
+
 static av_always_inline void
 yuv2rgba64_X_c_template(SwsInternal *c, const int16_t *lumFilter,
                        const int32_t **lumSrc, int lumFilterSize,
@@ -1198,23 +1251,7 @@ yuv2rgba64_X_c_template(SwsInternal *c, const int16_t *lumFilter,
         G = V * c->yuv2rgb_v2g_coeff + U * c->yuv2rgb_u2g_coeff;
         B =                            U * c->yuv2rgb_u2b_coeff;

-        // 8 bits: 30 - 22 = 8 bits, 16 bits: 30 bits - 14 = 16 bits
-        output_pixel(&dest[0], av_clip_uintp2(((int)(R_B + Y1) >> 14) + (1<<15), 16));
-        output_pixel(&dest[1], av_clip_uintp2(((int)(  G + Y1) >> 14) + (1<<15), 16));
-        output_pixel(&dest[2], av_clip_uintp2(((int)(B_R + Y1) >> 14) + (1<<15), 16));
-        if (eightbytes) {
-            output_pixel(&dest[3], av_clip_uintp2(A1      , 30) >> 14);
-            output_pixel(&dest[4], av_clip_uintp2(((int)(R_B + Y2) >> 14) + (1<<15), 16));
-            output_pixel(&dest[5], av_clip_uintp2(((int)(  G + Y2) >> 14) + (1<<15), 16));
-            output_pixel(&dest[6], av_clip_uintp2(((int)(B_R + Y2) >> 14) + (1<<15), 16));
-            output_pixel(&dest[7], av_clip_uintp2(A2      , 30) >> 14);
-            dest += 8;
-        } else {
-            output_pixel(&dest[3], av_clip_uintp2(((int)(R_B + Y2) >> 14) + (1<<15), 16));
-            output_pixel(&dest[4], av_clip_uintp2(((int)(  G + Y2) >> 14) + (1<<15), 16));
-            output_pixel(&dest[5], av_clip_uintp2(((int)(B_R + Y2) >> 14) + (1<<15), 16));
-            dest += 6;
-        }
+        output_pixel_rgba(dest, i, Y1, Y2, R_B, G, B_R, A1, A2, target, eightbytes, is_be);
     }
 }

@@ -1267,22 +1304,7 @@ yuv2rgba64_2_c_template(SwsInternal *c, const int32_t *buf[2],
             A2 += 1 << 13;
         }

-        output_pixel(&dest[0], av_clip_uintp2(((int)(R_B + Y1) >> 14) + (1<<15), 16));
-        output_pixel(&dest[1], av_clip_uintp2(((int)(  G + Y1) >> 14) + (1<<15), 16));
-        output_pixel(&dest[2], av_clip_uintp2(((int)(B_R + Y1) >> 14) + (1<<15), 16));
-        if (eightbytes) {
-            output_pixel(&dest[3], av_clip_uintp2(A1      , 30) >> 14);
-            output_pixel(&dest[4], av_clip_uintp2(((int)(R_B + Y2) >> 14) + (1<<15), 16));
-            output_pixel(&dest[5], av_clip_uintp2(((int)(  G + Y2) >> 14) + (1<<15), 16));
-            output_pixel(&dest[6], av_clip_uintp2(((int)(B_R + Y2) >> 14) + (1<<15), 16));
-            output_pixel(&dest[7], av_clip_uintp2(A2      , 30) >> 14);
-            dest += 8;
-        } else {
-            output_pixel(&dest[3], av_clip_uintp2(((int)(R_B + Y2) >> 14) + (1<<15), 16));
-            output_pixel(&dest[4], av_clip_uintp2(((int)(  G + Y2) >> 14) + (1<<15), 16));
-            output_pixel(&dest[5], av_clip_uintp2(((int)(B_R + Y2) >> 14) + (1<<15), 16));
-            dest += 6;
-        }
+        output_pixel_rgba(dest, i, Y1, Y2, R_B, G, B_R, A1, A2, target, eightbytes, is_be);
     }
 }

@@ -1324,22 +1346,7 @@ yuv2rgba64_1_c_template(SwsInternal *c, const int32_t *buf0,
             G = V * c->yuv2rgb_v2g_coeff + U * c->yuv2rgb_u2g_coeff;
             B =                            U * c->yuv2rgb_u2b_coeff;

-            output_pixel(&dest[0], av_clip_uintp2(((int)(R_B + Y1) >> 14) + (1<<15), 16));
-            output_pixel(&dest[1], av_clip_uintp2(((int)(  G + Y1) >> 14) + (1<<15), 16));
-            output_pixel(&dest[2], av_clip_uintp2(((int)(B_R + Y1) >> 14) + (1<<15), 16));
-            if (eightbytes) {
-                output_pixel(&dest[3], av_clip_uintp2(A1      , 30) >> 14);
-                output_pixel(&dest[4], av_clip_uintp2(((int)(R_B + Y2) >> 14) + (1<<15), 16));
-                output_pixel(&dest[5], av_clip_uintp2(((int)(  G + Y2) >> 14) + (1<<15), 16));
-                output_pixel(&dest[6], av_clip_uintp2(((int)(B_R + Y2) >> 14) + (1<<15), 16));
-                output_pixel(&dest[7], av_clip_uintp2(A2      , 30) >> 14);
-                dest += 8;
-            } else {
-                output_pixel(&dest[3], av_clip_uintp2(((int)(R_B + Y2) >> 14) + (1<<15), 16));
-                output_pixel(&dest[4], av_clip_uintp2(((int)(  G + Y2) >> 14) + (1<<15), 16));
-                output_pixel(&dest[5], av_clip_uintp2(((int)(B_R + Y2) >> 14) + (1<<15), 16));
-                dest += 6;
-            }
+            output_pixel_rgba(dest, i, Y1, Y2, R_B, G, B_R, A1, A2, target, eightbytes, is_be);
         }
     } else {
         const int32_t *ubuf1 = ubuf[1], *vbuf1 = vbuf[1];
@@ -1373,22 +1380,7 @@ yuv2rgba64_1_c_template(SwsInternal *c, const int32_t *buf0,
             G = V * c->yuv2rgb_v2g_coeff + U * c->yuv2rgb_u2g_coeff;
             B =                            U * c->yuv2rgb_u2b_coeff;

-            output_pixel(&dest[0], av_clip_uintp2(((int)(R_B + Y1) >> 14) + (1<<15), 16));
-            output_pixel(&dest[1], av_clip_uintp2(((int)(  G + Y1) >> 14) + (1<<15), 16));
-            output_pixel(&dest[2], av_clip_uintp2(((int)(B_R + Y1) >> 14) + (1<<15), 16));
-            if (eightbytes) {
-                output_pixel(&dest[3], av_clip_uintp2(A1      , 30) >> 14);
-                output_pixel(&dest[4], av_clip_uintp2(((int)(R_B + Y2) >> 14) + (1<<15), 16));
-                output_pixel(&dest[5], av_clip_uintp2(((int)(  G + Y2) >> 14) + (1<<15), 16));
-                output_pixel(&dest[6], av_clip_uintp2(((int)(B_R + Y2) >> 14) + (1<<15), 16));
-                output_pixel(&dest[7], av_clip_uintp2(A2      , 30) >> 14);
-                dest += 8;
-            } else {
-                output_pixel(&dest[3], av_clip_uintp2(((int)(R_B + Y2) >> 14) + (1<<15), 16));
-                output_pixel(&dest[4], av_clip_uintp2(((int)(  G + Y2) >> 14) + (1<<15), 16));
-                output_pixel(&dest[5], av_clip_uintp2(((int)(B_R + Y2) >> 14) + (1<<15), 16));
-                dest += 6;
-            }
+            output_pixel_rgba(dest, i, Y1, Y2, R_B, G, B_R, A1, A2, target, eightbytes, is_be);
         }
     }
 }
@@ -1445,16 +1437,7 @@ yuv2rgba64_full_X_c_template(SwsInternal *c, const int16_t *lumFilter,
         G = (unsigned)V * c->yuv2rgb_v2g_coeff + (unsigned)U * c->yuv2rgb_u2g_coeff;
         B =                                      (unsigned)U * c->yuv2rgb_u2b_coeff;

-        // 8bit: 30 - 22 = 8bit, 16bit: 30bit - 14 = 16bit
-        output_pixel(&dest[0], av_clip_uintp2(((int)(R_B + (unsigned)Y)>>14) + (1<<15), 16));
-        output_pixel(&dest[1], av_clip_uintp2(((int)(  G + (unsigned)Y)>>14) + (1<<15), 16));
-        output_pixel(&dest[2], av_clip_uintp2(((int)(B_R + (unsigned)Y)>>14) + (1<<15), 16));
-        if (eightbytes) {
-            output_pixel(&dest[3], av_clip_uintp2(A, 30) >> 14);
-            dest += 4;
-        } else {
-            dest += 3;
-        }
+        output_pixel_rgba_full(dest, i, Y, R_B, G, B_R, A, target, eightbytes, is_be);
     }
 }

@@ -1501,15 +1484,7 @@ yuv2rgba64_full_2_c_template(SwsInternal *c, const int32_t *buf[2],
             A += 1 << 13;
         }

-        output_pixel(&dest[0], av_clip_uintp2(((int)(R_B + Y) >> 14) + (1<<15), 16));
-        output_pixel(&dest[1], av_clip_uintp2(((int)(  G + Y) >> 14) + (1<<15), 16));
-        output_pixel(&dest[2], av_clip_uintp2(((int)(B_R + Y) >> 14) + (1<<15), 16));
-        if (eightbytes) {
-            output_pixel(&dest[3], av_clip_uintp2(A, 30) >> 14);
-            dest += 4;
-        } else {
-            dest += 3;
-        }
+        output_pixel_rgba_full(dest, i, Y, R_B, G, B_R, A, target, eightbytes, is_be);
     }
 }

@@ -1545,15 +1520,7 @@ yuv2rgba64_full_1_c_template(SwsInternal *c, const int32_t *buf0,
             G = V * c->yuv2rgb_v2g_coeff + U * c->yuv2rgb_u2g_coeff;
             B =                            U * c->yuv2rgb_u2b_coeff;

-            output_pixel(&dest[0], av_clip_uintp2(((int)(R_B + Y) >> 14) + (1<<15), 16));
-            output_pixel(&dest[1], av_clip_uintp2(((int)(  G + Y) >> 14) + (1<<15), 16));
-            output_pixel(&dest[2], av_clip_uintp2(((int)(B_R + Y) >> 14) + (1<<15), 16));
-            if (eightbytes) {
-                output_pixel(&dest[3], av_clip_uintp2(A, 30) >> 14);
-                dest += 4;
-            } else {
-                dest += 3;
-            }
+            output_pixel_rgba_full(dest, i, Y, R_B, G, B_R, A, target, eightbytes, is_be);
         }
     } else {
         const int32_t *ubuf1 = ubuf[1], *vbuf1 = vbuf[1];
@@ -1581,15 +1548,7 @@ yuv2rgba64_full_1_c_template(SwsInternal *c, const int32_t *buf0,
             G = V * c->yuv2rgb_v2g_coeff + U * c->yuv2rgb_u2g_coeff;
             B =                            U * c->yuv2rgb_u2b_coeff;

-            output_pixel(&dest[0], av_clip_uintp2(((int)(R_B + Y) >> 14) + (1<<15), 16));
-            output_pixel(&dest[1], av_clip_uintp2(((int)(  G + Y) >> 14) + (1<<15), 16));
-            output_pixel(&dest[2], av_clip_uintp2(((int)(B_R + Y) >> 14) + (1<<15), 16));
-            if (eightbytes) {
-                output_pixel(&dest[3], av_clip_uintp2(A, 30) >> 14);
-                dest += 4;
-            } else {
-                dest += 3;
-            }
+            output_pixel_rgba_full(dest, i, Y, R_B, G, B_R, A, target, eightbytes, is_be);
         }
     }
 }
@@ -1659,6 +1618,8 @@ YUV2PACKED16WRAPPER(yuv2, rgba64, bgra64be, AV_PIX_FMT_BGRA64, BE, 1, 1)
 YUV2PACKED16WRAPPER(yuv2, rgba64, bgra64le, AV_PIX_FMT_BGRA64, LE, 1, 1)
 YUV2PACKED16WRAPPER(yuv2, rgba64, bgrx64be, AV_PIX_FMT_BGRA64, BE, 0, 1)
 YUV2PACKED16WRAPPER(yuv2, rgba64, bgrx64le, AV_PIX_FMT_BGRA64, LE, 0, 1)
+YUV2PACKED16WRAPPER(yuv2, rgba64, rgbf32be, AV_PIX_FMT_RGBF32, BE, 0, 0)
+YUV2PACKED16WRAPPER(yuv2, rgba64, rgbf32le, AV_PIX_FMT_RGBF32, LE, 0, 0)
 YUV2PACKED16WRAPPER(yuv2, ya16, ya16be, AV_PIX_FMT_YA16, BE, 1, 0)
 YUV2PACKED16WRAPPER(yuv2, ya16, ya16le, AV_PIX_FMT_YA16, LE, 1, 0)
 YUV2PACKED16WRAPPER(yuv2, ya16, yaf32be, AV_PIX_FMT_YAF32, BE, 1, 0)
@@ -1676,6 +1637,8 @@ YUV2PACKED16WRAPPER(yuv2, rgba64_full, bgra64be_full, AV_PIX_FMT_BGRA64, BE, 1,
 YUV2PACKED16WRAPPER(yuv2, rgba64_full, bgra64le_full, AV_PIX_FMT_BGRA64, LE, 1, 1)
 YUV2PACKED16WRAPPER(yuv2, rgba64_full, bgrx64be_full, AV_PIX_FMT_BGRA64, BE, 0, 1)
 YUV2PACKED16WRAPPER(yuv2, rgba64_full, bgrx64le_full, AV_PIX_FMT_BGRA64, LE, 0, 1)
+YUV2PACKED16WRAPPER(yuv2, rgba64_full, rgbf32be_full, AV_PIX_FMT_RGBF32, BE, 0, 0)
+YUV2PACKED16WRAPPER(yuv2, rgba64_full, rgbf32le_full, AV_PIX_FMT_RGBF32, LE, 0, 0)

 /*
  * Write out 2 RGB pixels in the target pixel format. This function takes a
@@ -3586,6 +3549,16 @@ av_cold void ff_sws_init_output_funcs(SwsInternal *c,
             *yuv2packed2 = yuv2x2bgr10_full_2_c;
             *yuv2packed1 = yuv2x2bgr10_full_1_c;
             break;
+        case AV_PIX_FMT_RGBF32LE:
+            *yuv2packedX = yuv2rgbf32le_full_X_c;
+            *yuv2packed2 = yuv2rgbf32le_full_2_c;
+            *yuv2packed1 = yuv2rgbf32le_full_1_c;
+            break;
+        case AV_PIX_FMT_RGBF32BE:
+            *yuv2packedX = yuv2rgbf32be_full_X_c;
+            *yuv2packed2 = yuv2rgbf32be_full_2_c;
+            *yuv2packed1 = yuv2rgbf32be_full_1_c;
+            break;
         case AV_PIX_FMT_GBRP:
         case AV_PIX_FMT_GBRP9BE:
         case AV_PIX_FMT_GBRP9LE:
@@ -3810,6 +3783,16 @@ av_cold void ff_sws_init_output_funcs(SwsInternal *c,
             *yuv2packed2 = yuv2x2bgr10_2_c;
             *yuv2packedX = yuv2x2bgr10_X_c;
             break;
+        case AV_PIX_FMT_RGBF32LE:
+            *yuv2packedX = yuv2rgbf32le_X_c;
+            *yuv2packed2 = yuv2rgbf32le_2_c;
+            *yuv2packed1 = yuv2rgbf32le_1_c;
+            break;
+        case AV_PIX_FMT_RGBF32BE:
+            *yuv2packedX = yuv2rgbf32be_X_c;
+            *yuv2packed2 = yuv2rgbf32be_2_c;
+            *yuv2packed1 = yuv2rgbf32be_1_c;
+            break;
         }
     }
     switch (dstFormat) {
diff --git a/libswscale/utils.c b/libswscale/utils.c
index 6aabce39ab..37a9cb94b5 100644
--- a/libswscale/utils.c
+++ b/libswscale/utils.c
@@ -1396,6 +1396,8 @@ av_cold int ff_sws_init_single_context(SwsContext *sws, SwsFilter *srcFilter,
         dstFormat != AV_PIX_FMT_RGB48BE &&
         dstFormat != AV_PIX_FMT_BGR48LE &&
         dstFormat != AV_PIX_FMT_BGR48BE &&
+        dstFormat != AV_PIX_FMT_RGBF32LE &&
+        dstFormat != AV_PIX_FMT_RGBF32BE &&
         dstFormat != AV_PIX_FMT_RGBA  &&
         dstFormat != AV_PIX_FMT_ARGB  &&
         dstFormat != AV_PIX_FMT_BGRA  &&
diff --git a/libswscale/yuv2rgb.c b/libswscale/yuv2rgb.c
index a430a110db..bb15ab1f77 100644
--- a/libswscale/yuv2rgb.c
+++ b/libswscale/yuv2rgb.c
@@ -965,7 +965,7 @@ av_cold int ff_yuv2rgb_c_init_tables(SwsInternal *c, const int inv_table[4],
         fill_gv_table(c->table_gV, 4, cgv);
         break;
     default:
-        if(!isPlanar(c->opts.dst_format) || bpp <= 24)
+        if ((!isPlanar(c->opts.dst_format) && !isFloat(c->opts.dst_format)) || bpp <= 24)
             av_log(c, AV_LOG_ERROR, "%ibpp not supported by yuv2rgb\n", bpp);
         return AVERROR(EINVAL);
     }
diff --git a/tests/ref/fate/filter-pixdesc-rgbf32be b/tests/ref/fate/filter-pixdesc-rgbf32be
new file mode 100644
index 0000000000..87913a59f1
--- /dev/null
+++ b/tests/ref/fate/filter-pixdesc-rgbf32be
@@ -0,0 +1 @@
+pixdesc-rgbf32be    9513ca81f85fe60c48b5bb6160b98180
diff --git a/tests/ref/fate/filter-pixdesc-rgbf32le b/tests/ref/fate/filter-pixdesc-rgbf32le
new file mode 100644
index 0000000000..7b362bbb98
--- /dev/null
+++ b/tests/ref/fate/filter-pixdesc-rgbf32le
@@ -0,0 +1 @@
+pixdesc-rgbf32le    440a6f384268d355816b02e7c3c368ce
diff --git a/tests/ref/fate/filter-pixfmts-copy b/tests/ref/fate/filter-pixfmts-copy
index 5c02a63897..cd68289f11 100644
--- a/tests/ref/fate/filter-pixfmts-copy
+++ b/tests/ref/fate/filter-pixfmts-copy
@@ -104,6 +104,8 @@ rgb8                7ac6008c84d622c2fc50581706e17576
 rgba                b6e1b441c365e03b5ffdf9b7b68d9a0c
 rgba64be            ae2ae04b5efedca3505f47c4dd6ea6ea
 rgba64le            b91e1d77f799eb92241a2d2d28437b15
+rgbf32be            eb8610acb97af6adb59d8a192204bf26
+rgbf32le            134ac0933d1f2bef30d11fd113ab2ecc
 uyva                8896d7525f12de08818a01a5d5cf84f1
 uyvy422             3bcf3c80047592f2211fae3260b1b65d
 v30xle              44503e6d78bc474c1b72c5ceb1779539
diff --git a/tests/ref/fate/filter-pixfmts-crop b/tests/ref/fate/filter-pixfmts-crop
index 261336f7cf..c845bd580e 100644
--- a/tests/ref/fate/filter-pixfmts-crop
+++ b/tests/ref/fate/filter-pixfmts-crop
@@ -102,6 +102,8 @@ rgb8                9b364a8f112ad9459fec47a51cc03b30
 rgba                9488ac85abceaf99a9309eac5a87697e
 rgba64be            89910046972ab3c68e2a348302cc8ca9
 rgba64le            fea8ebfc869b52adf353778f29eac7a7
+rgbf32be            d6f8c49ef3def3c11a06dd70ebc057d4
+rgbf32le            7a5e25cd4812e34103751b61c894b27d
 uyva                03f362ac6a39f25286bc6616111b0752
 v30xle              ee090c91c28e70b126f6c76a64c39f60
 vuya                76578a705ff3a37559653c1289bd03dd
diff --git a/tests/ref/fate/filter-pixfmts-field b/tests/ref/fate/filter-pixfmts-field
index 1e137f4b47..9f807433c9 100644
--- a/tests/ref/fate/filter-pixfmts-field
+++ b/tests/ref/fate/filter-pixfmts-field
@@ -104,6 +104,8 @@ rgb8                62c3b9e2a171de3d894a8eeb271c85e8
 rgba                ee616262ca6d67b7ecfba4b36c602ce3
 rgba64be            23c8c0edaabe3eaec89ce69633fb0048
 rgba64le            dfdba4de4a7cac9abf08852666c341d3
+rgbf32be            919ea3ceab0fbb77e4a53548cb7191a3
+rgbf32le            c6dc8ae2b4dfd4c1c0f6b3af950dbeef
 uyva                147398d2e8d310f915c95863ad192c5e
 uyvy422             1c49e44ab3f060e85fc4a3a9464f045e
 v30xle              394101c7c80b12e34f4352156a3a74b3
diff --git a/tests/ref/fate/filter-pixfmts-fieldorder b/tests/ref/fate/filter-pixfmts-fieldorder
index 93bea75fbb..0b5c4342fb 100644
--- a/tests/ref/fate/filter-pixfmts-fieldorder
+++ b/tests/ref/fate/filter-pixfmts-fieldorder
@@ -93,6 +93,8 @@ rgb8                6deae05ccac5c50bd0d9c9fe8e124557
 rgba                1fdf872a087a32cd35b80cc7be399578
 rgba64be            5598f44514d122b9a57c5c92c20bbc61
 rgba64le            b34e6e30621ae579519a2d91a96a0acf
+rgbf32be            f92c90bf08d70e854e4f8179de0eaf30
+rgbf32le            6202cc01added07819b74bb062ceef17
 uyva                ccf5dfd33765dda88c4b4afa2ea31305
 uyvy422             75de70e31c435dde878002d3f22b238a
 v30xle              e453b8f0ad09e64e3a0173a4e3c2930d
diff --git a/tests/ref/fate/filter-pixfmts-hflip b/tests/ref/fate/filter-pixfmts-hflip
index 05fc467a9d..c071cf6424 100644
--- a/tests/ref/fate/filter-pixfmts-hflip
+++ b/tests/ref/fate/filter-pixfmts-hflip
@@ -102,6 +102,8 @@ rgb8                68a3a575badadd9e4f90226209f11699
 rgba                51961c723ea6707e0a410cd3f21f15d3
 rgba64be            c910444019f4cfbf4d995227af55da8d
 rgba64le            0c810d8b3a6bca10321788e1cb145340
+rgbf32be            82ca0560630c21b141098adbf5a2e65e
+rgbf32le            46e3d448f093bb386ba93885bd99861c
 uyva                a8391c24037e2a670196b47bf6a2ca57
 v30xle              ea5575ee99f826d7447bcc47fdb6639f
 vuya                7e530261e7ac4eae4fd616fd7572d0b8
diff --git a/tests/ref/fate/filter-pixfmts-il b/tests/ref/fate/filter-pixfmts-il
index b790105e36..e3e72f715c 100644
--- a/tests/ref/fate/filter-pixfmts-il
+++ b/tests/ref/fate/filter-pixfmts-il
@@ -103,6 +103,8 @@ rgb8                93f9fa5ecf522abe13ed34f21831fdfe
 rgba                625d8f4bd39c4bdbf61eb5e4713aecc9
 rgba64be            db70d33aa6c06f3e0a1c77bd11284261
 rgba64le            a8a2daae04374a27219bc1c890204007
+rgbf32be            9dc7a55820a278c5f5c7eba50f5e9564
+rgbf32le            2c71576443b61ac5222c1a33564a10e3
 uyva                d2655e1a1c56bcb48f7c7a6a6270dd93
 uyvy422             d6ee3ca43356d08c392382b24b22cda5
 v30xle              40776197aa84a4784d195692fe890c88
diff --git a/tests/ref/fate/filter-pixfmts-null b/tests/ref/fate/filter-pixfmts-null
index 5c02a63897..cd68289f11 100644
--- a/tests/ref/fate/filter-pixfmts-null
+++ b/tests/ref/fate/filter-pixfmts-null
@@ -104,6 +104,8 @@ rgb8                7ac6008c84d622c2fc50581706e17576
 rgba                b6e1b441c365e03b5ffdf9b7b68d9a0c
 rgba64be            ae2ae04b5efedca3505f47c4dd6ea6ea
 rgba64le            b91e1d77f799eb92241a2d2d28437b15
+rgbf32be            eb8610acb97af6adb59d8a192204bf26
+rgbf32le            134ac0933d1f2bef30d11fd113ab2ecc
 uyva                8896d7525f12de08818a01a5d5cf84f1
 uyvy422             3bcf3c80047592f2211fae3260b1b65d
 v30xle              44503e6d78bc474c1b72c5ceb1779539
diff --git a/tests/ref/fate/filter-pixfmts-scale b/tests/ref/fate/filter-pixfmts-scale
index 54f0db1a76..5478a2be98 100644
--- a/tests/ref/fate/filter-pixfmts-scale
+++ b/tests/ref/fate/filter-pixfmts-scale
@@ -104,6 +104,8 @@ rgb8                bcdc033b4ef0979d060dbc8893d4db58
 rgba                85bb5d03cea1c6e8002ced3373904336
 rgba64be            ee73e57923af984b31cc7795d13929da
 rgba64le            783d2779adfafe3548bdb671ec0de69e
+rgbf32be            8491b339d91c40ad4d96d5b68aefd046
+rgbf32le            0262f60b0a8f1a05b24f3959d8122857
 uyva                2358038be6dac002a6c736e798a3d91c
 uyvy422             aeb4ba4f9f003ae21f6d18089198244f
 v30xle              8cba1fdc0ba2c39eb6fb5885dcf628a7
diff --git a/tests/ref/fate/filter-pixfmts-transpose b/tests/ref/fate/filter-pixfmts-transpose
index 4b07f1bd79..91d61f8e2e 100644
--- a/tests/ref/fate/filter-pixfmts-transpose
+++ b/tests/ref/fate/filter-pixfmts-transpose
@@ -92,6 +92,8 @@ rgb8                c90feb30c3c9391ef5f470209d7b7a15
 rgba                4d76a9542143752a4ac30f82f88f68f1
 rgba64be            a60041217f4c0cd796d19d3940a12a41
 rgba64le            ad47197774858858ae7b0c177dffa459
+rgbf32be            a89fa50c9e278ad1e2bc44a9435c48fd
+rgbf32le            883cc75a2f3f00090b719d99e4c2b1da
 uyva                cb773ee5a9f8964b9c826d55f9f425a3
 v30xle              55147546a787bc72fcb0ca28b1456344
 vuya                9ece18a345beb17cd19e09e443eca4bf
diff --git a/tests/ref/fate/filter-pixfmts-vflip b/tests/ref/fate/filter-pixfmts-vflip
index 7f08bc9254..3fe598f209 100644
--- a/tests/ref/fate/filter-pixfmts-vflip
+++ b/tests/ref/fate/filter-pixfmts-vflip
@@ -104,6 +104,8 @@ rgb8                7df049b6094f8a5e084d74462f6d6cde
 rgba                c1a5908572737f2ae1e5d8218af65f4b
 rgba64be            17e6273323b5779b5f3f775f150c1011
 rgba64le            48f45b10503b7dd140329c3dd0d54c98
+rgbf32be            3fccaf8e4c5a55cb4cca6df18b702525
+rgbf32le            cd0b091dfe143cec2bc9af0cd6af073a
 uyva                d43e89ba3d5c9274e1948eac8630fcc6
 uyvy422             3a237e8376264e0cfa78f8a3fdadec8a
 v30xle              15de0d677d900991e41671a57c431ba5