Commit 02a63704 authored by Sandesh Venkatesh's avatar Sandesh Venkatesh
Browse files

Cleanup of float dependencies

[x] Converted proto signal computation2 and ivas_masa_stereotype_detection
[x] MASA_ISM_DATA and STEREO_DFT_DEC_DATA buffer cleanup
[x] ivas core dec cleanup
parent 1c58561f
Loading
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -2717,8 +2717,7 @@ enum
#define LG10                                  24660       /*  10*log10(2)  in Q13                 */
#define LG10_s3_0                             16440       /* 10*log10(2)/1.55 = 1.00343331 in Q14              */
#define LOG2_10                               27213      /* log base 2 of 10 in Q12 */
#define LOG10_2                               646456993      /* log base 10 of 2 in Q31 */

#define INV_LOG10_2_Q31                       646456993      /* inverse log base 10 of 2 in Q31 */
#define MU_MA_FX                              10923     /* original prediction factor for the AMR WB tables (Q15) */

#define E_MIN_FXQ15                           115     /* Q15*/
@@ -3025,6 +3024,8 @@ extern const Word16 Idx2Freq_Tbl[];
#define FS_16K_IN_NS_Q31 34360

#define ONE_BY_THREE_Q15 10923    /* 1/3.f in Q15 */
#define THREE_Q21        6291456
#define SIX_Q21          12582912

