Revision 4eb7a735

View differences:

libavcodec/ac3dec.c
197 197
} AC3DecodeContext;
198 198

  
199 199
/**
200
 * Generate a Kaiser-Bessel Derived Window.
201
 */
202
static void ac3_window_init(float *window)
203
{
204
   int i, j;
205
   double sum = 0.0, bessel, tmp;
206
   double local_window[256];
207
   double alpha2 = (5.0 * M_PI / 256.0) * (5.0 * M_PI / 256.0);
208

  
209
   for (i = 0; i < 256; i++) {
210
       tmp = i * (256 - i) * alpha2;
211
       bessel = 1.0;
212
       for (j = 100; j > 0; j--) /* default to 100 iterations */
213
           bessel = bessel * tmp / (j * j) + 1;
214
       sum += bessel;
215
       local_window[i] = sum;
216
   }
217

  
218
   sum++;
219
   for (i = 0; i < 256; i++)
220
       window[i] = sqrt(local_window[i] / sum);
221
}
222

  
223
/**
224 200
 * Symmetrical Dequantization
225 201
 * reference: Section 7.3.3 Expansion of Mantissas for Symmetrical Quantization
226 202
 *            Tables 7.19 to 7.23
......
301 277
    ac3_tables_init();
302 278
    ff_mdct_init(&s->imdct_256, 8, 1);
303 279
    ff_mdct_init(&s->imdct_512, 9, 1);
304
    ac3_window_init(s->window);
280
    ff_kbd_window_init(s->window);
305 281
    dsputil_init(&s->dsp, avctx);
306 282
    av_init_random(0, &s->dith_state);
307 283

  
libavcodec/dsputil.h
645 645
    FFTContext fft;
646 646
} MDCTContext;
647 647

  
648
/**
649
 * Generate a Kaiser-Bessel Derived Window.
650
 * @param   window  pointer to half window
651
 */
652
void ff_kbd_window_init(float *window);
653

  
648 654
int ff_mdct_init(MDCTContext *s, int nbits, int inverse);
649 655
void ff_imdct_calc(MDCTContext *s, FFTSample *output,
650 656
                const FFTSample *input, FFTSample *tmp);
libavcodec/mdct.c
25 25
 * MDCT/IMDCT transforms.
26 26
 */
27 27

  
28
// Generate a Kaiser-Bessel Derived Window.
29
void ff_kbd_window_init(float *window)
30
{
31
   int i, j;
32
   double sum = 0.0, bessel, tmp;
33
   double local_window[256];
34
   double alpha2 = (5.0 * M_PI / 256.0) * (5.0 * M_PI / 256.0);
35

  
36
   for (i = 0; i < 256; i++) {
37
       tmp = i * (256 - i) * alpha2;
38
       bessel = 1.0;
39
       for (j = 100; j > 0; j--) /* default to 100 iterations */
40
           bessel = bessel * tmp / (j * j) + 1;
41
       sum += bessel;
42
       local_window[i] = sum;
43
   }
44

  
45
   sum++;
46
   for (i = 0; i < 256; i++)
47
       window[i] = sqrt(local_window[i] / sum);
48
}
49

  
28 50
/**
29 51
 * init MDCT or IMDCT computation.
30 52
 */

Also available in: Unified diff