Commit a9803e23 authored by vaclav's avatar vaclav
Browse files

harmonize cng_params_upd_fx() and cng_params_postupd_fx()

parent b6dcb714
Loading
Loading
Loading
Loading
+24 −6
Original line number Diff line number Diff line
@@ -180,12 +180,14 @@ IF( GT_16( element_mode, IVAS_SCE ) )
{
    return;
}

/*---------------------------------------------------------------------*
 * Generate white noise vector
 *---------------------------------------------------------------------*/

/*for ( i=0; i<L_frame; i++ )exc2[i] = (float)own_random( seed );*/
Random_Fill( seed, L_frame, exc2, 4 );

/*------------------------------------------------------------*
 * Insert random variation for excitation energy
 *  (random variation is scaled according to *lp_ener value)
@@ -240,6 +242,7 @@ FOR( i_subfr = 0; i_subfr < L_frame; i_subfr += L_SUBFR )
        move16();
    }
}

IF( NE_16( Opt_AMR_WB, 1 ) )
{
    Copy( exc2, exc3, L_FRAME16k );
@@ -538,7 +541,6 @@ IF( NE_16( Opt_AMR_WB, 1 ) )
    }
    L_tmp2 = L_shr( L_tmp2, sub( add( Q_exc, Q_exc ), 5 ) ); /*Q6*/


    /*  enr = (*lp_ener)/enr; */
    /*  ftmp = sqrt(enr); */
    L_tmp = L_max( 1, *lp_ener ); /*Q6*/
@@ -592,12 +594,15 @@ ELSE
return;
}


/*-------------------------------------------------------*
 * cng_params_postupd_fx
 *
 * Post-update of CNG parameters
 *-------------------------------------------------------*/

void cng_params_postupd_fx(
#ifndef HARM_NON_LINEARITY
    const Word16 ho_circ_ptr,          /* i  : pointer for CNG averaging buffers                  Q0    */
    Word16 *cng_buf_cnt,               /* i/o: counter for CNG store buffers                      Q0    */
    const Word16 *const cng_exc2_buf,  /* i  : Excitation buffer                                  Q_exc */
@@ -702,6 +707,7 @@ void cng_params_postupd_fx(
}

void cng_params_postupd_ivas_fx(
#endif
    const Word16 ho_circ_ptr,          /* i  : pointer for CNG averaging buffers                  Q0    */
    Word16 *cng_buf_cnt,               /* i/o: counter for CNG store buffers                      Q0    */
    const Word16 *const cng_exc2_buf,  /* i  : Excitation buffer                                  Q_exc */
@@ -781,7 +787,6 @@ void cng_params_postupd_ivas_fx(
        }
        ELSE
        {

            CNG_mode = get_cng_mode( last_active_brate );

            /* att = 1/pow(2,ENR_ATT_fx[CNG_mode]); */
@@ -828,6 +833,7 @@ void cng_params_postupd_ivas_fx(
 *
 * update CNG parameters
 *-------------------------------------------------------*/
#ifndef HARM_NON_LINEARITY
void cng_params_upd_fx(
    const Word16 lsp_new[],        /* i  : LSP aprameters                                     Q15   */
    const Word16 exc2[],           /* i  : current enhanced excitation                        Q_exc */
@@ -997,8 +1003,13 @@ void cng_params_upd_fx(

    return;
}
#endif

#ifdef HARM_NON_LINEARITY
void cng_params_upd_fx(
#else
void cng_params_upd_ivas_fx(
#endif
    const Word16 lsp_new[],         /* i  : LSP aprameters                                     Q15   */
    const Word16 exc2[],            /* i  : current enhanced excitation                        Q_exc */
    const Word16 L_frame,           /* i  : frame length                                       Q0    */
@@ -1008,7 +1019,7 @@ void cng_params_upd_ivas_fx(
    Word16 ho_lsp_circ[],           /* o  : old LSP buffer for CNG averaging                   Q15   */
    const Word16 Q_exc,             /* i  : Q value of excitation                                    */
    const Word16 enc_dec_flag,      /* i  : Flag indicating encoder or decoder (ENC,DEC)             */
    Word32 ho_env_circ[],           /* i/o: Envelope buffer                                    Q(6+shift)    */
    Word32 ho_env_circ[],           /* i/o: Envelope buffer                            Q6/Q(6+shift) */
    Word16 *cng_buf_cnt,            /* i/o: Counter of postponed FFT-processing instances            */
    Word16 cng_exc2_buf[],          /* i/o: Excitation buffer                                  Q_exc */
    Word16 cng_Qexc_buf[],          /* i/o: Q_exc buffer                                       Q0    */
@@ -1176,10 +1187,17 @@ void cng_params_upd_ivas_fx(
        /* update the circular buffer of old residual envelope */
        /* Copy32( env, &(ho_env_circ[add(shl(*ho_circ_ptr,4),shl(*ho_circ_ptr,2))]), NUM_ENV_CNG ); */
        Copy32( env, &( ho_env_circ[( *ho_circ_ptr ) * NUM_ENV_CNG] ), NUM_ENV_CNG );
#ifdef HARM_NON_LINEARITY
        IF( NE_16( element_mode, EVS_MONO ) )
#endif
        {
            scale_sig32( &( ho_env_circ[( *ho_circ_ptr ) * NUM_ENV_CNG] ), NUM_ENV_CNG, shift ); // Q(6+shift)
        }
    }

    *ho_circ_size = add( *ho_circ_size, 1 );
    move16();

    if ( GT_16( *ho_circ_size, HO_HIST_SIZE ) )
    {
        *ho_circ_size = HO_HIST_SIZE;
+8 −4
Original line number Diff line number Diff line
@@ -4007,6 +4007,7 @@ void CNG_exc_fx(
);
void cng_params_postupd_fx(
#ifndef HARM_NON_LINEARITY
    const Word16 ho_circ_ptr,          /* i  : pointer for CNG averaging buffers                  Q0    */
    Word16 *cng_buf_cnt,               /* i/o: counter for CNG store buffers                      Q0    */
    const Word16 *const cng_exc2_buf,  /* i  : Excitation buffer                                  Q_exc */
@@ -4016,6 +4017,7 @@ void cng_params_postupd_fx(
);
void cng_params_postupd_ivas_fx(
#endif
    const Word16 ho_circ_ptr,          /* i  : pointer for CNG averaging buffers                  Q0    */
    Word16 *cng_buf_cnt,               /* i/o: counter for CNG store buffers                      Q0    */
    const Word16 *const cng_exc2_buf,  /* i  : Excitation buffer                                  Q_exc */
@@ -4027,6 +4029,7 @@ void cng_params_postupd_ivas_fx(
);
void cng_params_upd_fx(
#ifndef HARM_NON_LINEARITY
    const Word16 lsp_new[],        /* i  : LSP parameters                                     Q15   */
    const Word16 exc2[],           /* i  : current enhanced excitation                        Q_exc */
    const Word16 L_frame,          /* i  : frame length                                       Q0    */
@@ -4045,6 +4048,7 @@ void cng_params_upd_fx(
);
void cng_params_upd_ivas_fx(
#endif
    const Word16 lsp_new[],         /* i  : LSP aprameters                                     Q15   */
    const Word16 exc2[],            /* i  : current enhanced excitation                        Q_exc */
    const Word16 L_frame,           /* i  : frame length                                       Q0    */
+5 −0
Original line number Diff line number Diff line
@@ -2321,6 +2321,10 @@ ivas_error acelp_core_dec_fx(
    IF( GT_32( st->core_brate, SID_2k40 ) && st->hTdCngDec != NULL && st->hFdCngDec != NULL )
    {
        /* update CNG parameters in active frames */
#ifdef HARM_NON_LINEARITY
        cng_params_upd_fx( lsp_new_fx, exc_fx, st->L_frame, &st->hTdCngDec->ho_circ_ptr, st->hTdCngDec->ho_ener_circ_fx, &st->hTdCngDec->ho_circ_size, st->hTdCngDec->ho_lsp_circ_fx,
                           st->Q_exc, DEC, st->hTdCngDec->ho_env_circ_fx, NULL, NULL, NULL, NULL, st->last_active_brate, st->element_mode, st->hFdCngDec->hFdCngCom->CngBandwidth );
#else
        IF( EQ_16( st->element_mode, EVS_MONO ) )
        {
            cng_params_upd_fx( lsp_new_fx, exc_fx, st->L_frame, &st->hTdCngDec->ho_circ_ptr, st->hTdCngDec->ho_ener_circ_fx, &st->hTdCngDec->ho_circ_size, st->hTdCngDec->ho_lsp_circ_fx,
@@ -2332,6 +2336,7 @@ ivas_error acelp_core_dec_fx(
                                    st->hTdCngDec->ho_lsp_circ_fx, st->Q_exc, DEC, st->hTdCngDec->ho_env_circ_fx, NULL, NULL, NULL, NULL, st->last_active_brate, st->element_mode,
                                    st->hFdCngDec->hFdCngCom->CngBandwidth );
        }
#endif

        /* Set 16k LSP flag for CNG buffer */
        st->hTdCngDec->ho_16k_lsp[st->hTdCngDec->ho_circ_ptr] = 0;
+11 −0
Original line number Diff line number Diff line
@@ -934,16 +934,27 @@ void decoder_LPD_fx(
            E_LPC_lev_dur( r_h, r_l, A, NULL, M, NULL );
            E_LPC_a_lsp_conversion( A, lsptmp, &xspnew_uw[0], M );
            Residu3_fx( A, buf + L_LP - L_FRAME, res, L_FRAME, 1 );

#ifdef HARM_NON_LINEARITY
            cng_params_upd_fx( lsptmp, res, st->L_frame, &st->hTdCngDec->ho_circ_ptr, st->hTdCngDec->ho_ener_circ_fx, &st->hTdCngDec->ho_circ_size, st->hTdCngDec->ho_lsp_circ_fx,
                               Qexc, DEC, st->hTdCngDec->ho_env_circ_fx, NULL, NULL, NULL, NULL, st->last_active_brate, EVS_MONO, -1 );
#else
            cng_params_upd_fx( lsptmp, res, st->L_frame, &st->hTdCngDec->ho_circ_ptr,
                               st->hTdCngDec->ho_ener_circ_fx, &st->hTdCngDec->ho_circ_size, st->hTdCngDec->ho_lsp_circ_fx,
                               Qexc, DEC, st->hTdCngDec->ho_env_circ_fx, NULL, NULL, NULL, NULL, st->last_active_brate );
#endif
        }
        ELSE
        {
#ifdef HARM_NON_LINEARITY
            cng_params_upd_fx( &lsp[M], st->old_exc_fx + L_EXC_MEM_DEC - st->L_frame, st->L_frame, &st->hTdCngDec->ho_circ_ptr, st->hTdCngDec->ho_ener_circ_fx, &st->hTdCngDec->ho_circ_size, st->hTdCngDec->ho_lsp_circ_fx,
                               st->Q_exc, DEC, st->hTdCngDec->ho_env_circ_fx, NULL, NULL, NULL, NULL, st->last_active_brate, EVS_MONO, -1 );
#else
            cng_params_upd_fx( &lsp[M], st->old_exc_fx + L_EXC_MEM_DEC - st->L_frame,
                               st->L_frame, &st->hTdCngDec->ho_circ_ptr, st->hTdCngDec->ho_ener_circ_fx,
                               &st->hTdCngDec->ho_circ_size, st->hTdCngDec->ho_lsp_circ_fx, st->Q_exc, DEC,
                               st->hTdCngDec->ho_env_circ_fx, NULL, NULL, NULL, NULL, st->last_active_brate );
#endif
        }

        /* Set 16k LSP flag for CNG buffer */
+11 −0
Original line number Diff line number Diff line
@@ -753,13 +753,24 @@ void stereo_tcx_core_dec_fx(

            IF( st->hTdCngDec != NULL )
            {
#ifdef HARM_NON_LINEARITY
                cng_params_upd_fx( lsptmp, res, st->L_frame, &st->hTdCngDec->ho_circ_ptr, st->hTdCngDec->ho_ener_circ_fx, &st->hTdCngDec->ho_circ_size, st->hTdCngDec->ho_lsp_circ_fx,
                                   st->Q_exc, DEC, st->hTdCngDec->ho_env_circ_fx, NULL, NULL, NULL, NULL, st->last_active_brate, st->element_mode, st->hFdCngDec->hFdCngCom->CngBandwidth );
#else
                cng_params_upd_ivas_fx( lsptmp, res, st->L_frame, &st->hTdCngDec->ho_circ_ptr, st->hTdCngDec->ho_ener_circ_fx, &st->hTdCngDec->ho_circ_size, st->hTdCngDec->ho_lsp_circ_fx, st->Q_exc, DEC, st->hTdCngDec->ho_env_circ_fx, NULL, NULL, NULL, NULL, st->last_active_brate, st->element_mode, st->hFdCngDec->hFdCngCom->CngBandwidth );
#endif
            }
        }
        ELSE IF( st->hTdCngDec != NULL )
        {
#ifdef HARM_NON_LINEARITY
            cng_params_upd_fx( &lsp_fx[M], st->old_exc_fx + sub( L_EXC_MEM_DEC, st->L_frame ), st->L_frame, &st->hTdCngDec->ho_circ_ptr, st->hTdCngDec->ho_ener_circ_fx, &st->hTdCngDec->ho_circ_size, st->hTdCngDec->ho_lsp_circ_fx,
                               st->Q_exc, DEC, st->hTdCngDec->ho_env_circ_fx, NULL, NULL, NULL, NULL, st->last_active_brate, st->element_mode, st->hFdCngDec->hFdCngCom->CngBandwidth );
#else
            cng_params_upd_ivas_fx( &lsp_fx[M], st->old_exc_fx + sub( L_EXC_MEM_DEC, st->L_frame ), st->L_frame, &st->hTdCngDec->ho_circ_ptr, st->hTdCngDec->ho_ener_circ_fx, &st->hTdCngDec->ho_circ_size, st->hTdCngDec->ho_lsp_circ_fx, st->Q_exc, DEC, st->hTdCngDec->ho_env_circ_fx, NULL, NULL, NULL, NULL, st->last_active_brate, st->element_mode, st->hFdCngDec->hFdCngCom->CngBandwidth );
#endif
        }

        /* Set 16k LSP flag for CNG buffer */
        // st->hTdCngDec->ho_16k_lsp[st->hTdCngDec->ho_circ_ptr] = ( st->L_frame == L_FRAME ? 0 : 1 );
        IF( EQ_16( st->L_frame, L_FRAME ) )
Loading