Commit 588e1320 authored by Sandesh Venkatesh's avatar Sandesh Venkatesh
Browse files

Fix for issue 771: Frequency peak for DTX Stereo at lower bitrates and

issue 772: Noise Burst for DTX Stereo at lower bitrates with Fs 16kHz
parent 4856d31e
Loading
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -171,6 +171,11 @@ Word32 sum2_f_32_fx(
    const Word32 *vec,  /* i  : input vector                          */
    const int16_t lvec, /* i  : length of input vector                */
    Word16 gb );
Word32 sum2_32_fx(
    const Word32 *vec, /* i  : input vector                          */
    const Word16 lvec, /* i  : length of input vector                */
    Word16 *e );
#endif
void set_c(
+24 −0
Original line number Diff line number Diff line
@@ -233,6 +233,30 @@ Word32 sum2_f_32_fx(

    return tmp;
}

Word32 sum2_32_fx(
    const Word32 *vec, /* i  : input vector                          */
    const Word16 lvec, /* i  : length of input vector                */
    Word16 *e )
{
    int16_t i;
    Word32 tmp;

    tmp = 0;
    Word32 var_a = 0;
    Word16 exp = 0, exp_tmp;
    FOR( i = 0; i < lvec; i++ )
    {
        exp_tmp = norm_l( vec[i] );
        var_a = L_shl( vec[i], exp_tmp );
        var_a = Mpy_32_32( var_a, var_a );
        exp_tmp = shl( sub( *e, exp_tmp ), 1 );
        tmp = BASOP_Util_Add_Mant32Exp( tmp, exp, var_a, exp_tmp, &exp );
    }
    *e = exp;

    return tmp;
}
#endif

/*-------------------------------------------------------------------*
+0 −10
Original line number Diff line number Diff line
@@ -684,16 +684,6 @@ void CNG_dec_fx(
        }
    }

    /* Update the frame length memory */
    st_fx->last_CNG_L_frame = st_fx->L_frame;
    move16();

    IF( NE_32( st_fx->core_brate, SID_1k75 ) )
    {
        hTdCngDec->num_ho = m;
        move16();
    }

    IF( st_fx->Opt_AMR_WB )
    {
        E_LPC_f_isp_a_conversion( st_fx->lspCNG_fx, Aq, M );
+1 −1
Original line number Diff line number Diff line
@@ -340,7 +340,7 @@ ivas_error core_switching_pre_dec_ivas_fx(
       within ACELP_CORE if switching from another bitarate to vbr, last_ppp and last_nelp is always updated in the previous frame */
    test();
    test();
    IF( EQ_16( st->core, ACELP_CORE ) && ( NE_16( st->last_core, ACELP_CORE ) || NE_16( st->last_codec_mode, MODE2 ) ) )
    IF( EQ_16( st->core, ACELP_CORE ) && ( NE_16( st->last_core, ACELP_CORE ) || EQ_16( st->last_codec_mode, MODE2 ) ) )
    {
        st->last_ppp_mode_dec = 0;
        st->last_nelp_mode_dec = 0;
+27 −14
Original line number Diff line number Diff line
@@ -1194,11 +1194,14 @@ ivas_error ivas_core_dec(

            swb_CNG_dec_ivas_fx( st, synth_fxl, hb_synth_16_fx[n], sid_bw[n], negate( q ) );

            Copy_Scale_sig_16_32( hb_synth_16_fx[n], hb_synth_32_fx[n], L_FRAME48k, add( Q11, q ) );
            Copy_Scale_sig_16_32( synth_fxl, synth_32_fx[n], L_FRAME48k, add( Q11, q ) );
            Scale_sig( st->hBWE_TD->state_lpc_syn_fx, LPC_SHB_ORDER, negate( sub( Q8, st->prev_Q_bwe_syn ) ) );
            Scale_sig32( st->hBWE_TD->genSHBsynth_Hilbert_Mem_fx, HILBERT_MEM_SIZE, negate( sub( st->prev_Q_bwe_syn2, Q11 ) ) );
            Copy_Scale_sig_16_32( st->hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx, st->hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx_32, imult1616( 2, ALLPASSSECTIONS_STEEP ), negate( sub( st->prev_Q_bwe_syn2, Q11 ) ) );
            IF( EQ_32( st->core_brate, FRAME_NO_DATA ) || EQ_32( st->core_brate, SID_2k40 ) )
            {
                Copy_Scale_sig_16_32( hb_synth_16_fx[n], hb_synth_32_fx[n], L_FRAME48k, ( Q11 + q ) );
            }
            Copy_Scale_sig_16_32( synth_fxl, synth_32_fx[n], L_FRAME48k, ( Q11 + q ) );
            Scale_sig( st->hBWE_TD->state_lpc_syn_fx, LPC_SHB_ORDER, -( Q8 - st->prev_Q_bwe_syn ) );
            Scale_sig32( st->hBWE_TD->genSHBsynth_Hilbert_Mem_fx, HILBERT_MEM_SIZE, -( st->prev_Q_bwe_syn2 - Q11 ) );
            Copy_Scale_sig_16_32( st->hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx, st->hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx_32, 2 * ALLPASSSECTIONS_STEEP, -( st->prev_Q_bwe_syn2 - Q11 ) );
        }

        /*-------------------------------------------------------------------*
@@ -1393,8 +1396,8 @@ ivas_error ivas_core_dec(
            test();
            IF( GE_16( output_frame, L_FRAME32k ) && GT_16( st->extl, SWB_CNG ) && EQ_16( st->core, ACELP_CORE ) && st->hTdCngDec != NULL )
            {
                Word16 exp, fra;
                Word16 gb;
                Word16 exp;
                Word32 fra;
                SWITCH( output_frame )
                {
                    case L_FRAME8k:
@@ -1417,14 +1420,24 @@ ivas_error ivas_core_dec(

                L_tmp = L_deposit_l( 2 ); /*0.001 in Q11*/

                gb = find_guarded_bits_fx( output_frame );
                L_tmp = L_add( L_tmp, sum2_f_32_fx( hb_synth_32_fx[n], output_frame, sub( 11, gb ) ) );
                Word16 exp2;
                exp = 20;
                move16();
                Word32 L_tmp2 = sum2_32_fx( hb_synth_32_fx[n], output_frame, &exp );
                L_tmp = BASOP_Util_Add_Mant32Exp( L_tmp, 20, L_tmp2, exp, &exp );
                L_tmp = Mpy_32_16_1( L_tmp, tmp16 );
                exp = norm_l( L_tmp );
                fra = Log2_norm_lc( L_shl( L_tmp, exp ) );
                exp = sub( sub( 30, shl( sub( Q11, 0 ), 1 ) ), exp );
                L_tmp = Mpy_32_16( exp, fra, LG10 );
                st->last_shb_ener_fx = round_fx_sat( L_shl_sat( L_tmp, 10 ) ); /*Q8*/
                exp2 = norm_l( L_tmp );
                exp = sub( exp, exp2 );
                fra = BASOP_Util_Log2( L_shl_sat( L_tmp, exp2 ) );
                exp2 = norm_l( exp );
                L_tmp = L_shl( exp, exp2 );
                exp = sub( Q31, exp2 );
                L_tmp = BASOP_Util_Add_Mant32Exp( fra, 6, L_tmp, exp, &exp );
                // exp = sub( sub( 30, shl( sub( Q11, 0 ), 1 ) ), exp );
                L_tmp = Mpy_32_16_1( L_tmp, 24660 );
                exp = add( exp, 2 );
                st->last_shb_ener_fx = round_fx_sat( L_shl_sat( L_tmp, exp - 7 ) ); /*Q8*/
                st->hTdCngDec->last_shb_ener_fx = L_shl_sat( L_tmp, exp - 20 );     /*Q11*/
            }
        }

Loading