From 40c0ac869bf675fe7bfd2174473aa761e5bb1f4d Mon Sep 17 00:00:00 2001 From: Jonas Sv Date: Fri, 5 May 2023 18:53:19 +0200 Subject: [PATCH 1/9] added all SNS-VQ stage1 DCT16 encoder side code, decoder and tables still to be added --- lib_com/cnst.h | 4 + lib_com/ivas_rom_com.c | 70 +++++++++- lib_com/ivas_rom_com.h | 16 +++ lib_com/lsf_tools.c | 138 +++++++++++++++++-- lib_com/options.h | 4 + lib_com/prot.h | 27 ++++ lib_com/rom_com.c | 16 +++ lib_com/rom_com.h | 4 + lib_enc/ivas_sns_enc.c | 14 ++ lib_enc/lsf_msvq_ma_enc.c | 270 ++++++++++++++++++++++++-------------- 10 files changed, 452 insertions(+), 111 deletions(-) diff --git a/lib_com/cnst.h b/lib_com/cnst.h index 261ef6f907..79e42b7fe4 100644 --- a/lib_com/cnst.h +++ b/lib_com/cnst.h @@ -1403,6 +1403,10 @@ typedef enum _DCTTYPE 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 4016fdfe17..a1da6a2d8c 100644 --- a/lib_com/ivas_rom_com.c +++ b/lib_com/ivas_rom_com.c @@ -5597,6 +5597,8 @@ const int16_t ivas_sns_cdbks_tcx20_levels[SNS_MSVQ_NSTAGES_TCX20] = { 128, 64, 3 const int16_t ivas_sns_cdbks_tcx20_bits[SNS_MSVQ_NSTAGES_TCX20] = { 7, 6, 5, 5 }; /* 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, @@ -5727,6 +5729,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, @@ -5862,8 +5866,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, @@ -5874,6 +5881,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, @@ -6004,6 +6012,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, @@ -6049,7 +6059,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, @@ -6058,6 +6072,60 @@ const float ivas_sns_means_tcx10[M] = { -0.4801f , -0.4108f , -0.4564f , -0.6112f }; +#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] = { 0 }; +const float snsSt1_tr_midQ_truncQ_tcx10[M]={ 0 }; +const float *const snsSt1_tr_midQ_truncQ[2]= {snsSt1_tr_midQ_truncQ_tcx20, snsSt1_tr_midQ_truncQ_tcx10}; + +const float snsSt1_dct_invScaleF_tcx20[3] = {0 }; +const float snsSt1_dct_invScaleF_tcx10[3] = {0 }; +const float *const snsSt1_dct_invScaleF[2]= { snsSt1_dct_invScaleF_tcx20, snsSt1_dct_invScaleF_tcx10}; + +const float snsSt1_dct_scaleF_tcx20[3] = {0 }; +const float snsSt1_dct_scaleF_tcx10[3] = {0 }; +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]= { 0 }; +const int16_t snsSt1_dct_cols_per_segment_tcx10[4]= { 0 }; +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]= { 0 }; +const int16_t snsSt1_trunc_dct_cols_per_segment_tcx10[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}; +const int16_t snsSt1_cum_entries_per_segment_tcx10[5]={0}; +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]={0}; +const int16_t snsSt1_entries_per_segment_tcx10[4]={0}; +const int16_t *const snsSt1_entries_per_segment[2]={ snsSt1_entries_per_segment_tcx20 ,snsSt1_entries_per_segment_tcx10}; + +const Word8 *const snsSt1_stage1_W8Qx_dct_sections_tcx20[4]={0}; +const Word8 *const snsSt1_stage1_W8Qx_dct_sections_tcx10[4]={0}; +const Word8 *const* snsSt1_stage1_W8Qx_dct_sections[2]={snsSt1_stage1_W8Qx_dct_sections_tcx20, snsSt1_stage1_W8Qx_dct_sections_tcx10 }; + +const Word16 *const snsSt1_dct_col_syn_shift_tcx20[4]={0}; +const Word16 *const snsSt1_dct_col_syn_shift_tcx10[4]={0}; +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]={0}; +const Word8 snsSt1_segm_neighbour_fwd_tcx10[128]={0}; +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]={0}; +const Word8 snsSt1_segm_neighbour_rev_tcx10[128]={0}; +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, 4}; /*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 }; 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 174435448a..4fe8a52e37 100644 --- a/lib_com/ivas_rom_com.h +++ b/lib_com/ivas_rom_com.h @@ -420,6 +420,22 @@ extern const float *const ivas_sns_cdbks_tcx10[]; extern const float ivas_sns_means_tcx20[]; extern const float ivas_sns_means_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 */ + extern const int16_t ivas_sns_cdbks_side_tcx20_levels[]; extern const int16_t ivas_sns_cdbks_side_tcx20_bits[]; extern const int16_t ivas_sns_cdbks_side_tcx10_levels[]; diff --git a/lib_com/lsf_tools.c b/lib_com/lsf_tools.c index 02a735e80c..5ce306eb59 100644 --- a/lib_com/lsf_tools.c +++ b/lib_com/lsf_tools.c @@ -245,7 +245,7 @@ void isp2a( *-----------------------------------------------------------------*/ get_isppol( &isp[0], f1, nc ); - get_isppol( &isp[1], f2, (int16_t) ( nc - 1 ) ); + get_isppol( &isp[1], f2, ( int16_t )( nc - 1 ) ); /*-----------------------------------------------------------------* * Multiply F2(z) by (1 - z^-2) * @@ -2027,6 +2027,74 @@ 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 */ + 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( n ==M || n == NPART ); + + 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 */ @@ -2138,7 +2206,8 @@ void msvq_dec( } if ( i == 0 && applyIDCT_flag != 0 ) - { + { + assert( 0 && "IDCT16 code here" ); 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 */ } @@ -2153,7 +2222,7 @@ void msvq_dec( FOR( j = 0; j < n; ++j ) { move16(); - uq_ind[start + j] = add( uq_ind[start + j], (Word16) ( cb[i][Idx[i] * maxn + j] * 2.0f * 1.28f ) ); + uq_ind[start + j] = add( uq_ind[start + j], ( Word16 )( cb[i][Idx[i] * maxn + j] * 2.0f * 1.28f ) ); } } #undef WMC_TOOL_SKIP @@ -2420,7 +2489,7 @@ void a2isf( spec2isf( RealOut, ImagOut, 128, isf, old_isf ); - isf[lpcOrder - 1] = (Float32) ( acos( a[lpcOrder] ) * SCALE1_HALF ); + isf[lpcOrder - 1] = ( Float32 )( acos( a[lpcOrder] ) * SCALE1_HALF ); return; } @@ -2460,7 +2529,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 +2543,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 +2624,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 +2638,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 +2652,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 ); @@ -2582,7 +2673,7 @@ void create_IDCT_N_Matrix( float *inv_matrixFloatQ, const int16_t N, const int16 for ( c = 0; c < mat_cpy_size; c++ ) { - idx = (Word16) ( idx_ptr[c] ); + idx = ( Word16 )( idx_ptr[c] ); W16_val = absval_ptr[abs( idx )]; if ( idx < 0 ) @@ -2596,21 +2687,46 @@ 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 - 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 */ + 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 */ +#undef WMC_TOOL_SKIP + } +#ifdef ERI_SNSVQ_ROMOPT + } +#endif } } diff --git a/lib_com/options.h b/lib_com/options.h index d841a798e2..2b5716b276 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -172,6 +172,10 @@ #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 ERI_SNSVQ_ROMOPT /* BASOP ROM OPT store added SNS VQ stage 1 tables in DCT16 domain, as for FDCNGVQ stage 1 */ + /* ################## End DEVELOPMENT switches ######################### */ /* clang-format on */ #endif diff --git a/lib_com/prot.h b/lib_com/prot.h index 69bcaa6647..b894981785 100644 --- a/lib_com/prot.h +++ b/lib_com/prot.h @@ -8086,6 +8086,28 @@ 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 */ + 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,8 +8151,13 @@ 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 */ +#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 */ diff --git a/lib_com/rom_com.c b/lib_com/rom_com.c index 9c2b49bca2..0e78801a98 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 3ea7a7f4c3..996d3ff83c 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_enc/ivas_sns_enc.c b/lib_enc/ivas_sns_enc.c index c4f20841f3..7ae8720846 100644 --- a/lib_enc/ivas_sns_enc.c +++ b/lib_enc/ivas_sns_enc.c @@ -397,6 +397,12 @@ int16_t quantize_sns( float weights[M]; const float *means; float sns_buffer[CPE_CHANNELS][NB_DIV][M]; +#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; @@ -451,6 +457,8 @@ int16_t quantize_sns( } } + + for ( ch = 0; ch < CPE_CHANNELS; ++ch ) { st = sts[ch]; @@ -488,8 +496,14 @@ int16_t quantize_sns( } else { +#ifdef ERI_SNSVQ_ROMOPT + msvq_enc( cdbks, NULL, NULL, sns_ptr, levels, 3, nStages, weights, M, M, 1, invTrfMatrix, &indices[idxIndices] ); + msvq_dec( cdbks, NULL, NULL, nStages, M, M, &indices[idxIndices], 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 + } idxIndices += nStages; diff --git a/lib_enc/lsf_msvq_ma_enc.c b/lib_enc/lsf_msvq_ma_enc.c index 0f7a798a75..64878b7452 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 */ @@ -123,8 +128,13 @@ 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 */ + /* 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 ); @@ -260,6 +270,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, 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 +290,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 +386,23 @@ 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 ( stages == SNS_MSVQ_NSTAGES_TCX20 ) + { + tcx_ind = TCX_20_CORE - 1; /* = 0 , tcx20 tables */ + } + if ( 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 +419,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 +504,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,43 +724,93 @@ 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 else /* non-DCT Stage #1 code below */ if ( !s ) /* means: m==1 */ - { - /* This loop is identical to the one below, except, that the inner + { + /* 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. */ - /* dist[0][0] */ - for ( j = 0; j < levels[s]; j++ ) + /* dist[0][0] */ + for ( j = 0; j < levels[s]; j++ ) + { + en = 0.0f; + /* w,Tmp */ + /* Compute weighted codebook element and its energy */ + for ( c2 = 0; c2 < n; c2++ ) { - en = 0.0f; - /* w,Tmp */ - /* Compute weighted codebook element and its energy */ - for ( c2 = 0; c2 < n; c2++ ) + Tmp[start + c2] = w[start + c2] * cbp[c2]; + en += cbp[c2] * Tmp[start + c2]; + } + cbp += maxn; /* pointer is incremented */ + + pTmp = &resid[0][0]; + /* Tmp */ + tmp = ( *pTmp++ ) * Tmp[0]; + for ( c2 = 1; c2 < N; c2++ ) + { + tmp += ( *pTmp++ ) * Tmp[c2]; + } + tmp = en - 2.0f * tmp; + tmp += dist[0][0]; + if ( tmp < dist[1][p_max] ) + { + /* Replace worst */ + dist[1][p_max] = tmp; + indices[1][p_max * stages] = j; + parents[p_max] = 0; + + p_max = 0; + for ( c2 = 1; c2 < maxC; c2++ ) { - Tmp[start + c2] = w[start + c2] * cbp[c2]; - en += cbp[c2] * Tmp[start + c2]; + if ( dist[1][c2] > dist[1][p_max] ) + { + p_max = c2; + } } - cbp += maxn; /* pointer is incremented */ + } /* if (tmp <= dist[1][p_max]) */ + } /* for (j=0; j dist[1][p_max] ) - { - p_max = c2; - } - } - } /* if (tmp <= dist[1][p_max]) */ - } /* for(c=0; c Date: Mon, 8 May 2023 13:57:31 +0200 Subject: [PATCH 2/9] added BSL SD measurements --- lib_com/options.h | 3 +- lib_debug/snr.c | 193 ++++++++++++++++++++++++++++++++++++++++- lib_enc/ivas_sns_enc.c | 26 ++++++ 3 files changed, 220 insertions(+), 2 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 2b5716b276..e52d8f9f30 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -174,7 +174,8 @@ #define HR_METADATA /* Nok: encode directional MASA metadata with more bits at 384k and 512k */ -#define ERI_SNSVQ_ROMOPT /* BASOP ROM OPT store added SNS VQ stage 1 tables in DCT16 domain, as for FDCNGVQ stage 1 */ +//#define ERI_SNSVQ_ROMOPT /* BASOP ROM OPT store added SNS VQ stage 1 tables in DCT16 domain, as for FDCNGVQ stage 1 */ +#define SNS_MSVQ_DEBUG /* measure SD */ /* ################## End DEVELOPMENT switches ######################### */ /* clang-format on */ diff --git a/lib_debug/snr.c b/lib_debug/snr.c index f6e6fa9d52..1c32c0ed21 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_enc/ivas_sns_enc.c b/lib_enc/ivas_sns_enc.c index 7ae8720846..78766a2b20 100644 --- a/lib_enc/ivas_sns_enc.c +++ b/lib_enc/ivas_sns_enc.c @@ -504,6 +504,32 @@ int16_t quantize_sns( msvq_dec( cdbks, NULL, NULL, nStages, M, M, &indices[idxIndices], 0, NULL, snsQ, NULL ); #endif +#ifdef SNS_MSVQ_DEBUG + { + char vq_name[1024]; + char v[1024]; + int16_t nC; /* nCandidates */ + int16_t tcx = 10; + if ( nSubframes == 1) { + tcx = 20; + } + +#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_ptr, snsQ, M, 0, vq_name ); + } +#endif } idxIndices += nStages; -- GitLab From 93b6b2e1877050f1a301b65a5457237560434152 Mon Sep 17 00:00:00 2001 From: Jonas Sv Date: Mon, 8 May 2023 14:27:17 +0200 Subject: [PATCH 3/9] added tcx20 DCT tables --- lib_com/ivas_rom_com.c | 238 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 224 insertions(+), 14 deletions(-) diff --git a/lib_com/ivas_rom_com.c b/lib_com/ivas_rom_com.c index a1da6a2d8c..05fab392a9 100644 --- a/lib_com/ivas_rom_com.c +++ b/lib_com/ivas_rom_com.c @@ -6075,49 +6075,259 @@ const float ivas_sns_means_tcx10[M] = { #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] = { 0 }; -const float snsSt1_tr_midQ_truncQ_tcx10[M]={ 0 }; +/* v2d TCX20 97.3%, .55 maxmove + seg_trunc_lens = 12 14 16(16,16) + nElem = 14 16 98(49,49) +*/ + +/* v2d tcx10 788 Words . 99.5% , .55 mse_ maxmove + seg_trunc_lens = 8 10 12 16 + nElem = 13 34 41 40 */ + + +const float snsSt1_tr_midQ_truncQ_tcx20[M] = /* Q13 */ { + -6.522216796875000e-01f, -1.426513671875000e+00f, -1.277343750000000e+00f, -9.533691406250000e-01f, +1.857910156250000e-01f, -5.761718750000000e-02f, +8.435058593750000e-01f, -1.645507812500000e-01f, + -3.063964843750000e-02f, -1.065673828125000e-01f, +4.514160156250000e-01f, +2.604980468750000e-01f, +3.583984375000000e-01f, +6.871337890625000e-01f, +8.574218750000000e-01f, +1.024780273437500e+00f +}; + +const float snsSt1_tr_midQ_truncQ_tcx10[M]={ }; const float *const snsSt1_tr_midQ_truncQ[2]= {snsSt1_tr_midQ_truncQ_tcx20, snsSt1_tr_midQ_truncQ_tcx10}; -const float snsSt1_dct_invScaleF_tcx20[3] = {0 }; -const float snsSt1_dct_invScaleF_tcx10[3] = {0 }; + +/* +const float fdcng_dct_scaleF[3] = { 0.420288085937500f , (0.420288085937500f / 16.0f) , (0.420288085937500f * 0.420288085937500f) / (16.0f*16.0f) }; +const float fdcng_dct_invScaleF[2] = { 2.379272460937500f ,2.379272460937500f*16.0f }; +*/ + +const float snsSt1_dct_invScaleF_tcx20[2] = { 31977.0/2048.0, 31977.0/128.0, (31977.0/128.0)*(31977.0/128.0) }; /* Q11 invScale*/ +const float snsSt1_dct_invScaleF_tcx10[2] = { }; const float *const snsSt1_dct_invScaleF[2]= { snsSt1_dct_invScaleF_tcx20, snsSt1_dct_invScaleF_tcx10}; -const float snsSt1_dct_scaleF_tcx20[3] = {0 }; -const float snsSt1_dct_scaleF_tcx10[3] = {0 }; +const float snsSt1_dct_scaleF_tcx20[3] = { 16789.0/262144.0, (16789.0*16.0)/262144.0 }; /* Q18 */ +const float snsSt1_dct_scaleF_tcx10[3] = { }; 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]= { 0 }; -const int16_t snsSt1_dct_cols_per_segment_tcx10[4]= { 0 }; + +const int16_t snsSt1_dct_cols_per_segment_tcx20[4]= { 12, 14, 16, 16 }; + +const int16_t snsSt1_dct_cols_per_segment_tcx10[4]= { }; 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]= { 0 }; const int16_t snsSt1_trunc_dct_cols_per_segment_tcx10[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}; +const int16_t snsSt1_cum_entries_per_segment_tcx20[5]={ 0, 14, 30, 30+98/2, 128 }; const int16_t snsSt1_cum_entries_per_segment_tcx10[5]={0}; 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]={0}; +const int16_t snsSt1_entries_per_segment_tcx20[4]={ 14, 16, 98/2, 98/2 }; const int16_t snsSt1_entries_per_segment_tcx10[4]={0}; const int16_t *const snsSt1_entries_per_segment[2]={ snsSt1_entries_per_segment_tcx20 ,snsSt1_entries_per_segment_tcx10}; -const Word8 *const snsSt1_stage1_W8Qx_dct_sections_tcx20[4]={0}; + + +const Word8 /*seg 0, 14 x 12 */ sns_tcx20_dct_s0_W8Qx[168]={ + 0, -40, 119, -69, 59, -28, 99, -3, 98, -18, 35, 51, + 0, -25, -53, -13, -76, -15, -82, 46, 68, 40, -22, -60, + 0, -15, -122, -27, -47, -38, -72, -9, 25, -3, -6, 40, + 0, -1, -93, 75, 12, 21, 7, -9, 28, -17, -22, 100, + 0, 38, -121, -35, -63, -46, -87, -22, -1, -50, -24, 39, + 0, 46, -72, 74, 5, 14, 0, -10, 19, -32, -41, 73, + 0, 78, 78, 37, 81, 80, 36, -112, -18, 43, 34, 83, + 0, 79, 48, 14, -31, -86, -110, -27, -14, -60, -83, -63, + 0, 83, -112, -56, -54, -55, -67, -40, -14, -71, -54, -18, + 0, 89, 59, 37, 6, -15, -39, -2, -1, -65, -35, -3, + 0, 100, 54, 31, 5, 15, 39, 75, 52, -47, -30, 42, + 0, 107, -55, -45, -43, -54, -101, -63, -33, -92, -56, -12, + 0, 112, -38, 37, 8, -21, -39, -35, -23, -79, -41, -14, + 0, 122, 27, -28, -30, -40, -91, -41, -12, -80, -61, -38 +}; +const Word8 /*seg 1, 16 x 14 */ sns_tcx20_dct_s1_W8Qx[224]={ + 0, -82, -12, 3, -28, -11, -25, -18, -7, -48, -12, 35, 11, 29, + 0, -71, 11, 66, 0, 5, -8, -12, 41, -49, 11, 67, 26, 44, + 0, -69, 43, 84, -42, 9, -22, -21, -18, -53, -20, 17, 2, 18, + 0, -46, 25, 108, 34, 27, 2, 26, 31, -24, 7, 35, 22, 24, + 0, -44, -41, -47, -76, 7, 24, 78, -32, 32, -22, 2, 64, 25, + 0, -40, -27, 12, 24, 62, 46, 65, 35, 34, 4, 46, 29, 30, + 0, -32, -96, 56, 74, 9, -36, -9, -26, 63, 80, 9, -73, 58, + 0, -10, -53, -69, -100, 33, 90, -40, 18, -19, 73, 34, -54, -72, + 0, 8, -37, -47, -28, 25, 48, 93, 62, -17, -20, 18, 59, 51, + 0, 26, -62, -61, -74, -46, -34, 62, 115, 72, 19, 23, -34, -63, + 0, 35, 43, 97, 50, 26, 8, 36, 38, 3, 10, 40, 20, 34, + 0, 71, -2, 85, 35, -1, -16, 18, 14, -20, 0, 9, 5, 19, + 0, 78, 40, 76, 31, 4, -6, 24, 22, -5, 5, 28, 10, 28, + 0, 83, -1, 37, -8, -13, -20, -6, 8, -30, -10, 17, 4, 18, + 0, 85, 37, 29, 27, 99, 66, -3, -111, -28, -5, 94, 44, 14, + 0, 127, -7, -17, -17, -37, -27, -9, -5, -71, -22, 13, 14, 23 +}; +const Word8 /*seg 2, 98 x 16 */ sns_tcx20_dct_s2_W8Qx[1568]={ + 0, -127, 17, 49, -27, -4, -14, -11, -14, -17, -24, 36, 6, 28, -23, -48, + 0, -99, -41, 88, 8, -6, -32, -16, 6, -42, -18, 40, 5, 22, -24, -49, + 0, -93, 3, 81, -27, -27, -12, -6, -37, -26, -21, 23, 3, 30, -29, -52, + 0, -89, 39, 11, -12, -10, -31, -19, -16, -33, -27, 25, 2, 31, -25, -45, + 0, -82, 73, -31, 12, 50, -23, 85, 54, -12, 51, -56, 73, -32, 29, -42, + 0, -63, -47, 26, -8, -10, -34, -25, -5, -28, -26, 40, 9, 35, -22, -51, + 0, -59, -18, 93, 14, -34, -38, 1, -11, -50, -27, 25, 5, 14, -26, -45, + 0, -49, -11, -12, -60, -27, -81, 36, 65, 8, 80, 114, -37, 54, 92, -18, + 0, -47, -7, -4, -13, -23, -25, -5, -23, -29, -25, 32, 8, 37, -24, -48, + 0, -46, 74, 48, 17, 19, -14, 7, 12, -9, -12, 27, 9, 7, -19, -46, + 0, -39, 38, 14, -22, -18, -40, -41, -26, -46, -33, 1, -6, 12, -28, -48, + 0, -38, 6, 84, -26, -9, -19, -3, -11, -20, -6, 22, 4, 26, -21, -41, + 0, -33, 14, 48, 8, -4, -9, 3, 14, -17, -5, 26, 10, 22, -19, -40, + 0, -30, -12, 53, 14, -31, -39, -37, -26, -32, -31, 2, 2, 12, -29, -48, + 0, -28, 96, 13, 100, 23, 40, -4, 80, -55, 46, 7, 5, 72, -60, -17, + 0, -21, 49, 84, -30, 9, -28, -19, -8, -32, -20, 6, 3, 9, -21, -42, + 0, -18, -25, -24, -32, -41, -27, -22, -32, -12, -10, -4, 1, 26, -22, -44, + 0, -15, -37, 26, -33, -50, -5, -81, -10, -18, -17, -38, 38, 47, -57, -82, + 0, -15, 45, 64, 34, 7, 3, 27, 43, 6, 13, 39, 20, 35, -15, -39, + 0, -10, 12, 16, -39, -37, -27, 2, 9, -17, -20, 18, 7, 32, -15, -36, + 0, -7, 14, 93, 44, -2, -19, 21, 36, 13, 13, 31, 27, 27, -15, -37, + 0, -6, 32, 46, 9, -9, -13, 5, 22, -10, -2, 27, 13, 27, -19, -41, + 0, -6, -15, 21, -14, -13, -15, 14, 18, -5, -1, 42, 15, 28, -18, -38, + 0, -4, 21, 25, -1, -17, -20, -9, 9, -18, -10, 20, 9, 20, -21, -43, + 0, 0, 14, 93, 53, 0, -37, -40, -27, -41, -40, -17, -4, 3, -27, -46, + 0, 0, -1, -22, -31, -34, -50, -42, -40, -36, -19, -22, -14, 26, -29, -49, + 0, 3, 19, 76, -19, -10, -34, -46, -46, -49, -31, 6, 0, 14, -24, -45, + 0, 5, -2, 67, 12, -4, -19, 5, 11, -11, -5, 20, 8, 20, -19, -39, + 0, 9, -15, 11, -36, -22, -30, -26, 6, -24, -23, 6, -1, 6, -28, -44, + 0, 9, 3, 76, 27, -45, -70, -91, -52, -22, -66, -35, 4, -7, -32, -42, + 0, 11, -32, -18, -34, -21, -24, -18, -13, -22, -15, -1, 2, 14, -25, -40, + 0, 12, -49, 12, 84, 21, -24, -48, 77, 90, -14, -114, 28, 101, -6, -59, + 0, 13, 47, 16, -20, -21, -38, -30, -27, -42, -30, -9, -1, 9, -25, -45, + 0, 17, 14, 23, -17, -23, -27, -17, -2, -26, -17, 8, 3, 11, -23, -43, + 0, 17, 40, 53, 17, -3, -12, 4, 19, -12, -2, 25, 13, 25, -18, -41, + 0, 18, 16, 74, 14, 42, 22, 45, 18, -33, 16, 23, 28, 25, -13, -36, + 0, 19, 5, 23, 16, -2, -4, 18, 35, 5, 10, 41, 13, 16, -21, -45, + 0, 20, 2, 11, -24, -86, -37, -83, -67, 2, -80, 67, -13, -91, -40, -58, + 0, 20, -15, 28, 22, -24, -50, -70, -71, -39, -29, -19, -15, 12, -34, -44, + 0, 25, -2, 38, -14, -16, -26, 1, -3, -32, -14, 14, 3, 15, -21, -41, + 0, 28, -22, -2, -52, -55, -38, -31, -10, -38, -18, -4, 6, 13, -24, -40, + 0, 28, 59, 71, 6, -9, -22, -22, -7, -29, -19, -1, 4, 10, -21, -46, + 0, 31, -20, 29, -6, -7, -15, 21, 11, -18, -5, 18, 4, 17, -21, -39, + 0, 33, 23, 80, 12, -1, -12, 22, 19, -5, 1, 39, 14, 25, -16, -40, + 0, 33, 21, 48, 15, 8, -23, -69, -67, -50, -47, -8, 5, 17, -33, -54, + 0, 37, -14, 6, -50, -39, -53, -42, -30, -51, -25, -27, 4, -101, -92, -96, + 0, 38, 27, 71, 19, -22, -55, -62, -32, -44, -31, -14, 3, 23, -25, -43, + 0, 38, -6, 84, 72, -11, -71, -42, -50, -53, -32, -36, -31, 32, -22, -52, + 0, 39, 2, 63, 51, -21, -23, 18, 18, 15, 13, 10, 10, 17, -18, -40, + 0, 40, 36, 22, -4, -13, -14, 12, 28, 4, 7, 36, 15, 23, -17, -40, + 0, 40, -33, 11, -37, -25, -36, -15, -1, -23, -16, 9, -3, -1, -27, -45, + 0, 40, -2, 17, -20, -20, -28, -2, -2, -29, -13, 9, 2, 10, -21, -41, + 0, 41, 6, 41, 2, -10, -15, 22, 15, -21, -1, 24, 7, 19, -18, -39, + 0, 41, 1, -2, -32, -16, -34, -65, -63, -50, -28, 31, 25, 44, -34, -59, + 0, 41, 18, 32, -13, -22, -27, -2, -4, -35, -9, 11, 2, 15, -20, -38, + 0, 42, 21, -5, -56, -59, -41, -14, 5, -26, -47, -3, -3, 21, -23, -50, + 0, 44, 12, 2, 42, -49, -90, -55, -51, -34, -11, -45, 15, 37, -55, -19, + 0, 47, 7, 51, -35, -42, -48, -36, -27, -53, -49, -37, -16, -3, -28, -43, + 0, 48, -36, -108, -69, 47, 90, 53, 24, 101, 48, -111, -61, -78, 43, 96, + 0, 52, -36, -48, -2, -66, -62, 0, -31, -48, -12, 37, 3, 9, -34, -68, + 0, 54, 40, 29, -28, -20, -34, -27, -19, -47, -33, -1, -1, 15, -21, -43, + 0, 55, 55, 33, -35, -76, -70, -38, -13, -19, -30, -14, -11, 10, -35, -47, + 0, 56, 0, 23, 24, -51, 1, 112, -21, 17, 15, 42, 0, 41, -22, -44, + 0, 56, -12, 24, -4, -13, -21, 6, 7, -19, -7, 24, 6, 13, -20, -40, + 0, 57, 32, -31, 8, -38, -55, -38, -76, -54, -21, -28, 7, 20, -51, -45, + 0, 57, -10, -32, -29, -14, -6, 21, 57, 16, -2, -2, 2, 8, -28, -47, + 0, 58, -10, 31, 25, -7, -54, -24, -63, -101, -27, 24, -20, 53, -20, -77, + 0, 59, 10, 62, -9, -6, -28, -24, -8, -27, -21, 4, -2, 18, -24, -45, + 0, 61, 18, 27, -3, -3, -7, 11, 18, -8, 0, 26, 10, 24, -20, -41, + 0, 64, -27, 4, -23, -34, -61, -46, -51, -56, -23, -3, -2, 27, -25, -44, + 0, 65, 28, 55, 33, -6, -12, -9, 10, -27, -20, -14, -2, 0, -26, -43, + 0, 65, -22, 31, 45, -69, -46, -62, -115, -32, -31, 2, -5, 30, -38, -41, + 0, 65, 4, 2, -43, -41, -35, 3, -4, -42, -21, 15, 1, -16, -38, -53, + 0, 66, 14, 50, 51, 9, -51, -59, -28, -55, -24, 3, -9, 9, -16, -44, + 0, 66, 15, 11, -4, -16, -42, -51, -37, -60, -25, 18, 9, 28, -19, -47, + 0, 68, 65, 65, 8, -14, -23, -15, -1, -16, -11, 11, 6, 21, -25, -42, + 0, 70, 1, -65, -18, -27, -55, -2, -3, -69, 0, -64, 16, -12, -56, -41, + 0, 71, 52, 82, -20, -45, -65, -49, 14, -43, -16, 6, -28, -7, -34, -54, + 0, 74, -44, -17, -46, -57, -49, -9, -4, -36, -24, -21, -3, 0, -31, -52, + 0, 76, 1, -22, 19, -39, -51, -64, -94, -17, -16, 6, 5, 29, -41, -50, + 0, 76, 29, 61, -13, -5, -6, -108, -31, -13, -76, -21, -3, -12, -23, -64, + 0, 78, -15, -2, -31, -94, -68, 26, 11, -38, -23, 0, -25, 46, -13, -54, + 0, 78, 26, -8, -46, -32, -33, -24, -1, -26, -18, 8, 4, 16, -22, -44, + 0, 79, -26, 31, -28, -29, -37, -20, -2, -31, -26, -5, -2, 6, -26, -47, + 0, 80, -3, -33, -15, -82, -12, -28, -28, -18, -54, 18, -2, 33, -43, -65, + 0, 81, -48, -20, -1, -99, -25, -22, -79, -35, -22, 29, 5, 6, -45, -63, + 0, 88, 12, 57, 20, -22, -44, -45, -35, -45, -30, -58, -8, 51, -24, -60, + 0, 89, 41, 28, 15, -16, -55, -80, -25, -48, -36, -52, -4, 36, -37, -49, + 0, 93, 6, -10, -20, -16, -21, -12, 11, -16, -10, 10, 4, 13, -23, -42, + 0, 95, -40, 78, 24, -19, -1, -24, 3, -25, -27, 16, 5, 14, -17, -48, + 0, 95, 21, 38, -11, -65, -79, -23, 37, -38, -28, 7, -6, 9, -21, -45, + 0, 95, -5, 13, 47, -16, -55, -22, -49, -71, -9, 11, 4, 36, -18, -47, + 0, 99, -8, 13, -29, -43, -40, -49, -17, -39, -23, 0, -1, 6, -28, -43, + 0, 105, 7, 50, 37, -15, -19, 19, 7, -17, -9, -4, -5, 1, -27, -42, + 0, 105, 60, 28, -37, -44, -39, -32, -4, -28, -20, -9, -5, 1, -29, -44, + 0, 111, -30, -20, -2, -22, -7, 42, 45, 7, -15, -29, -9, -8, -35, -50, + 0, 116, 64, 56, 12, 4, -9, -12, -6, -22, -2, 11, -6, -11, -32, -46, + 0, 118, 19, 24, 4, -24, -33, -21, -1, -28, -9, 14, -3, 9, -21, -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_s2_W8Qx[1568/2]) }; + + const Word8 *const snsSt1_stage1_W8Qx_dct_sections_tcx10[4]={0}; const Word8 *const* snsSt1_stage1_W8Qx_dct_sections[2]={snsSt1_stage1_W8Qx_dct_sections_tcx20, snsSt1_stage1_W8Qx_dct_sections_tcx10 }; -const Word16 *const snsSt1_dct_col_syn_shift_tcx20[4]={0}; +const Word16 snsSt1_tcx20_stage1_col_syn_shift_segm0[12]={ + 0, 4, 3, 3, 3, 3, 2, 2, + 2, 1, 1, 0 +}; +const Word16 snsSt1_tcx20_stage1_col_syn_shift_segm1[14]={ + 0, 4, 4, 3, 3, 3, 3, 2, + 2, 1, 2, 1, 2, 1 +}; +const Word16 snsSt1_tcx20_stage1_col_syn_shift_segm2[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_segm2}; + const Word16 *const snsSt1_dct_col_syn_shift_tcx10[4]={0}; 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]={0}; + +const Word8 snsSt1_segm_neighbour_fwd_tcx20[128]= { + 44, 37, 23, 61, 60, 3, 28, 120, + 108, 100, 26, 8, 121, 29, 15, 17, + 33, 45, 21, 18, 19, 88, 1, 4, + 6, 97, 126, 116, 10, 125, 32, 35, + 31, 30, 39, 38, 20, 41, 14, 16, + 43, 42, 48, 36, 34, 40, 2, 52, + 65, 53, 54, 50, 57, 64, 59, 46, + 49, 66, 55, 56, 68, 47, 51, 79, + 71, 73, 63, 58, 77, 72, 80, 76, + 81, 24, 78, 70, 74, 25, 5, 90, + 93, 83, 69, 75, 82, 67, 94, 84, + 22, 111, 110, 62, 95, 102, 85, 106, + 104, 98, 92, 113, 103, 115, 122, 86, + 87, 107, 112, 91, 99, 101, 117, 114, + 7, 119, 11, 89, 96, 9, 0, 118, + 127, 109, 13, 27, 105, 12, 124, 123 +}; const Word8 snsSt1_segm_neighbour_fwd_tcx10[128]={0}; 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]={0}; + +const Word8 snsSt1_segm_neighbour_rev_tcx20[128]= { + 118, 22, 46, 5, 23, 78, 24, 112, + 11, 117, 28, 114, 125, 122, 38, 14, + 39, 15, 19, 20, 36, 18, 88, 2, + 73, 77, 10, 123, 6, 13, 33, 32, + 30, 16, 44, 31, 43, 1, 35, 34, + 45, 37, 41, 40, 0, 17, 55, 61, + 42, 56, 51, 62, 47, 49, 50, 58, + 59, 52, 67, 54, 4, 3, 91, 66, + 53, 48, 57, 85, 60, 82, 75, 64, + 69, 65, 76, 83, 71, 68, 74, 63, + 70, 72, 84, 81, 87, 94, 103, 104, + 21, 115, 79, 107, 98, 80, 86, 92, + 116, 25, 97, 108, 9, 109, 93, 100, + 96, 124, 95, 105, 8, 121, 90, 89, + 106, 99, 111, 101, 27, 110, 119, 113, + 7, 12, 102, 127, 126, 29, 26, 120 +}; + const Word8 snsSt1_segm_neighbour_rev_tcx10[128]={0}; const Word8 *const snsSt1_segm_neighbour_rev[2]={snsSt1_segm_neighbour_rev_tcx20 , snsSt1_segm_neighbour_rev_tcx10}; -- GitLab From 76ab3e5339ff726621d3e22e7ab30110b14857c7 Mon Sep 17 00:00:00 2001 From: Jonas Sv Date: Mon, 8 May 2023 15:12:32 +0200 Subject: [PATCH 4/9] added tcx10 SNSVQ DCT tables --- lib_com/ivas_rom_com.c | 225 +++++++++++++++++++++++++++++++++++++---- lib_com/options.h | 2 +- 2 files changed, 205 insertions(+), 22 deletions(-) diff --git a/lib_com/ivas_rom_com.c b/lib_com/ivas_rom_com.c index 05fab392a9..abdb29ca68 100644 --- a/lib_com/ivas_rom_com.c +++ b/lib_com/ivas_rom_com.c @@ -6090,37 +6090,34 @@ const float snsSt1_tr_midQ_truncQ_tcx20[M] = /* Q13 */ { -3.063964843750000e-02f, -1.065673828125000e-01f, +4.514160156250000e-01f, +2.604980468750000e-01f, +3.583984375000000e-01f, +6.871337890625000e-01f, +8.574218750000000e-01f, +1.024780273437500e+00f }; -const float snsSt1_tr_midQ_truncQ_tcx10[M]={ }; +const float snsSt1_tr_midQ_truncQ_tcx10[M]={ /* Q14 */ + -1.926879882812500e-01f, -8.222045898437500e-01f, -1.214416503906250e+00f, -5.881347656250000e-01f, +2.371215820312500e-01f, +6.344604492187500e-01f, +1.252441406250000e-01f, -3.415527343750000e-01f, + -2.136230468750000e-03f, +4.404907226562500e-01f, +5.527343750000000e-01f, +5.050659179687500e-01f, +3.703613281250000e-01f, +3.050537109375000e-01f, -5.877685546875000e-02f, +4.943847656250000e-02f +}; const float *const snsSt1_tr_midQ_truncQ[2]= {snsSt1_tr_midQ_truncQ_tcx20, snsSt1_tr_midQ_truncQ_tcx10}; -/* -const float fdcng_dct_scaleF[3] = { 0.420288085937500f , (0.420288085937500f / 16.0f) , (0.420288085937500f * 0.420288085937500f) / (16.0f*16.0f) }; -const float fdcng_dct_invScaleF[2] = { 2.379272460937500f ,2.379272460937500f*16.0f }; -*/ - -const float snsSt1_dct_invScaleF_tcx20[2] = { 31977.0/2048.0, 31977.0/128.0, (31977.0/128.0)*(31977.0/128.0) }; /* Q11 invScale*/ -const float snsSt1_dct_invScaleF_tcx10[2] = { }; +const float snsSt1_dct_invScaleF_tcx20[3] = { (float)(31977.0/2048.0), (float)(31977.0/128.0), (float)((31977.0/128.0)*(31977.0/128.0)) }; /* Q11 invScale*/ +const float snsSt1_dct_invScaleF_tcx10[3] = { (float)(30052.0/2048.0), (float)(30052.0/128.0), (float)((30052.0/128.0)*(30052.0/128.0)) }; /* Q11 invScale*/ const float *const snsSt1_dct_invScaleF[2]= { snsSt1_dct_invScaleF_tcx20, snsSt1_dct_invScaleF_tcx10}; -const float snsSt1_dct_scaleF_tcx20[3] = { 16789.0/262144.0, (16789.0*16.0)/262144.0 }; /* Q18 */ -const float snsSt1_dct_scaleF_tcx10[3] = { }; +const float snsSt1_dct_scaleF_tcx20[2] = { (float)(16789.0/262144.0), (float)((16789.0*16.0)/262144.0) }; /* Q18 for dctFscale */ +const float snsSt1_dct_scaleF_tcx10[2] = { (float)(17865.0/262144.0), (float)((17865.0*16.0)/262144.0) }; /* Q18 for dctFscale */ 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]= { 12, 14, 16, 16 }; - -const int16_t snsSt1_dct_cols_per_segment_tcx10[4]= { }; +const int16_t snsSt1_dct_cols_per_segment_tcx20[4]= { 12, 14, 16, 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]= { 0 }; -const int16_t snsSt1_trunc_dct_cols_per_segment_tcx10[4]= { 0 }; +const int16_t snsSt1_trunc_dct_cols_per_segment_tcx20[4]= { 4, 2, 0, 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, 14, 30, 30+98/2, 128 }; -const int16_t snsSt1_cum_entries_per_segment_tcx10[5]={0}; +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]={ 14, 16, 98/2, 98/2 }; @@ -6265,8 +6262,143 @@ const Word8 /*seg 2, 98 x 16 */ sns_tcx20_dct_s2_W8Qx[1568]={ }; 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_s2_W8Qx[1568/2]) }; - -const Word8 *const snsSt1_stage1_W8Qx_dct_sections_tcx10[4]={0}; +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, 57, + 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, -38, 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, -73, 72, -43, 41, -16, -1, -40, 79, -26, 81, -47, + 0, -56, -76, -27, 23, 107, -30, -17, -25, 35, 7, 108, + 0, -49, 6, 71, 41, -39, -47, 1, -1, 37, -68, -1, + 0, -48, 2, 34, 35, 7, -11, -34, 10, 70, 11, 26, + 0, -41, -11, -1, 25, -40, -59, -41, -4, 47, -33, -12, + 0, -33, 18, 25, 6, -49, -29, -51, -18, 10, -36, -18, + 0, -32, 36, 36, 25, -2, -14, -11, 14, 95, 13, 14, + 0, -27, -5, -35, -8, -72, -38, -57, -20, 16, -37, -21, + 0, -24, -29, 19, 40, -11, -26, -17, -9, 46, -20, -19, + 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, -2, 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, 12, -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, 59, 24, 18, + 0, 24, 33, 22, 18, -39, -25, -24, 15, 73, -19, -19, + 0, 25, 76, 40, 17, -7, -30, -46, 12, -16, 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, 68, 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, 77, 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, 12, 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, -104, -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[12]={ @@ -6283,7 +6415,24 @@ const Word16 snsSt1_tcx20_stage1_col_syn_shift_segm2[16]={ }; 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_segm2}; -const Word16 *const snsSt1_dct_col_syn_shift_tcx10[4]={0}; + +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 }; @@ -6305,7 +6454,24 @@ const Word8 snsSt1_segm_neighbour_fwd_tcx20[128]= { 7, 119, 11, 89, 96, 9, 0, 118, 127, 109, 13, 27, 105, 12, 124, 123 }; -const Word8 snsSt1_segm_neighbour_fwd_tcx10[128]={0}; +const Word8 snsSt1_segm_neighbour_fwd_tcx10[128]={ + 21, 78, 72, 44, 6, 87, 7, 11, + 10, 46, 86, 12, 9, 0, 13, 19, + 15, 14, 50, 91, 47, 55, 54, 49, + 30, 23, 27, 112, 101, 33, 63, 110, + 75, 34, 69, 38, 67, 96, 120, 45, + 79, 125, 40, 124, 82, 5, 126, 99, + 29, 93, 16, 18, 17, 57, 51, 102, + 52, 58, 103, 39, 107, 71, 116, 28, + 31, 66, 77, 26, 62, 105, 114, 68, + 100, 115, 70, 36, 32, 37, 83, 1, + 2, 119, 43, 122, 85, 3, 81, 8, + 89, 90, 108, 88, 98, 53, 24, 59, + 48, 92, 22, 95, 20, 97, 94, 61, + 106, 60, 56, 25, 127, 104, 111, 65, + 113, 118, 64, 109, 73, 74, 35, 42, + 117, 123, 41, 76, 80, 121, 84, 4 +}; const Word8 *const snsSt1_segm_neighbour_fwd[2]={snsSt1_segm_neighbour_fwd_tcx20 , snsSt1_segm_neighbour_fwd_tcx10}; @@ -6328,7 +6494,24 @@ const Word8 snsSt1_segm_neighbour_rev_tcx20[128]= { 7, 12, 102, 127, 126, 29, 26, 120 }; -const Word8 snsSt1_segm_neighbour_rev_tcx10[128]={0}; +const Word8 snsSt1_segm_neighbour_rev_tcx10[128]={ + 13, 79, 80, 85, 127, 45, 4, 6, + 87, 12, 8, 7, 11, 14, 17, 16, + 50, 52, 51, 15, 100, 0, 98, 25, + 94, 107, 67, 26, 63, 48, 24, 64, + 76, 29, 33, 118, 75, 77, 35, 59, + 42, 122, 119, 82, 3, 39, 9, 20, + 96, 23, 18, 54, 56, 93, 22, 21, + 106, 53, 57, 95, 105, 103, 68, 30, + 114, 111, 65, 36, 71, 34, 74, 61, + 2, 116, 117, 32, 123, 66, 1, 40, + 124, 86, 44, 78, 126, 84, 10, 5, + 91, 88, 89, 19, 97, 49, 102, 99, + 37, 101, 92, 47, 72, 28, 55, 58, + 109, 69, 104, 60, 90, 115, 31, 110, + 27, 112, 70, 73, 62, 120, 113, 81, + 38, 125, 83, 121, 43, 41, 46, 108 +}; 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, 4}; /*number of circ. neigbours to postcheck */ diff --git a/lib_com/options.h b/lib_com/options.h index e52d8f9f30..0fe578ae5e 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -174,7 +174,7 @@ #define HR_METADATA /* Nok: encode directional MASA metadata with more bits at 384k and 512k */ -//#define ERI_SNSVQ_ROMOPT /* BASOP ROM OPT store added SNS VQ stage 1 tables in DCT16 domain, as for FDCNGVQ stage 1 */ +#define ERI_SNSVQ_ROMOPT /* BASOP ROM OPT store added SNS VQ stage 1 tables in DCT16 domain, as for FDCNGVQ stage 1 */ #define SNS_MSVQ_DEBUG /* measure SD */ /* ################## End DEVELOPMENT switches ######################### */ -- GitLab From d59bbad9c6778d8bbcd8f3b25228dd1fb07f9586 Mon Sep 17 00:00:00 2001 From: Jonas Sv Date: Wed, 10 May 2023 14:03:26 +0200 Subject: [PATCH 5/9] initial SNSVQ ROM Optimized stage 1 MSVQ tables in DCT16 domain, saving approx 2kW TROM --- lib_com/cnst.h | 10 ++++++ lib_com/ivas_rom_com.c | 17 +++++---- lib_com/lsf_tools.c | 72 +++++++++++++++++++++++++++++++------ lib_com/options.h | 2 +- lib_com/prot.h | 1 + lib_dec/ivas_sns_dec.c | 11 +++++- lib_enc/ivas_sns_enc.c | 8 ++--- lib_enc/lsf_msvq_ma_enc.c | 76 ++++++++++++++++++++++++++++++--------- 8 files changed, 157 insertions(+), 40 deletions(-) diff --git a/lib_com/cnst.h b/lib_com/cnst.h index 79e42b7fe4..bcd162acd6 100644 --- a/lib_com/cnst.h +++ b/lib_com/cnst.h @@ -1397,6 +1397,16 @@ 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 */ diff --git a/lib_com/ivas_rom_com.c b/lib_com/ivas_rom_com.c index abdb29ca68..cde9869787 100644 --- a/lib_com/ivas_rom_com.c +++ b/lib_com/ivas_rom_com.c @@ -6097,12 +6097,17 @@ const float snsSt1_tr_midQ_truncQ_tcx10[M]={ /* Q14 */ const float *const snsSt1_tr_midQ_truncQ[2]= {snsSt1_tr_midQ_truncQ_tcx20, snsSt1_tr_midQ_truncQ_tcx10}; -const float snsSt1_dct_invScaleF_tcx20[3] = { (float)(31977.0/2048.0), (float)(31977.0/128.0), (float)((31977.0/128.0)*(31977.0/128.0)) }; /* Q11 invScale*/ -const float snsSt1_dct_invScaleF_tcx10[3] = { (float)(30052.0/2048.0), (float)(30052.0/128.0), (float)((30052.0/128.0)*(30052.0/128.0)) }; /* Q11 invScale*/ + + +/*const float fdcng_dct_invScaleF[2] = { 2.379272460937500f ,2.379272460937500f*16.0f }; */ +const float snsSt1_dct_invScaleF_tcx20[2] = { (float)(31977.0/2048.0), (float)(31977.0/128.0) }; /* Q11 invScale*/ +const float snsSt1_dct_invScaleF_tcx10[2] = { (float)(30052.0/2048.0), (float)(30052.0/128.0) }; /* Q11 invScale*/ const float *const snsSt1_dct_invScaleF[2]= { snsSt1_dct_invScaleF_tcx20, snsSt1_dct_invScaleF_tcx10}; -const float snsSt1_dct_scaleF_tcx20[2] = { (float)(16789.0/262144.0), (float)((16789.0*16.0)/262144.0) }; /* Q18 for dctFscale */ -const float snsSt1_dct_scaleF_tcx10[2] = { (float)(17865.0/262144.0), (float)((17865.0*16.0)/262144.0) }; /* Q18 for dctFscale */ + +/* const float fdcng_dct_scaleF[3] = { scaleF , (scaleF / 16.0f) , (scaleF*scaleF) / (16.0f*16.0f) } ; */ +const float snsSt1_dct_scaleF_tcx20[3] = { (float)(16789.0/262144.0), (float)((16789.0)/(262144.0*16.0)), (float)(((16789.0)/(262144.0*16.0))*((16789.0)/(262144.0*16.0))) }; /* Q18 for dctFscale */ +const float snsSt1_dct_scaleF_tcx10[3] = { (float)(17865.0/262144.0), (float)((17865.0)/(262144.0*16.0)), (float)(((17865.0)/(262144.0*16.0))*((17865.0)/(262144.0*16.0))) }; /* Q18 for dctFscale */ 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 }; @@ -6121,7 +6126,7 @@ const int16_t snsSt1_cum_entries_per_segment_tcx10[5]={ 0, 13, 47, 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]={ 14, 16, 98/2, 98/2 }; -const int16_t snsSt1_entries_per_segment_tcx10[4]={0}; +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}; @@ -6514,7 +6519,7 @@ const Word8 snsSt1_segm_neighbour_rev_tcx10[128]={ }; 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, 4}; /*number of circ. neigbours to postcheck */ +const int16_t snsSt1_npost[2]={8, 6}; /*number of circ. neigbours to postcheck */ #endif /* ERI_SNSVQ_ROMOPT */ diff --git a/lib_com/lsf_tools.c b/lib_com/lsf_tools.c index 5ce306eb59..af9fee1060 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 *-------------------------------------------------------------------*/ @@ -2042,6 +2047,8 @@ void dec_SNS_FDCNG_MSVQ_DCT_stage1( 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 */ @@ -2054,7 +2061,8 @@ void dec_SNS_FDCNG_MSVQ_DCT_stage1( const Word8 *cbpW8; const Word16 *dct_col_shift_tab; - assert( n ==M || n == NPART ); + 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++ ) @@ -2094,7 +2102,6 @@ void dec_SNS_FDCNG_MSVQ_DCT_stage1( } #endif - void dec_FDCNG_MSVQ_stage1( int16_t j_full, /* i: index full range */ int16_t n, /* i: dimension to generate */ @@ -2174,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; + int16_t *cum_entries_per_segment = (int16_t *) cdk1_ivas_cum_entries_per_segment; + Word8 *const *W8Qx_dct_sections = (Word8 *const *)cdk_37bits_ivas_stage1_W8Qx_dct_sections; + int16_t *cols_per_segment = (int16_t *)cdk1_ivas_cols_per_segment; + int16_t *const *col_syn_shift = (int16_t *const *)stage1_dct_col_syn_shift; + int16_t max_trunc = FDCNG_VQ_DCT_MAXTRUNC; + float *dct_scaleF = (float *)fdcng_dct_scaleF; + float *midQ_truncQ = (float *)cdk1r_tr_midQ_truncQ; +#endif set_zero( uq, N ); if ( uq_ind ) @@ -2206,10 +2225,42 @@ void msvq_dec( } if ( i == 0 && applyIDCT_flag != 0 ) - { - assert( 0 && "IDCT16 code here" ); + { +#ifdef ERI_SNSVQ_ROMOPT + if ( N == 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 = (int16_t*)snsSt1_cum_entries_per_segment[tcx_ind]; + W8Qx_dct_sections = (Word8 *const *) snsSt1_stage1_W8Qx_dct_sections[tcx_ind]; + cols_per_segment = (int16_t * )snsSt1_dct_cols_per_segment[tcx_ind]; + col_syn_shift = (int16_t *const *) snsSt1_dct_col_syn_shift[tcx_ind]; + max_trunc = SNS_VQ_DCT_MAXTRUNC; + dct_scaleF = (float *)snsSt1_dct_scaleF[tcx_ind]; + midQ_truncQ = (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 { @@ -2530,10 +2581,10 @@ void dctT2_N_apply_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_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 +#endif } else { @@ -2544,10 +2595,10 @@ void dctT2_N_apply_matrix( 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_16 || dcttype == IDCT_T2_XX_24 ); +#else assert( dcttype == IDCT_T2_XX_24 ); -#endif +#endif } pt_y = tmp_y; @@ -2711,7 +2762,6 @@ void create_IDCT_N_Matrix( float *inv_matrixFloatQ, const int16_t N, const int16 MULT( 1 ); /* for negate */ #undef WMC_TOOL_SKIP } - } else { diff --git a/lib_com/options.h b/lib_com/options.h index 0fe578ae5e..0c8d40bed2 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -175,7 +175,7 @@ #define ERI_SNSVQ_ROMOPT /* BASOP ROM OPT store added SNS VQ stage 1 tables in DCT16 domain, as for FDCNGVQ stage 1 */ -#define SNS_MSVQ_DEBUG /* measure SD */ +//#define SNS_MSVQ_DEBUG /* measure SD */ /* ################## End DEVELOPMENT switches ######################### */ /* clang-format on */ diff --git a/lib_com/prot.h b/lib_com/prot.h index b894981785..6738c99d61 100644 --- a/lib_com/prot.h +++ b/lib_com/prot.h @@ -8101,6 +8101,7 @@ void dec_SNS_FDCNG_MSVQ_DCT_stage1( 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 */ diff --git a/lib_dec/ivas_sns_dec.c b/lib_dec/ivas_sns_dec.c index 5e3c388437..ef53deeda8 100644 --- a/lib_dec/ivas_sns_dec.c +++ b/lib_dec/ivas_sns_dec.c @@ -251,6 +251,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]; @@ -284,12 +290,15 @@ void dequantize_sns( nStages = SNS_MSVQ_NSTAGES_SIDE; means = ( st->core == TCX_20_CORE ) ? ivas_sns_means_side_tcx20 : ivas_sns_means_side_tcx10; msvq_dec( side_cdbks, NULL, NULL, nStages, M, M, &indices[ch][idxIndices + SNS_STEREO_MODE_OFFSET_INDICES], 0, NULL, snsQ, NULL ); - v_add( snsQ, means, snsQ, M ); } 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 78766a2b20..8dbca70039 100644 --- a/lib_enc/ivas_sns_enc.c +++ b/lib_enc/ivas_sns_enc.c @@ -497,8 +497,8 @@ int16_t quantize_sns( else { #ifdef ERI_SNSVQ_ROMOPT - msvq_enc( cdbks, NULL, NULL, sns_ptr, levels, 3, nStages, weights, M, M, 1, invTrfMatrix, &indices[idxIndices] ); - msvq_dec( cdbks, NULL, NULL, nStages, M, M, &indices[idxIndices], 1, invTrfMatrix, snsQ, NULL ); + 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 ); @@ -506,8 +506,8 @@ int16_t quantize_sns( #ifdef SNS_MSVQ_DEBUG { - char vq_name[1024]; - char v[1024]; + char vq_name[2*1024]; + char v[2*1024]; int16_t nC; /* nCandidates */ int16_t tcx = 10; if ( nSubframes == 1) { diff --git a/lib_enc/lsf_msvq_ma_enc.c b/lib_enc/lsf_msvq_ma_enc.c index 64878b7452..6990f76198 100644 --- a/lib_enc/lsf_msvq_ma_enc.c +++ b/lib_enc/lsf_msvq_ma_enc.c @@ -128,13 +128,13 @@ 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 */ + /* 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, n_segm * 2 ); + set_s( indices_st1_local, 0, n_segm * 2 ); /* debug init */ +#else set_f( dist1_ptr, FLT_MAX, maxC_st1 ); -#endif +#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 ); @@ -206,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 */ @@ -216,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 */ @@ -270,18 +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, invTrfMatrix, dcttype + 1, &( st1_syn_vec_ptr[c * N] ), NULL ); - } -#else + 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 ); { @@ -392,12 +427,14 @@ void msvq_enc( if ( applyDCT_flag && N == M && cb[0] == NULL && levels[0] == ( 1 << 7 ) ) { - if ( stages == SNS_MSVQ_NSTAGES_TCX20 ) + if ( applyDCT_flag == 20 ) { + assert( stages == SNS_MSVQ_NSTAGES_TCX20 ); tcx_ind = TCX_20_CORE - 1; /* = 0 , tcx20 tables */ } - if ( stages == SNS_MSVQ_NSTAGES_TCX10 ) + if ( applyDCT_flag == 10 ) { + assert( stages == SNS_MSVQ_NSTAGES_TCX10 ); tcx_ind = TCX_10_CORE - 1; /* == 1, tcx10 tables */ } } @@ -837,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 ); -- GitLab From 0015f60e8ca3f5bd56a841a3ffe7bceb5f25d213 Mon Sep 17 00:00:00 2001 From: Jonas Sv Date: Wed, 10 May 2023 14:44:56 +0200 Subject: [PATCH 6/9] corrected gcc warnings in LSF_tools.c --- lib_com/lsf_tools.c | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/lib_com/lsf_tools.c b/lib_com/lsf_tools.c index af9fee1060..9cd239ad20 100644 --- a/lib_com/lsf_tools.c +++ b/lib_com/lsf_tools.c @@ -2185,13 +2185,13 @@ void msvq_dec( DCTTYPE dcttype = IDCT_T2_XX_24; int16_t tcx_ind = -1; int16_t n_segm = FDCNG_VQ_DCT_NSEGM; - int16_t *cum_entries_per_segment = (int16_t *) cdk1_ivas_cum_entries_per_segment; - Word8 *const *W8Qx_dct_sections = (Word8 *const *)cdk_37bits_ivas_stage1_W8Qx_dct_sections; - int16_t *cols_per_segment = (int16_t *)cdk1_ivas_cols_per_segment; - int16_t *const *col_syn_shift = (int16_t *const *)stage1_dct_col_syn_shift; + 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; - float *dct_scaleF = (float *)fdcng_dct_scaleF; - float *midQ_truncQ = (float *)cdk1r_tr_midQ_truncQ; + const float *dct_scaleF = (const float *) fdcng_dct_scaleF; + const float *midQ_truncQ = (const float *) cdk1r_tr_midQ_truncQ; #endif set_zero( uq, N ); @@ -2227,7 +2227,7 @@ void msvq_dec( if ( i == 0 && applyIDCT_flag != 0 ) { #ifdef ERI_SNSVQ_ROMOPT - if ( N == SNS_VQ_MAX_LEN ) + if ( maxN == SNS_VQ_MAX_LEN ) { dcttype = IDCT_T2_XX_16; tcx_ind = ( applyIDCT_flag==20 )? 0 : 1; /* 20-->0 && 10->>1 */ @@ -2241,16 +2241,13 @@ void msvq_dec( } #endif n_segm = SNS_VQ_DCT_NSEGM; - cum_entries_per_segment = (int16_t*)snsSt1_cum_entries_per_segment[tcx_ind]; - W8Qx_dct_sections = (Word8 *const *) snsSt1_stage1_W8Qx_dct_sections[tcx_ind]; - cols_per_segment = (int16_t * )snsSt1_dct_cols_per_segment[tcx_ind]; - col_syn_shift = (int16_t *const *) snsSt1_dct_col_syn_shift[tcx_ind]; + 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 = (float *)snsSt1_dct_scaleF[tcx_ind]; - midQ_truncQ = (float *)snsSt1_tr_midQ_truncQ[tcx_ind]; - - - + 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( -- GitLab From c24bd5350a790c2378fa42500de83b78a51ed23e Mon Sep 17 00:00:00 2001 From: Jonas Sv Date: Wed, 10 May 2023 15:26:14 +0200 Subject: [PATCH 7/9] clang format fixes --- lib_com/ivas_rom_com.h | 4 +- lib_com/lsf_tools.c | 27 +++---- lib_com/prot.h | 34 ++++----- lib_debug/snr.c | 2 +- lib_dec/ivas_sns_dec.c | 2 +- lib_enc/ivas_sns_enc.c | 38 +++++----- lib_enc/lsf_msvq_ma_enc.c | 154 +++++++++++++++++++------------------- 7 files changed, 132 insertions(+), 129 deletions(-) diff --git a/lib_com/ivas_rom_com.h b/lib_com/ivas_rom_com.h index 4fe8a52e37..c7355ae02f 100644 --- a/lib_com/ivas_rom_com.h +++ b/lib_com/ivas_rom_com.h @@ -425,7 +425,7 @@ 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_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[]; @@ -433,7 +433,7 @@ 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[]; +extern const int16_t snsSt1_npost[]; #endif /* ERI_SNSVQ_ROMOPT */ extern const int16_t ivas_sns_cdbks_side_tcx20_levels[]; diff --git a/lib_com/lsf_tools.c b/lib_com/lsf_tools.c index 9cd239ad20..dec680dd08 100644 --- a/lib_com/lsf_tools.c +++ b/lib_com/lsf_tools.c @@ -250,7 +250,7 @@ void isp2a( *-----------------------------------------------------------------*/ get_isppol( &isp[0], f1, nc ); - get_isppol( &isp[1], f2, ( int16_t )( nc - 1 ) ); + get_isppol( &isp[1], f2, (int16_t) ( nc - 1 ) ); /*-----------------------------------------------------------------* * Multiply F2(z) by (1 - z^-2) * @@ -2045,9 +2045,9 @@ void dec_SNS_FDCNG_MSVQ_DCT_stage1( 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 */ + 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 */ @@ -2185,8 +2185,8 @@ void msvq_dec( 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 *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; @@ -2230,18 +2230,19 @@ void msvq_dec( if ( maxN == SNS_VQ_MAX_LEN ) { dcttype = IDCT_T2_XX_16; - tcx_ind = ( applyIDCT_flag==20 )? 0 : 1; /* 20-->0 && 10->>1 */ + tcx_ind = ( applyIDCT_flag == 20 ) ? 0 : 1; /* 20-->0 && 10->>1 */ #ifdef DEBUGGING - if (tcx_ind == 0 ) { + if ( tcx_ind == 0 ) + { assert( stages == SNS_MSVQ_NSTAGES_TCX20 ); } else if ( tcx_ind == 1 ) { assert( stages == SNS_MSVQ_NSTAGES_TCX10 ); } -#endif +#endif n_segm = SNS_VQ_DCT_NSEGM; - cum_entries_per_segment = (const int16_t*)snsSt1_cum_entries_per_segment[tcx_ind]; + 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]; @@ -2270,7 +2271,7 @@ void msvq_dec( FOR( j = 0; j < n; ++j ) { move16(); - uq_ind[start + j] = add( uq_ind[start + j], ( Word16 )( cb[i][Idx[i] * maxn + j] * 2.0f * 1.28f ) ); + uq_ind[start + j] = add( uq_ind[start + j], (Word16) ( cb[i][Idx[i] * maxn + j] * 2.0f * 1.28f ) ); } } #undef WMC_TOOL_SKIP @@ -2537,7 +2538,7 @@ void a2isf( spec2isf( RealOut, ImagOut, 128, isf, old_isf ); - isf[lpcOrder - 1] = ( Float32 )( acos( a[lpcOrder] ) * SCALE1_HALF ); + isf[lpcOrder - 1] = (Float32) ( acos( a[lpcOrder] ) * SCALE1_HALF ); return; } @@ -2721,7 +2722,7 @@ void create_IDCT_N_Matrix( float *inv_matrixFloatQ, const int16_t N, const int16 for ( c = 0; c < mat_cpy_size; c++ ) { - idx = ( Word16 )( idx_ptr[c] ); + idx = (Word16) ( idx_ptr[c] ); W16_val = absval_ptr[abs( idx )]; if ( idx < 0 ) diff --git a/lib_com/prot.h b/lib_com/prot.h index 6738c99d61..37cce4c8d8 100644 --- a/lib_com/prot.h +++ b/lib_com/prot.h @@ -8089,11 +8089,11 @@ void dec_FDCNG_MSVQ_stage1( #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 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 *cols_per_segment, /* i: */ + const int16_t *const *dct_col_syn_shift, /* i: */ const int16_t max_trunc, /* i: */ const float *dct_scaleF, /* i: */ @@ -8106,8 +8106,8 @@ void dec_SNS_FDCNG_MSVQ_DCT_stage1( const DCTTYPE idcttype, /* i: specify which IDCT */ float *uq, /* o: synthesized stage1 vector */ Word16 *uq_ind /* o: synthesized stage1 vector in BASOP */ - ) ; -#endif +); +#endif void create_IDCT_N_Matrix( float *inv_matrixFloatQ, /* i/o: RAM buffer */ @@ -8154,18 +8154,18 @@ int16_t msvq_stage1_dct_search( /* o 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 */ + 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 */ + 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_debug/snr.c b/lib_debug/snr.c index 1c32c0ed21..89f84a1346 100644 --- a/lib_debug/snr.c +++ b/lib_debug/snr.c @@ -628,7 +628,7 @@ void print_snr() 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 +#endif } fprintf( stdout, "\n" ); } diff --git a/lib_dec/ivas_sns_dec.c b/lib_dec/ivas_sns_dec.c index ef53deeda8..c9324cea71 100644 --- a/lib_dec/ivas_sns_dec.c +++ b/lib_dec/ivas_sns_dec.c @@ -298,7 +298,7 @@ void dequantize_sns( 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 +#endif } idxIndices += nStages; } diff --git a/lib_enc/ivas_sns_enc.c b/lib_enc/ivas_sns_enc.c index 8dbca70039..4a287fa6a9 100644 --- a/lib_enc/ivas_sns_enc.c +++ b/lib_enc/ivas_sns_enc.c @@ -397,11 +397,11 @@ int16_t quantize_sns( float weights[M]; const float *means; float sns_buffer[CPE_CHANNELS][NB_DIV][M]; -#ifdef ERI_SNSVQ_ROMOPT +#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 */ + 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; @@ -457,7 +457,6 @@ int16_t quantize_sns( } } - for ( ch = 0; ch < CPE_CHANNELS; ++ch ) { @@ -497,8 +496,8 @@ int16_t quantize_sns( else { #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 ); + 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 ); @@ -506,28 +505,31 @@ int16_t quantize_sns( #ifdef SNS_MSVQ_DEBUG { - char vq_name[2*1024]; - char v[2*1024]; + char vq_name[2 * 1024]; + char v[2 * 1024]; int16_t nC; /* nCandidates */ int16_t tcx = 10; - if ( nSubframes == 1) { + if ( nSubframes == 1 ) + { tcx = 20; } #ifdef ERI_SNSVQ_ROMOPT - sprintf( v, "ERI_Tcx%d",tcx ); + 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_ptr, snsQ, M, 0, vq_name ); + 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_ptr, snsQ, M, 0, vq_name ); } #endif } diff --git a/lib_enc/lsf_msvq_ma_enc.c b/lib_enc/lsf_msvq_ma_enc.c index 6990f76198..fcdc4534a1 100644 --- a/lib_enc/lsf_msvq_ma_enc.c +++ b/lib_enc/lsf_msvq_ma_enc.c @@ -233,20 +233,20 @@ int16_t msvq_stage1_dct_search( 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 */ + 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 */ + 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++ ) + for ( j = maxC_st1; j < 2 * n_segm; j++ ) { dist1_ptr[j] = FLT_MAX; indices_st1_local[j] = -1; } -#endif +#endif } #endif @@ -308,7 +308,7 @@ int16_t msvq_stage1_dct_search( #ifdef ERI_SNSVQ_ROMOPT - assert( N == 24 || N == M ); + assert( N == 24 || N == M ); for ( c = 0; c < maxC_st1; c++ ) { dec_SNS_FDCNG_MSVQ_DCT_stage1( @@ -768,86 +768,37 @@ void msvq_enc( else /* non-DCT Stage #1 code below */ 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. */ - /* dist[0][0] */ - for ( j = 0; j < levels[s]; j++ ) { - en = 0.0f; - /* w,Tmp */ - /* Compute weighted codebook element and its energy */ - for ( c2 = 0; c2 < n; c2++ ) - { - Tmp[start + c2] = w[start + c2] * cbp[c2]; - en += cbp[c2] * Tmp[start + c2]; - } - cbp += maxn; /* pointer is incremented */ - - pTmp = &resid[0][0]; - /* Tmp */ - tmp = ( *pTmp++ ) * Tmp[0]; - for ( c2 = 1; c2 < N; c2++ ) - { - tmp += ( *pTmp++ ) * Tmp[c2]; - } - tmp = en - 2.0f * tmp; - tmp += dist[0][0]; - if ( tmp < dist[1][p_max] ) + /* 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. */ + /* dist[0][0] */ + for ( j = 0; j < levels[s]; j++ ) { - /* Replace worst */ - dist[1][p_max] = tmp; - indices[1][p_max * stages] = j; - parents[p_max] = 0; - - p_max = 0; - for ( c2 = 1; c2 < maxC; c2++ ) + en = 0.0f; + /* w,Tmp */ + /* Compute weighted codebook element and its energy */ + for ( c2 = 0; c2 < n; c2++ ) { - if ( dist[1][c2] > dist[1][p_max] ) - { - p_max = c2; - } + Tmp[start + c2] = w[start + c2] * cbp[c2]; + en += cbp[c2] * Tmp[start + c2]; } - } /* if (tmp <= dist[1][p_max]) */ - } /* for (j=0; j dist[1][p_max] ) + { + p_max = c2; + } + } + } /* if (tmp <= dist[1][p_max]) */ + } /* for(c=0; c Date: Wed, 10 May 2023 20:11:47 +0200 Subject: [PATCH 8/9] added updated SNSVQ DCT16 Stage1 tables for tcx10 and tcx20 --- lib_com/ivas_rom_com.c | 900 ++++++++++++++++++++--------------------- lib_com/ivas_rom_com.h | 25 +- lib_com/options.h | 2 +- lib_enc/ivas_sns_enc.c | 28 +- 4 files changed, 476 insertions(+), 479 deletions(-) diff --git a/lib_com/ivas_rom_com.c b/lib_com/ivas_rom_com.c index 53f4146bb4..10d694033d 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 }; @@ -6646,456 +7094,6 @@ const float ivas_sns_means_tcx10[M] = { -0.4801f , -0.4108f , -0.4564f , -0.6112f }; -#ifdef ERI_SNSVQ_ROMOPT - /* DCT16 domain segmentwise structured SNS-VQ stage1 tables indexed as tcx20 "0" and tcx10 as "1" */ - -/* v2d TCX20 97.3%, .55 maxmove - seg_trunc_lens = 12 14 16(16,16) - nElem = 14 16 98(49,49) -*/ - -/* v2d tcx10 788 Words . 99.5% , .55 mse_ maxmove - seg_trunc_lens = 8 10 12 16 - nElem = 13 34 41 40 */ - - -const float snsSt1_tr_midQ_truncQ_tcx20[M] = /* Q13 */ { - -6.522216796875000e-01f, -1.426513671875000e+00f, -1.277343750000000e+00f, -9.533691406250000e-01f, +1.857910156250000e-01f, -5.761718750000000e-02f, +8.435058593750000e-01f, -1.645507812500000e-01f, - -3.063964843750000e-02f, -1.065673828125000e-01f, +4.514160156250000e-01f, +2.604980468750000e-01f, +3.583984375000000e-01f, +6.871337890625000e-01f, +8.574218750000000e-01f, +1.024780273437500e+00f -}; - -const float snsSt1_tr_midQ_truncQ_tcx10[M]={ /* Q14 */ - -1.926879882812500e-01f, -8.222045898437500e-01f, -1.214416503906250e+00f, -5.881347656250000e-01f, +2.371215820312500e-01f, +6.344604492187500e-01f, +1.252441406250000e-01f, -3.415527343750000e-01f, - -2.136230468750000e-03f, +4.404907226562500e-01f, +5.527343750000000e-01f, +5.050659179687500e-01f, +3.703613281250000e-01f, +3.050537109375000e-01f, -5.877685546875000e-02f, +4.943847656250000e-02f -}; -const float *const snsSt1_tr_midQ_truncQ[2]= {snsSt1_tr_midQ_truncQ_tcx20, snsSt1_tr_midQ_truncQ_tcx10}; - - - - -/*const float fdcng_dct_invScaleF[2] = { 2.379272460937500f ,2.379272460937500f*16.0f }; */ -const float snsSt1_dct_invScaleF_tcx20[2] = { (float)(31977.0/2048.0), (float)(31977.0/128.0) }; /* Q11 invScale*/ -const float snsSt1_dct_invScaleF_tcx10[2] = { (float)(30052.0/2048.0), (float)(30052.0/128.0) }; /* Q11 invScale*/ -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] = { (float)(16789.0/262144.0), (float)((16789.0)/(262144.0*16.0)), (float)(((16789.0)/(262144.0*16.0))*((16789.0)/(262144.0*16.0))) }; /* Q18 for dctFscale */ -const float snsSt1_dct_scaleF_tcx10[3] = { (float)(17865.0/262144.0), (float)((17865.0)/(262144.0*16.0)), (float)(((17865.0)/(262144.0*16.0))*((17865.0)/(262144.0*16.0))) }; /* Q18 for dctFscale */ -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]= { 12, 14, 16, 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]= { 4, 2, 0, 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, 14, 30, 30+98/2, 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]={ 14, 16, 98/2, 98/2 }; -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[168]={ - 0, -40, 119, -69, 59, -28, 99, -3, 98, -18, 35, 51, - 0, -25, -53, -13, -76, -15, -82, 46, 68, 40, -22, -60, - 0, -15, -122, -27, -47, -38, -72, -9, 25, -3, -6, 40, - 0, -1, -93, 75, 12, 21, 7, -9, 28, -17, -22, 100, - 0, 38, -121, -35, -63, -46, -87, -22, -1, -50, -24, 39, - 0, 46, -72, 74, 5, 14, 0, -10, 19, -32, -41, 73, - 0, 78, 78, 37, 81, 80, 36, -112, -18, 43, 34, 83, - 0, 79, 48, 14, -31, -86, -110, -27, -14, -60, -83, -63, - 0, 83, -112, -56, -54, -55, -67, -40, -14, -71, -54, -18, - 0, 89, 59, 37, 6, -15, -39, -2, -1, -65, -35, -3, - 0, 100, 54, 31, 5, 15, 39, 75, 52, -47, -30, 42, - 0, 107, -55, -45, -43, -54, -101, -63, -33, -92, -56, -12, - 0, 112, -38, 37, 8, -21, -39, -35, -23, -79, -41, -14, - 0, 122, 27, -28, -30, -40, -91, -41, -12, -80, -61, -38 -}; -const Word8 /*seg 1, 16 x 14 */ sns_tcx20_dct_s1_W8Qx[224]={ - 0, -82, -12, 3, -28, -11, -25, -18, -7, -48, -12, 35, 11, 29, - 0, -71, 11, 66, 0, 5, -8, -12, 41, -49, 11, 67, 26, 44, - 0, -69, 43, 84, -42, 9, -22, -21, -18, -53, -20, 17, 2, 18, - 0, -46, 25, 108, 34, 27, 2, 26, 31, -24, 7, 35, 22, 24, - 0, -44, -41, -47, -76, 7, 24, 78, -32, 32, -22, 2, 64, 25, - 0, -40, -27, 12, 24, 62, 46, 65, 35, 34, 4, 46, 29, 30, - 0, -32, -96, 56, 74, 9, -36, -9, -26, 63, 80, 9, -73, 58, - 0, -10, -53, -69, -100, 33, 90, -40, 18, -19, 73, 34, -54, -72, - 0, 8, -37, -47, -28, 25, 48, 93, 62, -17, -20, 18, 59, 51, - 0, 26, -62, -61, -74, -46, -34, 62, 115, 72, 19, 23, -34, -63, - 0, 35, 43, 97, 50, 26, 8, 36, 38, 3, 10, 40, 20, 34, - 0, 71, -2, 85, 35, -1, -16, 18, 14, -20, 0, 9, 5, 19, - 0, 78, 40, 76, 31, 4, -6, 24, 22, -5, 5, 28, 10, 28, - 0, 83, -1, 37, -8, -13, -20, -6, 8, -30, -10, 17, 4, 18, - 0, 85, 37, 29, 27, 99, 66, -3, -111, -28, -5, 94, 44, 14, - 0, 127, -7, -17, -17, -37, -27, -9, -5, -71, -22, 13, 14, 23 -}; -const Word8 /*seg 2, 98 x 16 */ sns_tcx20_dct_s2_W8Qx[1568]={ - 0, -127, 17, 49, -27, -4, -14, -11, -14, -17, -24, 36, 6, 28, -23, -48, - 0, -99, -41, 88, 8, -6, -32, -16, 6, -42, -18, 40, 5, 22, -24, -49, - 0, -93, 3, 81, -27, -27, -12, -6, -37, -26, -21, 23, 3, 30, -29, -52, - 0, -89, 39, 11, -12, -10, -31, -19, -16, -33, -27, 25, 2, 31, -25, -45, - 0, -82, 73, -31, 12, 50, -23, 85, 54, -12, 51, -56, 73, -32, 29, -42, - 0, -63, -47, 26, -8, -10, -34, -25, -5, -28, -26, 40, 9, 35, -22, -51, - 0, -59, -18, 93, 14, -34, -38, 1, -11, -50, -27, 25, 5, 14, -26, -45, - 0, -49, -11, -12, -60, -27, -81, 36, 65, 8, 80, 114, -37, 54, 92, -18, - 0, -47, -7, -4, -13, -23, -25, -5, -23, -29, -25, 32, 8, 37, -24, -48, - 0, -46, 74, 48, 17, 19, -14, 7, 12, -9, -12, 27, 9, 7, -19, -46, - 0, -39, 38, 14, -22, -18, -40, -41, -26, -46, -33, 1, -6, 12, -28, -48, - 0, -38, 6, 84, -26, -9, -19, -3, -11, -20, -6, 22, 4, 26, -21, -41, - 0, -33, 14, 48, 8, -4, -9, 3, 14, -17, -5, 26, 10, 22, -19, -40, - 0, -30, -12, 53, 14, -31, -39, -37, -26, -32, -31, 2, 2, 12, -29, -48, - 0, -28, 96, 13, 100, 23, 40, -4, 80, -55, 46, 7, 5, 72, -60, -17, - 0, -21, 49, 84, -30, 9, -28, -19, -8, -32, -20, 6, 3, 9, -21, -42, - 0, -18, -25, -24, -32, -41, -27, -22, -32, -12, -10, -4, 1, 26, -22, -44, - 0, -15, -37, 26, -33, -50, -5, -81, -10, -18, -17, -38, 38, 47, -57, -82, - 0, -15, 45, 64, 34, 7, 3, 27, 43, 6, 13, 39, 20, 35, -15, -39, - 0, -10, 12, 16, -39, -37, -27, 2, 9, -17, -20, 18, 7, 32, -15, -36, - 0, -7, 14, 93, 44, -2, -19, 21, 36, 13, 13, 31, 27, 27, -15, -37, - 0, -6, 32, 46, 9, -9, -13, 5, 22, -10, -2, 27, 13, 27, -19, -41, - 0, -6, -15, 21, -14, -13, -15, 14, 18, -5, -1, 42, 15, 28, -18, -38, - 0, -4, 21, 25, -1, -17, -20, -9, 9, -18, -10, 20, 9, 20, -21, -43, - 0, 0, 14, 93, 53, 0, -37, -40, -27, -41, -40, -17, -4, 3, -27, -46, - 0, 0, -1, -22, -31, -34, -50, -42, -40, -36, -19, -22, -14, 26, -29, -49, - 0, 3, 19, 76, -19, -10, -34, -46, -46, -49, -31, 6, 0, 14, -24, -45, - 0, 5, -2, 67, 12, -4, -19, 5, 11, -11, -5, 20, 8, 20, -19, -39, - 0, 9, -15, 11, -36, -22, -30, -26, 6, -24, -23, 6, -1, 6, -28, -44, - 0, 9, 3, 76, 27, -45, -70, -91, -52, -22, -66, -35, 4, -7, -32, -42, - 0, 11, -32, -18, -34, -21, -24, -18, -13, -22, -15, -1, 2, 14, -25, -40, - 0, 12, -49, 12, 84, 21, -24, -48, 77, 90, -14, -114, 28, 101, -6, -59, - 0, 13, 47, 16, -20, -21, -38, -30, -27, -42, -30, -9, -1, 9, -25, -45, - 0, 17, 14, 23, -17, -23, -27, -17, -2, -26, -17, 8, 3, 11, -23, -43, - 0, 17, 40, 53, 17, -3, -12, 4, 19, -12, -2, 25, 13, 25, -18, -41, - 0, 18, 16, 74, 14, 42, 22, 45, 18, -33, 16, 23, 28, 25, -13, -36, - 0, 19, 5, 23, 16, -2, -4, 18, 35, 5, 10, 41, 13, 16, -21, -45, - 0, 20, 2, 11, -24, -86, -37, -83, -67, 2, -80, 67, -13, -91, -40, -58, - 0, 20, -15, 28, 22, -24, -50, -70, -71, -39, -29, -19, -15, 12, -34, -44, - 0, 25, -2, 38, -14, -16, -26, 1, -3, -32, -14, 14, 3, 15, -21, -41, - 0, 28, -22, -2, -52, -55, -38, -31, -10, -38, -18, -4, 6, 13, -24, -40, - 0, 28, 59, 71, 6, -9, -22, -22, -7, -29, -19, -1, 4, 10, -21, -46, - 0, 31, -20, 29, -6, -7, -15, 21, 11, -18, -5, 18, 4, 17, -21, -39, - 0, 33, 23, 80, 12, -1, -12, 22, 19, -5, 1, 39, 14, 25, -16, -40, - 0, 33, 21, 48, 15, 8, -23, -69, -67, -50, -47, -8, 5, 17, -33, -54, - 0, 37, -14, 6, -50, -39, -53, -42, -30, -51, -25, -27, 4, -101, -92, -96, - 0, 38, 27, 71, 19, -22, -55, -62, -32, -44, -31, -14, 3, 23, -25, -43, - 0, 38, -6, 84, 72, -11, -71, -42, -50, -53, -32, -36, -31, 32, -22, -52, - 0, 39, 2, 63, 51, -21, -23, 18, 18, 15, 13, 10, 10, 17, -18, -40, - 0, 40, 36, 22, -4, -13, -14, 12, 28, 4, 7, 36, 15, 23, -17, -40, - 0, 40, -33, 11, -37, -25, -36, -15, -1, -23, -16, 9, -3, -1, -27, -45, - 0, 40, -2, 17, -20, -20, -28, -2, -2, -29, -13, 9, 2, 10, -21, -41, - 0, 41, 6, 41, 2, -10, -15, 22, 15, -21, -1, 24, 7, 19, -18, -39, - 0, 41, 1, -2, -32, -16, -34, -65, -63, -50, -28, 31, 25, 44, -34, -59, - 0, 41, 18, 32, -13, -22, -27, -2, -4, -35, -9, 11, 2, 15, -20, -38, - 0, 42, 21, -5, -56, -59, -41, -14, 5, -26, -47, -3, -3, 21, -23, -50, - 0, 44, 12, 2, 42, -49, -90, -55, -51, -34, -11, -45, 15, 37, -55, -19, - 0, 47, 7, 51, -35, -42, -48, -36, -27, -53, -49, -37, -16, -3, -28, -43, - 0, 48, -36, -108, -69, 47, 90, 53, 24, 101, 48, -111, -61, -78, 43, 96, - 0, 52, -36, -48, -2, -66, -62, 0, -31, -48, -12, 37, 3, 9, -34, -68, - 0, 54, 40, 29, -28, -20, -34, -27, -19, -47, -33, -1, -1, 15, -21, -43, - 0, 55, 55, 33, -35, -76, -70, -38, -13, -19, -30, -14, -11, 10, -35, -47, - 0, 56, 0, 23, 24, -51, 1, 112, -21, 17, 15, 42, 0, 41, -22, -44, - 0, 56, -12, 24, -4, -13, -21, 6, 7, -19, -7, 24, 6, 13, -20, -40, - 0, 57, 32, -31, 8, -38, -55, -38, -76, -54, -21, -28, 7, 20, -51, -45, - 0, 57, -10, -32, -29, -14, -6, 21, 57, 16, -2, -2, 2, 8, -28, -47, - 0, 58, -10, 31, 25, -7, -54, -24, -63, -101, -27, 24, -20, 53, -20, -77, - 0, 59, 10, 62, -9, -6, -28, -24, -8, -27, -21, 4, -2, 18, -24, -45, - 0, 61, 18, 27, -3, -3, -7, 11, 18, -8, 0, 26, 10, 24, -20, -41, - 0, 64, -27, 4, -23, -34, -61, -46, -51, -56, -23, -3, -2, 27, -25, -44, - 0, 65, 28, 55, 33, -6, -12, -9, 10, -27, -20, -14, -2, 0, -26, -43, - 0, 65, -22, 31, 45, -69, -46, -62, -115, -32, -31, 2, -5, 30, -38, -41, - 0, 65, 4, 2, -43, -41, -35, 3, -4, -42, -21, 15, 1, -16, -38, -53, - 0, 66, 14, 50, 51, 9, -51, -59, -28, -55, -24, 3, -9, 9, -16, -44, - 0, 66, 15, 11, -4, -16, -42, -51, -37, -60, -25, 18, 9, 28, -19, -47, - 0, 68, 65, 65, 8, -14, -23, -15, -1, -16, -11, 11, 6, 21, -25, -42, - 0, 70, 1, -65, -18, -27, -55, -2, -3, -69, 0, -64, 16, -12, -56, -41, - 0, 71, 52, 82, -20, -45, -65, -49, 14, -43, -16, 6, -28, -7, -34, -54, - 0, 74, -44, -17, -46, -57, -49, -9, -4, -36, -24, -21, -3, 0, -31, -52, - 0, 76, 1, -22, 19, -39, -51, -64, -94, -17, -16, 6, 5, 29, -41, -50, - 0, 76, 29, 61, -13, -5, -6, -108, -31, -13, -76, -21, -3, -12, -23, -64, - 0, 78, -15, -2, -31, -94, -68, 26, 11, -38, -23, 0, -25, 46, -13, -54, - 0, 78, 26, -8, -46, -32, -33, -24, -1, -26, -18, 8, 4, 16, -22, -44, - 0, 79, -26, 31, -28, -29, -37, -20, -2, -31, -26, -5, -2, 6, -26, -47, - 0, 80, -3, -33, -15, -82, -12, -28, -28, -18, -54, 18, -2, 33, -43, -65, - 0, 81, -48, -20, -1, -99, -25, -22, -79, -35, -22, 29, 5, 6, -45, -63, - 0, 88, 12, 57, 20, -22, -44, -45, -35, -45, -30, -58, -8, 51, -24, -60, - 0, 89, 41, 28, 15, -16, -55, -80, -25, -48, -36, -52, -4, 36, -37, -49, - 0, 93, 6, -10, -20, -16, -21, -12, 11, -16, -10, 10, 4, 13, -23, -42, - 0, 95, -40, 78, 24, -19, -1, -24, 3, -25, -27, 16, 5, 14, -17, -48, - 0, 95, 21, 38, -11, -65, -79, -23, 37, -38, -28, 7, -6, 9, -21, -45, - 0, 95, -5, 13, 47, -16, -55, -22, -49, -71, -9, 11, 4, 36, -18, -47, - 0, 99, -8, 13, -29, -43, -40, -49, -17, -39, -23, 0, -1, 6, -28, -43, - 0, 105, 7, 50, 37, -15, -19, 19, 7, -17, -9, -4, -5, 1, -27, -42, - 0, 105, 60, 28, -37, -44, -39, -32, -4, -28, -20, -9, -5, 1, -29, -44, - 0, 111, -30, -20, -2, -22, -7, 42, 45, 7, -15, -29, -9, -8, -35, -50, - 0, 116, 64, 56, 12, 4, -9, -12, -6, -22, -2, 11, -6, -11, -32, -46, - 0, 118, 19, 24, 4, -24, -33, -21, -1, -28, -9, 14, -3, 9, -21, -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_s2_W8Qx[1568/2]) }; - -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, 57, - 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, -38, 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, -73, 72, -43, 41, -16, -1, -40, 79, -26, 81, -47, - 0, -56, -76, -27, 23, 107, -30, -17, -25, 35, 7, 108, - 0, -49, 6, 71, 41, -39, -47, 1, -1, 37, -68, -1, - 0, -48, 2, 34, 35, 7, -11, -34, 10, 70, 11, 26, - 0, -41, -11, -1, 25, -40, -59, -41, -4, 47, -33, -12, - 0, -33, 18, 25, 6, -49, -29, -51, -18, 10, -36, -18, - 0, -32, 36, 36, 25, -2, -14, -11, 14, 95, 13, 14, - 0, -27, -5, -35, -8, -72, -38, -57, -20, 16, -37, -21, - 0, -24, -29, 19, 40, -11, -26, -17, -9, 46, -20, -19, - 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, -2, 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, 12, -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, 59, 24, 18, - 0, 24, 33, 22, 18, -39, -25, -24, 15, 73, -19, -19, - 0, 25, 76, 40, 17, -7, -30, -46, 12, -16, 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, 68, 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, 77, 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, 12, 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, -104, -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[12]={ - 0, 4, 3, 3, 3, 3, 2, 2, - 2, 1, 1, 0 -}; -const Word16 snsSt1_tcx20_stage1_col_syn_shift_segm1[14]={ - 0, 4, 4, 3, 3, 3, 3, 2, - 2, 1, 2, 1, 2, 1 -}; -const Word16 snsSt1_tcx20_stage1_col_syn_shift_segm2[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_segm2}; - - -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]= { - 44, 37, 23, 61, 60, 3, 28, 120, - 108, 100, 26, 8, 121, 29, 15, 17, - 33, 45, 21, 18, 19, 88, 1, 4, - 6, 97, 126, 116, 10, 125, 32, 35, - 31, 30, 39, 38, 20, 41, 14, 16, - 43, 42, 48, 36, 34, 40, 2, 52, - 65, 53, 54, 50, 57, 64, 59, 46, - 49, 66, 55, 56, 68, 47, 51, 79, - 71, 73, 63, 58, 77, 72, 80, 76, - 81, 24, 78, 70, 74, 25, 5, 90, - 93, 83, 69, 75, 82, 67, 94, 84, - 22, 111, 110, 62, 95, 102, 85, 106, - 104, 98, 92, 113, 103, 115, 122, 86, - 87, 107, 112, 91, 99, 101, 117, 114, - 7, 119, 11, 89, 96, 9, 0, 118, - 127, 109, 13, 27, 105, 12, 124, 123 -}; -const Word8 snsSt1_segm_neighbour_fwd_tcx10[128]={ - 21, 78, 72, 44, 6, 87, 7, 11, - 10, 46, 86, 12, 9, 0, 13, 19, - 15, 14, 50, 91, 47, 55, 54, 49, - 30, 23, 27, 112, 101, 33, 63, 110, - 75, 34, 69, 38, 67, 96, 120, 45, - 79, 125, 40, 124, 82, 5, 126, 99, - 29, 93, 16, 18, 17, 57, 51, 102, - 52, 58, 103, 39, 107, 71, 116, 28, - 31, 66, 77, 26, 62, 105, 114, 68, - 100, 115, 70, 36, 32, 37, 83, 1, - 2, 119, 43, 122, 85, 3, 81, 8, - 89, 90, 108, 88, 98, 53, 24, 59, - 48, 92, 22, 95, 20, 97, 94, 61, - 106, 60, 56, 25, 127, 104, 111, 65, - 113, 118, 64, 109, 73, 74, 35, 42, - 117, 123, 41, 76, 80, 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]= { - 118, 22, 46, 5, 23, 78, 24, 112, - 11, 117, 28, 114, 125, 122, 38, 14, - 39, 15, 19, 20, 36, 18, 88, 2, - 73, 77, 10, 123, 6, 13, 33, 32, - 30, 16, 44, 31, 43, 1, 35, 34, - 45, 37, 41, 40, 0, 17, 55, 61, - 42, 56, 51, 62, 47, 49, 50, 58, - 59, 52, 67, 54, 4, 3, 91, 66, - 53, 48, 57, 85, 60, 82, 75, 64, - 69, 65, 76, 83, 71, 68, 74, 63, - 70, 72, 84, 81, 87, 94, 103, 104, - 21, 115, 79, 107, 98, 80, 86, 92, - 116, 25, 97, 108, 9, 109, 93, 100, - 96, 124, 95, 105, 8, 121, 90, 89, - 106, 99, 111, 101, 27, 110, 119, 113, - 7, 12, 102, 127, 126, 29, 26, 120 -}; - -const Word8 snsSt1_segm_neighbour_rev_tcx10[128]={ - 13, 79, 80, 85, 127, 45, 4, 6, - 87, 12, 8, 7, 11, 14, 17, 16, - 50, 52, 51, 15, 100, 0, 98, 25, - 94, 107, 67, 26, 63, 48, 24, 64, - 76, 29, 33, 118, 75, 77, 35, 59, - 42, 122, 119, 82, 3, 39, 9, 20, - 96, 23, 18, 54, 56, 93, 22, 21, - 106, 53, 57, 95, 105, 103, 68, 30, - 114, 111, 65, 36, 71, 34, 74, 61, - 2, 116, 117, 32, 123, 66, 1, 40, - 124, 86, 44, 78, 126, 84, 10, 5, - 91, 88, 89, 19, 97, 49, 102, 99, - 37, 101, 92, 47, 72, 28, 55, 58, - 109, 69, 104, 60, 90, 115, 31, 110, - 27, 112, 70, 73, 62, 120, 113, 81, - 38, 125, 83, 121, 43, 41, 46, 108 -}; -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 }; diff --git a/lib_com/ivas_rom_com.h b/lib_com/ivas_rom_com.h index 0df2d97f9b..d0c3db33b3 100644 --- a/lib_com/ivas_rom_com.h +++ b/lib_com/ivas_rom_com.h @@ -425,18 +425,6 @@ 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[]; -#else -extern const int16_t ivas_sns_cdbks_tcx20_levels[]; -extern const int16_t ivas_sns_cdbks_tcx20_bits[]; - -extern const int16_t ivas_sns_cdbks_tcx10_levels[]; -extern const int16_t ivas_sns_cdbks_tcx10_bits[]; - -extern const float *const ivas_sns_cdbks_tcx20[]; -extern const float *const ivas_sns_cdbks_tcx10[]; - -extern const float ivas_sns_means_tcx20[]; -extern const float ivas_sns_means_tcx10[]; #ifdef ERI_SNSVQ_ROMOPT extern const float *const snsSt1_tr_midQ_truncQ[]; @@ -454,6 +442,19 @@ 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[]; + +extern const int16_t ivas_sns_cdbks_tcx10_levels[]; +extern const int16_t ivas_sns_cdbks_tcx10_bits[]; + +extern const float *const ivas_sns_cdbks_tcx20[]; +extern const float *const ivas_sns_cdbks_tcx10[]; + +extern const float ivas_sns_means_tcx20[]; +extern const float ivas_sns_means_tcx10[]; + extern const int16_t ivas_sns_cdbks_side_tcx20_levels[]; extern const int16_t ivas_sns_cdbks_side_tcx20_bits[]; extern const int16_t ivas_sns_cdbks_side_tcx10_levels[]; diff --git a/lib_com/options.h b/lib_com/options.h index 4ffbcb4bbf..c527103a67 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -191,7 +191,7 @@ #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 */ -#define ERI_SNSVQ_ROMOPT /* Eri: BASOP ROM OPT store added SNS VQ stage 1 tables in DCT16 domain, as for FDCNGVQ stage 1 */ +#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 ######################### */ diff --git a/lib_enc/ivas_sns_enc.c b/lib_enc/ivas_sns_enc.c index e7fe3aa706..b6d7841397 100644 --- a/lib_enc/ivas_sns_enc.c +++ b/lib_enc/ivas_sns_enc.c @@ -514,8 +514,10 @@ int16_t quantize_sns( #ifndef FIX_445_SNS_BUGFIXES const float *means; #endif - - float sns_buffer[CPE_CHANNELS][NB_DIV][M]; + +#ifdef SNS_MSVQ_DEBUG + float sns_inbuf[M]; +#endif #ifdef ERI_SNSVQ_ROMOPT float *invTrfMatrix; float tmpRAM[M][M]; /*16*16*/ @@ -661,8 +663,11 @@ 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_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] ); @@ -674,18 +679,11 @@ int16_t quantize_sns( char vq_name[2 * 1024]; char v[2 * 1024]; int16_t nC; /* nCandidates */ - int16_t tcx = 10; - if ( nSubframes == 1 ) - { - tcx = 20; - } - + int16_t tcx = (nSubframes == 1) ? 20: 10; #ifdef ERI_SNSVQ_ROMOPT - sprintf( v, "ERI_Tcx%d", tcx ); - nC = 3; + sprintf( v, "ERI_Tcx%d", tcx ); nC = 3; #else - sprintf( v, "BSL_Tcx%d", tcx ); - nC = 3; + sprintf( v, "BSL_Tcx%d", tcx ); nC = 3; #endif if ( sns_stereo_mode[ch] == 0 ) { @@ -695,8 +693,8 @@ int16_t quantize_sns( { sprintf( vq_name, "SD2_%s_LR_Ch%dsub%dSt%dnC%d", v, ch, k, nStages, nC ); } - assert(0); - snr_diff( sns_ptr, snsQ, M, 0, vq_name ); + + snr_diff( sns_inbuf, snsQ, M, 0, vq_name ); } #endif } -- GitLab From f68446fdf42cf72490e64366b76f0fe42a0e9497 Mon Sep 17 00:00:00 2001 From: Jonas Sv Date: Wed, 10 May 2023 20:19:24 +0200 Subject: [PATCH 9/9] clang format --- lib_enc/ivas_sns_enc.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/lib_enc/ivas_sns_enc.c b/lib_enc/ivas_sns_enc.c index b6d7841397..dfa450661c 100644 --- a/lib_enc/ivas_sns_enc.c +++ b/lib_enc/ivas_sns_enc.c @@ -513,11 +513,11 @@ int16_t quantize_sns( float weights[M]; #ifndef FIX_445_SNS_BUGFIXES const float *means; -#endif - +#endif + #ifdef SNS_MSVQ_DEBUG float sns_inbuf[M]; -#endif +#endif #ifdef ERI_SNSVQ_ROMOPT float *invTrfMatrix; float tmpRAM[M][M]; /*16*16*/ @@ -667,7 +667,7 @@ int16_t quantize_sns( 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_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] ); @@ -679,11 +679,13 @@ int16_t quantize_sns( char vq_name[2 * 1024]; char v[2 * 1024]; int16_t nC; /* nCandidates */ - int16_t tcx = (nSubframes == 1) ? 20: 10; + int16_t tcx = ( nSubframes == 1 ) ? 20 : 10; #ifdef ERI_SNSVQ_ROMOPT - sprintf( v, "ERI_Tcx%d", tcx ); nC = 3; + sprintf( v, "ERI_Tcx%d", tcx ); + nC = 3; #else - sprintf( v, "BSL_Tcx%d", tcx ); nC = 3; + sprintf( v, "BSL_Tcx%d", tcx ); + nC = 3; #endif if ( sns_stereo_mode[ch] == 0 ) { @@ -693,7 +695,7 @@ int16_t quantize_sns( { 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 -- GitLab