This is an automated email from the git hooks/post-receive script.

Git pushed a commit to branch master
in repository ffmpeg.

commit 59166b4131baa9a3c0e840f25ffeec52b03fddde
Author:     Ramiro Polla <[email protected]>
AuthorDate: Tue May 26 01:29:05 2026 +0200
Commit:     Ramiro Polla <[email protected]>
CommitDate: Fri Jun 5 22:33:58 2026 +0200

    swscale/input: fix rgbf32 input (add half input functions)
    
    The rgbf32 input code was missing the subsampled input functions.
    
    This fixes:
    $ ./libswscale/tests/swscale -scaler none -src rgbf32be -dst rgb565be
    rgbf32be 96x96 -> rgb565be 96x96, flags=0x0 dither=1 scaler=0/0, 
SSIM={Y=0.999820 U=0.932819 V=0.924956 A=1.000000} loss=1.436615e-02
    rgbf32be 96x96 -> rgb565be 96x96, flags=0x0 dither=1 scaler=0/0
      loss 1.436615e-02 is WORSE by 1.413935e-02, expected loss 2.267957e-04
    
    Sponsored-by: Sovereign Tech Fund
    Signed-off-by: Ramiro Polla <[email protected]>
---
 libswscale/input.c | 37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)

diff --git a/libswscale/input.c b/libswscale/input.c
index 71ff3a6553..2e6dd6f413 100644
--- a/libswscale/input.c
+++ b/libswscale/input.c
@@ -1354,6 +1354,29 @@ static av_always_inline void rgbf32_to_uv_c(uint8_t 
*_dstU, uint8_t *_dstV, cons
     }
 }
 
+static av_always_inline void rgbf32_to_uv_half_c(uint8_t *_dstU, uint8_t 
*_dstV, const uint8_t *unused1,
+                                                 const uint8_t *_src, const 
uint8_t *unused2,
+                                                 int width, int is_be, int32_t 
*rgb2yuv)
+{
+    const float *src = (const float *) _src;
+    uint16_t *dstU   = (uint16_t *) _dstU;
+    uint16_t *dstV   = (uint16_t *) _dstV;
+    int32_t ru = rgb2yuv[RU_IDX], gu = rgb2yuv[GU_IDX], bu = rgb2yuv[BU_IDX];
+    int32_t rv = rgb2yuv[RV_IDX], gv = rgb2yuv[GV_IDX], bv = rgb2yuv[BV_IDX];
+
+    for (int i = 0; i < width; i++) {
+        int r = (lrintf(av_clipf(65535.0f * rdpx(&src[6 * i + 0]), 0.0f, 
65535.0f)) +
+                 lrintf(av_clipf(65535.0f * rdpx(&src[6 * i + 3]), 0.0f, 
65535.0f))) >> 1;
+        int g = (lrintf(av_clipf(65535.0f * rdpx(&src[6 * i + 1]), 0.0f, 
65535.0f)) +
+                 lrintf(av_clipf(65535.0f * rdpx(&src[6 * i + 4]), 0.0f, 
65535.0f))) >> 1;
+        int b = (lrintf(av_clipf(65535.0f * rdpx(&src[6 * i + 2]), 0.0f, 
65535.0f)) +
+                 lrintf(av_clipf(65535.0f * rdpx(&src[6 * i + 5]), 0.0f, 
65535.0f))) >> 1;
+
+        dstU[i] = (ru*r + gu*g + bu*b + (0x10001 << (RGB2YUV_SHIFT - 1))) >> 
RGB2YUV_SHIFT;
+        dstV[i] = (rv*r + gv*g + bv*b + (0x10001 << (RGB2YUV_SHIFT - 1))) >> 
RGB2YUV_SHIFT;
+    }
+}
+
 static av_always_inline void rgbf32_to_y_c(uint8_t *_dst, const uint8_t *_src,
                                            const uint8_t *unused1, const 
uint8_t *unused2,
                                            int width, int is_be, int32_t 
*rgb2yuv)
@@ -1502,6 +1525,14 @@ static void rgbf32##endian_name##_to_uv_c(uint8_t *dstU, 
uint8_t *dstV,
 {                                                                              
                     \
     rgbf32_to_uv_c(dstU, dstV, unused1, src, unused2, w, endian, rgb2yuv);     
                     \
 }                                                                              
                     \
+static void rgbf32##endian_name##_to_uv_half_c(uint8_t *dstU, uint8_t *dstV,   
                     \
+                                               const uint8_t *unused1,         
                     \
+                                               const uint8_t *src, const 
uint8_t *unused2,          \
+                                               int w, uint32_t *rgb2yuv,       
                     \
+                                               void *opq)                      
                     \
+{                                                                              
                     \
+    rgbf32_to_uv_half_c(dstU, dstV, unused1, src, unused2, w, endian, 
rgb2yuv);                     \
+}                                                                              
                     \
 static void grayf32##endian_name##ToY16_c(uint8_t *dst, const uint8_t *src,    
                     \
                                           const uint8_t *unused1, const 
uint8_t *unused2,           \
                                           int width, uint32_t *unused, void 
*opq)                   \
@@ -2193,6 +2224,12 @@ av_cold void ff_sws_init_input_funcs(SwsInternal *c,
         case AV_PIX_FMT_RGBF16LE:
             *chrToYV12 = rgbf16leToUV_half_c;
             break;
+        case AV_PIX_FMT_RGBF32BE:
+            *chrToYV12 = rgbf32be_to_uv_half_c;
+            break;
+        case AV_PIX_FMT_RGBF32LE:
+            *chrToYV12 = rgbf32le_to_uv_half_c;
+            break;
         }
     } else {
         switch (srcFormat) {

_______________________________________________
ffmpeg-cvslog mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to