/*
* MDCT/IMDCT transforms
- * Copyright (c) 2002 Fabrice Bellard.
+ * Copyright (c) 2002 Fabrice Bellard
*
* This file is part of FFmpeg.
*
#include "dsputil.h"
/**
- * @file mdct.c
+ * @file libavcodec/mdct.c
* MDCT/IMDCT transforms.
*/
// Generate a Kaiser-Bessel Derived Window.
#define BESSEL_I0_ITER 50 // default: 50 iterations of Bessel I0 approximation
-void ff_kbd_window_init(float *window, float alpha, int n)
+av_cold void ff_kbd_window_init(float *window, float alpha, int n)
{
int i, j;
double sum = 0.0, bessel, tmp;
DECLARE_ALIGNED(16, float, ff_sine_512 [ 512]);
DECLARE_ALIGNED(16, float, ff_sine_1024[1024]);
DECLARE_ALIGNED(16, float, ff_sine_2048[2048]);
-float *ff_sine_windows[5] = {
- ff_sine_128, ff_sine_256, ff_sine_512, ff_sine_1024, ff_sine_2048,
+DECLARE_ALIGNED(16, float, ff_sine_4096[4096]);
+float *ff_sine_windows[6] = {
+ ff_sine_128, ff_sine_256, ff_sine_512, ff_sine_1024, ff_sine_2048, ff_sine_4096
};
// Generate a sine window.
-void ff_sine_window_init(float *window, int n) {
- float alpha = M_PI / (2.0 * n);
+av_cold void ff_sine_window_init(float *window, int n) {
int i;
for(i = 0; i < n; i++)
- window[i] = sin((i + 0.5) * alpha);
+ window[i] = sinf((i + 0.5) * (M_PI / (2.0 * n)));
}
/**
* init MDCT or IMDCT computation.
*/
-int ff_mdct_init(MDCTContext *s, int nbits, int inverse)
+av_cold int ff_mdct_init(MDCTContext *s, int nbits, int inverse, double scale)
{
int n, n4, i;
- double alpha;
+ double alpha, theta;
memset(s, 0, sizeof(*s));
n = 1 << nbits;
if (!s->tsin)
goto fail;
+ theta = 1.0 / 8.0 + (scale < 0 ? n4 : 0);
+ scale = sqrt(fabs(scale));
for(i=0;i<n4;i++) {
- alpha = 2 * M_PI * (i + 1.0 / 8.0) / n;
- s->tcos[i] = -cos(alpha);
- s->tsin[i] = -sin(alpha);
+ alpha = 2 * M_PI * (i + theta) / n;
+ s->tcos[i] = -cos(alpha) * scale;
+ s->tsin[i] = -sin(alpha) * scale;
}
if (ff_fft_init(&s->fft, s->nbits - 2, inverse) < 0)
goto fail;
ff_fft_calc(&s->fft, z);
/* post rotation + reordering */
- output += n4;
for(k = 0; k < n8; k++) {
FFTSample r0, i0, r1, i1;
CMUL(r0, i1, z[n8-k-1].im, z[n8-k-1].re, tsin[n8-k-1], tcos[n8-k-1]);
* Compute inverse MDCT of size N = 2^nbits
* @param output N samples
* @param input N/2 samples
- * @param tmp N/2 samples
*/
void ff_imdct_calc_c(MDCTContext *s, FFTSample *output, const FFTSample *input)
{
* Compute MDCT of size N = 2^nbits
* @param input N samples
* @param out N/2 samples
- * @param tmp temporary storage of N/2 samples
*/
void ff_mdct_calc(MDCTContext *s, FFTSample *out, const FFTSample *input)
{
}
}
-void ff_mdct_end(MDCTContext *s)
+av_cold void ff_mdct_end(MDCTContext *s)
{
av_freep(&s->tcos);
av_freep(&s->tsin);