Skip to content
Commits on Source (19)
......@@ -49,6 +49,7 @@
#include "split_rend_bfi_file_reader.h"
#include "vector3_pair_file_reader.h"
#include "wmc_auto.h"
#include "basop32.h"
#define WMC_TOOL_SKIP
......
......@@ -1268,7 +1268,7 @@ Word16 round_fx( Word32 L_var1 )
Word32 L_rounded;
BASOP_SATURATE_WARNING_OFF
L_rounded = L_add( L_var1, (Word32) 0x00008000L );
L_rounded = L_add_sat( L_var1, (Word32) 0x00008000L );
BASOP_SATURATE_WARNING_ON
var_out = extract_h( L_rounded );
......
......@@ -2085,6 +2085,8 @@ Word32 norm_llQ31( /* o : normalized result Q31 */
return L_sum;
}
#ifndef FIX_ISSUE_1817_REPLACE_CARRY_OVERFLOW
/* note: now available in basop_util.h */
Word32 w_norm_llQ31( Word64 L_sum, Word16 *exp );
Word32 w_norm_llQ31( /* o : normalized result Q31 */
Word64 L_sum, /* i : upper and lower bits of accu, unsigned Q31 */
......@@ -2111,6 +2113,7 @@ Word32 w_norm_llQ31( /* o : normalized result Q31 */
L_tmp = W_extract_h( L64_inp64 );
return L_tmp;
}
#endif
Word32 Dot_product16HQ( /* o : normalized result Q31 */
const Word32 L_off, /* i : initial sum value Qn */
......@@ -2135,6 +2138,24 @@ Word32 Dot_product16HQ( /* o : normalized result
return L_sum;
}
Word32 sum_array_norm( /* o : normalized result Q31 */
const Word32 x[], /* i : x vector Qn */
const Word16 lg, /* i : vector length, range [0..7FFF] Q0 */
Word16 *exp /* o : exponent of result in [-32,31] Q0 */
)
{
Word16 i;
Word64 W_tmp = 0;
Word32 L_tmp;
FOR( i = 0; i < lg; i++ )
{
W_tmp = W_add( W_tmp, x[i] ); /*Q31*/
}
L_tmp = w_norm_llQ31( W_tmp, exp ); /*Q31 - *exp*/
return L_tmp;
}
Word32 Norm32Norm( const Word32 *x, const Word16 headroom, const Word16 length, Word16 *result_e )
{
Word32 L_tmp, L_tmp2;
......
......@@ -612,6 +612,20 @@ Word32 Dot_product16HQ( /*<! o : normalized result
Word16 *exp /*<! o : exponent of result in [-32,31] Q0 */
);
/*------------------------------------------------------------------*
* sum_array_norm:
*
* \brief Compute array summation of x[] using 64-bit accumulator.
*
* Performs normalization of the result, returns the exponent
* Note: no headroom is required for data in x[]
*------------------------------------------------------------------*/
Word32 sum_array_norm( /* o : normalized result Q31 */
const Word32 x[], /* i : x vector Qn */
const Word16 lg, /* i : vector length, range [0..7FFF] Q0 */
Word16 *exp /* o : exponent of result in [-32,31] Q0 */
);
/*------------------------------------------------------------------*
* norm_llQ31:
*
......@@ -627,6 +641,23 @@ Word32 norm_llQ31( /* o : normalized result Q31 */
Word16 *exp /* o : exponent of result in [-32,31] Q0 */
);
#ifdef FIX_ISSUE_1817_REPLACE_CARRY_OVERFLOW
/*------------------------------------------------------------------*
* w_norm_llQ31:
*
* \brief Compute normalized Q31 Values out of overflowed Q31 value
* using 64-bit operators
*------------------------------------------------------------------*/
static inline Word32 w_norm_llQ31( Word64 L64_var1, Word16 *S_var2 ) /*Q31 - L_tmp_exp*/
{
Word32 L_result;
Word16 sh = W_norm( L64_var1 );
L_result = W_extract_h( W_shl( L64_var1, sh ) );
*S_var2 = ( L_result == 0 ) ? -32 : 32 - sh;
return L_result;
}
#endif
/**
* \brief Compute dot product of 1 32 bit vectors with itself
* \param x input vector 1
......
......@@ -90,7 +90,10 @@
#define FIX_1824
#define FIX_1822
<<<<<<< HEAD
#define FIX_ISSUE_1764 /* NTT: update renorm and use abs */
=======
>>>>>>> 84312b808372d2e7c5f93cecaf09bc3b61427149
#define FIX_ISSUE_1817_REPLACE_CARRY_OVERFLOW /* FhG: bit-exact, replace carry and overflow operations by 64-bit operations, MR 1931 */
#define FIX_1844_MISSING_FREE /* FhG: add missing free in ivas_binRenderer_convModuleClose_fx() */
......
......@@ -6,9 +6,9 @@
#include <stdio.h>
#include <assert.h>
#include "prot_fx.h"
#include "options.h"
#include "basop_util.h"
#include "stl.h"
#include "options.h"
#include "math.h"
#include "ivas_prot_fx.h"
#include "rom_com.h"
......@@ -1859,6 +1859,7 @@ static Word32 CalculateAbsEnergy_fx( /* o : normalized resul
const Word16 lg, /* i : vector length, range [0..7FFF] Q0 */
Word16 *exp /* o : exponent of result in [-32,31] Q0 */
)
#ifndef FIX_ISSUE_1817_REPLACE_CARRY_OVERFLOW
{
Word16 i;
Word32 L_sum, L_c;
......@@ -1895,7 +1896,22 @@ static Word32 CalculateAbsEnergy_fx( /* o : normalized resul
L_sum = norm_llQ31( L_c, L_sum, exp );
return L_sum;
}
#else
{
Word16 i;
Word32 L_sum;
Word64 L_sum64;
L_sum64 = W_deposit32_l( L_off );
FOR( i = 0; i < lg; i += 2 )
{
L_sum64 = W_mac_16_16( L_sum64, x[i], x[i] );
}
L_sum = w_norm_llQ31( L_sum64, exp ); /*Q31 - *exp */
return L_sum;
}
#endif /* FIX_ISSUE_1817_REPLACE_CARRY_OVERFLOW */
void IMDCT_fx( Word32 *x, Word16 x_e, Word16 *old_syn_overl, Word16 *syn_Overl_TDAC, Word16 *xn_buf, const Word16 *tcx_aldo_window_1, const PWord16 *tcx_aldo_window_1_trunc, const PWord16 *tcx_aldo_window_2, const PWord16 *tcx_mdct_window_half, const PWord16 *tcx_mdct_window_minimum, const PWord16 *tcx_mdct_window_trans, Word16 tcx_mdct_window_half_length, Word16 tcx_mdct_window_min_length, Word16 index, Word16 left_rect, Word16 tcx_offset, Word16 overlap, Word16 L_frame, Word16 L_frameTCX, Word16 L_spec_TCX5, Word16 L_frame_glob, Word16 frame_cnt, Word16 bfi, Word16 *old_out, Word16 *Q_old_wtda, Decoder_State *st, Word16 fullbandScale, Word16 *acelp_zir )
{
......
......@@ -576,13 +576,17 @@ Word16 ApplyFdCng_fx(
Word16 facTab[NPART];
Word16 facTabExp[NPART];
Word16 tmp_loop;
#ifndef FIX_ISSUE_1817_REPLACE_CARRY_OVERFLOW
Word32 L_c;
#endif
Word16 lsp_cng[M];
HANDLE_FD_CNG_DEC hFdCngDec;
HANDLE_FD_CNG_COM hFdCngCom;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
#ifndef FIX_ISSUE_1817_REPLACE_CARRY_OVERFLOW
Flag Carry = 0;
#endif
move16();
move16();
#endif
......@@ -794,6 +798,7 @@ Word16 ApplyFdCng_fx(
{
tmp_loop = sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand );
#ifndef FIX_ISSUE_1817_REPLACE_CARRY_OVERFLOW
L_tmp = L_deposit_h( 0 );
L_c = L_deposit_h( 0 );
FOR( j = 0; j < tmp_loop; j++ )
......@@ -826,6 +831,19 @@ Word16 ApplyFdCng_fx(
st->hTcxDec->conCngLevelBackgroundTrace = round_fx_sat( Sqrt32( L_tmp, &L_tmp_exp ) ); /*Q15 - L_tmp_exp*/
move16();
L_tmp_exp = add( L_tmp_exp, 1 );
#else
L_tmp = sum_array_norm( cngNoiseLevel, tmp_loop, &L_tmp_exp ); /*Q31 - L_tmp_exp*/
L_tmp_exp = sub( add( L_tmp_exp, *cngNoiseLevel_exp ), 1 );
L_tmp = L_shr( L_tmp, 15 ); /*Q16 - L_tmp_exp*/
L_tmp = Mpy_32_16_1( L_tmp, shr( T_DIV_L_Frame[L_shl( L_mac( -28000, NORM_MDCT_FACTOR, 95 ), 1 - 15 )], 1 ) ); /*Q16,exp -7*/
L_tmp_exp = add( L_tmp_exp, -7 + ( 31 - 16 ) ); /*->Q31, L_tmp_exp*/
st->hTcxDec->conCngLevelBackgroundTrace = round_fx_sat( Sqrt32( L_tmp, &L_tmp_exp ) ); /*Q15 - L_tmp_exp*/
move16();
L_tmp_exp = add( L_tmp_exp, 1 );
#endif
st->hTcxDec->conCngLevelBackgroundTrace_e = L_tmp_exp;
move16();
}
......@@ -833,6 +851,7 @@ Word16 ApplyFdCng_fx(
{
tmp_loop = sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand );
#ifndef FIX_ISSUE_1817_REPLACE_CARRY_OVERFLOW
L_tmp = L_deposit_h( 0 );
L_c = L_deposit_h( 0 );
FOR( j = 0; j < tmp_loop; j++ )
......@@ -863,12 +882,25 @@ Word16 ApplyFdCng_fx(
L_tmp_exp = add( L_tmp_exp, 31 - 16 ); /*->Q31, L_tmp_exp*/
st->hTcxDec->conCngLevelBackgroundTrace = round_fx_sat( Sqrt32( L_tmp, &L_tmp_exp ) ); /*Q15 - L_tmp_exp*/
#else
L_tmp = sum_array_norm( cngNoiseLevel, tmp_loop, &L_tmp_exp );
L_tmp_exp = sub( add( L_tmp_exp, *cngNoiseLevel_exp ), 1 );
L_tmp = Mpy_32_16_1( L_tmp, hFdCngCom->fftlen ); /*Q16 - L_tmp_exp*/
L_tmp = Mpy_32_16_1( L_tmp, T_DIV_L_Frame[L_shl( L_mac( -28000, st->L_frame, 95 ), 1 - 15 )] ); /*Q16,exp -7*/
L_tmp_exp = add( L_tmp_exp, -7 + ( 31 - 16 ) ); /*->Q31, L_tmp_exp*/
st->hTcxDec->conCngLevelBackgroundTrace = round_fx_sat( Sqrt32( L_tmp, &L_tmp_exp ) ); /*Q15 - L_tmp_exp*/
#endif
move16();
st->hTcxDec->conCngLevelBackgroundTrace_e = L_tmp_exp;
move16();
}
tmp_loop = sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand );
#ifndef FIX_ISSUE_1817_REPLACE_CARRY_OVERFLOW
L_tmp = L_deposit_h( 0 );
L_c = L_deposit_h( 0 );
FOR( j = 0; j < tmp_loop; j++ )
......@@ -900,6 +932,19 @@ Word16 ApplyFdCng_fx(
st->cngTDLevel = round_fx_sat( Sqrt32( L_tmp, &L_tmp_exp ) ); /*Q15 - L_tmp_exp*/
move16();
#else
L_tmp = sum_array_norm( cngNoiseLevel, tmp_loop, &L_tmp_exp ); /*Q31 - L_tmp_exp*/
L_tmp_exp = sub( add( L_tmp_exp, *cngNoiseLevel_exp ), 1 );
L_tmp = Mpy_32_16_1( L_tmp, hFdCngCom->fftlen ); /*Q16 - L_tmp_exp*/
L_tmp = Mpy_32_16_1( L_tmp, T_DIV_L_Frame[L_shr( L_mac( -28000, st->L_frame, 95 ), 15 - 1 )] ); /*Q16,exp -7*/
L_tmp_exp = add( L_tmp_exp, -7 + ( 31 - 16 ) ); /*->Q31, L_tmp_exp */
st->cngTDLevel = round_fx_sat( Sqrt32( L_tmp, &L_tmp_exp ) ); /*Q15 - L_tmp_exp*/
move16();
#endif
st->cngTDLevel_e = L_tmp_exp;
move16();
}
......@@ -1018,6 +1063,7 @@ Word16 ApplyFdCng_fx(
/*st->cngTDLevel = (float)sqrt( (sumFLOAT(cngNoiseLevel, hFdCngCom->stopFFTbin - hFdCngCom->startBand) / 2 * hFdCngCom->fftlen) / st->Mode2_L_frame);*/
tmp_loop = sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand );
#ifndef FIX_ISSUE_1817_REPLACE_CARRY_OVERFLOW
L_tmp = L_deposit_h( 0 );
L_c = L_deposit_h( 0 );
FOR( j = 0; j < tmp_loop; j++ )
......@@ -1049,6 +1095,18 @@ Word16 ApplyFdCng_fx(
st->cngTDLevel = round_fx_o( Sqrt32( L_tmp, &L_tmp_exp ), &Overflow ); /*Q15 - L_tmp_exp*/
move16();
#else
L_tmp = sum_array_norm( cngNoiseLevel, tmp_loop, &L_tmp_exp ); /*Q31 - L_tmp_exp*/
L_tmp_exp = sub( add( L_tmp_exp, *cngNoiseLevel_exp ), 1 );
L_tmp = Mpy_32_16_1( L_tmp, hFdCngCom->fftlen ); /*Q16 - L_tmp_exp*/
L_tmp = Mpy_32_16_1( L_tmp, T_DIV_L_Frame[L_shl( L_mac( -28000, st->L_frame, 95 ), 1 - 15 )] ); /*Q16,exp -7*/
L_tmp_exp = add( L_tmp_exp, -7 + ( 31 - 16 ) ); /*->Q31, L_tmp_exp*/
st->cngTDLevel = round_fx( Sqrt32( L_tmp, &L_tmp_exp ) ); /*Q15 - L_tmp_exp*/
move16();
#endif
st->cngTDLevel_e = L_tmp_exp;
move16();
BREAK;
......