Commit b6cd72eb authored by Mohammadreza Naghibzadeh's avatar Mohammadreza Naghibzadeh
Browse files

Merge remote-tracking branch 'origin/main' into 1962_fix_format_conv_spectral_diff_opt

# Conflicts:
#	lib_com/options.h
parents 3ecfd529 cb50e441
Loading
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -77,12 +77,15 @@
#define FIX_1942_ASSERTION_LOWSHELF                          /* FhG: Modified the target_gains_db_fx calculation in compute_t60_coeffs_fx() */
#define FIX_1944_CRASH_FOR_STEREO                            /* FhG: improve TonalMDCTConceal_InsertNoise calculation precision */
#define FIX_1970_SBA_CRASH                                   /* Dlb: Fix for issue 1970, SBA crash */

#define FIX_1978_SAT_MISSING_IN_GAIN_ENC                     /* VA:  Fix add saturation missing that lead to a crash in P800-10 */

#define FIX_1979_SAT_MISSING_IN_LSF_ENC                      /* VA: Proposal to fix 1979, saturation in lsf_enc, NOkia to review */
#define FIX_1946_CRASH_JBM_PROCESSING                        /* FhG: Increased guard bits of DFT_fx */
#define FIX_1980_CRASH_FDCNG_ENCODESID                       /* FhG: Add one bit of headroom in e_fx calculation in FdCng_encodeSID_ivas_fx() */
#define FIX_1987_CRASH_OMASA_ENERGY                          /* FhG: Replace cldfbAnalysis_ts_fx_fix_q() with cldfbAnalysis_ts_fx_var_q() to avoid assertion error */
#define FIX_1985_SBA_714_HF_LOSS                             /* Dlb: Fix for issue 1985, improved dirac ref pow precision*/

#define FIX_1962_FORMAT_CONV_SPECTRAL_DIFF                   /* FhG: Improved precision of targetEnergy in ivas_ls_setup_conversion_process_mdct_fx() */
/* #################### Start BASOP porting switches ############################ */

+52 −0
Original line number Diff line number Diff line
@@ -2632,10 +2632,48 @@ void protoSignalComputation4_fx(
    Word32 sq_tmp_fx;
    Word32 *p_proto_buffer_fx;
    Word16 min_q_shift, q_shift;
#ifndef FIX_1985_SBA_714_HF_LOSS
    Word16 min_q_shift2, q_shift2;
#endif
    Word32 re, im;
    Word16 proto_power_smooth_fx_q, sq_tmp_q;
#ifdef FIX_1985_SBA_714_HF_LOSS
    Word64 ref_pow64[CLDFB_NO_CHANNELS_MAX], re64;
    Word16 sf1, sf2;
#endif

#ifdef FIX_1985_SBA_714_HF_LOSS
    FOR( l = 0; l < num_freq_bands; l++ )
    {
        re64 = W_mult_32_32( RealBuffer_fx[0][0][l], RealBuffer_fx[0][0][l] );
        re64 = W_mac_32_32( re64, ImagBuffer_fx[0][0][l], ImagBuffer_fx[0][0][l] );
        ref_pow64[l] = W_shr( re64, 1 ); // 2*q_cldfb +1
        move64();
    }
    FOR( k = 1; k < 4; k++ )
    {
        FOR( l = 0; l < num_freq_bands; l++ )
        {
            re64 = W_mult_32_32( RealBuffer_fx[k][0][l], RealBuffer_fx[k][0][l] );
            re64 = W_mac_32_32( re64, ImagBuffer_fx[k][0][l], ImagBuffer_fx[k][0][l] );
            ref_pow64[l] = W_add( ref_pow64[l], W_shr( re64, 1 ) ); // 2*q_cldfb +1
            move64();
        }
    }
    sf1 = W_norm_arr( ref_pow64, s_min( CLDFB_NO_CHANNELS_HALF, num_freq_bands ) );
    FOR( l = 0; l < s_min( CLDFB_NO_CHANNELS_HALF, num_freq_bands ); l++ )
    {
        reference_power_fx[l] = W_extract_h( W_shl( ref_pow64[l], sf1 ) );
    }
    reference_power_q[0] = sub( add( shl( q_cldfb, 1 ), sf1 ), 31 );

    sf2 = W_norm_arr( &ref_pow64[CLDFB_NO_CHANNELS_HALF], s_max( 0, sub( num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ) );
    FOR( l = CLDFB_NO_CHANNELS_HALF; l < num_freq_bands; l++ )
    {
        reference_power_fx[l] = W_extract_h( W_shl( ref_pow64[l], sf2 ) );
    }
    reference_power_q[1] = sub( add( shl( q_cldfb, 1 ), sf2 ), 31 );
#else
    min_q_shift = Q31;
    move16();
    q_shift = Q31;
@@ -2695,8 +2733,22 @@ void protoSignalComputation4_fx(
    sq_tmp_q = sub( add( add( q_cldfb, min_q_shift2 ), add( q_cldfb, min_q_shift2 ) ), 31 );
    reference_power_q[1] = sq_tmp_q;
    move16();
#endif

#ifdef FIX_1985_SBA_714_HF_LOSS
    min_q_shift = Q31;
    /* calculate the shift possible for both RealBuffer_fx and ImagBuffer_fx buffers*/
    FOR( k = 0; k < s_max( 4, nchan_transport ); k++ )
    {
        q_shift = L_norm_arr( RealBuffer_fx[k][0], num_freq_bands );
        min_q_shift = s_min( q_shift, min_q_shift );
        q_shift = L_norm_arr( ImagBuffer_fx[k][0], num_freq_bands );
        min_q_shift = s_min( q_shift, min_q_shift );
    }
    min_q_shift = sub( min_q_shift, find_guarded_bits_fx( 2 ) );
#else
    min_q_shift = sub( s_min( q_shift, q_shift2 ), find_guarded_bits_fx( 2 ) );
#endif

    /*For decorrelated diffuseness*/
    FOR( l = 0; l < num_outputs_diff; l++ )