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

LTV crash fixes and encoder float structure elements cleanup - 2

parent 9cb31d7d
Loading
Loading
Loading
Loading
Loading
+3 −4
Original line number Diff line number Diff line
@@ -286,10 +286,9 @@ ivas_error pre_proc_ivas(
    const int32_t element_brate,                                /* i  : element bitrate                         */
    const int32_t last_element_brate,                           /* i  : last element bitrate                    */
    const int16_t input_frame,                                  /* i  : frame length                            */
    float old_inp_12k8[],                                       /* i/o: buffer of old input signal              */
    Word16 old_inp_12k8_fx[],                                       /* i/o: buffer of old input signal              */
    float old_inp_16k[],                                        /* i/o: buffer of old input signal @ 16kHz      */
    float **inp,                                                /* o  : ptr. to inp. signal in the current frame*/
    Word16 old_inp_16k_fx[],                                        /* i/o: buffer of old input signal @ 16kHz      */
    Word16 **inp_fx,                                                /* o  : ptr. to inp. signal in the current frame*/
    Word32 *ener_fx,                                            /* o  : residual energy from Levinson-Durbin Q6 */
    Word16 A[NB_SUBFR16k * ( M + 1 )],                           /* i/o: A(z) unquantized for the 4 subframes    */
    Word16 Aw[NB_SUBFR16k * ( M + 1 )],                          /* i/o: weighted A(z) unquantized for subframes */
@@ -299,7 +298,7 @@ ivas_error pre_proc_ivas(
    Word16 lsp_mid[M],                                           /* i/o: LSPs in the middle of the frame         */
    Word16 *new_inp_resamp16k_fx,                                   /* o  : new input signal @16kHz, non pre-emphasised, used by the WB TBE/BWE */
    int16_t *Voicing_flag,                                      /* o  : voicing flag for HQ FEC                 */
    float old_wsp[],                                      /* i  : weighted input signal buffer            */
    Word16 old_wsp_fx[],                                      /* i  : weighted input signal buffer            */
    const int16_t loc_harm,                                     /* i  : harmonicity flag                        */
#ifndef IVAS_FLOAT_FIXED
    const float cor_map_sum,                                    /* i  : speech/music clasif. parameter          */
+2 −2
Original line number Diff line number Diff line
@@ -5876,8 +5876,8 @@ static Word32 non_linearity_scaled_copy_ivas(
        }
        FOR( ; i < length; i++ )
        {
            L_tmp = L_mult( input[i], input[i] );    /* 2*Q_inp+1 */
            L_tmp = Mult_32_32( L_tmp, prev_scale ); /* 2*Q_inp */
            /* L_tmp = (input[i] * input[i]) * prev_scale;*/
            L_tmp = Mpy_32_16_1( Mpy_32_16_1( prev_scale, input[i] ), input[i] ); /* 2*Q_inp */

            test();
            test();
+7 −7
Original line number Diff line number Diff line
@@ -297,18 +297,18 @@ static void find_enr_dft_fx(
            te = W_shl( te, te_exp );             // 2 * Q_inp_dmx + te_exp
            BinE_fx[bin_cnt] = W_extract_h( te ); // 2 * Q_inp_dmx + te_exp - 32
            move32();
            g_fx = L_sub( L_shr( g_1_fx, guarded_bits ), Mpy_32_32( g_2_fx, c_fx ) );
            tmp_fx = L_sub( Mpy_32_32( c_fx, c_1_fx ), Mpy_32_32( s_fx, s_1_fx ) );
            s_fx = L_add( Mpy_32_32( s_fx, c_1_fx ), Mpy_32_32( c_fx, s_1_fx ) );
            c_fx = tmp_fx;
            g_fx = L_sub( L_shr( g_1_fx, guarded_bits ), Mpy_32_32( g_2_fx, c_fx ) ); // 30 - guarded_bits
            tmp_fx = L_sub( Mpy_32_32( c_fx, c_1_fx ), Mpy_32_32( s_fx, s_1_fx ) );   // 31 - guarded_bits
            s_fx = L_add( Mpy_32_32( s_fx, c_1_fx ), Mpy_32_32( c_fx, s_1_fx ) );     // 31 - guarded_bits
            c_fx = tmp_fx;                                                            // 31 - guarded_bits
            move32();

            Word64 ngmult = W_mult0_32_32( norm_val_fx, g_fx ); // Q31 + Q31 - gaurded_bits
            Word64 ngmult = W_mult0_32_32( norm_val_fx, g_fx ); // Q31 + Q30 - gaurded_bits
            Word16 ngmult_exp = W_norm( ngmult );
            ngmult = W_shl( ngmult, ngmult_exp );                                    // Q31 + Q31 - gaurded_bits + ngmult_exp
            ngmult = W_shl( ngmult, ngmult_exp );                                    // Q31 + Q30 - gaurded_bits + ngmult_exp
            BinE_fx[bin_cnt] = Mpy_32_32( W_extract_h( ngmult ), BinE_fx[bin_cnt] ); //(Q31 + Q31 - gaurded_bits + ngmult_exp) - Q32 + (2 * Q_inp_dmx + te_exp - 32) - 31
            move32();
            BinE_fx[bin_cnt] = L_shl( BinE_fx[bin_cnt], sub( *Qout, sub( sub( add( add( shl( Q_inp_dmx, 1 ), te_exp ), ngmult_exp ), 34 ), guarded_bits ) ) );
            BinE_fx[bin_cnt] = L_shl_sat( BinE_fx[bin_cnt], sub( *Qout, sub( sub( add( add( shl( Q_inp_dmx, 1 ), te_exp ), ngmult_exp ), 34 ), guarded_bits ) ) );
            move32();
            // To Be Checked
            band_fx[i] = L_add_sat( BinE_fx[bin_cnt], band_fx[i] );
+1 −1
Original line number Diff line number Diff line
@@ -567,7 +567,7 @@ void gauss2v_fx(
            }
            ELSE
            {
                if ( L_msu( L_shl( L_mult( cor2w_mantissa, eneri_mantissa ), difference_norm ), cor2_mantissa, enerw_mantissa ) < 0 )
                if ( L_msu_sat( L_shl( L_mult( cor2w_mantissa, eneri_mantissa ), difference_norm ), cor2_mantissa, enerw_mantissa ) < 0 ) // Saturation to be revisited
                {
                    update_best = 1;
                    move16();
+36 −33
Original line number Diff line number Diff line
@@ -170,34 +170,36 @@ ivas_error init_encoder(
    init_gp_clip( st->clip_var );
    pitch_ol_init( &st->old_thres, &st->old_pitch, &st->delta_pit, &st->old_corr );
    set_f( st->old_wsp, 0, L_WSP_MEM );
    set_f( st->old_wsp2, 0, ( L_WSP_MEM - L_INTERPOL ) / OPL_DECIM );
#else
    init_gp_clip_fx( st->clip_var_fx );
    pitch_ol_init_fx( &st->old_thres_fx, &st->old_pitch, &st->delta_pit, &st->old_corr_fx );
#endif
#ifdef IVAS_FLOAT_FIXED
    set16_fx( st->old_wsp_fx, 0, L_WSP_MEM );
    st->exp_old_wsp = 0;
    move16();
    set16_fx( st->old_wsp2_fx, 0, ( L_WSP_MEM - L_INTERPOL ) / OPL_DECIM ); // Needs to change depending on usage.
    st->Q_old_wsp2 = Q15;
    move16();
#endif

#ifndef IVAS_FLOAT_FIXED
    set_f( st->old_wsp2, 0, ( L_WSP_MEM - L_INTERPOL ) / OPL_DECIM );
    st->mem_preemph = 0.0f;
    st->mem_preemph16k = 0.0f;
    st->mem_preemph_enc_flt = 0.0;
#endif

    st->mem_preemph = 0.0f;
#ifdef IVAS_FLOAT_FIXED
#else
    st->mem_preemph_fx = 0;
    st->mem_preemph16k_fx = 0;
    st->mem_preemph_enc = 0;
    st->exp_mem_preemph_enc = 0;
    st->mem_deemp_preQ_fx = 0;
#endif

    /* AVQ pre-quantizer memory */
#ifndef IVAS_FLOAT_FIXED
    st->mem_preemp_preQ = 0.0f;
    st->mem_deemp_preQ = 0.0f;
#else
    st->mem_preemp_preQ_fx = 0;
    st->mem_deemp_preQ_fx = 0;
#endif
    st->last_nq_preQ = 0;
    st->last_code_preq = 0;
@@ -219,9 +221,6 @@ ivas_error init_encoder(
    st->mem_wsp_q = 0;
    move16();
    set16_fx( st->mem_decim2_fx, 0, 3 );
    set16_fx( st->old_wsp2_fx, 0, ( L_WSP_MEM - L_INTERPOL ) / OPL_DECIM ); // Needs to change depending on usage.
    st->Q_old_wsp2 = Q15;
    move16();
#endif
#endif

@@ -324,17 +323,20 @@ ivas_error init_encoder(
    st->spike_hyst = -1;

    /* stereo switching memories */
#ifndef IVAS_FLOAT_FIXED
    st->mem_preemph_DFT = 0.0f;
    set_f( st->inp_12k8_mem_stereo_sw, 0, STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT );
    st->mem_preemph16k_DFT = 0.0f;
    set_f( st->inp_16k_mem_stereo_sw, 0, STEREO_DFT_OVL_16k - L_MEM_RECALC_16K - L_FILT16k );
#ifdef IVAS_FLOAT_FIXED
#else
    st->mem_preemph_DFT_fx = 0;
    set16_fx( st->inp_12k8_mem_stereo_sw_fx, 0, sub( sub( STEREO_DFT_OVL_12k8, L_MEM_RECALC_12K8 ), L_FILT ) );
    set16_fx( st->inp_12k8_mem_stereo_sw_fx, 0, STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT );
    st->mem_preemph16k_DFT_fx = 0;
    set16_fx( st->inp_16k_mem_stereo_sw_fx, 0, sub( sub( STEREO_DFT_OVL_16k, L_MEM_RECALC_16K ), L_FILT16k ) );
    st->sharpFlag = 0;
    set16_fx( st->inp_16k_mem_stereo_sw_fx, 0, STEREO_DFT_OVL_16k - L_MEM_RECALC_16K - L_FILT16k );
#endif

    st->sharpFlag = 0;

    /* Stationary noise UV modification  */
#ifndef IVAS_FLOAT_FIXED
    st->ge_sm = 10;
@@ -438,9 +440,13 @@ ivas_error init_encoder(

#ifdef IVAS_FLOAT_FIXED
        st->Bin_E_old_fx = st->hSignalBuf->Bin_E_old_fx;
#endif
        st->mem_decim_fx = st->hSignalBuf->mem_decim_fx;
        st->mem_decim16k_fx = st->hSignalBuf->mem_decim16k_fx;
#else
        st->Bin_E_old = st->hSignalBuf->Bin_E_old;
        st->mem_decim = st->hSignalBuf->mem_decim_flt;
        st->mem_decim16k = st->hSignalBuf->mem_decim16k_flt;
#endif
        st->old_inp_12k8 = st->hSignalBuf->old_inp_12k8_flt;
        st->old_inp_16k = st->hSignalBuf->old_inp_16k_flt;
#ifdef IVAS_FLOAT_FIXED
@@ -463,17 +469,22 @@ ivas_error init_encoder(
#endif
        /* initializations */

#ifdef IVAS_FLOAT_FIXED
        set32_fx( st->Bin_E_old_fx, 0, L_FFT / 2 );
        st->q_Bin_E_old = Q31;
        move16();
        set16_fx( st->mem_decim_fx, 0, 2 * L_FILT_MAX );
        set16_fx( st->mem_decim16k_fx, 0, 2 * L_FILT_MAX );
#else
        set_f( st->Bin_E_old, 0, L_FFT / 2 );
        set_f( st->mem_decim, 0, 2 * L_FILT_MAX );
        set_f( st->mem_decim16k, 0, 2 * L_FILT_MAX );
#endif
        set_f( st->old_inp_12k8, 0, L_INP_MEM );
        set_f( st->old_inp_16k, 0, L_INP_MEM );
#ifdef IVAS_FLOAT_FIXED
        set32_fx( st->Bin_E_old_fx, 0, L_FFT / 2 );
        st->q_Bin_E_old = Q31;
        move16();
        set16_fx( st->old_inp_12k8_fx, 0, L_INP_MEM );
        set16_fx( st->old_inp_16k_fx, 0, L_INP_MEM );
        set16_fx( st->mem_decim_fx, 0, 2 * L_FILT_MAX );
        st->input_buff_fx = st->hSignalBuf->input_buff;
        st->input_buff32_fx = st->hSignalBuf->input_buff32;
        set32_fx( st->hSignalBuf->input_buff32, 0, L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ) );
@@ -513,12 +524,15 @@ ivas_error init_encoder(
    else
    {
        st->hSignalBuf = NULL;
#ifndef IVAS_FLOAT_FIXED
        st->Bin_E_old = NULL;
        st->mem_decim = NULL;
#ifdef IVAS_FLOAT_FIXED
        st->mem_decim16k = NULL;
#else
        st->Bin_E_old_fx = NULL;
        st->mem_decim_fx = NULL;
        st->mem_decim16k_fx = NULL;
#endif
        st->mem_decim16k = NULL;
        st->old_inp_12k8 = NULL;
        st->old_inp_16k = NULL;
#ifndef IVAS_FLOAT_FIXED
@@ -1399,11 +1413,6 @@ ivas_error init_encoder_ivas_fx(
    move16();

#if 1 // TODO: Float Initializations. To be removed later
    st->mem_preemph = 0.0f;
    st->mem_preemph_DFT = 0.0f;
    set_f( st->inp_12k8_mem_stereo_sw, 0, STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT );
    st->mem_preemph16k_DFT = 0.0f;
    set_f( st->inp_16k_mem_stereo_sw, 0, STEREO_DFT_OVL_16k - L_MEM_RECALC_16K - L_FILT16k );
    st->active_cnt = 0;
#ifndef IVAS_FLOAT_FIXED
    st->old_hpfilt_in = 0.0f;
@@ -1646,8 +1655,6 @@ ivas_error init_encoder_ivas_fx(
            st->input_fx = st->input_buff_fx + frame_length;
        }
#if 1 // TODO: To be removed later
        st->mem_decim = st->hSignalBuf->mem_decim_flt;
        st->mem_decim16k = st->hSignalBuf->mem_decim16k_flt;
        st->old_inp_12k8 = st->hSignalBuf->old_inp_12k8_flt;
        st->old_inp_16k = st->hSignalBuf->old_inp_16k_flt;
#ifndef IVAS_FLOAT_FIXED
@@ -1655,8 +1662,6 @@ ivas_error init_encoder_ivas_fx(
        st->buf_speech_enc_flt = st->hSignalBuf->buf_speech_enc_flt;
        st->buf_wspeech_enc_flt = st->hSignalBuf->buf_wspeech_enc_flt;
#endif
        set_f( st->mem_decim, 0, 2 * L_FILT_MAX );
        set_f( st->mem_decim16k, 0, 2 * L_FILT_MAX );
        set_f( st->old_inp_12k8, 0, L_INP_MEM );
        set_f( st->old_inp_16k, 0, L_INP_MEM );
#ifndef IVAS_FLOAT_FIXED
@@ -1679,8 +1684,6 @@ ivas_error init_encoder_ivas_fx(
        st->buf_wspeech_enc = NULL;
        st->input_buff_fx = NULL;
#if 1
        st->mem_decim = NULL;
        st->mem_decim16k = NULL;
        st->old_inp_12k8 = NULL;
        st->old_inp_16k = NULL;
#ifndef IVAS_FLOAT_FIXED
Loading