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

Git pushed a commit to branch master
in repository ffmpeg.

commit 4650de8cc1c6b808799aae858e4e1ec1e369d06f
Author:     Niklas Haas <[email protected]>
AuthorDate: Fri Aug 14 10:54:46 2026 +0200
Commit:     Niklas Haas <[email protected]>
CommitDate: Fri Oct 2 14:11:50 2026 +0200

    swscale/uops_tmpl: avoid overflow of intermediate linear products
    
    Multiplying e.g. uint16_t * uint16_t results in implicit promotion to
    signed integer, which might overflow (undefined behavior). Force an
    explicit cast to an unsigned intermediate type large enough to avoid
    promotion to integer. This shouldn't affect codegen because the
    intermediate result is cast right back to `pixel_t`.
    
    Sponsored-by: Sovereign Tech Fund
    Signed-off-by: Niklas Haas <[email protected]>
---
 libswscale/uops_tmpl.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/libswscale/uops_tmpl.c b/libswscale/uops_tmpl.c
index c13ef8669d..4d08502609 100644
--- a/libswscale/uops_tmpl.c
+++ b/libswscale/uops_tmpl.c
@@ -30,6 +30,7 @@
 #  define PIXEL_TYPE SWS_PIXEL_F32
 #  define pixel_t    float
 #  define inter_t    float
+#  define uinter_t   float
 #  define vec3_t     v3f32_t
 #  define PX         F32
 #  define px         f32
@@ -38,6 +39,7 @@
 #  define PIXEL_SWAP av_bswap32
 #  define pixel_t    uint32_t
 #  define inter_t    int64_t
+#  define uinter_t   uint64_t
 #  define PX         U32
 #  define px         u32
 #elif BIT_DEPTH == 16
@@ -45,12 +47,14 @@
 #  define PIXEL_SWAP av_bswap16
 #  define pixel_t    uint16_t
 #  define inter_t    int64_t
+#  define uinter_t   uint64_t
 #  define PX         U16
 #  define px         u16
 #elif BIT_DEPTH == 8
 #  define PIXEL_MAX  0xFFu
 #  define pixel_t    uint8_t
 #  define inter_t    int32_t
+#  define uinter_t   uint32_t
 #  define PX         U8
 #  define px         u8
 #else
@@ -834,7 +838,7 @@ DECL_FUNC(linear, const SwsCompMask mask, const uint32_t 
one, const uint32_t zer
         const pixel_t ww = w[i];
 
 #define LIN_VAL(I, J, val) \
-    ((one & SWS_MASK(I, J)) ? (val) : c.m[I][J] * (val))
+    ((one & SWS_MASK(I, J)) ? (val) : (uinter_t) c.m[I][J] * (val))
 
 #define LIN_ROW(I, var) do {                                    \
     pixel_t tmp = (zero & SWS_MASK(I, 4)) ? 0 : c.k[I];         \
@@ -1017,6 +1021,7 @@ SWS_FOR_STRUCT(PX, LUT_3D, DECL_ENTRY, .setup = 
fn(setup_lut3d) )
 #undef PIXEL_SWAP
 #undef pixel_t
 #undef inter_t
+#undef uinter_t
 #undef vec3_t
 #undef PX
 #undef px

-- 
To stop receiving notification emails like this one, please contact
[email protected].
_______________________________________________
ffmpeg-cvslog mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to