summaryrefslogtreecommitdiff
path: root/libavcodec/mdct.c
diff options
context:
space:
mode:
authorSiarhei Siamashka <siarhei.siamashka@gmail.com>2009-05-16 14:17:08 +0000
committerSiarhei Siamashka <siarhei.siamashka@gmail.com>2009-05-16 14:17:08 +0000
commit7d485f165f7f6313002da1fe67c2742f0fbb16c9 (patch)
tree87e68249904f3c5bc7dcfc05df2eea10fd318ea2 /libavcodec/mdct.c
parent3ac56e28b0a3fc84ccac9ac7e359f0f29567f8a0 (diff)
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. Originally committed as revision 18855 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/mdct.c')
-rw-r--r--libavcodec/mdct.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/libavcodec/mdct.c b/libavcodec/mdct.c
index 7bd4d77f68..8a42adb4f3 100644
--- a/libavcodec/mdct.c
+++ b/libavcodec/mdct.c
@@ -68,10 +68,10 @@ 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)
+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 @@ av_cold int ff_mdct_init(MDCTContext *s, int nbits, int inverse)
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;