Mercurial > libavcodec.hg
changeset 7094:b0820b8bd4dd libavcodec
Add generic ff_sine_window_init function and implement in codecs appropriately
author | superdump |
---|---|
date | Sun, 22 Jun 2008 15:12:27 +0000 |
parents | 544da38cb2c9 |
children | af6510f5f7e1 |
files | cook.c dsputil.h imc.c mdct.c nellymoserdec.c |
diffstat | 5 files changed, 19 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/cook.c Sun Jun 22 13:20:41 2008 +0000 +++ b/cook.c Sun Jun 22 15:12:27 2008 +0000 @@ -239,9 +239,9 @@ return -1; /* Initialize the MLT window: simple sine window. */ - alpha = M_PI / (2.0 * (float)mlt_size); + ff_sine_window_init(q->mlt_window, mlt_size); for(j=0 ; j<mlt_size ; j++) - q->mlt_window[j] = sin((j + 0.5) * alpha) * sqrt(2.0 / q->samples_per_channel); + q->mlt_window[j] *= sqrt(2.0 / q->samples_per_channel); /* Initialize the MDCT. */ if (ff_mdct_init(&q->mdct_ctx, av_log2(mlt_size)+1, 1)) {
--- a/dsputil.h Sun Jun 22 13:20:41 2008 +0000 +++ b/dsputil.h Sun Jun 22 15:12:27 2008 +0000 @@ -649,6 +649,13 @@ */ void ff_kbd_window_init(float *window, float alpha, int n); +/** + * Generate a sine window. + * @param window pointer to half window + * @param n size of half window + */ +void ff_sine_window_init(float *window, int n); + int ff_mdct_init(MDCTContext *s, int nbits, int inverse); void ff_imdct_calc(MDCTContext *s, FFTSample *output, const FFTSample *input, FFTSample *tmp);
--- a/imc.c Sun Jun 22 13:20:41 2008 +0000 +++ b/imc.c Sun Jun 22 15:12:27 2008 +0000 @@ -102,8 +102,9 @@ q->old_floor[i] = 1.0; /* Build mdct window, a simple sine window normalized with sqrt(2) */ + ff_sine_window_init(q->mdct_sine_window, COEFFS); for(i = 0; i < COEFFS; i++) - q->mdct_sine_window[i] = sin((i + 0.5) / 512.0 * M_PI) * sqrt(2.0); + q->mdct_sine_window[i] *= sqrt(2.0); for(i = 0; i < COEFFS/2; i++){ q->post_cos[i] = cos(i / 256.0 * M_PI); q->post_sin[i] = sin(i / 256.0 * M_PI);
--- a/mdct.c Sun Jun 22 13:20:41 2008 +0000 +++ b/mdct.c Sun Jun 22 15:12:27 2008 +0000 @@ -48,6 +48,13 @@ window[i] = sqrt(local_window[i] / sum); } +// Generate a sine window. +void ff_sine_window_init(float *window, int n) { + int i; + for(i = 0; i < n; i++) + window[i] = sin((i + 0.5) / (2 * n) * M_PI); +} + /** * init MDCT or IMDCT computation. */
--- a/nellymoserdec.c Sun Jun 22 13:20:41 2008 +0000 +++ b/nellymoserdec.c Sun Jun 22 15:12:27 2008 +0000 @@ -148,9 +148,7 @@ /* Generate overlap window */ if (!sine_window[0]) - for (i=0 ; i<128; i++) { - sine_window[i] = sin((i + 0.5) / 256.0 * M_PI); - } + ff_sine_window_init(sine_window, 128); return 0; }