Commit d61cd826 authored by Sandesh Venkatesh's avatar Sandesh Venkatesh
Browse files

Merge branch 'bug_fixes_front_vad_preproc_front' into 'main'

Bug fixes in front vad and pre-proc front functions

See merge request !1545
parents 77f336c1 59ddeb18
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -620,7 +620,7 @@ void ivas_analy_sp_fx(
    *q_fr_bands = add( *q_fr_bands, exp );
    move16();

    exp = sub( getScaleFactor32( band_energies, 2 * NB_BANDS ), 1 );
    exp = getScaleFactor32( band_energies, 2 * NB_BANDS );
    scale_sig32( band_energies, 2 * NB_BANDS, exp ); /* q_band_energies + exp */
    *q_band_energies = add( *q_band_energies, exp );
    move16();
+23 −60
Original line number Diff line number Diff line
@@ -945,78 +945,41 @@ ivas_error pre_proc_front_ivas_fx(
        test();
        IF( st->idchan == 0 || EQ_16( element_mode, IVAS_CPE_MDCT ) )
        {
            test();
            test();
            IF( EQ_16( element_mode, IVAS_CPE_TD ) && lr_vad_enabled && band_energies_LR_fx != NULL )
            Word16 norm;
            norm = L_norm_arr( st->hFdCngEnc->msPeriodog_fx, NPART );
            IF( NE_16( norm, Q31 ) )
            {
                Word16 normmsPeriodog_fx = Q31, zero_flag = 0;
                scale_sig32( st->hFdCngEnc->msPeriodog_fx, NPART, norm ); // exp:st->hFdCngEnc->msPeriodog_fx_exp-norm
                st->hFdCngEnc->msPeriodog_fx_exp = sub( st->hFdCngEnc->msPeriodog_fx_exp, norm );
                st->hFdCngEnc->msPeriodog_fx_exp_cldfb = sub( st->hFdCngEnc->msPeriodog_fx_exp_cldfb, norm );
                st->hFdCngEnc->msPeriodog_fx_exp_fft = sub( st->hFdCngEnc->msPeriodog_fx_exp_fft, norm );
                move16();
                move16();
                zero_flag = get_zero_flag( st->hFdCngEnc->msPeriodog_fx, NPART );
                IF( zero_flag )
                {
                    normmsPeriodog_fx = getScaleFactor32( st->hFdCngEnc->msPeriodog_fx, NPART );
                move16();
            }
                st->hFdCngEnc->msPeriodog_fx_exp_cldfb = sub( 31, normmsPeriodog_fx );
                st->hFdCngEnc->msPeriodog_fx_exp_fft = sub( 31, normmsPeriodog_fx );
                move16();
                move16();
                Scale_sig32( st->hFdCngEnc->msPeriodog_fx, NPART, normmsPeriodog_fx ); /* exp(st->hFdCngEnc->msPeriodog_fx_exp - normmsPeriodog_fx) */
                st->hFdCngEnc->msPeriodog_fx_exp = sub( st->hFdCngEnc->msPeriodog_fx_exp, normmsPeriodog_fx );
                Word16 msNoiseEst_Q = Q31;
                move16();
                move16();
                zero_flag = get_zero_flag( st->hFdCngEnc->msNoiseEst_old_fx, NPART );
                IF( zero_flag )
            norm = L_norm_arr( st->hFdCngEnc->msNoiseEst_old_fx, NPART );
            IF( NE_16( norm, Q31 ) )
            {
                    msNoiseEst_Q = getScaleFactor32( st->hFdCngEnc->msNoiseEst_old_fx, NPART );
                    scale_sig32( st->hFdCngEnc->msNoiseEst_old_fx, NPART, msNoiseEst_Q ); /* exp(st->hFdCngEnc->msNoiseEst_old_fx_exp - msNoiseEst_Q) */
                    st->hFdCngEnc->msNoiseEst_old_fx_exp = sub( st->hFdCngEnc->msNoiseEst_old_fx_exp, msNoiseEst_Q );
                scale_sig32( st->hFdCngEnc->msNoiseEst_old_fx, NPART, norm ); // exp:st->hFdCngEnc->msNoiseEst_old_fx_exp-norm
                st->hFdCngEnc->msNoiseEst_old_fx_exp = sub( st->hFdCngEnc->msNoiseEst_old_fx_exp, norm );
                move16();
            }

            test();
            test();
            IF( EQ_16( element_mode, IVAS_CPE_TD ) && lr_vad_enabled && band_energies_LR_fx != NULL )
            {
                perform_noise_estimation_enc_ivas_fx( band_energies_LR_fx, sub( Q31, band_energies_LR_fx_q ), enerBuffer_fx, *enerBuffer_fx_exp, st->hFdCngEnc, input_Fs, hCPE );
            }
            ELSE
            {
                Word16 normmsPeriodog_fx = Q31, zero_flag = 0;
                move16();
                move16();
                shift = getScaleFactor32( band_energies_fx, 2 * NB_BANDS );
                scale_sig32( band_energies_fx, 2 * NB_BANDS, shift );
                q_band_energies = add( q_band_energies, shift );

                zero_flag = get_zero_flag( st->hFdCngEnc->msPeriodog_fx, NPART ); /* Q0 */
                IF( zero_flag )
                {
                    normmsPeriodog_fx = getScaleFactor32( st->hFdCngEnc->msPeriodog_fx, NPART );
                }
                st->hFdCngEnc->msPeriodog_fx_exp_cldfb = sub( 31, normmsPeriodog_fx );
                st->hFdCngEnc->msPeriodog_fx_exp_fft = sub( 31, normmsPeriodog_fx );
                move16();
                move16();
                Scale_sig32( st->hFdCngEnc->msPeriodog_fx, NPART, normmsPeriodog_fx ); /* exp(st->hFdCngEnc->msPeriodog_fx_exp - normmsPeriodog_fx)*/
                st->hFdCngEnc->msPeriodog_fx_exp = sub( st->hFdCngEnc->msPeriodog_fx_exp, normmsPeriodog_fx );
                move16();
                Word16 msNoiseEst_Q = Q31;
                move16();
                zero_flag = get_zero_flag( st->hFdCngEnc->msNoiseEst_old_fx, NPART ); /* Q0 */
                IF( zero_flag )
                norm = L_norm_arr( st->hFdCngEnc->hFdCngCom->periodog, PERIODOGLEN );
                IF( NE_16( norm, Q31 ) )
                {
                    msNoiseEst_Q = getScaleFactor32( st->hFdCngEnc->msNoiseEst_old_fx, NPART );
                    scale_sig32( st->hFdCngEnc->msNoiseEst_old_fx, NPART, msNoiseEst_Q ); /* exp(st->hFdCngEnc->msNoiseEst_old_fx_exp - msNoiseEst_Q) */
                    st->hFdCngEnc->msNoiseEst_old_fx_exp = sub( st->hFdCngEnc->msNoiseEst_old_fx_exp, msNoiseEst_Q );
                    move16();
                }
                zero_flag = get_zero_flag( st->hFdCngEnc->hFdCngCom->periodog, PERIODOGLEN ); /* Q0 */
                Word16 normmsperiodog = 31;
                    scale_sig32( st->hFdCngEnc->hFdCngCom->periodog, PERIODOGLEN, norm ); // exp:st->hFdCngEnc->hFdCngCom->exp_cldfb_periodog-norm
                    st->hFdCngEnc->hFdCngCom->exp_cldfb_periodog = sub( st->hFdCngEnc->hFdCngCom->exp_cldfb_periodog, norm );
                    move16();
                IF( zero_flag )
                {
                    normmsperiodog = getScaleFactor32( st->hFdCngEnc->hFdCngCom->periodog, PERIODOGLEN );
                }
                st->hFdCngEnc->hFdCngCom->exp_cldfb_periodog = sub( 31, normmsperiodog );
                move16();

                perform_noise_estimation_enc_ivas_fx( band_energies_fx, sub( Q31, q_band_energies ), enerBuffer_fx, *enerBuffer_fx_exp, st->hFdCngEnc, input_Fs, hCPE );
            }
+3 −3
Original line number Diff line number Diff line
@@ -241,9 +241,9 @@ ivas_error front_vad_fx(

            PREEMPH_FX( hFrontVad->buffer_12k8_fx + L_FFT / 2, PREEMPH_FAC, L_FRAME, &hFrontVad->mem_preemph_fx );

            Q_new = add( sub( Q_inp, Qband ), Q_add );
            Scale_sig( hFrontVad->buffer_12k8_fx, L_FFT / 2, sub( Q_new, Q_buffer[n] ) );                           /* Q_new */
            Scale_sig( hFrontVad->buffer_12k8_fx + L_FFT / 2, 384 - L_FFT / 2, sub( Q_new, add( Q_inp, Qband ) ) ); /* Q_new */
            Q_new = s_min( add( add( Q_inp, Qband ), Q_add ), Q_buffer[n] );
            scale_sig( hFrontVad->buffer_12k8_fx, L_FFT / 2, sub( Q_new, Q_buffer[n] ) );                                       /* Q_new */
            scale_sig( hFrontVad->buffer_12k8_fx + L_FFT / 2, 3 * L_FRAME / 2 - L_FFT / 2, sub( Q_new, add( Q_inp, Qband ) ) ); /* Q_new */

            Q_buffer[n] = Q_new;
            move16();