From 82361d50d0dcbb72132fe1203fe152a89dd165e9 Mon Sep 17 00:00:00 2001 From: rtognimp Date: Tue, 18 Apr 2006 19:39:34 +0000 Subject: Update to faad2 cvs 20040915+MPlayer fixes Patch by me and Emanuele Giaquinta git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@18142 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libfaad2/Makefile | 1 + libfaad2/README | 2 +- libfaad2/analysis.h | 2 +- libfaad2/bits.c | 2 +- libfaad2/cfft.c | 408 +----------------- libfaad2/cfft.h | 6 +- libfaad2/cfft_tab.h | 134 +++++- libfaad2/common.c | 154 +++---- libfaad2/common.h | 13 +- libfaad2/decoder.c | 14 +- libfaad2/decoder.h | 2 +- libfaad2/drc.c | 2 +- libfaad2/drc.h | 2 +- libfaad2/drm_dec.c | 990 ++++++++++++++++++++++++++++++++++++++++++++ libfaad2/drm_dec.h | 97 +++++ libfaad2/error.c | 2 +- libfaad2/error.h | 2 +- libfaad2/filtbank.c | 367 +--------------- libfaad2/filtbank.h | 8 +- libfaad2/fixed.h | 2 +- libfaad2/hcr.c | 587 +++++++++++++------------- libfaad2/huffman.c | 57 ++- libfaad2/huffman.h | 2 +- libfaad2/ic_predict.c | 2 +- libfaad2/ic_predict.h | 2 +- libfaad2/iq_table.h | 2 +- libfaad2/is.c | 2 +- libfaad2/is.h | 2 +- libfaad2/kbd_win.h | 2 +- libfaad2/local_changes.diff | 253 +++++++++-- libfaad2/lt_predict.c | 2 +- libfaad2/lt_predict.h | 2 +- libfaad2/mdct.c | 2 +- libfaad2/mdct.h | 5 +- libfaad2/mdct_tab.h | 2 +- libfaad2/mp4.c | 2 +- libfaad2/mp4.h | 2 +- libfaad2/ms.c | 2 +- libfaad2/ms.h | 2 +- libfaad2/neaacdec.h | 12 +- libfaad2/output.c | 2 +- libfaad2/output.h | 2 +- libfaad2/pns.c | 2 +- libfaad2/pns.h | 2 +- libfaad2/ps_dec.c | 5 +- libfaad2/ps_dec.h | 7 +- libfaad2/ps_syntax.c | 14 +- libfaad2/ps_tables.h | 2 +- libfaad2/pulse.c | 2 +- libfaad2/pulse.h | 2 +- libfaad2/rvlc.c | 2 +- libfaad2/rvlc.h | 2 +- libfaad2/sbr_dct.c | 2 +- libfaad2/sbr_dct.h | 2 +- libfaad2/sbr_dec.c | 8 +- libfaad2/sbr_dec.h | 2 +- libfaad2/sbr_e_nf.c | 2 +- libfaad2/sbr_e_nf.h | 2 +- libfaad2/sbr_fbt.c | 6 +- libfaad2/sbr_fbt.h | 2 +- libfaad2/sbr_hfadj.c | 2 +- libfaad2/sbr_hfadj.h | 2 +- libfaad2/sbr_hfgen.c | 11 +- libfaad2/sbr_hfgen.h | 2 +- libfaad2/sbr_huff.c | 2 +- libfaad2/sbr_huff.h | 2 +- libfaad2/sbr_noise.h | 2 +- libfaad2/sbr_qmf.c | 2 +- libfaad2/sbr_qmf.h | 6 +- libfaad2/sbr_qmf_c.h | 2 +- libfaad2/sbr_syntax.c | 57 ++- libfaad2/sbr_syntax.h | 2 +- libfaad2/sbr_tf_grid.c | 2 +- libfaad2/sbr_tf_grid.h | 2 +- libfaad2/sine_win.h | 2 +- libfaad2/specrec.c | 197 +++++---- libfaad2/specrec.h | 2 +- libfaad2/ssr.c | 2 +- libfaad2/ssr.h | 2 +- libfaad2/ssr_fb.c | 2 +- libfaad2/ssr_fb.h | 2 +- libfaad2/ssr_ipqf.c | 2 +- libfaad2/ssr_ipqf.h | 2 +- libfaad2/ssr_win.h | 2 +- libfaad2/structs.h | 13 +- libfaad2/syntax.c | 16 +- libfaad2/syntax.h | 2 +- libfaad2/tns.c | 2 +- libfaad2/tns.h | 2 +- 89 files changed, 2143 insertions(+), 1427 deletions(-) create mode 100644 libfaad2/drm_dec.c create mode 100644 libfaad2/drm_dec.h (limited to 'libfaad2') diff --git a/libfaad2/Makefile b/libfaad2/Makefile index 7e3be6a33a..ca911d054d 100644 --- a/libfaad2/Makefile +++ b/libfaad2/Makefile @@ -8,6 +8,7 @@ SRCS = bits.c \ common.c \ decoder.c \ drc.c \ + drm_dec.c \ error.c \ filtbank.c \ hcr.c \ diff --git a/libfaad2/README b/libfaad2/README index bd36b51fc2..5fb717062e 100644 --- a/libfaad2/README +++ b/libfaad2/README @@ -1,3 +1,3 @@ -This is a FAAD2 2.1 beta CVS snapshot from 2004-07-12. +This is a FAAD2 CVS snapshot from 2004-09-15. Only the content of the libfaad/ and include/ subdirectories is present here. MPlayer-specific modifications can be found in local_changes.diff. diff --git a/libfaad2/analysis.h b/libfaad2/analysis.h index 0a562eaaf1..25dd9d90ce 100644 --- a/libfaad2/analysis.h +++ b/libfaad2/analysis.h @@ -22,7 +22,7 @@ ** Commercial non-GPL licensing of this software is possible. ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. ** -** $Id: analysis.h,v 1.12 2004/02/26 09:29:26 menno Exp $ +** $Id: analysis.h,v 1.14 2004/09/04 14:56:27 menno Exp $ **/ #ifndef __ANALYSIS_H__ diff --git a/libfaad2/bits.c b/libfaad2/bits.c index 3c4cb80a24..0801e0e4ff 100644 --- a/libfaad2/bits.c +++ b/libfaad2/bits.c @@ -22,7 +22,7 @@ ** Commercial non-GPL licensing of this software is possible. ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. ** -** $Id: bits.c,v 1.37 2004/02/26 09:29:26 menno Exp $ +** $Id: bits.c,v 1.39 2004/09/04 14:56:27 menno Exp $ **/ #include "common.h" diff --git a/libfaad2/cfft.c b/libfaad2/cfft.c index 6a1b005fc3..3b81665595 100644 --- a/libfaad2/cfft.c +++ b/libfaad2/cfft.c @@ -22,7 +22,7 @@ ** Commercial non-GPL licensing of this software is possible. ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. ** -** $Id: cfft.c,v 1.27 2004/06/30 12:45:55 menno Exp $ +** $Id: cfft.c,v 1.30 2004/09/08 09:43:11 gcp Exp $ **/ /* @@ -44,14 +44,6 @@ /* static function declarations */ -#ifdef USE_SSE -static void passf2pos_sse(const uint16_t l1, const complex_t *cc, - complex_t *ch, const complex_t *wa); -static void passf2pos_sse_ido(const uint16_t ido, const uint16_t l1, const complex_t *cc, - complex_t *ch, const complex_t *wa); -static void passf4pos_sse_ido(const uint16_t ido, const uint16_t l1, const complex_t *cc, complex_t *ch, - const complex_t *wa1, const complex_t *wa2, const complex_t *wa3); -#endif static void passf2pos(const uint16_t ido, const uint16_t l1, const complex_t *cc, complex_t *ch, const complex_t *wa); static void passf2neg(const uint16_t ido, const uint16_t l1, const complex_t *cc, @@ -74,89 +66,6 @@ static void cffti1(uint16_t n, complex_t *wa, uint16_t *ifac); passf2, passf3, passf4, passf5. Complex FFT passes fwd and bwd. ----------------------------------------------------------------------*/ -#if 0 //def USE_SSE -static void passf2pos_sse(const uint16_t l1, const complex_t *cc, - complex_t *ch, const complex_t *wa) -{ - uint16_t k, ah, ac; - - for (k = 0; k < l1; k++) - { - ah = 2*k; - ac = 4*k; - - RE(ch[ah]) = RE(cc[ac]) + RE(cc[ac+1]); - IM(ch[ah]) = IM(cc[ac]) + IM(cc[ac+1]); - - RE(ch[ah+l1]) = RE(cc[ac]) - RE(cc[ac+1]); - IM(ch[ah+l1]) = IM(cc[ac]) - IM(cc[ac+1]); - } -} - -static void passf2pos_sse_ido(const uint16_t ido, const uint16_t l1, const complex_t *cc, - complex_t *ch, const complex_t *wa) -{ - uint16_t i, k, ah, ac; - - for (k = 0; k < l1; k++) - { - ah = k*ido; - ac = 2*k*ido; - - for (i = 0; i < ido; i+=4) - { - __m128 m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, m11, m12, m13, m14; - __m128 m15, m16, m17, m18, m19, m20, m21, m22, m23, m24; - __m128 w1, w2, w3, w4; - - m1 = _mm_load_ps(&RE(cc[ac+i])); - m2 = _mm_load_ps(&RE(cc[ac+ido+i])); - m5 = _mm_load_ps(&RE(cc[ac+i+2])); - m6 = _mm_load_ps(&RE(cc[ac+ido+i+2])); - w1 = _mm_load_ps(&RE(wa[i])); - w3 = _mm_load_ps(&RE(wa[i+2])); - - m3 = _mm_add_ps(m1, m2); - m15 = _mm_add_ps(m5, m6); - - m4 = _mm_sub_ps(m1, m2); - m16 = _mm_sub_ps(m5, m6); - - _mm_store_ps(&RE(ch[ah+i]), m3); - _mm_store_ps(&RE(ch[ah+i+2]), m15); - - - w2 = _mm_shuffle_ps(w1, w1, _MM_SHUFFLE(2, 3, 0, 1)); - w4 = _mm_shuffle_ps(w3, w3, _MM_SHUFFLE(2, 3, 0, 1)); - - m7 = _mm_mul_ps(m4, w1); - m17 = _mm_mul_ps(m16, w3); - m8 = _mm_mul_ps(m4, w2); - m18 = _mm_mul_ps(m16, w4); - - m9 = _mm_shuffle_ps(m7, m8, _MM_SHUFFLE(2, 0, 2, 0)); - m19 = _mm_shuffle_ps(m17, m18, _MM_SHUFFLE(2, 0, 2, 0)); - m10 = _mm_shuffle_ps(m7, m8, _MM_SHUFFLE(3, 1, 3, 1)); - m20 = _mm_shuffle_ps(m17, m18, _MM_SHUFFLE(3, 1, 3, 1)); - - m11 = _mm_add_ps(m9, m10); - m21 = _mm_add_ps(m19, m20); - m12 = _mm_sub_ps(m9, m10); - m22 = _mm_sub_ps(m19, m20); - - m13 = _mm_shuffle_ps(m11, m11, _MM_SHUFFLE(0, 0, 3, 2)); - m23 = _mm_shuffle_ps(m21, m21, _MM_SHUFFLE(0, 0, 3, 2)); - - m14 = _mm_unpacklo_ps(m12, m13); - m24 = _mm_unpacklo_ps(m22, m23); - - _mm_store_ps(&RE(ch[ah+i+l1*ido]), m14); - _mm_store_ps(&RE(ch[ah+i+2+l1*ido]), m24); - } - } -} -#endif - static void passf2pos(const uint16_t ido, const uint16_t l1, const complex_t *cc, complex_t *ch, const complex_t *wa) { @@ -385,218 +294,6 @@ static void passf3(const uint16_t ido, const uint16_t l1, const complex_t *cc, } } -#ifdef USE_SSE -ALIGN static const int32_t negate[4] = { 0x0, 0x0, 0x0, 0x80000000 }; - -__declspec(naked) static void passf4pos_sse(const uint16_t l1, const complex_t *cc, - complex_t *ch, const complex_t *wa1, const complex_t *wa2, - const complex_t *wa3) -{ - __asm { - push ebx - mov ebx, esp - and esp, -16 - push edi - push esi - sub esp, 8 - movzx edi, WORD PTR [ebx+8] - - movaps xmm1, XMMWORD PTR negate - - test edi, edi - jle l1_is_zero - - lea esi, DWORD PTR [edi+edi] - add esi, esi - sub esi, edi - add esi, esi - add esi, esi - add esi, esi - mov eax, DWORD PTR [ebx+16] - add esi, eax - lea ecx, DWORD PTR [edi+edi] - add ecx, ecx - add ecx, ecx - add ecx, ecx - add ecx, eax - lea edx, DWORD PTR [edi+edi] - add edx, edx - add edx, edx - add edx, eax - xor eax, eax - mov DWORD PTR [esp], ebp - mov ebp, DWORD PTR [ebx+12] - -fftloop: - lea edi, DWORD PTR [eax+eax] - add edi, edi - movaps xmm2, XMMWORD PTR [ebp+edi*8] - movaps xmm0, XMMWORD PTR [ebp+edi*8+16] - movaps xmm7, XMMWORD PTR [ebp+edi*8+32] - movaps xmm5, XMMWORD PTR [ebp+edi*8+48] - movaps xmm6, xmm2 - addps xmm6, xmm0 - movaps xmm4, xmm1 - xorps xmm4, xmm7 - movaps xmm3, xmm1 - xorps xmm3, xmm5 - xorps xmm2, xmm1 - xorps xmm0, xmm1 - addps xmm7, xmm5 - subps xmm2, xmm0 - movaps xmm0, xmm6 - shufps xmm0, xmm7, 68 - subps xmm4, xmm3 - shufps xmm6, xmm7, 238 - movaps xmm5, xmm2 - shufps xmm5, xmm4, 68 - movaps xmm3, xmm0 - addps xmm3, xmm6 - shufps xmm2, xmm4, 187 - subps xmm0, xmm6 - movaps xmm4, xmm5 - addps xmm4, xmm2 - mov edi, DWORD PTR [ebx+16] - movaps XMMWORD PTR [edi+eax*8], xmm3 - subps xmm5, xmm2 - movaps XMMWORD PTR [edx+eax*8], xmm4 - movaps XMMWORD PTR [ecx+eax*8], xmm0 - movaps XMMWORD PTR [esi+eax*8], xmm5 - add eax, 2 - movzx eax, ax - movzx edi, WORD PTR [ebx+8] - cmp eax, edi - jl fftloop - - mov ebp, DWORD PTR [esp] - -l1_is_zero: - - add esp, 8 - pop esi - pop edi - mov esp, ebx - pop ebx - ret - } -} -#endif - -#if 0 -static void passf4pos_sse_ido(const uint16_t ido, const uint16_t l1, const complex_t *cc, - complex_t *ch, const complex_t *wa1, const complex_t *wa2, - const complex_t *wa3) -{ - uint16_t i, k, ac, ah; - - for (k = 0; k < l1; k++) - { - ac = 4*k*ido; - ah = k*ido; - - for (i = 0; i < ido; i+=2) - { - __m128 m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, m11, m12, m13, m14, m15, m16; - __m128 n1, n2, n3, n4, n5, n6, n7, n8, n9, m17, m18, m19, m20, m21, m22, m23; - __m128 w1, w2, w3, w4, w5, w6, m24, m25, m26, m27, m28, m29, m30; - __m128 neg1 = _mm_set_ps(-1.0, 1.0, -1.0, 1.0); - - m1 = _mm_load_ps(&RE(cc[ac+i])); - m2 = _mm_load_ps(&RE(cc[ac+i+2*ido])); - m3 = _mm_add_ps(m1, m2); - m4 = _mm_sub_ps(m1, m2); - - n1 = _mm_load_ps(&RE(cc[ac+i+ido])); - n2 = _mm_load_ps(&RE(cc[ac+i+3*ido])); - n3 = _mm_add_ps(n1, n2); - - n4 = _mm_mul_ps(neg1, n1); - n5 = _mm_mul_ps(neg1, n2); - n6 = _mm_sub_ps(n4, n5); - - m5 = _mm_add_ps(m3, n3); - - n7 = _mm_shuffle_ps(n6, n6, _MM_SHUFFLE(2, 3, 0, 1)); - n8 = _mm_add_ps(m4, n7); - - m6 = _mm_sub_ps(m3, n3); - n9 = _mm_sub_ps(m4, n7); - - _mm_store_ps(&RE(ch[ah+i]), m5); - -#if 0 - static INLINE void ComplexMult(real_t *y1, real_t *y2, - real_t x1, real_t x2, real_t c1, real_t c2) - { - *y1 = MUL_F(x1, c1) + MUL_F(x2, c2); - *y2 = MUL_F(x2, c1) - MUL_F(x1, c2); - } - - m7.0 = RE(c2)*RE(wa1[i]) - m7.1 = IM(c2)*IM(wa1[i]) - m7.2 = RE(c6)*RE(wa1[i+1]) - m7.3 = IM(c6)*IM(wa1[i+1]) - - m8.0 = RE(c2)*IM(wa1[i]) - m8.1 = IM(c2)*RE(wa1[i]) - m8.2 = RE(c6)*IM(wa1[i+1]) - m8.3 = IM(c6)*RE(wa1[i+1]) - - RE(0) = m7.0 - m7.1 - IM(0) = m8.0 + m8.1 - RE(1) = m7.2 - m7.3 - IM(1) = m8.2 + m8.3 - - //// - RE(0) = RE(c2)*RE(wa1[i]) - IM(c2)*IM(wa1[i]) - IM(0) = RE(c2)*IM(wa1[i]) + IM(c2)*RE(wa1[i]) - RE(1) = RE(c6)*RE(wa1[i+1]) - IM(c6)*IM(wa1[i+1]) - IM(1) = RE(c6)*IM(wa1[i+1]) + IM(c6)*RE(wa1[i+1]) -#endif - - w1 = _mm_load_ps(&RE(wa1[i])); - w3 = _mm_load_ps(&RE(wa2[i])); - w5 = _mm_load_ps(&RE(wa3[i])); - - w2 = _mm_shuffle_ps(w1, w1, _MM_SHUFFLE(2, 3, 0, 1)); - w4 = _mm_shuffle_ps(w3, w3, _MM_SHUFFLE(2, 3, 0, 1)); - w6 = _mm_shuffle_ps(w5, w5, _MM_SHUFFLE(2, 3, 0, 1)); - - m7 = _mm_mul_ps(n8, w1); - m15 = _mm_mul_ps(m6, w3); - m23 = _mm_mul_ps(n9, w5); - m8 = _mm_mul_ps(n8, w2); - m16 = _mm_mul_ps(m6, w4); - m24 = _mm_mul_ps(n9, w6); - - m9 = _mm_shuffle_ps(m7, m8, _MM_SHUFFLE(2, 0, 2, 0)); - m17 = _mm_shuffle_ps(m15, m16, _MM_SHUFFLE(2, 0, 2, 0)); - m25 = _mm_shuffle_ps(m23, m24, _MM_SHUFFLE(2, 0, 2, 0)); - m10 = _mm_shuffle_ps(m7, m8, _MM_SHUFFLE(3, 1, 3, 1)); - m18 = _mm_shuffle_ps(m15, m16, _MM_SHUFFLE(3, 1, 3, 1)); - m26 = _mm_shuffle_ps(m23, m24, _MM_SHUFFLE(3, 1, 3, 1)); - - m11 = _mm_add_ps(m9, m10); - m19 = _mm_add_ps(m17, m18); - m27 = _mm_add_ps(m25, m26); - m12 = _mm_sub_ps(m9, m10); - m20 = _mm_sub_ps(m17, m18); - m28 = _mm_sub_ps(m25, m26); - - m13 = _mm_shuffle_ps(m11, m11, _MM_SHUFFLE(0, 0, 3, 2)); - m21 = _mm_shuffle_ps(m19, m19, _MM_SHUFFLE(0, 0, 3, 2)); - m29 = _mm_shuffle_ps(m27, m27, _MM_SHUFFLE(0, 0, 3, 2)); - m14 = _mm_unpacklo_ps(m12, m13); - m22 = _mm_unpacklo_ps(m20, m21); - m30 = _mm_unpacklo_ps(m28, m29); - - _mm_store_ps(&RE(ch[ah+i+l1*ido]), m14); - _mm_store_ps(&RE(ch[ah+i+2*l1*ido]), m22); - _mm_store_ps(&RE(ch[ah+i+3*l1*ido]), m30); - } - } -} -#endif static void passf4pos(const uint16_t ido, const uint16_t l1, const complex_t *cc, complex_t *ch, const complex_t *wa1, const complex_t *wa2, @@ -992,101 +689,6 @@ static void passf5(const uint16_t ido, const uint16_t l1, const complex_t *cc, cfftf1, cfftf, cfftb, cffti1, cffti. Complex FFTs. ----------------------------------------------------------------------*/ -#ifdef USE_SSE - -#define CONV(A,B,C) ( (A<<2) | ((B & 0x1)<<1) | ((C==1)&0x1) ) - -static INLINE void cfftf1pos_sse(uint16_t n, complex_t *c, complex_t *ch, - const uint16_t *ifac, const complex_t *wa, - const int8_t isign) -{ - uint16_t i; - uint16_t k1, l1, l2; - uint16_t na, nf, ip, iw, ix2, ix3, ix4, ido, idl1; - - nf = ifac[1]; - na = 0; - l1 = 1; - iw = 0; - - for (k1 = 2; k1 <= nf+1; k1++) - { - ip = ifac[k1]; - l2 = ip*l1; - ido = n / l2; - idl1 = ido*l1; - - ix2 = iw + ido; - ix3 = ix2 + ido; - ix4 = ix3 + ido; - - switch (CONV(ip,na,ido)) - { - case CONV(4,0,0): - //passf4pos_sse_ido((const uint16_t)ido, (const uint16_t)l1, (const complex_t*)c, ch, &wa[iw], &wa[ix2], &wa[ix3]); - passf4pos((const uint16_t)ido, (const uint16_t)l1, (const complex_t*)c, ch, &wa[iw], &wa[ix2], &wa[ix3]); - break; - case CONV(4,0,1): - passf4pos_sse((const uint16_t)l1, (const complex_t*)c, ch, &wa[iw], &wa[ix2], &wa[ix3]); - break; - case CONV(4,1,0): - passf4pos((const uint16_t)ido, (const uint16_t)l1, (const complex_t*)ch, c, &wa[iw], &wa[ix2], &wa[ix3]); - //passf4pos_sse_ido((const uint16_t)ido, (const uint16_t)l1, (const complex_t*)ch, c, &wa[iw], &wa[ix2], &wa[ix3]); - break; - case CONV(4,1,1): - passf4pos_sse((const uint16_t)l1, (const complex_t*)ch, c, &wa[iw], &wa[ix2], &wa[ix3]); - break; - case CONV(2,0,0): - passf2pos((const uint16_t)ido, (const uint16_t)l1, (const complex_t*)c, ch, &wa[iw]); - //passf2pos_sse_ido((const uint16_t)ido, (const uint16_t)l1, (const complex_t*)c, ch, &wa[iw]); - break; - case CONV(2,0,1): - passf2pos((const uint16_t)ido, (const uint16_t)l1, (const complex_t*)c, ch, &wa[iw]); - //passf2pos_sse((const uint16_t)l1, (const complex_t*)c, ch, &wa[iw]); - break; - case CONV(2,1,0): - passf2pos((const uint16_t)ido, (const uint16_t)l1, (const complex_t*)ch, c, &wa[iw]); - //passf2pos_sse_ido((const uint16_t)ido, (const uint16_t)l1, (const complex_t*)ch, c, &wa[iw]); - break; - case CONV(2,1,1): - passf2pos((const uint16_t)ido, (const uint16_t)l1, (const complex_t*)ch, c, &wa[iw]); - //passf2pos_sse((const uint16_t)l1, (const complex_t*)ch, c, &wa[iw]); - break; - case CONV(3,0,0): - case CONV(3,0,1): - passf3((const uint16_t)ido, (const uint16_t)l1, (const complex_t*)c, ch, &wa[iw], &wa[ix2], isign); - break; - case CONV(3,1,0): - case CONV(3,1,1): - passf3((const uint16_t)ido, (const uint16_t)l1, (const complex_t*)ch, c, &wa[iw], &wa[ix2], isign); - break; - case CONV(5,0,0): - case CONV(5,0,1): - passf5((const uint16_t)ido, (const uint16_t)l1, (const complex_t*)c, ch, &wa[iw], &wa[ix2], &wa[ix3], &wa[ix4], isign); - break; - case CONV(5,1,0): - case CONV(5,1,1): - passf5((const uint16_t)ido, (const uint16_t)l1, (const complex_t*)ch, c, &wa[iw], &wa[ix2], &wa[ix3], &wa[ix4], isign); - break; - } - - na = 1 - na; - - l1 = l2; - iw += (ip-1) * ido; - } - - if (na == 0) - return; - - for (i = 0; i < n; i++) - { - RE(c[i]) = RE(ch[i]); - IM(c[i]) = IM(ch[i]); - } -} -#endif - static INLINE void cfftf1pos(uint16_t n, complex_t *c, complex_t *ch, const uint16_t *ifac, const complex_t *wa, const int8_t isign) @@ -1255,13 +857,6 @@ void cfftb(cfft_info *cfft, complex_t *c) cfftf1pos(cfft->n, c, cfft->work, (const uint16_t*)cfft->ifac, (const complex_t*)cfft->tab, +1); } -#ifdef USE_SSE -void cfftb_sse(cfft_info *cfft, complex_t *c) -{ - cfftf1pos_sse(cfft->n, c, cfft->work, (const uint16_t*)cfft->ifac, (const complex_t*)cfft->tab, +1); -} -#endif - static void cffti1(uint16_t n, complex_t *wa, uint16_t *ifac) { static uint16_t ntryh[4] = {3, 4, 2, 5}; @@ -1388,6 +983,7 @@ cfft_info *cffti(uint16_t n) case 240: cfft->tab = (complex_t*)cfft_tab_240; break; #endif #endif + case 128: cfft->tab = (complex_t*)cfft_tab_128; break; } #endif diff --git a/libfaad2/cfft.h b/libfaad2/cfft.h index 03b6630626..c39a9a59a6 100644 --- a/libfaad2/cfft.h +++ b/libfaad2/cfft.h @@ -22,7 +22,7 @@ ** Commercial non-GPL licensing of this software is possible. ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. ** -** $Id: cfft.h,v 1.17 2004/02/26 09:29:26 menno Exp $ +** $Id: cfft.h,v 1.20 2004/09/08 09:43:11 gcp Exp $ **/ #ifndef __CFFT_H__ @@ -46,10 +46,6 @@ void cfftb(cfft_info *cfft, complex_t *c); cfft_info *cffti(uint16_t n); void cfftu(cfft_info *cfft); -#ifdef USE_SSE -void cfftb_sse(cfft_info *cfft, complex_t *c); -#endif - #ifdef __cplusplus } diff --git a/libfaad2/cfft_tab.h b/libfaad2/cfft_tab.h index c4c9bcadff..fdaadb3aa6 100644 --- a/libfaad2/cfft_tab.h +++ b/libfaad2/cfft_tab.h @@ -22,7 +22,7 @@ ** Commercial non-GPL licensing of this software is possible. ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. ** -** $Id: cfft_tab.h,v 1.15 2004/06/30 12:45:55 menno Exp $ +** $Id: cfft_tab.h,v 1.17 2004/09/04 14:56:28 menno Exp $ **/ #ifndef __CFFT_TAB_H__ @@ -1680,6 +1680,138 @@ ALIGN static const complex_t cfft_tab_240[] = #endif +ALIGN static const complex_t cfft_tab_128[] = +{ + { FRAC_CONST(1.000000000000000), FRAC_CONST(0.000000000000000) }, + { FRAC_CONST(0.998795449733734), FRAC_CONST(0.049067676067352) }, + { FRAC_CONST(0.995184719562531), FRAC_CONST(0.098017141222954) }, + { FRAC_CONST(0.989176511764526), FRAC_CONST(0.146730467677116) }, + { FRAC_CONST(0.980785250663757), FRAC_CONST(0.195090323686600) }, + { FRAC_CONST(0.970031261444092), FRAC_CONST(0.242980197072029) }, + { FRAC_CONST(0.956940352916718), FRAC_CONST(0.290284663438797) }, + { FRAC_CONST(0.941544055938721), FRAC_CONST(0.336889863014221) }, + { FRAC_CONST(0.923879504203796), FRAC_CONST(0.382683455944061) }, + { FRAC_CONST(0.903989315032959), FRAC_CONST(0.427555084228516) }, + { FRAC_CONST(0.881921231746674), FRAC_CONST(0.471396744251251) }, + { FRAC_CONST(0.857728600502014), FRAC_CONST(0.514102756977081) }, + { FRAC_CONST(0.831469595432281), FRAC_CONST(0.555570244789124) }, + { FRAC_CONST(0.803207516670227), FRAC_CONST(0.595699310302734) }, + { FRAC_CONST(0.773010432720184), FRAC_CONST(0.634393334388733) }, + { FRAC_CONST(0.740951120853424), FRAC_CONST(0.671558976173401) }, + { FRAC_CONST(0.707106769084930), FRAC_CONST(0.707106769084930) }, + { FRAC_CONST(0.671558916568756), FRAC_CONST(0.740951180458069) }, + { FRAC_CONST(0.634393274784088), FRAC_CONST(0.773010432720184) }, + { FRAC_CONST(0.595699310302734), FRAC_CONST(0.803207516670227) }, + { FRAC_CONST(0.555570185184479), FRAC_CONST(0.831469655036926) }, + { FRAC_CONST(0.514102697372437), FRAC_CONST(0.857728660106659) }, + { FRAC_CONST(0.471396654844284), FRAC_CONST(0.881921291351318) }, + { FRAC_CONST(0.427555114030838), FRAC_CONST(0.903989315032959) }, + { FRAC_CONST(0.382683426141739), FRAC_CONST(0.923879504203796) }, + { FRAC_CONST(0.336889833211899), FRAC_CONST(0.941544055938721) }, + { FRAC_CONST(0.290284633636475), FRAC_CONST(0.956940352916718) }, + { FRAC_CONST(0.242980122566223), FRAC_CONST(0.970031261444092) }, + { FRAC_CONST(0.195090234279633), FRAC_CONST(0.980785310268402) }, + { FRAC_CONST(0.146730497479439), FRAC_CONST(0.989176511764526) }, + { FRAC_CONST(0.098017133772373), FRAC_CONST(0.995184719562531) }, + { FRAC_CONST(0.049067649990320), FRAC_CONST(0.998795449733734) }, + { FRAC_CONST(-0.000000043711388), FRAC_CONST(1.000000000000000) }, + { FRAC_CONST(-0.049067739397287), FRAC_CONST(0.998795449733734) }, + { FRAC_CONST(-0.098017223179340), FRAC_CONST(0.995184719562531) }, + { FRAC_CONST(-0.146730571985245), FRAC_CONST(0.989176511764526) }, + { FRAC_CONST(-0.195090323686600), FRAC_CONST(0.980785250663757) }, + { FRAC_CONST(-0.242980197072029), FRAC_CONST(0.970031261444092) }, + { FRAC_CONST(-0.290284723043442), FRAC_CONST(0.956940293312073) }, + { FRAC_CONST(-0.336889922618866), FRAC_CONST(0.941544055938721) }, + { FRAC_CONST(-0.382683515548706), FRAC_CONST(0.923879504203796) }, + { FRAC_CONST(-0.427555084228516), FRAC_CONST(0.903989315032959) }, + { FRAC_CONST(-0.471396833658218), FRAC_CONST(0.881921231746674) }, + { FRAC_CONST(-0.514102756977081), FRAC_CONST(0.857728600502014) }, + { FRAC_CONST(-0.555570363998413), FRAC_CONST(0.831469535827637) }, + { FRAC_CONST(-0.595699369907379), FRAC_CONST(0.803207516670227) }, + { FRAC_CONST(-0.634393274784088), FRAC_CONST(0.773010492324829) }, + { FRAC_CONST(-0.671559035778046), FRAC_CONST(0.740951061248779) }, + { FRAC_CONST(-0.707106769084930), FRAC_CONST(0.707106769084930) }, + { FRAC_CONST(-0.740951240062714), FRAC_CONST(0.671558856964111) }, + { FRAC_CONST(-0.773010492324829), FRAC_CONST(0.634393274784088) }, + { FRAC_CONST(-0.803207635879517), FRAC_CONST(0.595699131488800) }, + { FRAC_CONST(-0.831469655036926), FRAC_CONST(0.555570185184479) }, + { FRAC_CONST(-0.857728600502014), FRAC_CONST(0.514102756977081) }, + { FRAC_CONST(-0.881921350955963), FRAC_CONST(0.471396625041962) }, + { FRAC_CONST(-0.903989315032959), FRAC_CONST(0.427555054426193) }, + { FRAC_CONST(-0.923879623413086), FRAC_CONST(0.382683277130127) }, + { FRAC_CONST(-0.941544115543365), FRAC_CONST(0.336889803409576) }, + { FRAC_CONST(-0.956940352916718), FRAC_CONST(0.290284723043442) }, + { FRAC_CONST(-0.970031261444092), FRAC_CONST(0.242980077862740) }, + { FRAC_CONST(-0.980785310268402), FRAC_CONST(0.195090308785439) }, + { FRAC_CONST(-0.989176511764526), FRAC_CONST(0.146730333566666) }, + { FRAC_CONST(-0.995184719562531), FRAC_CONST(0.098017096519470) }, + { FRAC_CONST(-0.998795449733734), FRAC_CONST(0.049067486077547) }, + { FRAC_CONST(1.000000000000000), FRAC_CONST(0.000000000000000) }, + { FRAC_CONST(0.995184719562531), FRAC_CONST(0.098017141222954) }, + { FRAC_CONST(0.980785250663757), FRAC_CONST(0.195090323686600) }, + { FRAC_CONST(0.956940352916718), FRAC_CONST(0.290284663438797) }, + { FRAC_CONST(0.923879504203796), FRAC_CONST(0.382683455944061) }, + { FRAC_CONST(0.881921231746674), FRAC_CONST(0.471396744251251) }, + { FRAC_CONST(0.831469595432281), FRAC_CONST(0.555570244789124) }, + { FRAC_CONST(0.773010432720184), FRAC_CONST(0.634393334388733) }, + { FRAC_CONST(0.707106769084930), FRAC_CONST(0.707106769084930) }, + { FRAC_CONST(0.634393274784088), FRAC_CONST(0.773010432720184) }, + { FRAC_CONST(0.555570185184479), FRAC_CONST(0.831469655036926) }, + { FRAC_CONST(0.471396654844284), FRAC_CONST(0.881921291351318) }, + { FRAC_CONST(0.382683426141739), FRAC_CONST(0.923879504203796) }, + { FRAC_CONST(0.290284633636475), FRAC_CONST(0.956940352916718) }, + { FRAC_CONST(0.195090234279633), FRAC_CONST(0.980785310268402) }, + { FRAC_CONST(0.098017133772373), FRAC_CONST(0.995184719562531) }, + { FRAC_CONST(1.000000000000000), FRAC_CONST(0.000000000000000) }, + { FRAC_CONST(0.980785250663757), FRAC_CONST(0.195090323686600) }, + { FRAC_CONST(0.923879504203796), FRAC_CONST(0.382683455944061) }, + { FRAC_CONST(0.831469595432281), FRAC_CONST(0.555570244789124) }, + { FRAC_CONST(0.707106769084930), FRAC_CONST(0.707106769084930) }, + { FRAC_CONST(0.555570185184479), FRAC_CONST(0.831469655036926) }, + { FRAC_CONST(0.382683426141739), FRAC_CONST(0.923879504203796) }, + { FRAC_CONST(0.195090234279633), FRAC_CONST(0.980785310268402) }, + { FRAC_CONST(-0.000000043711388), FRAC_CONST(1.000000000000000) }, + { FRAC_CONST(-0.195090323686600), FRAC_CONST(0.980785250663757) }, + { FRAC_CONST(-0.382683515548706), FRAC_CONST(0.923879504203796) }, + { FRAC_CONST(-0.555570363998413), FRAC_CONST(0.831469535827637) }, + { FRAC_CONST(-0.707106769084930), FRAC_CONST(0.707106769084930) }, + { FRAC_CONST(-0.831469655036926), FRAC_CONST(0.555570185184479) }, + { FRAC_CONST(-0.923879623413086), FRAC_CONST(0.382683277130127) }, + { FRAC_CONST(-0.980785310268402), FRAC_CONST(0.195090308785439) }, + { FRAC_CONST(1.000000000000000), FRAC_CONST(0.000000000000000) }, + { FRAC_CONST(0.956940352916718), FRAC_CONST(0.290284663438797) }, + { FRAC_CONST(0.831469595432281), FRAC_CONST(0.555570244789124) }, + { FRAC_CONST(0.634393274784088), FRAC_CONST(0.773010432720184) }, + { FRAC_CONST(0.382683426141739), FRAC_CONST(0.923879504203796) }, + { FRAC_CONST(0.098017133772373), FRAC_CONST(0.995184719562531) }, + { FRAC_CONST(-0.195090323686600), FRAC_CONST(0.980785250663757) }, + { FRAC_CONST(-0.471396833658218), FRAC_CONST(0.881921231746674) }, + { FRAC_CONST(-0.707106769084930), FRAC_CONST(0.707106769084930) }, + { FRAC_CONST(-0.881921231746674), FRAC_CONST(0.471396833658218) }, + { FRAC_CONST(-0.980785310268402), FRAC_CONST(0.195090308785439) }, + { FRAC_CONST(-0.995184719562531), FRAC_CONST(-0.098017267882824) }, + { FRAC_CONST(-0.923879504203796), FRAC_CONST(-0.382683426141739) }, + { FRAC_CONST(-0.773010551929474), FRAC_CONST(-0.634393215179443) }, + { FRAC_CONST(-0.555570006370544), FRAC_CONST(-0.831469774246216) }, + { FRAC_CONST(-0.290284544229507), FRAC_CONST(-0.956940352916718) }, + { FRAC_CONST(1.000000000000000), FRAC_CONST(0.000000000000000) }, + { FRAC_CONST(0.923879504203796), FRAC_CONST(0.382683455944061) }, + { FRAC_CONST(0.707106769084930), FRAC_CONST(0.707106769084930) }, + { FRAC_CONST(0.382683426141739), FRAC_CONST(0.923879504203796) }, + { FRAC_CONST(1.000000000000000), FRAC_CONST(0.000000000000000) }, + { FRAC_CONST(0.707106769084930), FRAC_CONST(0.707106769084930) }, + { FRAC_CONST(-0.000000043711388), FRAC_CONST(1.000000000000000) }, + { FRAC_CONST(-0.707106769084930), FRAC_CONST(0.707106769084930) }, + { FRAC_CONST(1.000000000000000), FRAC_CONST(0.000000000000000) }, + { FRAC_CONST(0.382683426141739), FRAC_CONST(0.923879504203796) }, + { FRAC_CONST(-0.707106769084930), FRAC_CONST(0.707106769084930) }, + { FRAC_CONST(-0.923879504203796), FRAC_CONST(-0.382683426141739) }, + { FRAC_CONST(1.000000000000000), FRAC_CONST(0.000000000000000) }, + { FRAC_CONST(1.000000000000000), FRAC_CONST(0.000000000000000) }, + { FRAC_CONST(1.000000000000000), FRAC_CONST(0.000000000000000) }, + { FRAC_CONST(0.000000011924881), FRAC_CONST(-1.000000000000000) } +}; + #endif #ifdef __cplusplus diff --git a/libfaad2/common.c b/libfaad2/common.c index 7b60c80b15..a06f938460 100644 --- a/libfaad2/common.c +++ b/libfaad2/common.c @@ -1,19 +1,19 @@ /* ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding ** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com -** +** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. -** +** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. -** +** ** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software +** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** ** Any non-GPL usage of this software or parts of this software is strictly @@ -22,7 +22,7 @@ ** Commercial non-GPL licensing of this software is possible. ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. ** -** $Id: common.c,v 1.19 2004/06/30 12:45:56 menno Exp $ +** $Id: common.c,v 1.22 2004/09/08 09:43:11 gcp Exp $ **/ /* just some common functions that could be used anywhere */ @@ -33,67 +33,6 @@ #include #include "syntax.h" -#ifdef USE_SSE -__declspec(naked) static int32_t __fastcall test_cpuid(void) -{ - __asm - { - pushf - pop eax - mov ecx,eax - xor eax,(1<<21) - push eax - popf - pushf - pop eax - push ecx - popf - cmp eax,ecx - mov eax,0 - setne al - ret - } -} - -__declspec(naked) static void __fastcall run_cpuid(int32_t param, int32_t out[4]) -{ - __asm - { - pushad - push edx - mov eax,ecx - cpuid - pop edi - mov [edi+0],eax - mov [edi+4],ebx - mov [edi+8],ecx - mov [edi+12],edx - popad - ret - } -} - -uint8_t cpu_has_sse() -{ - int32_t features[4]; - - if (test_cpuid()) - { - run_cpuid(1, features); - } - - /* check for SSE */ - if (features[3] & 0x02000000) - return 1; - - return 0; -} -#else -uint8_t cpu_has_sse() -{ - return 0; -} -#endif /* Returns the sample rate index based on the samplerate */ uint8_t get_sr_index(const uint32_t samplerate) @@ -146,7 +85,7 @@ uint8_t max_pred_sfb(const uint8_t sr_index) uint8_t max_tns_sfb(const uint8_t sr_index, const uint8_t object_type, const uint8_t is_short) { - /* entry for each sampling rate + /* entry for each sampling rate * 1 Main/LC long window * 2 Main/LC short window * 3 SSR long window @@ -230,14 +169,13 @@ int8_t can_decode_ot(const uint8_t object_type) return -1; } -/* common malloc function */ void *faad_malloc(size_t size) { #if 0 // defined(_WIN32) && !defined(_WIN32_WCE) return _aligned_malloc(size, 16); -#else +#else // #ifdef 0 return malloc(size); -#endif +#endif // #ifdef 0 } /* common free function */ @@ -247,18 +185,18 @@ void faad_free(void *b) _aligned_free(b); #else free(b); -#endif } +#endif static const uint8_t Parity [256] = { // parity - 0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1, - 1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0, - 1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0, - 0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1, - 1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0, - 0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1, - 0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1, - 1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0 + 0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1, + 1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0, + 1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0, + 0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1, + 1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0, + 0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1, + 0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1, + 1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0 }; static uint32_t __r1 = 1; @@ -293,14 +231,14 @@ static uint32_t __r2 = 1; */ uint32_t random_int(void) { - uint32_t t1, t2, t3, t4; + uint32_t t1, t2, t3, t4; - t3 = t1 = __r1; t4 = t2 = __r2; // Parity calculation is done via table lookup, this is also available - t1 &= 0xF5; t2 >>= 25; // on CPUs without parity, can be implemented in C and avoid unpredictable - t1 = Parity [t1]; t2 &= 0x63; // jumps and slow rotate through the carry flag operations. - t1 <<= 31; t2 = Parity [t2]; + t3 = t1 = __r1; t4 = t2 = __r2; // Parity calculation is done via table lookup, this is also available + t1 &= 0xF5; t2 >>= 25; // on CPUs without parity, can be implemented in C and avoid unpredictable + t1 = Parity [t1]; t2 &= 0x63; // jumps and slow rotate through the carry flag operations. + t1 <<= 31; t2 = Parity [t2]; - return (__r1 = (t3 >> 1) | t1 ) ^ (__r2 = (t4 + t4) | t2 ); + return (__r1 = (t3 >> 1) | t1 ) ^ (__r2 = (t4 + t4) | t2 ); } uint32_t ones32(uint32_t x) @@ -496,7 +434,7 @@ int32_t log2_int(uint32_t val) { uint32_t frac; uint32_t whole = (val); - int8_t exp = 0; + int32_t exp = 0; uint32_t index; uint32_t index_frac; uint32_t x1, x2; @@ -534,4 +472,48 @@ int32_t log2_int(uint32_t val) return ((exp+REAL_BITS) << REAL_BITS) + errcorr + x1; } + +/* ld(x) = ld(x*y/y) = ld(x/y) + ld(y), with y=2^N and [1 <= (x/y) < 2] */ +real_t log2_fix(uint32_t val) +{ + uint32_t frac; + uint32_t whole = (val >> REAL_BITS); + int8_t exp = 0; + uint32_t index; + uint32_t index_frac; + uint32_t x1, x2; + uint32_t errcorr; + + /* error */ + if (val == 0) + return -100000; + + exp = floor_log2(val); + exp -= REAL_BITS; + + /* frac = [1..2] */ + if (exp >= 0) + frac = val >> exp; + else + frac = val << -exp; + + /* index in the log2 table */ + index = frac >> (REAL_BITS-TABLE_BITS); + + /* leftover part for linear interpolation */ + index_frac = frac & ((1<<(REAL_BITS-TABLE_BITS))-1); + + /* leave INTERP_BITS bits */ + index_frac = index_frac >> (REAL_BITS-TABLE_BITS-INTERP_BITS); + + x1 = log2_tab[index & ((1<> INTERP_BITS; + + return (exp << REAL_BITS) + errcorr + x1; +} #endif diff --git a/libfaad2/common.h b/libfaad2/common.h index 859baf2155..d4f4b3a73d 100644 --- a/libfaad2/common.h +++ b/libfaad2/common.h @@ -134,12 +134,6 @@ extern "C" { # endif #endif -#if ((defined(_WIN32) && !defined(_WIN32_WCE)) /* || ((__GNUC__ >= 3) && defined(__i386__)) */ ) -#ifndef FIXED_POINT -/* includes to enable SSE intrinsics */ -//#define USE_SSE -#endif -#endif #ifdef FIXED_POINT #define DIV_R(A, B) (((int64_t)A << REAL_BITS)/B) @@ -307,10 +301,6 @@ char *strchr(), *strrchr(); typedef float real_t; -#ifdef USE_SSE -# include -#endif - #define MUL_R(A,B) ((A)*(B)) #define MUL_C(A,B) ((A)*(B)) #define MUL_F(A,B) ((A)*(B)) @@ -341,7 +331,7 @@ char *strchr(), *strrchr(); } return i; } - #elif (defined(__i386__) && defined(__GNUC__)) && !defined(__MINGW32__) && !defined(HAVE_LRINTF) + #elif (defined(__i386__) && defined(__GNUC__)) && !defined(HAVE_LRINTF) #define HAS_LRINTF // from http://www.stereopsis.com/FPU.html static INLINE int lrintf(float f) @@ -426,6 +416,7 @@ uint32_t wl_min_lzc(uint32_t x); #ifdef FIXED_POINT #define LOG2_MIN_INF REAL_CONST(-10000) int32_t log2_int(uint32_t val); +int32_t log2_fix(uint32_t val); int32_t pow2_int(real_t val); real_t pow2_fix(real_t val); #endif diff --git a/libfaad2/decoder.c b/libfaad2/decoder.c index b4a7c4b1b7..f7d699f785 100644 --- a/libfaad2/decoder.c +++ b/libfaad2/decoder.c @@ -22,7 +22,7 @@ ** Commercial non-GPL licensing of this software is possible. ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. ** -** $Id: decoder.c,v 1.104 2004/06/30 12:45:56 menno Exp $ +** $Id: decoder.c,v 1.107 2004/09/08 09:43:11 gcp Exp $ **/ #include "common.h" @@ -143,15 +143,6 @@ NeAACDecHandle NEAACDECAPI NeAACDecOpen(void) hDecoder->drc = drc_init(REAL_CONST(1.0), REAL_CONST(1.0)); -#ifdef USE_SSE - if (cpu_has_sse()) - { - hDecoder->apply_sf_func = apply_scalefactors_sse; - } else { - hDecoder->apply_sf_func = apply_scalefactors; - } -#endif - return hDecoder; } @@ -901,6 +892,9 @@ static void* aac_frame_decode(NeAACDecHandle hDecoder, NeAACDecFrameInfo *hInfo, hInfo->header_type = ADIF; if (hDecoder->adts_header_present) hInfo->header_type = ADTS; +#if (defined(PS_DEC) || defined(DRM_PS)) + hInfo->ps = hDecoder->ps_used_global; +#endif /* check if frame has channel elements */ if (channels == 0) diff --git a/libfaad2/decoder.h b/libfaad2/decoder.h index ec5e5d3495..1b0c683afc 100644 --- a/libfaad2/decoder.h +++ b/libfaad2/decoder.h @@ -22,7 +22,7 @@ ** Commercial non-GPL licensing of this software is possible. ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. ** -** $Id: decoder.h,v 1.42 2004/05/17 10:18:02 menno Exp $ +** $Id: decoder.h,v 1.44 2004/09/04 14:56:28 menno Exp $ **/ #ifndef __DECODER_H__ diff --git a/libfaad2/drc.c b/libfaad2/drc.c index 7f8634306d..0b199c3304 100644 --- a/libfaad2/drc.c +++ b/libfaad2/drc.c @@ -22,7 +22,7 @@ ** Commercial non-GPL licensing of this software is possible. ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. ** -** $Id: drc.c,v 1.22 2004/02/26 09:29:26 menno Exp $ +** $Id: drc.c,v 1.24 2004/09/04 14:56:28 menno Exp $ **/ #include "common.h" diff --git a/libfaad2/drc.h b/libfaad2/drc.h index bddae2ce74..030939f19d 100644 --- a/libfaad2/drc.h +++ b/libfaad2/drc.h @@ -22,7 +22,7 @@ ** Commercial non-GPL licensing of this software is possible. ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. ** -** $Id: drc.h,v 1.16 2004/02/26 09:29:26 menno Exp $ +** $Id: drc.h,v 1.18 2004/09/04 14:56:28 menno Exp $ **/ #ifndef __DRC_H__ diff --git a/libfaad2/drm_dec.c b/libfaad2/drm_dec.c new file mode 100644 index 0000000000..8bf905169d --- /dev/null +++ b/libfaad2/drm_dec.c @@ -0,0 +1,990 @@ +/* +** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR and PS decoding +** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +** +** Any non-GPL usage of this software or parts of this software is strictly +** forbidden. +** +** Commercial non-GPL licensing of this software is possible. +** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** +** $Id$ +**/ + +#include +#include +#include +#include +#include "common.h" + +#ifdef DRM + +#include "sbr_dec.h" +#include "drm_dec.h" +#include "bits.h" + +/* constants */ +#define DECAY_CUTOFF 3 +#define DECAY_SLOPE 0.05f + +/* type definitaions */ +typedef const int8_t (*drm_ps_huff_tab)[2]; + + +/* binary search huffman tables */ +static const int8_t f_huffman_sa[][2] = +{ + { /*0*/ -15, 1 }, /* index 0: 1 bits: x */ + { 2, 3 }, /* index 1: 2 bits: 1x */ + { /*7*/ -8, 4 }, /* index 2: 3 bits: 10x */ + { 5, 6 }, /* index 3: 3 bits: 11x */ + { /*1*/ -14, /*-1*/ -16 }, /* index 4: 4 bits: 101x */ + { /*-2*/ -17, 7 }, /* index 5: 4 bits: 110x */ + { 8, 9 }, /* index 6: 4 bits: 111x */ + { /*2*/ -13, /*-3*/ -18 }, /* index 7: 5 bits: 1101x */ + { /*3*/ -12, 10 }, /* index 8: 5 bits: 1110x */ + { 11, 12 }, /* index 9: 5 bits: 1111x */ + { /*4*/ -11, /*5*/ -10 }, /* index 10: 6 bits: 11101x */ + { /*-4*/ -19, /*-5*/ -20 }, /* index 11: 6 bits: 11110x */ + { /*6*/ -9, 13 }, /* index 12: 6 bits: 11111x */ + { /*-7*/ -22, /*-6*/ -21 } /* index 13: 7 bits: 111111x */ +}; + +static const int8_t t_huffman_sa[][2] = +{ + { /*0*/ -15, 1 }, /* index 0: 1 bits: x */ + { 2, 3 }, /* index 1: 2 bits: 1x */ + { /*-1*/ -16, /*1*/ -14 }, /* index 2: 3 bits: 10x */ + { 4, 5 }, /* index 3: 3 bits: 11x */ + { /*-2*/ -17, /*2*/ -13 }, /* index 4: 4 bits: 110x */ + { 6, 7 }, /* index 5: 4 bits: 111x */ + { /*-3*/ -18, /*3*/ -12 }, /* index 6: 5 bits: 1110x */ + { 8, 9 }, /* index 7: 5 bits: 1111x */ + { /*-4*/ -19, /*4*/ -11 }, /* index 8: 6 bits: 11110x */ + { 10, 11 }, /* index 9: 6 bits: 11111x */ + { /*-5*/ -20, /*5*/ -10 }, /* index 10: 7 bits: 111110x */ + { /*-6*/ -21, 12 }, /* index 11: 7 bits: 111111x */ + { /*-7*/ -22, 13 }, /* index 12: 8 bits: 1111111x */ + { /*6*/ -9, /*7*/ -8 } /* index 13: 9 bits: 11111111x */ +}; + +static const int8_t f_huffman_pan[][2] = +{ + { /*0*/ -15, 1 }, /* index 0: 1 bits: x */ + { /*-1*/ -16, 2 }, /* index 1: 2 bits: 1x */ + { /*1*/ -14, 3 }, /* index 2: 3 bits: 11x */ + { 4, 5 }, /* index 3: 4 bits: 111x */ + { /*-2*/ -17, /*2*/ -13 }, /* index 4: 5 bits: 1110x */ + { 6, 7 }, /* index 5: 5 bits: 1111x */ + { /*-3*/ -18, /*3*/ -12 }, /* index 6: 6 bits: 11110x */ + { 8, 9 }, /* index 7: 6 bits: 11111x */ + { /*-4*/ -19, /*4*/ -11 }, /* index 8: 7 bits: 111110x */ + { 10, 11 }, /* index 9: 7 bits: 111111x */ + { /*-5*/ -20, /*5*/ -10 }, /* index 10: 8 bits: 1111110x */ + { 12, 13 }, /* index 11: 8 bits: 1111111x */ + { /*-6*/ -21, /*6*/ -9 }, /* index 12: 9 bits: 11111110x */ + { /*-7*/ -22, 14 }, /* index 13: 9 bits: 11111111x */ + { /*7*/ -8, 15 }, /* index 14: 10 bits: 111111111x */ + { 16, 17 }, /* index 15: 11 bits: 1111111111x */ + { /*-8*/ -23, /*8*/ -7 }, /* index 16: 12 bits: 11111111110x */ + { 18, 19 }, /* index 17: 12 bits: 11111111111x */ + { /*-10*/ -25, 20 }, /* index 18: 13 bits: 111111111110x */ + { 21, 22 }, /* index 19: 13 bits: 111111111111x */ + { /*-9*/ -24, /*9*/ -6 }, /* index 20: 14 bits: 1111111111101x */ + { /*10*/ -5, 23 }, /* index 21: 14 bits: 1111111111110x */ + { 24, 25 }, /* index 22: 14 bits: 1111111111111x */ + { /*-13*/ -28, /*-11*/ -26 }, /* index 23: 15 bits: 11111111111101x */ + { /*11*/ -4, /*13*/ -2 }, /* index 24: 15 bits: 11111111111110x */ + { 26, 27 }, /* index 25: 15 bits: 11111111111111x */ + { /*-14*/ -29, /*-12*/ -27 }, /* index 26: 16 bits: 111111111111110x */ + { /*12*/ -3, /*14*/ -1 } /* index 27: 16 bits: 111111111111111x */ +}; + +static const int8_t t_huffman_pan[][2] = +{ + { /*0*/ -15, 1 }, /* index 0: 1 bits: x */ + { /*-1*/ -16, 2 }, /* index 1: 2 bits: 1x */ + { /*1*/ -14, 3 }, /* index 2: 3 bits: 11x */ + { /*-2*/ -17, 4 }, /* index 3: 4 bits: 111x */ + { /*2*/ -13, 5 }, /* index 4: 5 bits: 1111x */ + { /*-3*/ -18, 6 }, /* index 5: 6 bits: 11111x */ + { /*3*/ -12, 7 }, /* index 6: 7 bits: 111111x */ + { /*-4*/ -19, 8 }, /* index 7: 8 bits: 1111111x */ + { /*4*/ -11, 9 }, /* index 8: 9 bits: 11111111x */ + { 10, 11 }, /* index 9: 10 bits: 111111111x */ + { /*-5*/ -20, /*5*/ -10 }, /* index 10: 11 bits: 1111111110x */ + { 12, 13 }, /* index 11: 11 bits: 1111111111x */ + { /*-6*/ -21, /*6*/ -9 }, /* index 12: 12 bits: 11111111110x */ + { 14, 15 }, /* index 13: 12 bits: 11111111111x */ + { /*-7*/ -22, /*7*/ -8 }, /* index 14: 13 bits: 111111111110x */ + { 16, 17 }, /* index 15: 13 bits: 111111111111x */ + { /*-8*/ -23, /*8*/ -7 }, /* index 16: 14 bits: 1111111111110x */ + { 18, 19 }, /* index 17: 14 bits: 1111111111111x */ + { /*-10*/ -25, /*10*/ -5 }, /* index 18: 15 bits: 11111111111110x */ + { 20, 21 }, /* index 19: 15 bits: 11111111111111x */ + { /*-9*/ -24, /*9*/ -6 }, /* index 20: 16 bits: 111111111111110x */ + { 22, 23 }, /* index 21: 16 bits: 111111111111111x */ + { 24, 25 }, /* index 22: 17 bits: 1111111111111110x */ + { 26, 27 }, /* index 23: 17 bits: 1111111111111111x */ + { /*-14*/ -29, /*-13*/ -28 }, /* index 24: 18 bits: 11111111111111100x */ + { /*-12*/ -27, /*-11*/ -26 }, /* index 25: 18 bits: 11111111111111101x */ + { /*11*/ -4, /*12*/ -3 }, /* index 26: 18 bits: 11111111111111110x */ + { /*13*/ -2, /*14*/ -1 } /* index 27: 18 bits: 11111111111111111x */ +}; + +/* There are 3 classes in the standard but the last 2 are identical */ +static const real_t sa_quant[8][2] = +{ + { FRAC_CONST(0.0000), FRAC_CONST(0.0000) }, + { FRAC_CONST(0.0501), FRAC_CONST(0.1778) }, + { FRAC_CONST(0.0706), FRAC_CONST(0.2818) }, + { FRAC_CONST(0.0995), FRAC_CONST(0.4467) }, + { FRAC_CONST(0.1399), FRAC_CONST(0.5623) }, + { FRAC_CONST(0.1957), FRAC_CONST(0.7079) }, + { FRAC_CONST(0.2713), FRAC_CONST(0.8913) }, + { FRAC_CONST(0.3699), FRAC_CONST(1.0000) }, +}; + +/* We don't need the actual quantizer values */ +#if 0 +static const real_t pan_quant[8][5] = +{ + { COEF_CONST(0.0000), COEF_CONST(0.0000), COEF_CONST(0.0000), COEF_CONST(0.0000), COEF_CONST(0.0000) }, + { COEF_CONST(0.1661), COEF_CONST(0.1661), COEF_CONST(0.3322), COEF_CONST(0.3322), COEF_CONST(0.3322) }, + { COEF_CONST(0.3322), COEF_CONST(0.3322), COEF_CONST(0.6644), COEF_CONST(0.8305), COEF_CONST(0.8305) }, + { COEF_CONST(0.4983), COEF_CONST(0.6644), COEF_CONST(0.9966), COEF_CONST(1.4949), COEF_CONST(1.6610) }, + { COEF_CONST(0.6644), COEF_CONST(0.9966), COEF_CONST(1.4949), COEF_CONST(2.1593), COEF_CONST(2.4914) }, + { COEF_CONST(0.8305), COEF_CONST(1.3288), COEF_CONST(2.1593), COEF_CONST(2.9897), COEF_CONST(3.4880) }, + { COEF_CONST(0.9966), COEF_CONST(1.8271), COEF_CONST(2.8236), COEF_CONST(3.8202), COEF_CONST(4.6507) }, + { COEF_CONST(1.3288), COEF_CONST(2.3253), COEF_CONST(3.4880), COEF_CONST(4.6507), COEF_CONST(5.8134) }, +}; +#endif + +/* 2^(pan_quant[x][y] */ +static const real_t pan_pow_2_pos[8][5] = { + { REAL_CONST(1.0000000), REAL_CONST(1.0000000), REAL_CONST(1.0000000), REAL_CONST(1.0000000), REAL_CONST(1.0000000) }, + { REAL_CONST(1.1220021), REAL_CONST(1.1220021), REAL_CONST(1.2589312), REAL_CONST(1.2589312), REAL_CONST(1.2589312) }, + { REAL_CONST(1.2589312), REAL_CONST(1.2589312), REAL_CONST(1.5849090), REAL_CONST(1.7783016), REAL_CONST(1.7783016) }, + { REAL_CONST(1.4125481), REAL_CONST(1.5849090), REAL_CONST(1.9952921), REAL_CONST(2.8184461), REAL_CONST(3.1623565) }, + { REAL_CONST(1.5849090), REAL_CONST(1.9952922), REAL_CONST(2.8184461), REAL_CONST(4.4669806), REAL_CONST(5.6232337) }, + { REAL_CONST(1.7783016), REAL_CONST(2.5119365), REAL_CONST(4.4669806), REAL_CONST(7.9430881), REAL_CONST(11.219994) }, + { REAL_CONST(1.9952921), REAL_CONST(3.5482312), REAL_CONST(7.0792671), REAL_CONST(14.125206), REAL_CONST(25.118876) }, + { REAL_CONST(2.5119365), REAL_CONST(5.0116998), REAL_CONST(11.219994), REAL_CONST(25.118876), REAL_CONST(56.235140) } +}; + +/* 2^(-pan_quant[x][y] */ +static const real_t pan_pow_2_neg[8][5] = { + { REAL_CONST(1), REAL_CONST(1), REAL_CONST(1), REAL_CONST(1), REAL_CONST(1) }, + { REAL_CONST(0.8912487), REAL_CONST(0.8912487), REAL_CONST(0.7943242), REAL_CONST(0.7943242), REAL_CONST(0.7943242) }, + { REAL_CONST(0.7943242), REAL_CONST(0.7943242), REAL_CONST(0.6309511), REAL_CONST(0.5623344), REAL_CONST(0.5623344) }, + { REAL_CONST(0.7079405), REAL_CONST(0.6309511), REAL_CONST(0.5011797), REAL_CONST(0.3548054), REAL_CONST(0.3162199) }, + { REAL_CONST(0.6309511), REAL_CONST(0.5011797), REAL_CONST(0.3548054), REAL_CONST(0.2238649), REAL_CONST(0.1778336) }, + { REAL_CONST(0.5623343), REAL_CONST(0.3980992), REAL_CONST(0.2238649), REAL_CONST(0.1258956), REAL_CONST(0.0891266) }, + { REAL_CONST(0.5011797), REAL_CONST(0.2818306), REAL_CONST(0.1412576), REAL_CONST(0.0707954), REAL_CONST(0.0398107) }, + { REAL_CONST(0.3980992), REAL_CONST(0.1995331), REAL_CONST(0.0891267), REAL_CONST(0.0398107), REAL_CONST(0.0177825) } +}; + +/* 2^(pan_quant[x][y]/30) */ +static const real_t pan_pow_2_30_pos[8][5] = { + { COEF_CONST(1), COEF_CONST(1), COEF_CONST(1), COEF_CONST(1), COEF_CONST(1) }, + { COEF_CONST(1.003845098), COEF_CONST(1.003845098), COEF_CONST(1.007704982), COEF_CONST(1.007704982), COEF_CONST(1.007704982) }, + { COEF_CONST(1.007704982), COEF_CONST(1.007704982), COEF_CONST(1.01546933), COEF_CONST(1.019373909), COEF_CONST(1.019373909) }, + { COEF_CONST(1.011579706), COEF_CONST(1.01546933), COEF_CONST(1.023293502), COEF_CONST(1.035142941), COEF_CONST(1.039123167) }, + { COEF_CONST(1.01546933), COEF_CONST(1.023293502), COEF_CONST(1.035142941), COEF_CONST(1.051155908), COEF_CONST(1.059252598) }, + { COEF_CONST(1.019373909), COEF_CONST(1.03117796), COEF_CONST(1.051155908), COEF_CONST(1.071518432), COEF_CONST(1.0839263) }, + { COEF_CONST(1.023293502), COEF_CONST(1.043118698), COEF_CONST(1.067414119), COEF_CONST(1.092277933), COEF_CONST(1.113439626) }, + { COEF_CONST(1.03117796), COEF_CONST(1.055195268), COEF_CONST(1.0839263), COEF_CONST(1.113439626), COEF_CONST(1.143756546) } +}; + +/* 2^(-pan_quant[x][y]/30) */ +static const real_t pan_pow_2_30_neg[8][5] = { + { COEF_CONST(1), COEF_CONST(1), COEF_CONST(1), COEF_CONST(1), COEF_CONST(1) }, + { COEF_CONST(0.99616963), COEF_CONST(0.99616963), COEF_CONST(0.992353931), COEF_CONST(0.992353931), COEF_CONST(0.99235393) }, + { COEF_CONST(0.992353931), COEF_CONST(0.992353931), COEF_CONST(0.984766325), COEF_CONST(0.980994305), COEF_CONST(0.980994305) }, + { COEF_CONST(0.988552848), COEF_CONST(0.984766325), COEF_CONST(0.977236734), COEF_CONST(0.966050157), COEF_CONST(0.962349827) }, + { COEF_CONST(0.984766325), COEF_CONST(0.977236734), COEF_CONST(0.966050157), COEF_CONST(0.951333663), COEF_CONST(0.944061881) }, + { COEF_CONST(0.980994305), COEF_CONST(0.969764715), COEF_CONST(0.951333663), COEF_CONST(0.933255062), COEF_CONST(0.922571949) }, + { COEF_CONST(0.977236734), COEF_CONST(0.958663671), COEF_CONST(0.936843519), COEF_CONST(0.915517901), COEF_CONST(0.898117847) }, + { COEF_CONST(0.969764715), COEF_CONST(0.947691892), COEF_CONST(0.922571949), COEF_CONST(0.898117847), COEF_CONST(0.874311936) } +}; + +static const real_t g_decayslope[MAX_SA_BAND] = { + FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(0.95),FRAC_CONST(0.9), FRAC_CONST(0.85), FRAC_CONST(0.8), + FRAC_CONST(0.75),FRAC_CONST(0.7), FRAC_CONST(0.65),FRAC_CONST(0.6), FRAC_CONST(0.55),FRAC_CONST(0.5), FRAC_CONST(0.45), + FRAC_CONST(0.4), FRAC_CONST(0.35),FRAC_CONST(0.3), FRAC_CONST(0.25),FRAC_CONST(0.2), FRAC_CONST(0.15), FRAC_CONST(0.1), + FRAC_CONST(0.05),FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0), + FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0), + FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0), + FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0) +}; + +static const real_t sa_sqrt_1_minus[8][2] = { + { FRAC_CONST(1), FRAC_CONST(1) }, + { FRAC_CONST(0.998744206), FRAC_CONST(0.984066644) }, + { FRAC_CONST(0.997504707), FRAC_CONST(0.959473168) }, + { FRAC_CONST(0.995037562), FRAC_CONST(0.894683804) }, + { FRAC_CONST(0.990165638), FRAC_CONST(0.826933317) }, + { FRAC_CONST(0.980663811), FRAC_CONST(0.706312672) }, + { FRAC_CONST(0.962494836), FRAC_CONST(0.45341406) }, + { FRAC_CONST(0.929071574), FRAC_CONST(0) } +}; + +static const uint8_t sa_freq_scale[9][2] = +{ + { 0, 0}, + { 1, 1}, + { 2, 2}, + { 3, 3}, + { 5, 5}, + { 7, 7}, + {10,10}, + {13,13}, + {46,23} +}; + +static const uint8_t pan_freq_scale[21] = +{ + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, + 11, 12, 13, 14, 15, 18, 22, 26, 32, 64 +}; + +static const uint8_t pan_quant_class[20] = +{ + 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 2, 2, 2, 2, 3, 3, 3, 4, 4, 4 +}; + +/* Inverse mapping lookup */ +static const uint8_t pan_inv_freq[64] = { + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, + 15, 15, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, + 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19 +}; + +static const uint8_t sa_inv_freq[MAX_SA_BAND] = { + 0, 1, 2, 3, 3, 4, 4, 5, 5, 5, 6, 6, 6, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7 +}; + +static const real_t filter_coeff[] = +{ + FRAC_CONST(0.65143905754106), + FRAC_CONST(0.56471812200776), + FRAC_CONST(0.48954165955695) +}; + +static const uint8_t delay_length[][2] = +{ + { 1, 3 }, { 2, 4 }, { 3, 5 } +}; + +static const real_t delay_fraction[] = +{ + FRAC_CONST(0.43), FRAC_CONST(0.75), FRAC_CONST(0.347) +}; + +static const real_t peak_decay[2] = +{ + FRAC_CONST(0.58664621951003), FRAC_CONST(0.76592833836465) +}; + +static const real_t smooth_coeff[2] = +{ + FRAC_CONST(0.6), FRAC_CONST(0.25) +}; + +/* Please note that these are the same tables as in plain PS */ +static const complex_t Q_Fract_allpass_Qmf[][3] = { + { { FRAC_CONST(0.7804303765), FRAC_CONST(0.6252426505) }, { FRAC_CONST(0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(0.8550928831), FRAC_CONST(0.5184748173) } }, + { { FRAC_CONST(-0.4399392009), FRAC_CONST(0.8980275393) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(-0.0643581524), FRAC_CONST(0.9979268909) } }, + { { FRAC_CONST(-0.9723699093), FRAC_CONST(-0.2334454209) }, { FRAC_CONST(0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(-0.9146071672), FRAC_CONST(0.4043435752) } }, + { { FRAC_CONST(0.0157073960), FRAC_CONST(-0.9998766184) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(-0.7814115286), FRAC_CONST(-0.6240159869) } }, + { { FRAC_CONST(0.9792228341), FRAC_CONST(-0.2027871907) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(0.1920081824), FRAC_CONST(-0.9813933372) } }, + { { FRAC_CONST(0.4115142524), FRAC_CONST(0.9114032984) }, { FRAC_CONST(0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(0.9589683414), FRAC_CONST(-0.2835132182) } }, + { { FRAC_CONST(-0.7996847630), FRAC_CONST(0.6004201174) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(0.6947838664), FRAC_CONST(0.7192186117) } }, + { { FRAC_CONST(-0.7604058385), FRAC_CONST(-0.6494481564) }, { FRAC_CONST(0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(-0.3164770305), FRAC_CONST(0.9486001730) } }, + { { FRAC_CONST(0.4679299891), FRAC_CONST(-0.8837655187) }, { FRAC_CONST(0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(-0.9874414206), FRAC_CONST(0.1579856575) } }, + { { FRAC_CONST(0.9645573497), FRAC_CONST(0.2638732493) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(-0.5966450572), FRAC_CONST(-0.8025052547) } }, + { { FRAC_CONST(-0.0471066870), FRAC_CONST(0.9988898635) }, { FRAC_CONST(0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(0.4357025325), FRAC_CONST(-0.9000906944) } }, + { { FRAC_CONST(-0.9851093888), FRAC_CONST(0.1719288528) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(0.9995546937), FRAC_CONST(-0.0298405960) } }, + { { FRAC_CONST(-0.3826831877), FRAC_CONST(-0.9238796234) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(0.4886211455), FRAC_CONST(0.8724960685) } }, + { { FRAC_CONST(0.8181498647), FRAC_CONST(-0.5750049949) }, { FRAC_CONST(0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(-0.5477093458), FRAC_CONST(0.8366686702) } }, + { { FRAC_CONST(0.7396308780), FRAC_CONST(0.6730127335) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(-0.9951074123), FRAC_CONST(-0.0987988561) } }, + { { FRAC_CONST(-0.4954589605), FRAC_CONST(0.8686313629) }, { FRAC_CONST(0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(-0.3725017905), FRAC_CONST(-0.9280315042) } }, + { { FRAC_CONST(-0.9557929039), FRAC_CONST(-0.2940406799) }, { FRAC_CONST(0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(0.6506417990), FRAC_CONST(-0.7593847513) } }, + { { FRAC_CONST(0.0784594864), FRAC_CONST(-0.9969173074) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(0.9741733670), FRAC_CONST(0.2258014232) } }, + { { FRAC_CONST(0.9900237322), FRAC_CONST(-0.1409008205) }, { FRAC_CONST(0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(0.2502108514), FRAC_CONST(0.9681913853) } }, + { { FRAC_CONST(0.3534744382), FRAC_CONST(0.9354441762) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(-0.7427945137), FRAC_CONST(0.6695194840) } }, + { { FRAC_CONST(-0.8358076215), FRAC_CONST(0.5490224361) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(-0.9370992780), FRAC_CONST(-0.3490629196) } }, + { { FRAC_CONST(-0.7181259394), FRAC_CONST(-0.6959131360) }, { FRAC_CONST(0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(-0.1237744763), FRAC_CONST(-0.9923103452) } }, + { { FRAC_CONST(0.5224990249), FRAC_CONST(-0.8526399136) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(0.8226406574), FRAC_CONST(-0.5685616732) } }, + { { FRAC_CONST(0.9460852146), FRAC_CONST(0.3239179254) }, { FRAC_CONST(0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(0.8844994903), FRAC_CONST(0.4665412009) } }, + { { FRAC_CONST(-0.1097348556), FRAC_CONST(0.9939609170) }, { FRAC_CONST(0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(-0.0047125919), FRAC_CONST(0.9999889135) } }, + { { FRAC_CONST(-0.9939610362), FRAC_CONST(0.1097337380) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(-0.8888573647), FRAC_CONST(0.4581840038) } }, + { { FRAC_CONST(-0.3239168525), FRAC_CONST(-0.9460855722) }, { FRAC_CONST(0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(-0.8172453642), FRAC_CONST(-0.5762898922) } }, + { { FRAC_CONST(0.8526405096), FRAC_CONST(-0.5224980116) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(0.1331215799), FRAC_CONST(-0.9910997152) } }, + { { FRAC_CONST(0.6959123611), FRAC_CONST(0.7181267142) }, { F