Commit 3345c1ea authored by Nishant S Kulgod's avatar Nishant S Kulgod
Browse files

commit 1

parent 0df52ff5
Loading
Loading
Loading
Loading
Loading
+89 −85

File changed.

Preview size limit exceeded, changes collapsed.

+27 −33
Original line number Diff line number Diff line
@@ -216,30 +216,29 @@ ivas_error ivas_cpe_enc_fx(
#endif
    }

    Copy32( data_fx_ch0, sts[0]->input32_fx, input_frame ); // Q(q_data_fx)
    sts[0]->q_inp32 = q_data_fx;
    Word16 Q_min = s_min( q_data_fx, add( sts[0]->q_inp32, L_norm_arr( sts[0]->input32_fx - input_frame, input_frame ) ) );
    scale_sig32( sts[0]->input32_fx - input_frame, input_frame, sub( Q_min, sts[0]->q_inp32 ) );
    Copy_Scale_sig32( data_fx_ch0, sts[0]->input32_fx, input_frame, sub( Q_min, q_data_fx ) ); // Q(Q_min)
    sts[0]->q_inp32 = Q_min;
    move16();

    Word16 norm = L_norm_arr( sts[0]->input32_fx, input_frame );
    scale_sig32( sts[0]->input32_fx, input_frame, norm );
    sts[0]->q_inp32 = add( sts[0]->q_inp32, norm );
    move16();

    Copy_Scale_sig32_16( sts[0]->input32_fx, sts[0]->input_fx, input_frame, 0 );
    sts[0]->q_inp = sub( sts[0]->q_inp32, Q16 );
    Copy_Scale_sig32_16( sts[0]->input32_fx, sts[0]->input_fx, input_frame, norm );
    sts[0]->q_inp = add( sub( sts[0]->q_inp32, Q16 ), norm );
    move16();
    IF( data_fx_ch1 != NULL ) /*this may happen for cases with odd number of channels*/
    {
        Copy32( data_fx_ch1, sts[1]->input32_fx, input_frame ); // Q(q_data_fx)
        sts[1]->q_inp32 = q_data_fx;
        Q_min = s_min( q_data_fx, add( sts[1]->q_inp32, L_norm_arr( sts[1]->input32_fx - input_frame, input_frame ) ) );
        scale_sig32( sts[1]->input32_fx - input_frame, input_frame, sub( Q_min, sts[1]->q_inp32 ) );
        Copy_Scale_sig32( data_fx_ch1, sts[1]->input32_fx, input_frame, sub( Q_min, q_data_fx ) ); // Q(Q_min)
        sts[1]->q_inp32 = Q_min;
        move16();

        norm = L_norm_arr( sts[1]->input32_fx, input_frame );
        scale_sig32( sts[1]->input32_fx, input_frame, norm );
        sts[1]->q_inp32 = add( sts[1]->q_inp32, norm );
        move16();

        Copy_Scale_sig32_16( sts[1]->input32_fx, sts[1]->input_fx, input_frame, 0 );
        sts[1]->q_inp = sub( sts[1]->q_inp32, Q16 );
        Copy_Scale_sig32_16( sts[1]->input32_fx, sts[1]->input_fx, input_frame, norm );
        sts[1]->q_inp = add( sub( sts[1]->q_inp32, Q16 ), norm );
        move16();
    }

@@ -369,24 +368,6 @@ ivas_error ivas_cpe_enc_fx(
    /*----------------------------------------------------------------*
     * Set TD stereo parameters
     *----------------------------------------------------------------*/
    Copy_Scale_sig_16_32_no_sat( sts[1]->input_fx, sts[1]->input32_fx, input_frame, sub( Q11, sts[1]->q_inp ) ); /* Q11 */
    Copy_Scale_sig_16_32_no_sat( sts[0]->input_fx, sts[0]->input32_fx, input_frame, sub( Q11, sts[0]->q_inp ) ); /* Q11 */
    Word16 shift = getScaleFactor32( sts[1]->input32_fx, input_frame );
    scale_sig32( sts[1]->input32_fx, input_frame, shift ); /* Q11 + shift */
    sts[1]->q_inp32 = add( Q11, shift );
    move16();

    shift = getScaleFactor32( sts[0]->input32_fx, input_frame );
    scale_sig32( sts[0]->input32_fx, input_frame, shift ); /* Q11 + shift */
    sts[0]->q_inp32 = add( Q11, shift );
    move16();

    Q_inp = s_min( Q_inp, s_min( sts[0]->q_inp32, sts[1]->q_inp32 ) );
    scale_sig32( sts[0]->input32_fx, input_frame, sub( Q_inp, sts[0]->q_inp32 ) ); /* Q_inp */
    scale_sig32( sts[1]->input32_fx, input_frame, sub( Q_inp, sts[1]->q_inp32 ) ); /* Q_inp */
    sts[1]->q_inp32 = sts[0]->q_inp32 = Q_inp;
    move16();
    move16();

    IF( ( error = stereo_set_tdm_fx( hCPE, input_frame, Q_inp ) ) != IVAS_ERR_OK )
    {
@@ -397,7 +378,7 @@ ivas_error ivas_cpe_enc_fx(
    /*----------------------------------------------------------------*
     * Resets/updates in case of stereo switching
     *----------------------------------------------------------------*/
    shift = norm_arr( sts[1]->old_input_signal_fx, input_frame );
    Word16 shift = norm_arr( sts[1]->old_input_signal_fx, input_frame );
    Scale_sig( sts[1]->old_input_signal_fx, input_frame, shift ); /* sts[1]->q_old_inp + shift  */
    sts[1]->q_old_inp = add( sts[1]->q_old_inp, shift );
    move16();
@@ -741,6 +722,8 @@ ivas_error ivas_cpe_enc_fx(
            move16();
        }
        stereo_tdm_downmix_ivas_fx( hCPE->hStereoTD, sts[0]->input_fx, sts[1]->input_fx, input_frame, tdm_ratio_idx, tdm_SM_flag, tdm_ratio_idx_SM );
        Copy_Scale_sig_16_32_no_sat( sts[0]->input_fx, sts[0]->input32_fx, input_frame, sub( sts[0]->q_inp32, sts[0]->q_inp ) );
        Copy_Scale_sig_16_32_no_sat( sts[1]->input_fx, sts[1]->input32_fx, input_frame, sub( sts[1]->q_inp32, sts[1]->q_inp ) );

        /* signal the bitrate for BW selection in the SCh */
        sts[0]->bits_frame_channel = 0;
@@ -831,6 +814,9 @@ ivas_error ivas_cpe_enc_fx(
        move16();
        move16();
        stereo_dft_enc_synthesize_fx( hCPE->hStereoDft, sts[0]->input32_fx, &out_start_ind, &out_end_ind, 0, input_Fs, input_Fs, 0, NULL );
        Scale_sig32( sts[0]->input32_fx - input_frame, add( out_start_ind, input_frame ), sub( Q15, sts[0]->q_inp32 ) ); // scaling initial part of the input buffer
        sts[0]->q_inp32 = Q15;
        move16();

        // Normalise the input buffer from Q15
        Word16 input_norm, q_inp32, common_q, fir_delay_len;
@@ -890,6 +876,9 @@ ivas_error ivas_cpe_enc_fx(
        set16_fx( sts[1]->input_fx, 0, input_frame );
        sts[1]->q_inp = Q15;
        move16();
        set32_fx( sts[1]->input32_fx, 0, input_frame );
        sts[1]->q_inp32 = Q31;
        move16();
    }

#ifdef DEBUG_MODE_INFO
@@ -1232,6 +1221,9 @@ ivas_error ivas_cpe_enc_fx(
            Copy( orig_input_fx[n], sts[n]->old_input_signal_fx, input_frame ); /* Q_orig_inp */
            sts[n]->q_old_inp = Q_orig_inp[n];
            move16();
            Copy_Scale_sig_16_32_no_sat( sts[n]->input_fx - input_frame, sts[n]->input32_fx - input_frame, input_frame, 16 ); // duplicating the data for input32_fx
            sts[n]->q_inp32 = add( Q_orig_inp[n], 16 );
            move16();
        }
    }
    ELSE IF( EQ_16( hCPE->element_mode, IVAS_CPE_DFT ) )
@@ -1239,6 +1231,7 @@ ivas_error ivas_cpe_enc_fx(
        Copy( sts[0]->input_fx, sts[0]->old_input_signal_fx, input_frame ); /* sts[n]->q_inp */
        sts[0]->q_old_inp = sts[0]->q_inp;
        move16();
        Copy32( sts[0]->input32_fx, sts[0]->input32_fx - input_frame, input_frame ); /* st->q_inp32 */
    }
    ELSE IF( st_ivas->hMCT == NULL ) /* note: in MCT, input buffers are updated later in ivas_mct_enc() */
    {
@@ -1248,6 +1241,7 @@ ivas_error ivas_cpe_enc_fx(
            Copy( sts[n]->input_fx, sts[n]->old_input_signal_fx, input_frame ); /* sts[n]->q_inp */
            sts[n]->q_old_inp = sts[n]->q_inp;
            move16();
            Copy32( sts[n]->input32_fx, sts[n]->input32_fx - input_frame, input_frame ); /* st->q_inp32 */
        }
    }

+35 −4
Original line number Diff line number Diff line
@@ -666,14 +666,45 @@ ivas_error front_vad_spar_fx(

        old_pitch = st->pitch[1];
        move16();
        Scale_sig( wsp_fx, 368, sub( Q8, Q_inp_12k8 ) ); // Q8
        pitch_ol_ivas_fx( st->pitch, st->voicing_fx, &st->old_pitch, &st->old_corr_fx, corr_shift_fx, &st->old_thres_fx, &st->delta_pit, st->old_wsp2_fx, wsp_fx, st->mem_decim2_fx, relE_fx, st->clas, st->input_bwidth, st->Opt_SC_VBR, Q8 );
        Word16 shift, Q_wsp;
        Word16 shift1 = norm_arr( old_wsp_fx, L_WSP_MEM );
        Word16 shift2 = norm_arr( wsp_fx, L_WSP - L_WSP_MEM );
        maximum_abs_16_fx( old_wsp_fx, L_WSP_MEM, &shift );
        if ( !shift )
        {
            shift1 = Q15;
            move16();
        }
        maximum_abs_16_fx( wsp_fx, L_WSP - L_WSP_MEM, &shift );
        if ( !shift )
        {
            shift2 = Q15;
            move16();
        }

        shift = s_min( Q15, s_min( add( Q_inp_12k8, shift1 ), add( Q_inp_12k8, shift2 ) ) );
        shift = s_min( shift, add( norm_arr( st->mem_decim2_fx, 3 ), st->Q_old_wsp2 ) );
        shift = s_min( shift, add( norm_arr( st->old_wsp2_fx, ( L_WSP_MEM - L_INTERPOL ) / OPL_DECIM ), st->Q_old_wsp2 ) );

        scale_sig( old_wsp_fx, L_WSP_MEM, sub( shift, Q_inp_12k8 ) );
        scale_sig( wsp_fx, L_WSP - L_WSP_MEM, sub( shift, Q_inp_12k8 ) );

        Q_wsp = shift;
        move16();

        scale_sig( st->mem_decim2_fx, 3, sub( Q_wsp, st->Q_old_wsp2 ) );                                    // Q( mem_decim ) = Q( old_wsp2 )
        scale_sig( st->old_wsp2_fx, ( L_WSP_MEM - L_INTERPOL ) / OPL_DECIM, sub( Q_wsp, st->Q_old_wsp2 ) ); // Q_wsp

        st->Q_old_wsp2 = Q_wsp;
        move16();

        pitch_ol_ivas_fx( st->pitch, st->voicing_fx, &st->old_pitch, &st->old_corr_fx, corr_shift_fx, &st->old_thres_fx, &st->delta_pit, st->old_wsp2_fx, wsp_fx, st->mem_decim2_fx, relE_fx, st->clas, st->input_bwidth, st->Opt_SC_VBR, Q_wsp );

        /* Updates for adaptive lag window memory */
        st->old_pitch_la = st->pitch[2]; /* Q0 */
        move16();
        Scale_sig( wsp_fx, 368, Q9 - Q8 ); /* Q9 */
        StableHighPitchDetect_ivas_fx( &flag_spitch, st->pitch, st->voicing_fx, wsp_fx, st->localVAD, &st->voicing_sm_fx, &st->voicing0_sm_fx, &st->LF_EnergyRatio_sm_fx, &st->predecision_flag, &st->diff_sm_fx, &st->energy_sm_fx, Q12, st->lgBin_E_fx );

        StableHighPitchDetect_ivas_fx( &flag_spitch, st->pitch, st->voicing_fx, wsp_fx, st->localVAD, &st->voicing_sm_fx, &st->voicing0_sm_fx, &st->LF_EnergyRatio_sm_fx, &st->predecision_flag, &st->diff_sm_fx, &st->energy_sm_fx, Q_wsp, st->lgBin_E_fx );
        IF( st->hSpMusClas != NULL )
        {
            Word16 dummy_int;
+9 −15
Original line number Diff line number Diff line
@@ -165,10 +165,14 @@ ivas_error ivas_ism_enc_fx(
        /*------------------------------------------------------------------*
         * Initialization - general
         *-----------------------------------------------------------------*/
        Copy32( data[sce_id], st->input32_fx, input_frame ); // Q(q_data)
        q_st_inp_16 = sub( L_norm_arr( st->input32_fx, input_frame ), 16 );
        Copy_Scale_sig_32_16( st->input32_fx, st->input_fx, input_frame, q_st_inp_16 ); // q_data -> Q(q_inp + q_data)
        st->q_inp = add( q_st_inp_16, q_data );
        Word16 Q_min = s_min( q_data, add( st->q_inp32, L_norm_arr( st->input32_fx - input_frame, input_frame ) ) );
        scale_sig32( st->input32_fx - input_frame, input_frame, sub( Q_min, st->q_inp32 ) );
        Copy_Scale_sig32( data[sce_id], st->input32_fx, input_frame, sub( Q_min, q_data ) ); // Q(Q_min)
        st->q_inp32 = Q_min;
        move16();
        q_st_inp_16 = sub( getScaleFactor32( st->input32_fx, input_frame ), 16 );
        Copy_Scale_sig_32_16( st->input32_fx, st->input_fx, input_frame, q_st_inp_16 ); // Q_min -> Q(q_inp + Q_min)
        st->q_inp = add( q_st_inp_16, Q_min );
        move16();

        st->element_mode = IVAS_SCE;
@@ -275,16 +279,6 @@ ivas_error ivas_ism_enc_fx(
     *-----------------------------------------------------------------*/

    /* compute the dominant sce_id using long term energy */
    FOR( Word16 j = 0; j < st_ivas->nchan_transport; j++ )
    {
        test();
        IF( st_ivas->hSCE[j] && st_ivas->hSCE[j]->hCoreCoder[0] )
        {
            Copy_Scale_sig_16_32_no_sat( st_ivas->hSCE[j]->hCoreCoder[0]->input_fx, st_ivas->hSCE[j]->hCoreCoder[0]->input32_fx, input_frame, sub( Q11, st_ivas->hSCE[j]->hCoreCoder[0]->q_inp ) ); /* Q11 */
            st_ivas->hSCE[j]->hCoreCoder[0]->q_inp32 = Q11;
            move16();
        }
    }

    IF( st_ivas->hEncoderConfig->Opt_DTX_ON )
    {
@@ -479,7 +473,7 @@ ivas_error ivas_ism_enc_fx(

        Copy( st->input_fx, st->old_input_signal_fx, input_frame ); /* st->q_inp */
        st->q_old_inp = st->q_inp;
        move16();
        Copy32( st->input32_fx, st->input32_fx - input_frame, input_frame ); /* st->q_inp32 */

        hSCE->last_element_brate = hSCE->element_brate; /* Q0 */
        move32();
+8 −3
Original line number Diff line number Diff line
@@ -122,10 +122,14 @@ ivas_error ivas_sce_enc_fx(

    set16_zero_fx( old_inp_12k8_fx[0], L_INP_12k8 );

    Copy32( data_fx, st->input32_fx, input_frame ); // Q(q_data_fx)
    q_input = sub( add( L_norm_arr( st->input32_fx, input_frame ), q_data_fx ), 16 );
    Word16 Q_min = s_min( q_data_fx, add( st->q_inp32, L_norm_arr( st->input32_fx - input_frame, input_frame ) ) );
    scale_sig32( st->input32_fx - input_frame, input_frame, sub( Q_min, st->q_inp32 ) );
    Copy_Scale_sig32( data_fx, st->input32_fx, input_frame, sub( Q_min, q_data_fx ) ); // Q(Q_min)
    st->q_inp32 = Q_min;
    move16();
    q_input = sub( add( L_norm_arr( st->input32_fx, input_frame ), Q_min ), 16 );

    Copy_Scale_sig32_16( st->input32_fx, st->input_fx, input_frame, sub( add( Q16, q_input ), q_data_fx ) ); // Q(q_data_fx) -> Q(q_input)
    Copy_Scale_sig32_16( st->input32_fx, st->input_fx, input_frame, sub( add( Q16, q_input ), Q_min ) ); // Q(Q_min) -> Q(q_input)
    st->q_inp = q_input;
    move16();

@@ -362,6 +366,7 @@ ivas_error ivas_sce_enc_fx(
    Copy( st->input_fx, st->old_input_signal_fx, input_frame );
    st->q_old_inp = st->q_inp;
    move16();
    Copy32( st->input32_fx, st->input32_fx - input_frame, input_frame ); /* st->q_inp32 */
    hSCE->last_element_brate = hSCE->element_brate;
    move32();

Loading