Commit a032f81e authored by Manuel Jander's avatar Manuel Jander
Browse files

Change computeTargetPSDs_direct_subframe_fx to handle 2 scale regions...

 Change computeTargetPSDs_direct_subframe_fx to handle 2 scale regions directly. Extend 2 scale regions headroom calculation to proto_power_smooth_prev
parent 8d3b65bd
Loading
Loading
Loading
Loading
+11 −27
Original line number Diff line number Diff line
@@ -2057,28 +2057,6 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx(
        // Scale cy_auto_diff_smooth_fx if required
        IF( diff_start_band != 0 )
        {
#ifdef FIX_867_CLDFB_NRG_SCALE
            /* Is this necessary at all ? */
            q_com = s_min( s_min( q_reference_power_smooth[0], q_reference_power_smooth[1] ), h_dirac_output_synthesis_state->q_cy_auto_diff_smooth );
            scale_sig32( reference_power_smooth, s_min( num_freq_bands, CLDFB_NO_CHANNELS_HALF ), sub( q_com, q_reference_power_smooth[0] ) );                                                                            /**q_reference_power_smooth->q_com*/
            scale_sig32( reference_power_smooth + CLDFB_NO_CHANNELS_HALF, s_max( 0, sub( num_freq_bands, s_min( num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ) ), sub( q_com, q_reference_power_smooth[1] ) );                /**q_reference_power_smooth->q_com*/
            scale_sig32( h_dirac_output_synthesis_state->reference_power_smooth_prev_fx, s_min( num_freq_bands, CLDFB_NO_CHANNELS_HALF ), sub( q_com, q_reference_power_smooth[0] ) );                                    /**q_reference_power_smooth->q_com*/
            scale_sig32( h_dirac_output_synthesis_state->reference_power_smooth_prev_fx + CLDFB_NO_CHANNELS_HALF, s_max( 0, sub( num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( q_com, q_reference_power_smooth[1] ) ); /**q_reference_power_smooth->q_com*/
            scale_sig32( h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx,
                         i_mult( num_freq_bands, nchan_target_psds ),
                         sub( q_com, h_dirac_output_synthesis_state->q_cy_auto_diff_smooth ) ); /*h_dirac_output_synthesis_state->q_cy_auto_diff_smooth -> q_com*/
            q_reference_power_smooth[0] = q_com;
            q_reference_power_smooth[1] = q_com;
            move16();
            move16();
            h_dirac_output_synthesis_state->reference_power_smooth_prev_q[0] = q_com;
            h_dirac_output_synthesis_state->reference_power_smooth_prev_q[1] = q_com;
            move16();
            move16();

            h_dirac_output_synthesis_state->q_cy_auto_diff_smooth = q_com;
            move16();
#else
            q_com = s_min( *q_reference_power_smooth, h_dirac_output_synthesis_state->q_cy_auto_diff_smooth );
            scale_sig32( reference_power_smooth, num_freq_bands, sub( q_com, *q_reference_power_smooth ) );                                         /**q_reference_power_smooth->q_com*/
            scale_sig32( h_dirac_output_synthesis_state->reference_power_smooth_prev_fx, num_freq_bands, sub( q_com, *q_reference_power_smooth ) ); /**q_reference_power_smooth->q_com*/
@@ -2092,7 +2070,6 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx(

            h_dirac_output_synthesis_state->q_cy_auto_diff_smooth = q_com;
            move16();
#endif
        }
#endif

@@ -4325,7 +4302,7 @@ static void computeTargetPSDs_diffuse_subframe_fx(
    Word16 ch_idx, cur_idx;
    Word32 diffuse_power[CLDFB_NO_CHANNELS_MAX]; /* segment auxiliary buffer; size: num_freq_bands. */
#ifdef FIX_867_CLDFB_NRG_SCALE
    Word16 q_cy_auto_diff_smooth_new, q_diffuse_power;
    Word16 q_cy_auto_diff_smooth_new;
#endif

    /* estimate direct and diffuse power */
@@ -4333,6 +4310,14 @@ static void computeTargetPSDs_diffuse_subframe_fx(

#ifdef FIX_867_CLDFB_NRG_SCALE
    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] ) )
    {
        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();
    }
#endif
    /* compute target auto and cross PSDs of current frame (smoothed) */
    FOR( ch_idx = 0; ch_idx < num_channels; ++ch_idx )
@@ -4340,9 +4325,9 @@ static void computeTargetPSDs_diffuse_subframe_fx(
        cur_idx = imult1616( ch_idx, num_freq_bands );

#ifdef FIX_867_CLDFB_NRG_SCALE
        IF( GT_16( *q_cy_auto_diff_smooth, q_diffuse_power ) )
        IF ( GT_16( *q_cy_auto_diff_smooth, q_reference_power[0] ) )
        {
            Scale_sig32( &cy_auto_diff_smooth[cur_idx], start_band, sub( q_diffuse_power, *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
        v_multc_fixed( &diffuse_power[start_band], diffuse_responses_square[ch_idx], &cy_auto_diff_smooth[cur_idx + start_band], sub( num_freq_bands, start_band ) ); // (q_reference_power, Q31) -> q_reference_power
@@ -4355,7 +4340,6 @@ static void computeTargetPSDs_diffuse_subframe_fx(
    *q_cy_auto_diff_smooth = *q_reference_power;
    move16();
#endif

    return;
}

+24 −1
Original line number Diff line number Diff line
@@ -8452,7 +8452,6 @@ static void intermidiate_ext_dirac_render(
            hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[1] = add( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[1], tmp );
            move16(); move16();
#else
            /* Possible improvement: normalize both scale regions individually. */
            tmp = 0;
            move16();
            FOR( slot_idx = 0; slot_idx < hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_len; slot_idx = add( slot_idx, hSpatParamRendCom->num_freq_bands ) )
@@ -8485,12 +8484,36 @@ static void intermidiate_ext_dirac_render(
            move16();
#endif
#ifdef FIX_867_CLDFB_NRG_SCALE
#if 0
            /* Possible improvement: normalize both scale regions individually. */
            tmp = L_norm_arr( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_fx, imult1616( hDirACRend->num_protos_dir, hSpatParamRendCom->num_freq_bands ) );
            scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_len, tmp ); /* Q(hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q + tmp) */
            hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[0] = add( tmp, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[0] );
            hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[1] = add( tmp, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[1] );
            move16();
#else
            tmp = 0;
            FOR( slot_idx = 0; slot_idx < hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_len; slot_idx = add( slot_idx, hSpatParamRendCom->num_freq_bands ) )
            {
                tmp = s_min( tmp, L_norm_arr( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_fx, s_min( CLDFB_NO_CHANNELS_HALF, hSpatParamRendCom->num_freq_bands ) ) );
            }
            FOR( slot_idx = 0; slot_idx < hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_len; slot_idx = add( slot_idx, hSpatParamRendCom->num_freq_bands ) )
            {
                scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_fx, s_min( CLDFB_NO_CHANNELS_HALF, hSpatParamRendCom->num_freq_bands ), tmp ); /* Q(hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q + tmp) */
            }
            hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[0] = add( tmp, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[0] );
            move16();
            FOR( slot_idx = 0; slot_idx < hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_len; slot_idx = add( slot_idx, hSpatParamRendCom->num_freq_bands ) )
            {
                tmp = s_min( tmp, L_norm_arr( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_fx + CLDFB_NO_CHANNELS_HALF, s_max( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ) ) );
            }
            FOR( slot_idx = 0; slot_idx < hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_len; slot_idx = add( slot_idx, hSpatParamRendCom->num_freq_bands ) )
            {
                scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_fx + CLDFB_NO_CHANNELS_HALF, s_max( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), tmp ); /* Q(hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q + tmp) */
            }
            hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[1] = add( tmp, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[1] );
            move16();
#endif
#else
            tmp = L_norm_arr( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_fx, imult1616( hDirACRend->num_protos_dir, hSpatParamRendCom->num_freq_bands ) );
            scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_len, tmp ); /* Q(hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q + tmp) */