diff --git a/lib_com/cnst.h b/lib_com/cnst.h index f80119e697a92bf768d004c4b8d782aef68a73a7..ff6f43b16a6bcb9773e0b5ada0b61af4f30d4adc 100644 --- a/lib_com/cnst.h +++ b/lib_com/cnst.h @@ -210,6 +210,7 @@ enum{ #define INV_LOG_2 1.442695040888963f /* 1/log(2) */ #define INV_SQRT_2 0.70710676908493f /* 1/sqrt(2) */ +#define INV_SQRT_2_Q15 23170 /* 1/sqrt(2) in Q15 */ #define MAX_V_MULT_MAT 100 /* maximum array length for the function v_mult_mat() */ @@ -2926,6 +2927,7 @@ enum #define INV_MAX_LT_FX (Word16)((1.0f/MAX_LT)*32768) #define EVS_PI 3.14159265358979323846264338327950288f +#define EVS_PI_FX 25736 /* pi in Q13 */ #define LG10 24660 /* 10*log10(2) in Q13 */ diff --git a/lib_com/edct_fx.c b/lib_com/edct_fx.c index 06e1884563f4ef7798551550473ea17bb0110473..5b88f1f776d791be3221ca735d051866bd6f31ed 100644 --- a/lib_com/edct_fx.c +++ b/lib_com/edct_fx.c @@ -14,6 +14,44 @@ #include "math_32.h" +static Word16 get_edxt_factor( Word16 length ) /* Returns value of sqrtf(2.f/length) in Q15 */ +{ + Word16 factor = 0; /*Q15*/ + IF( EQ_16( length, 512 ) ) + { + factor = 2048; + } + ELSE IF( EQ_16( length, 256 ) ) + { + factor = 2896; + } + ELSE IF( EQ_16( length, 128 ) ) + { + factor = 4096; + } + ELSE IF( EQ_16( length, 640 ) ) + { + factor = 1832; + } + ELSE IF( EQ_16( length, 320 ) ) + { + factor = 2590; + } + ELSE IF( EQ_16( length, 160 ) ) + { + factor = 3663; + } + ELSE IF( EQ_16( length, 80 ) ) + { + factor = 5181; + } + ELSE IF( EQ_16( length, 960 ) ) + { + factor = 1496; + } + return factor; +} + static Word16 const * get_edct_table(Word16 length, Word16 *q) { Word16 const * edct_table = NULL; @@ -455,3 +493,245 @@ void iedct_short_fx( return; } + +#define FAST_EDXT /* optimized FFT-based DCT/DST algorithm */ +/*-------------------------------------------------------------------------* + * edxt_fx() + * + * DCT/DST-II or III transform (currently also calculates DCT-IV and DST-IV) + *-------------------------------------------------------------------------*/ + +void edxt_fx( + const Word32 *x, /* i : input signal */ + Word32 *y, /* o : output transform */ + const Word16 length, /* i : length */ + const UWord16 kernelType, /* i : kernel type (0 - 3) */ + const UWord16 synthesis /* i : nonzero for inverse */ +) +{ + Word16 k, m, fac = 0; + const Word16 *cosPtr = NULL, *sinPtr = NULL; + Word16 n = 0; + + IF( EQ_16( length, 512 ) ) + { + cosPtr = cos_scale_tbl_512; + sinPtr = sin_scale_tbl_512; + n = 1; + } + ELSE IF( EQ_16( length, 256 ) ) + { + cosPtr = cos_scale_tbl_512; + sinPtr = sin_scale_tbl_512; + n = 2; + } + ELSE IF( EQ_16( length, 128 ) ) + { + cosPtr = cos_scale_tbl_512; + sinPtr = sin_scale_tbl_512; + n = 4; + } + ELSE IF( EQ_16( length, 640 ) ) + { + cosPtr = cos_scale_tbl_640; + sinPtr = sin_scale_tbl_640; + n = 1; + } + ELSE IF( EQ_16( length, 320 ) ) + { + cosPtr = cos_scale_tbl_640; + sinPtr = sin_scale_tbl_640; + n = 2; + } + ELSE IF( EQ_16( length, 160 ) ) + { + cosPtr = cos_scale_tbl_640; + sinPtr = sin_scale_tbl_640; + n = 4; + } + ELSE IF( EQ_16( length, 80 ) ) + { + cosPtr = cos_scale_tbl_640; + sinPtr = sin_scale_tbl_640; + n = 8; + } + ELSE IF( EQ_16( length, 960 ) ) + { + cosPtr = cos_scale_tbl_960; + sinPtr = sin_scale_tbl_960; + n = 1; + } + +#ifdef FAST_EDXT + IF( EQ_16( kernelType, MDST_II ) || EQ_16( kernelType, MDCT_II ) ) + { + const Word16 Nm1 = sub( length, 1 ); + const Word16 xSign = sub( kernelType, 1 ); + Word32 re[L_FRAME_PLUS]; + Word32 im[L_FRAME_PLUS]; + + IF( !synthesis ) + { + FOR( k = shr( Nm1, 1 ); k >= 0; k-- ) /* pre-modulation of audio input */ + { + re[k] = x[2 * k]; + re[Nm1 - k] = Mpy_32_16_1( x[2 * k + 1], xSign ); + im[k] = im[Nm1 - k] = 0; + } + + IF( EQ_16( length, 512 ) ) + { + DoRTFTn_fx( re, im, 512 ); + } + ELSE /* fft() doesn't support 512 */ + { + fft_fx( re, im, length, 1 ); + } + + IF( shr( kernelType, 1 ) ) + { + FOR( k = shr( Nm1, 1 ); k > 0; k-- ) + { + // const float wRe = cosf( scale * k ); + // const float wIm = sinf( scale * k ); + const Word16 wRe = cosPtr[k * n]; + const Word16 wIm = sinPtr[k * n]; + + y[k] /*pt 1*/ = L_add( Mpy_32_16_1( re[k], wRe ), Mpy_32_16_1( im[k], wIm ) ); + y[length - k] = L_sub( Mpy_32_16_1( re[k], wIm ), Mpy_32_16_1( im[k], wRe ) ); + } + y[shr( length, 1 )] = Mpy_32_16_1( re[shr( length, 1 )], INV_SQRT_2_Q15 ); + } + ELSE /* forw. DST-II */ + { + FOR( k = shr( Nm1, 1 ); k > 0; k-- ) + { + // const float wRe = cosf( scale * k ); + // const float wIm = sinf( scale * k ); + const Word16 wRe = cosPtr[k * n]; + const Word16 wIm = sinPtr[k * n]; + + y[Nm1 - k] = L_add( Mpy_32_16_1( re[k], wRe ), Mpy_32_16_1( im[k], wIm ) ); + y[k - 1] = L_sub( Mpy_32_16_1( re[k], wIm ), Mpy_32_16_1( im[k], wRe ) ); + } + y[shr( Nm1, 1 )] = Mpy_32_16_1( re[shr( length, 1 )], INV_SQRT_2_Q15 ); + } + + y[Nm1 - Nm1 * (kernelType >> 1)] = L_shr( re[0], 1 ); + } + ELSE /* inverse II = III */ + { + IF( shr( kernelType, 1 ) ) + { + FOR( k = shr( Nm1, 1 ); k > 0; k-- ) + { + // const float wRe = cosf( scale * k ) * 0.5f; + // const float wIm = sinf( scale * k ) * 0.5f; + const Word16 wRe = shr( cosPtr[k * n], 1 ); + const Word16 wIm = shr( sinPtr[k * n], 1 ); + + re[k] = L_add( Mpy_32_16_1( x[k], wRe ), Mpy_32_16_1( x[length - k], wIm ) ); + im[k] = L_sub( Mpy_32_16_1( x[length - k], wRe ), Mpy_32_16_1( x[k], wIm ) ); + } + re[shr( length, 1 )] = Mpy_32_16_1(x[shr( length, 1 )], INV_SQRT_2_Q15); + } + ELSE /* DST type III */ + { + FOR( k = shr( Nm1, 1 ); k > 0; k-- ) + { + // const float wRe = cosf( scale * k ) * 0.5f; + // const float wIm = sinf( scale * k ) * 0.5f; + const Word16 wRe = shr( cosPtr[k * n], 1 ); + const Word16 wIm = shr( sinPtr[k * n], 1 ); + + re[k] = L_add( Mpy_32_16_1( x[Nm1 - k], wRe ), Mpy_32_16_1( x[k - 1], wIm ) ); + im[k] = L_sub( Mpy_32_16_1( x[k - 1], wRe ), Mpy_32_16_1( x[Nm1 - k], wIm ) ); + } + re[shr( length, 1 )] = Mpy_32_16_1(x[shr( Nm1, 1 )], INV_SQRT_2_Q15); + } + + re[0] = x[Nm1 - Nm1 * shr(kernelType, 1)]; + im[0] = im[shr( length, 1 )] = 0; + FOR( k = shr( Nm1, 1 ); k > 0; k-- ) + { + re[length - k] = re[k]; + im[length - k] = L_negate( im[k] ); + } + + IF( EQ_16( length, 512 ) ) + { + DoRTFTn_fx( re, im, 512 ); + } + ELSE /* fft() doesn't support 512 */ + { + fft_fx( re, im, length, 1 ); + } + + FOR( k = shr( Nm1, 1 ); k >= 0; k-- ) /* post-modulation of FFT output */ + { + y[2 * k] = re[k]; + IF( NE_16( xSign, 0 ) ) + { + y[2 * k + 1] = re[sub( Nm1, k )]; + } + ELSE + { + y[2 * k + 1] = 0; + } + } + } + } +#endif +#ifdef IVAS_FLOAT_FIXED_TO_BE_DONE + ELSE + /* TODO: below IF and ELSE blocks are unreachable, verified on code coverage report */ + IF( s_and( kernelType, 1 ) ) /* DST */ + { + const float offK = (kernelType == MDST_II && synthesis ? 0.5f : 1.0f - 0.5f * (kernelType >> 1)); + const float offM = (kernelType == MDST_II && synthesis ? 1.0f : 0.5f); + + FOR( k = 0; k < length; k++ ) + { + y[k] = 0.f; + FOR( m = 0; m < length; m++ ) + { + y[k] += x[m] * sinf( pi_len * ( m + offM ) * ( k + offK ) ); + } + } + IF( offK == 1.f ) + { + y[length - 1] *= 0.5f; /* scale Nyquist sample */ + } + } + ELSE /* kernelType 0, 2: DCT */ + { + const float offK = ( EQ_16( kernelType, MDCT_II ) && synthesis ? 0.5f : 0.5f - shr( shr( kernelType, 1 ), 1 ) ); + const float offM = ( EQ_16( kernelType, MDCT_II ) && synthesis ? 0.0f : 0.5f ); + + FOR( k = 0; k < length; k++ ) + { + y[k] = 0.f; + FOR( m = 0; m < length; m++ ) + { + y[k] += x[m] * cosf( pi_len * ( m + offM ) * ( k + offK ) ); + } + } + IF( offK == 0.f ) + { + y[0] *= 0.5f; /* scale lowest (i.e. DC) sample */ + } + } +#endif //IVAS_FLOAT_FIXED_TO_BE_DONE + /*v_multc(y, (kernelType == MDCT_II ? -1.f : 1.f) * sqrtf(2.f / length), y, length);*/ + fac = get_edxt_factor( length ); /* Q15 */ + IF( EQ_16( kernelType, MDCT_II ) ) + { + fac = negate( fac ); + } + + FOR( m = 0; m < length; m++ ) + { + y[m] = Mpy_32_16_1( y[m], fac ); + } + return; +} diff --git a/lib_com/prot_fx2.h b/lib_com/prot_fx2.h index 9f1e971f93d0f29358e1c46199f30d9e9c426fb5..554c8c49577e144427eadcf67a7e177ebd0d0b9b 100644 --- a/lib_com/prot_fx2.h +++ b/lib_com/prot_fx2.h @@ -3816,6 +3816,24 @@ void TCX_MDCT_Inverse( const Word16 r, const Word16 element_mode ); + +void TCX_MDST_Inverse_fx( + Word32 *x, + Word16 x_e, + Word16 *y, + const Word16 l, + const Word16 m, + const Word16 r ); + +void TCX_MDXT_Inverse_fx( + const Word32 *x, + Word16 x_e, + Word16 *y, + const Word16 l, + const Word16 m, + const Word16 r, + const UWord16 kernel_type ); + //edct_fx.c #define EDCT_FACTOR_SCALE 2 void edct_fx( @@ -3847,6 +3865,14 @@ void iedct_short_fx( const Word16 segment_length /* i : length */ ); +void edxt_fx( + const Word32 *x, /* i : input signal */ + Word32 *y, /* o : output transform */ + const Word16 length, /* i : length */ + const UWord16 kernelType, /* i : kernel type (0 - 3) */ + const UWord16 synthesis /* i : nonzero for inverse */ +); + //fft_evs.c void fft16(Word32 *re, Word32 *im, Word16 s, Word16 bScale); void BASOP_cfft(cmplx *pComplexBuf, Word16 sizeOfFft, Word16 *scale, Word32 workBuffer[2 * BASOP_CFFT_MAX_LENGTH]); diff --git a/lib_com/rom_com.c b/lib_com/rom_com.c index 272b1ab58e65329f2b1d6baac129a687edf28b54..679a8ca146d97c1a42ba98d97ad96daa0adfff5b 100644 --- a/lib_com/rom_com.c +++ b/lib_com/rom_com.c @@ -40902,3 +40902,876 @@ const Word16 ivas_sin_az_fx[361] = { SHC( 0x0000 ) }; + +#ifdef IVAS_FLOAT_FIXED +/* Tables required in edxt_fx() */ +const Word16 sin_scale_tbl_960[960] = /* Q15 */ + { + 0, 53, 107, 160, 214, + 268, 321, 375, 428, 482, + 536, 589, 643, 696, 750, + 804, 857, 911, 964, 1018, + 1072, 1125, 1179, 1232, 1286, + 1339, 1393, 1447, 1500, 1554, + 1607, 1661, 1714, 1768, 1821, + 1875, 1929, 1982, 2036, 2089, + 2143, 2196, 2250, 2303, 2357, + 2410, 2463, 2517, 2570, 2624, + 2677, 2731, 2784, 2838, 2891, + 2944, 2998, 3051, 3104, 3158, + 3211, 3265, 3318, 3371, 3425, + 3478, 3531, 3585, 3638, 3691, + 3744, 3798, 3851, 3904, 3957, + 4011, 4064, 4117, 4170, 4223, + 4276, 4330, 4383, 4436, 4489, + 4542, 4595, 4648, 4701, 4754, + 4807, 4860, 4913, 4966, 5019, + 5072, 5125, 5178, 5231, 5284, + 5337, 5390, 5443, 5496, 5549, + 5601, 5654, 5707, 5760, 5813, + 5865, 5918, 5971, 6024, 6076, + 6129, 6182, 6234, 6287, 6339, + 6392, 6445, 6497, 6550, 6602, + 6655, 6707, 6760, 6812, 6865, + 6917, 6969, 7022, 7074, 7126, + 7179, 7231, 7283, 7336, 7388, + 7440, 7492, 7544, 7597, 7649, + 7701, 7753, 7805, 7857, 7909, + 7961, 8013, 8065, 8117, 8169, + 8221, 8273, 8325, 8377, 8428, + 8480, 8532, 8584, 8635, 8687, + 8739, 8791, 8842, 8894, 8945, + 8997, 9048, 9100, 9151, 9203, + 9254, 9306, 9357, 9409, 9460, + 9511, 9563, 9614, 9665, 9716, + 9767, 9819, 9870, 9921, 9972, + 10023, 10074, 10125, 10176, 10227, + 10278, 10329, 10380, 10431, 10481, + 10532, 10583, 10634, 10684, 10735, + 10786, 10836, 10887, 10937, 10988, + 11038, 11089, 11139, 11190, 11240, + 11290, 11341, 11391, 11441, 11491, + 11542, 11592, 11642, 11692, 11742, + 11792, 11842, 11892, 11942, 11992, + 12042, 12092, 12142, 12191, 12241, + 12291, 12340, 12390, 12440, 12489, + 12539, 12588, 12638, 12687, 12737, + 12786, 12835, 12885, 12934, 12983, + 13033, 13082, 13131, 13180, 13229, + 13278, 13327, 13376, 13425, 13474, + 13523, 13571, 13620, 13669, 13718, + 13766, 13815, 13864, 13912, 13961, + 14009, 14058, 14106, 14154, 14203, + 14251, 14299, 14348, 14396, 14444, + 14492, 14540, 14588, 14636, 14684, + 14732, 14780, 14828, 14875, 14923, + 14971, 15019, 15066, 15114, 15161, + 15209, 15256, 15304, 15351, 15398, + 15446, 15493, 15540, 15587, 15635, + 15682, 15729, 15776, 15823, 15870, + 15917, 15963, 16010, 16057, 16104, + 16150, 16197, 16244, 16290, 16337, + 16383, 16429, 16476, 16522, 16568, + 16615, 16661, 16707, 16753, 16799, + 16845, 16891, 16937, 16983, 17029, + 17074, 17120, 17166, 17212, 17257, + 17303, 17348, 17394, 17439, 17484, + 17530, 17575, 17620, 17665, 17711, + 17756, 17801, 17846, 17891, 17936, + 17980, 18025, 18070, 18115, 18159, + 18204, 18248, 18293, 18337, 18382, + 18426, 18470, 18515, 18559, 18603, + 18647, 18691, 18735, 18779, 18823, + 18867, 18911, 18955, 18998, 19042, + 19086, 19129, 19173, 19216, 19259, + 19303, 19346, 19389, 19433, 19476, + 19519, 19562, 19605, 19648, 19691, + 19733, 19776, 19819, 19862, 19904, + 19947, 19989, 20032, 20074, 20116, + 20159, 20201, 20243, 20285, 20327, + 20369, 20411, 20453, 20495, 20537, + 20579, 20620, 20662, 20704, 20745, + 20787, 20828, 20869, 20911, 20952, + 20993, 21034, 21075, 21116, 21157, + 21198, 21239, 21280, 21321, 21361, + 21402, 21443, 21483, 21524, 21564, + 21604, 21645, 21685, 21725, 21765, + 21805, 21845, 21885, 21925, 21965, + 22004, 22044, 22084, 22123, 22163, + 22202, 22242, 22281, 22320, 22360, + 22399, 22438, 22477, 22516, 22555, + 22594, 22632, 22671, 22710, 22749, + 22787, 22826, 22864, 22902, 22941, + 22979, 23017, 23055, 23093, 23131, + 23169, 23207, 23245, 23283, 23320, + 23358, 23396, 23433, 23471, 23508, + 23545, 23583, 23620, 23657, 23694, + 23731, 23768, 23805, 23842, 23878, + 23915, 23952, 23988, 24025, 24061, + 24097, 24134, 24170, 24206, 24242, + 24278, 24314, 24350, 24386, 24422, + 24457, 24493, 24529, 24564, 24600, + 24635, 24670, 24706, 24741, 24776, + 24811, 24846, 24881, 24916, 24951, + 24985, 25020, 25054, 25089, 25123, + 25158, 25192, 25226, 25261, 25295, + 25329, 25363, 25397, 25430, 25464, + 25498, 25532, 25565, 25599, 25632, + 25665, 25699, 25732, 25765, 25798, + 25831, 25864, 25897, 25930, 25963, + 25995, 26028, 26060, 26093, 26125, + 26158, 26190, 26222, 26254, 26286, + 26318, 26350, 26382, 26414, 26445, + 26477, 26509, 26540, 26571, 26603, + 26634, 26665, 26696, 26727, 26758, + 26789, 26820, 26851, 26882, 26912, + 26943, 26973, 27004, 27034, 27064, + 27094, 27125, 27155, 27185, 27214, + 27244, 27274, 27304, 27333, 27363, + 27392, 27422, 27451, 27480, 27509, + 27538, 27567, 27596, 27625, 27654, + 27683, 27711, 27740, 27769, 27797, + 27825, 27854, 27882, 27910, 27938, + 27966, 27994, 28022, 28049, 28077, + 28105, 28132, 28160, 28187, 28214, + 28242, 28269, 28296, 28323, 28350, + 28377, 28403, 28430, 28457, 28483, + 28510, 28536, 28562, 28589, 28615, + 28641, 28667, 28693, 28719, 28744, + 28770, 28796, 28821, 28847, 28872, + 28897, 28923, 28948, 28973, 28998, + 29023, 29048, 29072, 29097, 29122, + 29146, 29171, 29195, 29219, 29244, + 29268, 29292, 29316, 29340, 29364, + 29387, 29411, 29435, 29458, 29482, + 29505, 29528, 29551, 29575, 29598, + 29621, 29643, 29666, 29689, 29712, + 29734, 29757, 29779, 29801, 29824, + 29846, 29868, 29890, 29912, 29934, + 29955, 29977, 29999, 30020, 30042, + 30063, 30084, 30106, 30127, 30148, + 30169, 30190, 30210, 30231, 30252, + 30272, 30293, 30313, 30333, 30354, + 30374, 30394, 30414, 30434, 30454, + 30473, 30493, 30513, 30532, 30552, + 30571, 30590, 30609, 30628, 30647, + 30666, 30685, 30704, 30723, 30741, + 30760, 30778, 30797, 30815, 30833, + 30851, 30869, 30887, 30905, 30923, + 30940, 30958, 30975, 30993, 31010, + 31028, 31045, 31062, 31079, 31096, + 31113, 31129, 31146, 31163, 31179, + 31196, 31212, 31228, 31245, 31261, + 31277, 31293, 31308, 31324, 31340, + 31356, 31371, 31387, 31402, 31417, + 31432, 31447, 31462, 31477, 31492, + 31507, 31522, 31536, 31551, 31565, + 31580, 31594, 31608, 31622, 31636, + 31650, 31664, 31678, 31691, 31705, + 31718, 31732, 31745, 31758, 31771, + 31785, 31797, 31810, 31823, 31836, + 31849, 31861, 31874, 31886, 31898, + 31911, 31923, 31935, 31947, 31959, + 31970, 31982, 31994, 32005, 32017, + 32028, 32039, 32050, 32062, 32073, + 32084, 32094, 32105, 32116, 32126, + 32137, 32147, 32158, 32168, 32178, + 32188, 32198, 32208, 32218, 32228, + 32237, 32247, 32256, 32266, 32275, + 32284, 32293, 32302, 32311, 32320, + 32329, 32338, 32346, 32355, 32363, + 32371, 32380, 32388, 32396, 32404, + 32412, 32420, 32427, 32435, 32443, + 32450, 32457, 32465, 32472, 32479, + 32486, 32493, 32500, 32507, 32513, + 32520, 32527, 32533, 32539, 32546, + 32552, 32558, 32564, 32570, 32576, + 32581, 32587, 32593, 32598, 32603, + 32609, 32614, 32619, 32624, 32629, + 32634, 32639, 32643, 32648, 32652, + 32657, 32661, 32665, 32670, 32674, + 32678, 32682, 32685, 32689, 32693, + 32696, 32700, 32703, 32706, 32710, + 32713, 32716, 32719, 32722, 32724, + 32727, 32730, 32732, 32735, 32737, + 32739, 32741, 32743, 32745, 32747, + 32749, 32751, 32752, 32754, 32755, + 32757, 32758, 32759, 32760, 32761, + 32762, 32763, 32764, 32764, 32765, + 32765, 32766, 32766, 32766, 32766 + }; + +const Word16 cos_scale_tbl_960[960] = /* Q15 */ + { + 32767, 32766, 32766, 32766, 32766, + 32765, 32765, 32764, 32764, 32763, + 32762, 32761, 32760, 32759, 32758, + 32757, 32755, 32754, 32752, 32751, + 32749, 32747, 32745, 32743, 32741, + 32739, 32737, 32735, 32732, 32730, + 32727, 32724, 32722, 32719, 32716, + 32713, 32710, 32706, 32703, 32700, + 32696, 32693, 32689, 32685, 32682, + 32678, 32674, 32670, 32665, 32661, + 32657, 32652, 32648, 32643, 32639, + 32634, 32629, 32624, 32619, 32614, + 32609, 32603, 32598, 32593, 32587, + 32581, 32576, 32570, 32564, 32558, + 32552, 32546, 32539, 32533, 32527, + 32520, 32513, 32507, 32500, 32493, + 32486, 32479, 32472, 32465, 32457, + 32450, 32443, 32435, 32427, 32420, + 32412, 32404, 32396, 32388, 32380, + 32371, 32363, 32355, 32346, 32338, + 32329, 32320, 32311, 32302, 32293, + 32284, 32275, 32266, 32256, 32247, + 32237, 32228, 32218, 32208, 32198, + 32188, 32178, 32168, 32158, 32147, + 32137, 32126, 32116, 32105, 32094, + 32084, 32073, 32062, 32050, 32039, + 32028, 32017, 32005, 31994, 31982, + 31970, 31959, 31947, 31935, 31923, + 31911, 31898, 31886, 31874, 31861, + 31849, 31836, 31823, 31810, 31797, + 31785, 31771, 31758, 31745, 31732, + 31718, 31705, 31691, 31678, 31664, + 31650, 31636, 31622, 31608, 31594, + 31580, 31565, 31551, 31536, 31522, + 31507, 31492, 31477, 31462, 31447, + 31432, 31417, 31402, 31387, 31371, + 31356, 31340, 31324, 31308, 31293, + 31277, 31261, 31245, 31228, 31212, + 31196, 31179, 31163, 31146, 31129, + 31113, 31096, 31079, 31062, 31045, + 31028, 31010, 30993, 30975, 30958, + 30940, 30923, 30905, 30887, 30869, + 30851, 30833, 30815, 30797, 30778, + 30760, 30741, 30723, 30704, 30685, + 30666, 30647, 30628, 30609, 30590, + 30571, 30552, 30532, 30513, 30493, + 30473, 30454, 30434, 30414, 30394, + 30374, 30354, 30333, 30313, 30293, + 30272, 30252, 30231, 30210, 30190, + 30169, 30148, 30127, 30106, 30084, + 30063, 30042, 30020, 29999, 29977, + 29955, 29934, 29912, 29890, 29868, + 29846, 29824, 29801, 29779, 29757, + 29734, 29712, 29689, 29666, 29643, + 29621, 29598, 29575, 29551, 29528, + 29505, 29482, 29458, 29435, 29411, + 29387, 29364, 29340, 29316, 29292, + 29268, 29244, 29219, 29195, 29171, + 29146, 29122, 29097, 29072, 29048, + 29023, 28998, 28973, 28948, 28923, + 28897, 28872, 28847, 28821, 28796, + 28770, 28744, 28719, 28693, 28667, + 28641, 28615, 28589, 28562, 28536, + 28510, 28483, 28457, 28430, 28403, + 28377, 28350, 28323, 28296, 28269, + 28242, 28214, 28187, 28160, 28132, + 28105, 28077, 28049, 28022, 27994, + 27966, 27938, 27910, 27882, 27854, + 27825, 27797, 27769, 27740, 27711, + 27683, 27654, 27625, 27596, 27567, + 27538, 27509, 27480, 27451, 27422, + 27392, 27363, 27333, 27304, 27274, + 27244, 27214, 27185, 27155, 27125, + 27094, 27064, 27034, 27004, 26973, + 26943, 26912, 26882, 26851, 26820, + 26789, 26758, 26727, 26696, 26665, + 26634, 26603, 26571, 26540, 26509, + 26477, 26445, 26414, 26382, 26350, + 26318, 26286, 26254, 26222, 26190, + 26158, 26125, 26093, 26060, 26028, + 25995, 25963, 25930, 25897, 25864, + 25831, 25798, 25765, 25732, 25699, + 25665, 25632, 25599, 25565, 25532, + 25498, 25464, 25430, 25397, 25363, + 25329, 25295, 25261, 25226, 25192, + 25158, 25123, 25089, 25054, 25020, + 24985, 24951, 24916, 24881, 24846, + 24811, 24776, 24741, 24706, 24670, + 24635, 24600, 24564, 24529, 24493, + 24457, 24422, 24386, 24350, 24314, + 24278, 24242, 24206, 24170, 24134, + 24097, 24061, 24025, 23988, 23952, + 23915, 23878, 23842, 23805, 23768, + 23731, 23694, 23657, 23620, 23583, + 23545, 23508, 23471, 23433, 23396, + 23358, 23320, 23283, 23245, 23207, + 23169, 23131, 23093, 23055, 23017, + 22979, 22941, 22902, 22864, 22826, + 22787, 22749, 22710, 22671, 22632, + 22594, 22555, 22516, 22477, 22438, + 22399, 22360, 22320, 22281, 22242, + 22202, 22163, 22123, 22084, 22044, + 22004, 21965, 21925, 21885, 21845, + 21805, 21765, 21725, 21685, 21645, + 21604, 21564, 21524, 21483, 21443, + 21402, 21361, 21321, 21280, 21239, + 21198, 21157, 21116, 21075, 21034, + 20993, 20952, 20911, 20869, 20828, + 20787, 20745, 20704, 20662, 20620, + 20579, 20537, 20495, 20453, 20411, + 20369, 20327, 20285, 20243, 20201, + 20159, 20116, 20074, 20032, 19989, + 19947, 19904, 19862, 19819, 19776, + 19733, 19691, 19648, 19605, 19562, + 19519, 19476, 19433, 19389, 19346, + 19303, 19259, 19216, 19173, 19129, + 19086, 19042, 18998, 18955, 18911, + 18867, 18823, 18779, 18735, 18691, + 18647, 18603, 18559, 18515, 18470, + 18426, 18382, 18337, 18293, 18248, + 18204, 18159, 18115, 18070, 18025, + 17980, 17936, 17891, 17846, 17801, + 17756, 17711, 17665, 17620, 17575, + 17530, 17484, 17439, 17394, 17348, + 17303, 17257, 17212, 17166, 17120, + 17074, 17029, 16983, 16937, 16891, + 16845, 16799, 16753, 16707, 16661, + 16615, 16568, 16522, 16476, 16429, + 16383, 16337, 16290, 16244, 16197, + 16150, 16104, 16057, 16010, 15963, + 15917, 15870, 15823, 15776, 15729, + 15682, 15635, 15587, 15540, 15493, + 15446, 15398, 15351, 15304, 15256, + 15209, 15161, 15114, 15066, 15019, + 14971, 14923, 14875, 14828, 14780, + 14732, 14684, 14636, 14588, 14540, + 14492, 14444, 14396, 14348, 14299, + 14251, 14203, 14154, 14106, 14058, + 14009, 13961, 13912, 13864, 13815, + 13766, 13718, 13669, 13620, 13571, + 13523, 13474, 13425, 13376, 13327, + 13278, 13229, 13180, 13131, 13082, + 13033, 12983, 12934, 12885, 12835, + 12786, 12737, 12687, 12638, 12588, + 12539, 12489, 12440, 12390, 12340, + 12291, 12241, 12191, 12142, 12092, + 12042, 11992, 11942, 11892, 11842, + 11792, 11742, 11692, 11642, 11592, + 11542, 11491, 11441, 11391, 11341, + 11290, 11240, 11190, 11139, 11089, + 11038, 10988, 10937, 10887, 10836, + 10786, 10735, 10684, 10634, 10583, + 10532, 10481, 10431, 10380, 10329, + 10278, 10227, 10176, 10125, 10074, + 10023, 9972, 9921, 9870, 9819, + 9767, 9716, 9665, 9614, 9563, + 9511, 9460, 9409, 9357, 9306, + 9254, 9203, 9151, 9100, 9048, + 8997, 8945, 8894, 8842, 8791, + 8739, 8687, 8635, 8584, 8532, + 8480, 8428, 8377, 8325, 8273, + 8221, 8169, 8117, 8065, 8013, + 7961, 7909, 7857, 7805, 7753, + 7701, 7649, 7597, 7544, 7492, + 7440, 7388, 7336, 7283, 7231, + 7179, 7126, 7074, 7022, 6969, + 6917, 6865, 6812, 6760, 6707, + 6655, 6602, 6550, 6497, 6445, + 6392, 6339, 6287, 6234, 6182, + 6129, 6076, 6024, 5971, 5918, + 5865, 5813, 5760, 5707, 5654, + 5601, 5549, 5496, 5443, 5390, + 5337, 5284, 5231, 5178, 5125, + 5072, 5019, 4966, 4913, 4860, + 4807, 4754, 4701, 4648, 4595, + 4542, 4489, 4436, 4383, 4330, + 4276, 4223, 4170, 4117, 4064, + 4011, 3957, 3904, 3851, 3798, + 3744, 3691, 3638, 3585, 3531, + 3478, 3425, 3371, 3318, 3265, + 3211, 3158, 3104, 3051, 2998, + 2944, 2891, 2838, 2784, 2731, + 2677, 2624, 2570, 2517, 2463, + 2410, 2357, 2303, 2250, 2196, + 2143, 2089, 2036, 1982, 1929, + 1875, 1821, 1768, 1714, 1661, + 1607, 1554, 1500, 1447, 1393, + 1339, 1286, 1232, 1179, 1125, + 1072, 1018, 964, 911, 857, + 804, 750, 696, 643, 589, + 536, 482, 428, 375, 321, + 268, 214, 160, 107, 53 + }; + +const Word16 cos_scale_tbl_640[640] = /* Q15 */ + { + 32767, 32766, 32766, 32766, 32765, + 32764, 32763, 32762, 32760, 32759, + 32757, 32755, 32752, 32750, 32747, + 32744, 32741, 32738, 32735, 32731, + 32727, 32723, 32719, 32714, 32710, + 32705, 32700, 32695, 32689, 32684, + 32678, 32672, 32665, 32659, 32652, + 32646, 32639, 32631, 32624, 32617, + 32609, 32601, 32593, 32584, 32576, + 32567, 32558, 32549, 32539, 32530, + 32520, 32510, 32500, 32490, 32479, + 32468, 32457, 32446, 32435, 32424, + 32412, 32400, 32388, 32376, 32363, + 32350, 32338, 32324, 32311, 32298, + 32284, 32270, 32256, 32242, 32228, + 32213, 32198, 32183, 32168, 32152, + 32137, 32121, 32105, 32089, 32073, + 32056, 32039, 32022, 32005, 31988, + 31970, 31953, 31935, 31917, 31898, + 31880, 31861, 31842, 31823, 31804, + 31785, 31765, 31745, 31725, 31705, + 31684, 31664, 31643, 31622, 31601, + 31580, 31558, 31536, 31514, 31492, + 31470, 31447, 31425, 31402, 31379, + 31356, 31332, 31308, 31285, 31261, + 31236, 31212, 31188, 31163, 31138, + 31113, 31087, 31062, 31036, 31010, + 30984, 30958, 30932, 30905, 30878, + 30851, 30824, 30797, 30769, 30741, + 30713, 30685, 30657, 30628, 30600, + 30571, 30542, 30513, 30483, 30454, + 30424, 30394, 30364, 30333, 30303, + 30272, 30241, 30210, 30179, 30148, + 30116, 30084, 30052, 30020, 29988, + 29955, 29923, 29890, 29857, 29824, + 29790, 29757, 29723, 29689, 29655, + 29621, 29586, 29551, 29517, 29482, + 29446, 29411, 29375, 29340, 29304, + 29268, 29232, 29195, 29159, 29122, + 29085, 29048, 29010, 28973, 28935, + 28897, 28859, 28821, 28783, 28744, + 28706, 28667, 28628, 28589, 28549, + 28510, 28470, 28430, 28390, 28350, + 28309, 28269, 28228, 28187, 28146, + 28105, 28063, 28022, 27980, 27938, + 27896, 27854, 27811, 27769, 27726, + 27683, 27640, 27596, 27553, 27509, + 27466, 27422, 27378, 27333, 27289, + 27244, 27200, 27155, 27109, 27064, + 27019, 26973, 26927, 26882, 26836, + 26789, 26743, 26696, 26650, 26603, + 26556, 26509, 26461, 26414, 26366, + 26318, 26270, 26222, 26174, 26125, + 26077, 26028, 25979, 25930, 25881, + 25831, 25782, 25732, 25682, 25632, + 25582, 25532, 25481, 25430, 25380, + 25329, 25278, 25226, 25175, 25123, + 25072, 25020, 24968, 24916, 24863, + 24811, 24758, 24706, 24653, 24600, + 24546, 24493, 24440, 24386, 24332, + 24278, 24224, 24170, 24116, 24061, + 24006, 23952, 23897, 23842, 23786, + 23731, 23675, 23620, 23564, 23508, + 23452, 23396, 23339, 23283, 23226, + 23169, 23112, 23055, 22998, 22941, + 22883, 22826, 22768, 22710, 22652, + 22594, 22535, 22477, 22418, 22360, + 22301, 22242, 22183, 22123, 22064, + 22004, 21945, 21885, 21825, 21765, + 21705, 21645, 21584, 21524, 21463, + 21402, 21341, 21280, 21219, 21157, + 21096, 21034, 20973, 20911, 20849, + 20787, 20724, 20662, 20600, 20537, + 20474, 20411, 20348, 20285, 20222, + 20159, 20095, 20032, 19968, 19904, + 19840, 19776, 19712, 19648, 19583, + 19519, 19454, 19389, 19324, 19259, + 19194, 19129, 19064, 18998, 18933, + 18867, 18801, 18735, 18669, 18603, + 18537, 18470, 18404, 18337, 18271, + 18204, 18137, 18070, 18003, 17936, + 17868, 17801, 17733, 17665, 17598, + 17530, 17462, 17394, 17325, 17257, + 17189, 17120, 17052, 16983, 16914, + 16845, 16776, 16707, 16638, 16568, + 16499, 16429, 16360, 16290, 16220, + 16150, 16080, 16010, 15940, 15870, + 15799, 15729, 15658, 15587, 15517, + 15446, 15375, 15304, 15233, 15161, + 15090, 15019, 14947, 14875, 14804, + 14732, 14660, 14588, 14516, 14444, + 14372, 14299, 14227, 14154, 14082, + 14009, 13936, 13864, 13791, 13718, + 13645, 13571, 13498, 13425, 13352, + 13278, 13204, 13131, 13057, 12983, + 12909, 12835, 12761, 12687, 12613, + 12539, 12465, 12390, 12316, 12241, + 12166, 12092, 12017, 11942, 11867, + 11792, 11717, 11642, 11567, 11491, + 11416, 11341, 11265, 11190, 11114, + 11038, 10963, 10887, 10811, 10735, + 10659, 10583, 10507, 10431, 10354, + 10278, 10202, 10125, 10049, 9972, + 9895, 9819, 9742, 9665, 9588, + 9511, 9434, 9357, 9280, 9203, + 9126, 9048, 8971, 8894, 8816, + 8739, 8661, 8584, 8506, 8428, + 8351, 8273, 8195, 8117, 8039, + 7961, 7883, 7805, 7727, 7649, + 7571, 7492, 7414, 7336, 7257, + 7179, 7100, 7022, 6943, 6865, + 6786, 6707, 6628, 6550, 6471, + 6392, 6313, 6234, 6155, 6076, + 5997, 5918, 5839, 5760, 5681, + 5601, 5522, 5443, 5364, 5284, + 5205, 5125, 5046, 4966, 4887, + 4807, 4728, 4648, 4569, 4489, + 4409, 4330, 4250, 4170, 4090, + 4011, 3931, 3851, 3771, 3691, + 3611, 3531, 3451, 3371, 3291, + 3211, 3131, 3051, 2971, 2891, + 2811, 2731, 2651, 2570, 2490, + 2410, 2330, 2250, 2169, 2089, + 2009, 1929, 1848, 1768, 1688, + 1607, 1527, 1447, 1366, 1286, + 1206, 1125, 1045, 964, 884, + 804, 723, 643, 562, 482, + 402, 321, 241, 160, 80 + }; + +const Word16 sin_scale_tbl_640[640] = /* Q15 */ + { + 0, 80, 160, 241, 321, + 402, 482, 562, 643, 723, + 804, 884, 964, 1045, 1125, + 1206, 1286, 1366, 1447, 1527, + 1607, 1688, 1768, 1848, 1929, + 2009, 2089, 2169, 2250, 2330, + 2410, 2490, 2570, 2651, 2731, + 2811, 2891, 2971, 3051, 3131, + 3211, 3291, 3371, 3451, 3531, + 3611, 3691, 3771, 3851, 3931, + 4011, 4090, 4170, 4250, 4330, + 4409, 4489, 4569, 4648, 4728, + 4807, 4887, 4966, 5046, 5125, + 5205, 5284, 5364, 5443, 5522, + 5601, 5681, 5760, 5839, 5918, + 5997, 6076, 6155, 6234, 6313, + 6392, 6471, 6550, 6628, 6707, + 6786, 6865, 6943, 7022, 7100, + 7179, 7257, 7336, 7414, 7492, + 7571, 7649, 7727, 7805, 7883, + 7961, 8039, 8117, 8195, 8273, + 8351, 8428, 8506, 8584, 8661, + 8739, 8816, 8894, 8971, 9048, + 9126, 9203, 9280, 9357, 9434, + 9511, 9588, 9665, 9742, 9819, + 9895, 9972, 10049, 10125, 10202, + 10278, 10354, 10431, 10507, 10583, + 10659, 10735, 10811, 10887, 10963, + 11038, 11114, 11190, 11265, 11341, + 11416, 11491, 11567, 11642, 11717, + 11792, 11867, 11942, 12017, 12092, + 12166, 12241, 12316, 12390, 12465, + 12539, 12613, 12687, 12761, 12835, + 12909, 12983, 13057, 13131, 13204, + 13278, 13352, 13425, 13498, 13571, + 13645, 13718, 13791, 13864, 13936, + 14009, 14082, 14154, 14227, 14299, + 14372, 14444, 14516, 14588, 14660, + 14732, 14804, 14875, 14947, 15019, + 15090, 15161, 15233, 15304, 15375, + 15446, 15517, 15587, 15658, 15729, + 15799, 15870, 15940, 16010, 16080, + 16150, 16220, 16290, 16360, 16429, + 16499, 16568, 16638, 16707, 16776, + 16845, 16914, 16983, 17052, 17120, + 17189, 17257, 17325, 17394, 17462, + 17530, 17598, 17665, 17733, 17801, + 17868, 17936, 18003, 18070, 18137, + 18204, 18271, 18337, 18404, 18470, + 18537, 18603, 18669, 18735, 18801, + 18867, 18933, 18998, 19064, 19129, + 19194, 19259, 19324, 19389, 19454, + 19519, 19583, 19648, 19712, 19776, + 19840, 19904, 19968, 20032, 20095, + 20159, 20222, 20285, 20348, 20411, + 20474, 20537, 20600, 20662, 20724, + 20787, 20849, 20911, 20973, 21034, + 21096, 21157, 21219, 21280, 21341, + 21402, 21463, 21524, 21584, 21645, + 21705, 21765, 21825, 21885, 21945, + 22004, 22064, 22123, 22183, 22242, + 22301, 22360, 22418, 22477, 22535, + 22594, 22652, 22710, 22768, 22826, + 22883, 22941, 22998, 23055, 23112, + 23169, 23226, 23283, 23339, 23396, + 23452, 23508, 23564, 23620, 23675, + 23731, 23786, 23842, 23897, 23952, + 24006, 24061, 24116, 24170, 24224, + 24278, 24332, 24386, 24440, 24493, + 24546, 24600, 24653, 24706, 24758, + 24811, 24863, 24916, 24968, 25020, + 25072, 25123, 25175, 25226, 25278, + 25329, 25380, 25430, 25481, 25532, + 25582, 25632, 25682, 25732, 25782, + 25831, 25881, 25930, 25979, 26028, + 26077, 26125, 26174, 26222, 26270, + 26318, 26366, 26414, 26461, 26509, + 26556, 26603, 26650, 26696, 26743, + 26789, 26836, 26882, 26927, 26973, + 27019, 27064, 27109, 27155, 27200, + 27244, 27289, 27333, 27378, 27422, + 27466, 27509, 27553, 27596, 27640, + 27683, 27726, 27769, 27811, 27854, + 27896, 27938, 27980, 28022, 28063, + 28105, 28146, 28187, 28228, 28269, + 28309, 28350, 28390, 28430, 28470, + 28510, 28549, 28589, 28628, 28667, + 28706, 28744, 28783, 28821, 28859, + 28897, 28935, 28973, 29010, 29048, + 29085, 29122, 29159, 29195, 29232, + 29268, 29304, 29340, 29375, 29411, + 29446, 29482, 29517, 29551, 29586, + 29621, 29655, 29689, 29723, 29757, + 29790, 29824, 29857, 29890, 29923, + 29955, 29988, 30020, 30052, 30084, + 30116, 30148, 30179, 30210, 30241, + 30272, 30303, 30333, 30364, 30394, + 30424, 30454, 30483, 30513, 30542, + 30571, 30600, 30628, 30657, 30685, + 30713, 30741, 30769, 30797, 30824, + 30851, 30878, 30905, 30932, 30958, + 30984, 31010, 31036, 31062, 31087, + 31113, 31138, 31163, 31188, 31212, + 31236, 31261, 31285, 31308, 31332, + 31356, 31379, 31402, 31425, 31447, + 31470, 31492, 31514, 31536, 31558, + 31580, 31601, 31622, 31643, 31664, + 31684, 31705, 31725, 31745, 31765, + 31785, 31804, 31823, 31842, 31861, + 31880, 31898, 31917, 31935, 31953, + 31970, 31988, 32005, 32022, 32039, + 32056, 32073, 32089, 32105, 32121, + 32137, 32152, 32168, 32183, 32198, + 32213, 32228, 32242, 32256, 32270, + 32284, 32298, 32311, 32324, 32338, + 32350, 32363, 32376, 32388, 32400, + 32412, 32424, 32435, 32446, 32457, + 32468, 32479, 32490, 32500, 32510, + 32520, 32530, 32539, 32549, 32558, + 32567, 32576, 32584, 32593, 32601, + 32609, 32617, 32624, 32631, 32639, + 32646, 32652, 32659, 32665, 32672, + 32678, 32684, 32689, 32695, 32700, + 32705, 32710, 32714, 32719, 32723, + 32727, 32731, 32735, 32738, 32741, + 32744, 32747, 32750, 32752, 32755, + 32757, 32759, 32760, 32762, 32763, + 32764, 32765, 32766, 32766, 32766 + }; + +const Word16 sin_scale_tbl_512[512] = /* Q15 */ + { + 0, 100, 201, 301, 402, + 502, 603, 703, 804, 904, + 1005, 1105, 1206, 1306, 1406, + 1507, 1607, 1708, 1808, 1908, + 2009, 2109, 2209, 2310, 2410, + 2510, 2610, 2711, 2811, 2911, + 3011, 3111, 3211, 3311, 3411, + 3511, 3611, 3711, 3811, 3911, + 4011, 4110, 4210, 4310, 4409, + 4509, 4608, 4708, 4807, 4907, + 5006, 5106, 5205, 5304, 5403, + 5502, 5601, 5700, 5799, 5898, + 5997, 6096, 6195, 6293, 6392, + 6491, 6589, 6688, 6786, 6884, + 6982, 7081, 7179, 7277, 7375, + 7473, 7571, 7668, 7766, 7864, + 7961, 8059, 8156, 8253, 8351, + 8448, 8545, 8642, 8739, 8836, + 8932, 9029, 9126, 9222, 9319, + 9415, 9511, 9607, 9703, 9799, + 9895, 9991, 10087, 10182, 10278, + 10373, 10469, 10564, 10659, 10754, + 10849, 10944, 11038, 11133, 11227, + 11322, 11416, 11510, 11604, 11698, + 11792, 11886, 11980, 12073, 12166, + 12260, 12353, 12446, 12539, 12632, + 12724, 12817, 12909, 13002, 13094, + 13186, 13278, 13370, 13462, 13553, + 13645, 13736, 13827, 13918, 14009, + 14100, 14191, 14281, 14372, 14462, + 14552, 14642, 14732, 14822, 14911, + 15001, 15090, 15179, 15268, 15357, + 15446, 15534, 15623, 15711, 15799, + 15887, 15975, 16063, 16150, 16238, + 16325, 16412, 16499, 16586, 16672, + 16759, 16845, 16931, 17017, 17103, + 17189, 17274, 17360, 17445, 17530, + 17615, 17699, 17784, 17868, 17952, + 18036, 18120, 18204, 18287, 18371, + 18454, 18537, 18620, 18702, 18785, + 18867, 18949, 19031, 19113, 19194, + 19276, 19357, 19438, 19519, 19599, + 19680, 19760, 19840, 19920, 20000, + 20079, 20159, 20238, 20317, 20396, + 20474, 20553, 20631, 20709, 20787, + 20864, 20942, 21019, 21096, 21173, + 21249, 21326, 21402, 21478, 21554, + 21629, 21705, 21780, 21855, 21930, + 22004, 22079, 22153, 22227, 22301, + 22374, 22448, 22521, 22594, 22666, + 22739, 22811, 22883, 22955, 23027, + 23098, 23169, 23240, 23311, 23382, + 23452, 23522, 23592, 23661, 23731, + 23800, 23869, 23938, 24006, 24075, + 24143, 24211, 24278, 24346, 24413, + 24480, 24546, 24613, 24679, 24745, + 24811, 24877, 24942, 25007, 25072, + 25136, 25201, 25265, 25329, 25392, + 25456, 25519, 25582, 25645, 25707, + 25769, 25831, 25893, 25954, 26016, + 26077, 26137, 26198, 26258, 26318, + 26378, 26437, 26497, 26556, 26615, + 26673, 26731, 26789, 26847, 26905, + 26962, 27019, 27076, 27132, 27188, + 27244, 27300, 27355, 27411, 27466, + 27520, 27575, 27629, 27683, 27736, + 27790, 27843, 27896, 27948, 28001, + 28053, 28105, 28156, 28208, 28259, + 28309, 28360, 28410, 28460, 28510, + 28559, 28608, 28657, 28706, 28754, + 28802, 28850, 28897, 28945, 28992, + 29038, 29085, 29131, 29177, 29222, + 29268, 29313, 29358, 29402, 29446, + 29490, 29534, 29577, 29621, 29663, + 29706, 29748, 29790, 29832, 29873, + 29915, 29955, 29996, 30036, 30076, + 30116, 30156, 30195, 30234, 30272, + 30311, 30349, 30386, 30424, 30461, + 30498, 30535, 30571, 30607, 30643, + 30678, 30713, 30748, 30783, 30817, + 30851, 30885, 30918, 30951, 30984, + 31017, 31049, 31081, 31113, 31144, + 31175, 31206, 31236, 31267, 31297, + 31326, 31356, 31385, 31413, 31442, + 31470, 31498, 31525, 31553, 31580, + 31606, 31633, 31659, 31684, 31710, + 31735, 31760, 31785, 31809, 31833, + 31856, 31880, 31903, 31926, 31948, + 31970, 31992, 32014, 32035, 32056, + 32077, 32097, 32117, 32137, 32156, + 32176, 32194, 32213, 32231, 32249, + 32267, 32284, 32301, 32318, 32334, + 32350, 32366, 32382, 32397, 32412, + 32426, 32441, 32455, 32468, 32482, + 32495, 32508, 32520, 32532, 32544, + 32556, 32567, 32578, 32588, 32599, + 32609, 32618, 32628, 32637, 32646, + 32654, 32662, 32670, 32678, 32685, + 32692, 32699, 32705, 32711, 32717, + 32722, 32727, 32732, 32736, 32740, + 32744, 32748, 32751, 32754, 32757, + 32759, 32761, 32763, 32764, 32765, + 32766, 32766 + }; + +const Word16 cos_scale_tbl_512[512] = /* Q15 */ + { + 32767, 32766, 32766, 32765, 32764, + 32763, 32761, 32759, 32757, 32754, + 32751, 32748, 32744, 32740, 32736, + 32732, 32727, 32722, 32717, 32711, + 32705, 32699, 32692, 32685, 32678, + 32670, 32662, 32654, 32646, 32637, + 32628, 32618, 32609, 32599, 32588, + 32578, 32567, 32556, 32544, 32532, + 32520, 32508, 32495, 32482, 32468, + 32455, 32441, 32426, 32412, 32397, + 32382, 32366, 32350, 32334, 32318, + 32301, 32284, 32267, 32249, 32231, + 32213, 32194, 32176, 32156, 32137, + 32117, 32097, 32077, 32056, 32035, + 32014, 31992, 31970, 31948, 31926, + 31903, 31880, 31856, 31833, 31809, + 31785, 31760, 31735, 31710, 31684, + 31659, 31633, 31606, 31580, 31553, + 31525, 31498, 31470, 31442, 31413, + 31385, 31356, 31326, 31297, 31267, + 31236, 31206, 31175, 31144, 31113, + 31081, 31049, 31017, 30984, 30951, + 30918, 30885, 30851, 30817, 30783, + 30748, 30713, 30678, 30643, 30607, + 30571, 30535, 30498, 30461, 30424, + 30386, 30349, 30311, 30272, 30234, + 30195, 30156, 30116, 30076, 30036, + 29996, 29955, 29915, 29873, 29832, + 29790, 29748, 29706, 29663, 29621, + 29577, 29534, 29490, 29446, 29402, + 29358, 29313, 29268, 29222, 29177, + 29131, 29085, 29038, 28992, 28945, + 28897, 28850, 28802, 28754, 28706, + 28657, 28608, 28559, 28510, 28460, + 28410, 28360, 28309, 28259, 28208, + 28156, 28105, 28053, 28001, 27948, + 27896, 27843, 27790, 27736, 27683, + 27629, 27575, 27520, 27466, 27411, + 27355, 27300, 27244, 27188, 27132, + 27076, 27019, 26962, 26905, 26847, + 26789, 26731, 26673, 26615, 26556, + 26497, 26437, 26378, 26318, 26258, + 26198, 26137, 26077, 26016, 25954, + 25893, 25831, 25769, 25707, 25645, + 25582, 25519, 25456, 25392, 25329, + 25265, 25201, 25136, 25072, 25007, + 24942, 24877, 24811, 24745, 24679, + 24613, 24546, 24480, 24413, 24346, + 24278, 24211, 24143, 24075, 24006, + 23938, 23869, 23800, 23731, 23661, + 23592, 23522, 23452, 23382, 23311, + 23240, 23169, 23098, 23027, 22955, + 22883, 22811, 22739, 22666, 22594, + 22521, 22448, 22374, 22301, 22227, + 22153, 22079, 22004, 21930, 21855, + 21780, 21705, 21629, 21554, 21478, + 21402, 21326, 21249, 21173, 21096, + 21019, 20942, 20864, 20787, 20709, + 20631, 20553, 20474, 20396, 20317, + 20238, 20159, 20079, 20000, 19920, + 19840, 19760, 19680, 19599, 19519, + 19438, 19357, 19276, 19194, 19113, + 19031, 18949, 18867, 18785, 18702, + 18620, 18537, 18454, 18371, 18287, + 18204, 18120, 18036, 17952, 17868, + 17784, 17699, 17615, 17530, 17445, + 17360, 17274, 17189, 17103, 17017, + 16931, 16845, 16759, 16672, 16586, + 16499, 16412, 16325, 16238, 16150, + 16063, 15975, 15887, 15799, 15711, + 15623, 15534, 15446, 15357, 15268, + 15179, 15090, 15001, 14911, 14822, + 14732, 14642, 14552, 14462, 14372, + 14281, 14191, 14100, 14009, 13918, + 13827, 13736, 13645, 13553, 13462, + 13370, 13278, 13186, 13094, 13002, + 12909, 12817, 12724, 12632, 12539, + 12446, 12353, 12260, 12166, 12073, + 11980, 11886, 11792, 11698, 11604, + 11510, 11416, 11322, 11227, 11133, + 11038, 10944, 10849, 10754, 10659, + 10564, 10469, 10373, 10278, 10182, + 10087, 9991, 9895, 9799, 9703, + 9607, 9511, 9415, 9319, 9222, + 9126, 9029, 8932, 8836, 8739, + 8642, 8545, 8448, 8351, 8253, + 8156, 8059, 7961, 7864, 7766, + 7668, 7571, 7473, 7375, 7277, + 7179, 7081, 6982, 6884, 6786, + 6688, 6589, 6491, 6392, 6293, + 6195, 6096, 5997, 5898, 5799, + 5700, 5601, 5502, 5403, 5304, + 5205, 5106, 5006, 4907, 4807, + 4708, 4608, 4509, 4409, 4310, + 4210, 4110, 4011, 3911, 3811, + 3711, 3611, 3511, 3411, 3311, + 3211, 3111, 3011, 2911, 2811, + 2711, 2610, 2510, 2410, 2310, + 2209, 2109, 2009, 1908, 1808, + 1708, 1607, 1507, 1406, 1306, + 1206, 1105, 1005, 904, 804, + 703, 603, 502, 402, 301, + 201, 100 + }; +#endif // IVAS_FLOAT_FIXED diff --git a/lib_com/rom_com.h b/lib_com/rom_com.h index ea47e0b23ffd3b4501ec24c331fbdc804f405bc3..b7e90a5065a92b97de009eb9202c2bbff87ffec2 100644 --- a/lib_com/rom_com.h +++ b/lib_com/rom_com.h @@ -2116,4 +2116,12 @@ extern const Word32 tbl_two_pow_shift_by_4[35]; /* Q30 */ extern const Word16 ivas_tan_panning_gain_tbl_fx[601]; extern const Word16 ivas_sine_panning_tbl_fx[601]; extern const Word16 ivas_sin_az_fx[361]; + +//edct_fx.c +extern const Word16 sin_scale_tbl_960[960]; +extern const Word16 cos_scale_tbl_960[960]; +extern const Word16 cos_scale_tbl_640[640]; +extern const Word16 sin_scale_tbl_640[640]; +extern const Word16 sin_scale_tbl_512[512]; +extern const Word16 cos_scale_tbl_512[512]; #endif diff --git a/lib_com/tcx_mdct_fx.c b/lib_com/tcx_mdct_fx.c index 9a04ae0633fdf8cd4a91224c4db2ef5215176de9..b4790375633e132a60c46abc286090d6001f3535 100644 --- a/lib_com/tcx_mdct_fx.c +++ b/lib_com/tcx_mdct_fx.c @@ -270,4 +270,118 @@ void TCX_MDCT_Inverse( } +#ifdef IVAS_FLOAT_FIXED +void TCX_MDST_Inverse_fx( + Word32 *x, + Word16 x_e, + Word16 *y, + const Word16 l, + const Word16 m, + const Word16 r) +{ + + Word16 i, fac, negfac, s; + Word16 L2 = l, R2 = r; + Word32 tmp_buf[N_MAX + L_MDCT_OVLP_MAX / 2]; + Word16 fac_e; + + L2 = shr( l, 1 ); + R2 = shr( r, 1 ); + + x_e = sub( 15, x_e ); + edst_fx( x, tmp_buf + L2, l / 2 + m + r / 2, &x_e); + x_e = sub( 15, x_e ); + + fac = TCX_MDCT_Inverse_GetScaleFactor( add( add( shr( l, 1 ), m ), shr( r, 1 ) ), &fac_e ); + x_e = add( x_e, fac_e ); + + negfac = negate( fac ); + + s = x_e; + move16(); + + FOR( i = 0; i < R2; i++ ) + { + y[l + m + R2 + i] = round_fx( L_shl( Mpy_32_16_1( tmp_buf[L2 + i], fac ), s ) ); /* fold out right end of DCT */ + } + + FOR( i = 0; i < L2; i++ ) + { + y[i] = round_fx( L_shl( Mpy_32_16_1( tmp_buf[L2 + m + R2 + i], negfac ), s ) ); /* negate, fold out left end of DCT */ + } + + FOR( i = 0; i < shr( add( L2, add( m, R2 ) ), 1 ); i++ ) + { + Word16 f; + f = round_fx( L_shl( Mpy_32_16_1( tmp_buf[L2 + i], fac ), s ) ); + + y[L2 + i] = round_fx( L_shl( Mpy_32_16_1( tmp_buf[l + m + R2 - 1 - i], negfac ), s ) ); /* time-reverse mid of DCT */ + + move16(); + y[l + m + R2 - 1 - i] = negate(f); + } +} + +/*-------------------------------------------------------------------* + * TCX_MDXT_Inverse_fx() + * + * + *-------------------------------------------------------------------*/ + +void TCX_MDXT_Inverse_fx( + const Word32 *x, + Word16 x_e, + Word16 *y, + const Word16 l, + const Word16 m, + const Word16 r, + const UWord16 kernel_type ) +{ + Word16 signLeft; + Word16 signRight; + Word16 i, fac, negfac, s, fac_e; + const Word16 L2 = shr( l, 1 ), R2 = shr( r, 1 ); + Word32 tmp_buf[N_MAX + L_MDCT_OVLP_MAX / 2]; + Word16 f; + + set32_fx( tmp_buf, 0, N_MAX + L_MDCT_OVLP_MAX / 2 ); + + edxt_fx( x, tmp_buf + L2, L2 + m + R2, kernel_type, TRUE ); + + fac = TCX_MDCT_Inverse_GetScaleFactor( add( add( shr( l, 1 ), m ), shr( r, 1 ) ), &fac_e ); + x_e = add( x_e, fac_e ); + + negfac = negate( fac ); + signLeft = ( kernel_type >= MDCT_II ? negfac : fac ); + signRight = ( kernel_type & 1 ? fac : negfac ); + + s = x_e; + move16(); + + FOR( i = 0; i < L2; i++ ) + { + y[i] = round_fx( L_shl( Mpy_32_16_1( tmp_buf[L2 + m + R2 + i], signLeft ), s ) ); /* fold out the left end */ + } + + FOR( i = 0; i < R2; i++ ) + { + y[l + m + R2 + i] = round_fx( L_shl( Mpy_32_16_1( tmp_buf[L2 + i], signRight ), s ) ); /* ...and right end */ + } + + FOR( i = 0; i < ( ( L2 + m + R2 ) >> 1 ); i++ ) + { + + f = round_fx( L_shl( Mpy_32_16_1( tmp_buf[L2 + i], negfac ), s ) ); + + y[L2 + i] = round_fx( L_shl( Mpy_32_16_1( tmp_buf[l + m + R2 - 1 - i], negfac ), s ) ); /* time-reverse mid of DCT */ + + move16(); + y[l + m + R2 - 1 - i] = f; + } + + return; +} + +#endif // IVAS_FLOAT_FIXED + diff --git a/lib_dec/dec_tcx.c b/lib_dec/dec_tcx.c index 72c70909995609e12bbe554aab07c27eac853a6e..096515ab5aefcff4b400884526c6ca37101f801f 100644 --- a/lib_dec/dec_tcx.c +++ b/lib_dec/dec_tcx.c @@ -44,6 +44,8 @@ #include "cnst.h" #include "wmc_auto.h" #include "ivas_rom_com.h" +#include "prot_fx1.h" +#include "prot_fx2.h" #ifndef IVAS_FLOAT_FIXED_UNIT_TESTING #include "debug.h" #endif // !IVAS_FLOAT_FIXED_UNIT_TESTING @@ -353,11 +355,48 @@ void IMDCT_flt( { if ( kernel_type == MDST_IV || ( kernel_type & w ) ) { +#ifdef IVAS_FLOAT_FIXED + Word32 x_fx[L_MDCT_OVLP_MAX + L_FRAME_PLUS + L_MDCT_OVLP_MAX]; + Word16 win_fx[810] = { 0 }; + Word16 q_x = Q16, q_win, x_e_hdrm; + x_e_hdrm = sub(q_x, 13); + q_win = q_x + x_e_hdrm - 16; + for ( int k = 0; k < L_ola + L_win; k++ ) + { + x_fx[w * L_spec_TCX5 + k] = (Word32) ( x[w * L_spec_TCX5 + k] * ( 1u << q_x ) ); + } + + TCX_MDST_Inverse_fx( x_fx + w * L_spec_TCX5, x_e_hdrm, win_fx, L_ola, L_win - L_ola, L_ola); + + for ( int k = 0; k < L_ola + L_win; k++ ) + { + win[k] = (float) win_fx[k] / ( 1u << (q_win) ); + } +#else TCX_MDST_Inverse_flt( x + w * L_spec_TCX5, win, L_ola, L_win - L_ola, L_ola, st->element_mode ); +#endif // IVAS_FLOAT_FIXED } else if ( kernel_type != 0 && w == 0 ) /* type 1 or 2 */ { +#ifdef IVAS_FLOAT_FIXED + Word32 x_fx[L_MDCT_OVLP_MAX + L_FRAME_PLUS + L_MDCT_OVLP_MAX]; + Word16 win_fx[810] = { 0 }; + Word16 q_x = Q13, q_win, x_e_hdrm; + x_e_hdrm = sub( q_x, 10 ); + q_win = q_x + x_e_hdrm - 16; + for ( int k = 0; k < L_ola + L_win; k++ ) + { + x_fx[w * L_spec_TCX5 + k] = (Word32) ( x[w * L_spec_TCX5 + k] * ( 1u << q_x ) ); + } + TCX_MDXT_Inverse_fx( x_fx + w * L_spec_TCX5, x_e_hdrm, win_fx, L_ola, L_win - L_ola, L_ola, kernel_type ); + + for ( int k = 0; k < L_ola + L_win; k++ ) + { + win[k] = (float) win_fx[k] / ( 1u << ( q_win ) ); + } +#else TCX_MDXT_Inverse_flt( x + w * L_spec_TCX5, win, L_ola, L_win - L_ola, L_ola, kernel_type ); +#endif // IVAS_FLOAT_FIXED } else {