Commit 9146e4d6 authored by Robert Swain's avatar Robert Swain

Add generic ff_sine_window_init function and implement in codecs appropriately

Originally committed as revision 13888 to svn://svn.ffmpeg.org/ffmpeg/trunk
parent d47f1607
......@@ -239,9 +239,9 @@ static int init_cook_mlt(COOKContext *q) {
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)) {
......
......@@ -649,6 +649,13 @@ typedef struct MDCTContext {
*/
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);
......
......@@ -102,8 +102,9 @@ static av_cold int imc_decode_init(AVCodecContext * avctx)
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);
......
......@@ -48,6 +48,13 @@ void ff_kbd_window_init(float *window, float alpha, int n)
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.
*/
......
......@@ -148,9 +148,7 @@ static av_cold int decode_init(AVCodecContext * avctx) {
/* 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;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment