Commit d59bbad9 authored by Jonas Svedberg's avatar Jonas Svedberg
Browse files

initial SNSVQ ROM Optimized stage 1 MSVQ tables in DCT16 domain, saving approx 2kW TROM

parent 76ab3e53
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -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 */
+11 −6
Original line number Diff line number Diff line
@@ -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 */
+61 −11
Original line number Diff line number Diff line
@@ -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 )
@@ -2207,9 +2226,41 @@ 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
        {
@@ -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
        {
+1 −1
Original line number Diff line number Diff line
@@ -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 */
+1 −0
Original line number Diff line number Diff line
@@ -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  */
Loading