PR #26121 opened by michaelni
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/26121
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/26121.patch


>From 7c5126953808de34ac67b514d8cc86b2e1411abd Mon Sep 17 00:00:00 2001
From: Michael Niedermayer <[email protected]>
Date: Sat, 14 Nov 2026 00:35:47 +0100
Subject: [PATCH 01/14] avfilter/vf_curves: clip planar high bit depth samples
 to the lookup table

Fixes: out of array read
Fixes: 6MsWULeKEl3N
Fixes: AISLE-2026-0166-00695

Found-by: Joshua Rogers (AISLE)

Out of array read Replicated through UnModified FFmpeg with ASAN
---
 libavfilter/vf_curves.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/libavfilter/vf_curves.c b/libavfilter/vf_curves.c
index 69e9c5257c4..d83ac249c99 100644
--- a/libavfilter/vf_curves.c
+++ b/libavfilter/vf_curves.c
@@ -809,6 +809,7 @@ static int filter_slice_planar(AVFilterContext *ctx, void 
*arg, int jobnr, int n
     const uint8_t a = curves->rgba_map[A];
     const int slice_start = ff_slice_pos(in->height, jobnr, nb_jobs);
     const int slice_end   = ff_slice_pos(in->height, jobnr + 1, nb_jobs);
+    const int max = curves->lut_size - 1;
 
     if (curves->is_16bit) {
         for (y = slice_start; y < slice_end; y++) {
@@ -822,9 +823,9 @@ static int filter_slice_planar(AVFilterContext *ctx, void 
*arg, int jobnr, int n
             const uint16_t *srcap = (const uint16_t *)(step == 4 ? in 
->data[a] + y *  in->linesize[a] : NULL);
 
             for (x = 0; x < in->width; x++) {
-                dstrp[x] = curves->graph[R][srcrp[x]];
-                dstgp[x] = curves->graph[G][srcgp[x]];
-                dstbp[x] = curves->graph[B][srcbp[x]];
+                dstrp[x] = curves->graph[R][FFMIN(srcrp[x], max)];
+                dstgp[x] = curves->graph[G][FFMIN(srcgp[x], max)];
+                dstbp[x] = curves->graph[B][FFMIN(srcbp[x], max)];
                 if (!direct && step == 4)
                     dstap[x] = srcap[x];
             }
-- 
2.54.0


>From 483ca51a3f2dfab00d5c850acbd17f0d00194e03 Mon Sep 17 00:00:00 2001
From: Michael Niedermayer <[email protected]>
Date: Sat, 14 Nov 2026 01:57:50 +0100
Subject: [PATCH 02/14] avfilter/vf_lut3d: mask planar high bit depth samples
 in lut1d

Fixes: out of array read
Fixes: vtUg0iajmSsv
Fixes: AISLE-2026-0166-00685

Found-by: Joshua Rogers (AISLE)

Out of array read Replicated through UnModified FFmpeg with ASAN
---
 libavfilter/vf_lut3d.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/libavfilter/vf_lut3d.c b/libavfilter/vf_lut3d.c
index 2c78507b7e4..0151dd447fe 100644
--- a/libavfilter/vf_lut3d.c
+++ b/libavfilter/vf_lut3d.c
@@ -1895,9 +1895,9 @@ static int 
interp_1d_##nbits##_##name##_p##depth(AVFilterContext *ctx,       \
         const uint##nbits##_t *srcr = (const uint##nbits##_t *)srcrrow;      \
         const uint##nbits##_t *srca = (const uint##nbits##_t *)srcarow;      \
         for (x = 0; x < in->width; x++) {                                    \
-            float r = srcr[x] * scale_r;                                     \
-            float g = srcg[x] * scale_g;                                     \
-            float b = srcb[x] * scale_b;                                     \
+            float r = (srcr[x] & ((1 << depth) - 1)) * scale_r;              \
+            float g = (srcg[x] & ((1 << depth) - 1)) * scale_g;              \
+            float b = (srcb[x] & ((1 << depth) - 1)) * scale_b;              \
             r = interp_1d_##name(lut1d, 0, r);                               \
             g = interp_1d_##name(lut1d, 1, g);                               \
             b = interp_1d_##name(lut1d, 2, b);                               \
-- 
2.54.0


>From 4bbd9e808b6ab75147897fe9b5cecab827228d12 Mon Sep 17 00:00:00 2001
From: Michael Niedermayer <[email protected]>
Date: Sat, 14 Nov 2026 00:36:46 +0100
Subject: [PATCH 03/14] avfilter/vf_readeia608: clip high bit depth samples to
 the histogram

Fixes: out of array write
Fixes: 1gH0Fg8kXAvn
Fixes: AISLE-2026-0166-00264

Found-by: Joshua Rogers (AISLE)

Out of array write Replicated through UnModified FFmpeg with ASAN
---
 libavfilter/vf_readeia608.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavfilter/vf_readeia608.c b/libavfilter/vf_readeia608.c
index 86e9019356a..2d23afdf196 100644
--- a/libavfilter/vf_readeia608.c
+++ b/libavfilter/vf_readeia608.c
@@ -173,7 +173,7 @@ static void build_histogram(ReadEIA608Context *s, ScanItem 
*scan, const LineItem
     memset(scan->histogram, 0, (s->max + 1) * sizeof(*scan->histogram));
 
     for (int i = LAG; i < len + LAG; i++)
-        scan->histogram[line[i].input]++;
+        scan->histogram[FFMIN(line[i].input, s->max)]++;
 }
 
 static void find_black_and_white(ReadEIA608Context *s, ScanItem *scan)
-- 
2.54.0


>From 7189c3e54235caeba76597ab078f7051f527285b Mon Sep 17 00:00:00 2001
From: Michael Niedermayer <[email protected]>
Date: Sat, 14 Nov 2026 01:57:50 +0100
Subject: [PATCH 04/14] avfilter/vf_deflicker: allocate the histogram for all
 16 bit sample values

Fixes: out of array write
Fixes: QvFnGUZttUck
Fixes: AISLE-2026-0166-00061

Found-by: berrob14 (#24121)
Found-by: Joshua Rogers (AISLE)

Out of array write Replicated through UnModified FFmpeg with ASAN
---
 libavfilter/vf_deflicker.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavfilter/vf_deflicker.c b/libavfilter/vf_deflicker.c
index 38f838f088c..02ac17f16ba 100644
--- a/libavfilter/vf_deflicker.c
+++ b/libavfilter/vf_deflicker.c
@@ -333,7 +333,7 @@ static int config_input(AVFilterLink *inlink)
         s->calc_avgy = calc_avgy16;
     }
 
-    s->histogram = av_calloc(1 << s->depth, sizeof(*s->histogram));
+    s->histogram = av_calloc(1 << 16, sizeof(*s->histogram));
     if (!s->histogram)
         return AVERROR(ENOMEM);
 
-- 
2.54.0


>From 38614ef417ee886f7edefd81121e01b1d4a2a01c Mon Sep 17 00:00:00 2001
From: Michael Niedermayer <[email protected]>
Date: Sat, 14 Nov 2026 01:57:50 +0100
Subject: [PATCH 05/14] avfilter/vf_tmidequalizer: clip high bit depth samples
 to the histogram

Fixes: out of array access
Fixes: 1xO0YjckaN26
Fixes: AISLE-2026-0166-00146

Found-by: Joshua Rogers (AISLE)

Out of array access Replicated through UnModified FFmpeg with ASAN
---
 libavfilter/vf_tmidequalizer.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/libavfilter/vf_tmidequalizer.c b/libavfilter/vf_tmidequalizer.c
index 102d7c244f0..9bdbcc40da8 100644
--- a/libavfilter/vf_tmidequalizer.c
+++ b/libavfilter/vf_tmidequalizer.c
@@ -52,7 +52,8 @@ typedef struct TMidEqualizerContext {
                               int w, int h, float *histogram, size_t hsize);
     void (*apply_contrast_change)(const uint8_t *src, ptrdiff_t src_linesize,
                                   uint8_t *dst, ptrdiff_t dst_linesize,
-                                  int w, int h, float *change, float *orig);
+                                  int w, int h, float *change, float *orig,
+                                  size_t hsize);
 } TMidEqualizerContext;
 
 #define OFFSET(x) offsetof(TMidEqualizerContext, x)
@@ -135,7 +136,8 @@ static void compute_contrast_function(const float *const 
histograms[256],
 
 static void apply_contrast_change8(const uint8_t *src, ptrdiff_t src_linesize,
                                    uint8_t *dst, ptrdiff_t dst_linesize,
-                                   int w, int h, float *change, float *orig)
+                                   int w, int h, float *change, float *orig,
+                                   size_t hsize)
 {
     for (int y = 0; y < h; y++) {
         for (int x = 0; x < w; x++)
@@ -148,14 +150,15 @@ static void apply_contrast_change8(const uint8_t *src, 
ptrdiff_t src_linesize,
 
 static void apply_contrast_change16(const uint8_t *ssrc, ptrdiff_t 
src_linesize,
                                     uint8_t *ddst, ptrdiff_t dst_linesize,
-                                    int w, int h, float *change, float *orig)
+                                    int w, int h, float *change, float *orig,
+                                    size_t hsize)
 {
     const uint16_t *src = (const uint16_t *)ssrc;
     uint16_t *dst = (uint16_t *)ddst;
 
     for (int y = 0; y < h; y++) {
         for (int x = 0; x < w; x++)
-            dst[x] = lrintf(change[src[x]]);
+            dst[x] = lrintf(change[FFMIN(src[x], hsize - 1)]);
 
         dst += dst_linesize / 2;
         src += src_linesize / 2;
@@ -271,7 +274,8 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
             s->apply_contrast_change(in->data[p], in->linesize[p],
                                      out->data[p], out->linesize[p],
                                      s->plane_width[p], s->plane_height[p],
-                                     s->change[p], s->histogram[p][idx]);
+                                     s->change[p], s->histogram[p][idx],
+                                     s->histogram_size);
         }
     }
 
@@ -309,7 +313,7 @@ static void compute_histogram16(const uint8_t *ssrc, 
ptrdiff_t linesize,
 
     for (int y = 0; y < h; y++) {
         for (int x = 0; x < w; x++)
-            histogram[src[x]] += 1;
+            histogram[FFMIN(src[x], hsize - 1)] += 1;
         src += linesize / 2;
     }
 
-- 
2.54.0


>From 90be2c18dd49cd906387150d5b610837b0a19bf8 Mon Sep 17 00:00:00 2001
From: Michael Niedermayer <[email protected]>
Date: Sat, 14 Nov 2026 01:58:22 +0100
Subject: [PATCH 06/14] avfilter/vf_signalstats: allocate the histograms for
 all 16 bit sample values

Fixes: out of array write
Fixes: 91956.4 is outside the range of representable values of type 'unsigned 
short'
Fixes: 3DKcZFM0ZaFw
Fixes: AISLE-2026-0166-00233

Found-by: Joshua Rogers (AISLE)

Out of array write Replicated through UnModified FFmpeg with ASAN
Float to integer overflow Replicated through UnModified FFmpeg with UBSAN
---
 libavfilter/vf_signalstats.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/libavfilter/vf_signalstats.c b/libavfilter/vf_signalstats.c
index 5859b46478c..a904ae6551b 100644
--- a/libavfilter/vf_signalstats.c
+++ b/libavfilter/vf_signalstats.c
@@ -161,10 +161,10 @@ static int config_output(AVFilterLink *outlink)
     s->vsub = desc->log2_chroma_h;
     s->depth = desc->comp[0].depth;
     s->maxsize = 1 << s->depth;
-    s->histy = av_malloc_array(s->maxsize, sizeof(*s->histy));
-    s->histu = av_malloc_array(s->maxsize, sizeof(*s->histu));
-    s->histv = av_malloc_array(s->maxsize, sizeof(*s->histv));
-    s->histsat = av_malloc_array(s->maxsize, sizeof(*s->histsat));
+    s->histy = av_calloc(1 << 16, sizeof(*s->histy));
+    s->histu = av_calloc(1 << 16, sizeof(*s->histu));
+    s->histv = av_calloc(1 << 16, sizeof(*s->histv));
+    s->histsat = av_calloc(1 << 16, sizeof(*s->histsat));
 
     if (!s->histy || !s->histu || !s->histv || !s->histsat)
         return AVERROR(ENOMEM);
@@ -520,7 +520,7 @@ static int compute_sat_hue_metrics16(AVFilterContext *ctx, 
void *arg, int jobnr,
         for (i = 0; i < s->chromaw; i++) {
             const int yuvu = p_u[i];
             const int yuvv = p_v[i];
-            p_sat[i] = hypotf(yuvu - mid, yuvv - mid); // int or round?
+            p_sat[i] = (int)hypotf(yuvu - mid, yuvv - mid); // int or round?
             ((int16_t*)p_hue)[i] = fmodf(floorf((180.f / M_PI) * 
atan2f(yuvu-mid, yuvv-mid) + 180.f), 360.f);
         }
         p_u   += lsz_u;
-- 
2.54.0


>From ec0b23a5d5628f6225e39a3559e4a70af7b60529 Mon Sep 17 00:00:00 2001
From: Michael Niedermayer <[email protected]>
Date: Sat, 14 Nov 2026 01:57:50 +0100
Subject: [PATCH 07/14] avfilter/vf_colorchannelmixer: mask planar high bit
 depth samples to their depth

Fixes: out of array read
Fixes: yqhg3KTUAWGt
Fixes: AISLE-2026-0166-00099

Found-by: Joshua Rogers (AISLE)

Out of array read Replicated through UnModified FFmpeg with ASAN
---
 libavfilter/colorchannelmixer_template.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/libavfilter/colorchannelmixer_template.c 
b/libavfilter/colorchannelmixer_template.c
index aed5c59cff8..fa2091cacdb 100644
--- a/libavfilter/colorchannelmixer_template.c
+++ b/libavfilter/colorchannelmixer_template.c
@@ -23,19 +23,23 @@
 #undef pixel
 #undef cpixel
 #undef ROUND
+#undef MASK_TO_DEPTH
 #if DEPTH == 8
 #define pixel uint8_t
 #define cpixel int
 #define ROUND lrintf
+#define MASK_TO_DEPTH(x) (x)
 #elif DEPTH == 16
 #define pixel uint16_t
 #define cpixel int
 #define ROUND lrintf
+#define MASK_TO_DEPTH(x) ((x) & ((1 << depth) - 1))
 #else
 #define NOP(x) (x)
 #define pixel float
 #define cpixel float
 #define ROUND NOP
+#define MASK_TO_DEPTH NOP
 #endif
 
 #undef fn
@@ -67,10 +71,10 @@ static av_always_inline int 
fn(filter_slice_rgba_planar)(AVFilterContext *ctx, v
 
     for (int i = slice_start; i < slice_end; i++) {
         for (int j = 0; j < out->width; j++) {
-            const pixel rin = srcr[j];
-            const pixel gin = srcg[j];
-            const pixel bin = srcb[j];
-            const pixel ain = have_alpha ? srca[j] : 0;
+            const pixel rin = MASK_TO_DEPTH(srcr[j]);
+            const pixel gin = MASK_TO_DEPTH(srcg[j]);
+            const pixel bin = MASK_TO_DEPTH(srcb[j]);
+            const pixel ain = have_alpha ? MASK_TO_DEPTH(srca[j]) : 0;
             cpixel rout, gout, bout;
 
 #if DEPTH == 32
-- 
2.54.0


>From 75ec77a778b0121d3430548bd2763f3e4b23524c Mon Sep 17 00:00:00 2001
From: Michael Niedermayer <[email protected]>
Date: Sat, 14 Nov 2026 00:39:40 +0100
Subject: [PATCH 08/14] avfilter/vf_lut2: restrict the pixel formats of the
 second input when an output depth is set

Fixes: out of array read
Fixes: KGLXYgEtxsqI
Fixes: AISLE-2026-0166-00510

Found-by: Joshua Rogers (AISLE)

Out of array read Replicated through UnModified FFmpeg with ASAN
---
 libavfilter/vf_lut2.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/libavfilter/vf_lut2.c b/libavfilter/vf_lut2.c
index cabdc980ea1..dfc30754d0f 100644
--- a/libavfilter/vf_lut2.c
+++ b/libavfilter/vf_lut2.c
@@ -182,9 +182,11 @@ static int query_formats(const AVFilterContext *ctx,
     if (s->tlut2 || !s->odepth)
         return ff_set_pixel_formats_from_list2(ctx, cfg_in, cfg_out, 
all_pix_fmts);
 
-    ret = ff_formats_ref(ff_make_pixel_format_list(all_pix_fmts), 
&cfg_in[0]->formats);
-    if (ret < 0)
-        return ret;
+    for (int i = 0; i < 2; i++) {
+        ret = ff_formats_ref(ff_make_pixel_format_list(all_pix_fmts), 
&cfg_in[i]->formats);
+        if (ret < 0)
+            return ret;
+    }
 
     switch (s->odepth) {
     case 8:  pix_fmts = bit8_pix_fmts;  break;
-- 
2.54.0


>From bd5a8e549f2c5b80312345ef9fd6b649b3fbe624 Mon Sep 17 00:00:00 2001
From: Michael Niedermayer <[email protected]>
Date: Sat, 14 Nov 2026 01:57:51 +0100
Subject: [PATCH 09/14] avfilter/vf_lut2: mask the index into the lookup table

Fixes: out of array read
Fixes: 7lsmzPaM2P1v

Found during triage of the security report AISLE-2026-R0057

Out of array read Replicated through UnModified FFmpeg with ASAN
---
 libavfilter/vf_lut2.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavfilter/vf_lut2.c b/libavfilter/vf_lut2.c
index dfc30754d0f..e89ad032ade 100644
--- a/libavfilter/vf_lut2.c
+++ b/libavfilter/vf_lut2.c
@@ -258,6 +258,7 @@ static int lut2_##zname##_##xname##_##yname(AVFilterContext 
*ctx,
     AVFrame *srcx = td->srcx;                                                  
  \
     AVFrame *srcy = td->srcy;                                                  
  \
     const int odepth = s->odepth;                                              
  \
+    const int lut_mask = sizeof(xtype) + sizeof(ytype) == 2 ? -1 : (1 << 
s->depth) - 1; \
     int p, y, x;                                                               
  \
                                                                                
  \
     for (p = 0; p < s->nb_planes; p++) {                                       
  \
@@ -274,7 +275,7 @@ static int lut2_##zname##_##xname##_##yname(AVFilterContext 
*ctx,
                                                                                
  \
         for (y = slice_start; y < slice_end; y++) {                            
  \
             for (x = 0; x < s->widthx[p]; x++) {                               
  \
-                dst[x] = av_clip_uintp2_c(lut[(srcyy[x] << s->depthx) | 
srcxx[x]], odepth); \
+                dst[x] = av_clip_uintp2_c(lut[((srcyy[x] << s->depthx) | 
srcxx[x]) & lut_mask], odepth); \
             }                                                                  
  \
                                                                                
  \
             dst   += out->linesize[p] / zdiv;                                  
  \
-- 
2.54.0


>From 80096b67c1a0e95afffee6451983dfc55580a457 Mon Sep 17 00:00:00 2001
From: Michael Niedermayer <[email protected]>
Date: Sat, 14 Nov 2026 01:57:51 +0100
Subject: [PATCH 10/14] avfilter/vf_entropy: allocate the histogram for all 16
 bit sample values

Fixes: out of array access
Fixes: QHL0p233f9jc

Found during triage of the security report AISLE-2026-R0057

Out of array access Replicated through UnModified FFmpeg with ASAN
---
 libavfilter/vf_entropy.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavfilter/vf_entropy.c b/libavfilter/vf_entropy.c
index 1d13bb484b9..e53d183e533 100644
--- a/libavfilter/vf_entropy.c
+++ b/libavfilter/vf_entropy.c
@@ -91,7 +91,7 @@ static int config_input(AVFilterLink *inlink)
     s->planenames[2] = s->is_rgb ? 'B' : 'V';
     s->planenames[3] = 'A';
 
-    s->histogram = av_malloc_array(1 << s->depth, sizeof(*s->histogram));
+    s->histogram = av_calloc(1 << 16, sizeof(*s->histogram));
     if (!s->histogram)
         return AVERROR(ENOMEM);
 
-- 
2.54.0


>From c2a142a86429869f669b008ec2846bf8627fc516 Mon Sep 17 00:00:00 2001
From: Michael Niedermayer <[email protected]>
Date: Sat, 14 Nov 2026 01:57:51 +0100
Subject: [PATCH 11/14] avfilter/vf_hqdn3d: mask high bit depth samples to
 their depth

Fixes: out of array read
Fixes: 8Z3kXCidIqzE

Found-by: berrob14 (#24121)
Found independently during triage of the security report AISLE-2026-R0057

Out of array read Replicated through UnModified FFmpeg with ASAN
---
 libavfilter/vf_hqdn3d.c       | 2 +-
 libavfilter/x86/vf_hqdn3d.asm | 3 +++
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/libavfilter/vf_hqdn3d.c b/libavfilter/vf_hqdn3d.c
index 3b46b6d4f80..e5c73d350d5 100644
--- a/libavfilter/vf_hqdn3d.c
+++ b/libavfilter/vf_hqdn3d.c
@@ -42,7 +42,7 @@
 #include "vf_hqdn3d.h"
 
 #define LUT_BITS (depth==16 ? 8 : 4)
-#define LOAD(x) (((depth == 8 ? src[x] : AV_RN16A(src + (x) * 2)) << (16 - 
depth))\
+#define LOAD(x) (((depth == 8 ? src[x] : AV_RN16A(src + (x) * 2) & ((1 << 
depth) - 1)) << (16 - depth))\
                  + (((1 << (16 - depth)) - 1) >> 1))
 #define STORE(x,val) (depth == 8 ? dst[x] = (val) >> (16 - depth) : \
                                    AV_WN16A(dst + (x) * 2, (val) >> (16 - 
depth)))
diff --git a/libavfilter/x86/vf_hqdn3d.asm b/libavfilter/x86/vf_hqdn3d.asm
index 1dfdc6c8fbb..cbe21e057d9 100644
--- a/libavfilter/x86/vf_hqdn3d.asm
+++ b/libavfilter/x86/vf_hqdn3d.asm
@@ -38,6 +38,9 @@ SECTION .text
     movzx  %1, word [srcq+(%2)*2]
 %endif
 %if %3 != 16
+%if %3 != 8
+    and    %1, (1<<%3)-1
+%endif
     shl    %1, 16-%3
     add    %1, (1<<(15-%3))-1
 %endif
-- 
2.54.0


>From 0f777fffd3a6c3ae153b4d363a60b586e82a03bc Mon Sep 17 00:00:00 2001
From: Michael Niedermayer <[email protected]>
Date: Sat, 14 Nov 2026 01:57:51 +0100
Subject: [PATCH 12/14] avfilter/vf_median: mask the histogram bins of high bit
 depth samples

Fixes: out of array write
Fixes: M6ZGmNclqAuM

Found during triage of the security report AISLE-2026-R0057

Out of array write Replicated through UnModified FFmpeg with ASAN
---
 libavfilter/median_template.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavfilter/median_template.c b/libavfilter/median_template.c
index 57ee7cb7e56..e18dd126985 100644
--- a/libavfilter/median_template.c
+++ b/libavfilter/median_template.c
@@ -44,8 +44,8 @@
 #define fn2(a,b)   fn3(a,b)
 #define fn(a)      fn2(a, DEPTH)
 
-#define PICK_COARSE_BIN(x, y) (BINS * (x) + ((y) >> SHIFT))
-#define PICK_FINE_BIN(x, y, z) (BINS * ((x) * ((y) >> SHIFT) + (z)) + ((y) & 
MASK))
+#define PICK_COARSE_BIN(x, y) (BINS * (x) + (((y) >> SHIFT) & MASK))
+#define PICK_FINE_BIN(x, y, z) (BINS * ((x) * (((y) >> SHIFT) & MASK) + (z)) + 
((y) & MASK))
 
 static void fn(filter_plane)(AVFilterContext *ctx, const uint8_t *ssrc, int 
src_linesize,
                              uint8_t *ddst, int dst_linesize, int width, int 
height,
-- 
2.54.0


>From cf7dac47322786e0bf6a68f01f618b2055770865 Mon Sep 17 00:00:00 2001
From: Michael Niedermayer <[email protected]>
Date: Sat, 14 Nov 2026 01:57:51 +0100
Subject: [PATCH 13/14] avfilter/vf_histogram: avoid a division by 0 when no
 sample is within the histogram

Fixes: division by zero
Fixes: 8cytnsCgSI9y

Found during triage of the security report AISLE-2026-R0057

Division by zero Replicated through UnModified FFmpeg with UBSAN
---
 libavfilter/vf_histogram.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavfilter/vf_histogram.c b/libavfilter/vf_histogram.c
index d9bba081343..b1207f92797 100644
--- a/libavfilter/vf_histogram.c
+++ b/libavfilter/vf_histogram.c
@@ -444,7 +444,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
         const int width = s->planewidth[p];
         const int mid = s->mid;
         double max_hval_log;
-        unsigned max_hval = 0;
+        unsigned max_hval = 1;
         int starty, startx;
 
         if (!((1 << k) & s->components))
-- 
2.54.0


>From 9bdfe3c14d3c897c2d69ed8e218278b6f2934704 Mon Sep 17 00:00:00 2001
From: Michael Niedermayer <[email protected]>
Date: Sat, 14 Nov 2026 02:01:23 +0100
Subject: [PATCH 14/14] avfilter/vf_deflicker: limit the factor so the scaled
 samples fit in an int

Fixes: -nan is outside the range of representable values of type 'int'
Fixes: g08Dzsg95lYL

Found during triage of the security report AISLE-2026-R0057

Undefined float to integer conversion Replicated through UnModified FFmpeg with 
UBSAN
---
 libavfilter/vf_deflicker.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavfilter/vf_deflicker.c b/libavfilter/vf_deflicker.c
index 02ac17f16ba..c1a3d88490f 100644
--- a/libavfilter/vf_deflicker.c
+++ b/libavfilter/vf_deflicker.c
@@ -378,7 +378,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *buf)
     s->get_factor(ctx, &f);
     if (!s->bypass)
         s->deflicker(ctx, in->data[0], in->linesize[0], out->data[0], 
out->linesize[0],
-                     outlink->w, outlink->h, f);
+                     outlink->w, outlink->h, av_clipf(f, 0, INT_MAX / 
UINT16_MAX));
     for (y = 1 - s->bypass; y < s->nb_planes; y++) {
         av_image_copy_plane(out->data[y], out->linesize[y],
                             in->data[y], in->linesize[y],
-- 
2.54.0

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

Reply via email to