typedef enum
{
+7 −48
Original line number Diff line number Diff line
@@ -320,7 +320,7 @@ void stereo_tcx_dec_mode_switch_reconf_To_fixed(
                st->hTcxDec->tcxltp_last_gain_unmodified = (Word16) floatToFixed( st->hTcxDec->tcxltp_last_gain_unmodified_float, 15 );
                st->output_frame_fx = st->hTcxDec->L_frameTCX;
                st->hTcxDec->CngLevelBackgroundTrace_bfi_fx = floatToFixed( st->hTcxDec->CngLevelBackgroundTrace_bfi, 15 );
                st->hTcxDec->conceal_eof_gain = (Word16) floatToFixed( st->hTcxDec->conceal_eof_gain_float, 14 );
                //st->hTcxDec->conceal_eof_gain = (Word16) floatToFixed( st->hTcxDec->conceal_eof_gain_float, 14 );
            }
            IF( st->hHQ_core )
            {
@@ -363,20 +363,9 @@ void stereo_tcx_dec_mode_switch_reconf_To_fixed(
            st->last_gain_syn_deemph = 0;
            IF( hBWE_TD )
            {
                Q_state_lsyn_filt_shb = Q_factor_arr( hBWE_TD->state_lsyn_filt_shb, 6 );
                floatToFixed_arr( hBWE_TD->state_lsyn_filt_shb, hBWE_TD->state_lsyn_filt_shb_fx, Q_state_lsyn_filt_shb, 6 );
                Q_state_lsyn_filt_dwn_shb = Q_factor_arr( hBWE_TD->state_lsyn_filt_dwn_shb, 6 );
                floatToFixed_arr( hBWE_TD->state_lsyn_filt_dwn_shb, hBWE_TD->state_lsyn_filt_dwn_shb_fx, Q_state_lsyn_filt_dwn_shb, 6 );
                Q_mem_resamp_HB = Q_factor_arr( hBWE_TD->mem_resamp_HB, 13 );
                floatToFixed_arr( hBWE_TD->mem_resamp_HB, hBWE_TD->mem_resamp_HB_fx, Q_mem_resamp_HB, 13 );
                Q_syn_overlap = Q_factor_arr( hBWE_TD->syn_overlap, 20 );
                floatToFixed_arr( hBWE_TD->syn_overlap, hBWE_TD->syn_overlap_fx, Q_syn_overlap, 20 );
                Q_int_3_over_2_tbemem_dec = Q_factor_arr( hBWE_TD->int_3_over_2_tbemem_dec, 15 );
                Q_mem_resamp_HB_32k = Q_factor_arr( hBWE_TD->mem_resamp_HB_32k, 7 );
                floatToFixed_arr( hBWE_TD->int_3_over_2_tbemem_dec, hBWE_TD->int_3_over_2_tbemem_dec_fx, Q_int_3_over_2_tbemem_dec, INTERP_3_2_MEM_LEN );
                floatToFixed_arr( hBWE_TD->mem_resamp_HB_32k, hBWE_TD->mem_resamp_HB_32k_fx, Q_mem_resamp_HB_32k, 7 );
            }
            //st->TcxBandwidth = (Word16) floatToFixed( st->TcxBandwidth_float, 15 );
        }
        else
        {
@@ -405,18 +394,8 @@ void stereo_tcx_dec_mode_switch_reconf_To_fixed(

            IF( st->hBWE_TD != NULL )
            {
                Q_state_lsyn_filt_shb = Q_factor_arr( hBWE_TD->state_lsyn_filt_shb, 6 );
                Q_state_lsyn_filt_dwn_shb = Q_factor_arr( hBWE_TD->state_lsyn_filt_dwn_shb, 6 );
                Q_mem_resamp_HB = Q_factor_arr( hBWE_TD->mem_resamp_HB, 13 );
                Q_syn_overlap = Q_factor_arr( hBWE_TD->syn_overlap, 20 );
                Q_int_3_over_2_tbemem_dec = Q_factor_arr( hBWE_TD->int_3_over_2_tbemem_dec, 15 );
                Q_mem_resamp_HB_32k = Q_factor_arr( hBWE_TD->mem_resamp_HB_32k, 7 );
                fixedToFloat_arr( hBWE_TD->state_lsyn_filt_shb_fx, hBWE_TD->state_lsyn_filt_shb, Q_state_lsyn_filt_shb, 6 );
                fixedToFloat_arr( hBWE_TD->state_lsyn_filt_dwn_shb_fx, hBWE_TD->state_lsyn_filt_dwn_shb, Q_state_lsyn_filt_dwn_shb, 6 );
                fixedToFloat_arr( hBWE_TD->mem_resamp_HB_fx, hBWE_TD->mem_resamp_HB, Q_mem_resamp_HB, 13 );
                fixedToFloat_arr( hBWE_TD->syn_overlap_fx, hBWE_TD->syn_overlap, Q_syn_overlap, 20 );
                fixedToFloat_arr( hBWE_TD->int_3_over_2_tbemem_dec_fx, hBWE_TD->int_3_over_2_tbemem_dec, Q_int_3_over_2_tbemem_dec, 15 );
                fixedToFloat_arr( hBWE_TD->mem_resamp_HB_32k_fx, hBWE_TD->mem_resamp_HB_32k, Q_mem_resamp_HB_32k, 7 );
            }
            IF( st->hTcxDec )
            {
@@ -431,7 +410,7 @@ void stereo_tcx_dec_mode_switch_reconf_To_fixed(
                fixedToFloat_arr( st->hTcxDec->old_synth, st->hTcxDec->old_synth_float, Q_old_synth, OLD_SYNTH_INTERNAL_DEC );
                fixedToFloat_arr( st->hTcxDec->synth_history_fx, st->hTcxDec->synth_history, Q_synth_history, L_PROT48k + L_FRAME_MAX );
                st->hTcxDec->q_synth_history_fx = Q_synth_history;
                st->hTcxDec->conceal_eof_gain_float = fixedToFloat( st->hTcxDec->conceal_eof_gain, 14 );
                //st->hTcxDec->conceal_eof_gain_float = fixedToFloat( st->hTcxDec->conceal_eof_gain, 14 );
                st->hTcxDec->CngLevelBackgroundTrace_bfi = fixedToFloat( st->hTcxDec->CngLevelBackgroundTrace_bfi_fx, 15 );
            }

@@ -562,7 +541,7 @@ void stereo_tcx_dec_mode_switch_reconf_To_fixed_2(
                st->hTcxDec->tcxltp_last_gain_unmodified = (Word16) floatToFixed( st->hTcxDec->tcxltp_last_gain_unmodified_float, 15 );
                st->output_frame_fx = st->hTcxDec->L_frameTCX;
                st->hTcxDec->CngLevelBackgroundTrace_bfi_fx = floatToFixed( st->hTcxDec->CngLevelBackgroundTrace_bfi, 15 );
                st->hTcxDec->conceal_eof_gain = (Word16) floatToFixed( st->hTcxDec->conceal_eof_gain_float, 14 );
                //st->hTcxDec->conceal_eof_gain = (Word16) floatToFixed( st->hTcxDec->conceal_eof_gain_float, 14 );
            }
            IF( st->hHQ_core )
            {
@@ -604,18 +583,8 @@ void stereo_tcx_dec_mode_switch_reconf_To_fixed_2(
            st->last_gain_syn_deemph = 0;
            IF( hBWE_TD )
            {
                Q_state_lsyn_filt_shb = Q_factor_arr( hBWE_TD->state_lsyn_filt_shb, 6 );
                floatToFixed_arr( hBWE_TD->state_lsyn_filt_shb, hBWE_TD->state_lsyn_filt_shb_fx, Q_state_lsyn_filt_shb, 6 );
                Q_state_lsyn_filt_dwn_shb = Q_factor_arr( hBWE_TD->state_lsyn_filt_dwn_shb, 6 );
                floatToFixed_arr( hBWE_TD->state_lsyn_filt_dwn_shb, hBWE_TD->state_lsyn_filt_dwn_shb_fx, Q_state_lsyn_filt_dwn_shb, 6 );
                Q_mem_resamp_HB = Q_factor_arr( hBWE_TD->mem_resamp_HB, 13 );
                floatToFixed_arr( hBWE_TD->mem_resamp_HB, hBWE_TD->mem_resamp_HB_fx, Q_mem_resamp_HB, 13 );
                Q_syn_overlap = Q_factor_arr( hBWE_TD->syn_overlap, 20 );
                floatToFixed_arr( hBWE_TD->syn_overlap, hBWE_TD->syn_overlap_fx, Q_syn_overlap, 20 );
                Q_int_3_over_2_tbemem_dec = Q_factor_arr( hBWE_TD->int_3_over_2_tbemem_dec, 15 );
                Q_mem_resamp_HB_32k = Q_factor_arr( hBWE_TD->mem_resamp_HB_32k, 7 );
                floatToFixed_arr( hBWE_TD->int_3_over_2_tbemem_dec, hBWE_TD->int_3_over_2_tbemem_dec_fx, Q_int_3_over_2_tbemem_dec, INTERP_3_2_MEM_LEN );
                floatToFixed_arr( hBWE_TD->mem_resamp_HB_32k, hBWE_TD->mem_resamp_HB_32k_fx, Q_mem_resamp_HB_32k, 7 );
            }
        }
        else
@@ -643,21 +612,10 @@ void stereo_tcx_dec_mode_switch_reconf_To_fixed_2(
                st->hIGFDec->igfData.pSpecFlat_float = &st->hIGFDec->igfData.pSpecFlatBuf[0];
                st->hIGFDec->igfData.igfInfo.nfSeed = &st->hIGFDec->igfData.igfInfo.nfSeedBuf[0];
            }
            //st->TcxBandwidth_float = fixedToFloat( st->TcxBandwidth, 15 );
            IF( st->hBWE_TD != NULL )
            {
                Q_state_lsyn_filt_shb = Q_factor_arr( hBWE_TD->state_lsyn_filt_shb, 6 );
                Q_state_lsyn_filt_dwn_shb = Q_factor_arr( hBWE_TD->state_lsyn_filt_dwn_shb, 6 );
                Q_mem_resamp_HB = Q_factor_arr( hBWE_TD->mem_resamp_HB, 13 );
                Q_syn_overlap = Q_factor_arr( hBWE_TD->syn_overlap, 20 );
                Q_int_3_over_2_tbemem_dec = Q_factor_arr( hBWE_TD->int_3_over_2_tbemem_dec, 15 );
                Q_mem_resamp_HB_32k = Q_factor_arr( hBWE_TD->mem_resamp_HB_32k, 7 );
                fixedToFloat_arr( hBWE_TD->state_lsyn_filt_shb_fx, hBWE_TD->state_lsyn_filt_shb, Q_state_lsyn_filt_shb, 6 );
                fixedToFloat_arr( hBWE_TD->state_lsyn_filt_dwn_shb_fx, hBWE_TD->state_lsyn_filt_dwn_shb, Q_state_lsyn_filt_dwn_shb, 6 );
                fixedToFloat_arr( hBWE_TD->mem_resamp_HB_fx, hBWE_TD->mem_resamp_HB, Q_mem_resamp_HB, 13 );
                fixedToFloat_arr( hBWE_TD->syn_overlap_fx, hBWE_TD->syn_overlap, Q_syn_overlap, 20 );
                fixedToFloat_arr( hBWE_TD->int_3_over_2_tbemem_dec_fx, hBWE_TD->int_3_over_2_tbemem_dec, Q_int_3_over_2_tbemem_dec, 15 );
                fixedToFloat_arr( hBWE_TD->mem_resamp_HB_32k_fx, hBWE_TD->mem_resamp_HB_32k, Q_mem_resamp_HB_32k, 7 );
            }
            IF( st->hTcxDec )
            {
@@ -672,7 +630,7 @@ void stereo_tcx_dec_mode_switch_reconf_To_fixed_2(
                fixedToFloat_arr( st->hTcxDec->old_synth, st->hTcxDec->old_synth_float, Q_old_synth, OLD_SYNTH_INTERNAL_DEC );
                fixedToFloat_arr( st->hTcxDec->synth_history_fx, st->hTcxDec->synth_history, Q_synth_history, L_PROT48k + L_FRAME_MAX );
                st->hTcxDec->q_synth_history_fx = Q_synth_history;
                st->hTcxDec->conceal_eof_gain_float = fixedToFloat( st->hTcxDec->conceal_eof_gain, 14 );
                //st->hTcxDec->conceal_eof_gain_float = fixedToFloat( st->hTcxDec->conceal_eof_gain, 14 );
                st->hTcxDec->CngLevelBackgroundTrace_bfi = fixedToFloat( st->hTcxDec->CngLevelBackgroundTrace_bfi_fx, 15 );
                st->hTcxDec->conCngLevelBackgroundTrace = (Word16) st->hTcxDec->CngLevelBackgroundTrace_bfi_fx;
                st->hTcxDec->conCngLevelBackgroundTrace_e = 0;
@@ -750,7 +708,7 @@ void stereo_tcx_dec_mode_switch_reconf_To_fixed_2(
            st->hTcxDec->old_excFB_fx[p] = (Word16) ( st->hTcxDec->old_excFB[p] * ( 1u << st->Q_exc ) );
        }
        st->prev_Q_syn = st->Q_syn;
        st->hTcxDec->conceal_eof_gain = (Word16) floatToFixed( st->hTcxDec->conceal_eof_gain_float, Q14 );
        //st->hTcxDec->conceal_eof_gain = (Word16) floatToFixed( st->hTcxDec->conceal_eof_gain_float, Q14 );
        st->hTcxDec->conCngLevelBackgroundTrace = (Word16) floatToFixed( st->hTcxDec->CngLevelBackgroundTrace_bfi, Q15 - st->hTcxDec->conCngLevelBackgroundTrace_e );
        if ( st->hTcxDec->conNoiseLevelMemory_e[0] < 0 )
        {
@@ -870,7 +828,8 @@ void fixed_to_float_stereo_tcx_core_dec(
    }

    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->conceal_eof_gain_float = fixedToFloat( st->hTcxDec->conceal_eof_gain, Q14 );

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

+1 −1
Original line number Diff line number Diff line
@@ -189,7 +189,7 @@ static Word16 ivas_imax2_jacobsen_mag_fx(
    IF( NE_32( numer, 0 ) && NE_32( denom, 0 ) )
    {
        tmp = BASOP_Util_Divide3232_Scale( numer, denom, &tmp_e );
        tmp = shl( tmp, tmp_e );                         // Q15
        tmp = shl_sat( tmp, tmp_e );                         // Q15
        posi = shl_sat( mult_r( tmp, C_JACOB_FX ), Q1 ); // Q15
    }
    ELSE
+0 −3
Original line number Diff line number Diff line
@@ -2631,7 +2631,6 @@ void acelp_decoder_state_float2fix(Decoder_State *st, STEREO_CNG_DEC_HANDLE hSte
    //FdCng
    if ( st->hFdCngDec )
    {
        //floatToFixed_arrL( st->hFdCngDec->hFdCngCom->sidNoiseEst_flt, st->hFdCngDec->hFdCngCom->sidNoiseEst, Q31 - st->hFdCngDec->hFdCngCom->sidNoiseEstExp, NPART );
        floatToFixed_arrL( st->hFdCngDec->hFdCngCom->sidNoiseEstLp_flt, st->hFdCngDec->hFdCngCom->sidNoiseEstLp, Q31 - st->hFdCngDec->hFdCngCom->sidNoiseEstExp, NPART );
        st->hFdCngDec->hFdCngCom->cngNoiseLevelExp = Q31 - 4;
        floatToFixed_arrL(st->hFdCngDec->hFdCngCom->cngNoiseLevel_flt, st->hFdCngDec->hFdCngCom->cngNoiseLevel, Q31 - st->hFdCngDec->hFdCngCom->cngNoiseLevelExp, FFTCLDFBLEN);
@@ -2642,8 +2641,6 @@ void acelp_decoder_state_float2fix(Decoder_State *st, STEREO_CNG_DEC_HANDLE hSte
        floatToFixed_arr(st->hFdCngDec->hFdCngCom->olapBufferSynth2_flt, st->hFdCngDec->hFdCngCom->olapBufferSynth2, st->hFdCngDec->hFdCngCom->fftlenShift, FFTLEN);
        st->hFdCngDec->hFdCngCom->likelihood_noisy_speech = float_to_fix16(st->hFdCngDec->hFdCngCom->likelihood_noisy_speech_flt, Q15);
        floatToFixed_arrL( st->hFdCngDec->bandNoiseShape_float, st->hFdCngDec->bandNoiseShape, Q31 - st->hFdCngDec->bandNoiseShape_exp, FFTLEN2);
        //st->hFdCngDec->partNoiseShape_exp = 31 - Q4;
        //floatToFixed_arrL(st->hFdCngDec->partNoiseShape_float, st->hFdCngDec->partNoiseShape, Q31 - st->hFdCngDec->partNoiseShape_exp, NPART);
        /*CNA: ApplyFdCng*/
        if ((st->hFdCngDec != NULL || st->idchan == 1) && st->element_mode != IVAS_CPE_MDCT)
        {
+2 −2
Original line number Diff line number Diff line
@@ -718,11 +718,11 @@ Word16 res_bpf_adapt_fx(
    }
    error_nrg = L_shr( error_nrg, 1 );                                                                                                                           // Q0
    error_nrg = Mpy_32_16_1( error_nrg, 6553 /* 0.2f in Q15 */ );                                                                                                /* Division by 5 for average value */
    bpf_error_ratio = LT_32( ( L_shr( error_nrg, 1 ) ), res_hb_nrg ) ? (Word16) ( L_shl( ( L_shl( error_nrg, Q5 ) / res_hb_nrg ), Q7 ) ) : shl( ONE_IN_Q12, 1 ); /* Form decision variable and apply limit */
    bpf_error_ratio = LT_32( ( L_shr( error_nrg, 1 ) ), res_hb_nrg ) ? (Word16) ( L_shl( ( L_shl( error_nrg, Q5 ) / res_hb_nrg ), Q8 ) ) : shl( ONE_IN_Q12, 1 ); /* Form decision variable and apply limit */
    bpf_error_ratio = add( mult( STEREO_DFT_BPF_ADAPT_BETA_FX, bpf_error_ratio ), mult( sub( MAX_16, STEREO_DFT_BPF_ADAPT_BETA_FX ), hStereoDft->bpf_error_ratio_mem_fx ) );
    hStereoDft->bpf_error_ratio_mem_fx = bpf_error_ratio;

    res_bpf_flag = (Word16) LT_16( bpf_error_ratio, ONE_IN_Q12 );
    res_bpf_flag = (Word16) LT_16( bpf_error_ratio, ONE_IN_Q13 );

    return res_bpf_flag;
}
Loading