avfilter/af_afftfilt: calculate all channels FFT values upfront
authorPaul B Mahol <onemda@gmail.com>
Mon, 12 Nov 2018 08:27:08 +0000 (09:27 +0100)
committerPaul B Mahol <onemda@gmail.com>
Mon, 12 Nov 2018 08:27:08 +0000 (09:27 +0100)
libavfilter/af_afftfilt.c

index d5e3b7f..150f8ed 100644 (file)
@@ -289,15 +289,18 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
 
         for (ch = 0; ch < inlink->channels; ch++) {
             FFTComplex *fft_data = s->fft_data[ch];
+
+            av_fft_permute(s->fft, fft_data);
+            av_fft_calc(s->fft, fft_data);
+        }
+
+        for (ch = 0; ch < inlink->channels; ch++) {
+            FFTComplex *fft_data = s->fft_data[ch];
             FFTComplex *fft_temp = s->fft_temp[ch];
             float *buf = (float *)s->buffer->extended_data[ch];
             int x;
-
             values[VAR_CHANNEL] = ch;
 
-            av_fft_permute(s->fft, fft_data);
-            av_fft_calc(s->fft, fft_data);
-
             for (n = 0; n <= window_size / 2; n++) {
                 float fr, fi;