Commit 924d09ab authored by Manuel Jander's avatar Manuel Jander
Browse files

Increase precision of computeTargetPSDs_direct_subframe_fx().

parent 9917716d
Loading
Loading
Loading
Loading
Loading
+15 −5
Original line number Diff line number Diff line
@@ -4136,10 +4136,12 @@ static void computeTargetPSDs_direct_subframe_fx(
    Word32 *cy_cross_dir_smooth, /*q_cy_cross_dir_smooth*/
    Word16 *q_cy_cross_dir_smooth )
{
    Word16 ch_idx, cur_idx, i, q_tmp;
#ifdef FIX_867_CLDFB_NRG_SCALE
    Word16 ch_idx, cur_idx, q_tmp;
    Word32 L_tmp[CLDFB_NO_CHANNELS_MAX];
    Word16 q_cy_auto_dir_smooth_local[2];
#else
    Word16 ch_idx, cur_idx, i, q_tmp;
    Word64 W_tmp[CLDFB_NO_CHANNELS_MAX], W_max;
    set64_fx( W_tmp, 0, CLDFB_NO_CHANNELS_MAX );
#endif
@@ -4148,19 +4150,21 @@ static void computeTargetPSDs_direct_subframe_fx(
    Word32 direct_power[CLDFB_NO_CHANNELS_MAX]; /* size: num_freq_bands. */

    /* estimate direct and diffuse power */
#ifndef FIX_867_CLDFB_NRG_SCALE
    FOR( i = 0; i < num_freq_bands; i++ )
    {
        direct_power[i] = Mpy_32_32( direct_power_factor[i], reference_power[i] );
        move32();
#ifndef FIX_867_CLDFB_NRG_SCALE
        test();
        if ( direct_power[i] == 0 && ( direct_power_factor[i] != 0 && reference_power[i] != 0 ) )
        {
            direct_power[i] = 1;
            move32();
        }
#endif
    }
#else
    v_mult_fixed( direct_power_factor, reference_power, direct_power, num_freq_bands );
#endif
    /* compute target auto and cross PSDs of current frame (smoothed) */
    FOR( ch_idx = 0; ch_idx < num_channels; ++ch_idx )
    {
@@ -4206,9 +4210,15 @@ static void computeTargetPSDs_direct_subframe_fx(
        q_tmp = L_norm_arr( &direct_responses_square[cur_idx], num_freq_bands );
        Copy_Scale_sig32( &direct_responses_square[cur_idx], L_tmp, num_freq_bands, q_tmp );
        v_mult_fixed( direct_power, L_tmp, &cy_auto_dir_smooth[cur_idx], num_freq_bands ); // (q_reference_power, q_tmp) -> q_reference_power + q_tmp
        Scale_sig32( &cy_auto_dir_smooth[cur_idx] + CLDFB_NO_CHANNELS_HALF, s_max( sub( num_freq_bands, CLDFB_NO_CHANNELS_HALF ), 0 ), sub( q_reference_power[0], q_reference_power[1] ) );
        q_cy_auto_dir_smooth[ch_idx] = add( q_reference_power[0], q_tmp );

        q_cy_auto_dir_smooth_local[0] = add( add( q_reference_power[0], q_tmp ), L_norm_arr( cy_auto_dir_smooth + cur_idx, s_min( num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ) );
        q_cy_auto_dir_smooth_local[1] = add( add( q_reference_power[1], q_tmp ), L_norm_arr( cy_auto_dir_smooth + cur_idx + CLDFB_NO_CHANNELS_HALF, s_max( sub( num_freq_bands, CLDFB_NO_CHANNELS_HALF ), 0 ) ) );
        q_cy_auto_dir_smooth[ch_idx] = s_min( q_cy_auto_dir_smooth_local[0], q_cy_auto_dir_smooth_local[1] );
        move16();

        Scale_sig32( cy_auto_dir_smooth + cur_idx, s_min( num_freq_bands, CLDFB_NO_CHANNELS_HALF ) , sub( q_cy_auto_dir_smooth[ch_idx], add( q_reference_power[0], q_tmp ) ) );
        Scale_sig32( cy_auto_dir_smooth + cur_idx + CLDFB_NO_CHANNELS_HALF, s_max( sub( num_freq_bands, CLDFB_NO_CHANNELS_HALF ), 0 ), sub(  q_cy_auto_dir_smooth[ch_idx], add( q_reference_power[1], q_tmp ) ) );

#endif
        v_mult_fixed( direct_power, &direct_responses[cur_idx], &cy_cross_dir_smooth[cur_idx], num_freq_bands ); // (q_reference_power, Q31) -> q_reference_power
#ifdef FIX_867_CLDFB_NRG_SCALE