|
|
@ -72,15 +72,15 @@ av_cold void ff_sine_window_init(float *window, int n) { |
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* init MDCT or IMDCT computation. |
|
|
|
* init MDCT or IMDCT computation. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
av_cold int ff_mdct_init(MDCTContext *s, int nbits, int inverse, double scale) |
|
|
|
av_cold int ff_mdct_init(FFTContext *s, int nbits, int inverse, double scale) |
|
|
|
{ |
|
|
|
{ |
|
|
|
int n, n4, i; |
|
|
|
int n, n4, i; |
|
|
|
double alpha, theta; |
|
|
|
double alpha, theta; |
|
|
|
|
|
|
|
|
|
|
|
memset(s, 0, sizeof(*s)); |
|
|
|
memset(s, 0, sizeof(*s)); |
|
|
|
n = 1 << nbits; |
|
|
|
n = 1 << nbits; |
|
|
|
s->nbits = nbits; |
|
|
|
s->mdct_bits = nbits; |
|
|
|
s->n = n; |
|
|
|
s->mdct_size = n; |
|
|
|
n4 = n >> 2; |
|
|
|
n4 = n >> 2; |
|
|
|
s->tcos = av_malloc(n4 * sizeof(FFTSample)); |
|
|
|
s->tcos = av_malloc(n4 * sizeof(FFTSample)); |
|
|
|
if (!s->tcos) |
|
|
|
if (!s->tcos) |
|
|
@ -96,7 +96,7 @@ av_cold int ff_mdct_init(MDCTContext *s, int nbits, int inverse, double scale) |
|
|
|
s->tcos[i] = -cos(alpha) * scale; |
|
|
|
s->tcos[i] = -cos(alpha) * scale; |
|
|
|
s->tsin[i] = -sin(alpha) * scale; |
|
|
|
s->tsin[i] = -sin(alpha) * scale; |
|
|
|
} |
|
|
|
} |
|
|
|
if (ff_fft_init(&s->fft, s->nbits - 2, inverse) < 0) |
|
|
|
if (ff_fft_init(s, s->mdct_bits - 2, inverse) < 0) |
|
|
|
goto fail; |
|
|
|
goto fail; |
|
|
|
return 0; |
|
|
|
return 0; |
|
|
|
fail: |
|
|
|
fail: |
|
|
@ -122,16 +122,16 @@ av_cold int ff_mdct_init(MDCTContext *s, int nbits, int inverse, double scale) |
|
|
|
* @param output N/2 samples |
|
|
|
* @param output N/2 samples |
|
|
|
* @param input N/2 samples |
|
|
|
* @param input N/2 samples |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
void ff_imdct_half_c(MDCTContext *s, FFTSample *output, const FFTSample *input) |
|
|
|
void ff_imdct_half_c(FFTContext *s, FFTSample *output, const FFTSample *input) |
|
|
|
{ |
|
|
|
{ |
|
|
|
int k, n8, n4, n2, n, j; |
|
|
|
int k, n8, n4, n2, n, j; |
|
|
|
const uint16_t *revtab = s->fft.revtab; |
|
|
|
const uint16_t *revtab = s->revtab; |
|
|
|
const FFTSample *tcos = s->tcos; |
|
|
|
const FFTSample *tcos = s->tcos; |
|
|
|
const FFTSample *tsin = s->tsin; |
|
|
|
const FFTSample *tsin = s->tsin; |
|
|
|
const FFTSample *in1, *in2; |
|
|
|
const FFTSample *in1, *in2; |
|
|
|
FFTComplex *z = (FFTComplex *)output; |
|
|
|
FFTComplex *z = (FFTComplex *)output; |
|
|
|
|
|
|
|
|
|
|
|
n = 1 << s->nbits; |
|
|
|
n = 1 << s->mdct_bits; |
|
|
|
n2 = n >> 1; |
|
|
|
n2 = n >> 1; |
|
|
|
n4 = n >> 2; |
|
|
|
n4 = n >> 2; |
|
|
|
n8 = n >> 3; |
|
|
|
n8 = n >> 3; |
|
|
@ -145,7 +145,7 @@ void ff_imdct_half_c(MDCTContext *s, FFTSample *output, const FFTSample *input) |
|
|
|
in1 += 2; |
|
|
|
in1 += 2; |
|
|
|
in2 -= 2; |
|
|
|
in2 -= 2; |
|
|
|
} |
|
|
|
} |
|
|
|
ff_fft_calc(&s->fft, z); |
|
|
|
ff_fft_calc(s, z); |
|
|
|
|
|
|
|
|
|
|
|
/* post rotation + reordering */ |
|
|
|
/* post rotation + reordering */ |
|
|
|
for(k = 0; k < n8; k++) { |
|
|
|
for(k = 0; k < n8; k++) { |
|
|
@ -164,10 +164,10 @@ void ff_imdct_half_c(MDCTContext *s, FFTSample *output, const FFTSample *input) |
|
|
|
* @param output N samples |
|
|
|
* @param output N samples |
|
|
|
* @param input N/2 samples |
|
|
|
* @param input N/2 samples |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
void ff_imdct_calc_c(MDCTContext *s, FFTSample *output, const FFTSample *input) |
|
|
|
void ff_imdct_calc_c(FFTContext *s, FFTSample *output, const FFTSample *input) |
|
|
|
{ |
|
|
|
{ |
|
|
|
int k; |
|
|
|
int k; |
|
|
|
int n = 1 << s->nbits; |
|
|
|
int n = 1 << s->mdct_bits; |
|
|
|
int n2 = n >> 1; |
|
|
|
int n2 = n >> 1; |
|
|
|
int n4 = n >> 2; |
|
|
|
int n4 = n >> 2; |
|
|
|
|
|
|
|
|
|
|
@ -184,16 +184,16 @@ void ff_imdct_calc_c(MDCTContext *s, FFTSample *output, const FFTSample *input) |
|
|
|
* @param input N samples |
|
|
|
* @param input N samples |
|
|
|
* @param out N/2 samples |
|
|
|
* @param out N/2 samples |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
void ff_mdct_calc_c(MDCTContext *s, FFTSample *out, const FFTSample *input) |
|
|
|
void ff_mdct_calc_c(FFTContext *s, FFTSample *out, const FFTSample *input) |
|
|
|
{ |
|
|
|
{ |
|
|
|
int i, j, n, n8, n4, n2, n3; |
|
|
|
int i, j, n, n8, n4, n2, n3; |
|
|
|
FFTSample re, im; |
|
|
|
FFTSample re, im; |
|
|
|
const uint16_t *revtab = s->fft.revtab; |
|
|
|
const uint16_t *revtab = s->revtab; |
|
|
|
const FFTSample *tcos = s->tcos; |
|
|
|
const FFTSample *tcos = s->tcos; |
|
|
|
const FFTSample *tsin = s->tsin; |
|
|
|
const FFTSample *tsin = s->tsin; |
|
|
|
FFTComplex *x = (FFTComplex *)out; |
|
|
|
FFTComplex *x = (FFTComplex *)out; |
|
|
|
|
|
|
|
|
|
|
|
n = 1 << s->nbits; |
|
|
|
n = 1 << s->mdct_bits; |
|
|
|
n2 = n >> 1; |
|
|
|
n2 = n >> 1; |
|
|
|
n4 = n >> 2; |
|
|
|
n4 = n >> 2; |
|
|
|
n8 = n >> 3; |
|
|
|
n8 = n >> 3; |
|
|
@ -212,7 +212,7 @@ void ff_mdct_calc_c(MDCTContext *s, FFTSample *out, const FFTSample *input) |
|
|
|
CMUL(x[j].re, x[j].im, re, im, -tcos[n8 + i], tsin[n8 + i]); |
|
|
|
CMUL(x[j].re, x[j].im, re, im, -tcos[n8 + i], tsin[n8 + i]); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
ff_fft_calc(&s->fft, x); |
|
|
|
ff_fft_calc(s, x); |
|
|
|
|
|
|
|
|
|
|
|
/* post rotation */ |
|
|
|
/* post rotation */ |
|
|
|
for(i=0;i<n8;i++) { |
|
|
|
for(i=0;i<n8;i++) { |
|
|
@ -226,9 +226,9 @@ void ff_mdct_calc_c(MDCTContext *s, FFTSample *out, const FFTSample *input) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
av_cold void ff_mdct_end(MDCTContext *s) |
|
|
|
av_cold void ff_mdct_end(FFTContext *s) |
|
|
|
{ |
|
|
|
{ |
|
|
|
av_freep(&s->tcos); |
|
|
|
av_freep(&s->tcos); |
|
|
|
av_freep(&s->tsin); |
|
|
|
av_freep(&s->tsin); |
|
|
|
ff_fft_end(&s->fft); |
|
|
|
ff_fft_end(s); |
|
|
|
} |
|
|
|
} |
|
|
|