Commit 225e7c9a authored by Manuel Jander's avatar Manuel Jander
Browse files

Issue #867 : use 2 scale regions for reference_power vectors to improve...

Issue #867 : use 2 scale regions for reference_power vectors to improve precision. Work in progress.
parent 9431fd35
Loading
Loading
Loading
Loading
+175 −93
Original line number Diff line number Diff line
@@ -67,27 +67,109 @@
#define BASOP_NOGLOB_DECLARE_LOCAL
#endif

#define FIX_867_CLDFB_NRG_SCALE

#define FIX_1378_ACELP_OUT_OF_BOUNDS

#define FIX_1464_SQ_GAIN_PRECISION
#define FIX_1464_NO_SINGLE_SPEC_Q

#define IVAS_FLOAT_FIXED
#define IVAS_FLOAT_FIXED_CONVERSIONS /* Temporary macro to keep track of intermediate flt to fixed and fixed to flt conversions */
#define MSAN_FIX
#define ISM_DISABLE
#define FIX_TMP_714
#define BASOP_NOGLOB_TMP_715
#define EVS_FUNC_MODIFIED
//#define EVS_FLOAT_ENC
#define IVAS_CNST
#define REMOVE_IVAS_UNUSED_PARAMETERS_WARNING  /*temporary operation on unused EVS parameters to remove warnings, these parameters will be used in IVAS */
#define MOD_BIT_ALLOC_ROM_TABLE   /* Just to highlight modification in bit allocation table and to ensure these modifications doesn't affect EVS modes*/
#define SIMPLIFY_CODE_BE   // Simplify synthesis loop
#define CR_2109_to_2112_cd0_ce0  /* This is related to the CRs include in the 26.444 package of 21-12. Concerns lead_deindexing and  */
#define FIX_QMETADATA_PENALTY /* Nokia: transform penalty calculation in qmetadata into integer operations */
#define FIX_1013_CRASH_HQ_CORE_DEC /* Ittiam: Saturation added on the lines of EVS */
#define NONE_BE_FIX_BASOP_1044_OSBA_PRERENDER_MIX_GAINS /* DLB: adjust prerendering and mixing gain in OSBA encoder. This is fix to float codes*/
#define NONBE_1233_HQ_CLASSIFIER_DIV_BY_ZERO            /* Eri: issue 1233: Address possible division by zero in hf_spectrum_sparseness() */
#define FIX_ISSUE_1062_AND_1068_TON_ENE_EST_FX
#define FIX_ISSUE_987
#define FIX_1054_IF_ELSE_CMPLX                  /* VA: Fix 1054 incorrect counting of complexity when ELSE-IF sequence is encoutered in two functions */
#define FIX_1052_COPY_CMPLX_DISCREPANCY         /* VA: modify IF-ELSE statements used in Copy*() functions to avoid dependency on x[] and y[] in RAM */
#define FIX_1049_SHR_RO_COMPLEXITY              /* VA: fix for issue 1049: incorrect counting of complexity in the shr_ro() function */
#define NONBE_IMPROVE_DIRAC_INTENSITY_PREC
#define FIX_1103_OPT_L_NORM_ARR                 /* FhG: Optimize L_norm_arr(), avoid IF */
#define FIX_1105_OPT_MINIMUM_SL                 /* FhG: Optimize minimum_s(), minimum_l(), avoid IF */
#define FIX_1104_OPT_GETMINSCALEFAC             /* FhG: Optimize get_min_scalefactor(), avoid IF */
#define FIX_1106_SIMPLIFY_SET32FX               /* FhG: simplify set32_fx() */
#define FIX_1107_VADDINC                        /* FhG: Optimize v_add_inc_fx() for most frequent case */
#define FIX_1009_OPT_PARAMMC_RENDER             /* FhG: Optimize ivas_param_mc_dec_render_fx() */
#define FIX_1109_OPTIM_MCT_STEREO_IGF_DEC       /* FhG: optimize mctStereoIGF_dec_fx() */
#define FIX_1110_OPTIM_DIRAC_DECORR_PROC        /* FhG: optimize ivas_dirac_dec_decorr_process() */
#define FIX_1127_IMPROVE_SBA_MLD                /* Ittiam: Avoid saturation for DiRAC reference power */
#define FIX_1100_REMOVE_LPC_RESCALING           /* VA: Remove the rescaling of LPC coefficient to Q12 as residu and syn-filt are already taking care of it*/
#define FIX_1133_IMPROVE_MC_MLD                 /* Ittiam: Correcting wrong updation of exponents in ivas_mc_paramupmix_param_est_enc_fx() */
#define FIX_ISSUE_1122                          /* Ittiam: Fix issue 1122: corrected incorrect scaling of a buffer leading to incorrect metadata bits */
#define FIX_ISSUE_1125                          /* Ittiam: Fix issue 1125: interfering talker flag not triggered on short test vector */
#define FIX_1132_STACK_CORRUPTION               /* Stack corruption issue due of extending index access*/
#define FIX_ISSUE_1092                          /* Ittiam: Fix for Issue 1092: BASOP asserts in stereo fx encoder for selection test inputs*/
#define FIX_ISSUE_1135                          /* Ittiam: Fix for Issue 1135: downmixing difference between float and fixed-point (DFT - stereo) */
#define FIX_ISSUE_1148
#define FIX_ISSUE_1147                          /* Ittiam: Fix for issue 1147: Added saturation in DetectTnsFilt_fx.*/
#define FIX_ISSUE_1150                          /* Ittiam: Fix for Issue 1150: Assertion error observed in evs_enc_fx (with option stereo_dmx_evs) from tcx_ltp_find_gain function*/
#define FIX_ISSUE_1151                          /* Ittiam: Fix for Issue 1151: Assertion error observed in evs_enc_fx (with option stereo_dmx_evs) from sp_mus_classif_gmm_fx function*/
#define FIX_ISSUE_1153                          /* Ittiam: Fix for Issue 1153: Assertion error observed in stereo_dmx_evs_enc_fx from calc_poc_fx function*/
#define FIX_ISSUE_1154                          /* Ittiam: Fix for Issue 1154: Encoder crash for ParamMC 7.1 at 96kbps in ivas_param_mc_param_est_enc_fx() */
#define FIX_ISSUE_1157                          /* Ittiam: Fix for Issue 1157: Encoder crash for Stereo at 48/64kbps DTX on/off in kernel_switch_trafo_fx() */
#define FIX_ISSUE_1152                          /* Ittiam: Fix for issue 1152: Assertion error observed in evs_enc_fx (with option stereo_dmx_evs) from find_tilt_fx function*/
#define FIX_ISSUE_1156                          /* Ittiam: Fix for Issue 1156: Encoder crash for Stereo at 32kbps in SWB_BWE_encoding_ivas_fx() */
#define FIX_DISCLAIMER                          /* VA: Add disclaimer for external renderer + Add info about IVAS reference version (FLP issue 1225) */
#define FIX_ISSUE_1167                          /* Ittiam: Fix for Issue 1167: Encoder crash for OSBA ISM3SBA1 at 13.2 and 16.4 kbps in gauss_L2_ivas_fx() */
#define FIX_1009_REPLACE_DIV_SQRT_BY_ISQRT_LC   /* FhG: Reduce workload of binaural rendering: replace 1./tmp & sqrt by Isqrt32 */
#define FIX_1113_OPT_DIRAC_BIN_REND             /* FhG: Various optimizations to ivas_dirac_dec_binaual_functions.c */
#define FIX_ISSUE_1187                          /* Ittiam: Fix for issue 1187: Assertion error observed in evs_enc_fx (with option stereo_dmx_evs) from bass_pf_enc_fx function*/
#define FIX_ISSUE_1186                          /* Ittiam: Fix for Issue 1186: Energy/scaling issue for ISM-1 at all bitrates */
#define FIX_ISSUE_1165                          /* Ittiam: Fix for issue 1165: Assertion in lpc2lsp_fx for OMASA LTV input */
#define FIX_ISSUE_1185                          /* Ittiam: Fix for issue 1185: Assertion in ivas_dirac_dec_binaural_internal_fx() for crash in decoder in fft30_with_cmplx_data()*/
#define FIX_ISSUE_1209                          /* Ittiam: Fix for issue 1209: Assertion exit in BASOP encoder (stereo_dmx_evs)*/
#define FIX_ISSUE_1218                          /* Ittiam: Fix for issue 1218: Assert in stereo_dft_generate_comfort_noise_fx of BASOP decoder with BASOP MASA DTX bitstream at 32 kbps*/
#define FIX_ISSUE_1290                          /* Ittiam: Fix for issue 1218: Assert in stereo_dft_generate_comfort_noise_fx of BASOP decoder with BASOP MASA DTX bitstream at 32 kbps*/
#define IVAS_ISSUE_1188_EVS_CRASH               /* Ittiam: Fix for issue 1188: Issue due to ASAN */
#define FIX_ISSUE_1155                          /* Ittiam: Fix for issue 1155: Encoder crash for Stereo at 32kbps in PostShortTerm_ivas_enc_fx()*/
#define FIX_1010_OPT_DIV                        /* FhG: SVD complexity optimizations (non-be) */
#define FIX_1010_OPT_SINGLE_RESCALE             /* FhG: SVD complexity optimizations (non-be) */
#define FIX_1010_OPT_GIVENS                     /* FhG: SVD complexity optimizations (non-be) */
#define FIX_1010_OPT_GIVENS_INV                 /* FhG: SVD complexity optimizations (non-be) */
#define FIX_1010_OPT_NORM_NOSAT                 /* FhG: SVD complexity optimizations (non-be) */
#define FIX_1010_OPT_SEC_SINGLE_RESCALE         /* FhG: SVD complexity optimizations (non-be) */
#define FIX_1072_SPEEDUP_matrixTransp2Mul_fx    /* FhG: complexity optimization (non-be)      */
#define FIX_1072_REDUCE_DIVS                    /* FhG: complexity optimization (non-be)      */
#define FIX_ISSUE_1230                          /* Ittiam: Fix for issue 1230: Basop Enc audible differences and distortion @16kbps */
#define NONBE_1211_DTX_BR_SWITCHING             /* VA: port float issue 1211: fix crash in MASA DTX bitrate switching */
#define FIX_1189_GSC_IVAS_OMASA                 /* VA: Fix for issue 1189: Bitstream desynchornization due to reading/writing of the GSC_IVAS_mode parameter */
#define NONBE_1273_ISM_METADATA_COUNTER         /* VA: BASOP issue 1265, FLP issue 1273: fix counter overflow in ISM metadata encoder */
#define NONBE_FIX_GSC_BSTR                      /* VA: issue 1264 FLP (1189 BASOP): Fix bitstream synchronization between encoder and decoder in ACELP GSC in OMASA */
#define FIX_1101_IVAS_SPAR_DEC_UPMIXER_SF       /* FhG: fix for issue 1101: complexity of spar dec upmixer */
/* Note: each compile switch (FIX_1101_...) is independent from the other ones */
//#define OPT_STEREO_32KBPS_V1                    /* Optimization made in stereo decoding path for 32kbps decoding */
#define OPT_AVOID_STATE_BUF_RESCALE             /* Optimization made to avoid rescale of synth state buffer */
#define FIX_1310_SPEEDUP_ivas_dirac_dec_get_response_fx                 /*FhG: WMOPS tuning, nonbe*/
#define FIX_1310_SPEEDUP_ivas_dirac_dec_output_synthesis_process_slot   /*FhG: WMOPS tuning, nonbe*/
/* Both following 2 macros (IMPROVE_HIGH_COMPLEXITY_PARAM_MC_PRM_EST*) are independent from each other, they refer to different code blocks */
#define IMPROVE_HIGH_COMPLEXITY_PARAM_MC_PRM_EST_BE    /* FhG: reduces WMOPS of param_mc_prm_est, bit-exact to previous version */
//#define IMPROVE_HIGH_COMPLEXITY_PARAM_MC_PRM_EST_NONBE /* FhG: reduces WMOPS of param_mc_prm_est, not bit-exact to previous version. Obsoleted by MERGE_REQUEST_1378_SPEEDUP_ivas_mc_param_enc_fx_NONBE. */
#define HARM_PUSH_BIT
#define HARM_ENC_INIT
//#define HARM_SCE_INIT
#define DIV32_OPT_NEWTON                               /* FhG: faster 32 by 32 bit division */ 
#define	MERGE_REQUEST_1378_SPEEDUP_ivas_mc_param_enc_fx_NONBE /* FhG: reduce WMOPS of Cy calculation in ivas_param_mc_param_est_enc_fx() by using 64 Bit addition. Obsoletes IMPROVE_HIGH_COMPLEXITY_PARAM_MC_PRM_EST_NONBE. */

