Commit 55a4521d authored by Manuel Jander's avatar Manuel Jander
Browse files

Reduce differences to main. Remove out of scope division change in...

Reduce differences to main. Remove out of scope division change in ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx(). Simplify reference power calculation in computeTargetPSDs_direct_subframe_fx().
parent 313863b0
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -3844,6 +3844,7 @@ void ivas_dirac_dec_render_sf_fx(
            move16();
        }
#endif

        exp = getScaleFactor32( hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_fx, i_mult( hDirACRend->h_output_synthesis_psd_params.max_band_decorr, hDirACRend->hOutSetup.nchan_out_woLFE ) );
        scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_fx, i_mult( hDirACRend->h_output_synthesis_psd_params.max_band_decorr, hDirACRend->hOutSetup.nchan_out_woLFE ), exp ); // Q(hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_q + exp)
        hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_q = add( hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_q, exp );
@@ -3930,6 +3931,7 @@ void ivas_dirac_dec_render_sf_fx(
            }
        }
#endif

        FOR( ch = 0; ch < hDirACRend->hOutSetup.nchan_out_woLFE; ch++ )
        {
            FOR( slot_idx = 0; slot_idx < hSpatParamRendCom->subframe_nbslots[subframe_idx]; slot_idx++ )
+35 −23
Original line number Diff line number Diff line
@@ -314,6 +314,7 @@ ivas_error ivas_dirac_dec_output_synthesis_open_fx(
        dirac_output_synthesis_state->reference_power_smooth_prev_q = Q31;
        move16();
#endif

        IF( ( dirac_output_synthesis_state->direction_smoothness_prev_fx = (Word32 *) malloc( hSpatParamRendCom->num_freq_bands * sizeof( Word32 ) ) ) == NULL )
        {
            return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis\n" ) );
@@ -1987,7 +1988,7 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx(
    Word16 alphaMaxBinFast;
    Word32 L_tmp;
    Word16 exp_arr[CLDFB_NO_CHANNELS_MAX * MAX_OUTPUT_CHANNELS];
#if 0
#if 1
    Word16 exp = 0, exp1, tmp, q_com, q_tmp, min_exp;
#else
    Word16 exp = 0, exp1, q_com, q_tmp, min_exp;
@@ -2219,7 +2220,7 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx(

        exp = 0;
        move16();
#if 0
#if 1
        tmp = BASOP_Util_Divide3232_Scale( weightedDirectionSmoothness, L_add( sumWeight, EPSILON_FX ), &exp ); /*Q(15-exp)*/
        smoothedDirectionSmoothness = L_shl_sat( L_deposit_l( tmp ), add( sub( Q31, Q15 ), exp ) );             // Q31
#else
@@ -2367,6 +2368,7 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx(

    p_power_smooth_prev = h_dirac_output_synthesis_state->proto_power_smooth_prev_fx;
    p_power_smooth = h_dirac_output_synthesis_state->proto_power_smooth_fx;

    FOR( k = 0; k < num_protos_dir; k++ )
    {
        FOR( l = 0; l < num_freq_bands; l++ )
@@ -2556,6 +2558,7 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx(
                                      add( q_cy_auto_dir_smooth_prev_local[k], q_tmp ) ),
                                 Q31 ) );
#endif

            *( p_gains_dir ) = Sqrt32( L_tmp, &exp ); // (Q31 - exp)
            move32();
            *( p_gains_dir ) = L_shl_sat( *( p_gains_dir ), sub( h_dirac_output_synthesis_state->gains_dir_prev_q, sub( Q31, exp ) ) ); // gains_dir_prev_q
@@ -4147,6 +4150,9 @@ static void computeTargetPSDs_direct_subframe_fx(
    Word16 q_cy_auto_dir_smooth_local[2];
#else
    Word16 ch_idx, cur_idx, i, q_tmp;
#ifdef FIX_867_CLDFB_NRG_SCALE
    Word32 L_tmp[CLDFB_NO_CHANNELS_MAX];
#else
    Word64 W_tmp[CLDFB_NO_CHANNELS_MAX], W_max;
    set64_fx( W_tmp, 0, CLDFB_NO_CHANNELS_MAX );
#endif
@@ -4160,12 +4166,14 @@ static void computeTargetPSDs_direct_subframe_fx(
    {
        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 );
@@ -4200,29 +4208,24 @@ static void computeTargetPSDs_direct_subframe_fx(
            cy_auto_dir_smooth[cur_idx + i] = W_extract_h( W_shl( W_tmp[i], q_tmp2 ) ); /*q_reference_power[1]+q_tmp*/ 
            move32();
        }
        q_cy_auto_dir_smooth[ch_idx] = add( q_reference_power[0], q_tmp );
        move16();
#else
        FOR( i = 0; i < num_freq_bands; i++ )
        {
            cy_auto_dir_smooth[cur_idx + i] = W_extract_h( W_shl( W_tmp[i], q_tmp ) ); /*q_reference_power+q_tmp*/
            move32();
        }
#endif
        q_cy_auto_dir_smooth[ch_idx] = add( q_reference_power[0], q_tmp );
        q_cy_auto_dir_smooth[ch_idx] = add( *q_reference_power, q_tmp );
        move16();
#endif
#else
        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

        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] );
        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 );
        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
@@ -4230,8 +4233,12 @@ static void computeTargetPSDs_direct_subframe_fx(
#endif
    }

#ifdef FIX_867_CLDFB_NRG_SCALE
    *q_cy_cross_dir_smooth = q_reference_power[0];
    move16();
#else
    *q_cy_cross_dir_smooth = *q_reference_power;
    move16();
#endif

    return;
@@ -4309,11 +4316,13 @@ static void computeTargetPSDs_diffuse_subframe_fx(
    v_mult_fixed( diffuse_power_factor, reference_power, diffuse_power, num_freq_bands ); // (Q31, q_reference_power) -> q_reference_power

#ifdef FIX_867_CLDFB_NRG_SCALE
    assert( q_reference_power[0] <= q_reference_power[1] );
    Scale_sig32( diffuse_power + CLDFB_NO_CHANNELS_HALF, s_max( 0, sub( num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( q_reference_power[0], q_reference_power[1] ) );
    q_cy_auto_diff_smooth_new = q_reference_power[0];
    move16();
    IF( LT_16( *q_cy_auto_diff_smooth, q_reference_power[0] ) )
    {
        assert( *q_cy_auto_diff_smooth <= q_reference_power[0] );
        Scale_sig32( diffuse_power, num_freq_bands, sub( *q_cy_auto_diff_smooth, q_reference_power[0] ) );
        q_cy_auto_diff_smooth_new = *q_cy_auto_diff_smooth;
        move16();
@@ -4327,6 +4336,7 @@ static void computeTargetPSDs_diffuse_subframe_fx(
#ifdef FIX_867_CLDFB_NRG_SCALE
        IF( GT_16( *q_cy_auto_diff_smooth, q_reference_power[0] ) )
        {
            assert( q_reference_power[0] <= *q_cy_auto_diff_smooth );
            Scale_sig32( &cy_auto_diff_smooth[cur_idx], start_band, sub( q_reference_power[0], *q_cy_auto_diff_smooth ) );
        }
#endif
@@ -4340,6 +4350,7 @@ static void computeTargetPSDs_diffuse_subframe_fx(
    *q_cy_auto_diff_smooth = *q_reference_power;
    move16();
#endif

    return;
}

@@ -4390,6 +4401,7 @@ static void computeTargetPSDs_diffuse_with_onsets_fx(
        move16();
    }
#endif

    /* compute target auto and cross PSDs of current frame (smoothed) */
    FOR( ch_idx = 0; ch_idx < num_channels; ++ch_idx )
    {
+10 −1
Original line number Diff line number Diff line
@@ -1652,7 +1652,6 @@ void protoSignalComputation1_fx(

        reference_power_fx[l] = Madd_32_32( Mpy_32_32( re, re ), im, im ); // 2*(q_cldfb+min_q_shift)-31
        move32();

#ifdef FIX_867_CLDFB_NRG_SCALE
        reference_power_q[qidx] = sub( add( add( q_cldfb, min_q_shift ), add( q_cldfb, min_q_shift ) ), 31 );
        move16();
@@ -1690,6 +1689,7 @@ void protoSignalComputation1_fx(
            move16();
        }
#endif

        idx = 2 * l;
        p_proto_buffer_fx[idx] = RealBuffer_fx[0][0][l]; // q_cldfb
        move32();
@@ -1874,6 +1874,7 @@ void protoSignalComputation2_fx(
    *q_proto_power_smooth = add( *q_proto_power_smooth, sub( q_shift, 1 ) );
    move16();
#endif

    IF( isloudspeaker )
    {
        p_proto_buffer_fx = proto_direct_buffer_f_fx + i_mult( i_mult( i_mult( slot_index, 2 ), num_freq_bands ), 3 ); // q_proto_direct_buffer_f
@@ -2966,6 +2967,7 @@ void protoSignalComputation2_fx(
    *q_reference_power = sub( add( q_reference_power_64fx, norm_shift ), 32 );
    move16();
#endif

    *q_proto_frame_f = add( q_cldfb, min_q_shift );
    move16();
    *q_proto_direct_buffer_f = add( q_cldfb, min_q_shift );
@@ -3060,6 +3062,7 @@ void protoSignalComputation4_fx(
    q_shift2 = min_q_shift2;
    min_q_shift2 = sub( min_q_shift2, find_guarded_bits_fx( i_mult( 2, 4 ) ) );
#endif

    FOR( k = 0; k < 4; k++ )
    {
#ifdef FIX_867_CLDFB_NRG_SCALE
@@ -4452,6 +4455,7 @@ static void ivas_masa_ext_dirac_render_sf_fx(

                    proto_direct_buffer_f_temp_q[slot_idx] = hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q;
                    move16();

#ifdef FIX_867_CLDFB_NRG_SCALE
                    IF( LT_16( DirAC_mem.reference_power_q[0], DirAC_mem.reference_power_smooth_q[0] ) )
                    {
@@ -4503,6 +4507,7 @@ static void ivas_masa_ext_dirac_render_sf_fx(
                        move16();
                    }
#endif

                    temp_proto_frame_q = sub( getScaleFactor32( hDirACRend->proto_frame_f_fx, hDirACRend->proto_frame_f_len ), 2 );
                    Scale_sig32( hDirACRend->proto_frame_f_fx, hDirACRend->proto_frame_f_len, temp_proto_frame_q ); // hDirACRend->proto_frame_f_q+temp_proto_frame_q
                    hDirACRend->proto_frame_f_q = add( hDirACRend->proto_frame_f_q, temp_proto_frame_q );
@@ -4788,6 +4793,7 @@ static void ivas_masa_ext_dirac_render_sf_fx(
            hDirACRend->masa_stereo_type_detect->q_subtract_power_y = s_min( hDirACRend->masa_stereo_type_detect->q_subtract_power_y_smooth, hDirACRend->masa_stereo_type_detect->q_subtract_power_y );
            move16();
        }

#ifdef FIX_867_CLDFB_NRG_SCALE
        Scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx, CLDFB_NO_CHANNELS_HALF, sub( s_min( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[0], hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[0] ), hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[0] ) );                                     // s_min( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q )
        Scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx + hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF, sub( s_min( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[0], hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[0] ), hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[0] ) ); // s_min( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q )
@@ -4838,6 +4844,7 @@ static void ivas_masa_ext_dirac_render_sf_fx(
        hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q = s_min( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q );
        move16();
#endif

        Word16 proto_power_diff_smooth_prev_temp_q = getScaleFactor32( hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev_len );
        Scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev_len, proto_power_diff_smooth_prev_temp_q ); // hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev_q + proto_power_diff_smooth_prev_temp_q
        hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev_q = add( hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev_q, proto_power_diff_smooth_prev_temp_q );
@@ -4858,6 +4865,7 @@ static void ivas_masa_ext_dirac_render_sf_fx(
        Scale_sig32( diffuseness_vector_fx, hSpatParamRendCom->num_freq_bands, 1 );

        /*Buffer rescaling*/

#ifdef FIX_867_CLDFB_NRG_SCALE
        Scale_sig32( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_fx, CLDFB_NO_CHANNELS_HALF, sub( s_min( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q[0], DirAC_mem.reference_power_q[0] ), hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q[0] ) );                                                                    // s_min( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q, DirAC_mem.reference_power_q )
        Scale_sig32( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_fx + CLDFB_NO_CHANNELS_HALF, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ), sub( s_min( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q[1], DirAC_mem.reference_power_q[1] ), hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q[1] ) ); // s_min( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q, DirAC_mem.reference_power_q )
@@ -4893,6 +4901,7 @@ static void ivas_masa_ext_dirac_render_sf_fx(
        DirAC_mem.reference_power_smooth_q = s_min( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q, DirAC_mem.reference_power_q );
        move16();
#endif

        ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx( Cldfb_RealBuffer_fx,
                                                                    Cldfb_ImagBuffer_fx,
                                                                    hSpatParamRendCom,