diff --git a/lib_com/options.h b/lib_com/options.h index 0ae5cf8ca1470da7221c88047349f832dc5d334c..03a1b1e92990c525e35793ddc095097cb828ebde 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -84,4 +84,5 @@ #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_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 */ #endif diff --git a/lib_com/tools_fx.c b/lib_com/tools_fx.c index ba3e9c85b539d94272a53df81a5bd43795a4e649..b6cb03469dc17872997098a09c96e659146892cd 100644 --- a/lib_com/tools_fx.c +++ b/lib_com/tools_fx.c @@ -469,6 +469,7 @@ Word32 sum2_fx_mod( /* o : sum of all squared vector element * Copy: * * Copy vector x[] to y[] + * *-------------------------------------------------------------------*/ void Copy( const Word16 x[], /* i : input vector */ @@ -485,15 +486,27 @@ void Copy( y[i] = x[i]; move16(); } + +#ifdef FIX_1052_COPY_CMPLX_DISCREPANCY + /* Location of x and y may differ depending on platform/memory allocation. Since IF and ELSE has different complexity count, the early return is used instead of ELSE to ensure the same complexity number regardless of x and y memory addresses. */ + return; +#endif } + +#ifndef FIX_1052_COPY_CMPLX_DISCREPANCY ELSE { +#endif FOR( i = L - 1; i >= 0; i-- ) { y[i] = x[i]; move16(); } + + return; +#ifndef FIX_1052_COPY_CMPLX_DISCREPANCY } +#endif } /*-------------------------------------------------------------------* * Copy64: @@ -514,15 +527,27 @@ void Copy64( y[i] = x[i]; move64(); } + +#ifdef FIX_1052_COPY_CMPLX_DISCREPANCY + /* Location of x and y may differ depending on platform/memory allocation. Since IF and ELSE has different complexity count, the early return is used instead of ELSE to ensure the same complexity number regardless of x and y memory addresses. */ + return; +#endif } + +#ifndef FIX_1052_COPY_CMPLX_DISCREPANCY ELSE { +#endif FOR( i = L - 1; i >= 0; i-- ) { y[i] = x[i]; move64(); } + + return; +#ifndef FIX_1052_COPY_CMPLX_DISCREPANCY } +#endif } void set64_fx( @@ -558,9 +583,17 @@ void Copy_pword( move16(); move16(); } + +#ifdef FIX_1052_COPY_CMPLX_DISCREPANCY + /* Location of x and y may differ depending on platform/memory allocation. Since IF and ELSE has different complexity count, the early return is used instead of ELSE to ensure the same complexity number regardless of x and y memory addresses. */ + return; +#endif } + +#ifndef FIX_1052_COPY_CMPLX_DISCREPANCY ELSE { +#endif FOR( i = L - 1; i >= 0; i-- ) { y[i].v.im = x[i].v.im; @@ -568,7 +601,11 @@ void Copy_pword( move16(); move16(); } + + return; +#ifndef FIX_1052_COPY_CMPLX_DISCREPANCY } +#endif } /*-------------------------------------------------------------------* * Copy32: @@ -589,15 +626,24 @@ void Copy32( y[i] = x[i]; move32(); } + +#ifdef FIX_1052_COPY_CMPLX_DISCREPANCY + return; +#endif } + +#ifndef FIX_1052_COPY_CMPLX_DISCREPANCY ELSE { +#endif FOR( i = L - 1; i >= 0; i-- ) { y[i] = x[i]; move32(); } +#ifndef FIX_1052_COPY_CMPLX_DISCREPANCY } +#endif } void set8_fx(