#define TEST_HR

#define FIX_1101_IVAS_SPAR_DEC_UPMIXER_SF_USE_MADD_ADD_WEIGHTS  /* FhG: Defines 1.0f-weight variables, uses Madd operation instead of L_add_sat */
#define FIX_1101_IVAS_SPAR_DEC_UPMIXER_SF_SPLIT_LOOPS           /* FhG: Splits single loop with IF-statements into two low-complex loops */
#define FIX_1101_IVAS_SPAR_DEC_UPMIXER_SF_HQ_CONSTANTS          /* FhG: IMPROVE PRECISION: Uses 1/6 and 1/20 in full-precise Q31 constants instead of Q15 */
#define FIX_1101_IVAS_SPAR_DEC_UPMIXER_SF_USE_UNIQUE_SHL        /* FhG: Uses unique shift amount in each loop iteration */
#define FIX_11_1_IVAS_SPAR_DEC_UPMIXER_SF_RND_COEFFS            /* FhG  ivas_spar_com.c: Zeroes very small negative coeffs via L_shr_r (was L_shr) */
#define FIX_ISSUE_1237                          /* VA: replacement of Copy_Scale_sig_16_32_DEPREC() that are doing 16 bits left shift by Copy_Scale_sig_16_32_no_sat() */
#define FIX_ISSUE_1237_KEEP_EVS_BE              /* VA: Fix to keep EVS bitexactness to 26.444 */
#define FIX_ISSUE_1214                          /* Ittiam: Fix for issue 1214: Energy leakage in IGF tiles for MDCT-stereo @64kbps SWB*/
#define FIX_881_HILBERT_FILTER                  /* VA: improve the precision of the Hilbert filter to remove 2kHz unwanted tone */
#define FIX_ISSUE_1245                          /* Ittiam: Fix for issue 1245: Basop Encoder: Audible noise for silent Stereo input DTX on @24.4 kbps, @32 kbps*/
#define FIX_ISSUE_1291                          /* Ittiam: Wrong use of imult1616() in ACELP rescaling */
#define FIX_920_IGF_INIT_ERROR                  /* FhG: issue 920: fix bitrate mismatch in initial IGF config to avoid error message in same cases */
#define FIX_MINOR_SVD_WMOPS_MR1010X             /* FhG: Minor WMOPS tuning, bit-exact to previous version, saves about 8.2 WMOPS for MR1010 */
#define SVD_WMOPS_OPT                           /* Ittiam : SVD related optimizations */
#define NONBE_FIX_1087_OOB_SBA_DTX_RS           /* VA: issue 1087: Extend the length of the buffer for MCT decoding to avoid out-of-bound writing in SBA SID bitrate switching decoding */
#define FIX_ISSUE_1279                          /* VA: correction of wrong scaling update */
#define FIX_ISSUE_1247
#define NONBE_FIX_1087_OOB_SBA_DTX_RS                   /* VA: issue 1087: Extend the length of the buffer for MCT decoding to avoid out-of-bound writing in SBA SID bitrate switching decoding */
#define FIX_1285_DECODER_CRASH
#define FIX_1072_SPEEDUP_gainpanning            /* FhG: Minor WMOPS tuning, nonbe */
#define FIX_1072_SPEEDUP_COMPUTEDIFUSENESS      /* FhG: Minor WMOPS tuning, nonbe */
#define FIX_1320_LOWRATE_ACELP
#define FIX_1297_OVERFLOW                       /* VA: fixes issue with overflows in pre-processing */
#define FIX_1298                                /* VA: fix possible assert in gaus_enc */
#define FIX_1300_ICA_SHIFT_QUANT_IMPROV         /* VA: Fix to 1300 to improve precision of the lag quantizer */
#define FIX_1301_CORRECT_TD_CNST                /* VA: Fix 1301, correct wrong constant in TD stereo */
#define FIX_867_CLDFB_NRG_SCALE                 /* Issue 867: split cldfb energy scale into 2 regions for better precision */
//#define FIX_867_CLDFB_NRG_SCALE_CLDFB           /* Issue 867: use dynamic scale for CLDFB analysis. Almost zero improvement. */
//#define FIX_867_CLDFB_NRG_SCALE_CLDFB_MASK      /* Issue 867: erase higher cldfb values to remove noise from MDCT */
#endif
+174 −69

