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

Git pushed a commit to branch master
in repository ffmpeg.

commit 69f0fa91d47c47c13c5182fc294f650aebacdf98
Author:     Niklas Haas <[email protected]>
AuthorDate: Thu Jul 23 19:21:21 2026 +0200
Commit:     Niklas Haas <[email protected]>
CommitDate: Mon Aug 3 09:32:30 2026 +0000

    swscale/lut3d: pad 3DLUT to eliminate over-read
    
    Instead of clamping in the application function. Trivial simplicity gain
    for the SIMD code.
    
    Sponsored-by: Sovereign Tech Fund
    Signed-off-by: Niklas Haas <[email protected]>
---
 libswscale/lut3d.c | 4 ++--
 libswscale/lut3d.h | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/libswscale/lut3d.c b/libswscale/lut3d.c
index 694b455dbc..e521bc4439 100644
--- a/libswscale/lut3d.c
+++ b/libswscale/lut3d.c
@@ -195,10 +195,9 @@ static av_always_inline v3u16_t apply_tone_map(const 
SwsLut3D *lut3d, v3u16_t ip
     const int shift = 16 - TONE_LUT_BITS;
     const int Ix = ipt.x >> shift;
     const int If = ipt.x & ((1 << shift) - 1);
-    const int In = FFMIN(Ix + 1, TONE_LUT_SIZE - 1);
 
     const v2u16_t w0 = lut3d->tone_map[Ix];
-    const v2u16_t w1 = lut3d->tone_map[In];
+    const v2u16_t w1 = lut3d->tone_map[Ix + 1];
     const v2u16_t w  = lerp2u16(w0, w1, If, shift);
     const int base   = (1 << 15) - w.y;
 
@@ -245,6 +244,7 @@ void ff_sws_lut3d_update(SwsLut3D *lut3d, const SwsColor 
*new_src)
     lut3d->map.src.frame_avg  = new_src->frame_avg;
 
     ff_sws_tone_map_generate(lut3d->tone_map, TONE_LUT_SIZE, &lut3d->map);
+    lut3d->tone_map[TONE_LUT_SIZE] = lut3d->tone_map[TONE_LUT_SIZE - 1];
 }
 
 void ff_sws_lut3d_apply(const SwsLut3D *lut3d, const uint8_t *in, int 
in_stride,
diff --git a/libswscale/lut3d.h b/libswscale/lut3d.h
index d2de851604..9e8381a2c0 100644
--- a/libswscale/lut3d.h
+++ b/libswscale/lut3d.h
@@ -56,7 +56,7 @@ typedef struct SwsLut3D {
     v3u16_t output[OUTPUT_LUT_SIZE_PT][OUTPUT_LUT_SIZE_PT][OUTPUT_LUT_SIZE_I];
 
     /* Split tone mapping LUT (for dynamic tone mapping) */
-    v2u16_t tone_map[TONE_LUT_SIZE]; /* new luma, desaturation */
+    v2u16_t tone_map[TONE_LUT_SIZE + 1]; /* new luma, desaturation */
 } SwsLut3D;
 
 SwsLut3D *ff_sws_lut3d_alloc(void);

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

Reply via email to