diff --git a/lib_com/cnst.h b/lib_com/cnst.h index 261ef6f907f1777ec47a9c01f3ff7661b5999b80..bcd162acd65152dcbe3a226aa7abbd79af7ef1be 100644 --- a/lib_com/cnst.h +++ b/lib_com/cnst.h @@ -1397,12 +1397,26 @@ enum #define FDCNG_VQ_DCT_NPOST 8 +#ifdef ERI_SNSVQ_ROMOPT +#define SNS_VQ_MAX_LEN M +#define SNS_VQ_DCT_NSEGM 4 +#define SNS_VQ_DCT_MINTRUNC 8 +#define SNS_VQ_DCT_MAXTRUNC M +#endif + + + + typedef enum _DCTTYPE { DCT_T2_24_XX = 0, /* truncated DCT_T2_24 */ IDCT_T2_XX_24 = 1, DCT_T2_21_XX = 2, /* truncated DCT_T2_21 */ IDCT_T2_XX_21 = 3 + #ifdef ERI_SNSVQ_ROMOPT + , DCT_T2_16_XX = 4, /* truncated DCT_T2_16 */ + IDCT_T2_XX_16 = 5 + #endif } DCTTYPE; diff --git a/lib_com/ivas_rom_com.c b/lib_com/ivas_rom_com.c index d9fc25c089d2b099b02d38565858ea7368a9ae0f..10d694033d93f018709e3113af516e5cfd3cb14b 100644 --- a/lib_com/ivas_rom_com.c +++ b/lib_com/ivas_rom_com.c @@ -5598,6 +5598,7 @@ const int16_t ivas_sns_cdbks_tcx20_bits[SNS_MSVQ_NSTAGES_TCX20] = { 7, 6, 5, 5 } #ifdef FIX_445_SNS_BUGFIXES /* pre-rounded codebook vectors for singed Q4.12 represantation */ +#ifndef ERI_SNSVQ_ROMOPT const float ivas_sns_cdbk_tcx20_stage1[ 128 * 16 ] = { -1.8305664f, -2.0878906f, -0.9638672f, 2.8059082f, 2.668213f, 1.1638184f, 1.390625f, 1.217041f, 1.3850098f, 0.44555664f, -0.47045898f, -0.5307617f, -0.810791f, -1.1647949f, -1.4560547f, -1.7612305f, -2.5979004f, -3.3308105f, -1.8554688f, -0.3605957f, 1.6828613f, 2.5871582f, 0.98168945f, 0.22436523f, -0.13110352f, 0.16699219f, 1.5004883f, 0.3293457f, 0.33569336f, 1.1591797f, 0.1796875f, -0.8718262f, @@ -5728,6 +5729,7 @@ const float ivas_sns_cdbk_tcx20_stage1[ 128 * 16 ] = { 1.7553711f, 2.8996582f, 1.9260254f, 0.40551758f, -0.0234375f, 0.44506836f, 0.31152344f, 0.1809082f, -0.47607422f, -0.4807129f, -1.204834f, -1.3293457f, -1.2412109f, -1.0134277f, -0.89501953f, -1.2602539f, 0.2253418f, 2.2539062f, 2.265625f, 0.57128906f, -0.7661133f, -0.6245117f, 0.21313477f, 1.2248535f, 0.8737793f, -0.12524414f, -0.9609375f, -2.416504f, -1.1223145f, -0.70532227f, -0.31469727f, -0.592041f, }; +#endif const float ivas_sns_cdbk_tcx20_stage2[ 64 * 16 ] = { -1.1569824f, -0.4765625f, 0.008056641f, 0.47802734f, 0.38330078f, -0.075683594f, -0.3737793f, -0.29516602f, -0.1352539f, 0.012939453f, 0.22241211f, 0.375f, 0.31689453f, 0.20874023f, 0.2541504f, 0.25439453f, -0.40600586f, -0.22070312f, -0.04272461f, 0.15893555f, -0.25195312f, -0.6623535f, -0.27172852f, 0.28735352f, 0.35742188f, 0.20166016f, 0.052246094f, -0.3647461f, -0.4506836f, 0.1862793f, 0.66796875f, 0.7585449f, @@ -5863,11 +5865,16 @@ const float ivas_sns_cdbk_tcx20_stage4[ 32 * 16 ] = { -0.0017089844f, -0.014160156f, -0.048339844f, -0.037109375f, -0.0949707f, -0.005859375f, 0.48388672f, -0.17480469f, -0.19140625f, 0.5727539f, -0.18920898f, -0.26391602f, 0.0048828125f, 0.067871094f, -0.045654297f, -0.06201172f, }; +#ifdef ERI_SNSVQ_ROMOPT + const float *const ivas_sns_cdbks_tcx20[SNS_MSVQ_NSTAGES_TCX20] = { NULL, ivas_sns_cdbk_tcx20_stage2, ivas_sns_cdbk_tcx20_stage3, ivas_sns_cdbk_tcx20_stage4 }; +#else const float *const ivas_sns_cdbks_tcx20[SNS_MSVQ_NSTAGES_TCX20] = { ivas_sns_cdbk_tcx20_stage1, ivas_sns_cdbk_tcx20_stage2, ivas_sns_cdbk_tcx20_stage3, ivas_sns_cdbk_tcx20_stage4 }; +#endif const int16_t ivas_sns_cdbks_tcx10_levels[SNS_MSVQ_NSTAGES_TCX10] = { 128, 32, 8 }; const int16_t ivas_sns_cdbks_tcx10_bits[SNS_MSVQ_NSTAGES_TCX10] = { 7, 5, 3 }; +#ifndef ERI_SNSVQ_ROMOPT const float ivas_sns_cdbk_tcx10_stage1[ 128 * 16 ] = { 1.0144043f, 1.1826172f, 0.3269043f, -0.6411133f, -1.2163086f, -1.1411133f, -1.1525879f, -0.8898926f, -0.19604492f, 0.7402344f, 1.1782227f, 1.0830078f, 0.78222656f, 0.26953125f, -0.33203125f, -1.0080566f, -0.38916016f, -0.31347656f, -1.1826172f, -2.036621f, -2.086914f, -1.8569336f, -1.637207f, -1.3156738f, -0.4182129f, 0.50634766f, 1.2770996f, 1.3771973f, 1.8566895f, 2.3503418f, 2.3015137f, 1.5678711f, @@ -5998,6 +6005,8 @@ const float ivas_sns_cdbk_tcx10_stage1[ 128 * 16 ] = { 3.256836f, 3.5593262f, 2.2746582f, 1.1318359f, 0.3149414f, -0.02368164f, 0.27172852f, -0.19335938f, -0.48779297f, -0.9663086f, -0.9187012f, -1.0222168f, -1.512207f, -1.6816406f, -1.8964844f, -2.1069336f, -0.057617188f, -0.45092773f, -0.9638672f, -0.72143555f, 0.20703125f, 1.4692383f, 1.921875f, 1.6833496f, 1.3933105f, 0.6699219f, 0.17333984f, -0.43798828f, -0.9772949f, -1.1477051f, -1.3552246f, -1.4057617f, }; +#endif + const float ivas_sns_cdbk_tcx10_stage2[ 32 * 16 ] = { 0.30615234f, 0.48828125f, -0.02709961f, -0.47680664f, -0.5300293f, -0.25463867f, -0.13305664f, -0.14941406f, -0.14819336f, 0.08666992f, 0.28833008f, 0.27514648f, 0.099365234f, -0.017578125f, 0.033203125f, 0.15893555f, 0.40942383f, -0.044189453f, -0.088378906f, 0.38720703f, 0.5151367f, 0.42236328f, 0.34960938f, 0.2680664f, 0.037597656f, -0.19970703f, -0.31054688f, -0.32617188f, -0.38452148f, -0.38085938f, -0.38598633f, -0.2692871f, @@ -6042,8 +6051,447 @@ const float ivas_sns_cdbk_tcx10_stage3[ 8 * 16 ] = { -0.0871582f, 0.022949219f, 0.00048828125f, 0.07397461f, 0.14379883f, 0.067871094f, 0.0036621094f, 0.1171875f, 0.087402344f, 0.0012207031f, -0.075927734f, -0.11352539f, -0.31420898f, -0.38916016f, -0.022949219f, 0.484375f, -0.1821289f, 0.060058594f, 0.24780273f, 0.41674805f, 0.2890625f, -0.1472168f, -0.20581055f, -0.083984375f, -0.060302734f, -0.19921875f, -0.17651367f, -0.08984375f, 0.011230469f, 0.13110352f, 0.080078125f, -0.09106445f, }; - + +#ifdef ERI_SNSVQ_ROMOPT +const float *const ivas_sns_cdbks_tcx10[SNS_MSVQ_NSTAGES_TCX10] = { NULL, ivas_sns_cdbk_tcx10_stage2, ivas_sns_cdbk_tcx10_stage3}; +#else const float *const ivas_sns_cdbks_tcx10[SNS_MSVQ_NSTAGES_TCX10] = { ivas_sns_cdbk_tcx10_stage1, ivas_sns_cdbk_tcx10_stage2, ivas_sns_cdbk_tcx10_stage3}; +#endif + +#ifdef ERI_SNSVQ_ROMOPT + /* DCT16 domain segmentwise structured SNS-VQ stage1 tables indexed as tcx20 "0" and tcx10 as "1" */ +const float snsSt1_tr_midQ_truncQ_tcx20[M] = /* Q15 */ { + +3.262023925781250e-01f, -5.435180664062500e-02f, -4.064941406250000e-02f, -2.441711425781250e-01f, +4.474487304687500e-01f, +9.436035156250000e-02f, +6.979980468750000e-01f, -3.786010742187500e-01f, +-3.912353515625000e-01f, -2.748107910156250e-01f, +3.875732421875000e-02f, -3.883972167968750e-01f, -2.582702636718750e-01f, +4.605102539062500e-02f, +1.916809082031250e-01f, +1.879577636718750e-01f +}; + +const float snsSt1_tr_midQ_truncQ_tcx10[M]={ /* Q15 */ + +7.582702636718750e-01f, +3.669738769531250e-01f, -3.175659179687500e-01f, -2.415466308593750e-01f, +3.718566894531250e-01f, +7.417602539062500e-01f, +1.756286621093750e-01f, -4.205932617187500e-01f, +-1.325988769531250e-01f, +6.930541992187500e-02f, -8.331298828125000e-03f, -7.064819335937500e-02f, -1.096801757812500e-01f, -1.058044433593750e-01f, -5.151062011718750e-01f, -5.618591308593750e-01f + +}; +const float *const snsSt1_tr_midQ_truncQ[2]= {snsSt1_tr_midQ_truncQ_tcx20, snsSt1_tr_midQ_truncQ_tcx10}; + +const float snsSt1_dct_invScaleF_tcx20[2] = { +1.521533203125000e+01f, +2.434453125000000e+02f }; /* Q11 invScale 31161*/ +const float snsSt1_dct_invScaleF_tcx10[2] = { +1.467431640625000e+01f, +2.347890625000000e+02f }; /* Q11 invScale 30053*/ +const float *const snsSt1_dct_invScaleF[2]= { snsSt1_dct_invScaleF_tcx20, snsSt1_dct_invScaleF_tcx10}; + + +/* const float fdcng_dct_scaleF[3] = { scaleF , (scaleF / 16.0f) , (scaleF*scaleF) / (16.0f*16.0f) } ; */ +const float snsSt1_dct_scaleF_tcx20[3] = { +6.572341918945312e-02f, +4.107713699340820e-03f, +1.687331183575225e-05f }; /* Q18 for dctFscale 17229 */ +const float snsSt1_dct_scaleF_tcx10[3] = { +6.814575195312500e-02f, +4.259109497070312e-03f, +1.814001370803453e-05f }; /* Q18 for dctFscale 17864 */ +const float *const snsSt1_dct_scaleF[2] = { snsSt1_dct_scaleF_tcx20, snsSt1_dct_scaleF_tcx10}; + +const int16_t snsSt1_dct_n_segm[2] = { 4, 4 }; + + +const int16_t snsSt1_dct_cols_per_segment_tcx20[4]= { 10, 12, 14, 16}; +const int16_t snsSt1_dct_cols_per_segment_tcx10[4]= { 8 , 10 , 12 , 16 }; +const int16_t *const snsSt1_dct_cols_per_segment[2]= { snsSt1_dct_cols_per_segment_tcx20, snsSt1_dct_cols_per_segment_tcx10}; + +const int16_t snsSt1_trunc_dct_cols_per_segment_tcx20[4]= { 6, 4, 2, 0}; +const int16_t snsSt1_trunc_dct_cols_per_segment_tcx10[4]= { 8, 6, 4, 0}; +const int16_t *const snsSt1_trunc_dct_cols_per_segment[2]= { snsSt1_trunc_dct_cols_per_segment_tcx20, snsSt1_trunc_dct_cols_per_segment_tcx10}; + +const int16_t snsSt1_cum_entries_per_segment_tcx20[5]={ 0, 10, 28, 41, 128 }; +const int16_t snsSt1_cum_entries_per_segment_tcx10[5]={ 0, 13, 47, 88, 128 }; +const int16_t *const snsSt1_cum_entries_per_segment[2]={ snsSt1_cum_entries_per_segment_tcx20 ,snsSt1_cum_entries_per_segment_tcx10}; + +const int16_t snsSt1_entries_per_segment_tcx20[4]={ 10, 18, 13, 87 }; +const int16_t snsSt1_entries_per_segment_tcx10[4]={ 13, 34, 41, 40 }; +const int16_t *const snsSt1_entries_per_segment[2]={ snsSt1_entries_per_segment_tcx20 ,snsSt1_entries_per_segment_tcx10}; + + + +const Word8 /*seg 0, 14 x 12 */ sns_tcx20_dct_s0_W8Qx[100]={ + 0, -38, 46, -66, 75, -44, 110, 9, 96, -21, + 0, -14, -66, -19, -33, -59, -69, -13, 31, 17, + 0, -1, -57, 64, 16, 49, 2, -1, 36, -37, + 0, 22, 37, 98, 47, 43, -9, 37, 27, -34, + 0, 34, -53, -18, -45, -111, -113, -39, 0, -98, + 0, 55, -75, -48, -54, -105, -72, -34, 16, -47, + 0, 92, -10, 1, -12, -45, -50, 31, 38, 1, + 0, 92, 18, 28, 13, 34, 17, 105, 50, -23, + 0, 94, -54, -49, -35, -90, -80, -88, -13, -124, + 0, 98, 17, 57, 37, -6, -44, 10, 13, -70 +}; +const Word8 /*seg 1, 16 x 14 */ sns_tcx20_dct_s1_W8Qx[216]={ + 0, -47, 9, 78, -9, 6, -45, -11, 3, -35, -20, 38, + 0, -43, 127, 54, 18, 25, -34, 13, 22, -10, -20, 25, + 0, -27, -74, -15, -55, -19, -127, 36, 92, 45, -63, -15, + 0, -22, -21, 23, -48, -51, -38, 43, 52, 25, -27, 21, + 0, 46, -90, 79, 22, 17, -7, -1, 29, -21, -53, 34, + 0, 59, 51, 100, 59, 24, 12, 52, 50, 10, 8, 39, + 0, 60, 20, 65, 4, -5, -48, -2, 6, -41, -35, 13, + 0, 61, 66, 27, -23, -21, -68, -23, -4, -75, -68, 2, + 0, 63, -10, 53, 69, 18, -101, -55, -22, -116, -52, 15, + 0, 68, -29, 38, 30, 8, -24, 16, 26, -1, -9, 35, + 0, 77, 55, 34, 70, 87, 46, -99, -9, 40, 38, 69, + 0, 78, 25, 0, -9, -90, -111, -31, -9, -36, -95, -23, + 0, 79, 98, 67, 23, 0, -33, 4, 14, -19, -21, 18, + 0, 84, 0, 43, 10, -16, -57, -18, -6, -72, -47, -1, + 0, 100, -48, 21, -8, -39, -78, -48, -11, -64, -45, 2, + 0, 107, -21, 44, 27, -4, -29, 7, 16, -18, -23, 9, + 0, 108, -24, -27, -30, -45, -107, -56, -20, -91, -71, -10, + 0, 127, -14, -14, -5, -24, -58, -7, 8, -57, -49, 9 +}; +const Word8 /*seg 2, 98 x 16 */ sns_tcx20_dct_s2_W8Qx[182]={ + 0, -83, 37, 69, -16, 9, -17, -22, -11, -52, -33, 21, 0, 6, + 0, -69, -8, 62, 12, 24, -2, 10, 59, -33, 11, 48, 29, 32, + 0, -67, -50, 16, 0, -8, -35, -12, 2, -56, -25, 45, 9, 19, + 0, -42, 23, 104, 46, 29, 3, 25, 31, -11, -4, 32, 18, 10, + 0, -39, -59, -57, -79, 16, 23, 77, -21, 43, -19, 12, 70, 20, + 0, -36, -93, 51, 88, 7, -31, -4, -25, 69, 72, 11, -71, 50, + 0, -12, -58, -63, -95, 43, 92, -31, 35, -5, 64, 25, -55, -86, + 0, -6, 0, 90, 52, 31, -7, 48, 48, 11, 13, 33, 29, 18, + 0, 1, -49, -49, -16, 24, 47, 102, 80, 4, -24, 20, 56, 32, + 0, 19, 62, 54, 15, -6, -21, -11, 10, -31, -20, 2, 7, -3, + 0, 25, -70, -61, -56, -40, -30, 66, 117, 78, 14, 27, -30, -66, + 0, 66, -2, 7, -2, -8, -42, -49, -27, -106, -24, 34, 15, 20, + 0, 78, 22, 39, 31, 90, 51, 24, -99, -38, -9, 86, 49, 13 +}; + +const Word8 /*seg 3, 87 x 16 */ sns_tcx20_dct_s3_W8Qx[1392]={ + 0, -127, 7, 58, -17, 0, -17, -10, -3, -10, -26, 47, 5, 16, -18, -42, + 0, -97, 1, 3, -15, -9, -32, -16, -6, -23, -20, 41, 6, 26, -22, -44, + 0, -90, -46, 84, 16, -10, -33, -2, 16, -39, -24, 42, 6, 9, -24, -46, + 0, -87, -11, 79, -16, -20, -12, -4, -29, -21, -21, 25, 6, 23, -26, -48, + 0, -74, 58, -34, 19, 47, -20, 89, 58, -4, 46, -57, 71, -42, 31, -36, + 0, -59, 35, 1, -7, -12, -38, -22, -13, -35, -33, 15, -3, 15, -27, -44, + 0, -56, -17, -5, -1, -24, -27, -6, -16, -24, -28, 38, 7, 31, -23, -47, + 0, -48, -20, 91, 24, -28, -35, -5, -4, -41, -32, 20, 2, 3, -25, -42, + 0, -43, -20, -11, -54, -25, -74, 49, 68, 2, 75, 121, -37, 32, 89, -14, + 0, -38, 8, 36, 15, 6, -11, 6, 25, -12, -8, 30, 10, 12, -18, -38, + 0, -32, -36, 5, -16, 3, -10, 28, 5, -8, -7, 29, 4, -1, -20, -36, + 0, -27, -31, 52, 22, -24, -43, -35, -17, -28, -35, 10, 2, 8, -26, -46, + 0, -26, 32, 71, -31, 5, -31, -33, -17, -33, -35, 6, -3, -1, -23, -41, + 0, -22, 93, 9, 95, 35, 45, -3, 93, -41, 37, 29, 2, 61, -52, -18, + 0, -21, 0, 8, -15, -27, -41, -33, -15, -35, -30, 5, -3, 2, -26, -43, + 0, -14, -56, 15, -26, -49, -5, -62, 8, -5, -4, 5, 46, 25, -75, -95, + 0, -12, 40, 59, 34, 20, 5, 34, 48, 0, 8, 36, 16, 16, -14, -37, + 0, -12, -33, -27, -18, -37, -38, -17, -32, -9, -13, -20, -9, 27, -16, -43, + 0, -11, 1, 88, 8, -9, -20, 1, 1, -17, -10, 21, 7, 15, -18, -37, + 0, -9, -13, 19, -3, -7, -16, 7, 21, -8, -12, 30, 5, 6, -20, -38, + 0, -9, 22, 42, 22, 4, -6, 16, 35, -3, -2, 36, 14, 17, -17, -39, + 0, -4, 4, 87, 56, -5, -46, -43, -29, -39, -50, -20, -8, -5, -26, -45, + 0, -3, 17, 30, 8, -7, -15, 0, 20, -12, -10, 25, 8, 10, -18, -39, + 0, 2, -55, 6, 74, 44, -25, -59, 63, 83, -14, -100, 15, 111, -7, -64, + 0, 6, -10, 61, 35, -10, -17, 16, 31, 5, -1, 26, 11, 8, -18, -38, + 0, 11, -1, -4, -30, -44, -42, -9, 2, -28, -37, -19, -13, 6, -20, -43, + 0, 13, -6, 46, 19, -40, -54, -84, -65, 4, -62, -3, -7, -54, -27, -40, + 0, 14, 30, 53, 22, 3, -12, 9, 27, -10, -8, 26, 11, 13, -17, -39, + 0, 14, -34, 12, -27, -32, -27, -36, 2, -30, -20, -13, 0, -2, -27, -40, + 0, 15, 31, 25, -26, -25, -40, -27, -16, -43, -38, -12, -5, -1, -22, -42, + 0, 15, -16, -21, -19, -6, -48, -54, -52, -52, -17, 19, 0, 23, -32, -43, + 0, 16, -8, 49, -2, -7, -26, 0, 5, -22, -16, 19, 2, 6, -18, -38, + 0, 16, 4, 26, 0, -8, -18, 2, 20, -13, -11, 23, 6, 3, -21, -40, + 0, 16, -37, -26, -27, -16, -27, -13, 5, -16, -19, 9, 2, 3, -23, -38, + 0, 17, -27, 29, 1, -2, -23, -6, 11, -14, -14, 25, 3, 8, -19, -35, + 0, 18, 24, 90, -18, 4, -27, -19, -14, -31, -32, 3, -1, 5, -21, -42, + 0, 22, 6, 48, 28, 37, 16, 37, 29, -12, 13, 48, 26, 23, -9, -34, + 0, 24, 12, 38, 18, 12, -29, -65, -59, -51, -53, 1, 6, 13, -32, -55, + 0, 30, -19, 11, -27, -21, -48, -38, -17, -44, -28, -25, 2, -111, -89, -95, + 0, 31, -20, 33, 12, -2, -19, 26, 24, -11, -6, 25, 6, 6, -18, -37, + 0, 33, -18, 80, 73, -10, -67, -40, -42, -48, -40, -28, -34, 17, -23, -49, + 0, 33, 18, 70, 32, -15, -56, -62, -24, -37, -32, -8, 2, 12, -20, -39, + 0, 34, -8, 17, -7, -11, -26, -1, 2, -29, -17, 12, 1, -1, -20, -38, + 0, 35, 8, 75, 28, 1, -13, 31, 35, 11, 7, 49, 17, 14, -12, -36, + 0, 35, 27, 27, 5, -6, -15, 9, 28, 3, 0, 34, 12, 10, -16, -38, + 0, 35, -12, -3, -28, -84, -30, -54, -43, 6, -75, 52, -10, -79, -39, -59, + 0, 37, -8, 59, 61, -21, -23, 21, 18, 11, 4, 13, 5, 6, -17, -37, + 0, 37, -3, 42, 3, -6, -17, 21, 19, -17, -5, 29, 6, 8, -16, -36, + 0, 38, 11, 35, -5, -16, -25, 1, 1, -33, -13, 15, 1, 4, -18, -35, + 0, 40, -21, 18, -36, -34, -42, -28, -14, -33, -24, 5, 4, 1, -25, -40, + 0, 40, -50, -104, -67, 23, 68, 51, 39, 91, 31, -121, -59, -82, 44, 95, + 0, 42, -42, 13, -12, -10, -23, 9, 20, -8, -12, 18, 0, -3, -23, -39, + 0, 42, 3, 14, 59, -39, -92, -50, -40, -36, -19, -42, 11, 31, -50, -20, + 0, 46, 3, 50, -20, -35, -46, -38, -25, -53, -56, -40, -20, -21, -31, -42, + 0, 46, 42, 68, 18, -5, -22, -17, -2, -22, -16, 8, 2, 6, -21, -41, + 0, 48, -12, 42, 16, -7, -52, -42, -43, -66, -27, 5, -11, 49, -26, -57, + 0, 50, 39, 32, -23, -69, -70, -28, 5, -13, -32, 1, -10, -4, -30, -42, + 0, 53, -12, 16, -3, -12, -26, 2, 18, -11, -7, 27, 4, 0, -19, -38, + 0, 54, 11, -13, -56, -29, -34, -35, 6, -17, -48, 2, 11, 21, -21, -58, + 0, 54, 21, -32, 12, -36, -60, -22, -56, -53, -26, -22, 5, 4, -48, -42, + 0, 56, 10, 30, 5, 3, -4, 21, 26, -4, -3, 28, 9, 10, -19, -39, + 0, 59, -37, -6, -18, -31, -55, -30, -27, -41, -26, 0, -4, -7, -28, -42, + 0, 61, -32, -3, 34, -24, -66, 5, -53, -91, -12, 53, -18, 70, -13, -88, + 0, 62, -36, 13, 48, -73, -39, -61, -117, -27, -40, 24, -8, 9, -40, -41, + 0, 63, 15, 30, 27, 0, -35, -37, -39, -46, -31, -3, -7, 17, -22, -51, + 0, 64, -5, 9, -31, -52, -39, 29, 23, -27, -30, -8, -9, -7, -22, -40, + 0, 65, -13, -25, 31, -36, -61, -59, -81, -11, -13, -3, 4, 13, -41, -38, + 0, 66, -11, 84, 38, -2, -31, -5, 4, -17, -17, -24, -10, -1, -24, -44, + 0, 66, 57, 81, -12, -37, -57, -44, 11, -29, -17, 5, -29, -25, -34, -52, + 0, 66, -11, -70, -14, -19, -48, 13, 13, -64, -2, -52, 14, -29, -54, -41, + 0, 67, 22, 59, 40, 0, -10, 1, 19, -20, -19, -5, 0, -9, -23, -39, + 0, 72, 18, 63, 7, 5, -10, -102, -19, -8, -70, -26, -7, -13, -22, -59, + 0, 73, -60, -39, 5, -87, -36, -3, -20, -44, -15, 18, 3, -13, -33, -65, + 0, 74, -31, 35, -18, -23, -38, -11, 6, -23, -26, 2, -3, -6, -26, -43, + 0, 75, -53, -10, -39, -38, -43, -13, 4, -30, -33, -12, -2, -10, -30, -48, + 0, 77, -25, -6, -19, -87, -76, 33, 19, -43, -24, 11, -30, 42, -10, -59, + 0, 77, 8, -18, -29, -20, -28, -19, 4, -21, -17, 8, 1, -3, -23, -41, + 0, 80, -17, -39, -7, -72, -17, -18, -25, -14, -51, 27, 2, 15, -43, -63, + 0, 87, -19, 52, 48, -41, -46, -38, -74, -47, -26, -30, 4, 32, -29, -46, + 0, 87, 28, 26, 22, -11, -59, -76, -21, -42, -41, -57, -7, 24, -34, -47, + 0, 89, 15, 52, -2, -59, -80, -24, 38, -31, -21, 3, -11, 3, -18, -42, + 0, 96, -51, 70, 24, -9, -3, -23, 11, -22, -30, 5, -7, -11, -21, -45, + 0, 101, -5, 0, 37, -11, -51, -20, -25, -70, -24, 25, 7, 27, -14, -47, + 0, 102, 46, 29, -28, -38, -36, -23, 6, -23, -23, -8, -4, -4, -25, -40, + 0, 111, 13, 16, 4, -27, -46, -30, 11, -26, -20, 13, -3, -15, -27, -39, + 0, 116, -38, -19, -3, -30, -17, 22, 31, -8, -20, -13, -1, -6, -26, -40, + 0, 117, 49, 48, 1, 5, -8, -5, 6, -16, 1, 24, -6, -30, -32, -43 +}; +const Word8 *const snsSt1_stage1_W8Qx_dct_sections_tcx20[4]={ sns_tcx20_dct_s0_W8Qx, sns_tcx20_dct_s1_W8Qx, sns_tcx20_dct_s2_W8Qx, sns_tcx20_dct_s3_W8Qx }; + +const Word8 /*seg 0, 13 x 8 */ sns_tcx10_dct_s0_W8Qx[104]={ + 0, -85, -29, 33, 29, -57, -79, -67, + 0, 36, 48, 42, 49, -37, -51, -88, + 0, 47, 67, -2, -35, -56, -112, -81, + 0, 76, 1, -8, 35, 6, -30, -50, + 0, 81, 35, -9, 26, -42, -66, -55, + 0, 84, -46, -33, -2, -61, -53, -86, + 0, 91, 60, 38, 56, -10, -27, -64, + 0, 100, 57, 6, -22, -82, -81, -119, + 0, 103, 3, -76, -21, -70, -101, -74, + 0, 104, 26, -2, 86, 7, -52, -80, + 0, 106, -2, -22, 42, -70, -83, -90, + 0, 122, 46, -23, -31, -24, -7, -39, + 0, 127, 12, -57, 4, -10, -36, -75 +}; +const Word8 /*seg 1, 34 x 10 */ sns_tcx10_dct_s1_W8Qx[340]={ + 0, -127, -1, 22, 9, -18, -52, -24, -49, 100, + 0, -91, 36, 55, 16, -19, -50, -15, -61, 66, + 0, -81, -4, -19, 19, -23, -68, -20, -48, 65, + 0, -56, 13, -8, -3, -31, -66, -30, -37, 45, + 0, -55, 45, 24, 10, -16, -57, -35, -40, 77, + 0, -55, -14, 34, -28, -63, -46, -36, -3, 94, + 0, -52, -22, -41, 26, -36, -103, -42, -42, 63, + 0, -47, 64, 68, 32, -32, -29, -49, 2, 111, + 0, -41, -32, 18, 28, -84, -79, -39, -69, -7, + 0, -29, 14, -30, -51, -75, -69, -60, -8, 80, + 0, -17, 15, 92, -15, -34, -46, -36, -39, 39, + 0, -15, -39, -65, -84, -78, -55, -37, 0, 73, + 0, -13, 0, 59, 75, -24, -64, -30, 16, 43, + 0, 2, 48, 19, 55, 11, -46, -25, -38, 58, + 0, 2, 51, 60, 20, -32, -64, -30, -1, 65, + 0, 5, -7, -32, -42, -98, -85, -50, -37, 55, + 0, 8, -53, -19, 85, 22, -13, -28, 5, 59, + 0, 14, -26, -77, -49, -50, -45, -38, -24, 55, + 0, 28, -5, 49, 16, -9, -36, -29, 31, 91, + 0, 31, 47, -21, 19, -30, -50, -43, -22, 5, + 0, 34, -31, -29, 19, 5, -27, -33, 26, 53, + 0, 35, -14, -20, -2, -53, -72, -43, -24, 28, + 0, 42, 18, 12, 21, -13, -35, -33, 23, 79, + 0, 42, 18, 13, 109, 8, -83, -39, 30, 29, + 0, 45, -52, -67, -69, -62, -52, 2, 89, 123, + 0, 50, 7, -14, 9, -45, -52, -8, 50, 94, + 0, 55, -16, 20, 80, -10, -51, -48, -30, 18, + 0, 57, 38, 16, 60, 9, -21, -14, 43, 75, + 0, 66, -12, -27, -35, -105, -82, -35, 12, 105, + 0, 69, 15, 38, 103, 3, -52, -20, 64, 84, + 0, 79, 26, 40, 48, -13, -59, -66, -12, 70, + 0, 90, 17, -32, 93, 50, -74, -98, -49, 2, + 0, 96, -29, 2, 119, -50, -63, -52, -65, -42, + 0, 105, 24, -33, 15, -54, -116, -61, 54, 117 +}; +const Word8 /*seg 2, 41 x 12 */ sns_tcx10_dct_s2_W8Qx[492]={ + 0, -23, 17, 2, 32, 4, -34, -33, -22, 73, -16, -8, + 0, -20, 47, 25, 1, -26, -37, -40, -20, 59, -17, -47, + 0, -10, 43, -37, 5, -26, -40, -35, -12, 52, -31, 17, + 0, -9, -36, -38, 19, -50, -56, -50, -3, 29, -44, -6, + 0, -8, 20, 9, 72, -9, -38, -43, 22, 39, 24, -3, + 0, 3, 29, 19, 12, -41, -31, -49, -19, 2, -42, -50, + 0, 6, 21, -30, -6, -69, -39, -53, -7, 69, -6, 37, + 0, 13, -24, -38, -23, -46, -24, -28, -6, -17, -29, 25, + 0, 14, -15, 30, 71, 36, -42, -68, 7, 18, -29, 1, + 0, 15, 20, -19, 27, 27, -42, -71, -69, -65, -60, 11, + 0, 17, -2, -70, 13, -37, -50, -42, -21, 41, 4, 57, + 0, 18, 33, 19, 65, -3, -38, -16, 28, 40, 17, -29, + 0, 19, 32, 15, -25, -67, -48, -41, -20, 49, -21, -35, + 0, 20, -19, -23, 35, -56, -55, -39, -13, -19, -32, 19, + 0, 21, 5, 3, 43, -32, -44, -43, 16, 60, 24, 18, + 0, 24, 33, 22, 18, -39, -25, -24, 15, 73, -19, -19, + 0, 25, 76, 40, 17, -7, -30, -46, 12, -15, 11, -58, + 0, 27, -8, -58, -32, -27, -16, -33, 0, 10, -13, 10, + 0, 35, 11, 19, 15, -31, -42, -56, -20, -48, -64, -31, + 0, 37, 33, 30, 40, 11, -38, -60, -42, -23, -43, -16, + 0, 40, 22, -42, 32, -30, -57, -37, -58, -9, -44, 43, + 0, 50, -22, -68, 25, -98, -65, -8, -13, 22, 2, 68, + 0, 53, 28, 18, 11, -47, -41, -42, 0, 24, -29, -21, + 0, 55, 51, 65, 45, 16, -10, -15, 27, 97, 15, 41, + 0, 61, 55, 30, 31, -35, -44, -62, -22, -17, -49, -29, + 0, 62, -2, -7, 54, 57, -53, -94, -36, -108, -83, 42, + 0, 67, 27, -5, 28, -12, -46, -67, -42, -93, -45, 29, + 0, 69, 30, -29, -14, -64, -50, -60, -5, 13, -47, -5, + 0, 70, 7, -45, 2, -80, -78, -45, 24, 119, -62, -7, + 0, 71, -2, 0, 13, -61, -50, -79, -7, -49, -80, 36, + 0, 78, 7, -49, 53, -24, -77, -45, -52, -47, -35, 122, + 0, 93, -27, -88, 17, -101, -66, -12, 19, -46, -65, 65 +}; +const Word8 /*seg 3, 40 x 16 */ sns_tcx10_dct_s3_W8Qx[640]={ + 0, -69, -22, -85, -72, -77, 0, 73, -12, -73, 83, -5, -123, 81, -1, -63, + 0, -67, -42, -88, -66, -71, -23, 69, 16, -36, 83, -9, -26, 49, 15, -65, + 0, -46, -45, -56, -64, -48, -7, 101, 32, -44, 58, -17, -44, 68, 36, -49, + 0, -45, -18, -64, -53, -41, -15, 64, 9, -52, 49, 7, -14, 78, 47, -13, + 0, -29, 1, -3, 8, -30, -11, -9, 16, 50, 16, 1, 14, 19, -2, 14, + 0, -27, 21, 62, 34, 32, 2, -59, 52, -14, 8, 10, -18, 55, 48, -24, + 0, -20, -22, -21, -5, -16, -26, -30, 18, 30, -24, 16, 19, 24, -10, -4, + 0, -17, 17, -17, 62, 58, 44, -38, -16, 58, 49, 16, 0, 46, 7, 86, + 0, -15, -61, -71, -68, -47, 89, -22, 9, 30, 39, 70, 123, -81, -101, -100, + 0, -15, 0, -42, 14, -25, -50, -49, -36, 21, 19, -10, -41, 2, -2, 30, + 0, -15, 10, 9, -9, -48, -37, -31, -17, 40, -16, 2, 5, 20, -9, 19, + 0, -14, 52, -86, 29, -52, 50, 36, 85, 43, 4, -70, -38, 41, 101, 100, + 0, -12, 66, 42, 43, -9, -14, -18, 20, 33, 31, -12, 34, 41, -9, 42, + 0, -9, 7, -65, -2, -4, -35, -17, -31, -51, -53, 42, -10, 33, -17, 14, + 0, -9, -18, 9, 12, -88, -42, -26, -29, -8, 2, 11, -6, 26, -3, -2, + 0, -8, 29, 11, 9, -39, -17, -42, 19, 35, 3, 5, -2, 26, 2, 14, + 0, -4, 0, 23, -1, -6, -21, -43, 8, 28, -21, 5, 1, 22, 13, 5, + 0, -1, 1, 9, 47, -13, -69, -58, -60, 6, 24, -18, -41, 13, 21, 37, + 0, 0, -1, -10, 19, -18, -25, -24, 1, 42, -10, -8, -17, 11, -21, 3, + 0, 0, 21, 42, 38, 3, -13, -14, 11, 50, 3, 12, 22, 28, 14, 18, + 0, 2, -35, -34, -57, -30, -1, 94, 44, -37, 49, -1, -49, 78, 23, -42, + 0, 10, -20, 15, -11, -45, -28, -23, 30, 41, -14, -2, -13, 16, -21, -8, + 0, 12, 9, 14, -7, -53, -34, -55, 2, 20, -33, -8, -30, 16, 0, 9, + 0, 14, 22, -4, 13, -20, -19, -19, 21, 49, 10, 9, 6, 18, -10, 7, + 0, 14, 43, 47, 44, -3, -10, -34, 29, 27, 22, 7, 6, 31, 19, 22, + 0, 17, 20, 55, 20, -27, -18, -64, 17, -38, -12, -27, -63, 23, -9, -13, + 0, 17, 0, 38, 51, -51, -40, -35, -40, -17, -43, -25, -46, 2, -7, 23, + 0, 23, -4, -6, 3, -10, -23, -22, 4, 25, -9, 11, 15, 21, -3, 8, + 0, 24, 16, -54, -23, -96, -48, 20, 17, -10, -13, 1, -75, 21, 43, 19, + 0, 34, 17, -15, -5, -71, -44, -58, -13, 0, -29, 17, 13, 24, 18, 26, + 0, 34, 16, 47, 35, 4, -11, -7, 25, 58, 4, 19, 28, 38, 9, 16, + 0, 36, 6, 1, 62, 44, -89, -67, -37, -22, -22, 33, -67, -15, 41, 36, + 0, 47, 14, -29, -14, 29, -11, -75, -47, -14, -61, 13, -11, 39, -1, -25, + 0, 53, 17, -79, -13, -10, -61, -55, 34, -50, -5, 38, -120, 5, -62, -28, + 0, 54, 19, -12, -55, -105, -44, -52, -39, 60, 1, -24, -48, 4, 62, 99, + 0, 55, -7, -53, 16, 3, -64, -67, -33, -29, -65, 47, 48, -2, 27, 62, + 0, 61, 25, 36, 36, -81, -12, -38, -85, 8, 6, -51, -79, 14, -33, 48, + 0, 72, -4, -92, -47, -32, -24, -57, 48, -10, -34, 2, -80, 25, -56, -32, + 0, 77, 18, -88, 2, -107, -51, -14, -20, 73, -42, 19, -119, 21, 5, 30, + 0, 85, 46, 5, 13, -18, -39, -101, -40, 15, -30, 8, -103, -16, 0, 69 +}; +const Word8 *const snsSt1_stage1_W8Qx_dct_sections_tcx10[4]={ sns_tcx10_dct_s0_W8Qx, sns_tcx10_dct_s1_W8Qx, sns_tcx10_dct_s2_W8Qx, sns_tcx10_dct_s3_W8Qx }; +const Word8 *const* snsSt1_stage1_W8Qx_dct_sections[2]={snsSt1_stage1_W8Qx_dct_sections_tcx20, snsSt1_stage1_W8Qx_dct_sections_tcx10 }; + +const Word16 snsSt1_tcx20_stage1_col_syn_shift_segm0[10]={ + 0, 4, 4, 3, 3, 2, 2, 1, + 2, 0 +}; +const Word16 snsSt1_tcx20_stage1_col_syn_shift_segm1[12]={ + 0, 4, 3, 3, 3, 3, 2, 2, + 2, 1, 1, 1 +}; +const Word16 snsSt1_tcx20_stage1_col_syn_shift_segm2[14]={ + 0, 4, 4, 3, 3, 3, 3, 2, + 2, 1, 2, 1, 2, 1 +}; +const Word16 snsSt1_tcx20_stage1_col_syn_shift_segm3[16]= { + 0, 4, 4, 3, 3, 3, 3, 2, + 2, 2, 2, 1, 2, 1, 2, 2 +}; +const Word16 *const snsSt1_dct_col_syn_shift_tcx20[4]={snsSt1_tcx20_stage1_col_syn_shift_segm0, snsSt1_tcx20_stage1_col_syn_shift_segm1, snsSt1_tcx20_stage1_col_syn_shift_segm2, snsSt1_tcx20_stage1_col_syn_shift_segm3}; + + +const Word16 snsSt1_tcx10_stage1_col_syn_shift_segm0[8]={ + 0, 4, 4, 3, 2, 2, 2, 1 +}; +const Word16 snsSt1_tcx10_stage1_col_syn_shift_segm1[10]={ + 0, 4, 4, 3, 2, 2, 2, 2, + 1, 0 +}; +const Word16 snsSt1_tcx10_stage1_col_syn_shift_segm2[12]={ + 0, 4, 4, 3, 3, 2, 3, 2, + 2, 0, 1, 0 +}; +const Word16 snsSt1_tcx10_stage1_col_syn_shift_segm3[16]={ + 0, 4, 4, 3, 3, 2, 3, 2, + 2, 1, 1, 1, 0, 1, 0, 0 +}; + +const Word16 *const snsSt1_dct_col_syn_shift_tcx10[4]={ snsSt1_tcx10_stage1_col_syn_shift_segm0, snsSt1_tcx10_stage1_col_syn_shift_segm1, snsSt1_tcx10_stage1_col_syn_shift_segm2, snsSt1_tcx10_stage1_col_syn_shift_segm3 }; +const Word16 *const* snsSt1_dct_col_syn_shift[2]={snsSt1_dct_col_syn_shift_tcx20, snsSt1_dct_col_syn_shift_tcx10 }; + +const Word8 snsSt1_segm_neighbour_fwd_tcx20[128]= { + 45, 56, 14, 77, 38, 113, 26, 6, + 5, 15, 48, 28, 58, 60, 19, 111, + 84, 117, 103, 108, 40, 121, 109, 9, + 116, 20, 27, 126, 29, 43, 52, 11, + 1, 2, 36, 65, 32, 3, 91, 64, + 7, 42, 46, 44, 41, 49, 53, 30, + 127, 12, 31, 47, 62, 10, 0, 13, + 75, 54, 71, 50, 51, 63, 59, 70, + 33, 61, 83, 55, 57, 72, 76, 66, + 73, 68, 69, 80, 82, 35, 67, 90, + 98, 96, 78, 88, 87, 95, 4, 81, + 89, 85, 92, 34, 74, 105, 79, 37, + 94, 100, 101, 86, 99, 16, 115, 107, + 119, 112, 21, 93, 18, 97, 102, 17, + 22, 104, 106, 114, 118, 39, 110, 122, + 23, 120, 24, 25, 125, 123, 8, 124 +}; +const Word8 snsSt1_segm_neighbour_fwd_tcx10[128]={ + 21, 75, 72, 42, 46, 87, 9, 6, + 12, 44, 8, 7, 11, 127, 49, 13, + 17, 14, 0, 15, 100, 19, 98, 27, + 90, 104, 61, 26, 62, 33, 73, 74, + 1, 30, 37, 118, 78, 108, 41, 81, + 120, 125, 43, 124, 86, 5, 10, 20, + 29, 25, 18, 54, 56, 57, 22, 51, + 92, 58, 101, 63, 95, 103, 110, 28, + 114, 105, 59, 113, 65, 66, 111, 68, + 80, 116, 117, 36, 32, 39, 35, 40, + 79, 119, 83, 122, 85, 3, 45, 126, + 91, 88, 89, 16, 50, 53, 55, 93, + 48, 24, 52, 47, 112, 97, 94, 107, + 106, 64, 102, 60, 96, 69, 23, 115, + 67, 71, 70, 109, 99, 34, 31, 76, + 38, 123, 2, 77, 82, 121, 84, 4 +}; +const Word8 *const snsSt1_segm_neighbour_fwd[2]={snsSt1_segm_neighbour_fwd_tcx20 , snsSt1_segm_neighbour_fwd_tcx10}; + + +const Word8 snsSt1_segm_neighbour_rev_tcx20[128]= { + 54, 32, 33, 37, 86, 8, 7, 40, + 126, 23, 53, 31, 49, 55, 2, 9, + 101, 111, 108, 14, 25, 106, 112, 120, + 122, 123, 6, 26, 11, 28, 47, 50, + 36, 64, 91, 77, 34, 95, 4, 117, + 20, 44, 41, 29, 43, 0, 42, 51, + 10, 45, 59, 60, 30, 46, 57, 67, + 1, 68, 12, 62, 13, 65, 52, 61, + 39, 35, 71, 78, 73, 74, 63, 58, + 69, 72, 92, 56, 70, 3, 82, 94, + 75, 87, 76, 66, 16, 89, 99, 84, + 83, 88, 79, 38, 90, 107, 96, 85, + 81, 109, 80, 100, 97, 98, 110, 18, + 113, 93, 114, 103, 19, 22, 118, 15, + 105, 5, 115, 102, 24, 17, 116, 104, + 121, 21, 119, 125, 127, 124, 27, 48 +}; + +const Word8 snsSt1_segm_neighbour_rev_tcx10[128]={ + 18, 32, 122, 85, 127, 45, 7, 11, + 10, 6, 46, 12, 8, 15, 17, 19, + 91, 16, 50, 21, 47, 0, 54, 110, + 97, 49, 27, 23, 63, 48, 33, 118, + 76, 29, 117, 78, 75, 34, 120, 77, + 79, 38, 3, 42, 9, 86, 4, 99, + 96, 14, 92, 55, 98, 93, 51, 94, + 52, 53, 57, 66, 107, 26, 28, 59, + 105, 68, 69, 112, 71, 109, 114, 113, + 2, 30, 31, 1, 119, 123, 36, 80, + 72, 39, 124, 82, 126, 84, 44, 5, + 89, 90, 24, 88, 56, 95, 102, 60, + 108, 101, 22, 116, 20, 58, 106, 61, + 25, 65, 104, 103, 37, 115, 62, 70, + 100, 67, 64, 111, 73, 74, 35, 81, + 40, 125, 83, 121, 43, 41, 87, 13 +}; +const Word8 *const snsSt1_segm_neighbour_rev[2]={snsSt1_segm_neighbour_rev_tcx20 , snsSt1_segm_neighbour_rev_tcx10}; + +const int16_t snsSt1_npost[2]={8, 6}; /*number of circ. neigbours to postcheck */ + +#endif /* ERI_SNSVQ_ROMOPT */ + const int16_t ivas_sns_cdbks_side_tcx20_levels[SNS_MSVQ_NSTAGES_SIDE] = { 32, 32 }; const int16_t ivas_sns_cdbks_side_tcx20_bits[SNS_MSVQ_NSTAGES_SIDE] = { 5, 5 }; @@ -6171,6 +6619,8 @@ const float ivas_sns_cdbks_side_tcx10_stage2[ 8 * 16 ] = { const float *const ivas_sns_cdbks_side_tcx10[SNS_MSVQ_NSTAGES_SIDE] = { ivas_sns_cdbks_side_tcx10_stage1, ivas_sns_cdbks_side_tcx10_stage2 }; #else /* codebooks trained for no adaptive tilt */ + +#ifndef ERI_SNSVQ_ROMOPT const float ivas_sns_cdbk_tcx20_stage1[ 128 * 16 ] = { -3.24881770f, -1.99497051f, -0.04725080f, 1.02318508f, 1.51589220f, 1.44649178f, 1.27858728f, 1.15137095f, 0.98029724f, 0.69167126f, 0.33414576f, 0.11759238f, -0.27510520f, -0.63610342f, -1.05394049f, -1.28304590f, -3.24340413f, -4.15075396f, -2.86242117f, -1.11561919f, 1.12899983f, 1.98341478f, 0.56638511f, -0.05841474f, -0.14875192f, 0.31098029f, 1.87121037f, 0.91347082f, 1.02548459f, 1.98227488f, 1.30278860f, 0.49435585f, @@ -6301,6 +6751,8 @@ const float ivas_sns_cdbk_tcx20_stage1[ 128 * 16 ] = { 2.58466208f, 2.01534437f, 1.28252767f, 0.44865967f, -0.33100837f, -0.81011259f, -1.06701187f, -1.12743988f, -1.21505758f, -0.99337144f, -0.66853937f, -0.46093443f, -0.22132067f, 0.00996599f, 0.24481197f, 0.30882455f, -0.62864502f, 1.04984327f, 1.56877053f, 0.77975000f, 0.01037804f, 0.92352492f, 1.12297462f, 0.76284403f, -0.16106015f, -0.21398417f, -0.62673537f, -1.68917053f, -1.60748063f, -0.79116243f, -0.06290217f, -0.43694470f }; +#endif + const float ivas_sns_cdbk_tcx20_stage2[ 64 * 16 ] = { -0.14487037f, 0.32346300f, 0.29798679f, -0.52393127f, -0.25671033f, 0.85717754f, -0.09030235f, -0.41110330f, -0.32938564f, -0.36580017f, -0.13142117f, -0.06404494f, 0.10671000f, 0.18731030f, 0.26606878f, 0.27885301f, 0.52707061f, 0.35016312f, 0.54090507f, 0.82023896f, 0.46675870f, -0.60012182f, -0.76783382f, -0.39198749f, -0.17916696f, -0.17307722f, -0.10507731f, -0.09327542f, -0.12176361f, -0.12715624f, -0.11980175f, -0.02587481f, @@ -6436,8 +6888,11 @@ const float ivas_sns_cdbk_tcx20_stage4[ 32 * 16 ] = { 0.44241891f, -0.06885632f, -0.14130761f, -0.04771012f, -0.00863562f, 0.00586591f, 0.12381405f, 0.08059256f, -0.06764947f, -0.22513354f, -0.10536820f, 0.02669478f, 0.01147300f, -0.01584685f, -0.02845628f, 0.01810479f }; +#ifdef ERI_SNSVQ_ROMOPT + const float *const ivas_sns_cdbks_tcx20[SNS_MSVQ_NSTAGES_TCX20] = { NULL, ivas_sns_cdbk_tcx20_stage2, ivas_sns_cdbk_tcx20_stage3, ivas_sns_cdbk_tcx20_stage4 }; +#else const float *const ivas_sns_cdbks_tcx20[SNS_MSVQ_NSTAGES_TCX20] = { ivas_sns_cdbk_tcx20_stage1, ivas_sns_cdbk_tcx20_stage2, ivas_sns_cdbk_tcx20_stage3, ivas_sns_cdbk_tcx20_stage4 }; - +#endif const float ivas_sns_means_tcx20[M] = { 0.9155f , 1.2408f , 1.0050f , 0.5846f, 0.2472f , 0.1902f , 0.0984f , 0.1039f, @@ -6448,6 +6903,7 @@ const float ivas_sns_means_tcx20[M] = { const int16_t ivas_sns_cdbks_tcx10_levels[SNS_MSVQ_NSTAGES_TCX10] = { 128, 32, 8 }; const int16_t ivas_sns_cdbks_tcx10_bits[SNS_MSVQ_NSTAGES_TCX10] = { 7, 5, 3 }; +#ifndef ERI_SNSVQ_ROMOPT const float ivas_sns_cdbk_tcx10_stage1[ 128 * 16 ] = { 0.06343891f, -0.00651786f, -0.56994713f, -0.98772396f, -1.35099293f, -1.24848646f, -1.20301995f, -0.81089507f, -0.06563095f, 1.11147581f, 1.73933309f, 1.65859611f, 1.26237806f, 0.68028141f, 0.12449909f, -0.39678907f, -1.34007175f, -1.50272189f, -2.07958791f, -2.38322761f, -2.22156614f, -1.96435669f, -1.68760863f, -1.23664935f, -0.28772180f, 0.87765579f, 1.83822720f, 1.95281398f, 2.33671266f, 2.76119687f, 2.75790597f, 2.17899850f, @@ -6578,6 +7034,8 @@ const float ivas_sns_cdbk_tcx10_stage1[ 128 * 16 ] = { 2.30575156f, 2.37005513f, 1.37776397f, 0.78509487f, 0.18022242f, -0.13093354f, 0.22126477f, -0.11444642f, -0.35716968f, -0.59492665f, -0.35765935f, -0.44655201f, -1.03213345f, -1.27074059f, -1.44000075f, -1.49558947f, -1.00874079f, -1.64011865f, -1.86084729f, -1.06805908f, 0.07222945f, 1.36179475f, 1.87160360f, 1.76248472f, 1.52374330f, 1.04119855f, 0.73448166f, 0.13768018f, -0.49711929f, -0.73696841f, -0.89885406f, -0.79450886f }; +#endif + const float ivas_sns_cdbk_tcx10_stage2[ 32 * 16 ] = { 0.30627323f, 0.48836579f, -0.02716944f, -0.47680077f, -0.52992614f, -0.25467720f, -0.13298242f, -0.14929291f, -0.14808149f, 0.08665801f, 0.28830653f, 0.27526330f, 0.09942358f, -0.01755061f, 0.03315580f, 0.15903469f, 0.40931263f, -0.04412117f, -0.08826419f, 0.38716891f, 0.51515595f, 0.42227845f, 0.34963425f, 0.26800736f, 0.03770000f, -0.19967080f, -0.31044249f, -0.32623294f, -0.38445978f, -0.38085950f, -0.38590829f, -0.26929836f, @@ -6623,7 +7081,11 @@ const float ivas_sns_cdbk_tcx10_stage3[ 8 * 16 ] = { -0.18216919f, 0.06012195f, 0.24774113f, 0.41673922f, 0.28902704f, -0.14711768f, -0.20580810f, -0.08400793f, -0.06024452f, -0.19915854f, -0.17662518f, -0.08993148f, 0.01116638f, 0.13122555f, 0.08011919f, -0.09107791f }; +#ifdef ERI_SNSVQ_ROMOPT +const float *const ivas_sns_cdbks_tcx10[SNS_MSVQ_NSTAGES_TCX10] = { NULL, ivas_sns_cdbk_tcx10_stage2, ivas_sns_cdbk_tcx10_stage3}; +#else const float *const ivas_sns_cdbks_tcx10[SNS_MSVQ_NSTAGES_TCX10] = { ivas_sns_cdbk_tcx10_stage1, ivas_sns_cdbk_tcx10_stage2, ivas_sns_cdbk_tcx10_stage3}; +#endif const float ivas_sns_means_tcx10[M] = { 0.9510f , 1.1892f , 0.8969f , 0.3467f, @@ -6632,6 +7094,8 @@ const float ivas_sns_means_tcx10[M] = { -0.4801f , -0.4108f , -0.4564f , -0.6112f }; + + const int16_t ivas_sns_cdbks_side_tcx20_levels[SNS_MSVQ_NSTAGES_SIDE] = { 32, 32 }; const int16_t ivas_sns_cdbks_side_tcx20_bits[SNS_MSVQ_NSTAGES_SIDE] = { 5, 5 }; const int16_t ivas_sns_cdbks_side_tcx10_levels[SNS_MSVQ_NSTAGES_SIDE] = { 32, 8 }; diff --git a/lib_com/ivas_rom_com.h b/lib_com/ivas_rom_com.h index ccfc3f9000282f65fcbc7ea088f4fecf00cfaafb..d0c3db33b3607a7a6ac9653eddd8255e13f40350 100644 --- a/lib_com/ivas_rom_com.h +++ b/lib_com/ivas_rom_com.h @@ -425,6 +425,23 @@ extern const int16_t ivas_sns_cdbks_side_tcx10_bits[]; extern const float *const ivas_sns_cdbks_side_tcx20[]; extern const float *const ivas_sns_cdbks_side_tcx10[]; + +#ifdef ERI_SNSVQ_ROMOPT +extern const float *const snsSt1_tr_midQ_truncQ[]; +extern const float *const snsSt1_dct_invScaleF[]; +extern const float *const snsSt1_dct_scaleF[]; +extern const int16_t snsSt1_dct_n_segm[]; +extern const int16_t *const snsSt1_dct_cols_per_segment[]; +extern const int16_t *const snsSt1_trunc_dct_cols_per_segment[]; +extern const int16_t *const snsSt1_cum_entries_per_segment[]; +extern const int16_t *const snsSt1_entries_per_segment[]; +extern const Word8 *const *snsSt1_stage1_W8Qx_dct_sections[]; +extern const Word16 *const *snsSt1_dct_col_syn_shift[]; +extern const Word8 *const snsSt1_segm_neighbour_fwd[]; +extern const Word8 *const snsSt1_segm_neighbour_rev[]; +extern const int16_t snsSt1_npost[]; +#endif /* ERI_SNSVQ_ROMOPT */ + #else extern const int16_t ivas_sns_cdbks_tcx20_levels[]; extern const int16_t ivas_sns_cdbks_tcx20_bits[]; diff --git a/lib_com/lsf_tools.c b/lib_com/lsf_tools.c index 02a735e80c0baf8914c90526bd7fde29581f5dd8..dec680dd08429824740d1fea286493310539986b 100644 --- a/lib_com/lsf_tools.c +++ b/lib_com/lsf_tools.c @@ -46,6 +46,11 @@ #include "basop_proto_func.h" #include "wmc_auto.h" +#ifdef ERI_SNSVQ_ROMOPT +#include "ivas_rom_com.h" /* updated msvq_enc/msvq_dec*/ +#endif + + /*-------------------------------------------------------------------* * Local function prototypes *-------------------------------------------------------------------*/ @@ -2027,6 +2032,76 @@ int16_t tcxlpc_get_cdk( return cdk; } + +#ifdef ERI_SNSVQ_ROMOPT +void dec_SNS_FDCNG_MSVQ_DCT_stage1( + const int16_t n_segm, /* i: */ + const int16_t *cum_entries_per_segment, /*i: */ + const Word8 *const *stage1_W8Qx_dct_sections, /* i: */ + const int16_t *cols_per_segment, /* i: */ + const int16_t *const *dct_col_syn_shift, /* i: */ + + const int16_t max_trunc, /* i: */ + const float *dct_scaleF, /* i: */ + const float *midQ_truncQ, /* i: */ + + int16_t j_full, /* i: index full range */ + int16_t n, /* i: dimension to generate */ + int16_t maxN, /* i: codebook storage/synthesis dimension */ + + const float *invTrfMatrix, /* i: IDCT matrix for synthesis */ + const DCTTYPE idcttype, /* i: specify which IDCT */ + float *uq, /* o: synthesized stage1 vector */ + Word16 *uq_ind /* o: synthesized stage1 vector in BASOP */ +) +{ + int16_t col, segm_ind, j; + float dct_vec[NPART]; + float idct_vec[NPART]; + const Word8 *cbpW8; + const Word16 *dct_col_shift_tab; + + assert( maxN == M || maxN == FDCNG_VQ_MAX_LEN ); + assert( n == M || n == FDCNG_VQ_MAX_LEN || n == FDCNG_VQ_MAX_LEN_WB ); + + segm_ind = 0; + for ( col = 1; col <= n_segm; col++ ) + { + if ( j_full >= cum_entries_per_segment[col] ) + { + segm_ind++; + } + } + + j = j_full - cum_entries_per_segment[segm_ind]; /* j is the local segment index */ + + // assert( j < entries_per_segment[segm_ind] ); + + /* Word8 column variable Qx storage*/ + cbpW8 = stage1_W8Qx_dct_sections[segm_ind]; /* Word8 storage fixed ptr_init */ + cbpW8 += j * cols_per_segment[segm_ind]; /* adaptive ptr init */ + dct_col_shift_tab = dct_col_syn_shift[segm_ind]; + + for ( col = 0; col < cols_per_segment[segm_ind]; col++ ) + { + dct_vec[col] = (float) ( ( (Word16) cbpW8[col] ) << dct_col_shift_tab[col] ); + /* LOGIC( 1 ); SHIFT( 1 ); ADD( 1 ); + in BASOP: s_and(for W8->W16), shl(), sub() + */ + } + dctT2_N_apply_matrix( (const float *) dct_vec, idct_vec, cols_per_segment[segm_ind], n, invTrfMatrix, max_trunc, idcttype ); + + /*scale down to original domain and move to Q0 */ + v_multc( idct_vec, dct_scaleF[1], idct_vec, n ); + /* dct_scaleF[1] --> 0.0625-->scale down from search Q4 domain to Q0 , + not really relevant for BASOP loop */ + + /*add common mid vector, in input bands domain */ + v_add( idct_vec, midQ_truncQ, uq, n ); + assert( uq_ind == NULL ); +} +#endif + void dec_FDCNG_MSVQ_stage1( int16_t j_full, /* i: index full range */ int16_t n, /* i: dimension to generate */ @@ -2106,6 +2181,18 @@ void msvq_dec( { int16_t i, n, maxn, start; Word16 j; +#ifdef ERI_SNSVQ_ROMOPT + DCTTYPE dcttype = IDCT_T2_XX_24; + int16_t tcx_ind = -1; + int16_t n_segm = FDCNG_VQ_DCT_NSEGM; + const int16_t *cum_entries_per_segment = (const int16_t *) cdk1_ivas_cum_entries_per_segment; + const Word8 *const *W8Qx_dct_sections = (const Word8 *const *) cdk_37bits_ivas_stage1_W8Qx_dct_sections; + const int16_t *cols_per_segment = (const int16_t *) cdk1_ivas_cols_per_segment; + const int16_t *const *col_syn_shift = (const int16_t *const *) stage1_dct_col_syn_shift; + int16_t max_trunc = FDCNG_VQ_DCT_MAXTRUNC; + const float *dct_scaleF = (const float *) fdcng_dct_scaleF; + const float *midQ_truncQ = (const float *) cdk1r_tr_midQ_truncQ; +#endif set_zero( uq, N ); if ( uq_ind ) @@ -2139,8 +2226,39 @@ void msvq_dec( if ( i == 0 && applyIDCT_flag != 0 ) { +#ifdef ERI_SNSVQ_ROMOPT + if ( maxN == SNS_VQ_MAX_LEN ) + { + dcttype = IDCT_T2_XX_16; + tcx_ind = ( applyIDCT_flag == 20 ) ? 0 : 1; /* 20-->0 && 10->>1 */ +#ifdef DEBUGGING + if ( tcx_ind == 0 ) + { + assert( stages == SNS_MSVQ_NSTAGES_TCX20 ); + } + else if ( tcx_ind == 1 ) + { + assert( stages == SNS_MSVQ_NSTAGES_TCX10 ); + } +#endif + n_segm = SNS_VQ_DCT_NSEGM; + cum_entries_per_segment = (const int16_t *) snsSt1_cum_entries_per_segment[tcx_ind]; + W8Qx_dct_sections = (const Word8 *const *) snsSt1_stage1_W8Qx_dct_sections[tcx_ind]; + cols_per_segment = (const int16_t *) snsSt1_dct_cols_per_segment[tcx_ind]; + col_syn_shift = (const int16_t *const *) snsSt1_dct_col_syn_shift[tcx_ind]; + max_trunc = SNS_VQ_DCT_MAXTRUNC; + dct_scaleF = (const float *) snsSt1_dct_scaleF[tcx_ind]; + midQ_truncQ = (const float *) snsSt1_tr_midQ_truncQ[tcx_ind]; + } + + dec_SNS_FDCNG_MSVQ_DCT_stage1( + n_segm, cum_entries_per_segment, W8Qx_dct_sections, + cols_per_segment, col_syn_shift, max_trunc, dct_scaleF, midQ_truncQ, + Idx[0], N, maxN, invTrfMatrix, dcttype, uq, uq_ind ); +#else assert( start == 0 ); dec_FDCNG_MSVQ_stage1( Idx[0], N, invTrfMatrix, IDCT_T2_XX_24, uq, uq_ind ); /* IDCT_T2 N=24 used for all synthesis */ +#endif } else { @@ -2460,7 +2578,11 @@ void dctT2_N_apply_matrix( mat_step_col = matrix_row_dim; /* matrix maximum storage size dependent, width of first row in matrix */ mat_step_row = 0; mat_step_col_flag = 1; +#ifdef ERI_SNSVQ_ROMOPT + assert( dcttype == DCT_T2_16_XX || dcttype == DCT_T2_21_XX || dcttype == DCT_T2_24_XX ); +#else assert( dcttype == DCT_T2_21_XX || dcttype == DCT_T2_24_XX ); +#endif } else { @@ -2470,7 +2592,11 @@ void dctT2_N_apply_matrix( mat_step_col = 1; mat_step_row = matrix_row_dim; mat_step_col_flag = 0; +#ifdef ERI_SNSVQ_ROMOPT + assert( dcttype == IDCT_T2_XX_16 || dcttype == IDCT_T2_XX_24 ); +#else assert( dcttype == IDCT_T2_XX_24 ); +#endif } pt_y = tmp_y; @@ -2547,8 +2673,11 @@ void extend_dctN_input( } } - +#ifdef ERI_SNSVQ_ROMOPT +/* inititate idctN DCT_MAXTRUNC x N matrix in RAM from a quantized compressed ROM format */ +#else /* inititate idct24 FDCNG_VQ_DCT_MAXTRUNCx N matrix in RAM from a quantized compressed ROM format */ +#endif void create_IDCT_N_Matrix( float *inv_matrixFloatQ, const int16_t N, const int16_t n_cols, const int16_t alloc_size ) { int16_t c, c1, r, r_flip, W16_val; @@ -2558,6 +2687,9 @@ void create_IDCT_N_Matrix( float *inv_matrixFloatQ, const int16_t N, const int16 const Word8 *idx_ptr; Word16 idx; float( *ptr )[FDCNG_VQ_DCT_MAXTRUNC] = (void *) inv_matrixFloatQ; /* fixed number of columns pointers, to simplifies adressing in ANSIC */ +#ifdef ERI_SNSVQ_ROMOPT + float( *ptrM )[M] = (void *) inv_matrixFloatQ; /* fixed number of columns pointers, to simplifies adressing in ANSIC */ +#endif absval_ptr = unique_idctT2_24coeffsQ16; idx_ptr = idctT2_24_compressed_idx; @@ -2569,6 +2701,14 @@ void create_IDCT_N_Matrix( float *inv_matrixFloatQ, const int16_t N, const int16 idx_ptr = idctT2_21_compressed_idx; len = N; } +#ifdef ERI_SNSVQ_ROMOPT + if ( N == M ) + { + absval_ptr = unique_idctT2_16coeffsQ16; + idx_ptr = idctT2_16_compressed_idx; + len = N; + } +#endif assert( alloc_size >= ( n_cols * len ) ); /* enough space for the full expanded IDCT matrix */ assert( N <= len ); @@ -2596,21 +2736,45 @@ void create_IDCT_N_Matrix( float *inv_matrixFloatQ, const int16_t N, const int16 flip symmetry for odd, even is used to save 50% IDCT Table ROM */ /* for an odd DCT center is not flipped e.g for DCT21 */ +#ifdef ERI_SNSVQ_ROMOPT + assert( n_cols == FDCNG_VQ_DCT_MAXTRUNC || n_cols == M ); +#else assert( n_cols == FDCNG_VQ_DCT_MAXTRUNC ); +#endif assert( ( n_cols & 1 ) == 0 ); + for ( c = 0; c < ( n_cols ); c += 2 ) { c1 = c + 1; r_flip = len - 1; - for ( r = 0; r < ( len / 2 ); r++, r_flip-- ) +#ifdef ERI_SNSVQ_ROMOPT + if ( n_cols == M ) + { + for ( r = 0; r < ( len / 2 ); r++, r_flip-- ) + { +#define WMC_TOOL_SKIP + ptrM[r_flip][c] = ptrM[r][c]; /* flipped */ + ptrM[r_flip][c1] = -( ptrM[r][c1] ); /* flipped and sign swapped */ + MOVE( 2 ); + MULT( 1 ); /* for negate */ +#undef WMC_TOOL_SKIP + } + } + else { +#endif + for ( r = 0; r < ( len / 2 ); r++, r_flip-- ) + { #define WMC_TOOL_SKIP - ptr[r_flip][c] = ptr[r][c]; /* flipped */ - ptr[r_flip][c1] = -( ptr[r][c1] ); /* flipped and sign swapped */ - MOVE( 2 ); - MULT( 1 ); /* for negate */ + ptr[r_flip][c] = ptr[r][c]; /* flipped */ + ptr[r_flip][c1] = -( ptr[r][c1] ); /* flipped and sign swapped */ + MOVE( 2 ); + MULT( 1 ); /* for negate */ #undef WMC_TOOL_SKIP + } +#ifdef ERI_SNSVQ_ROMOPT } +#endif } } diff --git a/lib_com/options.h b/lib_com/options.h index a8c5bdd0ef9d2605bc8d5b3ca62d172c8b434d6f..c527103a671f751f7583ec955576011baa861901 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -173,14 +173,17 @@ #define EUALER2QUAT_FIX /* Dlb :fix for issue 430 issue in euler2quat, sign of quat y is inverted */ #define HR_METADATA /* Nok: encode directional MASA metadata with more bits at 384k and 512k */ -#define SBA_TD_RESIDUAL /* Dlb : Issue 426: SBA encoder complexity optimization */ #define FIX_357_DTX_32K /* Eri: issue 357 - Forced LP-CNG at 32k */ #define FIX_435_ISM_MERGE_BUG /* Eri: Merge bug fix for ISM NULL metadata and tcx_only cases */ #define FIX_355_REFACTOR_PARAMBIN_TO_5MS /* Nokia: Fixes issue 355 by refactoring parametric binauralizer code to 5 ms mode */ #define FIX_411_EVS_BE_TESTS_ON_WINDOWS_FAILING /* Eri: Fix incorrect use of stack variable used for channel aware config file */ #define COMBINED_FORMAT_SIGNALING /* VA: Introduce a signaling bit for combined format coding */ + #define FIX_386_CORECODER_RECONFIG_2 /* VA: Issue 386: Resolve remaining ToDo comments in CoreCoder reconfig. */ + + + #define FIX_440_PARAM_ISM_DIR_NOISE /* FhG: Issue 440: Fix directional background noise becoming diffuse in ParamISM */ #define FIX_445_SNS_BUGFIXES /* FhG: bug fix for spectral tilt in SNS computation + necessary update of codebooks and converison to fixedpoint-compatible tables */ @@ -188,6 +191,9 @@ #define FIX_447_PARAMBIN_MASA_REGU_FAC /* Nokia: Issue 447: Fix issue by adjusting regularization factor minimum value. */ #define FIX_441_SBA_PARAMBIN_GAINS /* Nokia: Fix issue 441 by changing gains in SBA path of parametric binauralizer */ - /* ################## End DEVELOPMENT switches ######################### */ +#define ERI_SNSVQ_ROMOPT /* Eri: 445 Table ROM OPT for SNS-VQ at 48 kbps reusing DCT-N code from FDCNG-MSVQ */ +//#define SNS_MSVQ_DEBUG /* measure SD */ + +/* ################## End DEVELOPMENT switches ######################### */ /* clang-format on */ #endif diff --git a/lib_com/prot.h b/lib_com/prot.h index 69bcaa6647e5993a78d229b349a279ab79e90b4d..37cce4c8d8bbd09b174df12890c9eb75f28e1d2f 100644 --- a/lib_com/prot.h +++ b/lib_com/prot.h @@ -8086,6 +8086,29 @@ void dec_FDCNG_MSVQ_stage1( Word16 *uq_ind /* o: synthesized stage1 vector in BASOP */ ); + +#ifdef ERI_SNSVQ_ROMOPT +void dec_SNS_FDCNG_MSVQ_DCT_stage1( + const int16_t n_segm, /* i: */ + const int16_t *cum_entries_per_segment, /* i: */ + const Word8 *const *stage1_W8Qx_dct_sections, /* i: */ + const int16_t *cols_per_segment, /* i: */ + const int16_t *const *dct_col_syn_shift, /* i: */ + + const int16_t max_trunc, /* i: */ + const float *dct_scaleF, /* i: */ + const float *midQ_truncQ, /* i: */ + + int16_t j_full, /* i: index full range */ + int16_t n, /* i: dimension to generate */ + int16_t maxN, /* i: codebook storage/synthesis dimension */ + const float *invTrfMatrix, /* i: IDCT matrix for synthesis */ + const DCTTYPE idcttype, /* i: specify which IDCT */ + float *uq, /* o: synthesized stage1 vector */ + Word16 *uq_ind /* o: synthesized stage1 vector in BASOP */ +); +#endif + void create_IDCT_N_Matrix( float *inv_matrixFloatQ, /* i/o: RAM buffer */ const int16_t N, /* i: DCT length , number of time samples */ @@ -8129,15 +8152,20 @@ int16_t msvq_stage1_dct_search( /* o const Word16 *trunc_dct_cols_per_segment, /* i: trunc length per segment */ const Word16 *entries_per_segment, /* i: number of rows per segment */ const Word16 *cum_entries_per_segment, /* i: number of cumulative entries */ - const Word8 *const W8Qx_dct_sections[], /*i: Word8(byte) segment table ptrs */ - const Word16 *col_syn_shift[], /*i: columnwise syn shift tables */ - const Word8 *segm_neighbour_fwd, /*i: circular neighbour list fwd */ - const Word8 *segm_neighbour_rev, /*i: circular neighbour list reverse */ - const Word16 npost_check, /*i: number of neigbours to check , should be even */ - float *st1_mse_ptr, /*i: dynRAM buffer for MSEs */ - int16_t *indices_st1_local, /*o: selected cand indices */ - float *st1_syn_vec_ptr, /*i/o: buffer for IDCT24 synthesis */ - float *dist1_ptr /*o: resulting stage 1 MSEs in DCT-N domain */ +#ifdef ERI_SNSVQ_ROMOPT + const Word8 *const *W8Qx_dct_sections, /*i: Word8(byte) segment table ptrs */ + const Word16 *const *col_syn_shift, /*i: columnwise syn shift tables */ +#else + const Word8 *const W8Qx_dct_sections[], /*i: Word8(byte) segment table ptrs */ + const Word16 *col_syn_shift[], /*i: columnwise syn shift tables */ +#endif + const Word8 *segm_neighbour_fwd, /*i: circular neighbour list fwd */ + const Word8 *segm_neighbour_rev, /*i: circular neighbour list reverse */ + const Word16 npost_check, /*i: number of neigbours to check , should be even */ + float *st1_mse_ptr, /*i: dynRAM buffer for MSEs */ + int16_t *indices_st1_local, /*o: selected cand indices */ + float *st1_syn_vec_ptr, /*i/o: buffer for IDCT24 synthesis */ + float *dist1_ptr /*o: resulting stage 1 MSEs in DCT-N domain */ ); int16_t msvq_stage1_dct_recalc_candidates_fdcng_wb( diff --git a/lib_com/rom_com.c b/lib_com/rom_com.c index 25a5d6ee9e2bc576521784a27abdc242d86344dd..f9c0c5138602fcce17e6196e527e6bdf52de95a4 100644 --- a/lib_com/rom_com.c +++ b/lib_com/rom_com.c @@ -6140,6 +6140,22 @@ const Word8 idctT2_21_compressed_idx[(FDCNG_VQ_DCT_MAXTRUNC *( (21/2) + 1)) /* }; /*low storage IDCT24x18 table && IDCT21*18 */ +#ifdef ERI_SNSVQ_ROMOPT +const Word16 unique_idctT2_16coeffsQ16[15]={ + 2271, 4520, 6726, 8867, 10922, 12873, 14699, 16384, + 17911, 19266, 20435, 21407, 22173, 22725, 23059 +}; +const Word8 idctT2_16_compressed_idx[256/2]={ + 7, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, + 7, 12, 9, 6, 3, 0, -1, -4, -7, -10, -13, -14, -11, -8, -5, -2, + 7, 10, 5, 0, -3, -8, -13, -12, -7, -2, 1, 6, 11, 14, 9, 4, + 7, 8, 1, -4, -11, -12, -5, 0, 7, 14, 9, 2, -3, -10, -13, -6, + 7, 6, -1, -10, -11, -2, 5, 14, 7, 0, -9, -12, -3, 4, 13, 8, + 7, 4, -5, -14, -3, 6, 13, 2, -7, -12, -1, 8, 11, 0, -9, -10, + 7, 2, -9, -8, 3, 14, 1, -10, -7, 4, 13, 0, -11, -6, 5, 12, + 7, 0, -13, -2, 11, 4, -9, -6, 7, 8, -5, -10, 3, 12, -1, -14 +}; +#endif diff --git a/lib_com/rom_com.h b/lib_com/rom_com.h index 0d0f319e1df667cd86b34a47282db7ee282357ce..57f9a477c5bfafe1c1983edd89bf70f56f49cecd 100644 --- a/lib_com/rom_com.h +++ b/lib_com/rom_com.h @@ -1162,6 +1162,10 @@ extern const Word8 idctT2_24_compressed_idx[]; extern const Word16 unique_idctT2_21coeffsQ16[]; extern const Word8 idctT2_21_compressed_idx[]; +#ifdef ERI_SNSVQ_ROMOPT +extern const Word16 unique_idctT2_16coeffsQ16[]; +extern const Word8 idctT2_16_compressed_idx[]; +#endif extern const float idctT2_24_X_matrixFloatQ[]; diff --git a/lib_debug/snr.c b/lib_debug/snr.c index f6e6fa9d5219bbb0d41e3394571bd770794bc97a..89f84a1346eccbca44e128e3b1b18f6f0942fa6e 100644 --- a/lib_debug/snr.c +++ b/lib_debug/snr.c @@ -79,6 +79,16 @@ static float mem_deemph_y[MAX_INPUT_CHANNELS] = { 0 }; static float mem_synth_snr[MAX_INPUT_CHANNELS][M]; +#ifdef SNS_MSVQ_DEBUG +#define N_PCT ( 5 ) +static double pctlims[N_PCT] = { 1.0, 1.5, 2.0, 3.0, 4.0 }; /* dB limits*/ + +static int32_t acc_sd_out_pct[N_PCT][N_SNRPTR]; /*0 -> 4dB */ +static double acc_sd[N_SNRPTR]; +static double wc_sd[N_SNRPTR]; +static int32_t wc_sd_frame[N_SNRPTR]; +#endif + /*-------------------------------------------------------------------* * Local functions - they are copies of functions declared in prot.h but here we do not want to include prot.h due to its dependencies @@ -230,7 +240,138 @@ static void weight_a( * certain string. The signal is input in segments having certain length, * for which a global SNR, segmental SNR and weighted segmental SNR is computed. *--------------------------------------------------------------------*/ +#ifdef SNS_MSVQ_DEBUG +void snr( + const float *const signal, + const float *const noise, + const int16_t length, + const char *const name ) +{ + int16_t index, i; + double signal_sumsq, noise_sumsq, frame_snr, seg_en; + double noise_lin[MAX_SIGNAL_LENGTH]; + double noise_dB[MAX_SIGNAL_LENGTH]; + double noise_sumsq_sd; + + + index = lookup( name, (const char *const *) snr_name, snr_count ); + if ( index == -1 ) + { + index = snr_count; + signal_energy[index] = 0; + noise_energy[index] = 0; + acc_seg_snr[index] = 0; + seg_count[index] = 0; + acc_wseg_snr[index] = 0; + wseg_count[index] = 0; + snr_name[index] = malloc( sizeof( char ) * ( strlen( name ) + 1 ) ); + strcpy( snr_name[index], name ); + snr_count++; + + if ( strncmp( "SD", name, 2 ) == 0 ) + { + /* reset distribution of outliers stats */ + acc_sd[index] = 0.0; + for ( i = 0; i < N_PCT; i++ ) + { + acc_sd_out_pct[i][index] = 0; + } + wc_sd[index] = 0; + wc_sd_frame[index] = -1; + ; + } + } + + signal_sumsq = sum2_f( signal, length ) + 0.001f; + noise_sumsq = sum2_f( noise, length ) + 0.001f; + if ( signal_sumsq < noise_sumsq ) + signal_sumsq = noise_sumsq; + + + frame_snr = 10 * log10( signal_sumsq / noise_sumsq ); + seg_en = 10 * log10( signal_sumsq / length ); + if ( seg_en < 0.0 ) + seg_en = 0.0; + signal_energy[index] += signal_sumsq; + noise_energy[index] += noise_sumsq; + acc_seg_snr[index] += frame_snr; + seg_count[index]++; + acc_wseg_snr[index] += frame_snr * seg_en; + wseg_count[index] += seg_en; + + if ( strncmp( "SD", name, 2 ) == 0 ) + { + double sd, base; + base = 0.0; /* assume linear domain input noise values */ + if ( strncmp( "SD2", name, 3 ) == 0 ) + { + base = 2.0; /* assuming log2 domain input deltanoise values*/ + } + if ( strncmp( "SD10", name, 4 ) == 0 ) + { + base = 10.0; /* assuming log10 domain input deltanoise values*/ + } + + noise_sumsq_sd = 0.0001; + if ( base != 0.0 ) + { + if ( base == 10.0 ) + { + /* assume log10 has been applied already */ + /* convert to log10(x) to 10*log10(x) */ + for ( i = 0; i < length; i++ ) + { + noise_lin[i] = (double) noise[i]; /* dB ratio */ + noise_dB[i] = 10.0 * ( noise_lin[i] ); + noise_sumsq_sd += noise_dB[i] * noise_dB[i]; /* SD summed up in 10log10 domain */ + } + } + else + { + /* assume log2 has been applied already */ + /* convert to log2(x) to 10*log10(x) */ + for ( i = 0; i < length; i++ ) + { + noise_lin[i] = (double) noise[i]; /*dB ratio */ + noise_dB[i] = 3.010299956639812 * ( noise_lin[i] ); + noise_sumsq_sd += noise_dB[i] * noise_dB[i]; /* SD summed up in 10log10 domain */ + } + } + } + else + { /* ,assume noise is already in 10log10() domain , i.e a dB(in log10) difference */ + for ( i = 0; i < length; i++ ) + { + noise_lin[i] = (double) noise[i]; + noise_dB[i] = ( noise_lin[i] ); + noise_sumsq_sd += noise_dB[i] * noise_dB[i]; /* SD summed up in 10log10 domain */ + } + } + /* measure SD(RMS noise energy in 10log10 dB) stats , useful for a spectral parameters already in a log domain */ + /* RMS over full band , 100 = 10^2 in sqrt(1/N *sum( [10log10( P/P*)]^2, full band), P is input power spectra, P* is distored power spectra */ + sd = (double) sqrt( ( noise_sumsq_sd ) / (double) length ); /* RMS calc for SD */ + + acc_sd[index] += sd; + for ( i = 0; i < N_PCT; i++ ) + { + if ( sd > pctlims[i] ) + { + acc_sd_out_pct[i][index]++; + } + } + if ( sd > wc_sd[index] ) + { + wc_sd[index] = sd; +#ifdef DEBUGGING + wc_sd_frame[index] = frame; +#endif + } + } + + return; +} +#else void snr( const float *const signal, const float *const noise, @@ -273,7 +414,7 @@ void snr( return; } - +#endif /*-------------------------------------------------------------------* * snr_diff() @@ -425,8 +566,14 @@ void snr_celp( void print_snr() { +#ifdef SNS_MSVQ_DEBUG + int16_t i, j; + double snr, segsnr, wsegsnr; + double tot_sd, tot_out_pct[N_PCT]; +#else int16_t i; double snr, segsnr, wsegsnr; +#endif if ( snr_count > 0 ) { @@ -434,10 +581,54 @@ void print_snr() for ( i = 0; i < snr_count; i++ ) { +#ifdef SNS_MSVQ_DEBUG + if ( ( seg_count[i] > 0 ) && ( strncmp( "SD", snr_name[i], 2 ) == 0 ) ) + { + tot_sd = acc_sd[i] / seg_count[i]; + for ( j = 0; j < N_PCT; j++ ) + { + tot_out_pct[j] = (double) acc_sd_out_pct[j][i] / (double) seg_count[i] * 100.0; + } + } + else + { + tot_sd = 0.0; + for ( j = 0; j < N_PCT; j++ ) + { + tot_out_pct[j] = 0.0; + } + } + + + snr = 10 * log10( signal_energy[i] / ( noise_energy[i] + 0.0001f ) ); + segsnr = acc_seg_snr[i] / ( seg_count[i] + 0.0001f ); + wsegsnr = acc_wseg_snr[i] / ( wseg_count[i] + 0.0001f ); + + if ( strncmp( "SD", snr_name[i], 2 ) == 0 ) + + { + double secs_all, secs, mins; /* SD = noise energy statistics assuming SNR input is in a dB domain : 10log10 , log10 or log2 */ + fprintf( stdout, "%-31s, %6.3f dB(SegSnr), %5.3f dB(Ave.SD), SD-outl:", snr_name[i], segsnr, tot_sd ); + for ( j = 0; j < N_PCT; j++ ) + { + fprintf( stdout, ",(>%2.1fdB:%.1f%%)", pctlims[j], tot_out_pct[j] ); + } + secs_all = (double) wc_sd_frame[i] / 50.0; + mins = floor( secs_all / 60.0 ); + secs = secs_all - 60.0 * mins; + fprintf( stdout, ", (SD-wc: %5.3f frame=%d %dm:%.2fs)", wc_sd[i], wc_sd_frame[i], (int) mins, secs ); + fprintf( stdout, ", cnt:%d \n", seg_count[i] ); + } + else + { + fprintf( stdout, "%-31s %6.3f dB SNR %6.3f dB SegSNR %6.3f dB WSegSNR\n", snr_name[i], snr, segsnr, wsegsnr ); + } +#else snr = 10 * log10( signal_energy[i] / ( noise_energy[i] + 0.0001f ) ); segsnr = acc_seg_snr[i] / ( seg_count[i] + 0.0001f ); wsegsnr = acc_wseg_snr[i] / ( wseg_count[i] + 0.0001f ); fprintf( stdout, "%-22s %6.3f dB SNR %6.3f dB SegSNR %6.3f dB WSegSNR\n", snr_name[i], snr, segsnr, wsegsnr ); +#endif } fprintf( stdout, "\n" ); } diff --git a/lib_dec/ivas_sns_dec.c b/lib_dec/ivas_sns_dec.c index 4812091ecc5aff53331660c12bb35f2d2f38b112..99a1c587665ea06864ddabbee582db33feb7a008 100644 --- a/lib_dec/ivas_sns_dec.c +++ b/lib_dec/ivas_sns_dec.c @@ -333,6 +333,12 @@ void dequantize_sns( int16_t sns_stereo_mode[NB_DIV]; int16_t zero_side_flag[NB_DIV]; Decoder_State *st; +#ifdef ERI_SNSVQ_ROMOPT + float *invTrfMatrix; + float tmpRAM[M][M]; /* 16*16 */ + invTrfMatrix = (float *) tmpRAM; /* dynamically filled */ + create_IDCT_N_Matrix( invTrfMatrix, M, M, sizeof( tmpRAM ) / ( sizeof( float ) ) ); /* always create/set up IDCT16 matrix in RAM */ +#endif sns_stereo_mode[0] = indices[0][0]; sns_stereo_mode[1] = indices[0][1]; @@ -375,7 +381,11 @@ void dequantize_sns( } else { +#ifdef ERI_SNSVQ_ROMOPT + msvq_dec( cdbks, NULL, NULL, nStages, M, M, &indices[ch][idxIndices + SNS_STEREO_MODE_OFFSET_INDICES], 20 >> ( nSubframes - 1 ), invTrfMatrix, snsQ, NULL ); /*tcx20,tcx10 and/or fdcng(!=0) signalled via applyDCTflag*/ +#else msvq_dec( cdbks, NULL, NULL, nStages, M, M, &indices[ch][idxIndices + SNS_STEREO_MODE_OFFSET_INDICES], 0, NULL, snsQ, NULL ); +#endif } idxIndices += nStages; } diff --git a/lib_enc/ivas_sns_enc.c b/lib_enc/ivas_sns_enc.c index 7a93e335f21b775e1dda2463edc3391db354585f..dfa450661c5eac3c7affdce187e5887fa8d7d14e 100644 --- a/lib_enc/ivas_sns_enc.c +++ b/lib_enc/ivas_sns_enc.c @@ -515,6 +515,16 @@ int16_t quantize_sns( const float *means; #endif +#ifdef SNS_MSVQ_DEBUG + float sns_inbuf[M]; +#endif +#ifdef ERI_SNSVQ_ROMOPT + float *invTrfMatrix; + float tmpRAM[M][M]; /*16*16*/ + invTrfMatrix = (float *) tmpRAM; /* dynamically filled */ + create_IDCT_N_Matrix( invTrfMatrix, M, M, sizeof( tmpRAM ) / ( sizeof( float ) ) ); /*always create/set up IDCT16 matrix in RAM */ +#endif + nbits = 0; idxIndices = 0; set_f( weights, 1.0f, M ); @@ -611,6 +621,7 @@ int16_t quantize_sns( } #endif + for ( ch = 0; ch < CPE_CHANNELS; ++ch ) { st = sts[ch]; @@ -652,8 +663,42 @@ int16_t quantize_sns( } else { +#ifdef SNS_MSVQ_DEBUG + mvr2r( sns_ptr, sns_inbuf, M ); /* remember input for SD calc */ +#endif +#ifdef ERI_SNSVQ_ROMOPT + msvq_enc( cdbks, NULL, NULL, sns_ptr, levels, 3, nStages, weights, M, M, 20 >> ( nSubframes - 1 ), invTrfMatrix, &indices[idxIndices] ); /*tcx20,tcx10 or fdcngvq signaled via applyDCTflag*/ + msvq_dec( cdbks, NULL, NULL, nStages, M, M, &indices[idxIndices], 20 >> ( nSubframes - 1 ), invTrfMatrix, snsQ, NULL ); +#else msvq_enc( cdbks, NULL, NULL, sns_ptr, levels, 3, nStages, weights, M, M, 0, NULL, &indices[idxIndices] ); msvq_dec( cdbks, NULL, NULL, nStages, M, M, &indices[idxIndices], 0, NULL, snsQ, NULL ); +#endif + +#ifdef SNS_MSVQ_DEBUG + { + char vq_name[2 * 1024]; + char v[2 * 1024]; + int16_t nC; /* nCandidates */ + int16_t tcx = ( nSubframes == 1 ) ? 20 : 10; +#ifdef ERI_SNSVQ_ROMOPT + sprintf( v, "ERI_Tcx%d", tcx ); + nC = 3; +#else + sprintf( v, "BSL_Tcx%d", tcx ); + nC = 3; +#endif + if ( sns_stereo_mode[ch] == 0 ) + { + sprintf( vq_name, "SD2_%s_Mid_Ch%dsub%dSt%dnC%d", v, ch, k, nStages, nC ); + } + else + { + sprintf( vq_name, "SD2_%s_LR_Ch%dsub%dSt%dnC%d", v, ch, k, nStages, nC ); + } + + snr_diff( sns_inbuf, snsQ, M, 0, vq_name ); + } +#endif } idxIndices += nStages; diff --git a/lib_enc/lsf_msvq_ma_enc.c b/lib_enc/lsf_msvq_ma_enc.c index 0f7a798a75a8971530b55965a1ae43a7cb1b5a64..fcdc4534a1466d79053ffc11e90036eb6bfa540b 100644 --- a/lib_enc/lsf_msvq_ma_enc.c +++ b/lib_enc/lsf_msvq_ma_enc.c @@ -46,14 +46,15 @@ #include "basop_proto_func.h" #include "wmc_auto.h" +#ifdef ERI_SNSVQ_ROMOPT +#include "ivas_rom_com.h" +#endif + #define kMaxC 8 #include "ivas_prot.h" -// void dctT2_N_apply_matrix( const float *input, float *output, const int16_t dct_dim, int16_t fdcngvq_dim, const float *idctT2_24_X_matrixQ16, const int16_t matrix_1st_dim, DCTTYPE dcttype ); - - #ifdef ERI_MSVQ_CLEANUP int16_t msvq_stage1_dct_search( @@ -76,12 +77,16 @@ int16_t msvq_stage1_dct_search( const Word16 *trunc_dct_cols_per_segment, /* i: trunc length per segment */ const Word16 *entries_per_segment, /* i: number of rows per segment */ const Word16 *cum_entries_per_segment, /* i: number of cumulative entries */ - +#ifdef ERI_SNSVQ_ROMOPT + const Word8 *const *W8Qx_dct_sections, /*i: Word8(byte) segment table ptrs */ + const Word16 *const *col_syn_shift, /*i: columnwise syn shift tables */ +#else const Word8 *const W8Qx_dct_sections[], /*i: Word8(byte) segment table ptrs */ const Word16 *col_syn_shift[], /*i: columnwise syn shift tables */ - const Word8 *segm_neighbour_fwd, /*i: circular neighbour list fwd */ - const Word8 *segm_neighbour_rev, /*i: circular neighbour list reverse */ - const Word16 npost_check, /*i: number of neigbours to check , should be even */ +#endif + const Word8 *segm_neighbour_fwd, /*i: circular neighbour list fwd */ + const Word8 *segm_neighbour_rev, /*i: circular neighbour list reverse */ + const Word16 npost_check, /*i: number of neigbours to check , should be even */ float *st1_mse_ptr, /*i: dynRAM buffer for MSEs */ int16_t *indices_st1_local, /*o: selected cand indices */ @@ -124,7 +129,12 @@ int16_t msvq_stage1_dct_search( dctT2_N_apply_matrix( (const float *) u_mr_scaled, dct_target, min( max_dct_trunc, n_ana ), n_ana, invTrfMatrix, max_dct_trunc, dcttype ); /* init search state ptr's at the top */ +#ifdef ERI_SNSVQ_ROMOPT + set_f( dist1_ptr, FLT_MAX, n_segm * 2 ); + set_s( indices_st1_local, 0, n_segm * 2 ); /* debug init */ +#else set_f( dist1_ptr, FLT_MAX, maxC_st1 ); +#endif st1_mse_pair = &( dist1_ptr[0] ); /* req. ptr post upd +=2 */ st1_idx_pair = &( indices_st1_local[0] ); /* req. ptr post upd +=2 */ set_f( mse_trunc_segm, 0.0f, n_segm ); @@ -196,7 +206,11 @@ int16_t msvq_stage1_dct_search( } /* next segment */ +#ifdef ERI_SNSVQ_ROMOPT + for ( j = 0; j < ( n_segm * 2 ); j++ ) +#else for ( j = 0; j < maxC_st1; j++ ) +#endif { /* compute_full mse using stored DCT24 domain MSE's */ /* calculate MSE from stage1 inner using existing inner DCT domain variables */ @@ -206,8 +220,39 @@ int16_t msvq_stage1_dct_search( assert( ( maxC_st1 >= 3 ) ); assert( ( maxC_st1 <= 8 ) ); +#ifdef ERI_SNSVQ_ROMOPT + /* compress the 2*n_segm candidate list if maxC_st1 is lower than 2*n_segm */ + if ( maxC_st1 < 2 * n_segm ) + { + float dist1_ptr_full_tmp[2 * FDCNG_VQ_DCT_NSEGM]; + int16_t indices_st1_local_full_tmp[2 * FDCNG_VQ_DCT_NSEGM]; + + + mvr2r( dist1_ptr, dist1_ptr_full_tmp, 2 * n_segm ); + mvs2s( indices_st1_local, indices_st1_local_full_tmp, 2 * n_segm ); + + for ( j = 0; j < maxC_st1; j++ ) + { + c2 = minimum( dist1_ptr_full_tmp, 2 * n_segm, NULL ); /* find best entry among all 2*n_segm entries */ + + dist1_ptr[j] = dist1_ptr_full_tmp[c2]; /* move32() */ + indices_st1_local[j] = indices_st1_local_full_tmp[c2]; /* move16() */ + dist1_ptr_full_tmp[c2] = FLT_MAX; /* exclude */ + } + +#ifdef DEBUGGING + for ( j = maxC_st1; j < 2 * n_segm; j++ ) + { + dist1_ptr[j] = FLT_MAX; + indices_st1_local[j] = -1; + } +#endif + } +#endif + p_max = maximum( dist1_ptr, maxC_st1, NULL ); /* establish current worst candidate for MSVQ stage#2 among all maxC_st1 candidates so far */ + p_mins[0] = minimum( dist1_ptr, maxC_st1, NULL ); /* find best entry among all maxC_pre */ tmp = dist1_ptr[p_mins[0]]; dist1_ptr[p_mins[0]] = FLT_MAX; /* exclude 1st */ @@ -260,6 +305,18 @@ int16_t msvq_stage1_dct_search( /* always extract full length signal(e.g. 24) to be able to update WB(e.g. N_in==21) candidate MSE values */ /* in the case that only a part of the IDCT N vector is in final use */ + +#ifdef ERI_SNSVQ_ROMOPT + + assert( N == 24 || N == M ); + for ( c = 0; c < maxC_st1; c++ ) + { + dec_SNS_FDCNG_MSVQ_DCT_stage1( + n_segm, cum_entries_per_segment, W8Qx_dct_sections, + cols_per_segment, col_syn_shift, max_dct_trunc, dct_scaleF, midQ_truncQ, + indices_st1_local[c], N, N, invTrfMatrix, dcttype + 1, &( st1_syn_vec_ptr[c * N] ), NULL ); + } +#else /* note: synthesis not yet fully parameterized/generalized for other IDCT lengths */ assert( N == 24 ); { @@ -268,6 +325,7 @@ int16_t msvq_stage1_dct_search( dec_FDCNG_MSVQ_stage1( indices_st1_local[c], N, invTrfMatrix, dcttype + 1, &( st1_syn_vec_ptr[c * N] ), NULL ); } } +#endif return p_max; /*ptr to worst performing candidate */ } @@ -363,6 +421,25 @@ void msvq_enc( float *st1_mse_ptr; /* ptr to buffer in existing dRAM used for stage 1 candidate analysis */ #ifdef ERI_MSVQ_CLEANUP int16_t indices_st1_local[FDCNG_VQ_DCT_NSEGM * 2]; /* after stage#1 DCT search this is copied to the global indices[1][s*stages] structure */ + +#ifdef ERI_SNSVQ_ROMOPT + int16_t tcx_ind = -1; + + if ( applyDCT_flag && N == M && cb[0] == NULL && levels[0] == ( 1 << 7 ) ) + { + if ( applyDCT_flag == 20 ) + { + assert( stages == SNS_MSVQ_NSTAGES_TCX20 ); + tcx_ind = TCX_20_CORE - 1; /* = 0 , tcx20 tables */ + } + if ( applyDCT_flag == 10 ) + { + assert( stages == SNS_MSVQ_NSTAGES_TCX10 ); + tcx_ind = TCX_10_CORE - 1; /* == 1, tcx10 tables */ + } + } +#endif + #else float res24, high_diff[FDCNG_VQ_MAX_LEN - FDCNG_VQ_MAX_LEN_WB]; maxC_pre = ( FDCNG_VQ_DCT_NSEGM * 2 ); @@ -379,7 +456,6 @@ void msvq_enc( dcttype = DCT_T2_24_XX; #endif - /*----------------------------------------------------------------* * Allocate memory for previous (parent) and current nodes. * Parent node is indexed [0], current node is indexed [1]. @@ -465,28 +541,60 @@ void msvq_enc( #ifdef ERI_MSVQ_CLEANUP if ( !s && applyDCT_flag != 0 ) /* means: m==1 */ { - /* stage 1 candidates search in truncated dct24 domain without any weights */ - assert( N == FDCNG_VQ_MAX_LEN || N == FDCNG_VQ_MAX_LEN_WB ); /* 21 and 24 allowed */ - assert( maxC == 2 * FDCNG_VQ_DCT_NSEGM ); - - p_max = msvq_stage1_dct_search( u, FDCNG_VQ_MAX_LEN, maxC, - DCT_T2_24_XX, - FDCNG_VQ_DCT_MAXTRUNC, - invTrfMatrix, /* i : IDCT synthesis matrix for dim N */ - cdk1r_tr_midQ_truncQ, /* i: midQ vector */ - fdcng_dct_invScaleF, /* i: global inv scale factors*/ - fdcng_dct_scaleF, /* i: global scale factors*/ - FDCNG_VQ_DCT_NSEGM, /* i: number of segments */ - cdk1_ivas_cols_per_segment, /* i: remaining length per segment */ - cdk1_ivas_trunc_dct_cols_per_segment, /* i: trunc length per segment */ - cdk1_ivas_entries_per_segment, /* i: number of rows per segment */ - cdk1_ivas_cum_entries_per_segment, /* i: number of cumulative entries */ - cdk_37bits_ivas_stage1_W8Qx_dct_sections, /*i: Word8(byte) segment table ptrs */ - stage1_dct_col_syn_shift, /*i: columnwise syn shift tables */ - cdk1_ivas_segm_neighbour_fwd, /*i: circular neighbour list fwd */ - cdk1_ivas_segm_neighbour_rev, /*i: circular neighbour list reverse */ - FDCNG_VQ_DCT_NPOST, /*i: number of circ. neigbours to post check */ - st1_mse_ptr, indices_st1_local, st1_syn_vec_ptr, dist[1] ); +#ifdef ERI_SNSVQ_ROMOPT + if ( N == M ) + { + /* SNS-VQ stage 1 candidates search in truncated DCT16 (M==16) domain without weighting */ + assert( N == M ); /* only 16 allowed for SNS */ + assert( maxC <= 2 * FDCNG_VQ_DCT_NSEGM ); + p_max = msvq_stage1_dct_search( u, M, maxC, + DCT_T2_16_XX, + M, + invTrfMatrix, /* i : IDCT synthesis matrix for dim N */ + snsSt1_tr_midQ_truncQ[tcx_ind], /* i: midQ vector */ + snsSt1_dct_invScaleF[tcx_ind], /* i: global inv scale factors*/ + snsSt1_dct_scaleF[tcx_ind], /* i: global scale factors*/ + snsSt1_dct_n_segm[tcx_ind], /* i: number of segments */ + snsSt1_dct_cols_per_segment[tcx_ind], /* i: remaining length per segment */ + snsSt1_trunc_dct_cols_per_segment[tcx_ind], /* i: trunc length per segment */ + snsSt1_entries_per_segment[tcx_ind], /* i: number of rows per segment */ + snsSt1_cum_entries_per_segment[tcx_ind], /* i: number of cumulative entries */ + snsSt1_stage1_W8Qx_dct_sections[tcx_ind], /*i: Word8(byte) segment table ptrs */ + snsSt1_dct_col_syn_shift[tcx_ind], /*i: columnwise syn shift tables */ + snsSt1_segm_neighbour_fwd[tcx_ind], /*i: circular neighbour list fwd */ + snsSt1_segm_neighbour_rev[tcx_ind], /*i: circular neighbour list reverse */ + snsSt1_npost[tcx_ind], /*i: number of circ. neigbours to post check */ + st1_mse_ptr, indices_st1_local, st1_syn_vec_ptr, dist[1] ); + } + else + { /* FDCNG_VQ stage1 */ +#endif + /* stage 1 candidates search in truncated dct24 domain without any weights */ + assert( N == FDCNG_VQ_MAX_LEN || N == FDCNG_VQ_MAX_LEN_WB ); /* 21 and 24 allowed */ + assert( maxC == 2 * FDCNG_VQ_DCT_NSEGM ); + + p_max = msvq_stage1_dct_search( u, FDCNG_VQ_MAX_LEN, maxC, + DCT_T2_24_XX, + FDCNG_VQ_DCT_MAXTRUNC, + invTrfMatrix, /* i : IDCT synthesis matrix for dim N */ + cdk1r_tr_midQ_truncQ, /* i: midQ vector */ + fdcng_dct_invScaleF, /* i: global inv scale factors*/ + fdcng_dct_scaleF, /* i: global scale factors*/ + FDCNG_VQ_DCT_NSEGM, /* i: number of segments */ + cdk1_ivas_cols_per_segment, /* i: remaining length per segment */ + cdk1_ivas_trunc_dct_cols_per_segment, /* i: trunc length per segment */ + cdk1_ivas_entries_per_segment, /* i: number of rows per segment */ + cdk1_ivas_cum_entries_per_segment, /* i: number of cumulative entries */ + cdk_37bits_ivas_stage1_W8Qx_dct_sections, /*i: Word8(byte) segment table ptrs */ + stage1_dct_col_syn_shift, /*i: columnwise syn shift tables */ + cdk1_ivas_segm_neighbour_fwd, /*i: circular neighbour list fwd */ + cdk1_ivas_segm_neighbour_rev, /*i: circular neighbour list reverse */ + FDCNG_VQ_DCT_NPOST, /*i: number of circ. neigbours to post check */ + st1_mse_ptr, indices_st1_local, st1_syn_vec_ptr, dist[1] ); + +#ifdef ERI_SNSVQ_ROMOPT + } +#endif /* move established stage#1 indices to the global MSVQ list structure */ @@ -653,6 +761,7 @@ void msvq_enc( dec_FDCNG_MSVQ_stage1( indices_st1_local[c], FDCNG_VQ_MAX_LEN, invTrfMatrix, dcttype + 1, &( st1_syn_vec_ptr[c * FDCNG_VQ_MAX_LEN] ), NULL ); } + assert( maxC == maxC_pre ); } #endif @@ -661,7 +770,7 @@ void msvq_enc( if ( !s ) /* means: m==1 */ { /* This loop is identical to the one below, except, that the inner - loop over c=0..m is hardcoded to c=0, since m=1. */ + loop over c=0..m is hardcoded to c=0, since m=1. */ /* dist[0][0] */ for ( j = 0; j < levels[s]; j++ ) { @@ -765,7 +874,12 @@ void msvq_enc( p2 = cb_stage + ( indices[1][c * stages + s] ) * maxn; /* regular ptr init */ if ( s == 0 && applyDCT_flag != 0 ) { +#ifdef ERI_SNSVQ_ROMOPT + assert( maxn == FDCNG_VQ_MAX_LEN /*(FDCNG syn length)*/ || maxn == M /*(SNS synlength)*/ ); + p2 = (const float *) &( st1_syn_vec_ptr[c * maxn] ); /*ptr init of stage 1 */ +#else p2 = (const float *) &( st1_syn_vec_ptr[c * FDCNG_VQ_MAX_LEN] ); /*ptr init of stage 1 */ +#endif } mvr2r( p1, pTmp, start );