[FFmpeg-devel] [PATCH 03/12] mdct: remove temporary array in ff_kbd_window_init()

Mans Rullgard mans
Wed Jun 23 19:26:41 CEST 2010


The intermediate values can be stored in the output array, avoiding
the need for a variable-length array.
---
 libavcodec/mdct.c |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/libavcodec/mdct.c b/libavcodec/mdct.c
index 69e1bbf..e872e0c 100644
--- a/libavcodec/mdct.c
+++ b/libavcodec/mdct.c
@@ -36,7 +36,6 @@ av_cold void ff_kbd_window_init(float *window, float alpha, int n)
 {
    int i, j;
    double sum = 0.0, bessel, tmp;
-   double local_window[n];
    double alpha2 = (alpha * M_PI / n) * (alpha * M_PI / n);
 
    for (i = 0; i < n; i++) {
@@ -45,12 +44,12 @@ av_cold void ff_kbd_window_init(float *window, float alpha, int n)
        for (j = BESSEL_I0_ITER; j > 0; j--)
            bessel = bessel * tmp / (j * j) + 1;
        sum += bessel;
-       local_window[i] = sum;
+       window[i] = sum;
    }
 
    sum++;
    for (i = 0; i < n; i++)
-       window[i] = sqrt(local_window[i] / sum);
+       window[i] = sqrt(window[i] / sum);
 }
 
 #include "mdct_tablegen.h"
-- 
1.7.1




More information about the ffmpeg-devel mailing list