From b9fa32082c71013e90eab9e9997967d2939cf4a6 Mon Sep 17 00:00:00 2001 From: Loren Merritt Date: Sun, 13 Jul 2008 15:03:58 +0000 Subject: exploit mdct symmetry 2% faster vorbis on conroe, k8. 7% on celeron. Originally committed as revision 14207 to svn://svn.ffmpeg.org/ffmpeg/trunk --- libavcodec/mdct.c | 57 +++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 47 insertions(+), 10 deletions(-) (limited to 'libavcodec/mdct.c') diff --git a/libavcodec/mdct.c b/libavcodec/mdct.c index 07eef2b3d4..6a3b69a014 100644 --- a/libavcodec/mdct.c +++ b/libavcodec/mdct.c @@ -100,16 +100,9 @@ int ff_mdct_init(MDCTContext *s, int nbits, int inverse) (pim) = _are * _bim + _aim * _bre;\ } -/** - * 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(MDCTContext *s, FFTSample *output, - const FFTSample *input, FFTSample *tmp) +static void imdct_c(MDCTContext *s, const FFTSample *input, FFTSample *tmp) { - int k, n8, n4, n2, n, j; + int k, n4, n2, n, j; const uint16_t *revtab = s->fft.revtab; const FFTSample *tcos = s->tcos; const FFTSample *tsin = s->tsin; @@ -119,7 +112,6 @@ void ff_imdct_calc(MDCTContext *s, FFTSample *output, n = 1 << s->nbits; n2 = n >> 1; n4 = n >> 2; - n8 = n >> 3; /* pre rotation */ in1 = input; @@ -137,6 +129,25 @@ void ff_imdct_calc(MDCTContext *s, FFTSample *output, for(k = 0; k < n4; k++) { CMUL(z[k].re, z[k].im, z[k].re, z[k].im, tcos[k], tsin[k]); } +} + +/** + * 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(MDCTContext *s, FFTSample *output, + const FFTSample *input, FFTSample *tmp) +{ + int k, n8, n2, n; + FFTComplex *z = (FFTComplex *)tmp; + n = 1 << s->nbits; + n2 = n >> 1; + n8 = n >> 3; + + imdct_c(s, input, tmp); + for(k = 0; k < n8; k++) { output[2*k] = -z[n8 + k].im; output[n2-1-2*k] = z[n8 + k].im; @@ -152,6 +163,32 @@ void ff_imdct_calc(MDCTContext *s, FFTSample *output, } } +/** + * Compute the middle half of the inverse MDCT of size N = 2^nbits, + * thus excluding the parts that can be derived by symmetry + * @param output N/2 samples + * @param input N/2 samples + * @param tmp N/2 samples + */ +void ff_imdct_half(MDCTContext *s, FFTSample *output, + const FFTSample *input, FFTSample *tmp) +{ + int k, n8, n4, n; + FFTComplex *z = (FFTComplex *)tmp; + n = 1 << s->nbits; + n4 = n >> 2; + n8 = n >> 3; + + imdct_c(s, input, tmp); + + for(k = 0; k < n8; k++) { + output[n4-1-2*k] = z[n8+k].im; + output[n4-1-2*k-1] = -z[n8-k-1].re; + output[n4 + 2*k] = -z[n8+k].re; + output[n4 + 2*k+1] = z[n8-k-1].im; + } +} + /** * Compute MDCT of size N = 2^nbits * @param input N samples -- cgit v1.2.3