File changed.

Preview size limit exceeded, changes collapsed.

+75 −75

File changed.

Preview size limit exceeded, changes collapsed.

+190 −182

File changed.

Preview size limit exceeded, changes collapsed.

+22 −32
Original line number Diff line number Diff line
@@ -8309,8 +8309,7 @@ static void intermidiate_ext_dirac_render(
#ifdef FIX_867_CLDFB_NRG_SCALE
        DirAC_mem.reference_power_smooth_q[0] = DirAC_mem.reference_power_q[0] = Q31;
        DirAC_mem.reference_power_smooth_q[1] = DirAC_mem.reference_power_q[1] = Q31;
        move16();
        move16();
        move16(); move16();
#else
        DirAC_mem.reference_power_smooth_q = DirAC_mem.reference_power_q = Q31;
        move16();
@@ -8444,30 +8443,36 @@ static void intermidiate_ext_dirac_render(
        IF( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx )
        {
#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_fx, imult1616( hDirACRend->num_protos_dir, hSpatParamRendCom->num_freq_bands ) );
            scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_len, tmp ); /* Q(hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q + tmp) */
            hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[0] = add( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[0], tmp );
            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 ) )
            {
                tmp = s_min( tmp, L_norm_arr( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx + slot_idx, s_min( 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) ) {
                tmp = s_min(tmp, L_norm_arr( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx + slot_idx,  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_fx + slot_idx, s_min( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ), tmp ); /* Q(hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q + tmp) */
            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_fx + slot_idx, CLDFB_NO_CHANNELS_HALF, tmp ); /* Q(hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q + tmp) */
            }
            hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[0] = add( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[0], tmp );
            move16();
            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 ) )
            {
                tmp = s_min( tmp, L_norm_arr( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx + slot_idx + 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) ) {
                tmp = s_min(tmp, L_norm_arr( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx + slot_idx + CLDFB_NO_CHANNELS_HALF, 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_fx + slot_idx + 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_q + tmp) */
            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_fx + slot_idx + CLDFB_NO_CHANNELS_HALF, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ), tmp ); /* Q(hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q + tmp) */
            }
            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();
#endif
#else
            tmp = L_norm_arr( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx, imult1616( hDirACRend->num_protos_dir, hSpatParamRendCom->num_freq_bands ) );
            scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_len, tmp ); /* Q(hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q + tmp) */
@@ -8475,25 +8480,10 @@ static void intermidiate_ext_dirac_render(
            move16();
#endif
#ifdef FIX_867_CLDFB_NRG_SCALE
            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) */
            }
            /* 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] );
            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();
#else