Mercurial > libavcodec.hg
diff mdct.c @ 9658:67a20f0eb42c libavcodec
Support for getting (i)MDCT output multiplied by a constant scaling factor.
Scaling (i)MDCT output has no runtime overhead and can be used to improve
performance of audio codecs. All the changes are only needed in
'ff_mdct_init' function and slow down initialization a bit.
author | serge |
---|---|
date | Sat, 16 May 2009 14:17:08 +0000 |
parents | d527872fdf26 |
children | 50ec8930f99e |
line wrap: on
line diff
--- a/mdct.c Sat May 16 06:39:08 2009 +0000 +++ b/mdct.c Sat May 16 14:17:08 2009 +0000 @@ -68,10 +68,10 @@ /** * init MDCT or IMDCT computation. */ -av_cold 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; @@ -85,10 +85,12 @@ 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;