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

Merge branch 'LTV_stereo_omasa_crash_fixes_float_cleanup' into 'main'

LTV crash issue fix for stereo, OMASA formats and float code cleanup

See merge request !326
parents 44f2f1d6 cc2872a7
Loading
Loading
Loading
Loading
Loading
+0 −92
Original line number Diff line number Diff line
@@ -831,15 +831,6 @@ void fixed_to_float_stereo_tcx_core_dec(

    if ( EQ_16( st->core, ACELP_CORE ) )
    {

        for ( int p = 0; p < st->L_frame / 2; p++ )
        {
            //st->hTcxDec->syn_OverlFB_float[p] = (float) st->hTcxDec->syn_OverlFB[p] / (float) pow( 2, st->Q_syn );
            //st->hTcxDec->syn_Overl_float[p] = (float) st->hTcxDec->syn_Overl[p] / (float) pow( 2, st->Q_syn );
            //st->hTcxDec->old_syn_Overl_float[p] = (float) st->hTcxDec->old_syn_Overl[p] * 2 * ( 1u << st->Q_syn );
            //st->hTcxDec->syn_Overl_TDACFB_float[p] = (float) st->hTcxDec->syn_Overl_TDACFB[p] * 2 * (float) pow( 2, st->Q_syn );
            //st->hTcxDec->syn_Overl_TDAC_float[p] = (float) st->hTcxDec->syn_Overl_TDAC[p] * 2 * (float) pow( 2, st->Q_syn );
        }
        if (st->hHQ_core->Q_old_wtda >= 0)
        {
            for ( int p = 0; p < st->L_frame; p++ )
@@ -855,35 +846,8 @@ void fixed_to_float_stereo_tcx_core_dec(
                st->hHQ_core->old_out[p] = (float) st->hHQ_core->old_out_fx[p] * ( 1u << (-st->hHQ_core->Q_old_wtda) );
            }
        }
        //for ( int p = 0; p < st->L_frame; p++ )
        //{
        //    st->hTcxDec->old_excFB[p] = (float) ( st->hTcxDec->old_excFB_fx[p] ) / ( 1u << st->Q_exc );
        //}
    }

    //if ( st->lpcQuantization )
    //{
    //    st->safety_net = st->safety_net;
    //    st->mid_lsf_int = st->mid_lsf_int;
    //}

    //hTcxDec->tcxltp_last_gain_unmodified_float = fixedToFloat( hTcxDec->tcxltp_last_gain_unmodified, Q15 );

    //st->hTcxDec->conceal_eof_gain_float = fixedToFloat( st->hTcxDec->conceal_eof_gain, Q14 );

    //st->hTcxDec->CngLevelBackgroundTrace_bfi = fix16_to_float( st->hTcxDec->conCngLevelBackgroundTrace, 15 - st->hTcxDec->conCngLevelBackgroundTrace_e );

    //fixedToFloat_arr( hTcxDec->old_synth, hTcxDec->old_synth_float, 0, hTcxDec->old_synth_len );
    //fixedToFloat_arr( hTcxDec->synth_history_fx, hTcxDec->synth_history, 0, NS2SA_fx2( st->output_Fs, PH_ECU_MEM_NS ) );
    //st->hTcxDec->q_synth_history_fx = 0;

    //fixedToFloat_arr( hTcxDec->old_synthFB_fx, hTcxDec->old_synthFB, 0, NS2SA_fx2( st->output_Fs, PH_ECU_LOOKAHEAD_NS ) + hTcxDec->old_synth_lenFB );

    //if ( !st->tcxonly )
    //{
    //    fixedToFloat_arr( st->p_bpf_noise_buf, st->p_bpf_noise_buf_float, 0, L_FRAME_16k );
    //}

    st->hBPF->pst_mem_deemp_err_fx = (Word16)st->mem_error;
    /*=================================*/
    if ( st->hFdCngDec != NULL && ( st->sr_core == INT_FS_12k8 || st->sr_core == INT_FS_16k ) && st->total_brate <= MAX_ACELP_BRATE )
@@ -902,62 +866,14 @@ void fixed_to_float_stereo_tcx_core_dec(
                                                             ( ( st->element_mode == IVAS_CPE_TD || st->element_mode == IVAS_CPE_DFT ) && ( st->hFdCngDec->hFdCngCom->active_frame_counter > 0 ) ) || ( ( st->bfi == 1 ) && ( st->nbLostCmpt == 1 ) ) ) ) ||
                 ( st->m_frame_type == ZERO_FRAME ) )
            {
                //st->hTcxDec->CngLevelBackgroundTrace_bfi = fix_to_float( st->hTcxDec->CngLevelBackgroundTrace_bfi_fx, ( 31 - st->hTcxDec->CngLevelBackgroundTrace_bfi_exp ) );
                //st->hTcxDec->CngLevelBackgroundTrace_bfi = fix16_to_float( st->hTcxDec->conCngLevelBackgroundTrace, ( 15 - st->hTcxDec->conCngLevelBackgroundTrace_e) );
                //st->cngTDLevel_float = fixedToFloat( st->cngTDLevel, ( 15 - st->cngTDLevel_e ) );
                //for ( int p = 0; p < st->hFdCngDec->hFdCngCom->fftlen; p++ )
                //{
                //    st->hFdCngDec->hFdCngCom->fftBuffer_flt[p] = ( (float) st->hFdCngDec->hFdCngCom->fftBuffer[p] / ( 1u << ( 31 - st->hFdCngDec->hFdCngCom->fftBuffer_exp ) ) );
                //}
                if(( 31 - st->hFdCngDec->hFdCngCom->cngNoiseLevelExp ) >= 0)
                {
                    for ( int p = 0; p < ( st->hFdCngDec->hFdCngCom->stopFFTbin - st->hFdCngDec->hFdCngCom->startBand ); p++ )
                    {
                        st->hFdCngDec->hFdCngCom->cngNoiseLevel_flt[p] = ( (float) st->hFdCngDec->hFdCngCom->cngNoiseLevel[p] / ( 1u << ( 31 - st->hFdCngDec->hFdCngCom->cngNoiseLevelExp ) ) );
                    }
                }
                else{
                    for ( int p = 0; p < ( st->hFdCngDec->hFdCngCom->stopFFTbin - st->hFdCngDec->hFdCngCom->startBand ); p++ )
                    {
                        st->hFdCngDec->hFdCngCom->cngNoiseLevel_flt[p] = ( (float) st->hFdCngDec->hFdCngCom->cngNoiseLevel[p] * ( 1u << ( st->hFdCngDec->hFdCngCom->cngNoiseLevelExp - 31) ) );
                    }
                }
                for ( int p = 0; p < ( st->hFdCngDec->hFdCngCom->stopFFTbin - st->hFdCngDec->hFdCngCom->startBand ); p++ )
                {
                    //st->hFdCngDec->bandNoiseShape_float[p] = ( (float) st->hFdCngDec->bandNoiseShape[p] / ( 1u << ( 31 - st->hFdCngDec->bandNoiseShape_exp ) ) );
                }
                                
				                
                for ( int p = 0; p < st->hFdCngDec->npart_shaping; p++ )
                {
                    st->hFdCngDec->msNoiseEst_float[p] = (float) st->hFdCngDec->msNoiseEst[p] / ( 1u << ( 31 - st->hFdCngDec->msNoiseEst_exp ) );
					
                }
                if ( st->element_mode == IVAS_CPE_TD || st->element_mode == IVAS_CPE_DFT )
                {
                    for ( int p = 0; p < L_FRAME16k - st->hFdCngDec->hFdCngCom->startBand; p++ )
                    {
                        //st->hFdCngDec->smoothed_psd[st->hFdCngDec->hFdCngCom->startBand + p] = ( (float) st->hFdCngDec->smoothed_psd_fx[st->hFdCngDec->hFdCngCom->startBand + p] / ( 1u << ( 31 - st->hFdCngDec->msNoiseEst_exp ) ) );
                    }
                    st->hFdCngDec->q_smoothed_psd = sub( 31 , st->hFdCngDec->msNoiseEst_exp );
                }

                //int A_cng_q = 14;
                if ( st->element_mode != IVAS_CPE_MDCT || st->core == ACELP_CORE )
                {
                    //A_cng_q = 15 - norm_s( st->hFdCngDec->hFdCngCom->A_cng[0] );
                }
                //Scale_sig(st->hFdCngDec->hFdCngCom->A_cng, M + 1, A_cng_q - norm_s(st->hFdCngDec->hFdCngCom->A_cng[0] - 1));

                for ( int p = 0; p < M; p++ )
                {
                    //st->hFdCngDec->hFdCngCom->A_cng_flt[p] = ( (float) st->hFdCngDec->hFdCngCom->A_cng[p] / ( 1u << A_cng_q ) );
                }
            }
        }
    }

    //me2f_buf(st->hIGFDec->virtualSpec, st->hIGFDec->virtualSpec_e, st->hIGFDec->virtualSpecBuf, (N_MAX_TCX - IGF_START_MN));
    IF( EQ_16( st->core, TCX_20_CORE ) || EQ_16( st->core, TCX_10_CORE ) )
    {

@@ -969,14 +885,6 @@ void fixed_to_float_stereo_tcx_core_dec(
        {
            st->hHQ_core->old_out[ind] = (float) st->hHQ_core->old_out_fx[ind] / ( (float) pow( 2, st->hHQ_core->Q_old_wtda ) );
        }
        FOR( Word16 ind = 0; ind < L_FRAME32k / 2; ind++ )
        {
            //st->hTcxDec->syn_Overl_float[ind] = (float) st->hTcxDec->syn_Overl[ind] / ( (float) pow( 2, st->Q_syn + 1 ) );
        }
        FOR( Word16 ind = 0; ind < L_FRAME_MAX / 2; ind++ )
        {
            //st->hTcxDec->syn_OverlFB_float[ind] = (float) st->hTcxDec->syn_OverlFB[ind] / ( (float) pow( 2, st->Q_syn ) );
        }
    }
}
#endif // IVAS_FLOAT_FIXED
+1 −1
Original line number Diff line number Diff line
@@ -138,7 +138,7 @@ void sns_compute_scf_fx(
    FOR( i = 0; i < FDNS_NPTS; i++ )
    {
        xs[i] = Mpy_32_16_1( xs[i], pow_tilt[i] );
        xs[i] = L_shl( xs[i], Q8 ); // xs => Q12
        xs[i] = L_shl( xs[i], Q6 ); // xs => Q10
    }

    /* Noise floor at -40dB */
+13 −3
Original line number Diff line number Diff line
@@ -1206,10 +1206,12 @@ void E_LPC_f_lsp_a_conversion(const Word16 *lsp, Word16 *a, const Word16 m)
	{
#ifdef BASOP_NOGLOB
		t0 = L_max(t0, L_abs(L_add_o(f1[i], f2[i], &Overflow)));
    t0 = L_max(t0, L_abs(L_sub_o(f1[i], f2[i], &Overflow)));
#else
		t0 = L_max(t0, L_abs(L_add(f1[i], f2[i])));
#endif
    t0 = L_max(t0, L_abs(L_sub(f1[i], f2[i])));
#endif
		
	}
	k = s_min(norm_l(t0), 6);
	a[0] = shl(256, k);
@@ -1237,9 +1239,17 @@ void E_LPC_f_lsp_a_conversion(const Word16 *lsp, Word16 *a, const Word16 m)
#endif

		/* a[j] = 0.5*(f1[i] - f2[i]) */
#ifdef BASOP_NOGLOB
		t0 = L_sub_o(f1[i], f2[i], &Overflow);
#else
    t0 = L_sub(f1[i], f2[i]);
#endif
		t0 = L_shl(t0, k);
#ifdef BASOP_NOGLOB
		a[j] = round_fx_o(t0, &Overflow);             /* from Q23 to Qx and * 0.5 */
#else
    a[j] = round_fx(t0);             /* from Q23 to Qx and * 0.5 */
#endif
		j--;
	}

+14 −14
Original line number Diff line number Diff line
@@ -10980,25 +10980,25 @@ const SCALE_SETUP scaleTableMono[SIZE_SCALE_TABLE_MONO] =
const SCALE_SETUP scaleTable_cn_only[SIZE_SCALE_TABLE_CN] =
{
    { 0,     0,  8000, -3.5f,  20295/*1.2387211385 Q14*/ /*-3.5f*/, 20295 },
    { 0,  8000,  9600, -3.0f,  16306/*0.9952622652 Q14*/ /*-3.0f*/, 16306 },
    { 0,  9600, 13200, -2.5f,  12751/*0.7782794237 Q14*/ /*-2.5f*/, 12751 },
    { 0, 13200, 16400, -2.0f,   9583/*0.5848932266 Q14*/ /*-2.0f*/, 9583 },
    { 0,     0,  8000, -3.5f,  20295/*1.2387211385 Q14*/ /*-3.5f*/, -28672 },
    { 0,  8000,  9600, -3.0f,  16306/*0.9952622652 Q14*/ /*-3.0f*/, -24576 },
    { 0,  9600, 13200, -2.5f,  12751/*0.7782794237 Q14*/ /*-2.5f*/, -20480 },
    { 0, 13200, 16400, -2.0f,   9583/*0.5848932266 Q14*/ /*-2.0f*/, -16384 },
    { 0, 16400,128001,  0.0f,      0/*0.0000000000 Q14*/ /* 0.0f*/, 0 },
    { 1,     0,  8000, -3.0f,  16306/*0.9952622652 Q14*/ /*-3.0f*/, 16306 },
    { 1,  8000,  9600, -2.5f,  12751/*0.7782794237 Q14*/ /*-2.5f*/, 12751 },
    { 1,  9600, 13200, -1.5f,   6759/*0.4125375748 Q14*/ /*-1.5f*/, 6759 },
    { 1, 13200, 16400, -2.5f,  12751/*0.7782794237 Q14*/ /*-2.5f*/, 12751 },
    { 1, 16400, 24400, -0.5f,   1999/*0.1220184565 Q14*/ /*-0.5f*/, 1999 },
    { 1,     0,  8000, -3.0f,  16306/*0.9952622652 Q14*/ /*-3.0f*/, -24576 },
    { 1,  8000,  9600, -2.5f,  12751/*0.7782794237 Q14*/ /*-2.5f*/, -20480 },
    { 1,  9600, 13200, -1.5f,   6759/*0.4125375748 Q14*/ /*-1.5f*/, -12288 },
    { 1, 13200, 16400, -2.5f,  12751/*0.7782794237 Q14*/ /*-2.5f*/, -20480 },
    { 1, 16400, 24400, -0.5f,   1999/*0.1220184565 Q14*/ /*-0.5f*/, -4096 },
    { 1, 24400,128001,  0.0f,      0/*0.0000000000 Q14*/ /* 0.0f*/, 0 },
    { 2,     0,  8000, -2.5f,  12751/*0.7782794237 Q14*/ /*-2.5f*/, 12751 },
    { 2,  8000,  9600, -2.5f,  12751/*0.7782794237 Q14*/ /*-2.5f*/, 12751 },
    { 2,  9600, 13200, -2.0f,   9583/*0.5848932266 Q14*/ /*-2.0f*/, 9583 },
    { 2, 13200, 16400, -1.0f,   4242/*0.2589254379 Q14*/ /*-1.0f*/, 4242 },
    { 2,     0,  8000, -2.5f,  12751/*0.7782794237 Q14*/ /*-2.5f*/, -20480 },
    { 2,  8000,  9600, -2.5f,  12751/*0.7782794237 Q14*/ /*-2.5f*/, -20480 },
    { 2,  9600, 13200, -2.0f,   9583/*0.5848932266 Q14*/ /*-2.0f*/, -16384 },
    { 2, 13200, 16400, -1.0f,   4242/*0.2589254379 Q14*/ /*-1.0f*/, -8192 },
    { 2, 16400, 24400, -0.5f,   1999/*0.1220184565 Q14*/ /*-0.5f*/, 1999 },
    { 2, 16400, 24400, -0.5f,   1999/*0.1220184565 Q14*/ /*-0.5f*/, -4096 },
    { 2, 24400, 32000,  0.0f,      0/*0.0000000000 Q14*/ /* 0.0f*/, 0 },
    { 2, 32000,128001,  0.0f,      0/*0.0000000000 Q14*/ /* 0.0f*/, 0 }
};
+1 −1
Original line number Diff line number Diff line
@@ -461,7 +461,7 @@ typedef struct
    Word16  exp_cldfb_periodog;

    Word32  cngNoiseLevel[FFTCLDFBLEN];  /* Noise level applied for the CNG in each (sub)band */
    Word16 q_cngNoiseLevel;
    //Word16 q_cngNoiseLevel;
    Word16  cngNoiseLevelExp;

    int16_t seed;                     /* Seed memory (for random function) */
Loading