[FFmpeg-cvslog] avfilter/af_surround: refactor some code

Paul B Mahol git at videolan.org
Tue Dec 5 00:16:38 EET 2023


ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Mon Dec  4 21:46:07 2023 +0100| [704ef556fe7a4eab5d9aa520a62622f8f29d4e2b] | committer: Paul B Mahol

avfilter/af_surround: refactor some code

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=704ef556fe7a4eab5d9aa520a62622f8f29d4e2b
---

 libavfilter/af_surround.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/libavfilter/af_surround.c b/libavfilter/af_surround.c
index 79df86081c..5db123b81f 100644
--- a/libavfilter/af_surround.c
+++ b/libavfilter/af_surround.c
@@ -1213,15 +1213,17 @@ static int fft_channel(AVFilterContext *ctx, AVFrame *in, int ch)
     AudioSurroundContext *s = ctx->priv;
     float *src = (float *)s->input_in->extended_data[ch];
     float *win = (float *)s->window->extended_data[ch];
+    const float *window_func_lut = s->window_func_lut;
     const int offset = s->win_size - s->hop_size;
     const float level_in = s->input_levels[ch];
+    const int win_size = s->win_size;
 
     memmove(src, &src[s->hop_size], offset * sizeof(float));
     memcpy(&src[offset], in->extended_data[ch], in->nb_samples * sizeof(float));
     memset(&src[offset + in->nb_samples], 0, (s->hop_size - in->nb_samples) * sizeof(float));
 
-    for (int n = 0; n < s->win_size; n++)
-        win[n] = src[n] * s->window_func_lut[n] * level_in;
+    for (int n = 0; n < win_size; n++)
+        win[n] = src[n] * window_func_lut[n] * level_in;
 
     s->tx_fn(s->rdft[ch], (float *)s->input->extended_data[ch], win, sizeof(float));
 
@@ -1244,6 +1246,8 @@ static int ifft_channel(AVFilterContext *ctx, AVFrame *out, int ch)
 {
     AudioSurroundContext *s = ctx->priv;
     const float level_out = s->output_levels[ch] * s->win_gain;
+    const float *window_func_lut = s->window_func_lut;
+    const int win_size = s->win_size;
     float *dst, *ptr;
 
     dst = (float *)s->output_out->extended_data[ch];
@@ -1256,8 +1260,8 @@ static int ifft_channel(AVFilterContext *ctx, AVFrame *out, int ch)
     memset(s->overlap_buffer->extended_data[ch] + s->win_size * sizeof(float),
            0, s->hop_size * sizeof(float));
 
-    for (int n = 0; n < s->win_size; n++)
-        ptr[n] += dst[n] * s->window_func_lut[n] * level_out;
+    for (int n = 0; n < win_size; n++)
+        ptr[n] += dst[n] * window_func_lut[n] * level_out;
 
     ptr = (float *)s->overlap_buffer->extended_data[ch];
     dst = (float *)out->extended_data[ch];



More information about the ffmpeg-cvslog mailing list