mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-06-02 01:47:47 +00:00
Merge FFTContext and MDCTContext
Originally committed as revision 19931 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
parent
ec129499b8
commit
01b2214758
22 changed files with 91 additions and 99 deletions
|
@ -72,15 +72,15 @@ av_cold void ff_sine_window_init(float *window, int n) {
|
|||
/**
|
||||
* 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;
|
||||
double alpha, theta;
|
||||
|
||||
memset(s, 0, sizeof(*s));
|
||||
n = 1 << nbits;
|
||||
s->nbits = nbits;
|
||||
s->n = n;
|
||||
s->mdct_bits = nbits;
|
||||
s->mdct_size = n;
|
||||
n4 = n >> 2;
|
||||
s->tcos = av_malloc(n4 * sizeof(FFTSample));
|
||||
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->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;
|
||||
return 0;
|
||||
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 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;
|
||||
const uint16_t *revtab = s->fft.revtab;
|
||||
const uint16_t *revtab = s->revtab;
|
||||
const FFTSample *tcos = s->tcos;
|
||||
const FFTSample *tsin = s->tsin;
|
||||
const FFTSample *in1, *in2;
|
||||
FFTComplex *z = (FFTComplex *)output;
|
||||
|
||||
n = 1 << s->nbits;
|
||||
n = 1 << s->mdct_bits;
|
||||
n2 = n >> 1;
|
||||
n4 = n >> 2;
|
||||
n8 = n >> 3;
|
||||
|
@ -145,7 +145,7 @@ void ff_imdct_half_c(MDCTContext *s, FFTSample *output, const FFTSample *input)
|
|||
in1 += 2;
|
||||
in2 -= 2;
|
||||
}
|
||||
ff_fft_calc(&s->fft, z);
|
||||
ff_fft_calc(s, z);
|
||||
|
||||
/* post rotation + reordering */
|
||||
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 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 n = 1 << s->nbits;
|
||||
int n = 1 << s->mdct_bits;
|
||||
int n2 = n >> 1;
|
||||
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 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;
|
||||
FFTSample re, im;
|
||||
const uint16_t *revtab = s->fft.revtab;
|
||||
const uint16_t *revtab = s->revtab;
|
||||
const FFTSample *tcos = s->tcos;
|
||||
const FFTSample *tsin = s->tsin;
|
||||
FFTComplex *x = (FFTComplex *)out;
|
||||
|
||||
n = 1 << s->nbits;
|
||||
n = 1 << s->mdct_bits;
|
||||
n2 = n >> 1;
|
||||
n4 = n >> 2;
|
||||
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]);
|
||||
}
|
||||
|
||||
ff_fft_calc(&s->fft, x);
|
||||
ff_fft_calc(s, x);
|
||||
|
||||
/* post rotation */
|
||||
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->tsin);
|
||||
ff_fft_end(&s->fft);
|
||||
ff_fft_end(s);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue