Commit 798b61c5 authored by Sandesh Venkatesh's avatar Sandesh Venkatesh
Browse files

Merge branch '3gpp_issue_835_fix' into 'main'

Refactor computation of cx buffer in ParamMC to be bandwise

See merge request !556
parents 807d26cb 17417c9b
Loading
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -1708,6 +1708,19 @@ void synchro_synthesis_fx(

// ivas_dirac_output_synthesis_cov
void ivas_dirac_dec_output_synthesis_cov_param_mc_collect_slot_fx(
#ifdef FIX_835_PARAMMC_BUFFER_VALUES
    Word32 *RealBuffer_fx,                                                          /* i  : input channel filter bank samples (real part)         */
    Word16 RealBuffer_e,                                                            /* i  : exponent input channel filter bank samples (real part)*/
    Word32 *ImagBuffer_fx,                                                          /* i  : input channel filter bank samples (imaginary part     */
    Word16 ImagBuffer_e,                                                            /* i  : exponent input channel filter bank samples (real part)*/
    Word32 cx_fx[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS],      /* o  : accumulated input covariance (real part)              */
    Word16 *cx_e,                                                                   /* i  : exponent for accumulated input covariance (real part) */
    Word32 cx_imag_fx[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS], /* o  : accumulated input covariance (imaginary part)         */
    Word16 *cx_imag_e,                                                              /* i : exponent accumulated input covariance (imag part)      */
    PARAM_MC_DEC_HANDLE hParamMC,                                                   /* i  : handle to Parametric MC state                         */
    const Word16 param_band,                                                        /* i  : parameter band                                        */
    const Word16 nchan_in                                                           /* i  : number of input channels                              */
#else
    Word32 *RealBuffer_fx,                                                                                        /* i  : input channel filter bank samples (real part)         */
    Word16 RealBuffer_e,                                                                                          /* i  : exponent input channel filter bank samples (real part)*/
    Word32 *ImagBuffer_fx,                                                                                        /* i  : input channel filter bank samples (imaginary part     */
@@ -1718,6 +1731,7 @@ void ivas_dirac_dec_output_synthesis_cov_param_mc_collect_slot_fx(
    Word16 *cx_imag_e,                                                                                            /* i : exponent accumulated input covariance (imag part)      */
    PARAM_MC_DEC_HANDLE hParamMC,                                                                                 /* i  : handle to Parametric MC state                         */
    const Word16 nchan_in                                                                                         /* i  : number of input channels                              */
#endif
);

void configureFdCngDec_ivas_fx(
+1 −0
Original line number Diff line number Diff line
@@ -170,6 +170,7 @@

#define FIX_854_HILBERT_SCALING                 /* VA: reduce lost of precision due to unnecessary scaling, reduce a lot the 2 kHz tone */
#define FIX_856_EXTRACT_L                       /* VA: Fix undesirable wrap-around */
#define FIX_835_PARAMMC_BUFFER_VALUES                   /* FhG: issue 835: wide range of buffer values for cx in ParamMC */
/* ################## End DEVELOPMENT switches ######################### */

/* clang-format on */
+114 −0
Original line number Diff line number Diff line
@@ -732,7 +732,120 @@ void ivas_dirac_dec_output_synthesis_cov_param_mc_collect_slot(
 *
 * collect the multi channel input covariance for one filter bank time slot
 *-------------------------------------------------------------------*/
#ifdef FIX_835_PARAMMC_BUFFER_VALUES
void ivas_dirac_dec_output_synthesis_cov_param_mc_collect_slot_fx(
    Word32 *RealBuffer_fx,                                                          /* i  : input channel filter bank samples (real part)         */
    Word16 RealBuffer_e,                                                            /* i  : exponent input channel filter bank samples (real part)*/
    Word32 *ImagBuffer_fx,                                                          /* i  : input channel filter bank samples (imaginary part     */
    Word16 ImagBuffer_e,                                                            /* i  : exponent input channel filter bank samples (real part)*/
    Word32 cx_fx[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS],      /* o  : accumulated input covariance (real part)              */
    Word16 *cx_e,                                                                   /* i  : exponent for accumulated input covariance (real part) */
    Word32 cx_imag_fx[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS], /* o  : accumulated input covariance (imaginary part)         */
    Word16 *cx_imag_e,                                                              /* i : exponent accumulated input covariance (imag part)      */
    PARAM_MC_DEC_HANDLE hParamMC,                                                   /* i  : handle to Parametric MC state                         */
    const Word16 param_band,                                                        /* i  : parameter band                                        */
    const Word16 nchan_in                                                           /* i  : number of input channels                              */
)
{
    Word16 cx_init_e[PARAM_MC_MAX_PARAMETER_BANDS];
    Word16 cx_init_imag_e[PARAM_MC_MAX_PARAMETER_BANDS];
    Word16 band_idx, ch_idx;
    Word16 brange[2];
    Word32 real_in_buffer_fx[PARAM_MC_MAX_BANDS_IN_PARAMETER_BAND * MAX_TRANSPORT_CHANNELS];
    Word16 real_in_e;
    Word32 imag_in_buffer_fx[PARAM_MC_MAX_BANDS_IN_PARAMETER_BAND * MAX_TRANSPORT_CHANNELS];
    Word16 imag_in_e;
    Word32 real_buffer_fx[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS];
    Word32 imag_buffer_fx[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS];
    Word16 output_e;
    Word16 i, j, tmp1, tmp2, tmp1_e, tmp2_e, shift_imag, shift_real;
    Word32 L_tmp;
    Word16 band, num_bands;

    /* estimate input covariance */
    /* Already stack here instead of in the process_subframe */

    /* collect input frame */
    brange[0] = hParamMC->band_grouping[param_band];
    move16();
    brange[1] = hParamMC->band_grouping[param_band + 1];
    move16();
    num_bands = sub( brange[1], brange[0] );

    FOR( band_idx = 0; band_idx < num_bands; band_idx++ )
    {
        band = add( brange[0], band_idx );
        FOR( ch_idx = 0; ch_idx < nchan_in; ch_idx++ )
        {
            real_in_buffer_fx[add( band_idx, imult1616( num_bands, ch_idx ) )] = RealBuffer_fx[add( imult1616( ch_idx, hParamMC->num_freq_bands ), band )];
            move32();
            imag_in_buffer_fx[add( band_idx, imult1616( num_bands, ch_idx ) )] = ImagBuffer_fx[add( imult1616( ch_idx, hParamMC->num_freq_bands ), band )];
            move32();
        }
    }

    real_in_e = RealBuffer_e;
    move16();
    imag_in_e = ImagBuffer_e;
    move16();
    shift_real = sub( L_norm_arr( real_in_buffer_fx, imult1616( num_bands, nchan_in ) ), find_guarded_bits_fx( num_bands + 1 ) );
    shift_imag = sub( L_norm_arr( imag_in_buffer_fx, imult1616( num_bands, nchan_in ) ), find_guarded_bits_fx( num_bands + 1 ) );

    real_in_e = sub( real_in_e, shift_real );
    imag_in_e = sub( imag_in_e, shift_imag );


    output_e = s_max( real_in_e, imag_in_e );

    FOR( i = 0; i < num_bands * nchan_in; ++i )
    {
        real_in_buffer_fx[i] = L_shr( real_in_buffer_fx[i], sub( output_e, RealBuffer_e ) );
        move32();
        imag_in_buffer_fx[i] = L_shr( imag_in_buffer_fx[i], sub( output_e, ImagBuffer_e ) );
        move32();
    }

    cmplx_matrix_square_fx( real_in_buffer_fx, imag_in_buffer_fx, num_bands, nchan_in, real_buffer_fx, imag_buffer_fx, output_e, &output_e );
    v_add_fixed_me( cx_fx, *cx_e, real_buffer_fx, output_e, cx_fx, &tmp1_e, imult1616( nchan_in, nchan_in ), 1 );

    v_add_fixed_me( cx_imag_fx, *cx_imag_e, imag_buffer_fx, output_e, cx_imag_fx, &tmp2_e, imult1616( nchan_in, nchan_in ), 1 );
    cx_init_e[0] = tmp1_e;
    move16();
    cx_init_imag_e[0] = tmp2_e;
    move16();

    // normalizing both the matrices to a common exponent for a better precision
    tmp1 = 0;
    move16();
    tmp2 = 0;
    move16();

    FOR( j = 0; j < PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS; j++ )
    {
        L_tmp = BASOP_Util_Add_Mant32Exp( cx_fx[j], cx_init_e[0], 0, 0, &tmp1_e );
        L_tmp = BASOP_Util_Add_Mant32Exp( cx_imag_fx[j], cx_init_imag_e[0], 0, 0, &tmp2_e );
        tmp1 = s_max( tmp1, tmp1_e );
        tmp2 = s_max( tmp2, tmp2_e );
    }

    FOR( j = 0; j < PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS; j++ )
    {
        L_tmp = BASOP_Util_Add_Mant32Exp( cx_fx[j], cx_init_e[0], 0, 0, &tmp1_e );
        cx_fx[j] = L_shr( L_tmp, sub( tmp1, tmp1_e ) );
        move32();
        L_tmp = BASOP_Util_Add_Mant32Exp( cx_imag_fx[j], cx_init_imag_e[0], 0, 0, &tmp2_e );
        cx_imag_fx[j] = L_shr( L_tmp, sub( tmp2, tmp2_e ) );
        move32();
    }

    *cx_e = tmp1;
    move16();
    *cx_imag_e = tmp2;
    move16();

    return;
}
#else
void ivas_dirac_dec_output_synthesis_cov_param_mc_collect_slot_fx(
    Word32 *RealBuffer_fx,                                                                                        /* i  : input channel filter bank samples (real part)         */
    Word16 RealBuffer_e,                                                                                          /* i  : exponent input channel filter bank samples (real part)*/
@@ -855,6 +968,7 @@ void ivas_dirac_dec_output_synthesis_cov_param_mc_collect_slot_fx(
    return;
}
#endif
#endif

/*-------------------------------------------------------------------*
 * ivas_dirac_dec_output_synthesis_cov_param_mc_synthesise_slot()
+695 −0

File changed.

Preview size limit exceeded, changes collapsed.