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

Fix cases where number of bands is lower than CLDFB_NO_CHANNELS_HALF

parent d121436d
Loading
Loading
Loading
Loading
+11 −11
Original line number Diff line number Diff line
@@ -3126,7 +3126,7 @@ void ivas_dirac_dec_render_sf_fx(

            Copy32( reference_power_fx, &( hDirACRend->buffer_energy_fx[i_mult( sub( index, 1 ), num_freq_bands )] ), num_freq_bands );
#ifdef FIX_867_CLDFB_NRG_SCALE
            Scale_sig32( &( hDirACRend->buffer_energy_fx[add( i_mult( sub( index, 1 ), num_freq_bands ), CLDFB_NO_CHANNELS_HALF )] ), sub( num_freq_bands, CLDFB_NO_CHANNELS_HALF ), sub( DirAC_mem.reference_power_q[0], DirAC_mem.reference_power_q[1] ) );
            Scale_sig32( &( hDirACRend->buffer_energy_fx[add( i_mult( sub( index, 1 ), num_freq_bands ), CLDFB_NO_CHANNELS_HALF )] ), s_max( 0, sub( num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( DirAC_mem.reference_power_q[0], DirAC_mem.reference_power_q[1] ) );
            hDirACRend->q_buffer_energy[index - 1] = DirAC_mem.reference_power_q[0];
#else
            hDirACRend->q_buffer_energy[index - 1] = DirAC_mem.reference_power_q;
@@ -3367,7 +3367,7 @@ void ivas_dirac_dec_render_sf_fx(
            IF( LT_16( q_reference_power_smooth[0], DirAC_mem.reference_power_q[0] ) )
            {
                Word32 temp;
                FOR( i = 0; i < CLDFB_NO_CHANNELS_HALF; i++ )
                FOR( i = 0; i < s_min( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ); i++ )
                {
                    temp = L_shl( reference_power_fx[i], sub( q_reference_power_smooth[0], DirAC_mem.reference_power_q[0] ) );
                    reference_power_fx[i] = L_max(temp, L_min(reference_power_fx[i], 1));
@@ -3379,7 +3379,7 @@ void ivas_dirac_dec_render_sf_fx(
            ELSE
            {
                Word32 temp;
                FOR( i = 0; i < CLDFB_NO_CHANNELS_HALF; i++ )
                FOR( i = 0; i < s_min( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ); i++ )
                {
                    temp = L_shl( reference_power_smooth_fx[i], sub( DirAC_mem.reference_power_q[0], q_reference_power_smooth[0] ) );
                    reference_power_smooth_fx[i] = L_max(temp, L_min(reference_power_smooth_fx[i], 1));
@@ -3683,7 +3683,7 @@ void ivas_dirac_dec_render_sf_fx(
        ELSE
        {
            Word32 temp;
            FOR( i = 0; i < CLDFB_NO_CHANNELS_HALF; i++ )
            FOR( i = 0; i < s_min( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ); i++ )
            {
                temp = L_shl( reference_power_smooth_fx[i], sub( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q[0], q_reference_power_smooth[0] ) );
                reference_power_smooth_fx[i] = L_max( temp, L_min( reference_power_smooth_fx[i], 1 ) );
@@ -3770,11 +3770,11 @@ void ivas_dirac_dec_render_sf_fx(
        move16();
        FOR( i = 0; proto_power_smooth_len > i; i = add( i, hSpatParamRendCom->num_freq_bands ) )
        {
            exp = s_min( exp, getScaleFactor32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx + i, CLDFB_NO_CHANNELS_HALF ) );
            exp = s_min( exp, getScaleFactor32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx + i, s_min( CLDFB_NO_CHANNELS_HALF, hSpatParamRendCom->num_freq_bands ) ) );
        }
        FOR( i = 0; proto_power_smooth_len > i; i = add( i, hSpatParamRendCom->num_freq_bands ) )
        {
            scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx + i, CLDFB_NO_CHANNELS_HALF, exp ); // Q(hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q + exp)
            scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx + i, s_min( CLDFB_NO_CHANNELS_HALF, hSpatParamRendCom->num_freq_bands ), exp ); // Q(hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q + exp)
        }
        hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[0] = add( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[0], exp );
        move16();
@@ -3782,7 +3782,7 @@ void ivas_dirac_dec_render_sf_fx(
        {
            FOR( i = 0; proto_power_smooth_len > i; i = add( i, hSpatParamRendCom->num_freq_bands ) )
            {
                scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_fx + i, CLDFB_NO_CHANNELS_HALF, sub( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[0], hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[0] ) ); // proto_power_smooth_q
                scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_fx + i, s_min( CLDFB_NO_CHANNELS_HALF, hSpatParamRendCom->num_freq_bands ), sub( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[0], hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[0] ) ); // proto_power_smooth_q
            }
            hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[0] = hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[0];
            move16();
@@ -3791,7 +3791,7 @@ void ivas_dirac_dec_render_sf_fx(
        {
            FOR( i = 0; proto_power_smooth_len > i; i = add( i, hSpatParamRendCom->num_freq_bands ) )
            {
                scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx + i, CLDFB_NO_CHANNELS_HALF, sub( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[0], hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[0] ) ); // proto_power_smooth_prev_q
                scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx + i, s_min( CLDFB_NO_CHANNELS_HALF, hSpatParamRendCom->num_freq_bands ), sub( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[0], hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[0] ) ); // proto_power_smooth_prev_q
            }
            hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[0] = hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[0];
            move16();
@@ -3800,7 +3800,7 @@ void ivas_dirac_dec_render_sf_fx(
        move16();
        FOR( i = 0; proto_power_smooth_len > i; i = add( i, hSpatParamRendCom->num_freq_bands ) )
        {
            exp = s_min( exp, getScaleFactor32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx + CLDFB_NO_CHANNELS_HALF + i, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ) );
            exp = s_min( exp, getScaleFactor32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx + CLDFB_NO_CHANNELS_HALF + i, s_max( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ) ) );
        }
        FOR( i = 0; proto_power_smooth_len > i; i = add( i, hSpatParamRendCom->num_freq_bands ) )
        {
@@ -3812,7 +3812,7 @@ void ivas_dirac_dec_render_sf_fx(
        {
            FOR( i = 0; proto_power_smooth_len > i; i = add( i, hSpatParamRendCom->num_freq_bands ) )
            {
                scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_fx + CLDFB_NO_CHANNELS_HALF + i, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ), sub( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[1], hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[1] ) ); // proto_power_smooth_q
                scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_fx + CLDFB_NO_CHANNELS_HALF + i, s_max( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[1], hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[1] ) ); // proto_power_smooth_q
            }
            hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[1] = hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[1];
            move16();
@@ -3821,7 +3821,7 @@ void ivas_dirac_dec_render_sf_fx(
        {
            FOR( i = 0; proto_power_smooth_len > i; i = add( i, hSpatParamRendCom->num_freq_bands ) )
            {
                scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx + CLDFB_NO_CHANNELS_HALF + i, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ), sub( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[1], hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[1] ) ); // proto_power_smooth_prev_q
                scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx + CLDFB_NO_CHANNELS_HALF + i, s_max( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[1], hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[1] ) ); // proto_power_smooth_prev_q
            }
            hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[1] = hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[1];
            move16();
+8 −8
Original line number Diff line number Diff line
@@ -2061,9 +2061,9 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx(
            /* 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, 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, sub( num_freq_bands, CLDFB_NO_CHANNELS_HALF ), sub( q_com, q_reference_power_smooth[1] ) );                                         /**q_reference_power_smooth->q_com*/
            scale_sig32( reference_power_smooth + 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->reference_power_smooth_prev_fx, 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, 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->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*/
@@ -2320,7 +2320,7 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx(
    // Move proto_power_smooth_fx to common Q-factor

#ifdef FIX_867_CLDFB_NRG_SCALE
    Word16 min_exp2 = MIN_16;
    Word16 min_exp2 = -64;
    min_exp = MIN_16;
    move16();
    move16();
@@ -2331,7 +2331,7 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx(

    FOR( k = 0; k < num_protos_dir; k++ )
    {
        FOR( l = 0; l < CLDFB_NO_CHANNELS_HALF; l++ )
        FOR( l = 0; l < s_min( num_freq_bands, CLDFB_NO_CHANNELS_HALF ); l++ )
        {
            min_exp = s_max( min_exp, exp_arr[k * num_freq_bands + l] );
        }
@@ -2345,7 +2345,7 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx(

    FOR( k = 0; k < num_protos_dir; k++ )
    {
        FOR( l = 0; l < CLDFB_NO_CHANNELS_HALF; l++ )
        FOR( l = 0; l < s_min( num_freq_bands, CLDFB_NO_CHANNELS_HALF ); l++ )
        {
            *p_power_smooth = L_shr( *p_power_smooth, sub( min_exp, exp_arr[k * num_freq_bands + l] ) ); /*(31-(exp-(31-q_proto_power_smooth)))->(31-(min_exp-(31-q_proto_power_smooth)))*/
            move32();
@@ -4123,7 +4123,7 @@ static void computeTargetPSDs_direct_fx(
        v_mult_fixed( direct_power, &direct_responses_square[cur_idx], aux_buffer_res, num_freq_bands ); /* Q31 + Q(q_reference_power) - Q31 = Q(q_reference_power) */
#ifdef FIX_867_CLDFB_NRG_SCALE
        scale_sig32( aux_buffer_res, CLDFB_NO_CHANNELS_HALF, sub( common1_q, q_reference_power[0] ) );                                                 /* Q(common1_q) */
        scale_sig32( aux_buffer_res + CLDFB_NO_CHANNELS_HALF, sub( num_freq_bands, CLDFB_NO_CHANNELS_HALF ), sub( common1_q, q_reference_power[1] ) ); /* Q(common1_q) */
        scale_sig32( aux_buffer_res + CLDFB_NO_CHANNELS_HALF, s_max( 0, sub( num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( common1_q, q_reference_power[1] ) ); /* Q(common1_q) */
#else
        scale_sig32( aux_buffer_res, num_freq_bands, sub( common1_q, *q_reference_power ) ); /* Q(common1_q) */
#endif
@@ -4133,7 +4133,7 @@ static void computeTargetPSDs_direct_fx(
        v_mult_fixed( direct_power, &direct_responses[cur_idx], aux_buffer_res, num_freq_bands ); /* Q31 + Q(q_reference_power) - Q31 = Q(q_reference_power) */
#ifdef FIX_867_CLDFB_NRG_SCALE
        scale_sig32( aux_buffer_res, CLDFB_NO_CHANNELS_HALF, sub( common2_q, q_reference_power[0] ) );                                                 /* Q(common2_q) */
        scale_sig32( aux_buffer_res + CLDFB_NO_CHANNELS_HALF, sub( num_freq_bands, CLDFB_NO_CHANNELS_HALF ), sub( common2_q, q_reference_power[1] ) ); /* Q(common2_q) */
        scale_sig32( aux_buffer_res + CLDFB_NO_CHANNELS_HALF, s_max( 0, sub( num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( common2_q, q_reference_power[1] ) ); /* Q(common2_q) */
#else
        scale_sig32( aux_buffer_res, num_freq_bands, sub( common2_q, *q_reference_power ) ); /* Q(common2_q) */
#endif
@@ -4212,7 +4212,7 @@ static void computeTargetPSDs_direct_subframe_fx(
        }
        q_tmp = W_norm( W_max );
#ifdef FIX_867_CLDFB_NRG_SCALE
        FOR( i = 0; i < CLDFB_NO_CHANNELS_HALF; i++ )
        FOR( i = 0; i < s_min( num_freq_bands, CLDFB_NO_CHANNELS_HALF ); i++ )
        {
            cy_auto_dir_smooth[cur_idx + i] = W_extract_h( W_shl( W_tmp[i], q_tmp ) ); /*q_reference_power[0]+q_tmp*/
            move32();
+19 −19
Original line number Diff line number Diff line
@@ -1827,34 +1827,34 @@ void protoSignalComputation2_fx(
        q_shift = getScaleFactor32( proto_power_smooth_fx, CLDFB_NO_CHANNELS_HALF );
        q_shift = s_min( q_shift, getScaleFactor32( proto_power_smooth_fx + num_freq_bands, CLDFB_NO_CHANNELS_HALF ) );
        q_shift = s_min( q_shift, getScaleFactor32( proto_power_smooth_fx + num_freq_bands + num_freq_bands, CLDFB_NO_CHANNELS_HALF ) );
        scale_sig32( proto_power_smooth_fx, CLDFB_NO_CHANNELS_HALF, sub( q_shift, 1 ) );                                   // q_proto_power_smooth+q_shift-1
        scale_sig32( proto_power_smooth_fx + num_freq_bands, CLDFB_NO_CHANNELS_HALF, sub( q_shift, 1 ) );                  // q_proto_power_smooth+q_shift-1
        scale_sig32( proto_power_smooth_fx + num_freq_bands + num_freq_bands, CLDFB_NO_CHANNELS_HALF, sub( q_shift, 1 ) ); // q_proto_power_smooth+q_shift-1
        scale_sig32( proto_power_smooth_fx, s_min( num_freq_bands, CLDFB_NO_CHANNELS_HALF ), sub( q_shift, 1 ) );                                   // q_proto_power_smooth+q_shift-1
        scale_sig32( proto_power_smooth_fx + num_freq_bands, s_min( num_freq_bands, CLDFB_NO_CHANNELS_HALF ), sub( q_shift, 1 ) );                  // q_proto_power_smooth+q_shift-1
        scale_sig32( proto_power_smooth_fx + num_freq_bands + num_freq_bands, s_min( num_freq_bands, CLDFB_NO_CHANNELS_HALF ), sub( q_shift, 1 ) ); // q_proto_power_smooth+q_shift-1
    }
    ELSE
    {
        q_shift = getScaleFactor32( proto_power_smooth_fx, CLDFB_NO_CHANNELS_HALF );
        q_shift = s_min( q_shift, getScaleFactor32( proto_power_smooth_fx + num_freq_bands, CLDFB_NO_CHANNELS_HALF ) );
        scale_sig32( proto_power_smooth_fx, CLDFB_NO_CHANNELS_HALF, sub( q_shift, 1 ) );                  // q_proto_power_smooth+q_shift-1
        scale_sig32( proto_power_smooth_fx + num_freq_bands, CLDFB_NO_CHANNELS_HALF, sub( q_shift, 1 ) ); // q_proto_power_smooth+q_shift-1
        q_shift = getScaleFactor32( proto_power_smooth_fx, s_min( num_freq_bands, CLDFB_NO_CHANNELS_HALF ) );
        q_shift = s_min( q_shift, getScaleFactor32( proto_power_smooth_fx + num_freq_bands, s_min( num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ) );
        scale_sig32( proto_power_smooth_fx, s_min( num_freq_bands, CLDFB_NO_CHANNELS_HALF ), sub( q_shift, 1 ) );                  // q_proto_power_smooth+q_shift-1
        scale_sig32( proto_power_smooth_fx + num_freq_bands, s_min( num_freq_bands, CLDFB_NO_CHANNELS_HALF ), sub( q_shift, 1 ) ); // q_proto_power_smooth+q_shift-1
    }
    q_proto_power_smooth[0] = add( q_proto_power_smooth[0], sub( q_shift, 1 ) );
    move16();
    IF( isloudspeaker )
    {
        q_shift = getScaleFactor32( proto_power_smooth_fx + CLDFB_NO_CHANNELS_HALF, sub( num_freq_bands, CLDFB_NO_CHANNELS_HALF ) );
        q_shift = s_min( q_shift, getScaleFactor32( proto_power_smooth_fx + CLDFB_NO_CHANNELS_HALF + num_freq_bands, sub( num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ) );
        q_shift = s_min( q_shift, getScaleFactor32( proto_power_smooth_fx + CLDFB_NO_CHANNELS_HALF + num_freq_bands + num_freq_bands, sub( num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ) );
        scale_sig32( proto_power_smooth_fx + CLDFB_NO_CHANNELS_HALF, sub( num_freq_bands, CLDFB_NO_CHANNELS_HALF ), sub( q_shift, 1 ) );                                   // q_proto_power_smooth+q_shift-1
        scale_sig32( proto_power_smooth_fx + CLDFB_NO_CHANNELS_HALF + num_freq_bands, sub( num_freq_bands, CLDFB_NO_CHANNELS_HALF ), sub( q_shift, 1 ) );                  // q_proto_power_smooth+q_shift-1
        scale_sig32( proto_power_smooth_fx + CLDFB_NO_CHANNELS_HALF + num_freq_bands + num_freq_bands, sub( num_freq_bands, CLDFB_NO_CHANNELS_HALF ), sub( q_shift, 1 ) ); // q_proto_power_smooth+q_shift-1
        q_shift = getScaleFactor32( proto_power_smooth_fx + CLDFB_NO_CHANNELS_HALF, s_max( 0, sub( num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ) );
        q_shift = s_min( q_shift, getScaleFactor32( proto_power_smooth_fx + CLDFB_NO_CHANNELS_HALF + num_freq_bands, s_max( 0, sub( num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ) ) );
        q_shift = s_min( q_shift, getScaleFactor32( proto_power_smooth_fx + CLDFB_NO_CHANNELS_HALF + num_freq_bands + num_freq_bands, s_max( 0, sub( num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ) ) );
        scale_sig32( proto_power_smooth_fx + CLDFB_NO_CHANNELS_HALF, s_max( 0, sub( num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( q_shift, 1 ) );                                   // q_proto_power_smooth+q_shift-1
        scale_sig32( proto_power_smooth_fx + CLDFB_NO_CHANNELS_HALF + num_freq_bands, s_max( 0, sub( num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( q_shift, 1 ) );                  // q_proto_power_smooth+q_shift-1
        scale_sig32( proto_power_smooth_fx + CLDFB_NO_CHANNELS_HALF + num_freq_bands + num_freq_bands, s_max( 0, sub( num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( q_shift, 1 ) ); // q_proto_power_smooth+q_shift-1
    }
    ELSE
    {
        q_shift = getScaleFactor32( proto_power_smooth_fx + CLDFB_NO_CHANNELS_HALF, sub( num_freq_bands, CLDFB_NO_CHANNELS_HALF ) );
        q_shift = s_min( q_shift, getScaleFactor32( proto_power_smooth_fx + CLDFB_NO_CHANNELS_HALF + num_freq_bands, sub( num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ) );
        scale_sig32( proto_power_smooth_fx + CLDFB_NO_CHANNELS_HALF, sub( num_freq_bands, CLDFB_NO_CHANNELS_HALF ), sub( q_shift, 1 ) );                  // q_proto_power_smooth+q_shift-1
        scale_sig32( proto_power_smooth_fx + CLDFB_NO_CHANNELS_HALF + num_freq_bands, sub( num_freq_bands, CLDFB_NO_CHANNELS_HALF ), sub( q_shift, 1 ) ); // q_proto_power_smooth+q_shift-1
        q_shift = getScaleFactor32( proto_power_smooth_fx + CLDFB_NO_CHANNELS_HALF, s_max( 0, sub( num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ) );
        q_shift = s_min( q_shift, getScaleFactor32( proto_power_smooth_fx + CLDFB_NO_CHANNELS_HALF + num_freq_bands, s_max( 0, sub( num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ) ) );
        scale_sig32( proto_power_smooth_fx + CLDFB_NO_CHANNELS_HALF, s_max( 0, sub( num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( q_shift, 1 ) );                  // q_proto_power_smooth+q_shift-1
        scale_sig32( proto_power_smooth_fx + CLDFB_NO_CHANNELS_HALF + num_freq_bands, s_max( 0, sub( num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( q_shift, 1 ) ); // q_proto_power_smooth+q_shift-1
    }
    q_proto_power_smooth[1] = add( q_proto_power_smooth[1], sub( q_shift, 1 ) );
    move16();
@@ -2916,14 +2916,14 @@ void protoSignalComputation2_fx(
#ifdef FIX_867_CLDFB_NRG_SCALE
    Word16 norm_shift = 63;
    move16();
    FOR( l = 0; l < CLDFB_NO_CHANNELS_HALF; l++ )
    FOR( l = 0; l < s_min( num_freq_bands, CLDFB_NO_CHANNELS_HALF ); l++ )
    {
        IF( reference_power_64fx[l] )
        {
            norm_shift = s_min( norm_shift, W_norm( reference_power_64fx[l] ) );
        }
    }
    FOR( l = 0; l < CLDFB_NO_CHANNELS_HALF; l++ )
    FOR( l = 0; l < s_min( num_freq_bands, CLDFB_NO_CHANNELS_HALF ); l++ )
    {
        reference_power_fx[l] = W_extract_h( W_shl( reference_power_64fx[l], norm_shift ) ); // q_reference_power_64fx+norm_shift-32
        move32();