[FFmpeg-devel] [PATCH] avfilter/af_afftfilt: fix the overlap buffer size (PR #20933)

2025-11-16 Thread nots1dd via ffmpeg-devel
PR #20933 opened by nots1dd
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20933
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20933.patch

>From what I understand, we only need to be moving N bytes as window_size
- s->hop_size after inverse fft to the buffer for overlap. Currently the
compiler throws a warning regarding possible overflow and this patch
fixs it.

I ran FATE and tests are passing


>From 93b8c7d3acdb09c8c9514c513bfb734cac8cbe48 Mon Sep 17 00:00:00 2001
From: nots1dd 
Date: Sun, 16 Nov 2025 16:12:24 +0530
Subject: [PATCH] avfilter/af_afftfilt: fix the overlap buffer size

>From what I understand, we only need to be moving N bytes as window_size
- s->hop_size after inverse fft to the buffer for overlap. Currently the
compiler throws a warning regarding possible overflow and this patch
fixs it.
---
 libavfilter/af_afftfilt.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavfilter/af_afftfilt.c b/libavfilter/af_afftfilt.c
index 08cdcae2f7..4fc28c6143 100644
--- a/libavfilter/af_afftfilt.c
+++ b/libavfilter/af_afftfilt.c
@@ -250,6 +250,7 @@ static int filter_channel(AVFilterContext *ctx, void *arg, 
int jobnr, int nb_job
 {
 AFFTFiltContext *s = ctx->priv;
 const int window_size = s->window_size;
+const int hop_size = s->hop_size;
 const float *window_lut = s->window_func_lut;
 const float f = sqrtf(1.f - s->overlap);
 const int channels = s->channels;
@@ -294,7 +295,7 @@ static int filter_channel(AVFilterContext *ctx, void *arg, 
int jobnr, int nb_job
 
 s->itx_fn(s->ifft[ch], fft_out, fft_temp, sizeof(*fft_temp));
 
-memmove(buf, buf + s->hop_size, window_size * sizeof(float));
+memmove(buf, buf + hop_size, (window_size - hop_size) * sizeof(float));
 for (int i = 0; i < window_size; i++)
 buf[i] += fft_out[i].re * window_lut[i] * f;
 }
-- 
2.49.1

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


[FFmpeg-devel] [PATCH] avfilter/af_afftfilt: fix the overlap buffer size

2025-11-16 Thread nots1dd via ffmpeg-devel
>From what I understand, we only need to be moving N bytes as window_size
- s->hop_size after inverse fft to the buffer for overlap. Currently the
compiler throws a warning regarding possible overflow and this patch
fixs it.
---
 libavfilter/af_afftfilt.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavfilter/af_afftfilt.c b/libavfilter/af_afftfilt.c
index 08cdcae2f7..4fc28c6143 100644
--- a/libavfilter/af_afftfilt.c
+++ b/libavfilter/af_afftfilt.c
@@ -250,6 +250,7 @@ static int filter_channel(AVFilterContext *ctx, void *arg, 
int jobnr, int nb_job
 {
 AFFTFiltContext *s = ctx->priv;
 const int window_size = s->window_size;
+const int hop_size = s->hop_size;
 const float *window_lut = s->window_func_lut;
 const float f = sqrtf(1.f - s->overlap);
 const int channels = s->channels;
@@ -294,7 +295,7 @@ static int filter_channel(AVFilterContext *ctx, void *arg, 
int jobnr, int nb_job
 
 s->itx_fn(s->ifft[ch], fft_out, fft_temp, sizeof(*fft_temp));
 
-memmove(buf, buf + s->hop_size, window_size * sizeof(float));
+memmove(buf, buf + hop_size, (window_size - hop_size) * sizeof(float));
 for (int i = 0; i < window_size; i++)
 buf[i] += fft_out[i].re * window_lut[i] * f;
 }
-- 
2.51.0

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