From ba36acda70b184aaf7224b42f4e2ca3fbdabeb2b Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Mon, 3 Jun 2024 12:50:30 +0530 Subject: [PATCH 1/2] -10dB input crash fix, Stereo high MLD case fix, formulate2x2MixingMatrix_fx integration, struct cleanup [x] Crash fixes: -10dB input: [ltv-SBA at 128 kbps, 32kHZ in, 32kHz out, BINAURAL_ROOM_REVERB out HR] [x] High MLD fix: High MLD fix for the test case - stereo at 16.4 kbps, 32kHz in, 16kHz out, DTX on [x] ASAN fixes and BASOP updates [x] formulate2x2MixingMatrix_fx integration [x] fb_mixer table updates [x] dirac_dec_stack_mem and dirac_output_synthesis_state_structure cleanup --- lib_com/fft_fx.c | 715 ++++++------ lib_com/ivas_fb_mixer.c | 26 +- lib_com/ivas_rom_com.c | 36 +- lib_com/ivas_rom_com.h | 4 +- lib_com/ivas_spar_com.c | 20 +- lib_com/prot_fx2.h | 2 + lib_dec/ivas_dirac_dec.c | 46 +- lib_dec/ivas_init_dec.c | 16 +- lib_dec/ivas_jbm_dec.c | 339 ++---- lib_dec/ivas_masa_dec.c | 2 +- lib_dec/ivas_sba_dec.c | 2 +- lib_dec/ivas_stereo_dft_dec_fx.c | 15 +- lib_rend/ivas_dirac_dec_binaural_functions.c | 1095 +++++++++++++++++- lib_rend/ivas_dirac_rend.c | 118 +- lib_rend/ivas_stat_rend.h | 19 +- lib_rend/lib_rend.c | 93 +- 16 files changed, 1773 insertions(+), 775 deletions(-) diff --git a/lib_com/fft_fx.c b/lib_com/fft_fx.c index 4356c7fd9..20f7ec62c 100644 --- a/lib_com/fft_fx.c +++ b/lib_com/fft_fx.c @@ -157,8 +157,8 @@ static void fft4_5( Word32 *x, Word32 *y, const Word16 *Idx ); static void fft5_4( Word16 n1, Word32 *zRe, Word32 *zIm, const Word16 *Idx ); void DoRTFTn_fx_ivas( - Word32 *x, /* i/o: real part of input and output data */ - Word32 *y, /* i/o: imaginary part of input and output data */ + Word32 *x, /* i/o: real part of input and output data */ + Word32 *y, /* i/o: imaginary part of input and output data */ const Word16 n /* i : size of the FFT n=(2^k) up to 1024 */ ); /*-----------------------------------------------------------------* @@ -999,8 +999,8 @@ static void fft32_5( *-----------------------------------------------------------------*/ static void fft16_ivas( - Word32 *x, /* i/o: real part of input and output data */ - Word32 *y, /* i/o: imaginary part of input and output data */ + Word32 *x, /* i/o: real part of input and output data */ + Word32 *y, /* i/o: imaginary part of input and output data */ const Word16 *Idx /* i : pointer of the address table */ ) { @@ -1671,13 +1671,13 @@ static void cftfsub( l = 2; - IF( GT_16( n, 8 ) ) + IF ( GT_16(n, 8) ) { cft1st( n, a, w ); l = 8; - WHILE( LT_16( shl( l, 2 ), n ) ) + WHILE ( LT_16(shl(l, 2 ), n) ) { cftmdl( n, l, a, w ); l = shl( l, 2 ); @@ -2015,12 +2015,12 @@ static void cftbsub( Word32 x0r, x0i, x1r, x1i, x2r, x2i, x3r, x3i; l = 2; - IF( GT_16( n, 8 ) ) + IF ( GT_16(n, 8) ) { cft1st( n, a, w ); l = 8; - WHILE( LT_16( shl( l, 2 ), n ) ) + WHILE ( LT_16(shl(l, 2), n) ) { cftmdl( n, l, a, w ); l = shl( l, 2 ); @@ -2111,8 +2111,8 @@ static void rftbsub( Word16 j, k, kk, ks, m; Word16 wkr, wki; Word32 xr, xi, yr, yi; - a[1] = L_negate( a[1] ); - m = shr( n, 1 ); + a[1] = L_negate(a[1]); + m = shr(n, 1); ks = 2 * nc / m; kk = 0; FOR( j = 2; j < m; j += 2 ) @@ -2121,14 +2121,14 @@ static void rftbsub( kk += ks; wkr = sub( (Word16) 0x4000, c[nc - kk] ); wki = c[kk]; - xr = L_sub( a[j], a[k] ); - xi = L_add( a[j + 1], a[k + 1] ); - yr = L_add( Mpy_32_16_1( xr, wkr ), Mpy_32_16_1( xi, wki ) ); - yi = L_sub( Mpy_32_16_1( xi, wkr ), Mpy_32_16_1( xr, wki ) ); - a[j] = L_sub( a[j], yr ); - a[j + 1] = L_sub( yi, a[j + 1] ); - a[k] = L_add( a[k], yr ); - a[k + 1] = L_sub( yi, a[k + 1] ); + xr = L_sub(a[j], a[k]); + xi = L_add(a[j + 1], a[k + 1]); + yr = L_add(Mpy_32_16_1(xr, wkr), Mpy_32_16_1(xi, wki)); + yi = L_sub(Mpy_32_16_1(xi, wkr), Mpy_32_16_1(xr, wki)); + a[j] = L_sub(a[j], yr); + a[j + 1] = L_sub(yi, a[j + 1]); + a[k] = L_add(a[k], yr); + a[k + 1] = L_sub(yi, a[k + 1]); } a[m + 1] = L_negate( a[m + 1] ); @@ -2146,12 +2146,12 @@ static void dctsub( Word16 wkr, wki; Word32 xr; - m = shr( n, 1 ); + m = shr(n, 1); ks = nc / n; kk = 0; FOR( j = 1; j < m; j++ ) { - k = sub( n, j ); + k = sub(n, j); kk += ks; wkr = sub( c[kk], c[nc - kk] ); wki = add( c[kk], c[nc - kk] ); @@ -2185,17 +2185,17 @@ void edct2_fx_ivas( Copy32( in, a, n ); nw = ip[0]; - IF( GT_16( n, shl( nw, 2 ) ) ) + IF ( GT_16(n, shl( nw, 2 ) ) ) { - nw = shr( n, 2 ); + nw = shr(n, 2); } nc = ip[1]; - IF( GT_16( n, nc ) ) + IF ( GT_16(n, nc) ) { nc = n; } - IF( LT_16( isgn, 0 ) ) + IF ( LT_16(isgn, 0) ) { xr = a[n - 1]; FOR( j = n - 2; j >= 2; j -= 2 ) @@ -2206,7 +2206,7 @@ void edct2_fx_ivas( a[1] = L_sub( a[0], xr ); a[0] = L_add( a[0], xr ); - IF( GT_16( n, 4 ) ) + IF ( GT_16(n, 4) ) { rftbsub( n, a, nc, w + nw ); bitrv2_SR( n, ip + 2, a ); @@ -2218,16 +2218,16 @@ void edct2_fx_ivas( } } - IF( GE_16( isgn, 0 ) ) + IF ( GE_16(isgn, 0) ) { a[0] = L_shr( a[0], 1 ); } dctsub( n, a, nc, w + nw ); - IF( GE_16( isgn, 0 ) ) + IF ( GE_16(isgn, 0) ) { - IF( GT_16( n, 4 ) ) + IF ( GT_16(n, 4) ) { bitrv2_SR( n, ip + 2, a ); cftfsub( n, a, w ); @@ -2254,8 +2254,8 @@ void edct2_fx_ivas( } void DoRTFTn_fx_ivas( - Word32 *x, /* i/o: real part of input and output data */ - Word32 *y, /* i/o: imaginary part of input and output data */ + Word32 *x, /* i/o: real part of input and output data */ + Word32 *y, /* i/o: imaginary part of input and output data */ const Word16 n /* i : size of the FFT up to 1024 */ ) { @@ -2349,7 +2349,7 @@ void fft3_fx_ivas( Z2 = &Z1[m]; z2 = &Z2[0]; /* Z2 = &Z[2m]; */ x = &X[0]; - FOR( i = 0; i < n / 3; i++ ) + FOR ( i = 0; i < n / 3; i++ ) { *z0++ = *x++; /* Z0[i] = X[3i]; */ *z1++ = *x++; /* Z1[i] = X[3i+1]; */ @@ -2371,121 +2371,121 @@ void fft3_fx_ivas( RZ2 = &Z2[0]; IZ2 = &Z2[m]; - c1_step = negate( step ); + c1_step = negate(step); s1_step = step; - c2_step = negate( shl( step, 1 ) ); - s2_step = shl( step, 1 ); - c1_ind = add( T_SIN_PI_2, c1_step ); + c2_step = negate(shl(step, 1)); + s2_step = shl(step, 1); + c1_ind = add(T_SIN_PI_2, c1_step); s1_ind = s1_step; - c2_ind = add( T_SIN_PI_2, c2_step ); + c2_ind = add(T_SIN_PI_2, c2_step); s2_ind = s2_step; /* special case: i = 0 */ - RY[0] = L_add( RZ0[0], L_add( RZ1[0], RZ2[0] ) ); + RY[0] = L_add(RZ0[0], L_add(RZ1[0], RZ2[0])); /* first 3/12 */ - for ( i = 1; i < 3 * m / 8; i++, c1_ind = add( c1_ind, c1_step ), s1_ind = add( s1_ind, s1_step ), c2_ind = add( c2_ind, c2_step ), s2_ind = add( s2_ind, s2_step ) ) - { - RY[i] = L_add( RZ0[i], L_add( Mpy_32_16_1( RZ1[i], t_sin[c1_ind] ), - L_add( Mpy_32_16_1( IZ1[-i], t_sin[s1_ind] ), - L_add( Mpy_32_16_1( RZ2[i], t_sin[c2_ind] ), - Mpy_32_16_1( IZ2[-i], t_sin[s2_ind] ) ) ) ) ); - IY[-i] = L_sub( IZ0[-i], L_add( L_sub( Mpy_32_16_1( RZ1[i], t_sin[s1_ind] ), - Mpy_32_16_1( IZ1[-i], t_sin[c1_ind] ) ), - L_sub( Mpy_32_16_1( RZ2[i], t_sin[s2_ind] ), - Mpy_32_16_1( IZ2[-i], t_sin[c2_ind] ) ) ) ); + for (i = 1; i < 3 * m / 8; i++, c1_ind = add(c1_ind, c1_step), s1_ind = add(s1_ind, s1_step), c2_ind = add(c2_ind,c2_step), s2_ind = add(s2_ind, s2_step)) + { + RY[i] = L_add(RZ0[i], L_add(Mpy_32_16_1(RZ1[i], t_sin[c1_ind]), + L_add(Mpy_32_16_1(IZ1[-i], t_sin[s1_ind]), + L_add(Mpy_32_16_1(RZ2[i], t_sin[c2_ind]), + Mpy_32_16_1(IZ2[-i], t_sin[s2_ind]))))); + IY[-i] = L_sub(IZ0[-i], L_add(L_sub(Mpy_32_16_1(RZ1[i], t_sin[s1_ind]), + Mpy_32_16_1(IZ1[-i], t_sin[c1_ind])), + L_sub(Mpy_32_16_1(RZ2[i], t_sin[s2_ind]), + Mpy_32_16_1(IZ2[-i], t_sin[c2_ind])))); } /* next 1/12 */ - for ( ; i < 4 * m / 8; i++, c1_ind = add( c1_ind, c1_step ), s1_ind = add( s1_ind, s1_step ), c2_ind = sub( c2_ind, c2_step ), s2_ind = sub( s2_ind, s2_step ) ) - { - RY[i] = L_add( RZ0[i], L_sub( L_add( Mpy_32_16_1( RZ1[i], t_sin[c1_ind] ), - Mpy_32_16_1( IZ1[-i], t_sin[s1_ind] ) ), - L_sub( Mpy_32_16_1( RZ2[i], t_sin[c2_ind] ), - Mpy_32_16_1( IZ2[-i], t_sin[s2_ind] ) ) ) ); - IY[-i] = L_sub( IZ0[-i], L_sub( Mpy_32_16_1( RZ1[i], t_sin[s1_ind] ), - L_sub( Mpy_32_16_1( IZ1[-i], t_sin[c1_ind] ), - L_add( Mpy_32_16_1( RZ2[i], t_sin[s2_ind] ), - Mpy_32_16_1( IZ2[-i], t_sin[c2_ind] ) ) ) ) ); + for ( ; i < 4 * m / 8; i++, c1_ind = add(c1_ind, c1_step), s1_ind = add(s1_ind, s1_step), c2_ind = sub(c2_ind, c2_step), s2_ind = sub(s2_ind, s2_step) ) + { + RY[i] = L_add(RZ0[i], L_sub(L_add(Mpy_32_16_1(RZ1[i], t_sin[c1_ind]), + Mpy_32_16_1(IZ1[-i], t_sin[s1_ind])), + L_sub(Mpy_32_16_1(RZ2[i], t_sin[c2_ind]), + Mpy_32_16_1(IZ2[-i], t_sin[s2_ind])))); + IY[-i] = L_sub(IZ0[-i], L_sub(Mpy_32_16_1(RZ1[ i], t_sin[s1_ind]), + L_sub(Mpy_32_16_1(IZ1[-i], t_sin[c1_ind]), + L_add(Mpy_32_16_1(RZ2[ i], t_sin[s2_ind]), + Mpy_32_16_1(IZ2[-i], t_sin[c2_ind]))))); } /* special case: i = m/2 i.e. 1/3 */ - RY[i] = L_add( RZ0[i], - L_sub( Mpy_32_16_1( RZ1[i], t_sin[c1_ind] ), - Mpy_32_16_1( RZ2[i], t_sin[c2_ind] ) ) ); - IY[-i] = L_negate( L_add( Mpy_32_16_1( RZ1[i], t_sin[s1_ind] ), - Mpy_32_16_1( RZ2[i], t_sin[s2_ind] ) ) ); + RY[i] = L_add(RZ0[i], + L_sub(Mpy_32_16_1(RZ1[i], t_sin[c1_ind]), + Mpy_32_16_1(RZ2[i], t_sin[c2_ind]))); + IY[-i] = L_negate(L_add(Mpy_32_16_1(RZ1[i], t_sin[s1_ind]), + Mpy_32_16_1(RZ2[i], t_sin[s2_ind]))); i++; - c1_ind = add( c1_ind, c1_step ); - s1_ind = add( s1_ind, s1_step ); - c2_ind = sub( c2_ind, c2_step ); - s2_ind = sub( s2_ind, s2_step ); + c1_ind = add(c1_ind, c1_step); + s1_ind = add(s1_ind, s1_step); + c2_ind = sub(c2_ind, c2_step); + s2_ind = sub(s2_ind, s2_step); /* next 2/12 */ - for ( j = i - 2; i < 6 * m / 8; i++, j--, c1_ind = add( c1_ind, c1_step ), s1_ind = add( s1_ind, s1_step ), c2_ind = sub( c2_ind, c2_step ), s2_ind = sub( s2_ind, s2_step ) ) + for ( j = i - 2; i < 6 * m / 8; i++, j--, c1_ind = add(c1_ind, c1_step), s1_ind = add(s1_ind, s1_step), c2_ind = sub(c2_ind, c2_step), s2_ind = sub(s2_ind, s2_step) ) { - RY[i] = L_add( RZ0[j], L_sub( Mpy_32_16_1( RZ1[j], t_sin[c1_ind] ), - L_add( Mpy_32_16_1( IZ1[-j], t_sin[s1_ind] ), - L_add( Mpy_32_16_1( RZ2[j], t_sin[c2_ind] ), - Mpy_32_16_1( IZ2[-j], t_sin[s2_ind] ) ) ) ) ); + RY[i] = L_add(RZ0[j], L_sub(Mpy_32_16_1(RZ1[j], t_sin[c1_ind]), + L_add(Mpy_32_16_1(IZ1[-j], t_sin[s1_ind]), + L_add(Mpy_32_16_1(RZ2[j], t_sin[c2_ind]), + Mpy_32_16_1(IZ2[-j], t_sin[s2_ind]))))); - IY[-i] = L_negate( L_add( IZ0[-j], L_add( Mpy_32_16_1( RZ1[j], t_sin[s1_ind] ), - L_add( Mpy_32_16_1( IZ1[-j], t_sin[c1_ind] ), - L_sub( Mpy_32_16_1( RZ2[j], t_sin[s2_ind] ), - Mpy_32_16_1( IZ2[-j], t_sin[c2_ind] ) ) ) ) ) ); + IY[-i] = L_negate(L_add(IZ0[-j], L_add(Mpy_32_16_1(RZ1[j], t_sin[s1_ind]), + L_add(Mpy_32_16_1(IZ1[-j], t_sin[c1_ind]), + L_sub(Mpy_32_16_1(RZ2[j], t_sin[s2_ind]), + Mpy_32_16_1(IZ2[-j], t_sin[c2_ind])))))); } /*--------------------------half--------------------------*/ /* next 2/12 */ - for ( ; i < 8 * m / 8; i++, j--, c1_ind = sub( c1_ind, c1_step ), s1_ind = sub( s1_ind, s1_step ), c2_ind = add( c2_ind, c2_step ), s2_ind = add( s2_ind, s2_step ) ) - { - RY[i] = L_sub( RZ0[j], L_add( Mpy_32_16_1( RZ1[j], t_sin[c1_ind] ), - L_add( Mpy_32_16_1( IZ1[-j], t_sin[s1_ind] ), - L_sub( Mpy_32_16_1( RZ2[j], t_sin[c2_ind] ), - Mpy_32_16_1( IZ2[-j], t_sin[s2_ind] ) ) ) ) ); - IY[-i] = L_negate( L_add( IZ0[-j], L_sub( Mpy_32_16_1( RZ1[j], t_sin[s1_ind] ), - L_add( Mpy_32_16_1( IZ1[-j], t_sin[c1_ind] ), - L_add( Mpy_32_16_1( RZ2[j], t_sin[s2_ind] ), - Mpy_32_16_1( IZ2[-j], t_sin[c2_ind] ) ) ) ) ) ); + for ( ; i < 8 * m / 8; i++, j--, c1_ind = sub(c1_ind, c1_step), s1_ind = sub(s1_ind, s1_step), c2_ind = add(c2_ind, c2_step), s2_ind = add(s2_ind, s2_step) ) + { + RY[i] = L_sub(RZ0[j], L_add(Mpy_32_16_1(RZ1[j], t_sin[c1_ind]), + L_add(Mpy_32_16_1(IZ1[-j], t_sin[s1_ind]), + L_sub(Mpy_32_16_1(RZ2[j], t_sin[c2_ind]), + Mpy_32_16_1(IZ2[-j], t_sin[s2_ind]))))); + IY[-i] = L_negate(L_add(IZ0[-j], L_sub(Mpy_32_16_1(RZ1[j], t_sin[s1_ind]), + L_add(Mpy_32_16_1(IZ1[-j], t_sin[c1_ind]), + L_add(Mpy_32_16_1(RZ2[j], t_sin[s2_ind]), + Mpy_32_16_1(IZ2[-j], t_sin[c2_ind])))))); } /* special case: i = m, i.e 2/3 */ - RY[i] = L_sub( RZ0[j], L_add( Mpy_32_16_1( RZ1[j], t_sin[c1_ind] ), - Mpy_32_16_1( RZ2[j], t_sin[c2_ind] ) ) ); - IY[-i++] = L_sub( Mpy_32_16_1( RZ2[j], t_sin[s2_ind] ), - Mpy_32_16_1( RZ1[j], t_sin[s1_ind] ) ); - c1_ind = sub( c1_ind, c1_step ), s1_ind = sub( s1_ind, s1_step ), c2_ind = add( c2_ind, c2_step ), s2_ind = add( s2_ind, s2_step ); + RY[i] = L_sub(RZ0[j], L_add(Mpy_32_16_1(RZ1[j], t_sin[c1_ind]), + Mpy_32_16_1(RZ2[j], t_sin[c2_ind]))); + IY[-i++] = L_sub(Mpy_32_16_1(RZ2[j], t_sin[s2_ind]), + Mpy_32_16_1(RZ1[j], t_sin[s1_ind])); + c1_ind = sub(c1_ind, c1_step), s1_ind = sub(s1_ind, s1_step), c2_ind = add(c2_ind, c2_step), s2_ind = add(s2_ind, s2_step); /* next 1/12 */ - for ( j = 1; i < 9 * m / 8; i++, j++, c1_ind = sub( c1_ind, c1_step ), s1_ind = sub( s1_ind, s1_step ), c2_ind = add( c2_ind, c2_step ), s2_ind = add( s2_ind, s2_step ) ) - { - RY[i] = L_sub( RZ0[j], L_sub( Mpy_32_16_1( RZ1[j], t_sin[c1_ind] ), - L_sub( Mpy_32_16_1( IZ1[-j], t_sin[s1_ind] ), - L_add( Mpy_32_16_1( RZ2[j], t_sin[c2_ind] ), - Mpy_32_16_1( IZ2[-j], t_sin[s2_ind] ) ) ) ) ); - IY[-i] = L_sub( IZ0[-j], L_add( Mpy_32_16_1( RZ1[j], t_sin[s1_ind] ), - L_sub( Mpy_32_16_1( IZ1[-j], t_sin[c1_ind] ), - L_sub( Mpy_32_16_1( RZ2[j], t_sin[s2_ind] ), - Mpy_32_16_1( IZ2[-j], t_sin[c2_ind] ) ) ) ) ); + for ( j = 1; i < 9 * m / 8; i++, j++, c1_ind = sub(c1_ind, c1_step), s1_ind = sub(s1_ind, s1_step), c2_ind = add(c2_ind, c2_step), s2_ind = add(s2_ind, s2_step) ) + { + RY[i] = L_sub(RZ0[j], L_sub(Mpy_32_16_1(RZ1[j], t_sin[c1_ind]), + L_sub(Mpy_32_16_1(IZ1[-j], t_sin[s1_ind]), + L_add(Mpy_32_16_1(RZ2[j], t_sin[c2_ind]), + Mpy_32_16_1(IZ2[-j], t_sin[s2_ind]))))); + IY[-i] = L_sub(IZ0[-j], L_add(Mpy_32_16_1(RZ1[j], t_sin[s1_ind]), + L_sub(Mpy_32_16_1(IZ1[-j], t_sin[c1_ind]), + L_sub(Mpy_32_16_1(RZ2[j], t_sin[s2_ind]), + Mpy_32_16_1(IZ2[-j], t_sin[c2_ind]))))); } /* last 3/12 */ - for ( ; i < 12 * m / 8; i++, j++, c1_ind = sub( c1_ind, c1_step ), s1_ind = sub( s1_ind, s1_step ), c2_ind = sub( c2_ind, c2_step ), s2_ind = sub( s2_ind, s2_step ) ) - { - RY[i] = L_sub( RZ0[j], L_sub( L_sub( Mpy_32_16_1( RZ1[j], t_sin[c1_ind] ), - Mpy_32_16_1( IZ1[-j], t_sin[s1_ind] ) ), - L_sub( Mpy_32_16_1( RZ2[j], t_sin[c2_ind] ), - Mpy_32_16_1( IZ2[-j], t_sin[s2_ind] ) ) ) ); - IY[-i] = L_sub( IZ0[-j], L_sub( L_add( Mpy_32_16_1( RZ1[j], t_sin[s1_ind] ), - Mpy_32_16_1( IZ1[-j], t_sin[c1_ind] ) ), - L_add( Mpy_32_16_1( RZ2[j], t_sin[s2_ind] ), - Mpy_32_16_1( IZ2[-j], t_sin[c2_ind] ) ) ) ); + for ( ; i < 12 * m / 8; i++, j++, c1_ind = sub(c1_ind, c1_step), s1_ind = sub(s1_ind, s1_step), c2_ind = sub(c2_ind, c2_step), s2_ind = sub(s2_ind, s2_step) ) + { + RY[i] = L_sub(RZ0[j], L_sub(L_sub(Mpy_32_16_1(RZ1[j], t_sin[c1_ind]), + Mpy_32_16_1(IZ1[-j], t_sin[s1_ind])), + L_sub(Mpy_32_16_1(RZ2[j], t_sin[c2_ind]), + Mpy_32_16_1(IZ2[-j], t_sin[s2_ind])))); + IY[-i] = L_sub(IZ0[-j], L_sub(L_add(Mpy_32_16_1(RZ1[j], t_sin[s1_ind]), + Mpy_32_16_1(IZ1[-j], t_sin[c1_ind])), + L_add(Mpy_32_16_1(RZ2[j], t_sin[s2_ind]), + Mpy_32_16_1(IZ2[-j], t_sin[c2_ind])))); } /* special case: i = 3*m/2 */ - RY[i] = L_sub( RZ0[j], L_sub( Mpy_32_16_1( RZ1[j], t_sin[c1_ind] ), - Mpy_32_16_1( RZ2[j], t_sin[c2_ind] ) ) ); + RY[i] = L_sub(RZ0[j], L_sub(Mpy_32_16_1(RZ1[j], t_sin[c1_ind]), + Mpy_32_16_1(RZ2[j], t_sin[c2_ind]))); return; } @@ -2542,15 +2542,15 @@ void ifft3_fx_ivas( /* Inverse butterflies of order 3. */ /* Construction of Y0 */ - RY0[0] = L_add( RZ0[0], L_add( RZ1[0], RZ2[0] ) ); - FOR( i = 1; i < m / 2; i++ ) + RY0[0] = L_add(RZ0[0], L_add(RZ1[0], RZ2[0])); + FOR ( i = 1; i < m / 2; i++ ) { - RY0[i] = L_add( RZ0[i], L_add( RZ1[i], RZ2[-i] ) ); - IY0[-i] = L_add( IZ0[-i], L_sub( IZ1[-i], IZ2[i] ) ); + RY0[i] = L_add(RZ0[i], L_add(RZ1[i], RZ2[-i])); + IY0[-i] = L_add(IZ0[-i], L_sub(IZ1[-i], IZ2[i])); } /* m/2 */ - RY0[i] = L_add( RZ0[i], L_add( RZ1[i], RZ2[-i] ) ); + RY0[i] = L_add(RZ0[i], L_add(RZ1[i], RZ2[-i])); /* Construction of Y1 */ c0_ind = T_SIN_PI_2; @@ -2560,57 +2560,57 @@ void ifft3_fx_ivas( c2_ind = T_SIN_PI_2 * 1 / 3; s2_ind = T_SIN_PI_2 * 2 / 3; - RY1[0] = L_sub( Mpy_32_16_1( RZ0[0], t_sin[c0_ind] ), - L_add( Mpy_32_16_1( RZ1[0], t_sin[c1_ind] ), - L_add( Mpy_32_16_1( RZ2[0], t_sin[c2_ind] ), - L_add( Mpy_32_16_1( IZ1[0], t_sin[s1_ind] ), - Mpy_32_16_1( IZ2[0], t_sin[s2_ind] ) ) ) ) ); - - c0_ind = sub( c0_ind, step ); - s0_ind = add( s0_ind, step ); - c1_ind = add( c1_ind, step ); - s1_ind = sub( s1_ind, step ); - c2_ind = sub( c2_ind, step ); - s2_ind = add( s2_ind, step ); - for ( i = 1; i < m / 4; i++, c0_ind = sub( c0_ind, step ), s0_ind = add( s0_ind, step ), c1_ind = add( c1_ind, step ), s1_ind = sub( s1_ind, step ), c2_ind = sub( c2_ind, step ), s2_ind = add( s2_ind, step ) ) - { - RY1[i] = L_sub( Mpy_32_16_1( RZ0[i], t_sin[c0_ind] ), - L_add( Mpy_32_16_1( RZ1[i], t_sin[c1_ind] ), - L_add( Mpy_32_16_1( RZ2[-i], t_sin[c2_ind] ), - L_add( Mpy_32_16_1( IZ0[-i], t_sin[s0_ind] ), - L_add( Mpy_32_16_1( IZ1[-i], t_sin[s1_ind] ), - Mpy_32_16_1( IZ2[i], t_sin[s2_ind] ) ) ) ) ) ); - IY1[-i] = L_add( L_sub( Mpy_32_16_1( IZ0[-i], t_sin[c0_ind] ), - Mpy_32_16_1( IZ1[-i], t_sin[c1_ind] ) ), - L_add( Mpy_32_16_1( IZ2[i], t_sin[c2_ind] ), - L_add( Mpy_32_16_1( RZ0[i], t_sin[s0_ind] ), - L_sub( Mpy_32_16_1( RZ1[i], t_sin[s1_ind] ), - Mpy_32_16_1( RZ2[-i], t_sin[s2_ind] ) ) ) ) ); + RY1[0] = L_sub(Mpy_32_16_1(RZ0[0], t_sin[c0_ind]), + L_add(Mpy_32_16_1(RZ1[0], t_sin[c1_ind]), + L_add(Mpy_32_16_1(RZ2[0], t_sin[c2_ind]), + L_add(Mpy_32_16_1(IZ1[0], t_sin[s1_ind]), + Mpy_32_16_1(IZ2[0], t_sin[s2_ind]))))); + + c0_ind = sub(c0_ind, step); + s0_ind = add(s0_ind, step); + c1_ind = add(c1_ind, step); + s1_ind = sub(s1_ind, step); + c2_ind = sub(c2_ind, step); + s2_ind = add(s2_ind, step); + for ( i = 1; i < m / 4; i++, c0_ind = sub(c0_ind, step), s0_ind = add(s0_ind, step), c1_ind = add(c1_ind, step), s1_ind = sub(s1_ind, step), c2_ind = sub(c2_ind, step), s2_ind = add(s2_ind, step) ) + { + RY1[i] = L_sub(Mpy_32_16_1(RZ0[i], t_sin[c0_ind]), + L_add(Mpy_32_16_1(RZ1[i], t_sin[c1_ind]), + L_add(Mpy_32_16_1(RZ2[-i], t_sin[c2_ind]), + L_add(Mpy_32_16_1(IZ0[-i], t_sin[s0_ind]), + L_add(Mpy_32_16_1(IZ1[-i], t_sin[s1_ind]), + Mpy_32_16_1(IZ2[i], t_sin[s2_ind])))))); + IY1[-i] = L_add(L_sub(Mpy_32_16_1(IZ0[-i], t_sin[c0_ind]), + Mpy_32_16_1(IZ1[-i], t_sin[c1_ind])), + L_add(Mpy_32_16_1(IZ2[i], t_sin[c2_ind]), + L_add(Mpy_32_16_1(RZ0[i], t_sin[s0_ind]), + L_sub(Mpy_32_16_1(RZ1[i], t_sin[s1_ind]), + Mpy_32_16_1(RZ2[-i], t_sin[s2_ind]))))); } - for ( ; i < m / 2; i++, c0_ind = sub( c0_ind, step ), s0_ind = add( s0_ind, step ), c1_ind = add( c1_ind, step ), s1_ind = sub( s1_ind, step ), c2_ind = add( c2_ind, step ), s2_ind = sub( s2_ind, step ) ) - { - RY1[i] = L_sub( Mpy_32_16_1( RZ0[i], t_sin[c0_ind] ), - L_add( L_sub( Mpy_32_16_1( RZ1[i], t_sin[c1_ind] ), - Mpy_32_16_1( RZ2[-i], t_sin[c2_ind] ) ), - L_add( Mpy_32_16_1( IZ0[-i], t_sin[s0_ind] ), - L_add( Mpy_32_16_1( IZ1[-i], t_sin[s1_ind] ), - Mpy_32_16_1( IZ2[i], t_sin[s2_ind] ) ) ) ) ); - IY1[-i] = L_sub( Mpy_32_16_1( IZ0[-i], t_sin[c0_ind] ), - L_sub( L_add( Mpy_32_16_1( IZ1[-i], t_sin[c1_ind] ), - Mpy_32_16_1( IZ2[i], t_sin[c2_ind] ) ), - L_add( Mpy_32_16_1( RZ0[i], t_sin[s0_ind] ), - L_sub( Mpy_32_16_1( RZ1[i], t_sin[s1_ind] ), - Mpy_32_16_1( RZ2[-i], t_sin[s2_ind] ) ) ) ) ); + for ( ; i < m / 2; i++, c0_ind = sub(c0_ind, step), s0_ind = add(s0_ind, step), c1_ind = add(c1_ind, step), s1_ind = sub(s1_ind, step), c2_ind = add(c2_ind, step), s2_ind = sub(s2_ind, step) ) + { + RY1[i] = L_sub(Mpy_32_16_1(RZ0[i], t_sin[c0_ind]), + L_add(L_sub(Mpy_32_16_1(RZ1[i], t_sin[c1_ind]), + Mpy_32_16_1(RZ2[-i], t_sin[c2_ind])), + L_add(Mpy_32_16_1(IZ0[-i], t_sin[s0_ind]), + L_add(Mpy_32_16_1(IZ1[-i], t_sin[s1_ind]), + Mpy_32_16_1(IZ2[i], t_sin[s2_ind]))))); + IY1[-i] = L_sub(Mpy_32_16_1(IZ0[-i], t_sin[c0_ind]), + L_sub(L_add(Mpy_32_16_1(IZ1[-i], t_sin[c1_ind]), + Mpy_32_16_1(IZ2[i], t_sin[c2_ind])), + L_add(Mpy_32_16_1(RZ0[i], t_sin[s0_ind]), + L_sub(Mpy_32_16_1(RZ1[i], t_sin[s1_ind]), + Mpy_32_16_1(RZ2[-i], t_sin[s2_ind]))))); } /* m/2 */ - RY1[i] = L_sub( Mpy_32_16_1( RZ0[i], t_sin[c0_ind] ), - L_add( L_sub( Mpy_32_16_1( RZ1[i], t_sin[c1_ind] ), - Mpy_32_16_1( RZ2[-i], t_sin[c2_ind] ) ), - L_add( Mpy_32_16_1( IZ0[-i], t_sin[s0_ind] ), - L_add( Mpy_32_16_1( IZ1[-i], t_sin[s1_ind] ), - Mpy_32_16_1( IZ2[i], t_sin[s2_ind] ) ) ) ) ); + RY1[i] = L_sub(Mpy_32_16_1(RZ0[i], t_sin[c0_ind]), + L_add(L_sub(Mpy_32_16_1(RZ1[i], t_sin[c1_ind]), + Mpy_32_16_1(RZ2[-i], t_sin[c2_ind])), + L_add(Mpy_32_16_1(IZ0[-i], t_sin[s0_ind]), + L_add(Mpy_32_16_1(IZ1[-i], t_sin[s1_ind]), + Mpy_32_16_1(IZ2[i], t_sin[s2_ind]))))); /* Construction of Y2 */ c0_ind = T_SIN_PI_2; @@ -2620,89 +2620,89 @@ void ifft3_fx_ivas( c2_ind = T_SIN_PI_2 * 1 / 3; s2_ind = T_SIN_PI_2 * 2 / 3; step2 = 2 * step; - RY2[0] = L_sub( Mpy_32_16_1( RZ0[0], t_sin[c0_ind] ), - L_sub( L_add( Mpy_32_16_1( RZ1[0], t_sin[c1_ind] ), - Mpy_32_16_1( RZ2[0], t_sin[c2_ind] ) ), - L_add( Mpy_32_16_1( IZ1[0], t_sin[s1_ind] ), - Mpy_32_16_1( IZ2[0], t_sin[s2_ind] ) ) ) ); - - c0_ind = sub( c0_ind, step2 ); - s0_ind = add( s0_ind, step2 ); - c1_ind = sub( c1_ind, step2 ); - s1_ind = add( s1_ind, step2 ); - c2_ind = add( c2_ind, step2 ); - s2_ind = sub( s2_ind, step2 ); - for ( i = 1; i < m / 8; i++, c0_ind = sub( c0_ind, step2 ), s0_ind = add( s0_ind, step2 ), c1_ind = sub( c1_ind, step2 ), s1_ind = add( s1_ind, step2 ), c2_ind = add( c2_ind, step2 ), s2_ind = sub( s2_ind, step2 ) ) - { - RY2[i] = L_sub( Mpy_32_16_1( RZ0[i], t_sin[c0_ind] ), - L_add( L_add( Mpy_32_16_1( RZ1[i], t_sin[c1_ind] ), - Mpy_32_16_1( RZ2[-i], t_sin[c2_ind] ) ), - L_sub( Mpy_32_16_1( IZ0[-i], t_sin[s0_ind] ), - L_add( Mpy_32_16_1( IZ1[-i], t_sin[s1_ind] ), - Mpy_32_16_1( IZ2[i], t_sin[s2_ind] ) ) ) ) ); - IY2[-i] = L_add( L_sub( Mpy_32_16_1( IZ0[-i], t_sin[c0_ind] ), - Mpy_32_16_1( IZ1[-i], t_sin[c1_ind] ) ), - L_add( Mpy_32_16_1( IZ2[i], t_sin[c2_ind] ), - L_sub( Mpy_32_16_1( RZ0[i], t_sin[s0_ind] ), - L_sub( Mpy_32_16_1( RZ1[i], t_sin[s1_ind] ), - Mpy_32_16_1( RZ2[-i], t_sin[s2_ind] ) ) ) ) ); + RY2[0] = L_sub(Mpy_32_16_1(RZ0[0], t_sin[c0_ind]), + L_sub(L_add(Mpy_32_16_1(RZ1[0], t_sin[c1_ind]), + Mpy_32_16_1(RZ2[0], t_sin[c2_ind])), + L_add(Mpy_32_16_1(IZ1[0], t_sin[s1_ind]), + Mpy_32_16_1(IZ2[0], t_sin[s2_ind])))); + + c0_ind = sub(c0_ind, step2); + s0_ind = add(s0_ind, step2); + c1_ind = sub(c1_ind, step2); + s1_ind = add(s1_ind, step2); + c2_ind = add(c2_ind, step2); + s2_ind = sub(s2_ind, step2); + for ( i = 1; i < m / 8; i++, c0_ind = sub(c0_ind, step2), s0_ind = add(s0_ind, step2), c1_ind = sub(c1_ind, step2), s1_ind = add(s1_ind, step2), c2_ind = add(c2_ind, step2), s2_ind = sub(s2_ind, step2) ) + { + RY2[i] = L_sub(Mpy_32_16_1(RZ0[i], t_sin[c0_ind]), + L_add(L_add(Mpy_32_16_1(RZ1[i], t_sin[c1_ind]), + Mpy_32_16_1(RZ2[-i], t_sin[c2_ind])), + L_sub(Mpy_32_16_1(IZ0[-i], t_sin[s0_ind]), + L_add(Mpy_32_16_1(IZ1[-i], t_sin[s1_ind]), + Mpy_32_16_1(IZ2[i], t_sin[s2_ind]))))); + IY2[-i] = L_add(L_sub(Mpy_32_16_1(IZ0[-i], t_sin[c0_ind]), + Mpy_32_16_1(IZ1[-i], t_sin[c1_ind])), + L_add(Mpy_32_16_1(IZ2[i], t_sin[c2_ind]), + L_sub(Mpy_32_16_1(RZ0[i], t_sin[s0_ind]), + L_sub(Mpy_32_16_1(RZ1[i], t_sin[s1_ind]), + Mpy_32_16_1(RZ2[-i], t_sin[s2_ind]))))); } - for ( ; i < m / 4; i++, c0_ind = sub( c0_ind, step2 ), s0_ind = add( s0_ind, step2 ), c1_ind = add( c1_ind, step2 ), s1_ind = sub( s1_ind, step2 ), c2_ind = add( c2_ind, step2 ), s2_ind = sub( s2_ind, step2 ) ) - { - RY2[i] = L_add( Mpy_32_16_1( RZ0[i], t_sin[c0_ind] ), - L_sub( Mpy_32_16_1( RZ1[i], t_sin[c1_ind] ), - L_sub( L_add( Mpy_32_16_1( RZ2[-i], t_sin[c2_ind] ), - Mpy_32_16_1( IZ0[-i], t_sin[s0_ind] ) ), - L_add( Mpy_32_16_1( IZ1[-i], t_sin[s1_ind] ), - Mpy_32_16_1( IZ2[i], t_sin[s2_ind] ) ) ) ) ); - IY2[-i] = L_add( Mpy_32_16_1( IZ0[-i], t_sin[c0_ind] ), - L_add( Mpy_32_16_1( IZ1[-i], t_sin[c1_ind] ), - L_add( Mpy_32_16_1( IZ2[i], t_sin[c2_ind] ), - L_sub( Mpy_32_16_1( RZ0[i], t_sin[s0_ind] ), - L_sub( Mpy_32_16_1( RZ1[i], t_sin[s1_ind] ), - Mpy_32_16_1( RZ2[-i], t_sin[s2_ind] ) ) ) ) ) ); + for ( ; i < m / 4; i++, c0_ind = sub(c0_ind, step2), s0_ind = add(s0_ind, step2), c1_ind = add(c1_ind, step2), s1_ind = sub(s1_ind, step2), c2_ind = add(c2_ind, step2), s2_ind = sub(s2_ind, step2) ) + { + RY2[i] = L_add(Mpy_32_16_1(RZ0[i], t_sin[c0_ind]), + L_sub(Mpy_32_16_1(RZ1[i], t_sin[c1_ind]), + L_sub(L_add(Mpy_32_16_1(RZ2[-i], t_sin[c2_ind]), + Mpy_32_16_1(IZ0[-i], t_sin[s0_ind])), + L_add(Mpy_32_16_1(IZ1[-i], t_sin[s1_ind]), + Mpy_32_16_1(IZ2[i], t_sin[s2_ind]))))); + IY2[-i] = L_add(Mpy_32_16_1(IZ0[-i], t_sin[c0_ind]), + L_add(Mpy_32_16_1(IZ1[-i], t_sin[c1_ind]), + L_add(Mpy_32_16_1(IZ2[i], t_sin[c2_ind]), + L_sub(Mpy_32_16_1(RZ0[i], t_sin[s0_ind]), + L_sub(Mpy_32_16_1(RZ1[i], t_sin[s1_ind]), + Mpy_32_16_1(RZ2[-i], t_sin[s2_ind])))))); } - for ( ; i < 3 * m / 8; i++, c0_ind = sub( c0_ind, step2 ), s0_ind = add( s0_ind, step2 ), c1_ind = add( c1_ind, step2 ), s1_ind = sub( s1_ind, step2 ), c2_ind = sub( c2_ind, step2 ), s2_ind = add( s2_ind, step2 ) ) - { - RY2[i] = L_sub( L_add( Mpy_32_16_1( RZ0[i], t_sin[c0_ind] ), - Mpy_32_16_1( RZ1[i], t_sin[c1_ind] ) ), - L_sub( L_add( Mpy_32_16_1( RZ2[-i], t_sin[c2_ind] ), - Mpy_32_16_1( IZ0[-i], t_sin[s0_ind] ) ), - L_sub( Mpy_32_16_1( IZ1[-i], t_sin[s1_ind] ), - Mpy_32_16_1( IZ2[i], t_sin[s2_ind] ) ) ) ); - IY2[-i] = L_sub( L_add( Mpy_32_16_1( IZ0[-i], t_sin[c0_ind] ), - L_add( Mpy_32_16_1( IZ1[-i], t_sin[c1_ind] ), - L_add( Mpy_32_16_1( IZ2[i], t_sin[c2_ind] ), - Mpy_32_16_1( RZ0[i], t_sin[s0_ind] ) ) ) ), - L_add( Mpy_32_16_1( RZ1[i], t_sin[s1_ind] ), - Mpy_32_16_1( RZ2[-i], t_sin[s2_ind] ) ) ); + for ( ; i < 3 * m / 8; i++, c0_ind = sub(c0_ind, step2), s0_ind = add(s0_ind, step2), c1_ind = add(c1_ind, step2), s1_ind = sub(s1_ind, step2), c2_ind = sub(c2_ind, step2), s2_ind = add(s2_ind, step2) ) + { + RY2[i] = L_sub(L_add(Mpy_32_16_1(RZ0[i], t_sin[c0_ind]), + Mpy_32_16_1(RZ1[i], t_sin[c1_ind])), + L_sub(L_add(Mpy_32_16_1(RZ2[-i], t_sin[c2_ind]), + Mpy_32_16_1(IZ0[-i], t_sin[s0_ind])), + L_sub(Mpy_32_16_1(IZ1[-i], t_sin[s1_ind]), + Mpy_32_16_1(IZ2[i], t_sin[s2_ind])))); + IY2[-i] = L_sub(L_add(Mpy_32_16_1(IZ0[-i], t_sin[c0_ind]), + L_add(Mpy_32_16_1(IZ1[-i], t_sin[c1_ind]), + L_add(Mpy_32_16_1(IZ2[i], t_sin[c2_ind]), + Mpy_32_16_1(RZ0[i], t_sin[s0_ind])))), + L_add(Mpy_32_16_1(RZ1[i], t_sin[s1_ind]), + Mpy_32_16_1(RZ2[-i], t_sin[s2_ind]))); } - for ( ; i < m / 2; i++, c0_ind = add( c0_ind, step2 ), s0_ind = sub( s0_ind, step2 ), c1_ind = add( c1_ind, step2 ), s1_ind = sub( s1_ind, step2 ), c2_ind = sub( c2_ind, step2 ), s2_ind = add( s2_ind, step2 ) ) - { - RY2[i] = L_sub( L_sub( Mpy_32_16_1( RZ1[i], t_sin[c1_ind] ), - Mpy_32_16_1( RZ0[i], t_sin[c0_ind] ) ), - L_sub( L_add( Mpy_32_16_1( RZ2[-i], t_sin[c2_ind] ), - Mpy_32_16_1( IZ0[-i], t_sin[s0_ind] ) ), - L_sub( Mpy_32_16_1( IZ1[-i], t_sin[s1_ind] ), - Mpy_32_16_1( IZ2[i], t_sin[s2_ind] ) ) ) ); - IY2[-i] = L_add( L_sub( Mpy_32_16_1( IZ1[-i], t_sin[c1_ind] ), - Mpy_32_16_1( IZ0[-i], t_sin[c0_ind] ) ), - L_sub( L_add( Mpy_32_16_1( IZ2[i], t_sin[c2_ind] ), - Mpy_32_16_1( RZ0[i], t_sin[s0_ind] ) ), - L_add( Mpy_32_16_1( RZ1[i], t_sin[s1_ind] ), - Mpy_32_16_1( RZ2[-i], t_sin[s2_ind] ) ) ) ); + for ( ; i < m / 2; i++, c0_ind = add(c0_ind, step2), s0_ind = sub(s0_ind, step2), c1_ind = add(c1_ind, step2), s1_ind = sub(s1_ind, step2), c2_ind = sub(c2_ind, step2), s2_ind = add(s2_ind, step2) ) + { + RY2[i] = L_sub(L_sub(Mpy_32_16_1(RZ1[i], t_sin[c1_ind]), + Mpy_32_16_1(RZ0[i], t_sin[c0_ind])), + L_sub(L_add(Mpy_32_16_1(RZ2[-i], t_sin[c2_ind]), + Mpy_32_16_1(IZ0[-i], t_sin[s0_ind])), + L_sub(Mpy_32_16_1(IZ1[-i], t_sin[s1_ind]), + Mpy_32_16_1(IZ2[i], t_sin[s2_ind])))); + IY2[-i] = L_add(L_sub(Mpy_32_16_1(IZ1[-i], t_sin[c1_ind]), + Mpy_32_16_1(IZ0[-i], t_sin[c0_ind])), + L_sub(L_add(Mpy_32_16_1(IZ2[i], t_sin[c2_ind]), + Mpy_32_16_1(RZ0[i], t_sin[s0_ind])), + L_add(Mpy_32_16_1(RZ1[i], t_sin[s1_ind]), + Mpy_32_16_1(RZ2[-i], t_sin[s2_ind])))); } /* m/2 */ - RY2[i] = L_sub( L_sub( Mpy_32_16_1( RZ1[i], t_sin[c1_ind] ), - Mpy_32_16_1( RZ0[i], t_sin[c0_ind] ) ), - L_sub( L_add( Mpy_32_16_1( RZ2[-i], t_sin[c2_ind] ), - Mpy_32_16_1( IZ0[-i], t_sin[s0_ind] ) ), - L_sub( Mpy_32_16_1( IZ1[-i], t_sin[s1_ind] ), - Mpy_32_16_1( IZ2[i], t_sin[s2_ind] ) ) ) ); + RY2[i] = L_sub(L_sub(Mpy_32_16_1(RZ1[i], t_sin[c1_ind]), + Mpy_32_16_1(RZ0[i], t_sin[c0_ind])), + L_sub(L_add(Mpy_32_16_1(RZ2[-i], t_sin[c2_ind]), + Mpy_32_16_1(IZ0[-i], t_sin[s0_ind])), + L_sub(Mpy_32_16_1(IZ1[-i], t_sin[s1_ind]), + Mpy_32_16_1(IZ2[i], t_sin[s2_ind])))); /* Compute the inverse FFT for all 3 blocks. */ ifft_rel_fx32( RY0, m, order ); @@ -2714,12 +2714,12 @@ void ifft3_fx_ivas( y2 = RY2; /* Interlacing and scaling, scale = 1/3 */ - scale = (Word16) ( 0x2AAB ); - FOR( i = 0; i < n; ) + scale = (Word16)(0x2AAB); + FOR ( i = 0; i < n; ) { - X[i++] = Mpy_32_16_1( ( *y0++ ), scale ); - X[i++] = Mpy_32_16_1( ( *y1++ ), scale ); - X[i++] = Mpy_32_16_1( ( *y2++ ), scale ); + X[i++] = Mpy_32_16_1(( *y0++ ), scale); + X[i++] = Mpy_32_16_1(( *y1++ ), scale); + X[i++] = Mpy_32_16_1(( *y2++ ), scale); } return; @@ -2735,26 +2735,26 @@ static void rfft_post( Word16 s, c; Word16 i = 0; - tmp1 = L_add( buf[0], buf[1] ); - buf[1] = L_sub( buf[0], buf[1] ); + tmp1 = L_add(buf[0], buf[1]); + buf[1] = L_sub(buf[0], buf[1]); buf[0] = tmp1; - FOR( i = 1; i <= ( len + 2 ) / 4; i++ ) + FOR ( i = 1; i <= ( len + 2 ) / 4; i++ ) { s = sine_table[i]; /* sin(pi*i/(len/2)) */ c = sine_table[i + len / 4]; /* cos(pi*i/(len/2)) */ - tmp1 = L_sub( buf[2 * i], buf[len - 2 * i] ); - tmp2 = L_add( buf[2 * i + 1], buf[len - 2 * i + 1] ); - tmp3 = L_sub( Mpy_32_16_1( tmp1, s ), Mpy_32_16_1( tmp2, c ) ); /* real part of j*W(k,N)*[T(k) - T'(N-k)] */ - tmp4 = L_add( Mpy_32_16_1( tmp1, c ), Mpy_32_16_1( tmp2, s ) ); /* imag part of j*W(k,N)*[T(k) - T'(N-k)] */ - tmp1 = L_add( buf[2 * i], buf[len - 2 * i] ); - tmp2 = L_sub( buf[2 * i + 1], buf[len - 2 * i + 1] ); - - buf[2 * i] = L_shr( L_sub( tmp1, tmp3 ), 1 ); - buf[2 * i + 1] = L_shr( L_sub( tmp2, tmp4 ), 1 ); - buf[len - 2 * i] = L_shr( L_add( tmp1, tmp3 ), 1 ); - buf[len - 2 * i + 1] = L_negate( L_shr( L_add( tmp2, tmp4 ), 1 ) ); + tmp1 = L_sub(buf[2 * i], buf[len - 2 * i]); + tmp2 = L_add(buf[2 * i + 1], buf[len - 2 * i + 1]); + tmp3 = L_sub(Mpy_32_16_1(tmp1, s), Mpy_32_16_1(tmp2, c)); /* real part of j*W(k,N)*[T(k) - T'(N-k)] */ + tmp4 = L_add(Mpy_32_16_1(tmp1, c), Mpy_32_16_1(tmp2, s)); /* imag part of j*W(k,N)*[T(k) - T'(N-k)] */ + tmp1 = L_add(buf[2 * i], buf[len - 2 * i]); + tmp2 = L_sub(buf[2 * i + 1], buf[len - 2 * i + 1]); + + buf[2 * i] = L_shr(L_sub(tmp1, tmp3), 1); + buf[2 * i + 1] = L_shr(L_sub(tmp2, tmp4), 1); + buf[len - 2 * i] = L_shr(L_add(tmp1, tmp3), 1); + buf[len - 2 * i + 1] = L_negate(L_shr(L_add(tmp2, tmp4), 1)); } } @@ -2763,31 +2763,31 @@ static void rfft_pre( Word32 *buf, const Word16 len ) { - const Word16 scale = (Word16) ( 1.0f / len * 32768.0 ); + const Word16 scale = (Word16)(1.0f / len * 32768.0); Word32 tmp1, tmp2, tmp3, tmp4; Word16 s, c; Word16 i = 0; - tmp1 = L_add( buf[0], buf[1] ); - buf[1] = Mpy_32_16_1( L_sub( buf[0], buf[1] ), scale ); - buf[0] = Mpy_32_16_1( tmp1, scale ); + tmp1 = L_add(buf[0], buf[1]); + buf[1] = Mpy_32_16_1(L_sub(buf[0], buf[1]), scale); + buf[0] = Mpy_32_16_1(tmp1, scale); - FOR( i = 1; i <= ( len + 2 ) / 4; i++ ) + FOR ( i = 1; i <= ( len + 2 ) / 4; i++ ) { s = sine_table[i]; /* sin(pi*i/(len/2)) */ c = sine_table[i + len / 4]; /* cos(pi*i/(len/2)) */ - tmp1 = L_sub( buf[2 * i], buf[len - 2 * i] ); - tmp2 = L_add( buf[2 * i + 1], buf[len - 2 * i + 1] ); - tmp3 = L_add( Mpy_32_16_1( tmp1, s ), Mpy_32_16_1( tmp2, c ) ); /* real part of j*W(k,N)*[T(k) - T'(N-k)] */ - tmp4 = L_sub( Mpy_32_16_1( tmp2, s ), Mpy_32_16_1( tmp1, c ) ); /* imag part of j*W(k,N)*[T(k) - T'(N-k)] */ - tmp1 = L_add( buf[2 * i], buf[len - 2 * i] ); - tmp2 = L_sub( buf[2 * i + 1], buf[len - 2 * i + 1] ); - - buf[2 * i] = Mpy_32_16_1( L_add( tmp1, tmp3 ), scale ); - buf[2 * i + 1] = L_negate( Mpy_32_16_1( L_add( tmp2, tmp4 ), scale ) ); - buf[len - 2 * i] = Mpy_32_16_1( L_sub( tmp1, tmp3 ), scale ); - buf[len - 2 * i + 1] = Mpy_32_16_1( L_sub( tmp2, tmp4 ), scale ); + tmp1 = L_sub(buf[2 * i], buf[len - 2 * i]); + tmp2 = L_add(buf[2 * i + 1], buf[len - 2 * i + 1]); + tmp3 = L_add(Mpy_32_16_1(tmp1, s), Mpy_32_16_1(tmp2, c)); /* real part of j*W(k,N)*[T(k) - T'(N-k)] */ + tmp4 = L_sub(Mpy_32_16_1(tmp2, s), Mpy_32_16_1(tmp1, c)); /* imag part of j*W(k,N)*[T(k) - T'(N-k)] */ + tmp1 = L_add(buf[2 * i], buf[len - 2 * i]); + tmp2 = L_sub(buf[2 * i + 1], buf[len - 2 * i + 1]); + + buf[2 * i] = Mpy_32_16_1(L_add(tmp1, tmp3), scale); + buf[2 * i + 1] = L_negate(Mpy_32_16_1(L_add(tmp2, tmp4), scale)); + buf[len - 2 * i] = Mpy_32_16_1(L_sub(tmp1, tmp3), scale); + buf[len - 2 * i + 1] = Mpy_32_16_1(L_sub(tmp2, tmp4), scale); } return; @@ -2801,47 +2801,47 @@ Word16 RFFTN_fx( { assert( len <= 640 && len > 0 ); - IF( EQ_16( len, 640 ) ) + IF ( EQ_16(len, 640) ) { Word32 x[320], y[320]; Word16 i; - IF( NE_16( sign, -1 ) ) + IF ( NE_16(sign, -1) ) { rfft_pre( sine_table, data, len ); } - FOR( i = 0; i < 320; i++ ) + FOR ( i = 0; i < 320; i++ ) { x[i] = data[2 * i]; y[i] = data[2 * i + 1]; } DoRTFT320_fx( x, y ); - FOR( i = 0; i < 320; i++ ) + FOR ( i = 0; i < 320; i++ ) { data[2 * i] = x[i]; data[2 * i + 1] = y[i]; } - IF( EQ_16( sign, -1 ) ) + IF ( EQ_16(sign, -1) ) { rfft_post( sine_table, data, len ); } } ELSE { - IF( EQ_16( len, 512 ) ) + IF ( EQ_16(len, 512) ) { Word16 i; const Word16 log2 = 9; Word32 reordered_data[512]; - IF( EQ_16( sign, -1 ) ) + IF ( EQ_16(sign, -1) ) { fft_rel_fx32( data, len, log2 ); reordered_data[0] = data[0]; reordered_data[1] = data[len / 2]; - FOR( i = 1; i < len / 2; i++ ) + FOR ( i = 1; i < len / 2; i++ ) { reordered_data[2 * i] = data[i]; reordered_data[2 * i + 1] = data[len - i]; @@ -2851,7 +2851,7 @@ Word16 RFFTN_fx( { reordered_data[0] = data[0]; reordered_data[len / 2] = data[1]; - FOR( i = 1; i < len / 2; i++ ) + FOR ( i = 1; i < len / 2; i++ ) { reordered_data[i] = data[2 * i]; reordered_data[len - i] = data[2 * i + 1]; @@ -3101,7 +3101,7 @@ static void nextFFT( const Word16 length ) { cmplx val[5]; - SWITCH( length ) + SWITCH ( length ) { case 2: fft2( x ); @@ -3113,13 +3113,13 @@ static void nextFFT( fft4( x ); BREAK; case 5: - FOR( Word32 i = 0; i < 5; i++ ) + FOR ( Word32 i = 0; i < 5; i++ ) { val[i].re = x[2 * i]; val[i].im = x[2 * i + 1]; } fft5( val ); - FOR( Word32 i = 0; i < 5; i++ ) + FOR ( Word32 i = 0; i < 5; i++ ) { x[2 * i] = val[i].re; x[2 * i + 1] = val[i].im; @@ -3215,13 +3215,13 @@ static void cooleyTukeyFFT( fft4( x ); BREAK; case 5: - FOR( i = 0; i < 5; i++ ) + FOR ( i = 0; i < 5; i++ ) { val[i].re = x[2 * i]; val[i].im = x[2 * i + 1]; } fft5( val ); - FOR( i = 0; i < 5; i++ ) + FOR ( i = 0; i < 5; i++ ) { x[2 * i] = val[i].re; x[2 * i + 1] = val[i].im; @@ -3234,7 +3234,7 @@ static void cooleyTukeyFFT( { factor = findFactor( length ); - IF( GT_16( factor, 0 ) && GT_16( length / factor, 1 ) ) + IF ( GT_16(factor, 0) && GT_16( length / factor, 1 ) ) { n1 = factor; n2 = length / factor; @@ -3314,7 +3314,7 @@ static void pfaDFT( Word16 i, ii; Word16 cnt; - IF( GT_16( numFactors, 1 ) ) + IF ( GT_16(numFactors, 1) ) { Word32 *tmp = scratch1; Word16 n1_inv = 1, n2_inv = 1; @@ -3342,7 +3342,7 @@ static void pfaDFT( idx += incr; - IF( GT_16( idx, length ) ) + IF ( GT_16(idx, length) ) { idx -= length; } @@ -3378,7 +3378,7 @@ static void pfaDFT( tmp[2 * idx + 1] = x[cnt++]; idx += n2; - IF( GT_16( idx, length ) ) + IF ( GT_16(idx, length) ) { idx -= length; } @@ -5080,14 +5080,14 @@ static void fft_lenN( case 10: { cmplx y[10]; - FOR( j = 0; j < dim2; j++ ) + FOR ( j = 0; j < dim2; j++ ) { { y[j] = xx[0 + j * dim1]; }; } fft_len10( &y[0] ); - FOR( j = 0; j < dim2; j++ ) + FOR ( j = 0; j < dim2; j++ ) { x[0 + j * dim1] = y[j]; } @@ -5106,7 +5106,7 @@ static void fft_lenN( } } fft_len10( &y[0] ); - FOR( j = 0; j < dim2; j++ ) + FOR ( j = 0; j < dim2; j++ ) { x[i + j * dim1] = y[j]; } @@ -5117,7 +5117,7 @@ static void fft_lenN( case 16: { cmplx y[16]; - FOR( j = 0; j < dim2; j++ ) + FOR ( j = 0; j < dim2; j++ ) { { y[j] = xx[0 + j * dim1]; @@ -5125,7 +5125,7 @@ static void fft_lenN( } fft_len16( &y[0] ); - FOR( j = 0; j < dim2; j++ ) + FOR ( j = 0; j < dim2; j++ ) { x[0 + j * dim1] = y[j]; } @@ -5144,7 +5144,7 @@ static void fft_lenN( } } fft_len16( &y[0] ); - FOR( j = 0; j < dim2; j++ ) + FOR ( j = 0; j < dim2; j++ ) { x[i + j * dim1] = y[j]; } @@ -5155,14 +5155,14 @@ static void fft_lenN( case 20: { cmplx y[20]; - FOR( j = 0; j < dim2; j++ ) + FOR ( j = 0; j < dim2; j++ ) { { y[j] = xx[0 + j * dim1]; }; } fft_len20_fx( &y[0] ); - FOR( j = 0; j < dim2; j++ ) + FOR ( j = 0; j < dim2; j++ ) { x[0 + j * dim1] = y[j]; } @@ -5189,7 +5189,7 @@ static void fft_lenN( } } fft_len20_fx( &y[0] ); - FOR( j = 0; j < dim2; j++ ) + FOR ( j = 0; j < dim2; j++ ) { x[i + j * dim1] = y[j]; } @@ -5200,14 +5200,14 @@ static void fft_lenN( case 32: { cmplx y[32]; - FOR( j = 0; j < dim2; j++ ) + FOR ( j = 0; j < dim2; j++ ) { { y[j] = xx[0 + j * dim1]; }; } fft_len32( &y[0] ); - FOR( j = 0; j < dim2; j++ ) + FOR ( j = 0; j < dim2; j++ ) { x[0 + j * dim1] = y[j]; } @@ -5234,7 +5234,7 @@ static void fft_lenN( } } fft_len32( &y[0] ); - FOR( j = 0; j < dim2; j++ ) + FOR ( j = 0; j < dim2; j++ ) { x[i + j * dim1] = y[j]; } @@ -5260,7 +5260,7 @@ void fft_fx( { cmplx x[960]; - FOR( Word32 j = 0; j < length; j++ ) + FOR ( Word32 j = 0; j < length; j++ ) { x[j].re = re[s * j]; x[j].im = im[s * j]; @@ -5323,7 +5323,7 @@ void fft_fx( assert( !"fft length is not supported!" ); } - FOR( Word32 j = 0; j < length; j++ ) + FOR ( Word32 j = 0; j < length; j++ ) { re[s * j] = x[j].re; im[s * j] = x[j].im; @@ -5333,8 +5333,8 @@ void fft_fx( } void rfft_fx( - Word32 *x, /* i/o: values */ - const Word16 *w, /* i : window */ + Word32 *x, /* i/o: values */ + const Word16 *w, /* i : window */ const Word16 length, /* i : length of fft */ const Word16 isign /* i : sign */ ) @@ -5374,61 +5374,61 @@ void rfft_fx( assert( 0 ); } - SWITCH( isign ) + SWITCH ( isign ) { case -1: fft_fx( x, x + 1, sizeOfFft2, 2 ); - tmp = L_add( x[0], x[1] ); - x[1] = L_sub( x[0], x[1] ); + tmp = L_add(x[0], x[1]); + x[1] = L_sub(x[0], x[1]); x[0] = tmp; - FOR( i = 1; i <= sizeOfFft4; i++ ) + FOR ( i = 1; i <= sizeOfFft4; i++ ) { - t1 = L_sub( x[2 * i], x[length - 2 * i] ); - t2 = L_add( x[2 * i + 1], x[length - 2 * i + 1] ); - t3 = L_sub( Mpy_32_16_1( t1, w[i] ), Mpy_32_16_1( t2, w[i + sizeOfFft4] ) ); - t4 = L_add( Mpy_32_16_1( t1, w[i + sizeOfFft4] ), Mpy_32_16_1( t2, w[i] ) ); - t1 = L_add( x[2 * i], x[length - 2 * i] ); - t2 = L_sub( x[2 * i + 1], x[length - 2 * i + 1] ); - - x[2 * i] = Mpy_32_16_1( L_sub( t1, t3 ), 16384 ); - x[2 * i + 1] = Mpy_32_16_1( L_sub( t2, t4 ), 16384 ); - x[length - 2 * i] = Mpy_32_16_1( L_add( t1, t3 ), 16384 ); - x[length - 2 * i + 1] = Mpy_32_16_1( L_negate( L_add( t2, t4 ) ), 16384 ); + t1 = L_sub(x[2 * i], x[length - 2 * i]); + t2 = L_add(x[2 * i + 1], x[length - 2 * i + 1]); + t3 = L_sub(Mpy_32_16_1(t1, w[i]), Mpy_32_16_1(t2, w[i + sizeOfFft4])); + t4 = L_add(Mpy_32_16_1(t1, w[i + sizeOfFft4]), Mpy_32_16_1(t2, w[i])); + t1 = L_add(x[2 * i], x[length - 2 * i]); + t2 = L_sub(x[2 * i + 1], x[length - 2 * i + 1]); + + x[2 * i] = Mpy_32_16_1(L_sub(t1, t3), 16384); + x[2 * i + 1] = Mpy_32_16_1(L_sub(t2, t4), 16384); + x[length - 2 * i] = Mpy_32_16_1(L_add(t1, t3), 16384); + x[length - 2 * i + 1] = Mpy_32_16_1(L_negate(L_add(t2, t4)), 16384); } BREAK; case +1: - tmp = Mpy_32_16_1( L_add( x[0], x[1] ), 16384 ); - x[1] = Mpy_32_16_1( L_sub( x[1], x[0] ), 16384 ); + tmp = Mpy_32_16_1( L_add( x[0], x[1] ), 16384); + x[1] = Mpy_32_16_1( L_sub( x[1], x[0] ), 16384); x[0] = tmp; - FOR( i = 1; i <= sizeOfFft4; i++ ) + FOR ( i = 1; i <= sizeOfFft4; i++ ) { - t1 = L_sub( x[2 * i], x[length - 2 * i] ); - t2 = L_add( x[2 * i + 1], x[length - 2 * i + 1] ); - t3 = L_add( Mpy_32_16_1( t1, w[i] ), Mpy_32_16_1( t2, w[i + sizeOfFft4] ) ); - t4 = L_sub( Mpy_32_16_1( t2, w[i] ), Mpy_32_16_1( t1, w[i + sizeOfFft4] ) ); - t1 = L_add( x[2 * i], x[length - 2 * i] ); - t2 = L_sub( x[2 * i + 1], x[length - 2 * i + 1] ); - - x[2 * i] = Mpy_32_16_1( L_sub( t1, t3 ), 16384 ); - x[2 * i + 1] = Mpy_32_16_1( L_sub( t4, t2 ), 16384 ); - x[length - 2 * i] = Mpy_32_16_1( L_add( t1, t3 ), 16384 ); - x[length - 2 * i + 1] = Mpy_32_16_1( L_add( t2, t4 ), 16384 ); + t1 = L_sub(x[2 * i], x[length - 2 * i]); + t2 = L_add(x[2 * i + 1], x[length - 2 * i + 1]); + t3 = L_add(Mpy_32_16_1(t1, w[i]), Mpy_32_16_1(t2, w[i + sizeOfFft4])); + t4 = L_sub(Mpy_32_16_1(t2, w[i]), Mpy_32_16_1(t1, w[i + sizeOfFft4])); + t1 = L_add(x[2 * i], x[length - 2 * i]); + t2 = L_sub(x[2 * i + 1], x[length - 2 * i + 1]); + + x[2 * i] = Mpy_32_16_1(L_sub( t1, t3 ), 16384); + x[2 * i + 1] = Mpy_32_16_1( L_sub( t4, t2 ), 16384); + x[length - 2 * i] = Mpy_32_16_1(L_add( t1, t3 ), 16384); + x[length - 2 * i + 1] = Mpy_32_16_1(L_add( t2, t4 ), 16384); } fft_fx( x, x + 1, sizeOfFft2, 2 ); - FOR( i = 0; i < length; i += 2 ) + FOR ( i = 0; i < length; i += 2 ) { - x[i] = Mpy_32_16_1( x[i], s1 ); - x[i + 1] = Mpy_32_16_1( x[i + 1], s2 ); + x[i] = Mpy_32_16_1(x[i], s1); + x[i + 1] = Mpy_32_16_1(x[i+1], s2); } BREAK; @@ -5440,20 +5440,20 @@ void rfft_fx( Word16 find_guarded_bits_fx( Word32 n ) { return n <= 1 ? 0 : n <= 2 ? 1 - : n <= 4 ? 2 - : n <= 8 ? 3 - : n <= 16 ? 4 - : n <= 32 ? 5 - : n <= 64 ? 6 - : n <= 128 ? 7 - : n <= 256 ? 8 - : n <= 512 ? 9 - : n <= 1024 ? 10 - : n <= 2048 ? 11 - : n <= 4096 ? 12 - : n <= 8192 ? 13 - : n <= 16384 ? 14 - : 15; + : n <= 4 ? 2 + : n <= 8 ? 3 + : n <= 16 ? 4 + : n <= 32 ? 5 + : n <= 64 ? 6 + : n <= 128 ? 7 + : n <= 256 ? 8 + : n <= 512 ? 9 + : n <= 1024 ? 10 + : n <= 2048 ? 11 + : n <= 4096 ? 12 + : n <= 8192 ? 13 + : n <= 16384 ? 14 + : 15; } Word16 L_norm_arr( Word32 *arr, Word16 size ) @@ -5485,6 +5485,17 @@ Word16 get_min_scalefactor( Word32 x, Word32 y ) return scf; } +Flag is_zero_arr( Word32 *arr, Word16 size ) +{ + FOR( int i = 0; i < size; i++ ) + if ( arr[i] != 0 ) + { + return 0; + } + + return 1; +} + #if 0 /* Functions are already in fixed point and available in fft.c file */ diff --git a/lib_com/ivas_fb_mixer.c b/lib_com/ivas_fb_mixer.c index e11e81b8f..9c0c6b6d5 100644 --- a/lib_com/ivas_fb_mixer.c +++ b/lib_com/ivas_fb_mixer.c @@ -959,6 +959,17 @@ void ivas_FB_mixer_close( free( hFbMixer->pFb->fb_consts.ppFilterbank_FRs_non48k[1][j] ); hFbMixer->pFb->fb_consts.ppFilterbank_FRs_non48k[1][j] = NULL; } + +#ifdef IVAS_FLOAT_FIXED + FOR ( j = start_diff_band_non48k; j < num_bands; j++ ) + { + free( hFbMixer->pFb->fb_consts.ppFilterbank_FRs_non48k_fx[0][j] ); + hFbMixer->pFb->fb_consts.ppFilterbank_FRs_non48k_fx[0][j] = NULL; + + free( hFbMixer->pFb->fb_consts.ppFilterbank_FRs_non48k_fx[1][j] ); + hFbMixer->pFb->fb_consts.ppFilterbank_FRs_non48k_fx[1][j] = NULL; + } +#endif } } if ( hFbMixer->pFb != NULL ) @@ -2712,13 +2723,20 @@ static void ivas_get_ld_fb_resp_fx( scratch1_fx[s] = L_shl( scratch1_fx[s], 1 ); // Q30 } - const Word32 *sine_till_frame_len = ivas_sine_frame_len_640_fx; // Q30 - offset = 1; + const Word32 *sine_till_frame_len = NULL; + + IF( delay == IVAS_FB_1MS_16K_SAMP ) + { + sine_till_frame_len = ivas_sine_frame_len_640_del_16_fx; // Q30 + } + ELSE + { + sine_till_frame_len = ivas_sine_frame_len_640_del_32_fx; // Q30 + } Word16 iterator = 0; FOR( s = 2 * delay; s < frame_len + 1; s++ ) { - scratch1_fx[s] = Mpy_32_32( scratch1_fx[s], sine_till_frame_len[iterator + ( offset * delay_16 )] ); - offset = add( offset, 1 ); + scratch1_fx[s] = Mpy_32_32( scratch1_fx[s], sine_till_frame_len[iterator] ); iterator = add( iterator, 1 ); scratch1_fx[s] = L_shl( scratch1_fx[s], 1 ); // Q30 diff --git a/lib_com/ivas_rom_com.c b/lib_com/ivas_rom_com.c index 4a3d2ab6a..70869d12c 100644 --- a/lib_com/ivas_rom_com.c +++ b/lib_com/ivas_rom_com.c @@ -9436,7 +9436,7 @@ const Word32 ivas_sine_delay_32_fx[32] = { }; /* Q Factor is 30 */ -const Word32 ivas_sine_frame_len_640_fx[577] = { +const Word32 ivas_sine_frame_len_640_del_32_fx[577] = { 1073737856, 1073725888, 1073705984, 1073678144, 1073642368, 1073598592, 1073546880, 1073487168, 1073419584, 1073343936, 1073260416, 1073168896, 1073069440, 1072962048, 1072846720, 1072723392, 1072592128, @@ -9512,6 +9512,40 @@ const Word32 ivas_sine_frame_len_640_fx[577] = { 20460476, 17537830, 14615058, 11692176, 8769208, 5846174, 2923098, 0 }; + +const Word32 ivas_sine_frame_len_640_del_16_fx[289] = { + 1073725952, + 1073678400, 1073599104, 1073488064, 1073345344, 1073170880, 1072964736, 1072726912, 1072457408, 1072156160, 1071823296, + 1071458752, 1071062528, 1070634688, 1070175232, 1069684096, 1069161472, 1068607168, 1068021312, 1067403904, 1066755008, + 1066074560, 1065362624, 1064619200, 1063844352, 1063038016, 1062200320, 1061331264, 1060430848, 1059499072, 1058536000, + 1057541696, 1056516096, 1055459328, 1054371392, 1053252288, 1052102016, 1050920704, 1049708352, 1048465024, 1047190656, + 1045885376, 1044549184, 1043182208, 1041784320, 1040355712, 1038896320, 1037406272, 1035885568, 1034334272, 1032752448, + 1031140096, 1029497216, 1027824000, 1026120384, 1024386432, 1022622272, 1020827904, 1019003328, 1017148672, 1015264000, + 1013349248, 1011404608, 1009430080, 1007425792, 1005391680, 1003327872, 1001234432, 999111424, 996958848, 994776896, + 992565568, 990324864, 988054912, 985755712, 983427456, 981070144, 978683904, 976268672, 973824576, 971351808, + 968850240, 966320128, 963761408, 961174272, 958558720, 955914816, 953242752, 950542464, 947814144, 945057728, + 942273472, 939461440, 936621504, 933753984, 930858880, 927936192, 924986176, 922008896, 919004288, 915972544, + 912913664, 909827968, 906715264, 903575808, 900409728, 897217024, 893997760, 890752128, 887480128, 884181888, + 880857600, 877507328, 874131072, 870729024, 867301184, 863847744, 860368832, 856864448, 853334848, 849779968, + 846199936, 842594944, 838965120, 835310400, 831631104, 827927168, 824198848, 820446144, 816669184, 812868096, + 809043008, 805194048, 801321216, 797424768, 793504832, 789561344, 785594560, 781604608, 777591488, 773555456, + 769496640, 765414976, 761310656, 757183936, 753034880, 748863552, 744670080, 740454592, 736217216, 731958144, + 727677376, 723375232, 719051648, 714706752, 710340864, 705953920, 701546112, 697117632, 692668544, 688198976, + 683709056, 679198976, 674668864, 670118720, 665548800, 660959296, 656350208, 651721728, 647074048, 642407168, + 637721344, 633016704, 628293376, 623551488, 618791104, 614012480, 609215744, 604400960, 599568384, 594718080, + 589850176, 584964864, 580062272, 575142528, 570205824, 565252224, 560281984, 555295168, 550291904, 545272448, + 540236864, 535185280, 530117952, 525034944, 519936384, 514822496, 509693408, 504549248, 499390144, 494216384, + 489027968, 483825056, 478607904, 473376640, 468131360, 462872224, 457599424, 452313152, 447013472, 441700608, + 436374688, 431035904, 425684352, 420320224, 414943680, 409554848, 404153984, 398741152, 393316512, 387880320, + 382432576, 376973600, 371503488, 366022368, 360530464, 355027904, 349514848, 343991456, 338457920, 332914368, + 327360992, 321797952, 316225376, 310643520, 305052416, 299452352, 293843392, 288225792, 282599680, 276965152, + 271322528, 265671856, 260013344, 254347136, 248673408, 242992352, 237304096, 231608848, 225906752, 220197984, + 214482704, 208761088, 203033328, 197299552, 191559952, 185814672, 180063936, 174307856, 168546624, 162780432, + 157009424, 151233776, 145453648, 139669232, 133880696, 128088216, 122291928, 116492040, 110688704, 104882096, + 99072408, 93259768, 87444384, 81626424, 75806048, 69983424, 64158744, 58332160, 52503856, 46674000, + 40842768, 35010324, 29176854, 23342516, 17507490, 11671948, 5836060, 0 +}; + /************************ Q30 *******************************/ const Word32 ivas_fb_fr_12band_1ms_re_fx[IVAS_FB_12_1MS_LEN] = { 1046768256, 1012312512, 944113536, 843565952, 712700800, 554033920, 370399360, 163534048, -67588040, diff --git a/lib_com/ivas_rom_com.h b/lib_com/ivas_rom_com.h index dce741b3e..c96f4e884 100644 --- a/lib_com/ivas_rom_com.h +++ b/lib_com/ivas_rom_com.h @@ -594,7 +594,9 @@ extern const Word32 ivas_han_win_32k_fx[L_FRAME32k]; extern const Word32 ivas_han_win_16k_fx[L_FRAME32k]; extern const Word32 ivas_sine_delay_32_fx[32]; -extern const Word32 ivas_sine_frame_len_640_fx[577]; + +extern const Word32 ivas_sine_frame_len_640_del_32_fx[577]; +extern const Word32 ivas_sine_frame_len_640_del_16_fx[289]; extern const Word32 ivas_fb_fr_12band_1ms_re_fx[IVAS_FB_12_1MS_LEN]; extern const Word32 ivas_fb_fr_12band_1ms_im_fx[IVAS_FB_12_1MS_LEN]; diff --git a/lib_com/ivas_spar_com.c b/lib_com/ivas_spar_com.c index 9afcffe24..2b03b5a37 100644 --- a/lib_com/ivas_spar_com.c +++ b/lib_com/ivas_spar_com.c @@ -734,6 +734,7 @@ static void ivas_get_pred_coeffs_fx( Word16 dm_alpha_e, den_f_e, s_dm_f; prev_tmp_shift = 31; dm_alpha_e = 0; + Word16 dm_beta_re_e=0; IF( EQ_16( dyn_active_w_flag, 1 ) ) { @@ -842,6 +843,7 @@ static void ivas_get_pred_coeffs_fx( dm_beta_re = L_add( dm_beta_re, re ); // Q = 2*tmp_shift - 3 - 31 } + dm_beta_re_e = 31-(2 * tmp_shift - 3 - 31); dm_w = cov_real[0][0][b]; // Q30 den_f = L_max( dm_w, 1 ); passive_g = L_deposit_l( BASOP_Util_Divide3232_Scale( dm_alpha[b], den_f, &s_div ) ); @@ -911,15 +913,17 @@ static void ivas_get_pred_coeffs_fx( { Word32 sqrt_val; Word16 val_e; + Word16 num_f_e; /* quadratic activeW */ - num_f = L_sub( dm_beta_re, L_shl( Mpy_32_32( dm_alpha[b], activew_quad_thresh ), 1 ) ); + num_f = BASOP_Util_Add_Mant32Exp( dm_beta_re, dm_beta_re_e, L_negate(L_shl( Mpy_32_32( dm_alpha[b], activew_quad_thresh ), 1 )), add(dm_alpha_e,(31-Q29)),&num_f_e); - sqrt_val = L_shl( Mpy_32_32( Mpy_32_32( dm_alpha[b], dm_alpha[b] ), g_th_sq ), 2 ); - sqrt_val = L_add( sqrt_val, Mpy_32_32( dm_beta_re, dm_beta_re ) ); - sqrt_val = L_sub( sqrt_val, L_shl( Mpy_32_32( Mpy_32_32( dm_beta_re, g_th_sq ), dm_w ), 2 ) ); - val_e = norm_l( sqrt_val ); + sqrt_val = L_shl( Mpy_32_32( Mpy_32_32( dm_alpha[b], dm_alpha[b] ), g_th_sq ), 2 );/*Q27*/ + val_e = 4; + sqrt_val = BASOP_Util_Add_Mant32Exp( sqrt_val,4, Mpy_32_32( dm_beta_re, dm_beta_re ),2* dm_beta_re_e,&val_e); + sqrt_val = BASOP_Util_Add_Mant32Exp( sqrt_val, val_e, L_negate(L_shl( Mpy_32_32( Mpy_32_32( dm_beta_re, g_th_sq ), dm_w ), 2 )), add(dm_beta_re_e,4+1),&val_e); + //val_e = norm_l( sqrt_val ); sqrt_val = Sqrt32( sqrt_val, &val_e ); IF( LT_16( val_e, 0 ) ) { @@ -930,13 +934,15 @@ static void ivas_get_pred_coeffs_fx( sqrt_val = L_shl( sqrt_val, abs_s( val_e ) ); val_e = 0; } - num_f = L_add( num_f, sqrt_val ); + num_f = BASOP_Util_Add_Mant32Exp( num_f, num_f_e, sqrt_val,0,&num_f_e); den_f = L_shl( Mpy_32_32( dm_beta_re, g_th_sq ), 1 ); + den_f_e = add( dm_beta_re_e , 4 ); den_f = L_max( den_f, 1 ); dm_g[b] = activew_quad_thresh; // Q29 DM_F[b] = BASOP_Util_Divide3232_Scale_cadence( Mpy_32_32( dm_g[b], num_f ), den_f, &s_dm_f ); - div_shift = sub( s_dm_f, 2 ); + s_dm_f =add(s_dm_f,sub(add( 2 , num_f_e ) , den_f_e));/*Resultant exp for DM_F s_dm_f +( 2 + num_f_e ) - den_f_e*/ + div_shift = sub(s_dm_f, 1); DM_F[b] = L_shl( DM_F[b], div_shift ); // Q30 } } diff --git a/lib_com/prot_fx2.h b/lib_com/prot_fx2.h index 8c897e5a9..78e7ae597 100644 --- a/lib_com/prot_fx2.h +++ b/lib_com/prot_fx2.h @@ -4125,6 +4125,8 @@ Word16 L_norm_arr( Word32 *arr, Word16 size ); Word16 get_min_scalefactor( Word32 x, Word32 y ); +Flag is_zero_arr( Word32 *arr, Word16 size ); + void edct2_fx_ivas( const Word16 n, const Word16 isgn, diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index aa9ebf964..04e80efe2 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -5038,36 +5038,36 @@ void ivas_dirac_dec_render_sf_fx( } IF( st_ivas->hMasa == NULL && EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) { - fixedToFloat_arrL32( hDirACRend->h_output_synthesis_psd_state.direct_responses_fx, hDirACRend->h_output_synthesis_psd_state.direct_responses, hDirACRend->h_output_synthesis_psd_state.direct_responses_q, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir ) ); + /*fixedToFloat_arrL32( hDirACRend->h_output_synthesis_psd_state.direct_responses_fx, hDirACRend->h_output_synthesis_psd_state.direct_responses, hDirACRend->h_output_synthesis_psd_state.direct_responses_q, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir ) ); IF( hodirac_flag ) { fixedToFloat_arrL32( &hDirACRend->h_output_synthesis_psd_state.direct_responses_fx[i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir )], &hDirACRend->h_output_synthesis_psd_state.direct_responses[i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir )], hDirACRend->h_output_synthesis_psd_state.direct_responses_q, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir ) ); - } + }*/ } ELSE { - fixedToFloat_arrL32( hDirACRend->h_output_synthesis_psd_state.direct_responses_fx, hDirACRend->h_output_synthesis_psd_state.direct_responses, hDirACRend->h_output_synthesis_psd_state.direct_responses_q, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir ) ); + /*fixedToFloat_arrL32( hDirACRend->h_output_synthesis_psd_state.direct_responses_fx, hDirACRend->h_output_synthesis_psd_state.direct_responses, hDirACRend->h_output_synthesis_psd_state.direct_responses_q, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir ) ); IF( hDirACRend->synthesisConf != DIRAC_SYNTHESIS_GAIN_SHD ) { fixedToFloat_arrL32( hDirACRend->h_output_synthesis_psd_state.direct_responses_square_fx, hDirACRend->h_output_synthesis_psd_state.direct_responses_square, hDirACRend->h_output_synthesis_psd_state.direct_responses_square_q, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir ) ); - } + }*/ } IF( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) { - IF( nchan_transport >= 4 ) + /*IF( nchan_transport >= 4 ) { fixedToFloat_arrL32( reference_power_fx, DirAC_mem.reference_power, DirAC_mem.reference_power_q, 5 * hSpatParamRendCom->num_freq_bands ); - } - fixedToFloat_arrL32( hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_fx, hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f, hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, 2 * nchan_transport * hSpatParamRendCom->num_freq_bands * hSpatParamRendCom->subframe_nbslots[subframe_idx] ); - fixedToFloat_arrL32( hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_fx, hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f, hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_q, 2 * hDirACRend->num_outputs_diff * hSpatParamRendCom->num_freq_bands * hSpatParamRendCom->subframe_nbslots[subframe_idx] ); + }*/ + // fixedToFloat_arrL32( hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_fx, hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f, hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, 2 * nchan_transport * hSpatParamRendCom->num_freq_bands * hSpatParamRendCom->subframe_nbslots[subframe_idx] ); + // fixedToFloat_arrL32( hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_fx, hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f, hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_q, 2 * hDirACRend->num_outputs_diff * hSpatParamRendCom->num_freq_bands * hSpatParamRendCom->subframe_nbslots[subframe_idx] ); } ELSE IF( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_MONO ) ) { - fixedToFloat_arrL32( hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_fx, hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f, hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, i_mult( hSpatParamRendCom->subframe_nbslots[subframe_idx], i_mult( 4, hSpatParamRendCom->num_freq_bands ) ) ); + // fixedToFloat_arrL32( hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_fx, hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f, hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, i_mult( hSpatParamRendCom->subframe_nbslots[subframe_idx], i_mult( 4, hSpatParamRendCom->num_freq_bands ) ) ); fixedToFloat_arrL32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, i_mult( 2, hSpatParamRendCom->num_freq_bands ) ); fixedToFloat_arrL32( hDirACRend->proto_frame_f_fx, hDirACRend->proto_frame_f, hDirACRend->proto_frame_f_q, i_mult( 6, hSpatParamRendCom->num_freq_bands ) ); - fixedToFloat_arrL32( reference_power_fx, DirAC_mem.reference_power, DirAC_mem.reference_power_q, hSpatParamRendCom->num_freq_bands ); + // fixedToFloat_arrL32( reference_power_fx, DirAC_mem.reference_power, DirAC_mem.reference_power_q, hSpatParamRendCom->num_freq_bands ); } ELSE { @@ -5077,30 +5077,30 @@ void ivas_dirac_dec_render_sf_fx( case 8: case 6: case 4: - fixedToFloat_arrL32( hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_fx, hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f, hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, i_mult( i_mult( 2, hSpatParamRendCom->subframe_nbslots[subframe_idx] ), i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_diff ) ) ); + // fixedToFloat_arrL32( hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_fx, hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f, hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, i_mult( i_mult( 2, hSpatParamRendCom->subframe_nbslots[subframe_idx] ), i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_diff ) ) ); fixedToFloat_arrL32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_diff ) ); me2f_buf( hDirACRend->proto_frame_f_fx, hDirACRend->proto_frame_f_q, hDirACRend->proto_frame_f, i_mult( 2, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_diff ) ) ); - fixedToFloat_arrL32( reference_power_fx, DirAC_mem.reference_power, DirAC_mem.reference_power_q, hSpatParamRendCom->num_freq_bands ); + // fixedToFloat_arrL32( reference_power_fx, DirAC_mem.reference_power, DirAC_mem.reference_power_q, hSpatParamRendCom->num_freq_bands ); BREAK; case 2: IF( hDirACRend->hOutSetup.is_loudspeaker_setup ) { - fixedToFloat_arrL32( hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_fx, hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f, hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, i_mult( hSpatParamRendCom->subframe_nbslots[subframe_idx], i_mult( 6, hSpatParamRendCom->num_freq_bands ) ) ); + // fixedToFloat_arrL32( hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_fx, hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f, hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, i_mult( hSpatParamRendCom->subframe_nbslots[subframe_idx], i_mult( 6, hSpatParamRendCom->num_freq_bands ) ) ); fixedToFloat_arrL32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, i_mult( 3, hSpatParamRendCom->num_freq_bands ) ); } ELSE { - fixedToFloat_arrL32( hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_fx, hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f, hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, i_mult( hSpatParamRendCom->subframe_nbslots[subframe_idx], i_mult( 4, hSpatParamRendCom->num_freq_bands ) ) ); + // fixedToFloat_arrL32( hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_fx, hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f, hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, i_mult( hSpatParamRendCom->subframe_nbslots[subframe_idx], i_mult( 4, hSpatParamRendCom->num_freq_bands ) ) ); fixedToFloat_arrL32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, i_mult( 2, hSpatParamRendCom->num_freq_bands ) ); } me2f_buf( hDirACRend->proto_frame_f_fx, hDirACRend->proto_frame_f_q, hDirACRend->proto_frame_f, i_mult( 6, hSpatParamRendCom->num_freq_bands ) ); - fixedToFloat_arrL32( reference_power_fx, DirAC_mem.reference_power, DirAC_mem.reference_power_q, hSpatParamRendCom->num_freq_bands ); + // fixedToFloat_arrL32( reference_power_fx, DirAC_mem.reference_power, DirAC_mem.reference_power_q, hSpatParamRendCom->num_freq_bands ); BREAK; case 1: - fixedToFloat_arrL32( hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_fx, hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f, hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, i_mult( hSpatParamRendCom->subframe_nbslots[subframe_idx], i_mult( 2, hSpatParamRendCom->num_freq_bands ) ) ); + // fixedToFloat_arrL32( hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_fx, hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f, hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, i_mult( hSpatParamRendCom->subframe_nbslots[subframe_idx], i_mult( 2, hSpatParamRendCom->num_freq_bands ) ) ); fixedToFloat_arrL32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, hSpatParamRendCom->num_freq_bands ); me2f_buf( hDirACRend->proto_frame_f_fx, hDirACRend->proto_frame_f_q, hDirACRend->proto_frame_f, i_mult( 2, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_protos_diff ) ) ); - fixedToFloat_arrL32( reference_power_fx, DirAC_mem.reference_power, DirAC_mem.reference_power_q, hSpatParamRendCom->num_freq_bands ); + // fixedToFloat_arrL32( reference_power_fx, DirAC_mem.reference_power, DirAC_mem.reference_power_q, hSpatParamRendCom->num_freq_bands ); BREAK; } } @@ -5112,9 +5112,9 @@ void ivas_dirac_dec_render_sf_fx( } ELSE { - me2f_buf( DirAC_mem.frame_dec_f_fx, 31 - DirAC_mem.frame_dec_f_q, DirAC_mem.frame_dec_f, DirAC_mem.frame_dec_f_len ); + /* me2f_buf( DirAC_mem.frame_dec_f_fx, 31 - DirAC_mem.frame_dec_f_q, DirAC_mem.frame_dec_f, DirAC_mem.frame_dec_f_len ); - hDirACRend->proto_frame_dec_f = DirAC_mem.frame_dec_f; + hDirACRend->proto_frame_dec_f = DirAC_mem.frame_dec_f;*/ } } ELSE @@ -5136,10 +5136,10 @@ void ivas_dirac_dec_render_sf_fx( 31 - state->proto_power_diff_smooth_q, state->proto_power_diff_smooth, state->proto_power_diff_smooth_len ); - me2f_buf( state->proto_diffuse_buffer_f_fx, - 31 - state->proto_diffuse_buffer_f_q, - state->proto_diffuse_buffer_f, - state->proto_diffuse_buffer_f_len ); + /* me2f_buf( state->proto_diffuse_buffer_f_fx, + 31 - state->proto_diffuse_buffer_f_q, + state->proto_diffuse_buffer_f, + state->proto_diffuse_buffer_f_len );*/ } } diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index f263e210f..42503f11d 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -4411,19 +4411,7 @@ void ivas_initialize_handles_dec( /* ISM metadata handles */ - ivas_ism_metadata_close( st_ivas->hIsmMetaData, 0 ); - - /* ISM renderer handle */ - ivas_ism_renderer_close( &( st_ivas->hIsmRendererData ) ); - - /* DirAC handle */ - if ( st_ivas->ivas_format == ISM_FORMAT ) - { - ivas_param_ism_dec_close( &( st_ivas->hParamIsmDec ), &( st_ivas->hSpatParamRendCom ), st_ivas->hDecoderConfig->output_config ); - } - ELSE - - for ( i = 0; i < MAX_NUM_OBJECTS; i++ ) + for ( i = 0; i < MAX_NUM_OBJECTS; i++ ) { st_ivas->hIsmMetaData[i] = NULL; } @@ -5585,4 +5573,4 @@ static ivas_error doSanityChecks_IVAS( return IVAS_ERR_OK; } -#endif +#endif \ No newline at end of file diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index d3021e92a..88692037e 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -4547,19 +4547,7 @@ ivas_error ivas_jbm_dec_flush_renderer( DECODER_TC_BUFFER_HANDLE hTcBuffer; float output[MAX_CICP_CHANNELS][L_FRAME48k / MAX_PARAM_SPATIAL_SUBFRAMES]; float *p_output[MAX_CICP_CHANNELS]; -#ifdef IVAS_FLOAT_FIXED - Word32 output_fx[MAX_CICP_CHANNELS][L_FRAME48k / MAX_PARAM_SPATIAL_SUBFRAMES]; - Word32 *p_output_fx[MAX_CICP_CHANNELS]; - Word32 tmp_buffer_fx[MAX_OUTPUT_CHANNELS][L_FRAME48k] = { 0 }; - Word32 *p_temp_fx[MAX_OUTPUT_CHANNELS]; - Word16 subframe_len, gd_bits, exp, nchan_in, i, j, nchan_out; -#endif -#ifdef IVAS_FLOAT_FIXED - for ( i = 0; i < MAX_OUTPUT_CHANNELS; i++ ) - { - p_temp_fx[i] = tmp_buffer_fx[i]; - } -#endif + if ( !st_ivas->hDecoderConfig->Opt_tsm ) { return IVAS_ERR_OK; @@ -4610,9 +4598,6 @@ ivas_error ivas_jbm_dec_flush_renderer( for ( ch_idx = 0; ch_idx < MAX_CICP_CHANNELS; ch_idx++ ) { p_output[ch_idx] = output[ch_idx]; -#ifdef IVAS_FLOAT_FIXED - p_output_fx[ch_idx] = output_fx[ch_idx]; -#endif } if ( st_ivas->ivas_format == ISM_FORMAT ) @@ -4630,101 +4615,15 @@ ivas_error ivas_jbm_dec_flush_renderer( else if ( renderer_type_old == RENDERER_BINAURAL_MIXER_CONV_ROOM ) { /* Convert to CICPxx; used also for ISM->CICP19->binaural_room rendering */ -#ifdef IVAS_FLOAT_FIXED - set16_fx( st_ivas->hIsmRendererData->interpolator_fx, MAX16B, hTcBuffer->n_samples_granularity ); -#else set_f( st_ivas->hIsmRendererData->interpolator, 1.0f, hTcBuffer->n_samples_granularity ); -#endif -#ifdef IVAS_FLOAT_FIXED - Word16 q = 15; - FOR( Word16 ind1 = 0; ind1 < s_max( st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe, s_max( st_ivas->nchan_transport, st_ivas->nchan_ism ) ); ind1++ ) - { - FOR( Word16 ind2 = 0; ind2 < *nSamplesRendered; ind2++ ) - { - p_output_fx[ind1][ind2] = (Word16) ( p_output[ind1][ind2] * ( 1 << q ) ); - } - IF( st_ivas->hTcBuffer->tc ) - FOR( Word16 ind2 = 0; ind2 < *nSamplesRendered; ind2++ ) - { - st_ivas->hTcBuffer->tc_fx[ind1][ind2] = (Word32) ( st_ivas->hTcBuffer->tc[ind1][ind2] * ( 1 << q ) ); - } - } - - FOR( Word16 ind1 = 0; ind1 < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; ind1++ ) - { - FOR( Word16 ind2 = 0; ind2 < *nSamplesRendered; ind2++ ) - { - } - } - FOR( Word16 ind1 = 0; ind1 < MAX_NUM_OBJECTS; ind1++ ) - { - st_ivas->hIsmMetaData[ind1]->azimuth_fx = (Word32) ( st_ivas->hIsmMetaData[ind1]->azimuth * ( 1 << 22 ) ); - st_ivas->hIsmMetaData[ind1]->elevation_fx = (Word32) ( st_ivas->hIsmMetaData[ind1]->elevation * ( 1 << 22 ) ); - } - IF( st_ivas->hCombinedOrientationData ) - FOR( Word16 ind1 = 0; ind1 < 3; ind1++ ) - { - FOR( Word16 ind2 = 0; ind2 < 3; ind2++ ) - { - st_ivas->hCombinedOrientationData->Rmat_fx[0][ind1][ind2] = (Word32) ( st_ivas->hCombinedOrientationData->Rmat[0][ind1][ind2] * ( 1 << 15 ) ); - } - } - - ivas_ism_render_sf_fx( st_ivas, p_output_fx, *nSamplesRendered ); - FOR( Word16 ind1 = 0; ind1 < s_max( st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe, s_max( st_ivas->nchan_transport, st_ivas->nchan_ism ) ); ind1++ ) - { - FOR( Word16 ind2 = 0; ind2 < *nSamplesRendered; ind2++ ) - { - p_output[ind1][ind2] = (float) ( p_output_fx[ind1][ind2] ) / (float) ( 1 << q ); - } - } - FOR( Word16 ind1 = 0; ind1 < MAX_NUM_OBJECTS; ind1++ ) - { - st_ivas->hIsmMetaData[ind1]->azimuth = (float) ( st_ivas->hIsmMetaData[ind1]->azimuth_fx ) / (float) ( 1 << 22 ); - st_ivas->hIsmMetaData[ind1]->elevation = (float) ( st_ivas->hIsmMetaData[ind1]->elevation_fx ) / (float) ( 1 << 22 ); - } - -#else ivas_ism_render_sf( st_ivas, p_output, hTcBuffer->n_samples_granularity ); -#endif -#ifdef IVAS_FLOAT_FIXED - st_ivas->hCrendWrapper->p_io_qfactor = &st_ivas->hCrendWrapper->io_qfactor; - subframe_len = st_ivas->hTcBuffer->subframe_nbslots[0] * st_ivas->hTcBuffer->n_samples_granularity; - gd_bits = find_guarded_bits_fx( subframe_len ); - exp = 13; - nchan_in = 12; - nchan_out = 2; - exp -= gd_bits; - *st_ivas->hCrendWrapper->p_io_qfactor = exp; - for ( i = 0; i < nchan_in; i++ ) - { - for ( j = 0; j < hTcBuffer->n_samples_granularity; j++ ) - { - p_temp_fx[i][j] = (Word32) float_to_fixed( p_output[i][j], *st_ivas->hCrendWrapper->p_io_qfactor ); - } - } - if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, IVAS_AUDIO_CONFIG_7_1_4, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR, st_ivas->hDecoderConfig, NULL, - NULL, NULL, st_ivas->hTcBuffer, p_temp_fx, p_temp_fx, hTcBuffer->n_samples_granularity, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) - { - return error; - } - for ( i = 0; i < nchan_out; i++ ) - { - for ( j = 0; j < hTcBuffer->n_samples_granularity; j++ ) - { - - p_output[i][j] = fixed_to_float( p_temp_fx[i][j], *st_ivas->hCrendWrapper->p_io_qfactor ); - } - } -#else if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, IVAS_AUDIO_CONFIG_7_1_4, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR, st_ivas->hDecoderConfig, NULL, NULL, NULL, st_ivas->hTcBuffer, p_output, p_output, hTcBuffer->n_samples_granularity, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) { return error; } -#endif } } else @@ -4738,53 +4637,13 @@ ivas_error ivas_jbm_dec_flush_renderer( { if ( renderer_type_old == RENDERER_BINAURAL_MIXER_CONV || renderer_type_old == RENDERER_BINAURAL_MIXER_CONV_ROOM ) { -#ifdef IVAS_FLOAT_FIXED - st_ivas->hCrendWrapper->p_io_qfactor = &st_ivas->hCrendWrapper->io_qfactor; - subframe_len = st_ivas->hTcBuffer->subframe_nbslots[0] * st_ivas->hTcBuffer->n_samples_granularity; - gd_bits = find_guarded_bits_fx( subframe_len ); - exp = 13; - if ( ( error = getAudioConfigNumChannels( intern_config_old, &nchan_in ) ) != IVAS_ERR_OK ) - { - return error; - } - if ( ( error = getAudioConfigNumChannels( st_ivas->hOutSetup.output_config, &nchan_out ) ) != IVAS_ERR_OK ) - { - return error; - } - exp -= gd_bits; - *st_ivas->hCrendWrapper->p_io_qfactor = exp; - for ( i = 0; i < nchan_in; i++ ) - { - for ( j = 0; j < hTcBuffer->n_samples_granularity; j++ ) - { - - hTcBuffer->tc_fx[i][j] = (Word32) float_to_fixed( hTcBuffer->tc[i][j], *st_ivas->hCrendWrapper->p_io_qfactor ); - } - } - if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, intern_config_old, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, st_ivas->hCombinedOrientationData, - hIntSetupOld, st_ivas->hEFAPdata, st_ivas->hTcBuffer, hTcBuffer->tc_fx, p_output_fx, hTcBuffer->n_samples_granularity, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) - { - return error; - } - - ivas_binaural_add_LFE_fx( st_ivas, hTcBuffer->n_samples_granularity, st_ivas->hTcBuffer->tc_fx, p_output_fx ); - - for ( i = 0; i < nchan_in; i++ ) - { - for ( j = 0; j < *nSamplesRendered; j++ ) - { - // p_output[i][j] = fixed_to_float(p_output_fx[i][j], *st_ivas->hCrendWrapper->p_io_qfactor); - st_ivas->hTcBuffer->tc[i][j] = fixed_to_float( st_ivas->hTcBuffer->tc_fx[i][j], *st_ivas->hCrendWrapper->p_io_qfactor ); - } - } -#else if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, intern_config_old, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, st_ivas->hCombinedOrientationData, hIntSetupOld, st_ivas->hEFAPdata, st_ivas->hTcBuffer, hTcBuffer->tc, p_output, hTcBuffer->n_samples_granularity, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) { return error; } + ivas_binaural_add_LFE( st_ivas, hTcBuffer->n_samples_granularity, st_ivas->hTcBuffer->tc, p_output ); -#endif } else if ( st_ivas->renderer_type == RENDERER_BINAURAL_OBJECTS_TD ) { @@ -4793,29 +4652,7 @@ ivas_error ivas_jbm_dec_flush_renderer( return error; } -#ifdef IVAS_FLOAT_FIXED - Word16 q = Q16; - q = q - find_guarded_bits_fx( *nSamplesRendered ); - FOR( i = 0; i < st_ivas->nchan_transport; ++i ) - { - // p_tc and pout point to same location - floatToFixed_arrL( st_ivas->hTcBuffer->tc[i], st_ivas->hTcBuffer->tc_fx[i], q, *nSamplesRendered ); - p_output_fx[i] = malloc( L_FRAME48k * sizeof( Word32 ) ); - floatToFixed_arrL( p_output[i], p_output_fx[i], q, *nSamplesRendered ); - } - - ivas_binaural_add_LFE_fx( st_ivas, *nSamplesRendered, st_ivas->hTcBuffer->tc_fx, p_output_fx ); - - FOR( i = 0; i < st_ivas->nchan_transport; ++i ) - { - // p_tc and pout point to same location only need to do for 2 channels can be cleaned up later - fixedToFloat_arrL( st_ivas->hTcBuffer->tc_fx[i], st_ivas->hTcBuffer->tc[i], q, *nSamplesRendered ); - fixedToFloat_arrL( p_output_fx[i], p_output[i], q, *nSamplesRendered ); - free( p_output_fx[i] ); - } -#else - ivas_binaural_add_LFE( st_ivas, *nSamplesRendered, st_ivas->hTcBuffer->tc, p_output ); -#endif + ivas_binaural_add_LFE( st_ivas, hTcBuffer->n_samples_granularity, st_ivas->hTcBuffer->tc, p_output ); } } else @@ -4910,39 +4747,7 @@ ivas_error ivas_jbm_dec_flush_renderer( if ( st_ivas->ivas_format != MONO_FORMAT ) { #ifndef DISABLE_LIMITER -#ifdef IVAS_FLOAT_FIXED - Word16 ch_idx; - exp = 16; - for ( ch_idx = 0; ch_idx < MAX_CICP_CHANNELS; ch_idx++ ) - { - - p_output_fx[ch_idx] = output_fx[ch_idx]; - } - for ( ch_idx = 0; ch_idx < st_ivas->hDecoderConfig->nchan_out; ch_idx++ ) - { - exp = s_min( exp, Q_factor_arrL( p_output[ch_idx], *nSamplesRendered ) ); - } - exp -= 1; - for ( ch_idx = 0; ch_idx < st_ivas->hDecoderConfig->nchan_out; ch_idx++ ) - { - for ( j = 0; j < *nSamplesRendered; j++ ) - { - p_output_fx[ch_idx][j] = (Word32) ( p_output[ch_idx][j] * ( 1 << exp ) ); - } - } - ivas_limiter_dec_fx( st_ivas->hLimiter, p_output_fx, st_ivas->hDecoderConfig->nchan_out, *nSamplesRendered, st_ivas->BER_detect, exp ); - for ( ch_idx = 0; ch_idx < st_ivas->hDecoderConfig->nchan_out; ch_idx++ ) - { - for ( j = 0; j < *nSamplesRendered; j++ ) - { - p_output[ch_idx][j] = ( (float) p_output_fx[ch_idx][j] / ( 1 << exp ) ); - } - } -#else - ivas_limiter_dec( st_ivas->hLimiter, p_output, st_ivas->hDecoderConfig->nchan_out, *nSamplesRendered, st_ivas->BER_detect ); - -#endif #endif } } @@ -5890,6 +5695,7 @@ Word16 ivas_jbm_dec_get_render_granularity( * open and initialize JBM transport channel buffer *--------------------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED ivas_error ivas_jbm_dec_tc_buffer_open( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const TC_BUFFER_MODE tc_buffer_mode, /* i : buffer mode */ @@ -5936,14 +5742,12 @@ ivas_error ivas_jbm_dec_tc_buffer_open( if ( hTcBuffer->tc_buffer_mode == TC_BUFFER_MODE_NONE ) { -#ifdef IVAS_FLOAT_FIXED - hTcBuffer->tc_buffer_fx = NULL; + hTcBuffer->tc_buffer = NULL; - FOR( ch_idx = 0; ch_idx < MAX_TRANSPORT_CHANNELS + MAX_NUM_OBJECTS; ch_idx++ ) + for ( ch_idx = 0; ch_idx < MAX_TRANSPORT_CHANNELS + MAX_NUM_OBJECTS; ch_idx++ ) { - hTcBuffer->tc_fx[ch_idx] = NULL; + hTcBuffer->tc[ch_idx] = NULL; } -#endif } else { @@ -5965,64 +5769,42 @@ ivas_error ivas_jbm_dec_tc_buffer_open( if ( nsamp_to_allocate == 0 ) { -#ifdef IVAS_FLOAT_FIXED - hTcBuffer->tc_buffer_fx = NULL; - - FOR( ch_idx = 0; ch_idx < MAX_TRANSPORT_CHANNELS + MAX_NUM_OBJECTS; ch_idx++ ) - { - hTcBuffer->tc_fx[ch_idx] = NULL; - } -#endif - // hTcBuffer->tc_buffer = NULL; + hTcBuffer->tc_buffer = NULL; for ( ch_idx = 0; ch_idx < MAX_TRANSPORT_CHANNELS + MAX_NUM_OBJECTS; ch_idx++ ) { - // hTcBuffer->tc[ch_idx] = NULL; + hTcBuffer->tc[ch_idx] = NULL; } } else { if ( st_ivas->hDecoderConfig->Opt_tsm ) { -#ifdef IVAS_FLOAT_FIXED - hTcBuffer->tc_buff_len = nsamp_to_allocate; - IF( ( hTcBuffer->tc_buffer_fx = (Word32 *) malloc( nsamp_to_allocate * sizeof( Word32 ) ) ) == NULL ) + if ( ( hTcBuffer->tc_buffer = (float *) malloc( nsamp_to_allocate * sizeof( float ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for JBM TC Buffer\n" ) ); } - set32_fx( hTcBuffer->tc_buffer_fx, 0, nsamp_to_allocate ); -#endif + set_zero( hTcBuffer->tc_buffer, nsamp_to_allocate ); offset = 0; for ( ch_idx = 0; ch_idx < hTcBuffer->nchan_buffer_full; ch_idx++ ) { -#ifdef IVAS_FLOAT_FIXED - hTcBuffer->tc_fx[ch_idx] = &hTcBuffer->tc_buffer_fx[offset]; -#endif + hTcBuffer->tc[ch_idx] = &hTcBuffer->tc_buffer[offset]; offset += n_samp_full; } for ( ; ch_idx < hTcBuffer->nchan_transport_internal; ch_idx++ ) { -#ifdef IVAS_FLOAT_FIXED - hTcBuffer->tc_fx[ch_idx] = &hTcBuffer->tc_buffer_fx[offset]; -#endif + hTcBuffer->tc[ch_idx] = &hTcBuffer->tc_buffer[offset]; offset += n_samp_residual; } for ( ; ch_idx < MAX_TRANSPORT_CHANNELS + MAX_NUM_OBJECTS; ch_idx++ ) { -#ifdef IVAS_FLOAT_FIXED - hTcBuffer->tc_fx[ch_idx] = NULL; -#endif + hTcBuffer->tc[ch_idx] = NULL; } -#ifdef MSAN_FIX - st_ivas->hTcBuffer->no_channels = hTcBuffer->nchan_transport_internal; -#endif // MSAN_FIX } else { -#ifdef IVAS_FLOAT_FIXED - hTcBuffer->tc_buffer_fx = NULL; -#endif + hTcBuffer->tc_buffer = NULL; } } } @@ -6031,6 +5813,8 @@ ivas_error ivas_jbm_dec_tc_buffer_open( return IVAS_ERR_OK; } +#endif + #ifdef IVAS_FLOAT_FIXED ivas_error ivas_jbm_dec_tc_buffer_open_fx( @@ -6185,6 +5969,7 @@ ivas_error ivas_jbm_dec_tc_buffer_open_fx( * open and initialize JBM transport channel buffer *--------------------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED ivas_error ivas_jbm_dec_tc_buffer_reconfigure( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const TC_BUFFER_MODE tc_buffer_mode, /* i : new buffer mode */ @@ -6227,13 +6012,11 @@ ivas_error ivas_jbm_dec_tc_buffer_reconfigure( hTcBuffer->n_samples_granularity = n_samples_granularity; /* realloc buffers */ -#ifdef IVAS_FLOAT_FIXED - IF( ( hTcBuffer )->tc_buffer_fx != NULL ) + if ( hTcBuffer->tc_buffer != NULL ) { - free( ( hTcBuffer )->tc_buffer_fx ); - ( hTcBuffer )->tc_buffer_fx = NULL; + free( hTcBuffer->tc_buffer ); + hTcBuffer->tc_buffer = NULL; } -#endif if ( st_ivas->hDecoderConfig->Opt_tsm ) { @@ -6250,60 +6033,47 @@ ivas_error ivas_jbm_dec_tc_buffer_reconfigure( if ( nsamp_to_allocate == 0 ) { -#ifdef IVAS_FLOAT_FIXED - hTcBuffer->tc_buffer_fx = NULL; - FOR( ch_idx = 0; ch_idx < MAX_TRANSPORT_CHANNELS + MAX_NUM_OBJECTS; ch_idx++ ) + hTcBuffer->tc_buffer = NULL; + for ( ch_idx = 0; ch_idx < MAX_TRANSPORT_CHANNELS + MAX_NUM_OBJECTS; ch_idx++ ) { - hTcBuffer->tc_fx[ch_idx] = NULL; + hTcBuffer->tc[ch_idx] = NULL; } -#endif } else { if ( st_ivas->hDecoderConfig->Opt_tsm ) { -#ifdef IVAS_FLOAT_FIXED - hTcBuffer->tc_buff_len = nsamp_to_allocate; - if ( ( hTcBuffer->tc_buffer_fx = (Word32 *) malloc( nsamp_to_allocate * sizeof( Word32 ) ) ) == NULL ) + if ( ( hTcBuffer->tc_buffer = (float *) malloc( nsamp_to_allocate * sizeof( float ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for JBM TC Buffer\n" ) ); } - set32_fx( hTcBuffer->tc_buffer_fx, 0, nsamp_to_allocate ); -#endif + set_zero( hTcBuffer->tc_buffer, nsamp_to_allocate ); offset = 0; for ( ch_idx = 0; ch_idx < hTcBuffer->nchan_buffer_full; ch_idx++ ) { -#ifdef IVAS_FLOAT_FIXED - hTcBuffer->tc_fx[ch_idx] = &hTcBuffer->tc_buffer_fx[offset]; -#endif + hTcBuffer->tc[ch_idx] = &hTcBuffer->tc_buffer[offset]; offset += n_samp_full; } for ( ; ch_idx < hTcBuffer->nchan_transport_internal; ch_idx++ ) { -#ifdef IVAS_FLOAT_FIXED - hTcBuffer->tc_fx[ch_idx] = &hTcBuffer->tc_buffer_fx[offset]; -#endif + hTcBuffer->tc[ch_idx] = &hTcBuffer->tc_buffer[offset]; offset += n_samp_residual; } for ( ; ch_idx < MAX_TRANSPORT_CHANNELS + MAX_NUM_OBJECTS; ch_idx++ ) { -#ifdef IVAS_FLOAT_FIXED - hTcBuffer->tc_fx[ch_idx] = NULL; -#endif + hTcBuffer->tc[ch_idx] = NULL; } } else { - // hTcBuffer->tc_buffer = NULL; -#ifdef IVAS_FLOAT_FIXED - hTcBuffer->tc_buffer_fx = NULL; -#endif + hTcBuffer->tc_buffer = NULL; } } return IVAS_ERR_OK; } +#endif #ifdef IVAS_FLOAT_FIXED ivas_error ivas_jbm_dec_tc_buffer_reconfigure_fx( @@ -6534,32 +6304,25 @@ static void ivas_jbm_dec_tc_buffer_playout_fx( * Close JBM transport channel buffer *--------------------------------------------------------------------------*/ +#ifdef IVAS_FLOAT_FIXED void ivas_jbm_dec_tc_buffer_close( DECODER_TC_BUFFER_HANDLE *phTcBuffer /* i/o: TC buffer handle */ ) { - int16_t i; + Word16 i; - if ( *phTcBuffer != NULL ) + IF( *phTcBuffer != NULL ) { - for ( i = 0; i < MAX_TRANSPORT_CHANNELS + MAX_NUM_OBJECTS; i++ ) - { - //( *phTcBuffer )->tc[i] = NULL; - } - - // if ( ( *phTcBuffer )->tc_buffer != NULL ) + FOR( i = 0; i < MAX_TRANSPORT_CHANNELS + MAX_NUM_OBJECTS; i++ ) { - // free( ( *phTcBuffer )->tc_buffer ); - //( *phTcBuffer )->tc_buffer = NULL; + ( *phTcBuffer )->tc_fx[i] = NULL; } -#ifdef IVAS_FLOAT_FIXED IF( ( *phTcBuffer )->tc_buffer_fx != NULL ) { free( ( *phTcBuffer )->tc_buffer_fx ); ( *phTcBuffer )->tc_buffer_fx = NULL; } -#endif free( *phTcBuffer ); *phTcBuffer = NULL; @@ -6567,7 +6330,34 @@ void ivas_jbm_dec_tc_buffer_close( return; } +#else +void ivas_jbm_dec_tc_buffer_close( + DECODER_TC_BUFFER_HANDLE *phTcBuffer /* i/o: TC buffer handle */ +) +{ + int16_t i; + if ( *phTcBuffer != NULL ) + { + for ( i = 0; i < MAX_TRANSPORT_CHANNELS + MAX_NUM_OBJECTS; i++ ) + { + ( *phTcBuffer )->tc[i] = NULL; + } + + if ( ( *phTcBuffer )->tc_buffer != NULL ) + { + free( ( *phTcBuffer )->tc_buffer ); + ( *phTcBuffer )->tc_buffer = NULL; + } + + free( *phTcBuffer ); + *phTcBuffer = NULL; + } + + return; +} + +#endif /*--------------------------------------------------------------------------* * ivas_jbm_dec_td_renderers_adapt_subframes() @@ -6874,6 +6664,7 @@ TC_BUFFER_MODE ivas_jbm_dec_get_tc_buffer_mode( * *--------------------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED void ivas_jbm_dec_copy_tc_no_tsm( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ float *tc[], /* i : transport channels */ @@ -6949,7 +6740,7 @@ void ivas_jbm_dec_copy_tc_no_tsm( return; } - +#endif #ifdef IVAS_FLOAT_FIXED void ivas_jbm_dec_copy_tc_no_tsm_fx( diff --git a/lib_dec/ivas_masa_dec.c b/lib_dec/ivas_masa_dec.c index 61fe1caff..a638ee537 100644 --- a/lib_dec/ivas_masa_dec.c +++ b/lib_dec/ivas_masa_dec.c @@ -3238,7 +3238,7 @@ ivas_error ivas_masa_dec_reconfigure_fx( test(); IF( NE_16( tc_nchan_transport, st_ivas->hTcBuffer->nchan_transport_jbm ) || NE_16( tc_nchan_to_allocate, st_ivas->hTcBuffer->nchan_transport_internal ) || NE_16( buffer_mode_new, st_ivas->hTcBuffer->tc_buffer_mode ) ) { - IF( ( error = ivas_jbm_dec_tc_buffer_reconfigure( st_ivas, buffer_mode_new, tc_nchan_transport, tc_nchan_to_allocate, tc_nchan_to_allocate, n_samples_granularity ) ) != IVAS_ERR_OK ) + IF( ( error = ivas_jbm_dec_tc_buffer_reconfigure_fx( st_ivas, buffer_mode_new, tc_nchan_transport, tc_nchan_to_allocate, tc_nchan_to_allocate, n_samples_granularity ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 13186b6e5..214a5e430 100644 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -1373,7 +1373,7 @@ ivas_error ivas_sba_dec_reconfigure_fx( if ( tc_nchan_tc != st_ivas->hTcBuffer->nchan_transport_jbm || tc_nchan_to_allocate != st_ivas->hTcBuffer->nchan_transport_internal || tc_buffer_mode != st_ivas->hTcBuffer->tc_buffer_mode || granularity_new != st_ivas->hTcBuffer->n_samples_granularity ) { - if ( ( error = ivas_jbm_dec_tc_buffer_reconfigure( st_ivas, tc_buffer_mode, tc_nchan_tc, tc_nchan_to_allocate, tc_nchan_to_allocate, granularity_new ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_jbm_dec_tc_buffer_reconfigure_fx( st_ivas, tc_buffer_mode, tc_nchan_tc, tc_nchan_to_allocate, tc_nchan_to_allocate, granularity_new ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_dec/ivas_stereo_dft_dec_fx.c b/lib_dec/ivas_stereo_dft_dec_fx.c index 1c973dd5d..09867f30c 100644 --- a/lib_dec/ivas_stereo_dft_dec_fx.c +++ b/lib_dec/ivas_stereo_dft_dec_fx.c @@ -483,18 +483,17 @@ static void stereo_dft_dequantize_res_gains_f_fx( /* compensate for the offset and extract/remove sign of first index */ sign = LT_32( ind1[i], L_shl( 15, Q26 ) ) ? -1 : 1; move16(); - i1 = (Word16) L_shr( ( LT_32( ind1[i], L_shl( 15, Q26 ) ) ? L_sub( L_shl( 15, Q26 ), ind1[i] ) : L_sub( ind1[i], L_shl( 15, Q26 ) ) ), Q26 ); - fi = ( LT_32( ind1[i], L_shl( 15, Q26 ) ) ? L_sub( L_shl( 15, Q26 ), ind1[i] ) : L_sub( ind1[i], L_shl( 15, Q26 ) ) ) - L_shl( i1, Q26 ); + i1 = extract_l( L_shr( ( LT_32( ind1[i], L_shl( 15, Q26 ) ) ? L_sub( L_shl( 15, Q26 ), ind1[i] ) : L_sub( ind1[i], L_shl( 15, Q26 ) ) ), Q26 ) ); + fi = L_sub( ( LT_32( ind1[i], L_shl( 15, Q26 ) ) ? L_sub( L_shl( 15, Q26 ), ind1[i] ) : L_sub( ind1[i], L_shl( 15, Q26 ) ) ), L_shl( i1, Q26 ) ); move16(); - j1 = (Word16) L_shr( ind2[i], Q26 ); + j1 = extract_l( L_shr( ind2[i], Q26 ) ); fj = L_sub( ind2[i], L_shl( j1, Q26 ) ); /* choose base indices for interpolation */ - ji = (Word16) L_min( fj < ONE_IN_Q25 ? j1 : j1 + 1, 7 ); - ij = (Word16) L_min( fi < ONE_IN_Q25 ? i1 : i1 + 1, 15 ); + ji = extract_l( L_min( fj < ONE_IN_Q25 ? j1 : j1 + 1, 7 ) ); + ij = extract_l( L_min( fi < ONE_IN_Q25 ? i1 : i1 + 1, 15 ) ); /* interpolate values from table */ - // IF ( LT_32(i1, L_shl(15, Q26)) ) IF( LT_16( i1, 15 ) ) { gout[i] = Madd_32_32( Mpy_32_32( L_sub( MAX_32, L_shl( fi, Q5 ) ), dft_res_gains_q_fx[( i1 << 3 ) + ji][0] ), dft_res_gains_q_fx[( ( i1 + 1 ) << 3 ) + ji][0], L_shl( fi, Q5 ) ); @@ -507,7 +506,7 @@ static void stereo_dft_dequantize_res_gains_f_fx( } ELSE { - gout[i] = sign * dft_res_gains_q_fx[120 + ji][0]; + gout[i] = dft_res_gains_q_fx[120 + ji][0]; move32(); IF( EQ_16( sign, -1 ) ) { @@ -516,7 +515,7 @@ static void stereo_dft_dequantize_res_gains_f_fx( } } - IF( LT_32( j1, L_shl( 7, Q26 ) ) ) + IF( LT_16( j1, 7 ) ) { rout[i] = Madd_32_32( Mpy_32_32( L_sub( MAX_32, L_shl( fj, Q5 ) ), dft_res_gains_q_fx[( ij << 3 ) + j1][1] ), L_shl( fj, Q5 ), dft_res_gains_q_fx[( ij << 3 ) + j1 + 1][1] ); move32(); diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c index e22b800d6..465a91037 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions.c @@ -81,6 +81,8 @@ Word16 slot_fx[4] = { 32767, 16384, 10922, 8192 }; #define LOG_10_BASE_2_Q29 1783446528 // Q29 #define TAN_30_FX 17157 // Q15 #define INV_TAN30_FX 28377 // Q14 +#define EPSILON_MANT 1180591621 /* 1e-12 in Q70 */ +#define EPSILON_EXP ( -39 ) #endif #define ADAPT_HTPROTO_ROT_LIM_1 0.8f @@ -155,9 +157,9 @@ static void adaptTransportSignalsHeadtracked( COMBINED_ORIENTATION_HANDLE hHeadT #ifndef IVAS_FLOAT_FIXED static void ivas_dirac_dec_binaural_check_and_switch_transports_headtracked( COMBINED_ORIENTATION_HANDLE hHeadTrackData, float inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], float inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], const int16_t nBins, const int16_t nSlots, float Rmat[3][3] ); #endif - +#ifndef IVAS_FLOAT_FIXED static void formulate2x2MixingMatrix( float Ein1, float Ein2, float CinRe, float CinIm, float Eout1, float Eout2, float CoutRe, float CoutIm, float Q[BINAURAL_CHANNELS][BINAURAL_CHANNELS], float Mre[BINAURAL_CHANNELS][BINAURAL_CHANNELS], float Mim[BINAURAL_CHANNELS][BINAURAL_CHANNELS], const float regularizationFactor ); - +#endif #ifdef IVAS_FLOAT_FIXED static void hrtfShGetHrtf_fx( const Word16 bin, const Word16 aziDeg, const Word16 eleDeg, Word32 *lRealp, Word32 *lImagp, Word32 *rRealp, Word32 *rImagp, PARAMBIN_HRTF_GAIN_CACHE *gainCache, const Word16 useCachedValue ); #else @@ -176,6 +178,14 @@ static void matrixTransp2Mul( float Are[BINAURAL_CHANNELS][BINAURAL_CHANNELS], f static void ivas_masa_ext_rend_parambin_internal( MASA_EXT_REND_HANDLE hMasaExtRend, COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, float *output_f[], const int16_t subframe ); +#ifdef IVAS_FLOAT_FIXED +static void formulate2x2MixingMatrix_fx(Word32 Ein1_fx, Word32 Ein2_fx, Word16 q_Ein, Word32 CinRe_fx, Word32 CinIm_fx, Word16 q_Cin, Word32 Eout1_fx, Word32 Eout2_fx, Word16 q_Eout, Word32 CoutRe_fx, Word32 CoutIm_fx, Word16 q_Cout, Word32 Q_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], Word32 Mre_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], Word32 Mim_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], Word16 *q_M, const Word16 regularizationFactor_fx); + +static void matrixMul_fx(Word32 Are[BINAURAL_CHANNELS][BINAURAL_CHANNELS], Word32 Aim[BINAURAL_CHANNELS][BINAURAL_CHANNELS], Word16 *q_A, Word32 Bre[BINAURAL_CHANNELS][BINAURAL_CHANNELS], Word32 Bim[BINAURAL_CHANNELS][BINAURAL_CHANNELS], Word16 *q_B, Word32 outRe[BINAURAL_CHANNELS][BINAURAL_CHANNELS], Word32 outIm[BINAURAL_CHANNELS][BINAURAL_CHANNELS], Word16 *q_out); + +static void matrixTransp2Mul_fx(Word32 Are[BINAURAL_CHANNELS][BINAURAL_CHANNELS], Word32 Aim[BINAURAL_CHANNELS][BINAURAL_CHANNELS], Word16 *q_A, Word32 Bre[BINAURAL_CHANNELS][BINAURAL_CHANNELS], Word32 Bim[BINAURAL_CHANNELS][BINAURAL_CHANNELS], Word16 *q_B, Word32 outRe[BINAURAL_CHANNELS][BINAURAL_CHANNELS], Word32 outIm[BINAURAL_CHANNELS][BINAURAL_CHANNELS], Word16 *q_out); +#endif // 1 + /*------------------------------------------------------------------------- * ivas_dirac_dec_init_binaural_data() * @@ -2847,12 +2857,14 @@ static void ivas_dirac_dec_binaural_determine_processing_matrices( float CrEneL, CrEneR; /* Cr = residual decorrelated sound covariance matrix */ float CrCrossRe, CrCrossIm; float Mre[BINAURAL_CHANNELS][BINAURAL_CHANNELS], Mim[BINAURAL_CHANNELS][BINAURAL_CHANNELS], MdecRe[BINAURAL_CHANNELS][BINAURAL_CHANNELS], MdecIm[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; /* M = mixing matrix; Mdec = residual decorrelated signal mixing matrix */ +#ifndef IVAS_FLOAT_FIXED float prototypeMtx[BINAURAL_CHANNELS][BINAURAL_CHANNELS] = { { 1.0f, 0.05f }, { 0.05f, 1.0f } }; /* Prototype matrix determines a reference signal in mixing matrix determination */ - +#endif CrEneL = 0.0f; CrEneR = 0.0f; /* Formulate main processing matrix M */ +#ifndef IVAS_FLOAT_FIXED formulate2x2MixingMatrix( hDiracDecBin->ChEne[0][bin], hDiracDecBin->ChEne[1][bin], hDiracDecBin->ChCrossRe[bin], hDiracDecBin->ChCrossIm[bin], hDiracDecBin->ChEneOut[0][bin], hDiracDecBin->ChEneOut[1][bin], @@ -2863,6 +2875,82 @@ static void ivas_dirac_dec_binaural_determine_processing_matrices( #else hDiracDecBin->reqularizationFactor ); #endif +#else + Word16 q_M, q_Mdec = 0, q_CrEne, q_CrCross; + Word32 prototypeMtx_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS] = { { ONE_IN_Q31, 107374182 }, { 107374182, ONE_IN_Q31 } }; + Word32 Mre_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], Mim_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], MdecRe_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], MdecIm_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; /* M = mixing matrix; Mdec = residual decorrelated signal mixing matrix */ + Word32 CrEneL_fx, CrEneR_fx; /* Cr = residual decorrelated sound covariance matrix */ + Word32 CrCrossRe_fx, CrCrossIm_fx; + + IF( hDiracDecBin->ChEne_e[0][bin] > hDiracDecBin->ChEne_e[1][bin] ) + { + hDiracDecBin->ChEne_fx[1][bin] = L_shr( hDiracDecBin->ChEne_fx[1][bin], sub( hDiracDecBin->ChEne_e[0][bin], hDiracDecBin->ChEne_e[1][bin] ) ); + hDiracDecBin->q_ChEne = 31 - hDiracDecBin->ChEne_e[0][bin]; + hDiracDecBin->ChEne_e[1][bin] = hDiracDecBin->ChEne_e[0][bin]; + } + ELSE + { + hDiracDecBin->ChEne_fx[0][bin] = L_shr( hDiracDecBin->ChEne_fx[0][bin], sub( hDiracDecBin->ChEne_e[1][bin], hDiracDecBin->ChEne_e[0][bin] ) ); + hDiracDecBin->q_ChEne = 31 - hDiracDecBin->ChEne_e[1][bin]; + hDiracDecBin->ChEne_e[0][bin] = hDiracDecBin->ChEne_e[1][bin]; + } + IF( hDiracDecBin->ChEneOut_e[0][bin] > hDiracDecBin->ChEneOut_e[1][bin] ) + { + hDiracDecBin->ChEneOut_fx[1][bin] = L_shr( hDiracDecBin->ChEneOut_fx[1][bin], sub( hDiracDecBin->ChEneOut_e[0][bin], hDiracDecBin->ChEneOut_e[1][bin] ) ); + hDiracDecBin->q_ChEneOut = 31 - hDiracDecBin->ChEneOut_e[0][bin]; + hDiracDecBin->ChEneOut_e[1][bin] = hDiracDecBin->ChEneOut_e[0][bin]; + } + ELSE + { + hDiracDecBin->ChEneOut_fx[0][bin] = L_shr( hDiracDecBin->ChEneOut_fx[0][bin], sub( hDiracDecBin->ChEneOut_e[1][bin], hDiracDecBin->ChEneOut_e[0][bin] ) ); + hDiracDecBin->q_ChEneOut = 31 - hDiracDecBin->ChEneOut_e[1][bin]; + hDiracDecBin->ChEneOut_e[0][bin] = hDiracDecBin->ChEneOut_e[1][bin]; + } + + IF( hDiracDecBin->ChCrossRe_e[bin] > hDiracDecBin->ChCrossIm_e[bin] ) + { + hDiracDecBin->ChCrossIm_fx[bin] = L_shr( hDiracDecBin->ChCrossIm_fx[bin], sub( hDiracDecBin->ChCrossRe_e[bin], hDiracDecBin->ChCrossIm_e[bin] ) ); + hDiracDecBin->q_ChCross = 31 - hDiracDecBin->ChCrossRe_e[bin]; + hDiracDecBin->ChCrossIm_e[bin] = hDiracDecBin->ChCrossRe_e[bin]; + } + ELSE + { + hDiracDecBin->ChCrossRe_fx[bin] = L_shr( hDiracDecBin->ChCrossRe_fx[bin], sub( hDiracDecBin->ChCrossIm_e[bin], hDiracDecBin->ChCrossRe_e[bin] ) ); + hDiracDecBin->q_ChCross = 31 - hDiracDecBin->ChCrossIm_e[bin]; + hDiracDecBin->ChCrossRe_e[bin] = hDiracDecBin->ChCrossIm_e[bin]; + } + IF( hDiracDecBin->ChCrossReOut_e[bin] > hDiracDecBin->ChCrossImOut_e[bin] ) + { + hDiracDecBin->ChCrossImOut_fx[bin] = L_shr( hDiracDecBin->ChCrossImOut_fx[bin], sub( hDiracDecBin->ChCrossReOut_e[bin], hDiracDecBin->ChCrossImOut_e[bin] ) ); + hDiracDecBin->q_ChCrossOut = 31 - hDiracDecBin->ChCrossReOut_e[bin]; + hDiracDecBin->ChCrossImOut_e[bin] = hDiracDecBin->ChCrossReOut_e[bin]; + } + ELSE + { + hDiracDecBin->ChCrossReOut_fx[bin] = L_shr( hDiracDecBin->ChCrossReOut_fx[bin], sub( hDiracDecBin->ChCrossImOut_e[bin], hDiracDecBin->ChCrossReOut_e[bin] ) ); + hDiracDecBin->q_ChCrossOut = 31 - hDiracDecBin->ChCrossImOut_e[bin]; + hDiracDecBin->ChCrossReOut_e[bin] = hDiracDecBin->ChCrossImOut_e[bin]; + } + + formulate2x2MixingMatrix_fx( hDiracDecBin->ChEne_fx[0][bin], hDiracDecBin->ChEne_fx[1][bin], + hDiracDecBin->q_ChEne, + hDiracDecBin->ChCrossRe_fx[bin], hDiracDecBin->ChCrossIm_fx[bin], + hDiracDecBin->q_ChCross, + hDiracDecBin->ChEneOut_fx[0][bin], hDiracDecBin->ChEneOut_fx[1][bin], + hDiracDecBin->q_ChEneOut, + hDiracDecBin->ChCrossReOut_fx[bin], hDiracDecBin->ChCrossImOut_fx[bin], + hDiracDecBin->q_ChCrossOut, + prototypeMtx_fx, Mre_fx, Mim_fx, &q_M, hDiracDecBin->reqularizationFactor_fx ); + + for ( int a = 0; a < BINAURAL_CHANNELS; a++ ) + { + for ( int b = 0; b < BINAURAL_CHANNELS; b++ ) + { + Mre[a][b] = (float) Mre_fx[a][b] / (float) pow( 2, q_M ); + Mim[a][b] = (float) Mim_fx[a][b] / (float) pow( 2, q_M ); + } + } +#endif /* Load estimated covariance matrix to the [2][2] matrix form */ CxRe[0][0] = hDiracDecBin->ChEne[0][bin]; @@ -2920,11 +3008,57 @@ static void ivas_dirac_dec_binaural_determine_processing_matrices( /* Determine a residual mixing matrix Mdec for processing the decorrelated signal to obtain * the residual signal (that has the residual covariance matrix) */ +#ifndef IVAS_FLOAT_FIXED formulate2x2MixingMatrix( hDiracDecBin->ChEne[0][bin], hDiracDecBin->ChEne[1][bin], 0.0f, 0.0f, /* Decorrelated signal has ideally no cross-terms */ CrEneL, CrEneR, CrCrossRe, CrCrossIm, prototypeMtx, MdecRe, MdecIm, 0.2f ); +#else + + int16_t exp, exp1; + f2me( CrEneL, &CrEneL_fx, &exp ); + f2me( CrEneR, &CrEneR_fx, &exp1 ); + if ( exp > exp1 ) + { + CrEneR_fx = L_shr( CrEneR_fx, exp - exp1 ); + q_CrEne = 31 - exp; + } + else + { + CrEneL_fx = L_shr( CrEneL_fx, exp1 - exp ); + q_CrEne = 31 - exp1; + } + + f2me( CrCrossRe, &CrCrossRe_fx, &exp ); + f2me( CrCrossIm, &CrCrossIm_fx, &exp1 ); + if ( exp > exp1 ) + { + CrCrossIm_fx = L_shr( CrCrossIm_fx, exp - exp1 ); + q_CrCross = 31 - exp; + } + else + { + CrCrossRe_fx = L_shr( CrCrossRe_fx, exp1 - exp ); + q_CrCross = 31 - exp1; + } + + formulate2x2MixingMatrix_fx( hDiracDecBin->ChEne_fx[0][bin], hDiracDecBin->ChEne_fx[1][bin], + hDiracDecBin->q_ChEne, + 0, 0, /* Decorrelated signal has ideally no cross-terms */ + Q31, CrEneL_fx, CrEneR_fx, q_CrEne, + CrCrossRe_fx, CrCrossIm_fx, q_CrCross, + prototypeMtx_fx, MdecRe_fx, MdecIm_fx, &q_Mdec, 3277 ); // 3277 = 0.2 in Q14 + + for ( int a = 0; a < BINAURAL_CHANNELS; a++ ) + { + for ( int b = 0; b < BINAURAL_CHANNELS; b++ ) + { + MdecRe[a][b] = (float) MdecRe_fx[a][b] / (float) pow( 2, q_Mdec ); + MdecIm[a][b] = (float) MdecIm_fx[a][b] / (float) pow( 2, q_Mdec ); + } + } +#endif } else { @@ -3971,7 +4105,7 @@ static void ivas_dirac_dec_binaural_check_and_switch_transports_headtracked( } #endif - +#ifndef IVAS_FLOAT_FIXED static void eig2x2( const float E1, const float E2, @@ -4044,8 +4178,348 @@ static void eig2x2( return; } +#else +static void eig2x2_fx( + const Word32 E1_fx, + const Word32 E2_fx, + Word16 q_E, + const Word32 Cre_fx, + const Word32 Cim_fx, + Word16 q_C, + Word32 Ure_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], + Word32 Uim_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], + Word16 *q_U, + Word32 D_fx[BINAURAL_CHANNELS], + Word16 *q_D ) +{ + Word16 chA, chB, ch; + Word32 s_fx, normVal_fx, crossSquare_fx, a_fx, pm_fx, add_fx; + Word32 tmp1, tmp2, tmp3, e1, e2, c_re, c_im; + Word16 q_crossSquare, q_tmp1, q_tmp2, exp_tmp3, exp, q_e, q_c, q_U_1, q_U_2; + Word32 epsilon_mant = 1180591621; + Word16 epsilon_exp = -39; + + pm_fx = 0; + move32(); + add_fx = 0; + move32(); + q_tmp2 = 0; + move16(); + + FOR( chA = 0; chA < BINAURAL_CHANNELS; chA++ ) + { + FOR( chB = 0; chB < BINAURAL_CHANNELS; chB++ ) + { + Ure_fx[chA][chB] = 0; + move32(); + Uim_fx[chA][chB] = 0; + move32(); + } + } + + exp = sub( get_min_scalefactor( Cre_fx, Cim_fx ), 2 ); + c_re = L_shl( Cre_fx, exp ); + c_im = L_shl( Cim_fx, exp ); + q_c = add( q_C, exp ); + + exp = sub( get_min_scalefactor( E1_fx, E2_fx ), 2 ); + e1 = L_shl( E1_fx, exp ); + e2 = L_shl( E2_fx, exp ); + q_e = add( q_E, exp ); + + /*crossSquare_fx = (c_re * c_re) + (c_im * c_im) + a_fx = (e1 + e2) * (e1 + e2) - 4.0f * ((e1 * e2) - crossSquare_fx) = (e1 - e2)^2 + 4 * crossSquare_fx + pm_fx = 0.5f * sqrtf(max(0.0f, a_fx)) + add_fx = 0.5f * (e1 + e2)*/ + + IF( L_and( EQ_32( c_re, 0 ), EQ_32( c_im, 0 ) ) ) + { + /* if c_re = 0 and c_im = 0, then crossSquare_fx = (c_re * c_re) + (c_im * c_im) = 0 + a_fx = (E1 - E2)^2 + pm_fx = 0.5 * sqrt(max(0, a_fx)) = 0.5 * max(0, (e1 - e2)) */ + crossSquare_fx = 0; + move32(); + q_crossSquare = Q31; + move16(); + pm_fx = L_shr( L_max( 0, L_abs( L_sub( e1, e2 ) ) ), 1 ); + q_tmp2 = q_e; + move16(); + } + ELSE + { + crossSquare_fx = Madd_32_32( Mpy_32_32( c_re, c_re ), c_im, c_im ); + q_crossSquare = sub( add( q_c, q_c ), 31 ); + IF( EQ_32( e1, e2 ) ) + { + /* if e1 - e2 = 0, then a_fx = 4 * crossSquare_fx + pm_fx = 0.5 * sqrt(max(0, 4 * crossSquare_fx)) = sqrt(0, crossSquare_fx)*/ + IF( EQ_32( c_re, 0 ) || LT_32( abs( c_re ), ONE_IN_Q15 ) ) + { + /* if c_re = 0, then crossSquare_fx = c_im^2 => pm_fx = max(0, c_im) */ + pm_fx = L_max( 0, L_abs( c_im ) ); + q_tmp2 = q_c; + } + ELSE IF( EQ_32( c_im, 0 ) || LT_32( abs( c_im ), ONE_IN_Q15 ) ) + { + /* if c_im = 0, then crossSquare_fx = c_re^2 => pm_fx = max(0, c_re) */ + pm_fx = L_max( 0, L_abs( c_re ) ); + q_tmp2 = q_c; + } + ELSE + { + exp = sub( 31, q_crossSquare ); + pm_fx = Sqrt32( L_max( 0, crossSquare_fx ), &exp ); + q_tmp2 = sub( 31, exp ); + } + } + ELSE + { + /* if e1, e2 >> c_re, c_im then (e1 - e2)^2 ~ (e1 - e2)^2 + 4 * crossSquare_fx + a_fx = (E1 - E2)^2 + pm_fx = 0.5 * sqrt(max(0, a_fx)) = 0.5 * max(0, (e1 - e2)) */ + + IF( GT_16( sub( q_c, q_e ), Q15 ) ) + { + pm_fx = L_shr( L_max( 0, L_abs( L_sub( e1, e2 ) ) ), 1 ); + q_tmp2 = q_e; + move16(); + } + ELSE + { + tmp2 = crossSquare_fx; + q_tmp2 = sub( q_crossSquare, 2 ); // crossSquare_fx = 4 * crossSquare_fx; + + tmp1 = Mpy_32_32( L_sub( e1, e2 ), L_sub( e1, e2 ) ); + q_tmp1 = sub( add( q_e, q_e ), 31 ); + a_fx = BASOP_Util_Add_Mant32Exp( tmp1, sub( 31, q_tmp1 ), tmp2, sub( 31, q_tmp2 ), &q_tmp2 ); // (E1 - E2)^2 + 4 * crossSquare_fx + q_tmp2 = sub( 31, q_tmp2 ); + + exp = sub( 31, q_tmp2 ); + pm_fx = Sqrt32( L_max( 0, a_fx - 1 ), &exp ); + pm_fx = L_shr( pm_fx, 1 ); + q_tmp2 = sub( 31, exp ); + } + } + } + // add_fx = 0.5 * (e1 + e2) + add_fx = L_shr( L_add( e1, e2 ), 1 ); + q_tmp1 = q_e; + + IF( LT_16( q_tmp1, q_tmp2 ) ) + { + D_fx[0] = L_add( L_shr( add_fx, 1 ), L_shr( pm_fx, add( sub( q_tmp2, q_tmp1 ), 1 ) ) ); + move32(); + D_fx[1] = L_max( 0, L_sub( L_shr( add_fx, 1 ), L_shr( pm_fx, add( sub( q_tmp2, q_tmp1 ), 1 ) ) ) ); + move32(); + *q_D = sub( q_tmp1, 1 ); + move16(); + } + ELSE + { + D_fx[0] = L_add( L_shr( add_fx, add( sub( q_tmp1, q_tmp2 ), 1 ) ), L_shr( pm_fx, 1 ) ); + move32(); + D_fx[1] = L_max( 0, L_sub( L_shr( add_fx, add( sub( q_tmp1, q_tmp2 ), 1 ) ), L_shr( pm_fx, 1 ) ) ); + move32(); + *q_D = sub( q_tmp2, 1 ); + move16(); + } + /* Numeric case, when input is practically zeros */ + // IF( D_fx[0] < EPSILON_FX ) + IF( EQ_16( BASOP_Util_Cmp_Mant32Exp( D_fx[0], *q_D, EPSILON_MANT, EPSILON_EXP ), -1 ) ) + { + Ure_fx[0][0] = ONE_IN_Q31; + move32(); + Ure_fx[1][1] = ONE_IN_Q31; + move32(); + *q_U = Q31; + move16(); + + return; + } + + /* Numeric case, when input is near an identity matrix with a gain */ + tmp1 = Mpy_32_32( 2147484, add_fx ); // 2147484 = 1e-3f in Q31 + + IF( LT_16( q_tmp1, q_tmp2 ) ) + { + IF( LT_32( L_shr( pm_fx, sub( q_tmp2, q_tmp1 ) ), tmp1 ) ) + { + Ure_fx[0][0] = ONE_IN_Q30; + move32(); + Ure_fx[1][1] = ONE_IN_Q30; + move32(); + *q_U = Q30; + move16(); + + return; + } + } + ELSE + { + IF( LT_32( pm_fx, L_shr( tmp1, sub( q_tmp1, q_tmp2 ) ) ) ) + { + Ure_fx[0][0] = ONE_IN_Q30; + move32(); + Ure_fx[1][1] = ONE_IN_Q30; + move32(); + *q_U = Q30; + move16(); + + return; + } + } + + q_U_1 = 0; + q_U_2 = 0; + + /* Eigenvectors */ + FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + IF( LT_16( *q_D, q_e ) ) + { + tmp1 = L_sub( D_fx[ch], L_shr( e1, sub( q_e, *q_D ) ) ); + tmp2 = L_sub( D_fx[ch], L_shr( e2, sub( q_e, *q_D ) ) ); + q_tmp1 = *q_D; + move16(); + } + ELSE + { + tmp1 = L_sub( L_shr( D_fx[ch], sub( *q_D, q_e ) ), e1 ); + tmp2 = L_sub( L_shr( D_fx[ch], sub( *q_D, q_e ) ), e2 ); + q_tmp1 = q_e; + move16(); + } + + IF( GT_32( abs( tmp2 ), abs( tmp1 ) ) ) + { + s_fx = tmp2; + move32(); + exp = sub( norm_l( s_fx ), 1 ); + tmp2 = Mpy_32_32( s_fx, s_fx ); + q_tmp2 = sub( add( q_tmp1, q_tmp1 ), 31 ); + + tmp2 = BASOP_Util_Add_Mant32Exp( crossSquare_fx, sub( 31, q_crossSquare ), tmp2, sub( 31, q_tmp2 ), &q_tmp2 ); + q_tmp2 = sub( 31, q_tmp2 ); + + tmp3 = BASOP_Util_Add_Mant32Exp( tmp2, sub( 31, q_tmp2 ), epsilon_mant, epsilon_exp, &exp_tmp3 ); + + tmp2 = BASOP_Util_Divide3232_Scale_cadence( ONE_IN_Q30, tmp3, &exp ); + exp = sub( exp, sub( Q30, sub( 31, exp_tmp3 ) ) ); + normVal_fx = Sqrt32( tmp2, &exp ); + q_tmp2 = sub( 31, exp ); + + IF( LT_16( q_tmp1, q_c ) ) + { + c_re = L_shr( c_re, sub( q_c, q_tmp1 ) ); + c_im = L_shr( c_im, sub( q_c, q_tmp1 ) ); + q_c = q_tmp1; + move16(); + } + ELSE + { + s_fx = L_shr( s_fx, sub( q_tmp1, q_c ) ); + q_tmp1 = q_c; + move16(); + } + + Ure_fx[0][ch] = Mpy_32_32( s_fx, normVal_fx ); + move32(); + Ure_fx[1][ch] = Mpy_32_32( c_re, normVal_fx ); + move32(); + Uim_fx[1][ch] = Mpy_32_32( c_im, normVal_fx ); + move32(); + q_U_1 = sub( add( q_tmp1, q_tmp2 ), 31 ); + + IF( q_U_2 != 0 ) + { + IF( LT_16( q_U_1, q_U_2 ) ) + { + Ure_fx[1][ch - 1] = L_shr( Ure_fx[1][ch - 1], sub( q_U_2, q_U_1 ) ); + Ure_fx[0][ch - 1] = L_shr( Ure_fx[0][ch - 1], sub( q_U_2, q_U_1 ) ); + Uim_fx[0][ch - 1] = L_shr( Uim_fx[0][ch - 1], sub( q_U_2, q_U_1 ) ); + q_U_2 = q_U_1; + } + ELSE IF( GT_16( q_U_1, q_U_2 ) ) + { + Ure_fx[1][ch] = L_shr( Ure_fx[1][ch], sub( q_U_1, q_U_2 ) ); + Ure_fx[0][ch] = L_shr( Ure_fx[0][ch], sub( q_U_1, q_U_2 ) ); + Uim_fx[1][ch] = L_shr( Uim_fx[1][ch], sub( q_U_1, q_U_2 ) ); + q_U_1 = q_U_2; + } + } + q_U_2 = q_U_1; + } + ELSE + { + s_fx = tmp1; + move32(); + + exp = sub( norm_l( s_fx ), 1 ); + tmp2 = Mpy_32_32( s_fx, s_fx ); + q_tmp2 = sub( add( q_tmp1, q_tmp1 ), 31 ); + + tmp2 = BASOP_Util_Add_Mant32Exp( crossSquare_fx, sub( 31, q_crossSquare ), tmp2, sub( 31, q_tmp2 ), &q_tmp2 ); + q_tmp2 = sub( 31, q_tmp2 ); + + tmp3 = BASOP_Util_Add_Mant32Exp( tmp2, sub( 31, q_tmp2 ), epsilon_mant, epsilon_exp, &exp_tmp3 ); + + tmp2 = BASOP_Util_Divide3232_Scale_cadence( ONE_IN_Q30, tmp3, &exp ); + exp = sub( exp, sub( Q30, sub( 31, exp_tmp3 ) ) ); + normVal_fx = Sqrt32( tmp2, &exp ); + q_tmp2 = sub( 31, exp ); + + IF( LT_16( q_tmp1, q_c ) ) + { + c_re = L_shr( c_re, sub( q_c, q_tmp1 ) ); + c_im = L_shr( c_im, sub( q_c, q_tmp1 ) ); + q_c = q_tmp1; + move16(); + } + ELSE + { + s_fx = L_shr( s_fx, sub( q_tmp1, q_c ) ); + q_tmp1 = q_c; + move16(); + } + + Ure_fx[1][ch] = Mpy_32_32( s_fx, normVal_fx ); + move32(); + Ure_fx[0][ch] = Mpy_32_32( c_re, normVal_fx ); + move32(); + Uim_fx[0][ch] = Mpy_32_32( -c_im, normVal_fx ); + move32(); + q_U_2 = sub( add( q_tmp1, q_tmp2 ), 31 ); + + IF( q_U_1 != 0 ) + { + IF( LT_16( q_U_1, q_U_2 ) ) + { + Ure_fx[1][ch] = L_shr( Ure_fx[1][ch], sub( q_U_2, q_U_1 ) ); + Ure_fx[0][ch] = L_shr( Ure_fx[0][ch], sub( q_U_2, q_U_1 ) ); + Uim_fx[0][ch] = L_shr( Uim_fx[0][ch], sub( q_U_2, q_U_1 ) ); + q_U_2 = q_U_1; + } + ELSE IF( GT_16( q_U_1, q_U_2 ) ) + { + Ure_fx[1][ch - 1] = L_shr( Ure_fx[1][ch - 1], sub( q_U_1, q_U_2 ) ); + Ure_fx[0][ch - 1] = L_shr( Ure_fx[0][ch - 1], sub( q_U_1, q_U_2 ) ); + Uim_fx[1][ch - 1] = L_shr( Uim_fx[1][ch - 1], sub( q_U_1, q_U_2 ) ); + q_U_1 = q_U_2; + } + } + q_U_1 = q_U_2; + } + } + + *q_U = q_U_1 != 0 ? q_U_1 : q_U_2; + + return; +} +#endif // IVAS_FLOAT_FIXED + +#ifndef IVAS_FLOAT_FIXED static void matrixDiagMul( float reIn[BINAURAL_CHANNELS][BINAURAL_CHANNELS], float imIn[BINAURAL_CHANNELS][BINAURAL_CHANNELS], @@ -4066,6 +4540,40 @@ static void matrixDiagMul( return; } +#else +static void matrixDiagMul_fx( + Word32 reIn_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], + Word32 imIn_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], + Word16 q_In, + const Word32 D_fx[BINAURAL_CHANNELS], + Word16 q_D, + Word32 reOut_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], + Word32 imOut_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], + Word16 *q_Out ) +{ + Word16 chA, chB; + Word16 size = i_mult( BINAURAL_CHANNELS, BINAURAL_CHANNELS ); + + FOR( chA = 0; chA < BINAURAL_CHANNELS; chA++ ) + { + FOR( chB = 0; chB < BINAURAL_CHANNELS; chB++ ) + { + reOut_fx[chA][chB] = Mpy_32_32( reIn_fx[chA][chB], D_fx[chB] ); + imOut_fx[chA][chB] = Mpy_32_32( imIn_fx[chA][chB], D_fx[chB] ); + } + } + + *q_Out = sub( add( q_In, q_D ), 31 ); + + IF( L_and( is_zero_arr( reOut_fx[0], size ), is_zero_arr( imOut_fx[0], size ) ) ) + { + *q_Out = Q31; + move16(); + } + + return; +} +#endif // IVAS_FLOAT_FIXED static void matrixMul( @@ -4091,8 +4599,76 @@ static void matrixMul( return; } +#ifdef IVAS_FLOAT_FIXED +static void matrixMul_fx( + Word32 Are_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], + Word32 Aim_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], + Word16 *q_A, + Word32 Bre_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], + Word32 Bim_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], + Word16 *q_B, + Word32 outRe_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], + Word32 outIm_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], + Word16 *q_out ) +{ + Word16 chA, chB; + Word16 min_q_shift1, min_q_shift2; + Word16 size = i_mult( BINAURAL_CHANNELS, BINAURAL_CHANNELS ); + Word32 tmp1, tmp2; + + min_q_shift1 = sub( s_min( L_norm_arr( Are_fx[0], size ), L_norm_arr( Aim_fx[0], size ) ), 1 ); + min_q_shift2 = sub( s_min( L_norm_arr( Bre_fx[0], size ), L_norm_arr( Bim_fx[0], size ) ), 1 ); + scale_sig32( Are_fx[0], size, min_q_shift1 ); + scale_sig32( Aim_fx[0], size, min_q_shift1 ); + scale_sig32( Bre_fx[0], size, min_q_shift2 ); + scale_sig32( Bim_fx[0], size, min_q_shift2 ); + *q_A = add( *q_A, min_q_shift1 ); + *q_B = add( *q_B, min_q_shift2 ); + + FOR( chA = 0; chA < BINAURAL_CHANNELS; chA++ ) + { + FOR( chB = 0; chB < BINAURAL_CHANNELS; chB++ ) + { + tmp1 = ( Are_fx[chA][0] >= 0 && Bre_fx[0][chB] >= 0 ) || ( Are_fx[chA][0] < 0 && Bre_fx[0][chB] < 0 ) ? Mpy_32_32( Are_fx[chA][0], Bre_fx[0][chB] ) : L_negate( Mpy_32_32( abs( Are_fx[chA][0] ), abs( Bre_fx[0][chB] ) ) ); + tmp2 = ( Are_fx[chA][1] >= 0 && Bre_fx[1][chB] >= 0 ) || ( Are_fx[chA][1] < 0 && Bre_fx[1][chB] < 0 ) ? Mpy_32_32( Are_fx[chA][1], Bre_fx[1][chB] ) : L_negate( Mpy_32_32( abs( Are_fx[chA][1] ), abs( Bre_fx[1][chB] ) ) ); + // outRe_fx[chA][chB] = Madd_32_32( Mpy_32_32( Are_fx[chA][0], Bre_fx[0][chB] ), Are_fx[chA][1], Bre_fx[1][chB] ); + outRe_fx[chA][chB] = L_add( tmp1, tmp2 ); + move32(); + + tmp1 = ( Aim_fx[chA][0] >= 0 && Bim_fx[0][chB] >= 0 ) || ( Aim_fx[chA][0] < 0 && Bim_fx[0][chB] < 0 ) ? Mpy_32_32( Aim_fx[chA][0], Bim_fx[0][chB] ) : L_negate( Mpy_32_32( abs( Aim_fx[chA][0] ), abs( Bim_fx[0][chB] ) ) ); + tmp2 = ( Aim_fx[chA][1] >= 0 && Bim_fx[1][chB] >= 0 ) || ( Aim_fx[chA][1] < 0 && Bim_fx[1][chB] < 0 ) ? Mpy_32_32( Aim_fx[chA][1], Bim_fx[1][chB] ) : L_negate( Mpy_32_32( abs( Aim_fx[chA][1] ), abs( Bim_fx[1][chB] ) ) ); + // outRe_fx[chA][chB] = L_sub( outRe_fx[chA][chB], Madd_32_32( Mpy_32_32( Aim_fx[chA][0], Bim_fx[0][chB] ), Aim_fx[chA][1], Bim_fx[1][chB] ) ); + outRe_fx[chA][chB] = L_sub( outRe_fx[chA][chB], L_add( tmp1, tmp2 ) ); + move32(); + + tmp1 = ( Aim_fx[chA][0] >= 0 && Bre_fx[0][chB] >= 0 ) || ( Aim_fx[chA][0] < 0 && Bre_fx[0][chB] < 0 ) ? Mpy_32_32( Aim_fx[chA][0], Bre_fx[0][chB] ) : L_negate( Mpy_32_32( abs( Aim_fx[chA][0] ), abs( Bre_fx[0][chB] ) ) ); + tmp2 = ( Aim_fx[chA][1] >= 0 && Bre_fx[1][chB] >= 0 ) || ( Aim_fx[chA][1] < 0 && Bre_fx[1][chB] < 0 ) ? Mpy_32_32( Aim_fx[chA][1], Bre_fx[1][chB] ) : L_negate( Mpy_32_32( abs( Aim_fx[chA][1] ), abs( Bre_fx[1][chB] ) ) ); + // outIm_fx[chA][chB] = Madd_32_32( Mpy_32_32( Aim_fx[chA][0], Bre_fx[0][chB] ), Aim_fx[chA][1], Bre_fx[1][chB] ); + outIm_fx[chA][chB] = L_add( tmp1, tmp2 ); + move32(); + + tmp1 = ( Are_fx[chA][0] >= 0 && Bim_fx[0][chB] >= 0 ) || ( Are_fx[chA][0] < 0 && Bim_fx[0][chB] < 0 ) ? Mpy_32_32( Are_fx[chA][0], Bim_fx[0][chB] ) : L_negate( Mpy_32_32( abs( Are_fx[chA][0] ), abs( Bim_fx[0][chB] ) ) ); + tmp2 = ( Are_fx[chA][1] >= 0 && Bim_fx[1][chB] >= 0 ) || ( Are_fx[chA][1] < 0 && Bim_fx[1][chB] < 0 ) ? Mpy_32_32( Are_fx[chA][1], Bim_fx[1][chB] ) : L_negate( Mpy_32_32( abs( Are_fx[chA][1] ), abs( Bim_fx[1][chB] ) ) ); + // outIm_fx[chA][chB] = L_add( outIm_fx[chA][chB], Madd_32_32( Mpy_32_32( Are_fx[chA][0], Bim_fx[0][chB] ), Are_fx[chA][1], Bim_fx[1][chB] ) ); + outIm_fx[chA][chB] = L_add( outIm_fx[chA][chB], L_add( tmp1, tmp2 ) ); + move32(); + } + } + *q_out = sub( add( *q_A, *q_B ), 31 ); + + IF( L_and( is_zero_arr( outRe_fx[0], size ), is_zero_arr( outIm_fx[0], size ) ) ) + { + *q_out = Q31; + move16(); + } + + return; +} +#endif // IVAS_FLOAT_FIXED + +#ifndef IVAS_FLOAT_FIXED static void matrixTransp1Mul( float Are[BINAURAL_CHANNELS][BINAURAL_CHANNELS], float Aim[BINAURAL_CHANNELS][BINAURAL_CHANNELS], @@ -4116,6 +4692,61 @@ static void matrixTransp1Mul( return; } +#else +static void matrixTransp1Mul_fx( + Word32 Are_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], + Word32 Aim_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], + Word16 q_A, + Word32 Bre_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], + Word32 Bim_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], + Word16 q_B, + Word32 outRe_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], + Word32 outIm_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], + Word16 *q_out ) +{ + Word16 chA, chB; + Word16 size = i_mult( BINAURAL_CHANNELS, BINAURAL_CHANNELS ); + Word32 tmp1, tmp2; + + + FOR( chA = 0; chA < BINAURAL_CHANNELS; chA++ ) + { + FOR( chB = 0; chB < BINAURAL_CHANNELS; chB++ ) + { + tmp1 = ( ( ( Are_fx[0][chA] >= 0 ) && ( Bre_fx[0][chB] >= 0 ) ) || ( ( Are_fx[0][chA] < 0 ) && ( Bre_fx[0][chB] < 0 ) ) ) ? Mpy_32_32( Are_fx[0][chA], Bre_fx[0][chB] ) : L_negate( Mpy_32_32( abs( Are_fx[0][chA] ), abs( Bre_fx[0][chB] ) ) ); + tmp2 = ( ( ( Are_fx[1][chA] >= 0 ) && ( Bre_fx[1][chB] >= 0 ) ) || ( ( Are_fx[1][chA] < 0 ) && ( Bre_fx[1][chB] < 0 ) ) ) ? Mpy_32_32( Are_fx[1][chA], Bre_fx[1][chB] ) : L_negate( Mpy_32_32( abs( Are_fx[1][chA] ), abs( Bre_fx[1][chB] ) ) ); + // outRe_fx[chA][chB] = Madd_32_32( Mpy_32_32( Are_fx[0][chA], Bre_fx[0][chB] ), Are_fx[1][chA], Bre_fx[1][chB] ); + outRe_fx[chA][chB] = L_add( tmp1, tmp2 ); + move32(); + tmp1 = ( ( ( L_negate( Aim_fx[0][chA] ) >= 0 ) && ( Bim_fx[0][chB] >= 0 ) ) || ( ( L_negate( Aim_fx[0][chA] ) < 0 ) && ( Bim_fx[0][chB] < 0 ) ) ) ? Mpy_32_32( -Aim_fx[0][chA], Bim_fx[0][chB] ) : L_negate( Mpy_32_32( abs( -Aim_fx[0][chA] ), abs( Bim_fx[0][chB] ) ) ); + tmp2 = ( ( ( Aim_fx[1][chA] >= 0 ) && ( Bim_fx[1][chB] >= 0 ) ) || ( ( Aim_fx[1][chA] < 0 ) && ( Bim_fx[1][chB] < 0 ) ) ) ? Mpy_32_32( Aim_fx[1][chA], Bim_fx[1][chB] ) : L_negate( Mpy_32_32( abs( Aim_fx[1][chA] ), abs( Bim_fx[1][chB] ) ) ); + // outRe_fx[chA][chB] = L_sub( outRe_fx[chA][chB], Msub_32_32( Mpy_32_32( -Aim_fx[0][chA], Bim_fx[0][chB] ), Aim_fx[1][chA], Bim_fx[1][chB] ) ); + outRe_fx[chA][chB] = L_sub( outRe_fx[chA][chB], L_sub( tmp1, tmp2 ) ); + move32(); + + tmp1 = ( ( ( L_negate( Aim_fx[0][chA] ) >= 0 ) && ( Bre_fx[0][chB] >= 0 ) ) || ( ( L_negate( Aim_fx[0][chA] ) < 0 ) && ( Bre_fx[0][chB] < 0 ) ) ) ? Mpy_32_32( -Aim_fx[0][chA], Bre_fx[0][chB] ) : L_negate( Mpy_32_32( abs( -Aim_fx[0][chA] ), abs( Bre_fx[0][chB] ) ) ); + tmp2 = ( ( ( Aim_fx[1][chA] >= 0 ) && ( Bre_fx[1][chB] >= 0 ) ) || ( ( Aim_fx[1][chA] < 0 ) && ( Bre_fx[1][chB] < 0 ) ) ) ? Mpy_32_32( Aim_fx[1][chA], Bre_fx[1][chB] ) : L_negate( Mpy_32_32( abs( Aim_fx[1][chA] ), abs( Bre_fx[1][chB] ) ) ); + // outIm_fx[chA][chB] = Msub_32_32( Mpy_32_32( -Aim_fx[0][chA], Bre_fx[0][chB] ), Aim_fx[1][chA], Bre_fx[1][chB] ); + outIm_fx[chA][chB] = L_sub( tmp1, tmp2 ); + move32(); + tmp1 = ( ( ( Are_fx[0][chA] >= 0 ) && ( Bim_fx[0][chB] >= 0 ) ) || ( ( Are_fx[0][chA] < 0 ) && ( Bim_fx[0][chB] < 0 ) ) ) ? Mpy_32_32( Are_fx[0][chA], Bim_fx[0][chB] ) : L_negate( Mpy_32_32( abs( Are_fx[0][chA] ), abs( Bim_fx[0][chB] ) ) ); + tmp2 = ( ( ( Are_fx[1][chA] >= 0 ) && ( Bim_fx[1][chB] >= 0 ) ) || ( ( Are_fx[1][chA] < 0 ) && ( Bim_fx[1][chB] < 0 ) ) ) ? Mpy_32_32( Are_fx[1][chA], Bim_fx[1][chB] ) : L_negate( Mpy_32_32( abs( Are_fx[1][chA] ), abs( Bim_fx[1][chB] ) ) ); + // outIm_fx[chA][chB] = L_add( outIm_fx[chA][chB], Madd_32_32( Mpy_32_32( Are_fx[0][chA], Bim_fx[0][chB] ), Are_fx[1][chA], Bim_fx[1][chB] ) ); + outIm_fx[chA][chB] = L_add( outIm_fx[chA][chB], L_add( tmp1, tmp2 ) ); + move32(); + } + } + *q_out = sub( add( q_A, q_B ), 31 ); + + IF( L_and( is_zero_arr( outRe_fx[0], size ), is_zero_arr( outIm_fx[0], size ) ) ) + { + *q_out = Q31; + move16(); + } + + return; +} +#endif // IVAS_FLOAT_FIXED static void matrixTransp2Mul( @@ -4141,6 +4772,72 @@ static void matrixTransp2Mul( return; } +#ifdef IVAS_FLOAT_FIXED +static void matrixTransp2Mul_fx( + Word32 Are_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], + Word32 Aim_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], + Word16 *q_A, + Word32 Bre_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], + Word32 Bim_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], + Word16 *q_B, + Word32 outRe_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], + Word32 outIm_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], + Word16 *q_out ) +{ + Word16 chA, chB; + Word16 min_q_shift; + Word16 size = i_mult( BINAURAL_CHANNELS, BINAURAL_CHANNELS ); + Word32 tmp1, tmp2; + + min_q_shift = sub( s_min( L_norm_arr( Are_fx[0], size ), L_norm_arr( Aim_fx[0], size ) ), 1 ); + scale_sig32( Are_fx[0], size, min_q_shift ); + scale_sig32( Aim_fx[0], size, min_q_shift ); + *q_A = add( *q_A, min_q_shift ); + min_q_shift = sub( s_min( L_norm_arr( Bre_fx[0], size ), L_norm_arr( Bim_fx[0], size ) ), 1 ); + scale_sig32( Bre_fx[0], size, min_q_shift ); + scale_sig32( Bim_fx[0], size, min_q_shift ); + *q_B = add( *q_B, min_q_shift ); + + FOR( chA = 0; chA < BINAURAL_CHANNELS; chA++ ) + { + FOR( chB = 0; chB < BINAURAL_CHANNELS; chB++ ) + { + tmp1 = ( Are_fx[chA][0] >= 0 && Bre_fx[chB][0] >= 0 ) || ( Are_fx[chA][0] < 0 && Bre_fx[chB][0] < 0 ) ? Mpy_32_32( Are_fx[chA][0], Bre_fx[chB][0] ) : L_negate( Mpy_32_32( abs( Are_fx[chA][0] ), abs( Bre_fx[chB][0] ) ) ); + tmp2 = ( Are_fx[chA][1] >= 0 && Bre_fx[chB][1] >= 0 ) || ( Are_fx[chA][1] < 0 && Bre_fx[chB][1] < 0 ) ? Mpy_32_32( Are_fx[chA][1], Bre_fx[chB][1] ) : L_negate( Mpy_32_32( abs( Are_fx[chA][1] ), abs( Bre_fx[chB][1] ) ) ); + // outRe_fx[chA][chB] = Madd_32_32( Mpy_32_32( Are_fx[chA][0], Bre_fx[chB][0] ), Are_fx[chA][1], Bre_fx[chB][1] ); + outRe_fx[chA][chB] = L_add( tmp1, tmp2 ); + move32(); + + tmp1 = ( Aim_fx[chA][0] >= 0 && L_negate( Bim_fx[chB][0] ) >= 0 ) || ( Aim_fx[chA][0] < 0 && L_negate( Bim_fx[chB][0] ) < 0 ) ? Mpy_32_32( Aim_fx[chA][0], -Bim_fx[chB][0] ) : L_negate( Mpy_32_32( abs( Aim_fx[chA][0] ), abs( -Bim_fx[chB][0] ) ) ); + tmp2 = ( Aim_fx[chA][1] >= 0 && L_negate( Bim_fx[chB][1] ) >= 0 ) || ( Aim_fx[chA][1] < 0 && L_negate( Bim_fx[chB][1] ) < 0 ) ? Mpy_32_32( Aim_fx[chA][1], -Bim_fx[chB][1] ) : L_negate( Mpy_32_32( abs( Aim_fx[chA][1] ), abs( -Bim_fx[chB][1] ) ) ); + // outRe_fx[chA][chB] = L_sub( outRe_fx[chA][chB], Madd_32_32( Mpy_32_32( Aim_fx[chA][0], -Bim_fx[chB][0] ), Aim_fx[chA][1], -Bim_fx[chB][1] ) ); + outRe_fx[chA][chB] = L_sub( outRe_fx[chA][chB], L_add( tmp1, tmp2 ) ); + move32(); + + tmp1 = ( Aim_fx[chA][0] >= 0 && Bre_fx[chB][0] >= 0 ) || ( Aim_fx[chA][0] < 0 && Bre_fx[chB][0] < 0 ) ? Mpy_32_32( Aim_fx[chA][0], Bre_fx[chB][0] ) : L_negate( Mpy_32_32( abs( Aim_fx[chA][0] ), abs( Bre_fx[chB][0] ) ) ); + tmp2 = ( Aim_fx[chA][1] >= 0 && Bre_fx[chB][1] >= 0 ) || ( Aim_fx[chA][1] < 0 && Bre_fx[chB][1] < 0 ) ? Mpy_32_32( Aim_fx[chA][1], Bre_fx[chB][1] ) : L_negate( Mpy_32_32( abs( Aim_fx[chA][1] ), abs( Bre_fx[chB][1] ) ) ); + // outIm_fx[chA][chB] = Madd_32_32( Mpy_32_32( Aim_fx[chA][0], Bre_fx[chB][0] ), Aim_fx[chA][1], Bre_fx[chB][1] ); + outIm_fx[chA][chB] = L_add( tmp1, tmp2 ); + move32(); + + tmp1 = ( Are_fx[chA][0] >= 0 && L_negate( Bim_fx[chB][0] ) >= 0 ) || ( Are_fx[chA][0] < 0 && L_negate( Bim_fx[chB][0] ) < 0 ) ? Mpy_32_32( Are_fx[chA][0], -Bim_fx[chB][0] ) : L_negate( Mpy_32_32( abs( Are_fx[chA][0] ), abs( -Bim_fx[chB][0] ) ) ); + tmp2 = ( Are_fx[chA][1] >= 0 && L_negate( Bim_fx[chB][1] ) >= 0 ) || ( Are_fx[chA][1] < 0 && L_negate( Bim_fx[chB][1] ) < 0 ) ? Mpy_32_32( Are_fx[chA][1], -Bim_fx[chB][1] ) : L_negate( Mpy_32_32( abs( Are_fx[chA][1] ), abs( -Bim_fx[chB][1] ) ) ); + // outIm_fx[chA][chB] = L_add( outIm_fx[chA][chB], Madd_32_32( Mpy_32_32( Are_fx[chA][0], -Bim_fx[chB][0] ), Are_fx[chA][1], -Bim_fx[chB][1] ) ); + outIm_fx[chA][chB] = L_add( outIm_fx[chA][chB], L_add( tmp1, tmp2 ) ); + move32(); + } + } + *q_out = sub( add( *q_A, *q_B ), 31 ); + + IF( L_and( is_zero_arr( outRe_fx[0], size ), is_zero_arr( outIm_fx[0], size ) ) ) + { + *q_out = Q31; + move16(); + } + return; +} +#endif // IVAS_FLOAT_FIXED + #ifdef IVAS_FLOAT_FIXED static void chol2x2_fx( @@ -4396,7 +5093,7 @@ static void chol2x2( return; } #endif - +#ifndef IVAS_FLOAT_FIXED static void formulate2x2MixingMatrix( float Ein1, float Ein2, @@ -4552,6 +5249,394 @@ static void formulate2x2MixingMatrix( return; } +#else +static void formulate2x2MixingMatrix_fx( + Word32 Ein1_fx, + Word32 Ein2_fx, + Word16 q_Ein, + Word32 CinRe_fx, + Word32 CinIm_fx, + Word16 q_Cin, + Word32 Eout1_fx, + Word32 Eout2_fx, + Word16 q_Eout, + Word32 CoutRe_fx, + Word32 CoutIm_fx, + Word16 q_Cout, + Word32 Q_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], // Q31 + Word32 Mre_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], + Word32 Mim_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], + Word16 *q_M, + const Word16 regularizationFactor_fx ) +{ + /* + This function implements a 2x2 solution for an optimized spatial audio rendering algorithm + Vilkamo, J., Bäckström, T. and Kuntz, A., 2013. + "Optimized covariance domain framework for time–frequency processing of spatial audio." + Journal of the Audio Engineering Society, 61(6), pp.403-411. + + The result of the formulas below are the same as those in the publication, however, some + derivation details differ for as simple as possible 2x2 formulattion + */ + Word16 chA, chB; + Word32 maxEne_fx, tmp, maxEneDiv_fx; + Word16 q_maxEne, q_maxEneDiv, exp, exp1; + Word32 KyRe_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], KyIm_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + Word32 Uxre_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], Uxim_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + Word32 Sx_fx[BINAURAL_CHANNELS], Kxre_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], Kxim_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + Word32 tmpRe_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], tmpIm_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + Word32 Are_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], Aim_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + Word32 Ure_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], Uim_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + Word32 D_fx[BINAURAL_CHANNELS]; + Word32 div_fx[BINAURAL_CHANNELS]; + Word32 Ghat_fx[BINAURAL_CHANNELS]; + Word32 GhatQ_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + Word32 Pre_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], Pim_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + Word16 q_ky, q_Sx, q_Ux, q_Kx, q_A, q_U, q_D, q_P; + Word32 E_in1, E_in2, E_out1, E_out2, Cout_re, Cout_im, Cin_re, Cin_im; + Word16 q_ein, q_eout, q_cin, q_cout, q_Ghat, q_GhatQ, q_temp, q_div, exp_temp; + Word32 temp; + Word16 q_Pre[BINAURAL_CHANNELS][BINAURAL_CHANNELS], q_Pim[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + Word16 hdrm_re[BINAURAL_CHANNELS][BINAURAL_CHANNELS], hdrm_im[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + set_s( hdrm_re[0], 63, i_mult( BINAURAL_CHANNELS, BINAURAL_CHANNELS ) ); + set_s( hdrm_im[0], 63, i_mult( BINAURAL_CHANNELS, BINAURAL_CHANNELS ) ); + set_s( q_Pre[0], Q31, i_mult( BINAURAL_CHANNELS, BINAURAL_CHANNELS ) ); + set_s( q_Pim[0], Q31, i_mult( BINAURAL_CHANNELS, BINAURAL_CHANNELS ) ); + + q_ky = 0; + move16(); + q_Sx = 0; + move16(); + q_Ux = 0; + move16(); + q_Kx = 0; + move16(); + + exp = sub( get_min_scalefactor( Ein1_fx, Ein2_fx ), 1 ); + E_in1 = L_shl( Ein1_fx, exp ); + E_in2 = L_shl( Ein2_fx, exp ); + q_ein = add( q_Ein, exp ); + + exp = sub( get_min_scalefactor( Eout1_fx, Eout2_fx ), 1 ); + E_out1 = L_shl( Eout1_fx, exp ); + E_out2 = L_shl( Eout2_fx, exp ); + q_eout = add( q_Eout, exp ); + + exp = sub( get_min_scalefactor( CinRe_fx, CinIm_fx ), 1 ); + Cin_re = L_shl( CinRe_fx, exp ); + Cin_im = L_shl( CinIm_fx, exp ); + q_cin = add( q_Cin, exp ); + + exp = sub( get_min_scalefactor( CoutRe_fx, CoutIm_fx ), 1 ); + Cout_re = L_shl( CoutRe_fx, exp ); + Cout_im = L_shl( CoutIm_fx, exp ); + q_cout = add( q_Cout, exp ); + + /* Normalize energy values */ + maxEne_fx = L_max( E_in1, E_in2 ); + q_maxEne = q_ein; + move16(); + + tmp = L_max( E_out1, E_out2 ); + IF( LT_16( q_maxEne, q_eout ) ) + { + maxEne_fx = L_max( maxEne_fx, L_shr( tmp, sub( q_eout, q_maxEne ) ) ); + } + ELSE + { + maxEne_fx = L_max( L_shr( maxEne_fx, sub( q_maxEne, q_eout ) ), tmp ); + q_maxEne = q_eout; + move16(); + } + + // 4611686 = Q62 + IF( EQ_32( maxEne_fx, 0 ) ) + { + maxEneDiv_fx = BASOP_Util_Divide3232_Scale_cadence( ONE_IN_Q30, 4611686, &exp ); // 4611686 = 1e-12f in Q62 + q_maxEneDiv = add( sub( 31, exp ), sub( Q30, 62 ) ); + } + ELSE + { + maxEneDiv_fx = BASOP_Util_Divide3232_Scale_cadence( ONE_IN_Q30, maxEne_fx, &exp ); + q_maxEneDiv = add( sub( 31, exp ), sub( Q30, q_maxEne ) ); + } + exp = norm_l( maxEneDiv_fx ); + maxEneDiv_fx = L_shl( maxEneDiv_fx, exp ); + q_maxEneDiv = add( q_maxEneDiv, exp ); + + E_in1 = Mpy_32_32( E_in1, maxEneDiv_fx ); + E_in2 = Mpy_32_32( E_in2, maxEneDiv_fx ); + q_ein = sub( add( q_ein, q_maxEneDiv ), 31 ); + + Cin_re = Mpy_32_32( Cin_re, maxEneDiv_fx ); + Cin_im = Mpy_32_32( Cin_im, maxEneDiv_fx ); + q_cin = sub( add( q_cin, q_maxEneDiv ), 31 ); + + E_out1 = Mpy_32_32( E_out1, maxEneDiv_fx ); + E_out2 = Mpy_32_32( E_out2, maxEneDiv_fx ); + q_eout = sub( add( q_eout, q_maxEneDiv ), 31 ); + + Cout_re = Mpy_32_32( Cout_re, maxEneDiv_fx ); + Cout_im = Mpy_32_32( Cout_im, maxEneDiv_fx ); + q_cout = sub( add( q_cout, q_maxEneDiv ), 31 ); + + /* Cholesky decomposition of target / output covariance matrix */ + chol2x2_fx( E_out1, E_out2, q_eout, Cout_re, Cout_im, q_cout, KyRe_fx, KyIm_fx, &q_ky ); + + /* Eigendecomposition of input covariance matrix */ + eig2x2_fx( E_in1, E_in2, q_ein, Cin_re, Cin_im, q_cin, Uxre_fx, Uxim_fx, &q_Ux, Sx_fx, &q_Sx ); + + /* Eigendecomposition to Kx -- Ux Sx Ux' -> Kx Kx'*/ + exp = sub( 31, q_Sx ); + exp1 = sub( 31, q_Sx ); + Sx_fx[0] = Sqrt32( Sx_fx[0], &exp ); + move32(); + Sx_fx[1] = Sqrt32( Sx_fx[1], &exp1 ); + move32(); + q_Sx = sub( 31, s_max( exp, exp1 ) ); + Sx_fx[0] = L_shr( Sx_fx[0], sub( sub( 31, exp ), q_Sx ) ); + move32(); + Sx_fx[1] = L_shr( Sx_fx[1], sub( sub( 31, exp1 ), q_Sx ) ); + move32(); + + matrixDiagMul_fx( Uxre_fx, Uxim_fx, q_Ux, Sx_fx, q_Sx, Kxre_fx, Kxim_fx, &q_Kx ); + + /* Regularize the diagonal Sx for matrix inversion */ + Sx_fx[0] = L_max( L_shr( Sx_fx[0], 1 ), Mpy_32_16_1( Sx_fx[1], regularizationFactor_fx ) ); + Sx_fx[1] = L_max( L_shr( Sx_fx[1], 1 ), L_shl( Mpy_32_16_1( Sx_fx[0], regularizationFactor_fx ), 1 ) ); + q_Sx = sub( add( q_Sx, Q14 ), 15 ); + + temp = Mpy_32_32( E_in2, 2147484 ); // 2147484 = 0.001f in Q31 + temp = L_max( temp, E_in1 ); + + IF( EQ_32( temp, 0 ) ) + { + BASOP_Util_Divide3232_Scale_cadence( E_out1, 4611686, &exp ); // 4611686 = Q62 + exp = sub( exp, sub( q_eout, 62 ) ); + } + ELSE + { + temp = BASOP_Util_Add_Mant32Exp( temp, sub( 31, q_ein ), EPSILON_MANT, EPSILON_EXP, &exp_temp ); + + temp = BASOP_Util_Divide3232_Scale_cadence( E_out1, temp, &exp ); + exp = sub( exp, sub( q_eout, sub( 31, exp_temp ) ) ); + } + Ghat_fx[0] = Sqrt32( temp, &exp ); + move32(); + + temp = Mpy_32_32( E_in1, 2147484 ); // 2147484 = 0.001f in Q31 + temp = L_max( temp, E_in2 ); + IF( EQ_32( temp, 0 ) ) + { + BASOP_Util_Divide3232_Scale_cadence( E_out2, 4611686, &exp1 ); // 4611686 = Q62 + exp1 = sub( exp1, sub( q_eout, 62 ) ); + } + ELSE + { + temp = BASOP_Util_Add_Mant32Exp(temp, sub(31, q_ein), EPSILON_MANT, EPSILON_EXP, &exp_temp); + + temp = BASOP_Util_Divide3232_Scale_cadence( E_out2, temp, &exp1 ); + exp1 = sub( exp1, sub( q_eout, sub( 31, exp_temp ) ) ); + } + Ghat_fx[1] = Sqrt32( temp, &exp1 ); + move32(); + + q_Ghat = sub( 31, s_max( exp, exp1 ) ); + + Ghat_fx[0] = L_shr( Ghat_fx[0], sub( sub( 31, exp ), q_Ghat ) ); + move32(); + Ghat_fx[1] = L_shr( Ghat_fx[1], sub( sub( 31, exp1 ), q_Ghat ) ); + move32(); + + /* Matrix multiplication, tmp = Ky' * G_hat * Q */ + FOR( chA = 0; chA < BINAURAL_CHANNELS; chA++ ) + { + GhatQ_fx[chA][0] = Mpy_32_32( Q_fx[chA][0], Ghat_fx[chA] ); + GhatQ_fx[chA][1] = Mpy_32_32( Q_fx[chA][1], Ghat_fx[chA] ); + } + q_GhatQ = sub( add( Q31, q_Ghat ), 31 ); + + exp = sub( s_min( L_norm_arr( KyRe_fx[0], i_mult( BINAURAL_CHANNELS, BINAURAL_CHANNELS ) ), L_norm_arr( KyIm_fx[0], i_mult( BINAURAL_CHANNELS, BINAURAL_CHANNELS ) ) ), 1 ); + scale_sig32( KyRe_fx[0], i_mult( BINAURAL_CHANNELS, BINAURAL_CHANNELS ), exp ); + scale_sig32( KyIm_fx[0], i_mult( BINAURAL_CHANNELS, BINAURAL_CHANNELS ), exp ); + q_ky = add( q_ky, exp ); + + FOR( chA = 0; chA < BINAURAL_CHANNELS; chA++ ) + { + FOR( chB = 0; chB < BINAURAL_CHANNELS; chB++ ) + { + tmpRe_fx[chA][chB] = Madd_32_32( Mpy_32_32( KyRe_fx[0][chA], GhatQ_fx[0][chB] ), KyRe_fx[1][chA], GhatQ_fx[1][chB] ); + tmpIm_fx[chA][chB] = Msub_32_32( Mpy_32_32( -KyIm_fx[0][chA], GhatQ_fx[0][chB] ), KyIm_fx[1][chA], GhatQ_fx[1][chB] ); + } + } + + q_temp = sub( add( q_ky, q_GhatQ ), 31 ); + + /* A = Ky' * G_hat * Q * Kx (see publication) */ + matrixMul_fx( tmpRe_fx, tmpIm_fx, &q_temp, Kxre_fx, Kxim_fx, &q_Kx, Are_fx, Aim_fx, &q_A ); + + /* Find nearest orthonormal matrix P to A = Ky' * G_hat * Q * Kx + For matrix A that is P = A(A'A)^0.5 */ + matrixTransp1Mul_fx( Are_fx, Aim_fx, q_A, Are_fx, Aim_fx, q_A, tmpRe_fx, tmpIm_fx, &q_temp ); + + eig2x2_fx( tmpRe_fx[0][0], tmpRe_fx[1][1], q_temp, tmpRe_fx[1][0], tmpIm_fx[1][0], q_temp, Ure_fx, Uim_fx, &q_U, D_fx, &q_D ); + + IF( EQ_32( D_fx[0], 0 ) ) + { + temp = BASOP_Util_Divide3232_Scale_cadence( ONE_IN_Q30, 4611686, &exp ); // 4611686 = 1e-12 in Q62 + exp = sub( exp, sub( Q30, 62 ) ); + } + ELSE + { + temp = BASOP_Util_Divide3232_Scale_cadence( ONE_IN_Q30, D_fx[0], &exp ); + exp = sub( exp, sub( Q30, q_D ) ); + } + div_fx[0] = Sqrt32( temp, &exp ); + move32(); + + IF( EQ_32( D_fx[1], 0 ) ) + { + temp = BASOP_Util_Divide3232_Scale_cadence( ONE_IN_Q30, 4611686, &exp1 ); // 4611686 = 1e-12 in Q62 + exp1 = sub( exp1, sub( Q30, 62 ) ); + } + ELSE + { + temp = BASOP_Util_Divide3232_Scale_cadence( ONE_IN_Q30, D_fx[1], &exp1 ); + exp1 = sub( exp1, sub( Q30, q_D ) ); + } + div_fx[1] = Sqrt32( temp, &exp1 ); + move32(); + + q_div = sub( 31, s_max( exp, exp1 ) ); + + div_fx[0] = L_shr( div_fx[0], sub( sub( 31, exp ), q_div ) ); + move32(); + div_fx[1] = L_shr( div_fx[1], sub( sub( 31, exp1 ), q_div ) ); + move32(); + + // 1310720000 = 10,000.0f in Q17 + IF( LT_16( q_div, Q17 ) ) + { + div_fx[0] = L_min( L_shr( 1310720000, sub( Q17, q_div ) ), div_fx[0] ); + move32(); + div_fx[1] = L_min( L_shr( 1310720000, sub( Q17, q_div ) ), div_fx[1] ); + move32(); + } + ELSE + { + div_fx[0] = L_min( 1310720000, L_shr( div_fx[0], sub( q_div, Q17 ) ) ); + move32(); + div_fx[1] = L_min( 1310720000, L_shr( div_fx[1], sub( q_div, Q17 ) ) ); + move32(); + q_div = Q17; + move16(); + } + + matrixMul_fx( Are_fx, Aim_fx, &q_A, Ure_fx, Uim_fx, &q_U, tmpRe_fx, tmpIm_fx, &q_temp ); + + exp = L_norm_arr( div_fx, BINAURAL_CHANNELS ); + scale_sig32( div_fx, BINAURAL_CHANNELS, exp ); + q_div = add( q_div, exp ); + + FOR( chA = 0; chA < BINAURAL_CHANNELS; chA++ ) + { + FOR( chB = 0; chB < BINAURAL_CHANNELS; chB++ ) + { + Word64 W_tmp; + + W_tmp = W_mult0_32_32( tmpRe_fx[chA][chB], div_fx[chB] ); + IF( NE_64( W_tmp, 0 ) ) + { + hdrm_re[chA][chB] = sub( W_norm( W_tmp ), 0 ); + W_tmp = W_shl( W_tmp, hdrm_re[chA][chB] ); + tmpRe_fx[chA][chB] = W_extract_h( W_tmp ); + move32(); + hdrm_re[chA][chB] = sub( add( add( q_temp, q_div ), hdrm_re[chA][chB] ), 32 ); + } + ELSE + { + tmpRe_fx[chA][chB] = 0; + move32(); + } + + W_tmp = W_mult0_32_32( tmpIm_fx[chA][chB], div_fx[chB] ); + IF( NE_64( W_tmp, 0 ) ) + { + hdrm_im[chA][chB] = sub( W_norm( W_tmp ), 0 ); + W_tmp = W_shl( W_tmp, hdrm_im[chA][chB] ); + tmpIm_fx[chA][chB] = W_extract_h( W_tmp ); + move32(); + hdrm_im[chA][chB] = sub( add( add( q_temp, q_div ), hdrm_im[chA][chB] ), 32 ); + } + ELSE + { + tmpIm_fx[chA][chB] = 0; + move32(); + } + } + } + + minimum_s( hdrm_re[0], i_mult( BINAURAL_CHANNELS, BINAURAL_CHANNELS ), &exp ); + q_temp = exp; + minimum_s( hdrm_im[0], i_mult( BINAURAL_CHANNELS, BINAURAL_CHANNELS ), &exp ); + q_temp = s_min( q_temp, exp ); + + FOR( chA = 0; chA < BINAURAL_CHANNELS; chA++ ) + { + FOR( chB = 0; chB < BINAURAL_CHANNELS; chB++ ) + { + tmpRe_fx[chA][chB] = L_shr( tmpRe_fx[chA][chB], sub( hdrm_re[chA][chB], q_temp ) ); + tmpIm_fx[chA][chB] = L_shr( tmpIm_fx[chA][chB], sub( hdrm_im[chA][chB], q_temp ) ); + } + } + + matrixTransp2Mul_fx( tmpRe_fx, tmpIm_fx, &q_temp, Ure_fx, Uim_fx, &q_U, Pre_fx, Pim_fx, &q_P ); /* Nearest orthonormal matrix P to matrix A formulated */ + + /* These are the final formulas of the JAES publication M = Ky P Kx^(-1) */ + FOR( chA = 0; chA < BINAURAL_CHANNELS; chA++ ) + { + FOR( chB = 0; chB < BINAURAL_CHANNELS; chB++ ) + { + IF( EQ_32( Sx_fx[chB], 0 ) ) + { + Pre_fx[chA][chB] = BASOP_Util_Divide3232_Scale_cadence( Pre_fx[chA][chB], 4611686, &exp ); // 4611686 = 1e-12 in Q62 + q_Pre[chA][chB] = add( sub( q_P, 62 ), sub( 31, exp ) ); + Pim_fx[chA][chB] = BASOP_Util_Divide3232_Scale_cadence( Pim_fx[chA][chB], 4611686, &exp ); // 4611686 = 1e-12 in Q62 + q_Pim[chA][chB] = add( sub( q_P, 62 ), sub( 31, exp ) ); + } + ELSE + { + temp = BASOP_Util_Add_Mant32Exp( Sx_fx[chB], sub( 31, q_Sx ), EPSILON_MANT, EPSILON_EXP, &exp_temp ); + + Pre_fx[chA][chB] = BASOP_Util_Divide3232_Scale_cadence( Pre_fx[chA][chB], temp, &exp ); + q_Pre[chA][chB] = add( sub( q_P, sub( 31, exp_temp ) ), sub( 31, exp ) ); + Pim_fx[chA][chB] = BASOP_Util_Divide3232_Scale_cadence( Pim_fx[chA][chB], temp, &exp ); + q_Pim[chA][chB] = add( sub( q_P, sub( 31, exp_temp ) ), sub( 31, exp ) ); + } + } + } + minimum_s( q_Pre[0], i_mult( BINAURAL_CHANNELS, BINAURAL_CHANNELS ), &exp ); + q_P = s_min( q_P, exp ); + minimum_s( q_Pim[0], i_mult( BINAURAL_CHANNELS, BINAURAL_CHANNELS ), &exp ); + q_P = s_min( q_P, exp ); + + FOR( chA = 0; chA < BINAURAL_CHANNELS; chA++ ) + { + FOR( chB = 0; chB < BINAURAL_CHANNELS; chB++ ) + { + Pre_fx[chA][chB] = L_shr( Pre_fx[chA][chB], sub( q_Pre[chA][chB], q_P ) ); + Pim_fx[chA][chB] = L_shr( Pim_fx[chA][chB], sub( q_Pim[chA][chB], q_P ) ); + } + } + + matrixMul_fx( KyRe_fx, KyIm_fx, &q_ky, Pre_fx, Pim_fx, &q_P, tmpRe_fx, tmpIm_fx, &q_temp ); + + matrixTransp2Mul_fx( tmpRe_fx, tmpIm_fx, &q_temp, Uxre_fx, Uxim_fx, &q_Ux, Mre_fx, Mim_fx, q_M ); + + return; +} +#endif // 1 + #ifdef IVAS_FLOAT_FIXED static void getDirectPartGains_fx( diff --git a/lib_rend/ivas_dirac_rend.c b/lib_rend/ivas_dirac_rend.c index 5079c6d47..9cc95548d 100644 --- a/lib_rend/ivas_dirac_rend.c +++ b/lib_rend/ivas_dirac_rend.c @@ -343,11 +343,11 @@ ivas_error ivas_spat_hSpatParamRendCom_config_fx( hSpatParamRendCom = NULL; - IF( flag_config == DIRAC_RECONFIGURE ) + IF( EQ_32( flag_config, DIRAC_RECONFIGURE ) ) { hSpatParamRendCom = *hSpatParamRendCom_out; } - ELSE IF( flag_config == DIRAC_OPEN ) + ELSE IF( EQ_32( flag_config, DIRAC_OPEN ) ) { /*-----------------------------------------------------------------* * prepare library opening @@ -364,38 +364,47 @@ ivas_error ivas_spat_hSpatParamRendCom_config_fx( Word16 tmp1, tmp2, var1, var2; Word16 exp_tmp1 = 0; + move16(); tmp1 = BASOP_Util_Divide3232_Scale( output_Fs, FRAMES_PER_SEC, &exp_tmp1 ); Word16 exp_tmp2 = 0; + move16(); tmp2 = BASOP_Util_Divide1616_Scale( tmp1, CLDFB_NO_COL_MAX, &exp_tmp2 ); - exp_tmp2 = exp_tmp2 + ( exp_tmp1 - 15 ); + exp_tmp2 = add( exp_tmp2, sub( exp_tmp1, 15 ) ); Word16 exp_tmp3 = 0; + move16(); - IF( flag_config == DIRAC_OPEN ) + IF( EQ_32( flag_config, DIRAC_OPEN ) ) { hSpatParamRendCom->slot_size = shr( tmp2, 15 - exp_tmp2 ); // exp_tmp2 set16_fx( hSpatParamRendCom->subframe_nbslots, 0, MAX_JBM_SUBFRAMES_5MS ); set16_fx( hSpatParamRendCom->subframe_nbslots, JBM_CLDFB_SLOTS_IN_SUBFRAME, DEFAULT_JBM_SUBFRAMES_5MS ); hSpatParamRendCom->nb_subframes = DEFAULT_JBM_SUBFRAMES_5MS; + move16(); hSpatParamRendCom->subframes_rendered = 0; + move16(); hSpatParamRendCom->slots_rendered = 0; + move16(); hSpatParamRendCom->num_slots = DEFAULT_JBM_SUBFRAMES_5MS * JBM_CLDFB_SLOTS_IN_SUBFRAME; var1 = BASOP_Util_Divide3232_Scale( output_Fs, CLDFB_BANDWIDTH, &exp_tmp3 ); - var2 = shl( 1, 15 - exp_tmp3 - 1 ); - hSpatParamRendCom->num_freq_bands = shr( add( var1, var2 ), 15 - exp_tmp3 ); + var2 = shl( 1, sub( 15, add( exp_tmp3, 1 ) ) ); + hSpatParamRendCom->num_freq_bands = shr( add( var1, var2 ), sub( 15, exp_tmp3 ) ); hSpatParamRendCom->numSimultaneousDirections = 0; + move16(); hSpatParamRendCom->numParametricDirections = 0; + move16(); hSpatParamRendCom->numIsmDirections = 0; + move16(); } /*-----------------------------------------------------------------* * set input parameters *-----------------------------------------------------------------*/ - IF( ( ivas_format == SBA_FORMAT || ivas_format == SBA_ISM_FORMAT ) && flag_config == DIRAC_RECONFIGURE ) + IF( ( EQ_32( ivas_format, SBA_FORMAT ) || EQ_32( ivas_format, SBA_ISM_FORMAT ) ) && EQ_32( flag_config, DIRAC_RECONFIGURE ) ) { IF( hodirac_flag && hSpatParamRendCom->azimuth2 == NULL ) { - if ( ( error = ivas_dirac_allocate_parameters_fx( hSpatParamRendCom, 2 ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_dirac_allocate_parameters_fx( hSpatParamRendCom, 2 ) ), IVAS_ERR_OK ) ) { return error; } @@ -406,39 +415,50 @@ ivas_error ivas_spat_hSpatParamRendCom_config_fx( } } - IF( flag_config == DIRAC_OPEN ) + IF( EQ_32( flag_config, DIRAC_OPEN ) ) { hSpatParamRendCom->dirac_md_buffer_length = 0; + move16(); hSpatParamRendCom->dirac_bs_md_write_idx = 0; + move16(); hSpatParamRendCom->dirac_read_idx = 0; - IF( mc_mode == MC_MODE_MCMASA || masa_ext_rend_flag == 1 ) + move16(); + IF( EQ_32( mc_mode, MC_MODE_MCMASA ) || EQ_16( masa_ext_rend_flag, 1 ) ) { hSpatParamRendCom->dirac_md_buffer_length = MAX_PARAM_SPATIAL_SUBFRAMES; + move16(); set16_fx( hSpatParamRendCom->render_to_md_map, 0, MAX_JBM_SUBFRAMES_5MS * JBM_CLDFB_SLOTS_IN_SUBFRAME ); FOR( map_idx = 0; map_idx < DEFAULT_JBM_SUBFRAMES_5MS; map_idx++ ) { hSpatParamRendCom->render_to_md_map[map_idx] = map_idx; + move16(); } } - ELSE IF( ivas_format == MASA_FORMAT || ivas_format == MASA_ISM_FORMAT ) + ELSE IF( EQ_32( ivas_format, MASA_FORMAT ) || EQ_32( ivas_format, MASA_ISM_FORMAT ) ) { hSpatParamRendCom->dirac_md_buffer_length = MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR; + move16(); hSpatParamRendCom->dirac_bs_md_write_idx = DELAY_MASA_PARAM_DEC_SFR; + move16(); set16_fx( hSpatParamRendCom->render_to_md_map, 0, MAX_JBM_SUBFRAMES_5MS * JBM_CLDFB_SLOTS_IN_SUBFRAME ); FOR( map_idx = 0; map_idx < DEFAULT_JBM_SUBFRAMES_5MS; map_idx++ ) { hSpatParamRendCom->render_to_md_map[map_idx] = map_idx; + move16(); } } ELSE { Word16 num_slots_in_subfr; num_slots_in_subfr = dec_param_estim_flag ? CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES : 1; - hSpatParamRendCom->dirac_md_buffer_length = ( MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_DIRAC_PARAM_DEC_SFR ); + hSpatParamRendCom->dirac_md_buffer_length = add( MAX_PARAM_SPATIAL_SUBFRAMES, DELAY_DIRAC_PARAM_DEC_SFR ); + move16(); hSpatParamRendCom->dirac_bs_md_write_idx = DELAY_DIRAC_PARAM_DEC_SFR; + move16(); hSpatParamRendCom->dirac_read_idx = 0; + move16(); set16_fx( hSpatParamRendCom->render_to_md_map, 0, MAX_JBM_SUBFRAMES_5MS * JBM_CLDFB_SLOTS_IN_SUBFRAME ); FOR( map_idx = 0; map_idx < DEFAULT_JBM_SUBFRAMES_5MS * num_slots_in_subfr; map_idx++ ) @@ -447,14 +467,14 @@ ivas_error ivas_spat_hSpatParamRendCom_config_fx( } } - IF( ( error = ivas_dirac_allocate_parameters_fx( hSpatParamRendCom, 1 ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_dirac_allocate_parameters_fx( hSpatParamRendCom, 1 ) ), IVAS_ERR_OK ) ) { return error; } - IF( ivas_format == MASA_FORMAT || ivas_format == MASA_ISM_FORMAT || ( ( ivas_format == SBA_FORMAT || ivas_format == SBA_ISM_FORMAT ) && hodirac_flag ) ) + IF( EQ_32( ivas_format, MASA_FORMAT ) || EQ_32( ivas_format, MASA_ISM_FORMAT ) || ( ( EQ_32( ivas_format, SBA_FORMAT ) || EQ_32( ivas_format, SBA_ISM_FORMAT ) ) && hodirac_flag ) ) { - IF( ( error = ivas_dirac_allocate_parameters_fx( hSpatParamRendCom, 2 ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_dirac_allocate_parameters_fx( hSpatParamRendCom, 2 ) ), IVAS_ERR_OK ) ) { return error; } @@ -1253,15 +1273,17 @@ ivas_error ivas_dirac_alloc_mem( #endif hDirAC_mem->proto_power_smooth = NULL; hDirAC_mem->proto_power_diff_smooth = NULL; - hDirAC_mem->direct_responses_square = NULL; #ifdef IVAS_FLOAT_FIXED hDirAC_mem->proto_power_smooth_fx = NULL; hDirAC_mem->proto_power_diff_smooth_fx = NULL; hDirAC_mem->direct_responses_square_fx = NULL; +#else + hDirAC_mem->direct_responses_square = NULL; #endif - hDirAC_mem->frame_dec_f = NULL; #ifdef IVAS_FLOAT_FIXED hDirAC_mem->frame_dec_f_fx = NULL; +#else + hDirAC_mem->frame_dec_f = NULL; #endif if ( hDirACRend->synthesisConf != DIRAC_SYNTHESIS_GAIN_SHD ) { @@ -1307,13 +1329,13 @@ ivas_error ivas_dirac_alloc_mem( hDirAC_mem->proto_power_diff_smooth_q = 31; #endif +#ifndef IVAS_FLOAT_FIXED if ( ( hDirAC_mem->direct_responses_square = (float *) malloc( sizeof( float ) * size ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate stack memory for DirAC\n" ) ); } set_zero( hDirAC_mem->direct_responses_square, size ); - -#ifdef IVAS_FLOAT_FIXED +#else if ( ( hDirAC_mem->direct_responses_square_fx = (Word32 *) malloc( sizeof( Word32 ) * size ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate stack memory for DirAC\n" ) ); @@ -1322,11 +1344,12 @@ ivas_error ivas_dirac_alloc_mem( #endif if ( hDirACRend->proto_signal_decorr_on && ( renderer_type != RENDERER_BINAURAL_PARAMETRIC && renderer_type != RENDERER_BINAURAL_PARAMETRIC_ROOM && renderer_type != RENDERER_STEREO_PARAMETRIC ) ) { +#ifndef IVAS_FLOAT_FIXED if ( ( hDirAC_mem->frame_dec_f = (float *) malloc( sizeof( float ) * 2 * num_outputs_diff * num_freq_bands ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate stack memory for DirAC\n" ) ); } -#ifdef IVAS_FLOAT_FIXED +#else if ( ( hDirAC_mem->frame_dec_f_fx = (Word32 *) malloc( sizeof( Word32 ) * 2 * num_outputs_diff * num_freq_bands ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate stack memory for DirAC\n" ) ); @@ -1348,8 +1371,9 @@ ivas_error ivas_dirac_alloc_mem( hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_fx = hDirAC_mem->cy_auto_dir_smooth_fx; hDirACRend->h_output_synthesis_psd_state.q_cy_auto_dir_smooth = 0; move16(); -#endif +#else hDirACRend->h_output_synthesis_psd_state.direct_responses_square = hDirAC_mem->direct_responses_square; +#endif #ifdef IVAS_FLOAT_FIXED hDirACRend->h_output_synthesis_psd_state.direct_responses_square_fx = hDirAC_mem->direct_responses_square_fx; hDirACRend->h_output_synthesis_psd_state.direct_responses_square_q = Q31; @@ -1428,6 +1452,7 @@ ivas_error ivas_dirac_alloc_mem( #endif /*Responses (gains/factors)*/ +#ifndef IVAS_FLOAT_FIXED if ( ( hDirAC_mem->direct_responses = (float *) malloc( sizeof( float ) * size_ho ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate stack memory for DirAC\n" ) ); @@ -1437,7 +1462,7 @@ ivas_error ivas_dirac_alloc_mem( hDirACRend->h_output_synthesis_psd_state.direct_responses = hDirAC_mem->direct_responses; -#ifdef IVAS_FLOAT_FIXED +#else /*Responses (gains/factors)*/ if ( ( hDirAC_mem->direct_responses_fx = (Word32 *) malloc( sizeof( Word32 ) * size_ho ) ) == NULL ) { @@ -1451,19 +1476,21 @@ ivas_error ivas_dirac_alloc_mem( #endif /* Prototypes */ +#ifndef IVAS_FLOAT_FIXED hDirAC_mem->proto_direct_buffer_f = NULL; hDirAC_mem->proto_diffuse_buffer_f = NULL; -#ifdef IVAS_FLOAT_FIXED +#else hDirAC_mem->proto_direct_buffer_f_fx = NULL; hDirAC_mem->proto_diffuse_buffer_f_fx = NULL; #endif if ( renderer_type != RENDERER_BINAURAL_PARAMETRIC && renderer_type != RENDERER_BINAURAL_PARAMETRIC_ROOM && renderer_type != RENDERER_STEREO_PARAMETRIC ) { +#ifndef IVAS_FLOAT_FIXED if ( ( hDirAC_mem->proto_direct_buffer_f = (float *) malloc( sizeof( float ) * 2 * MAX_PARAM_SPATIAL_SUBFRAMES * num_protos_dir * num_freq_bands ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate stack memory for DirAC\n" ) ); } -#ifdef IVAS_FLOAT_FIXED +#else IF( ( hDirAC_mem->proto_direct_buffer_f_fx = (Word32 *) malloc( sizeof( Word32 ) * 2 * MAX_PARAM_SPATIAL_SUBFRAMES * num_protos_dir * num_freq_bands ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate stack memory for DirAC\n" ) ); @@ -1476,11 +1503,12 @@ ivas_error ivas_dirac_alloc_mem( { if ( hDirACRend->synthesisConf == DIRAC_SYNTHESIS_PSD_SHD ) { +#ifndef IVAS_FLOAT_FIXED if ( ( hDirAC_mem->proto_diffuse_buffer_f = (float *) malloc( sizeof( float ) * 2 * MAX_PARAM_SPATIAL_SUBFRAMES * size ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate stack memory for DirAC\n" ) ); } -#ifdef IVAS_FLOAT_FIXED +#else IF( ( hDirAC_mem->proto_diffuse_buffer_f_fx = (Word32 *) malloc( sizeof( Word32 ) * 2 * MAX_PARAM_SPATIAL_SUBFRAMES * size ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate stack memory for DirAC\n" ) ); @@ -1490,11 +1518,12 @@ ivas_error ivas_dirac_alloc_mem( } else { +#ifndef IVAS_FLOAT_FIXED if ( ( hDirAC_mem->proto_diffuse_buffer_f = (float *) malloc( sizeof( float ) * 2 * MAX_PARAM_SPATIAL_SUBFRAMES * num_outputs_diff * num_freq_bands ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate stack memory for DirAC\n" ) ); } -#ifdef IVAS_FLOAT_FIXED +#else IF( ( hDirAC_mem->proto_diffuse_buffer_f_fx = (Word32 *) malloc( sizeof( Word32 ) * 2 * MAX_PARAM_SPATIAL_SUBFRAMES * num_outputs_diff * num_freq_bands ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate stack memory for DirAC\n" ) ); @@ -1507,13 +1536,14 @@ ivas_error ivas_dirac_alloc_mem( #endif } } - hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f = hDirAC_mem->proto_direct_buffer_f; - hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f = hDirAC_mem->proto_diffuse_buffer_f; #ifdef IVAS_FLOAT_FIXED hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_fx = hDirAC_mem->proto_direct_buffer_f_fx; hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_fx = hDirAC_mem->proto_diffuse_buffer_f_fx; hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_len = hDirAC_mem->proto_diffuse_buffer_f_len; hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_q = Q31; +#else + hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f = hDirAC_mem->proto_diffuse_buffer_f; + hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f = hDirAC_mem->proto_direct_buffer_f; #endif /* Gains/power factors*/ hDirAC_mem->direct_power_factor = NULL; @@ -1561,8 +1591,8 @@ ivas_error ivas_dirac_alloc_mem( move16(); #endif - hDirAC_mem->reference_power = NULL; #ifndef IVAS_FLOAT_FIXED + hDirAC_mem->reference_power = NULL; hDirAC_mem->onset_filter = NULL; #endif #ifdef IVAS_FLOAT_FIXED @@ -1573,11 +1603,12 @@ ivas_error ivas_dirac_alloc_mem( { if ( renderer_type != RENDERER_BINAURAL_PARAMETRIC && renderer_type != RENDERER_BINAURAL_PARAMETRIC_ROOM && renderer_type != RENDERER_STEREO_PARAMETRIC ) { +#ifndef IVAS_FLOAT_FIXED if ( ( hDirAC_mem->reference_power = (float *) malloc( sizeof( float ) * 2 * num_freq_bands ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate stack memory for DirAC\n" ) ); } -#ifdef IVAS_FLOAT_FIXED +#else if ( ( hDirAC_mem->reference_power_fx = (Word32 *) malloc( sizeof( Word32 ) * 2 * num_freq_bands ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate stack memory for DirAC\n" ) ); @@ -1614,11 +1645,12 @@ ivas_error ivas_dirac_alloc_mem( { if ( num_protos_dir > 2 ) { +#ifndef IVAS_FLOAT_FIXED if ( ( hDirAC_mem->reference_power = (float *) malloc( sizeof( float ) * 5 * num_freq_bands ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate stack memory for DirAC\n" ) ); } -#ifdef IVAS_FLOAT_FIXED +#else if ( ( hDirAC_mem->reference_power_fx = (Word32 *) malloc( sizeof( Word32 ) * 5 * num_freq_bands ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate stack memory for DirAC\n" ) ); @@ -1691,10 +1723,10 @@ void ivas_dirac_free_mem_fx( { free( hDirAC_mem->proto_power_diff_smooth_fx ); } - IF( hDirAC_mem->direct_responses_square != NULL ) + /*IF( hDirAC_mem->direct_responses_square != NULL ) { free( hDirAC_mem->direct_responses_square ); - } + }*/ IF( hDirAC_mem->direct_responses_square_fx != NULL ) { free( hDirAC_mem->direct_responses_square_fx ); @@ -1703,8 +1735,8 @@ void ivas_dirac_free_mem_fx( { free( hDirAC_mem->frame_dec_f_fx ); } -#if 1 /* TODO: remove float free */ - IF( hDirAC_mem->frame_dec_f != NULL ) +#if 0 /* TODO: remove float free */ + IF (hDirAC_mem->frame_dec_f != NULL) { free( hDirAC_mem->frame_dec_f ); } @@ -1725,7 +1757,7 @@ void ivas_dirac_free_mem_fx( { free( hDirAC_mem->cy_auto_diff_smooth_fx ); } -#ifdef IVAS_FLOAT_FIXED_TO_BE_REMOVED +#ifndef IVAS_FLOAT_FIXED_TO_BE_REMOVED IF( hDirAC_mem->direct_responses != NULL ) { free( hDirAC_mem->direct_responses ); @@ -1735,20 +1767,18 @@ void ivas_dirac_free_mem_fx( { free( hDirAC_mem->direct_responses_fx ); } - IF( hDirAC_mem->proto_direct_buffer_f != NULL ) + /*IF( hDirAC_mem->proto_direct_buffer_f != NULL ) { free( hDirAC_mem->proto_direct_buffer_f ); - } + }*/ IF( hDirAC_mem->proto_direct_buffer_f_fx != NULL ) { free( hDirAC_mem->proto_direct_buffer_f_fx ); } -#if 1 /* TODO: remove float free */ - IF( hDirAC_mem->proto_diffuse_buffer_f != NULL ) + /*IF( hDirAC_mem->proto_diffuse_buffer_f != NULL ) { free( hDirAC_mem->proto_diffuse_buffer_f ); - } -#endif + }*/ IF( hDirAC_mem->proto_diffuse_buffer_f_fx != NULL ) { free( hDirAC_mem->proto_diffuse_buffer_f_fx ); @@ -1769,10 +1799,6 @@ void ivas_dirac_free_mem_fx( { free( hDirAC_mem->diffuse_power_factor_fx ); } - IF( hDirAC_mem->reference_power != NULL ) - { - free( hDirAC_mem->reference_power ); - } IF( hDirAC_mem->reference_power_fx != NULL ) { free( hDirAC_mem->reference_power_fx ); diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index 5ff6707a5..7e5eb9471 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -254,16 +254,19 @@ typedef struct ivas_spatial_parametric_rend_common_data_structure typedef struct dirac_dec_stack_mem { /*Decorrelator*/ - float *frame_dec_f; #ifdef IVAS_FLOAT_FIXED Word32 *frame_dec_f_fx; Word16 frame_dec_f_q; Word16 frame_dec_f_len; +#else + float *frame_dec_f; #endif /*Prototypes*/ +#ifndef IVAS_FLOAT_FIXED float *proto_direct_buffer_f; float *proto_diffuse_buffer_f; +#endif /*Prototype NRGs*/ float *proto_power_smooth; @@ -292,9 +295,10 @@ typedef struct dirac_dec_stack_mem #endif /*Directional responses (gains & Nrg)*/ +#ifndef IVAS_FLOAT_FIXED float *direct_responses; float *direct_responses_square; -#ifdef IVAS_FLOAT_FIXED +#else Word32 *direct_responses_fx; Word32 *direct_responses_square_fx; #endif @@ -308,8 +312,8 @@ typedef struct dirac_dec_stack_mem Word32 *cy_auto_diff_smooth_fx; #endif - float *reference_power; #ifndef IVAS_FLOAT_FIXED + float *reference_power; float *onset_filter; #else Word32 *reference_power_fx; @@ -360,9 +364,9 @@ typedef struct dirac_output_synthesis_params_structure typedef struct dirac_output_synthesis_state_structure { /* only pointer to local buffers */ +#ifndef IVAS_FLOAT_FIXED float *direct_responses; /* direct responses for DOA of current frame. Size: num_freq_bands*num_channels. */ float *direct_responses_square; -#ifndef IVAS_FLOAT_FIXED float *diffuse_responses_square; /* squared diffuse responses. Size: num_channels. */ #else Word32 *diffuse_responses_square_fx; /* squared diffuse responses. Size: num_channels. */ /* Q31 */ @@ -379,8 +383,10 @@ typedef struct dirac_output_synthesis_state_structure float *proto_power_diff_smooth_prev; /* only pointer to local buffers */ +#ifndef IVAS_FLOAT_FIXED float *proto_direct_buffer_f; /* Buffer for direct sound prototype signals. Size: 2*num_freq_bands*num_channels*buffer_length (complex interleaved). */ float *proto_diffuse_buffer_f; /* Buffer for diffuse sound prototype signals. Size: 2*num_freq_bands*num_channels*buffer_length (complex interleaved). */ +#endif /* Output gain memories */ float *gains_dir_prev; /* Direct sound gains of current synthesis block. Size: num_freq_bands*num_channel. */ @@ -907,6 +913,11 @@ typedef struct ivas_dirac_dec_binaural_data_structure Word32 ChCrossReOutPrev_fx[CLDFB_NO_CHANNELS_MAX]; Word32 ChCrossImOutPrev_fx[CLDFB_NO_CHANNELS_MAX]; + Word16 q_ChEne; + Word16 q_ChEneOut; + Word16 q_ChCross; + Word16 q_ChCrossOut; + Word16 ChEnePrev_e[BINAURAL_CHANNELS][CLDFB_NO_CHANNELS_MAX]; Word16 ChCrossRePrev_e[CLDFB_NO_CHANNELS_MAX]; Word16 ChCrossImPrev_e[CLDFB_NO_CHANNELS_MAX]; diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 7abd83ab9..4468ddfbe 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -14769,8 +14769,9 @@ static void intermidiate_ext_dirac_render( { IF( EQ_16( hDirACRend->panningConf, DIRAC_PANNING_VBAP ) ) { - hDirACRend->h_output_synthesis_psd_state.direct_responses_q = 30; - floatToFixed_arrL32( hDirACRend->h_output_synthesis_psd_state.direct_responses, hDirACRend->h_output_synthesis_psd_state.direct_responses_fx, hDirACRend->h_output_synthesis_psd_state.direct_responses_q, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir ) ); + Scale_sig32( hDirACRend->h_output_synthesis_psd_state.direct_responses_fx, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir ), sub( Q30, hDirACRend->h_output_synthesis_psd_state.direct_responses_q ) ); + hDirACRend->h_output_synthesis_psd_state.direct_responses_q = Q30; + // floatToFixed_arrL32( hDirACRend->h_output_synthesis_psd_state.direct_responses, hDirACRend->h_output_synthesis_psd_state.direct_responses_fx, hDirACRend->h_output_synthesis_psd_state.direct_responses_q, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir ) ); } else { @@ -14778,25 +14779,29 @@ static void intermidiate_ext_dirac_render( { if ( masa_band_mapping == NULL && hDirACRend->synthesisConf == DIRAC_SYNTHESIS_GAIN_SHD ) { - hDirACRend->h_output_synthesis_psd_state.direct_responses_q = 30; - floatToFixed_arrL32( hDirACRend->h_output_synthesis_psd_state.direct_responses, hDirACRend->h_output_synthesis_psd_state.direct_responses_fx, hDirACRend->h_output_synthesis_psd_state.direct_responses_q, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir ) ); + Scale_sig32( hDirACRend->h_output_synthesis_psd_state.direct_responses_fx, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir ), sub( Q30, hDirACRend->h_output_synthesis_psd_state.direct_responses_q ) ); + hDirACRend->h_output_synthesis_psd_state.direct_responses_q = Q30; + // floatToFixed_arrL32( hDirACRend->h_output_synthesis_psd_state.direct_responses, hDirACRend->h_output_synthesis_psd_state.direct_responses_fx, hDirACRend->h_output_synthesis_psd_state.direct_responses_q, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir ) ); } else if ( ( ( hDirACRend->synthesisConf == DIRAC_SYNTHESIS_GAIN_SHD ) && ( masa_band_mapping != NULL ) ) || hDirACRend->synthesisConf == DIRAC_SYNTHESIS_PSD_SHD || hDirACRend->synthesisConf == DIRAC_SYNTHESIS_MONO ) { - hDirACRend->h_output_synthesis_psd_state.direct_responses_q = 30; - floatToFixed_arrL32( hDirACRend->h_output_synthesis_psd_state.direct_responses, hDirACRend->h_output_synthesis_psd_state.direct_responses_fx, hDirACRend->h_output_synthesis_psd_state.direct_responses_q, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir ) ); + Scale_sig32( hDirACRend->h_output_synthesis_psd_state.direct_responses_fx, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir ), sub( Q30, hDirACRend->h_output_synthesis_psd_state.direct_responses_q ) ); + hDirACRend->h_output_synthesis_psd_state.direct_responses_q = Q30; + // floatToFixed_arrL32( hDirACRend->h_output_synthesis_psd_state.direct_responses, hDirACRend->h_output_synthesis_psd_state.direct_responses_fx, hDirACRend->h_output_synthesis_psd_state.direct_responses_q, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir ) ); } ELSE IF( EQ_16( hDirACRend->panningConf, DIRAC_PANNING_VBAP ) ) /*VBAP*/ { - hDirACRend->h_output_synthesis_psd_state.direct_responses_q = 30; - floatToFixed_arrL32( hDirACRend->h_output_synthesis_psd_state.direct_responses, hDirACRend->h_output_synthesis_psd_state.direct_responses_fx, hDirACRend->h_output_synthesis_psd_state.direct_responses_q, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir ) ); + Scale_sig32( hDirACRend->h_output_synthesis_psd_state.direct_responses_fx, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir ), sub( Q30, hDirACRend->h_output_synthesis_psd_state.direct_responses_q ) ); + hDirACRend->h_output_synthesis_psd_state.direct_responses_q = Q30; + // floatToFixed_arrL32( hDirACRend->h_output_synthesis_psd_state.direct_responses, hDirACRend->h_output_synthesis_psd_state.direct_responses_fx, hDirACRend->h_output_synthesis_psd_state.direct_responses_q, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir ) ); } } else if ( hDirACRend->panningConf == DIRAC_PANNING_VBAP ) /*VBAP*/ { - hDirACRend->h_output_synthesis_psd_state.direct_responses_q = 30; - floatToFixed_arrL32( hDirACRend->h_output_synthesis_psd_state.direct_responses, hDirACRend->h_output_synthesis_psd_state.direct_responses_fx, hDirACRend->h_output_synthesis_psd_state.direct_responses_q, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir ) ); + Scale_sig32( hDirACRend->h_output_synthesis_psd_state.direct_responses_fx, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir ), sub( Q30, hDirACRend->h_output_synthesis_psd_state.direct_responses_q ) ); + hDirACRend->h_output_synthesis_psd_state.direct_responses_q = Q30; + // floatToFixed_arrL32(hDirACRend->h_output_synthesis_psd_state.direct_responses, hDirACRend->h_output_synthesis_psd_state.direct_responses_fx, hDirACRend->h_output_synthesis_psd_state.direct_responses_q, i_mult(hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir)); } } } @@ -14855,8 +14860,22 @@ static void intermidiate_ext_dirac_render( hDirACRend->h_freq_domain_decorr_ap_state->q_decorr_buffer = 31 - tmp_e; } - f2me_buf( hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f, hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_fx, &hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_q, hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_len ); - hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_q = 31 - hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_q; + if ( hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_len > 0 ) + { + Word16 shift; + Word32 tmp1, tmp2; + maximum_abs_32_fx( hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_fx, hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_len, &tmp2 ); + maximum_abs_32_fx( hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_fx, hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_len, &tmp1 ); + + shift = s_min( ( tmp1 == 0 ) ? 31 : norm_l( tmp1 ), ( tmp2 == 0 ) ? 31 : norm_l( tmp2 ) ); + Word16 hr_exp = 31 - shift; + + Scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_fx, hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_len, ( 31 - hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_q ) - hr_exp ); + hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_q = 31 - hr_exp; + } + + // f2me_buf(hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f, hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_fx, &hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_q, hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_len); + // hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_q = 31 - hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_q; FOR( slot_idx = 0; slot_idx < hSpatParamRendCom->subframe_nbslots[subframe_idx]; slot_idx++ ) { /* CLDFB Analysis*/ @@ -14865,10 +14884,10 @@ static void intermidiate_ext_dirac_render( hMasaExtRend->cldfbAnaRend[ch]->Q_cldfb_state = Q11; } } - if ( DirAC_mem.frame_dec_f ) - { - // f2me_buf(DirAC_mem.frame_dec_f, DirAC_mem.frame_dec_f_fx, &hDirACRend->proto_frame_dec_f_q, DirAC_mem.frame_dec_f_len); - } + // if(DirAC_mem.frame_dec_f) + //{ + // //f2me_buf(DirAC_mem.frame_dec_f, DirAC_mem.frame_dec_f_fx, &hDirACRend->proto_frame_dec_f_q, DirAC_mem.frame_dec_f_len); + // } hDirACRend->proto_frame_dec_f_q = 31 - hDirACRend->proto_frame_dec_f_q; if ( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth ) { @@ -14894,23 +14913,21 @@ static void intermidiate_ext_dirac_render( hDirACRend->h_output_synthesis_psd_state.direct_power_factor[i] = fix_to_float( hDirACRend->h_output_synthesis_psd_state.direct_power_factor_fx[i], hDirACRend->h_output_synthesis_psd_state.direct_power_factor_q ); hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor[i] = fix_to_float( hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_fx[i], hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_q ); } - IF( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) - { - fixedToFloat_arrL( hDirACRend->h_output_synthesis_psd_state.direct_responses_fx, hDirACRend->h_output_synthesis_psd_state.direct_responses, hDirACRend->h_output_synthesis_psd_state.direct_responses_q, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir ) ); - } - ELSE - { - fixedToFloat_arrL( hDirACRend->h_output_synthesis_psd_state.direct_responses_fx, hDirACRend->h_output_synthesis_psd_state.direct_responses, hDirACRend->h_output_synthesis_psd_state.direct_responses_q, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir ) ); - IF( hDirACRend->synthesisConf != DIRAC_SYNTHESIS_GAIN_SHD ) - { - fixedToFloat_arrL( hDirACRend->h_output_synthesis_psd_state.direct_responses_square_fx, hDirACRend->h_output_synthesis_psd_state.direct_responses_square, hDirACRend->h_output_synthesis_psd_state.direct_responses_square_q, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir ) ); - } - } - if ( DirAC_mem.reference_power ) - { - fixedToFloat_arrL( DirAC_mem.reference_power_fx, DirAC_mem.reference_power, DirAC_mem.reference_power_q, DirAC_mem.reference_power_len ); - } + /* + IF(EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) + { + fixedToFloat_arrL( hDirACRend->h_output_synthesis_psd_state.direct_responses_fx, hDirACRend->h_output_synthesis_psd_state.direct_responses, hDirACRend->h_output_synthesis_psd_state.direct_responses_q, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir ) ); + } + ELSE + { + fixedToFloat_arrL( hDirACRend->h_output_synthesis_psd_state.direct_responses_fx, hDirACRend->h_output_synthesis_psd_state.direct_responses, hDirACRend->h_output_synthesis_psd_state.direct_responses_q, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir ) ); + IF( hDirACRend->synthesisConf != DIRAC_SYNTHESIS_GAIN_SHD ) + { + fixedToFloat_arrL( hDirACRend->h_output_synthesis_psd_state.direct_responses_square_fx, hDirACRend->h_output_synthesis_psd_state.direct_responses_square, hDirACRend->h_output_synthesis_psd_state.direct_responses_square_q, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir ) ); + } + } + }*/ if ( hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_prev ) { fixedToFloat_arrL( hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_prev_fx, hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_prev, hDirACRend->h_output_synthesis_psd_state.q_cy_auto_dir_smooth_prev, hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_prev_len ); @@ -14947,7 +14964,15 @@ static void intermidiate_ext_dirac_render( { fixedToFloat_arrL( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_len ); } - fixedToFloat_arrL32( hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_fx, hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f, hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_len ); + if ( hDirACRend->h_output_synthesis_psd_state.gains_diff_prev ) + { + fixedToFloat_arrL( hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_fx, hDirACRend->h_output_synthesis_psd_state.gains_diff_prev, hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_q, hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_len ); + } + if ( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth ) + { + fixedToFloat_arrL( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_len ); + } + // fixedToFloat_arrL32( hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_fx, hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f, hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_len); if ( hDirACRend->proto_signal_decorr_on == 1 ) { fixedToFloat_arrL32( hDirACRend->h_freq_domain_decorr_ap_state->decorr_buffer_fx, hDirACRend->h_freq_domain_decorr_ap_state->decorr_buffer, hDirACRend->h_freq_domain_decorr_ap_state->q_decorr_buffer, hDirACRend->h_freq_domain_decorr_ap_state->decorr_buffer_len ); @@ -14957,7 +14982,7 @@ static void intermidiate_ext_dirac_render( fixedToFloat_arrL( hDirACRend->h_freq_domain_decorr_ap_state->reverb_energy_smooth_fx, hDirACRend->h_freq_domain_decorr_ap_state->reverb_energy_smooth, hDirACRend->h_freq_domain_decorr_ap_state->q_reverb_energy_smooth, hDirACRend->num_protos_diff * hDirACRend->h_freq_domain_decorr_ap_params->max_band_decorr ); } } - fixedToFloat_arrL32( hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_fx, hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f, hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_q, hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_len ); + // fixedToFloat_arrL32( hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_fx, hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f, hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_q, hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_len); fixedToFloat_arrL32( hDirACRend->proto_frame_f_fx, hDirACRend->proto_frame_f, hDirACRend->proto_frame_f_q, hDirACRend->proto_frame_f_len ); // fixedToFloat_arrL32(DirAC_mem.frame_dec_f_fx, DirAC_mem.frame_dec_f, DirAC_mem.frame_dec_f_q, DirAC_mem.frame_dec_f_len); -- GitLab From 19b2f623146b69e008aed7ea473b9b645dd12f60 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Mon, 3 Jun 2024 12:57:02 +0530 Subject: [PATCH 2/2] Clang formatting changes --- lib_com/fft_fx.c | 704 +++++++++---------- lib_com/ivas_fb_mixer.c | 2 +- lib_com/ivas_spar_com.c | 22 +- lib_dec/ivas_init_dec.c | 2 +- lib_rend/ivas_dirac_dec_binaural_functions.c | 244 ++++--- 5 files changed, 486 insertions(+), 488 deletions(-) diff --git a/lib_com/fft_fx.c b/lib_com/fft_fx.c index 20f7ec62c..7a0d153eb 100644 --- a/lib_com/fft_fx.c +++ b/lib_com/fft_fx.c @@ -157,8 +157,8 @@ static void fft4_5( Word32 *x, Word32 *y, const Word16 *Idx ); static void fft5_4( Word16 n1, Word32 *zRe, Word32 *zIm, const Word16 *Idx ); void DoRTFTn_fx_ivas( - Word32 *x, /* i/o: real part of input and output data */ - Word32 *y, /* i/o: imaginary part of input and output data */ + Word32 *x, /* i/o: real part of input and output data */ + Word32 *y, /* i/o: imaginary part of input and output data */ const Word16 n /* i : size of the FFT n=(2^k) up to 1024 */ ); /*-----------------------------------------------------------------* @@ -999,8 +999,8 @@ static void fft32_5( *-----------------------------------------------------------------*/ static void fft16_ivas( - Word32 *x, /* i/o: real part of input and output data */ - Word32 *y, /* i/o: imaginary part of input and output data */ + Word32 *x, /* i/o: real part of input and output data */ + Word32 *y, /* i/o: imaginary part of input and output data */ const Word16 *Idx /* i : pointer of the address table */ ) { @@ -1671,13 +1671,13 @@ static void cftfsub( l = 2; - IF ( GT_16(n, 8) ) + IF( GT_16( n, 8 ) ) { cft1st( n, a, w ); l = 8; - WHILE ( LT_16(shl(l, 2 ), n) ) + WHILE( LT_16( shl( l, 2 ), n ) ) { cftmdl( n, l, a, w ); l = shl( l, 2 ); @@ -2015,12 +2015,12 @@ static void cftbsub( Word32 x0r, x0i, x1r, x1i, x2r, x2i, x3r, x3i; l = 2; - IF ( GT_16(n, 8) ) + IF( GT_16( n, 8 ) ) { cft1st( n, a, w ); l = 8; - WHILE ( LT_16(shl(l, 2), n) ) + WHILE( LT_16( shl( l, 2 ), n ) ) { cftmdl( n, l, a, w ); l = shl( l, 2 ); @@ -2111,8 +2111,8 @@ static void rftbsub( Word16 j, k, kk, ks, m; Word16 wkr, wki; Word32 xr, xi, yr, yi; - a[1] = L_negate(a[1]); - m = shr(n, 1); + a[1] = L_negate( a[1] ); + m = shr( n, 1 ); ks = 2 * nc / m; kk = 0; FOR( j = 2; j < m; j += 2 ) @@ -2121,14 +2121,14 @@ static void rftbsub( kk += ks; wkr = sub( (Word16) 0x4000, c[nc - kk] ); wki = c[kk]; - xr = L_sub(a[j], a[k]); - xi = L_add(a[j + 1], a[k + 1]); - yr = L_add(Mpy_32_16_1(xr, wkr), Mpy_32_16_1(xi, wki)); - yi = L_sub(Mpy_32_16_1(xi, wkr), Mpy_32_16_1(xr, wki)); - a[j] = L_sub(a[j], yr); - a[j + 1] = L_sub(yi, a[j + 1]); - a[k] = L_add(a[k], yr); - a[k + 1] = L_sub(yi, a[k + 1]); + xr = L_sub( a[j], a[k] ); + xi = L_add( a[j + 1], a[k + 1] ); + yr = L_add( Mpy_32_16_1( xr, wkr ), Mpy_32_16_1( xi, wki ) ); + yi = L_sub( Mpy_32_16_1( xi, wkr ), Mpy_32_16_1( xr, wki ) ); + a[j] = L_sub( a[j], yr ); + a[j + 1] = L_sub( yi, a[j + 1] ); + a[k] = L_add( a[k], yr ); + a[k + 1] = L_sub( yi, a[k + 1] ); } a[m + 1] = L_negate( a[m + 1] ); @@ -2146,12 +2146,12 @@ static void dctsub( Word16 wkr, wki; Word32 xr; - m = shr(n, 1); + m = shr( n, 1 ); ks = nc / n; kk = 0; FOR( j = 1; j < m; j++ ) { - k = sub(n, j); + k = sub( n, j ); kk += ks; wkr = sub( c[kk], c[nc - kk] ); wki = add( c[kk], c[nc - kk] ); @@ -2185,17 +2185,17 @@ void edct2_fx_ivas( Copy32( in, a, n ); nw = ip[0]; - IF ( GT_16(n, shl( nw, 2 ) ) ) + IF( GT_16( n, shl( nw, 2 ) ) ) { - nw = shr(n, 2); + nw = shr( n, 2 ); } nc = ip[1]; - IF ( GT_16(n, nc) ) + IF( GT_16( n, nc ) ) { nc = n; } - IF ( LT_16(isgn, 0) ) + IF( LT_16( isgn, 0 ) ) { xr = a[n - 1]; FOR( j = n - 2; j >= 2; j -= 2 ) @@ -2206,7 +2206,7 @@ void edct2_fx_ivas( a[1] = L_sub( a[0], xr ); a[0] = L_add( a[0], xr ); - IF ( GT_16(n, 4) ) + IF( GT_16( n, 4 ) ) { rftbsub( n, a, nc, w + nw ); bitrv2_SR( n, ip + 2, a ); @@ -2218,16 +2218,16 @@ void edct2_fx_ivas( } } - IF ( GE_16(isgn, 0) ) + IF( GE_16( isgn, 0 ) ) { a[0] = L_shr( a[0], 1 ); } dctsub( n, a, nc, w + nw ); - IF ( GE_16(isgn, 0) ) + IF( GE_16( isgn, 0 ) ) { - IF ( GT_16(n, 4) ) + IF( GT_16( n, 4 ) ) { bitrv2_SR( n, ip + 2, a ); cftfsub( n, a, w ); @@ -2254,8 +2254,8 @@ void edct2_fx_ivas( } void DoRTFTn_fx_ivas( - Word32 *x, /* i/o: real part of input and output data */ - Word32 *y, /* i/o: imaginary part of input and output data */ + Word32 *x, /* i/o: real part of input and output data */ + Word32 *y, /* i/o: imaginary part of input and output data */ const Word16 n /* i : size of the FFT up to 1024 */ ) { @@ -2349,7 +2349,7 @@ void fft3_fx_ivas( Z2 = &Z1[m]; z2 = &Z2[0]; /* Z2 = &Z[2m]; */ x = &X[0]; - FOR ( i = 0; i < n / 3; i++ ) + FOR( i = 0; i < n / 3; i++ ) { *z0++ = *x++; /* Z0[i] = X[3i]; */ *z1++ = *x++; /* Z1[i] = X[3i+1]; */ @@ -2371,121 +2371,121 @@ void fft3_fx_ivas( RZ2 = &Z2[0]; IZ2 = &Z2[m]; - c1_step = negate(step); + c1_step = negate( step ); s1_step = step; - c2_step = negate(shl(step, 1)); - s2_step = shl(step, 1); - c1_ind = add(T_SIN_PI_2, c1_step); + c2_step = negate( shl( step, 1 ) ); + s2_step = shl( step, 1 ); + c1_ind = add( T_SIN_PI_2, c1_step ); s1_ind = s1_step; - c2_ind = add(T_SIN_PI_2, c2_step); + c2_ind = add( T_SIN_PI_2, c2_step ); s2_ind = s2_step; /* special case: i = 0 */ - RY[0] = L_add(RZ0[0], L_add(RZ1[0], RZ2[0])); + RY[0] = L_add( RZ0[0], L_add( RZ1[0], RZ2[0] ) ); /* first 3/12 */ - for (i = 1; i < 3 * m / 8; i++, c1_ind = add(c1_ind, c1_step), s1_ind = add(s1_ind, s1_step), c2_ind = add(c2_ind,c2_step), s2_ind = add(s2_ind, s2_step)) - { - RY[i] = L_add(RZ0[i], L_add(Mpy_32_16_1(RZ1[i], t_sin[c1_ind]), - L_add(Mpy_32_16_1(IZ1[-i], t_sin[s1_ind]), - L_add(Mpy_32_16_1(RZ2[i], t_sin[c2_ind]), - Mpy_32_16_1(IZ2[-i], t_sin[s2_ind]))))); - IY[-i] = L_sub(IZ0[-i], L_add(L_sub(Mpy_32_16_1(RZ1[i], t_sin[s1_ind]), - Mpy_32_16_1(IZ1[-i], t_sin[c1_ind])), - L_sub(Mpy_32_16_1(RZ2[i], t_sin[s2_ind]), - Mpy_32_16_1(IZ2[-i], t_sin[c2_ind])))); + for ( i = 1; i < 3 * m / 8; i++, c1_ind = add( c1_ind, c1_step ), s1_ind = add( s1_ind, s1_step ), c2_ind = add( c2_ind, c2_step ), s2_ind = add( s2_ind, s2_step ) ) + { + RY[i] = L_add( RZ0[i], L_add( Mpy_32_16_1( RZ1[i], t_sin[c1_ind] ), + L_add( Mpy_32_16_1( IZ1[-i], t_sin[s1_ind] ), + L_add( Mpy_32_16_1( RZ2[i], t_sin[c2_ind] ), + Mpy_32_16_1( IZ2[-i], t_sin[s2_ind] ) ) ) ) ); + IY[-i] = L_sub( IZ0[-i], L_add( L_sub( Mpy_32_16_1( RZ1[i], t_sin[s1_ind] ), + Mpy_32_16_1( IZ1[-i], t_sin[c1_ind] ) ), + L_sub( Mpy_32_16_1( RZ2[i], t_sin[s2_ind] ), + Mpy_32_16_1( IZ2[-i], t_sin[c2_ind] ) ) ) ); } /* next 1/12 */ - for ( ; i < 4 * m / 8; i++, c1_ind = add(c1_ind, c1_step), s1_ind = add(s1_ind, s1_step), c2_ind = sub(c2_ind, c2_step), s2_ind = sub(s2_ind, s2_step) ) - { - RY[i] = L_add(RZ0[i], L_sub(L_add(Mpy_32_16_1(RZ1[i], t_sin[c1_ind]), - Mpy_32_16_1(IZ1[-i], t_sin[s1_ind])), - L_sub(Mpy_32_16_1(RZ2[i], t_sin[c2_ind]), - Mpy_32_16_1(IZ2[-i], t_sin[s2_ind])))); - IY[-i] = L_sub(IZ0[-i], L_sub(Mpy_32_16_1(RZ1[ i], t_sin[s1_ind]), - L_sub(Mpy_32_16_1(IZ1[-i], t_sin[c1_ind]), - L_add(Mpy_32_16_1(RZ2[ i], t_sin[s2_ind]), - Mpy_32_16_1(IZ2[-i], t_sin[c2_ind]))))); + for ( ; i < 4 * m / 8; i++, c1_ind = add( c1_ind, c1_step ), s1_ind = add( s1_ind, s1_step ), c2_ind = sub( c2_ind, c2_step ), s2_ind = sub( s2_ind, s2_step ) ) + { + RY[i] = L_add( RZ0[i], L_sub( L_add( Mpy_32_16_1( RZ1[i], t_sin[c1_ind] ), + Mpy_32_16_1( IZ1[-i], t_sin[s1_ind] ) ), + L_sub( Mpy_32_16_1( RZ2[i], t_sin[c2_ind] ), + Mpy_32_16_1( IZ2[-i], t_sin[s2_ind] ) ) ) ); + IY[-i] = L_sub( IZ0[-i], L_sub( Mpy_32_16_1( RZ1[i], t_sin[s1_ind] ), + L_sub( Mpy_32_16_1( IZ1[-i], t_sin[c1_ind] ), + L_add( Mpy_32_16_1( RZ2[i], t_sin[s2_ind] ), + Mpy_32_16_1( IZ2[-i], t_sin[c2_ind] ) ) ) ) ); } /* special case: i = m/2 i.e. 1/3 */ - RY[i] = L_add(RZ0[i], - L_sub(Mpy_32_16_1(RZ1[i], t_sin[c1_ind]), - Mpy_32_16_1(RZ2[i], t_sin[c2_ind]))); - IY[-i] = L_negate(L_add(Mpy_32_16_1(RZ1[i], t_sin[s1_ind]), - Mpy_32_16_1(RZ2[i], t_sin[s2_ind]))); + RY[i] = L_add( RZ0[i], + L_sub( Mpy_32_16_1( RZ1[i], t_sin[c1_ind] ), + Mpy_32_16_1( RZ2[i], t_sin[c2_ind] ) ) ); + IY[-i] = L_negate( L_add( Mpy_32_16_1( RZ1[i], t_sin[s1_ind] ), + Mpy_32_16_1( RZ2[i], t_sin[s2_ind] ) ) ); i++; - c1_ind = add(c1_ind, c1_step); - s1_ind = add(s1_ind, s1_step); - c2_ind = sub(c2_ind, c2_step); - s2_ind = sub(s2_ind, s2_step); + c1_ind = add( c1_ind, c1_step ); + s1_ind = add( s1_ind, s1_step ); + c2_ind = sub( c2_ind, c2_step ); + s2_ind = sub( s2_ind, s2_step ); /* next 2/12 */ - for ( j = i - 2; i < 6 * m / 8; i++, j--, c1_ind = add(c1_ind, c1_step), s1_ind = add(s1_ind, s1_step), c2_ind = sub(c2_ind, c2_step), s2_ind = sub(s2_ind, s2_step) ) + for ( j = i - 2; i < 6 * m / 8; i++, j--, c1_ind = add( c1_ind, c1_step ), s1_ind = add( s1_ind, s1_step ), c2_ind = sub( c2_ind, c2_step ), s2_ind = sub( s2_ind, s2_step ) ) { - RY[i] = L_add(RZ0[j], L_sub(Mpy_32_16_1(RZ1[j], t_sin[c1_ind]), - L_add(Mpy_32_16_1(IZ1[-j], t_sin[s1_ind]), - L_add(Mpy_32_16_1(RZ2[j], t_sin[c2_ind]), - Mpy_32_16_1(IZ2[-j], t_sin[s2_ind]))))); + RY[i] = L_add( RZ0[j], L_sub( Mpy_32_16_1( RZ1[j], t_sin[c1_ind] ), + L_add( Mpy_32_16_1( IZ1[-j], t_sin[s1_ind] ), + L_add( Mpy_32_16_1( RZ2[j], t_sin[c2_ind] ), + Mpy_32_16_1( IZ2[-j], t_sin[s2_ind] ) ) ) ) ); - IY[-i] = L_negate(L_add(IZ0[-j], L_add(Mpy_32_16_1(RZ1[j], t_sin[s1_ind]), - L_add(Mpy_32_16_1(IZ1[-j], t_sin[c1_ind]), - L_sub(Mpy_32_16_1(RZ2[j], t_sin[s2_ind]), - Mpy_32_16_1(IZ2[-j], t_sin[c2_ind])))))); + IY[-i] = L_negate( L_add( IZ0[-j], L_add( Mpy_32_16_1( RZ1[j], t_sin[s1_ind] ), + L_add( Mpy_32_16_1( IZ1[-j], t_sin[c1_ind] ), + L_sub( Mpy_32_16_1( RZ2[j], t_sin[s2_ind] ), + Mpy_32_16_1( IZ2[-j], t_sin[c2_ind] ) ) ) ) ) ); } /*--------------------------half--------------------------*/ /* next 2/12 */ - for ( ; i < 8 * m / 8; i++, j--, c1_ind = sub(c1_ind, c1_step), s1_ind = sub(s1_ind, s1_step), c2_ind = add(c2_ind, c2_step), s2_ind = add(s2_ind, s2_step) ) - { - RY[i] = L_sub(RZ0[j], L_add(Mpy_32_16_1(RZ1[j], t_sin[c1_ind]), - L_add(Mpy_32_16_1(IZ1[-j], t_sin[s1_ind]), - L_sub(Mpy_32_16_1(RZ2[j], t_sin[c2_ind]), - Mpy_32_16_1(IZ2[-j], t_sin[s2_ind]))))); - IY[-i] = L_negate(L_add(IZ0[-j], L_sub(Mpy_32_16_1(RZ1[j], t_sin[s1_ind]), - L_add(Mpy_32_16_1(IZ1[-j], t_sin[c1_ind]), - L_add(Mpy_32_16_1(RZ2[j], t_sin[s2_ind]), - Mpy_32_16_1(IZ2[-j], t_sin[c2_ind])))))); + for ( ; i < 8 * m / 8; i++, j--, c1_ind = sub( c1_ind, c1_step ), s1_ind = sub( s1_ind, s1_step ), c2_ind = add( c2_ind, c2_step ), s2_ind = add( s2_ind, s2_step ) ) + { + RY[i] = L_sub( RZ0[j], L_add( Mpy_32_16_1( RZ1[j], t_sin[c1_ind] ), + L_add( Mpy_32_16_1( IZ1[-j], t_sin[s1_ind] ), + L_sub( Mpy_32_16_1( RZ2[j], t_sin[c2_ind] ), + Mpy_32_16_1( IZ2[-j], t_sin[s2_ind] ) ) ) ) ); + IY[-i] = L_negate( L_add( IZ0[-j], L_sub( Mpy_32_16_1( RZ1[j], t_sin[s1_ind] ), + L_add( Mpy_32_16_1( IZ1[-j], t_sin[c1_ind] ), + L_add( Mpy_32_16_1( RZ2[j], t_sin[s2_ind] ), + Mpy_32_16_1( IZ2[-j], t_sin[c2_ind] ) ) ) ) ) ); } /* special case: i = m, i.e 2/3 */ - RY[i] = L_sub(RZ0[j], L_add(Mpy_32_16_1(RZ1[j], t_sin[c1_ind]), - Mpy_32_16_1(RZ2[j], t_sin[c2_ind]))); - IY[-i++] = L_sub(Mpy_32_16_1(RZ2[j], t_sin[s2_ind]), - Mpy_32_16_1(RZ1[j], t_sin[s1_ind])); - c1_ind = sub(c1_ind, c1_step), s1_ind = sub(s1_ind, s1_step), c2_ind = add(c2_ind, c2_step), s2_ind = add(s2_ind, s2_step); + RY[i] = L_sub( RZ0[j], L_add( Mpy_32_16_1( RZ1[j], t_sin[c1_ind] ), + Mpy_32_16_1( RZ2[j], t_sin[c2_ind] ) ) ); + IY[-i++] = L_sub( Mpy_32_16_1( RZ2[j], t_sin[s2_ind] ), + Mpy_32_16_1( RZ1[j], t_sin[s1_ind] ) ); + c1_ind = sub( c1_ind, c1_step ), s1_ind = sub( s1_ind, s1_step ), c2_ind = add( c2_ind, c2_step ), s2_ind = add( s2_ind, s2_step ); /* next 1/12 */ - for ( j = 1; i < 9 * m / 8; i++, j++, c1_ind = sub(c1_ind, c1_step), s1_ind = sub(s1_ind, s1_step), c2_ind = add(c2_ind, c2_step), s2_ind = add(s2_ind, s2_step) ) - { - RY[i] = L_sub(RZ0[j], L_sub(Mpy_32_16_1(RZ1[j], t_sin[c1_ind]), - L_sub(Mpy_32_16_1(IZ1[-j], t_sin[s1_ind]), - L_add(Mpy_32_16_1(RZ2[j], t_sin[c2_ind]), - Mpy_32_16_1(IZ2[-j], t_sin[s2_ind]))))); - IY[-i] = L_sub(IZ0[-j], L_add(Mpy_32_16_1(RZ1[j], t_sin[s1_ind]), - L_sub(Mpy_32_16_1(IZ1[-j], t_sin[c1_ind]), - L_sub(Mpy_32_16_1(RZ2[j], t_sin[s2_ind]), - Mpy_32_16_1(IZ2[-j], t_sin[c2_ind]))))); + for ( j = 1; i < 9 * m / 8; i++, j++, c1_ind = sub( c1_ind, c1_step ), s1_ind = sub( s1_ind, s1_step ), c2_ind = add( c2_ind, c2_step ), s2_ind = add( s2_ind, s2_step ) ) + { + RY[i] = L_sub( RZ0[j], L_sub( Mpy_32_16_1( RZ1[j], t_sin[c1_ind] ), + L_sub( Mpy_32_16_1( IZ1[-j], t_sin[s1_ind] ), + L_add( Mpy_32_16_1( RZ2[j], t_sin[c2_ind] ), + Mpy_32_16_1( IZ2[-j], t_sin[s2_ind] ) ) ) ) ); + IY[-i] = L_sub( IZ0[-j], L_add( Mpy_32_16_1( RZ1[j], t_sin[s1_ind] ), + L_sub( Mpy_32_16_1( IZ1[-j], t_sin[c1_ind] ), + L_sub( Mpy_32_16_1( RZ2[j], t_sin[s2_ind] ), + Mpy_32_16_1( IZ2[-j], t_sin[c2_ind] ) ) ) ) ); } /* last 3/12 */ - for ( ; i < 12 * m / 8; i++, j++, c1_ind = sub(c1_ind, c1_step), s1_ind = sub(s1_ind, s1_step), c2_ind = sub(c2_ind, c2_step), s2_ind = sub(s2_ind, s2_step) ) - { - RY[i] = L_sub(RZ0[j], L_sub(L_sub(Mpy_32_16_1(RZ1[j], t_sin[c1_ind]), - Mpy_32_16_1(IZ1[-j], t_sin[s1_ind])), - L_sub(Mpy_32_16_1(RZ2[j], t_sin[c2_ind]), - Mpy_32_16_1(IZ2[-j], t_sin[s2_ind])))); - IY[-i] = L_sub(IZ0[-j], L_sub(L_add(Mpy_32_16_1(RZ1[j], t_sin[s1_ind]), - Mpy_32_16_1(IZ1[-j], t_sin[c1_ind])), - L_add(Mpy_32_16_1(RZ2[j], t_sin[s2_ind]), - Mpy_32_16_1(IZ2[-j], t_sin[c2_ind])))); + for ( ; i < 12 * m / 8; i++, j++, c1_ind = sub( c1_ind, c1_step ), s1_ind = sub( s1_ind, s1_step ), c2_ind = sub( c2_ind, c2_step ), s2_ind = sub( s2_ind, s2_step ) ) + { + RY[i] = L_sub( RZ0[j], L_sub( L_sub( Mpy_32_16_1( RZ1[j], t_sin[c1_ind] ), + Mpy_32_16_1( IZ1[-j], t_sin[s1_ind] ) ), + L_sub( Mpy_32_16_1( RZ2[j], t_sin[c2_ind] ), + Mpy_32_16_1( IZ2[-j], t_sin[s2_ind] ) ) ) ); + IY[-i] = L_sub( IZ0[-j], L_sub( L_add( Mpy_32_16_1( RZ1[j], t_sin[s1_ind] ), + Mpy_32_16_1( IZ1[-j], t_sin[c1_ind] ) ), + L_add( Mpy_32_16_1( RZ2[j], t_sin[s2_ind] ), + Mpy_32_16_1( IZ2[-j], t_sin[c2_ind] ) ) ) ); } /* special case: i = 3*m/2 */ - RY[i] = L_sub(RZ0[j], L_sub(Mpy_32_16_1(RZ1[j], t_sin[c1_ind]), - Mpy_32_16_1(RZ2[j], t_sin[c2_ind]))); + RY[i] = L_sub( RZ0[j], L_sub( Mpy_32_16_1( RZ1[j], t_sin[c1_ind] ), + Mpy_32_16_1( RZ2[j], t_sin[c2_ind] ) ) ); return; } @@ -2542,15 +2542,15 @@ void ifft3_fx_ivas( /* Inverse butterflies of order 3. */ /* Construction of Y0 */ - RY0[0] = L_add(RZ0[0], L_add(RZ1[0], RZ2[0])); - FOR ( i = 1; i < m / 2; i++ ) + RY0[0] = L_add( RZ0[0], L_add( RZ1[0], RZ2[0] ) ); + FOR( i = 1; i < m / 2; i++ ) { - RY0[i] = L_add(RZ0[i], L_add(RZ1[i], RZ2[-i])); - IY0[-i] = L_add(IZ0[-i], L_sub(IZ1[-i], IZ2[i])); + RY0[i] = L_add( RZ0[i], L_add( RZ1[i], RZ2[-i] ) ); + IY0[-i] = L_add( IZ0[-i], L_sub( IZ1[-i], IZ2[i] ) ); } /* m/2 */ - RY0[i] = L_add(RZ0[i], L_add(RZ1[i], RZ2[-i])); + RY0[i] = L_add( RZ0[i], L_add( RZ1[i], RZ2[-i] ) ); /* Construction of Y1 */ c0_ind = T_SIN_PI_2; @@ -2560,57 +2560,57 @@ void ifft3_fx_ivas( c2_ind = T_SIN_PI_2 * 1 / 3; s2_ind = T_SIN_PI_2 * 2 / 3; - RY1[0] = L_sub(Mpy_32_16_1(RZ0[0], t_sin[c0_ind]), - L_add(Mpy_32_16_1(RZ1[0], t_sin[c1_ind]), - L_add(Mpy_32_16_1(RZ2[0], t_sin[c2_ind]), - L_add(Mpy_32_16_1(IZ1[0], t_sin[s1_ind]), - Mpy_32_16_1(IZ2[0], t_sin[s2_ind]))))); - - c0_ind = sub(c0_ind, step); - s0_ind = add(s0_ind, step); - c1_ind = add(c1_ind, step); - s1_ind = sub(s1_ind, step); - c2_ind = sub(c2_ind, step); - s2_ind = add(s2_ind, step); - for ( i = 1; i < m / 4; i++, c0_ind = sub(c0_ind, step), s0_ind = add(s0_ind, step), c1_ind = add(c1_ind, step), s1_ind = sub(s1_ind, step), c2_ind = sub(c2_ind, step), s2_ind = add(s2_ind, step) ) - { - RY1[i] = L_sub(Mpy_32_16_1(RZ0[i], t_sin[c0_ind]), - L_add(Mpy_32_16_1(RZ1[i], t_sin[c1_ind]), - L_add(Mpy_32_16_1(RZ2[-i], t_sin[c2_ind]), - L_add(Mpy_32_16_1(IZ0[-i], t_sin[s0_ind]), - L_add(Mpy_32_16_1(IZ1[-i], t_sin[s1_ind]), - Mpy_32_16_1(IZ2[i], t_sin[s2_ind])))))); - IY1[-i] = L_add(L_sub(Mpy_32_16_1(IZ0[-i], t_sin[c0_ind]), - Mpy_32_16_1(IZ1[-i], t_sin[c1_ind])), - L_add(Mpy_32_16_1(IZ2[i], t_sin[c2_ind]), - L_add(Mpy_32_16_1(RZ0[i], t_sin[s0_ind]), - L_sub(Mpy_32_16_1(RZ1[i], t_sin[s1_ind]), - Mpy_32_16_1(RZ2[-i], t_sin[s2_ind]))))); + RY1[0] = L_sub( Mpy_32_16_1( RZ0[0], t_sin[c0_ind] ), + L_add( Mpy_32_16_1( RZ1[0], t_sin[c1_ind] ), + L_add( Mpy_32_16_1( RZ2[0], t_sin[c2_ind] ), + L_add( Mpy_32_16_1( IZ1[0], t_sin[s1_ind] ), + Mpy_32_16_1( IZ2[0], t_sin[s2_ind] ) ) ) ) ); + + c0_ind = sub( c0_ind, step ); + s0_ind = add( s0_ind, step ); + c1_ind = add( c1_ind, step ); + s1_ind = sub( s1_ind, step ); + c2_ind = sub( c2_ind, step ); + s2_ind = add( s2_ind, step ); + for ( i = 1; i < m / 4; i++, c0_ind = sub( c0_ind, step ), s0_ind = add( s0_ind, step ), c1_ind = add( c1_ind, step ), s1_ind = sub( s1_ind, step ), c2_ind = sub( c2_ind, step ), s2_ind = add( s2_ind, step ) ) + { + RY1[i] = L_sub( Mpy_32_16_1( RZ0[i], t_sin[c0_ind] ), + L_add( Mpy_32_16_1( RZ1[i], t_sin[c1_ind] ), + L_add( Mpy_32_16_1( RZ2[-i], t_sin[c2_ind] ), + L_add( Mpy_32_16_1( IZ0[-i], t_sin[s0_ind] ), + L_add( Mpy_32_16_1( IZ1[-i], t_sin[s1_ind] ), + Mpy_32_16_1( IZ2[i], t_sin[s2_ind] ) ) ) ) ) ); + IY1[-i] = L_add( L_sub( Mpy_32_16_1( IZ0[-i], t_sin[c0_ind] ), + Mpy_32_16_1( IZ1[-i], t_sin[c1_ind] ) ), + L_add( Mpy_32_16_1( IZ2[i], t_sin[c2_ind] ), + L_add( Mpy_32_16_1( RZ0[i], t_sin[s0_ind] ), + L_sub( Mpy_32_16_1( RZ1[i], t_sin[s1_ind] ), + Mpy_32_16_1( RZ2[-i], t_sin[s2_ind] ) ) ) ) ); } - for ( ; i < m / 2; i++, c0_ind = sub(c0_ind, step), s0_ind = add(s0_ind, step), c1_ind = add(c1_ind, step), s1_ind = sub(s1_ind, step), c2_ind = add(c2_ind, step), s2_ind = sub(s2_ind, step) ) - { - RY1[i] = L_sub(Mpy_32_16_1(RZ0[i], t_sin[c0_ind]), - L_add(L_sub(Mpy_32_16_1(RZ1[i], t_sin[c1_ind]), - Mpy_32_16_1(RZ2[-i], t_sin[c2_ind])), - L_add(Mpy_32_16_1(IZ0[-i], t_sin[s0_ind]), - L_add(Mpy_32_16_1(IZ1[-i], t_sin[s1_ind]), - Mpy_32_16_1(IZ2[i], t_sin[s2_ind]))))); - IY1[-i] = L_sub(Mpy_32_16_1(IZ0[-i], t_sin[c0_ind]), - L_sub(L_add(Mpy_32_16_1(IZ1[-i], t_sin[c1_ind]), - Mpy_32_16_1(IZ2[i], t_sin[c2_ind])), - L_add(Mpy_32_16_1(RZ0[i], t_sin[s0_ind]), - L_sub(Mpy_32_16_1(RZ1[i], t_sin[s1_ind]), - Mpy_32_16_1(RZ2[-i], t_sin[s2_ind]))))); + for ( ; i < m / 2; i++, c0_ind = sub( c0_ind, step ), s0_ind = add( s0_ind, step ), c1_ind = add( c1_ind, step ), s1_ind = sub( s1_ind, step ), c2_ind = add( c2_ind, step ), s2_ind = sub( s2_ind, step ) ) + { + RY1[i] = L_sub( Mpy_32_16_1( RZ0[i], t_sin[c0_ind] ), + L_add( L_sub( Mpy_32_16_1( RZ1[i], t_sin[c1_ind] ), + Mpy_32_16_1( RZ2[-i], t_sin[c2_ind] ) ), + L_add( Mpy_32_16_1( IZ0[-i], t_sin[s0_ind] ), + L_add( Mpy_32_16_1( IZ1[-i], t_sin[s1_ind] ), + Mpy_32_16_1( IZ2[i], t_sin[s2_ind] ) ) ) ) ); + IY1[-i] = L_sub( Mpy_32_16_1( IZ0[-i], t_sin[c0_ind] ), + L_sub( L_add( Mpy_32_16_1( IZ1[-i], t_sin[c1_ind] ), + Mpy_32_16_1( IZ2[i], t_sin[c2_ind] ) ), + L_add( Mpy_32_16_1( RZ0[i], t_sin[s0_ind] ), + L_sub( Mpy_32_16_1( RZ1[i], t_sin[s1_ind] ), + Mpy_32_16_1( RZ2[-i], t_sin[s2_ind] ) ) ) ) ); } /* m/2 */ - RY1[i] = L_sub(Mpy_32_16_1(RZ0[i], t_sin[c0_ind]), - L_add(L_sub(Mpy_32_16_1(RZ1[i], t_sin[c1_ind]), - Mpy_32_16_1(RZ2[-i], t_sin[c2_ind])), - L_add(Mpy_32_16_1(IZ0[-i], t_sin[s0_ind]), - L_add(Mpy_32_16_1(IZ1[-i], t_sin[s1_ind]), - Mpy_32_16_1(IZ2[i], t_sin[s2_ind]))))); + RY1[i] = L_sub( Mpy_32_16_1( RZ0[i], t_sin[c0_ind] ), + L_add( L_sub( Mpy_32_16_1( RZ1[i], t_sin[c1_ind] ), + Mpy_32_16_1( RZ2[-i], t_sin[c2_ind] ) ), + L_add( Mpy_32_16_1( IZ0[-i], t_sin[s0_ind] ), + L_add( Mpy_32_16_1( IZ1[-i], t_sin[s1_ind] ), + Mpy_32_16_1( IZ2[i], t_sin[s2_ind] ) ) ) ) ); /* Construction of Y2 */ c0_ind = T_SIN_PI_2; @@ -2620,89 +2620,89 @@ void ifft3_fx_ivas( c2_ind = T_SIN_PI_2 * 1 / 3; s2_ind = T_SIN_PI_2 * 2 / 3; step2 = 2 * step; - RY2[0] = L_sub(Mpy_32_16_1(RZ0[0], t_sin[c0_ind]), - L_sub(L_add(Mpy_32_16_1(RZ1[0], t_sin[c1_ind]), - Mpy_32_16_1(RZ2[0], t_sin[c2_ind])), - L_add(Mpy_32_16_1(IZ1[0], t_sin[s1_ind]), - Mpy_32_16_1(IZ2[0], t_sin[s2_ind])))); - - c0_ind = sub(c0_ind, step2); - s0_ind = add(s0_ind, step2); - c1_ind = sub(c1_ind, step2); - s1_ind = add(s1_ind, step2); - c2_ind = add(c2_ind, step2); - s2_ind = sub(s2_ind, step2); - for ( i = 1; i < m / 8; i++, c0_ind = sub(c0_ind, step2), s0_ind = add(s0_ind, step2), c1_ind = sub(c1_ind, step2), s1_ind = add(s1_ind, step2), c2_ind = add(c2_ind, step2), s2_ind = sub(s2_ind, step2) ) - { - RY2[i] = L_sub(Mpy_32_16_1(RZ0[i], t_sin[c0_ind]), - L_add(L_add(Mpy_32_16_1(RZ1[i], t_sin[c1_ind]), - Mpy_32_16_1(RZ2[-i], t_sin[c2_ind])), - L_sub(Mpy_32_16_1(IZ0[-i], t_sin[s0_ind]), - L_add(Mpy_32_16_1(IZ1[-i], t_sin[s1_ind]), - Mpy_32_16_1(IZ2[i], t_sin[s2_ind]))))); - IY2[-i] = L_add(L_sub(Mpy_32_16_1(IZ0[-i], t_sin[c0_ind]), - Mpy_32_16_1(IZ1[-i], t_sin[c1_ind])), - L_add(Mpy_32_16_1(IZ2[i], t_sin[c2_ind]), - L_sub(Mpy_32_16_1(RZ0[i], t_sin[s0_ind]), - L_sub(Mpy_32_16_1(RZ1[i], t_sin[s1_ind]), - Mpy_32_16_1(RZ2[-i], t_sin[s2_ind]))))); + RY2[0] = L_sub( Mpy_32_16_1( RZ0[0], t_sin[c0_ind] ), + L_sub( L_add( Mpy_32_16_1( RZ1[0], t_sin[c1_ind] ), + Mpy_32_16_1( RZ2[0], t_sin[c2_ind] ) ), + L_add( Mpy_32_16_1( IZ1[0], t_sin[s1_ind] ), + Mpy_32_16_1( IZ2[0], t_sin[s2_ind] ) ) ) ); + + c0_ind = sub( c0_ind, step2 ); + s0_ind = add( s0_ind, step2 ); + c1_ind = sub( c1_ind, step2 ); + s1_ind = add( s1_ind, step2 ); + c2_ind = add( c2_ind, step2 ); + s2_ind = sub( s2_ind, step2 ); + for ( i = 1; i < m / 8; i++, c0_ind = sub( c0_ind, step2 ), s0_ind = add( s0_ind, step2 ), c1_ind = sub( c1_ind, step2 ), s1_ind = add( s1_ind, step2 ), c2_ind = add( c2_ind, step2 ), s2_ind = sub( s2_ind, step2 ) ) + { + RY2[i] = L_sub( Mpy_32_16_1( RZ0[i], t_sin[c0_ind] ), + L_add( L_add( Mpy_32_16_1( RZ1[i], t_sin[c1_ind] ), + Mpy_32_16_1( RZ2[-i], t_sin[c2_ind] ) ), + L_sub( Mpy_32_16_1( IZ0[-i], t_sin[s0_ind] ), + L_add( Mpy_32_16_1( IZ1[-i], t_sin[s1_ind] ), + Mpy_32_16_1( IZ2[i], t_sin[s2_ind] ) ) ) ) ); + IY2[-i] = L_add( L_sub( Mpy_32_16_1( IZ0[-i], t_sin[c0_ind] ), + Mpy_32_16_1( IZ1[-i], t_sin[c1_ind] ) ), + L_add( Mpy_32_16_1( IZ2[i], t_sin[c2_ind] ), + L_sub( Mpy_32_16_1( RZ0[i], t_sin[s0_ind] ), + L_sub( Mpy_32_16_1( RZ1[i], t_sin[s1_ind] ), + Mpy_32_16_1( RZ2[-i], t_sin[s2_ind] ) ) ) ) ); } - for ( ; i < m / 4; i++, c0_ind = sub(c0_ind, step2), s0_ind = add(s0_ind, step2), c1_ind = add(c1_ind, step2), s1_ind = sub(s1_ind, step2), c2_ind = add(c2_ind, step2), s2_ind = sub(s2_ind, step2) ) - { - RY2[i] = L_add(Mpy_32_16_1(RZ0[i], t_sin[c0_ind]), - L_sub(Mpy_32_16_1(RZ1[i], t_sin[c1_ind]), - L_sub(L_add(Mpy_32_16_1(RZ2[-i], t_sin[c2_ind]), - Mpy_32_16_1(IZ0[-i], t_sin[s0_ind])), - L_add(Mpy_32_16_1(IZ1[-i], t_sin[s1_ind]), - Mpy_32_16_1(IZ2[i], t_sin[s2_ind]))))); - IY2[-i] = L_add(Mpy_32_16_1(IZ0[-i], t_sin[c0_ind]), - L_add(Mpy_32_16_1(IZ1[-i], t_sin[c1_ind]), - L_add(Mpy_32_16_1(IZ2[i], t_sin[c2_ind]), - L_sub(Mpy_32_16_1(RZ0[i], t_sin[s0_ind]), - L_sub(Mpy_32_16_1(RZ1[i], t_sin[s1_ind]), - Mpy_32_16_1(RZ2[-i], t_sin[s2_ind])))))); + for ( ; i < m / 4; i++, c0_ind = sub( c0_ind, step2 ), s0_ind = add( s0_ind, step2 ), c1_ind = add( c1_ind, step2 ), s1_ind = sub( s1_ind, step2 ), c2_ind = add( c2_ind, step2 ), s2_ind = sub( s2_ind, step2 ) ) + { + RY2[i] = L_add( Mpy_32_16_1( RZ0[i], t_sin[c0_ind] ), + L_sub( Mpy_32_16_1( RZ1[i], t_sin[c1_ind] ), + L_sub( L_add( Mpy_32_16_1( RZ2[-i], t_sin[c2_ind] ), + Mpy_32_16_1( IZ0[-i], t_sin[s0_ind] ) ), + L_add( Mpy_32_16_1( IZ1[-i], t_sin[s1_ind] ), + Mpy_32_16_1( IZ2[i], t_sin[s2_ind] ) ) ) ) ); + IY2[-i] = L_add( Mpy_32_16_1( IZ0[-i], t_sin[c0_ind] ), + L_add( Mpy_32_16_1( IZ1[-i], t_sin[c1_ind] ), + L_add( Mpy_32_16_1( IZ2[i], t_sin[c2_ind] ), + L_sub( Mpy_32_16_1( RZ0[i], t_sin[s0_ind] ), + L_sub( Mpy_32_16_1( RZ1[i], t_sin[s1_ind] ), + Mpy_32_16_1( RZ2[-i], t_sin[s2_ind] ) ) ) ) ) ); } - for ( ; i < 3 * m / 8; i++, c0_ind = sub(c0_ind, step2), s0_ind = add(s0_ind, step2), c1_ind = add(c1_ind, step2), s1_ind = sub(s1_ind, step2), c2_ind = sub(c2_ind, step2), s2_ind = add(s2_ind, step2) ) - { - RY2[i] = L_sub(L_add(Mpy_32_16_1(RZ0[i], t_sin[c0_ind]), - Mpy_32_16_1(RZ1[i], t_sin[c1_ind])), - L_sub(L_add(Mpy_32_16_1(RZ2[-i], t_sin[c2_ind]), - Mpy_32_16_1(IZ0[-i], t_sin[s0_ind])), - L_sub(Mpy_32_16_1(IZ1[-i], t_sin[s1_ind]), - Mpy_32_16_1(IZ2[i], t_sin[s2_ind])))); - IY2[-i] = L_sub(L_add(Mpy_32_16_1(IZ0[-i], t_sin[c0_ind]), - L_add(Mpy_32_16_1(IZ1[-i], t_sin[c1_ind]), - L_add(Mpy_32_16_1(IZ2[i], t_sin[c2_ind]), - Mpy_32_16_1(RZ0[i], t_sin[s0_ind])))), - L_add(Mpy_32_16_1(RZ1[i], t_sin[s1_ind]), - Mpy_32_16_1(RZ2[-i], t_sin[s2_ind]))); + for ( ; i < 3 * m / 8; i++, c0_ind = sub( c0_ind, step2 ), s0_ind = add( s0_ind, step2 ), c1_ind = add( c1_ind, step2 ), s1_ind = sub( s1_ind, step2 ), c2_ind = sub( c2_ind, step2 ), s2_ind = add( s2_ind, step2 ) ) + { + RY2[i] = L_sub( L_add( Mpy_32_16_1( RZ0[i], t_sin[c0_ind] ), + Mpy_32_16_1( RZ1[i], t_sin[c1_ind] ) ), + L_sub( L_add( Mpy_32_16_1( RZ2[-i], t_sin[c2_ind] ), + Mpy_32_16_1( IZ0[-i], t_sin[s0_ind] ) ), + L_sub( Mpy_32_16_1( IZ1[-i], t_sin[s1_ind] ), + Mpy_32_16_1( IZ2[i], t_sin[s2_ind] ) ) ) ); + IY2[-i] = L_sub( L_add( Mpy_32_16_1( IZ0[-i], t_sin[c0_ind] ), + L_add( Mpy_32_16_1( IZ1[-i], t_sin[c1_ind] ), + L_add( Mpy_32_16_1( IZ2[i], t_sin[c2_ind] ), + Mpy_32_16_1( RZ0[i], t_sin[s0_ind] ) ) ) ), + L_add( Mpy_32_16_1( RZ1[i], t_sin[s1_ind] ), + Mpy_32_16_1( RZ2[-i], t_sin[s2_ind] ) ) ); } - for ( ; i < m / 2; i++, c0_ind = add(c0_ind, step2), s0_ind = sub(s0_ind, step2), c1_ind = add(c1_ind, step2), s1_ind = sub(s1_ind, step2), c2_ind = sub(c2_ind, step2), s2_ind = add(s2_ind, step2) ) - { - RY2[i] = L_sub(L_sub(Mpy_32_16_1(RZ1[i], t_sin[c1_ind]), - Mpy_32_16_1(RZ0[i], t_sin[c0_ind])), - L_sub(L_add(Mpy_32_16_1(RZ2[-i], t_sin[c2_ind]), - Mpy_32_16_1(IZ0[-i], t_sin[s0_ind])), - L_sub(Mpy_32_16_1(IZ1[-i], t_sin[s1_ind]), - Mpy_32_16_1(IZ2[i], t_sin[s2_ind])))); - IY2[-i] = L_add(L_sub(Mpy_32_16_1(IZ1[-i], t_sin[c1_ind]), - Mpy_32_16_1(IZ0[-i], t_sin[c0_ind])), - L_sub(L_add(Mpy_32_16_1(IZ2[i], t_sin[c2_ind]), - Mpy_32_16_1(RZ0[i], t_sin[s0_ind])), - L_add(Mpy_32_16_1(RZ1[i], t_sin[s1_ind]), - Mpy_32_16_1(RZ2[-i], t_sin[s2_ind])))); + for ( ; i < m / 2; i++, c0_ind = add( c0_ind, step2 ), s0_ind = sub( s0_ind, step2 ), c1_ind = add( c1_ind, step2 ), s1_ind = sub( s1_ind, step2 ), c2_ind = sub( c2_ind, step2 ), s2_ind = add( s2_ind, step2 ) ) + { + RY2[i] = L_sub( L_sub( Mpy_32_16_1( RZ1[i], t_sin[c1_ind] ), + Mpy_32_16_1( RZ0[i], t_sin[c0_ind] ) ), + L_sub( L_add( Mpy_32_16_1( RZ2[-i], t_sin[c2_ind] ), + Mpy_32_16_1( IZ0[-i], t_sin[s0_ind] ) ), + L_sub( Mpy_32_16_1( IZ1[-i], t_sin[s1_ind] ), + Mpy_32_16_1( IZ2[i], t_sin[s2_ind] ) ) ) ); + IY2[-i] = L_add( L_sub( Mpy_32_16_1( IZ1[-i], t_sin[c1_ind] ), + Mpy_32_16_1( IZ0[-i], t_sin[c0_ind] ) ), + L_sub( L_add( Mpy_32_16_1( IZ2[i], t_sin[c2_ind] ), + Mpy_32_16_1( RZ0[i], t_sin[s0_ind] ) ), + L_add( Mpy_32_16_1( RZ1[i], t_sin[s1_ind] ), + Mpy_32_16_1( RZ2[-i], t_sin[s2_ind] ) ) ) ); } /* m/2 */ - RY2[i] = L_sub(L_sub(Mpy_32_16_1(RZ1[i], t_sin[c1_ind]), - Mpy_32_16_1(RZ0[i], t_sin[c0_ind])), - L_sub(L_add(Mpy_32_16_1(RZ2[-i], t_sin[c2_ind]), - Mpy_32_16_1(IZ0[-i], t_sin[s0_ind])), - L_sub(Mpy_32_16_1(IZ1[-i], t_sin[s1_ind]), - Mpy_32_16_1(IZ2[i], t_sin[s2_ind])))); + RY2[i] = L_sub( L_sub( Mpy_32_16_1( RZ1[i], t_sin[c1_ind] ), + Mpy_32_16_1( RZ0[i], t_sin[c0_ind] ) ), + L_sub( L_add( Mpy_32_16_1( RZ2[-i], t_sin[c2_ind] ), + Mpy_32_16_1( IZ0[-i], t_sin[s0_ind] ) ), + L_sub( Mpy_32_16_1( IZ1[-i], t_sin[s1_ind] ), + Mpy_32_16_1( IZ2[i], t_sin[s2_ind] ) ) ) ); /* Compute the inverse FFT for all 3 blocks. */ ifft_rel_fx32( RY0, m, order ); @@ -2714,12 +2714,12 @@ void ifft3_fx_ivas( y2 = RY2; /* Interlacing and scaling, scale = 1/3 */ - scale = (Word16)(0x2AAB); - FOR ( i = 0; i < n; ) + scale = (Word16) ( 0x2AAB ); + FOR( i = 0; i < n; ) { - X[i++] = Mpy_32_16_1(( *y0++ ), scale); - X[i++] = Mpy_32_16_1(( *y1++ ), scale); - X[i++] = Mpy_32_16_1(( *y2++ ), scale); + X[i++] = Mpy_32_16_1( ( *y0++ ), scale ); + X[i++] = Mpy_32_16_1( ( *y1++ ), scale ); + X[i++] = Mpy_32_16_1( ( *y2++ ), scale ); } return; @@ -2735,26 +2735,26 @@ static void rfft_post( Word16 s, c; Word16 i = 0; - tmp1 = L_add(buf[0], buf[1]); - buf[1] = L_sub(buf[0], buf[1]); + tmp1 = L_add( buf[0], buf[1] ); + buf[1] = L_sub( buf[0], buf[1] ); buf[0] = tmp1; - FOR ( i = 1; i <= ( len + 2 ) / 4; i++ ) + FOR( i = 1; i <= ( len + 2 ) / 4; i++ ) { s = sine_table[i]; /* sin(pi*i/(len/2)) */ c = sine_table[i + len / 4]; /* cos(pi*i/(len/2)) */ - tmp1 = L_sub(buf[2 * i], buf[len - 2 * i]); - tmp2 = L_add(buf[2 * i + 1], buf[len - 2 * i + 1]); - tmp3 = L_sub(Mpy_32_16_1(tmp1, s), Mpy_32_16_1(tmp2, c)); /* real part of j*W(k,N)*[T(k) - T'(N-k)] */ - tmp4 = L_add(Mpy_32_16_1(tmp1, c), Mpy_32_16_1(tmp2, s)); /* imag part of j*W(k,N)*[T(k) - T'(N-k)] */ - tmp1 = L_add(buf[2 * i], buf[len - 2 * i]); - tmp2 = L_sub(buf[2 * i + 1], buf[len - 2 * i + 1]); - - buf[2 * i] = L_shr(L_sub(tmp1, tmp3), 1); - buf[2 * i + 1] = L_shr(L_sub(tmp2, tmp4), 1); - buf[len - 2 * i] = L_shr(L_add(tmp1, tmp3), 1); - buf[len - 2 * i + 1] = L_negate(L_shr(L_add(tmp2, tmp4), 1)); + tmp1 = L_sub( buf[2 * i], buf[len - 2 * i] ); + tmp2 = L_add( buf[2 * i + 1], buf[len - 2 * i + 1] ); + tmp3 = L_sub( Mpy_32_16_1( tmp1, s ), Mpy_32_16_1( tmp2, c ) ); /* real part of j*W(k,N)*[T(k) - T'(N-k)] */ + tmp4 = L_add( Mpy_32_16_1( tmp1, c ), Mpy_32_16_1( tmp2, s ) ); /* imag part of j*W(k,N)*[T(k) - T'(N-k)] */ + tmp1 = L_add( buf[2 * i], buf[len - 2 * i] ); + tmp2 = L_sub( buf[2 * i + 1], buf[len - 2 * i + 1] ); + + buf[2 * i] = L_shr( L_sub( tmp1, tmp3 ), 1 ); + buf[2 * i + 1] = L_shr( L_sub( tmp2, tmp4 ), 1 ); + buf[len - 2 * i] = L_shr( L_add( tmp1, tmp3 ), 1 ); + buf[len - 2 * i + 1] = L_negate( L_shr( L_add( tmp2, tmp4 ), 1 ) ); } } @@ -2763,31 +2763,31 @@ static void rfft_pre( Word32 *buf, const Word16 len ) { - const Word16 scale = (Word16)(1.0f / len * 32768.0); + const Word16 scale = (Word16) ( 1.0f / len * 32768.0 ); Word32 tmp1, tmp2, tmp3, tmp4; Word16 s, c; Word16 i = 0; - tmp1 = L_add(buf[0], buf[1]); - buf[1] = Mpy_32_16_1(L_sub(buf[0], buf[1]), scale); - buf[0] = Mpy_32_16_1(tmp1, scale); + tmp1 = L_add( buf[0], buf[1] ); + buf[1] = Mpy_32_16_1( L_sub( buf[0], buf[1] ), scale ); + buf[0] = Mpy_32_16_1( tmp1, scale ); - FOR ( i = 1; i <= ( len + 2 ) / 4; i++ ) + FOR( i = 1; i <= ( len + 2 ) / 4; i++ ) { s = sine_table[i]; /* sin(pi*i/(len/2)) */ c = sine_table[i + len / 4]; /* cos(pi*i/(len/2)) */ - tmp1 = L_sub(buf[2 * i], buf[len - 2 * i]); - tmp2 = L_add(buf[2 * i + 1], buf[len - 2 * i + 1]); - tmp3 = L_add(Mpy_32_16_1(tmp1, s), Mpy_32_16_1(tmp2, c)); /* real part of j*W(k,N)*[T(k) - T'(N-k)] */ - tmp4 = L_sub(Mpy_32_16_1(tmp2, s), Mpy_32_16_1(tmp1, c)); /* imag part of j*W(k,N)*[T(k) - T'(N-k)] */ - tmp1 = L_add(buf[2 * i], buf[len - 2 * i]); - tmp2 = L_sub(buf[2 * i + 1], buf[len - 2 * i + 1]); - - buf[2 * i] = Mpy_32_16_1(L_add(tmp1, tmp3), scale); - buf[2 * i + 1] = L_negate(Mpy_32_16_1(L_add(tmp2, tmp4), scale)); - buf[len - 2 * i] = Mpy_32_16_1(L_sub(tmp1, tmp3), scale); - buf[len - 2 * i + 1] = Mpy_32_16_1(L_sub(tmp2, tmp4), scale); + tmp1 = L_sub( buf[2 * i], buf[len - 2 * i] ); + tmp2 = L_add( buf[2 * i + 1], buf[len - 2 * i + 1] ); + tmp3 = L_add( Mpy_32_16_1( tmp1, s ), Mpy_32_16_1( tmp2, c ) ); /* real part of j*W(k,N)*[T(k) - T'(N-k)] */ + tmp4 = L_sub( Mpy_32_16_1( tmp2, s ), Mpy_32_16_1( tmp1, c ) ); /* imag part of j*W(k,N)*[T(k) - T'(N-k)] */ + tmp1 = L_add( buf[2 * i], buf[len - 2 * i] ); + tmp2 = L_sub( buf[2 * i + 1], buf[len - 2 * i + 1] ); + + buf[2 * i] = Mpy_32_16_1( L_add( tmp1, tmp3 ), scale ); + buf[2 * i + 1] = L_negate( Mpy_32_16_1( L_add( tmp2, tmp4 ), scale ) ); + buf[len - 2 * i] = Mpy_32_16_1( L_sub( tmp1, tmp3 ), scale ); + buf[len - 2 * i + 1] = Mpy_32_16_1( L_sub( tmp2, tmp4 ), scale ); } return; @@ -2801,47 +2801,47 @@ Word16 RFFTN_fx( { assert( len <= 640 && len > 0 ); - IF ( EQ_16(len, 640) ) + IF( EQ_16( len, 640 ) ) { Word32 x[320], y[320]; Word16 i; - IF ( NE_16(sign, -1) ) + IF( NE_16( sign, -1 ) ) { rfft_pre( sine_table, data, len ); } - FOR ( i = 0; i < 320; i++ ) + FOR( i = 0; i < 320; i++ ) { x[i] = data[2 * i]; y[i] = data[2 * i + 1]; } DoRTFT320_fx( x, y ); - FOR ( i = 0; i < 320; i++ ) + FOR( i = 0; i < 320; i++ ) { data[2 * i] = x[i]; data[2 * i + 1] = y[i]; } - IF ( EQ_16(sign, -1) ) + IF( EQ_16( sign, -1 ) ) { rfft_post( sine_table, data, len ); } } ELSE { - IF ( EQ_16(len, 512) ) + IF( EQ_16( len, 512 ) ) { Word16 i; const Word16 log2 = 9; Word32 reordered_data[512]; - IF ( EQ_16(sign, -1) ) + IF( EQ_16( sign, -1 ) ) { fft_rel_fx32( data, len, log2 ); reordered_data[0] = data[0]; reordered_data[1] = data[len / 2]; - FOR ( i = 1; i < len / 2; i++ ) + FOR( i = 1; i < len / 2; i++ ) { reordered_data[2 * i] = data[i]; reordered_data[2 * i + 1] = data[len - i]; @@ -2851,7 +2851,7 @@ Word16 RFFTN_fx( { reordered_data[0] = data[0]; reordered_data[len / 2] = data[1]; - FOR ( i = 1; i < len / 2; i++ ) + FOR( i = 1; i < len / 2; i++ ) { reordered_data[i] = data[2 * i]; reordered_data[len - i] = data[2 * i + 1]; @@ -3101,7 +3101,7 @@ static void nextFFT( const Word16 length ) { cmplx val[5]; - SWITCH ( length ) + SWITCH( length ) { case 2: fft2( x ); @@ -3113,13 +3113,13 @@ static void nextFFT( fft4( x ); BREAK; case 5: - FOR ( Word32 i = 0; i < 5; i++ ) + FOR( Word32 i = 0; i < 5; i++ ) { val[i].re = x[2 * i]; val[i].im = x[2 * i + 1]; } fft5( val ); - FOR ( Word32 i = 0; i < 5; i++ ) + FOR( Word32 i = 0; i < 5; i++ ) { x[2 * i] = val[i].re; x[2 * i + 1] = val[i].im; @@ -3215,13 +3215,13 @@ static void cooleyTukeyFFT( fft4( x ); BREAK; case 5: - FOR ( i = 0; i < 5; i++ ) + FOR( i = 0; i < 5; i++ ) { val[i].re = x[2 * i]; val[i].im = x[2 * i + 1]; } fft5( val ); - FOR ( i = 0; i < 5; i++ ) + FOR( i = 0; i < 5; i++ ) { x[2 * i] = val[i].re; x[2 * i + 1] = val[i].im; @@ -3234,7 +3234,7 @@ static void cooleyTukeyFFT( { factor = findFactor( length ); - IF ( GT_16(factor, 0) && GT_16( length / factor, 1 ) ) + IF( GT_16( factor, 0 ) && GT_16( length / factor, 1 ) ) { n1 = factor; n2 = length / factor; @@ -3314,7 +3314,7 @@ static void pfaDFT( Word16 i, ii; Word16 cnt; - IF ( GT_16(numFactors, 1) ) + IF( GT_16( numFactors, 1 ) ) { Word32 *tmp = scratch1; Word16 n1_inv = 1, n2_inv = 1; @@ -3342,7 +3342,7 @@ static void pfaDFT( idx += incr; - IF ( GT_16(idx, length) ) + IF( GT_16( idx, length ) ) { idx -= length; } @@ -3378,7 +3378,7 @@ static void pfaDFT( tmp[2 * idx + 1] = x[cnt++]; idx += n2; - IF ( GT_16(idx, length) ) + IF( GT_16( idx, length ) ) { idx -= length; } @@ -5080,14 +5080,14 @@ static void fft_lenN( case 10: { cmplx y[10]; - FOR ( j = 0; j < dim2; j++ ) + FOR( j = 0; j < dim2; j++ ) { { y[j] = xx[0 + j * dim1]; }; } fft_len10( &y[0] ); - FOR ( j = 0; j < dim2; j++ ) + FOR( j = 0; j < dim2; j++ ) { x[0 + j * dim1] = y[j]; } @@ -5106,7 +5106,7 @@ static void fft_lenN( } } fft_len10( &y[0] ); - FOR ( j = 0; j < dim2; j++ ) + FOR( j = 0; j < dim2; j++ ) { x[i + j * dim1] = y[j]; } @@ -5117,7 +5117,7 @@ static void fft_lenN( case 16: { cmplx y[16]; - FOR ( j = 0; j < dim2; j++ ) + FOR( j = 0; j < dim2; j++ ) { { y[j] = xx[0 + j * dim1]; @@ -5125,7 +5125,7 @@ static void fft_lenN( } fft_len16( &y[0] ); - FOR ( j = 0; j < dim2; j++ ) + FOR( j = 0; j < dim2; j++ ) { x[0 + j * dim1] = y[j]; } @@ -5144,7 +5144,7 @@ static void fft_lenN( } } fft_len16( &y[0] ); - FOR ( j = 0; j < dim2; j++ ) + FOR( j = 0; j < dim2; j++ ) { x[i + j * dim1] = y[j]; } @@ -5155,14 +5155,14 @@ static void fft_lenN( case 20: { cmplx y[20]; - FOR ( j = 0; j < dim2; j++ ) + FOR( j = 0; j < dim2; j++ ) { { y[j] = xx[0 + j * dim1]; }; } fft_len20_fx( &y[0] ); - FOR ( j = 0; j < dim2; j++ ) + FOR( j = 0; j < dim2; j++ ) { x[0 + j * dim1] = y[j]; } @@ -5189,7 +5189,7 @@ static void fft_lenN( } } fft_len20_fx( &y[0] ); - FOR ( j = 0; j < dim2; j++ ) + FOR( j = 0; j < dim2; j++ ) { x[i + j * dim1] = y[j]; } @@ -5200,14 +5200,14 @@ static void fft_lenN( case 32: { cmplx y[32]; - FOR ( j = 0; j < dim2; j++ ) + FOR( j = 0; j < dim2; j++ ) { { y[j] = xx[0 + j * dim1]; }; } fft_len32( &y[0] ); - FOR ( j = 0; j < dim2; j++ ) + FOR( j = 0; j < dim2; j++ ) { x[0 + j * dim1] = y[j]; } @@ -5234,7 +5234,7 @@ static void fft_lenN( } } fft_len32( &y[0] ); - FOR ( j = 0; j < dim2; j++ ) + FOR( j = 0; j < dim2; j++ ) { x[i + j * dim1] = y[j]; } @@ -5260,7 +5260,7 @@ void fft_fx( { cmplx x[960]; - FOR ( Word32 j = 0; j < length; j++ ) + FOR( Word32 j = 0; j < length; j++ ) { x[j].re = re[s * j]; x[j].im = im[s * j]; @@ -5323,7 +5323,7 @@ void fft_fx( assert( !"fft length is not supported!" ); } - FOR ( Word32 j = 0; j < length; j++ ) + FOR( Word32 j = 0; j < length; j++ ) { re[s * j] = x[j].re; im[s * j] = x[j].im; @@ -5333,8 +5333,8 @@ void fft_fx( } void rfft_fx( - Word32 *x, /* i/o: values */ - const Word16 *w, /* i : window */ + Word32 *x, /* i/o: values */ + const Word16 *w, /* i : window */ const Word16 length, /* i : length of fft */ const Word16 isign /* i : sign */ ) @@ -5374,61 +5374,61 @@ void rfft_fx( assert( 0 ); } - SWITCH ( isign ) + SWITCH( isign ) { case -1: fft_fx( x, x + 1, sizeOfFft2, 2 ); - tmp = L_add(x[0], x[1]); - x[1] = L_sub(x[0], x[1]); + tmp = L_add( x[0], x[1] ); + x[1] = L_sub( x[0], x[1] ); x[0] = tmp; - FOR ( i = 1; i <= sizeOfFft4; i++ ) + FOR( i = 1; i <= sizeOfFft4; i++ ) { - t1 = L_sub(x[2 * i], x[length - 2 * i]); - t2 = L_add(x[2 * i + 1], x[length - 2 * i + 1]); - t3 = L_sub(Mpy_32_16_1(t1, w[i]), Mpy_32_16_1(t2, w[i + sizeOfFft4])); - t4 = L_add(Mpy_32_16_1(t1, w[i + sizeOfFft4]), Mpy_32_16_1(t2, w[i])); - t1 = L_add(x[2 * i], x[length - 2 * i]); - t2 = L_sub(x[2 * i + 1], x[length - 2 * i + 1]); - - x[2 * i] = Mpy_32_16_1(L_sub(t1, t3), 16384); - x[2 * i + 1] = Mpy_32_16_1(L_sub(t2, t4), 16384); - x[length - 2 * i] = Mpy_32_16_1(L_add(t1, t3), 16384); - x[length - 2 * i + 1] = Mpy_32_16_1(L_negate(L_add(t2, t4)), 16384); + t1 = L_sub( x[2 * i], x[length - 2 * i] ); + t2 = L_add( x[2 * i + 1], x[length - 2 * i + 1] ); + t3 = L_sub( Mpy_32_16_1( t1, w[i] ), Mpy_32_16_1( t2, w[i + sizeOfFft4] ) ); + t4 = L_add( Mpy_32_16_1( t1, w[i + sizeOfFft4] ), Mpy_32_16_1( t2, w[i] ) ); + t1 = L_add( x[2 * i], x[length - 2 * i] ); + t2 = L_sub( x[2 * i + 1], x[length - 2 * i + 1] ); + + x[2 * i] = Mpy_32_16_1( L_sub( t1, t3 ), 16384 ); + x[2 * i + 1] = Mpy_32_16_1( L_sub( t2, t4 ), 16384 ); + x[length - 2 * i] = Mpy_32_16_1( L_add( t1, t3 ), 16384 ); + x[length - 2 * i + 1] = Mpy_32_16_1( L_negate( L_add( t2, t4 ) ), 16384 ); } BREAK; case +1: - tmp = Mpy_32_16_1( L_add( x[0], x[1] ), 16384); - x[1] = Mpy_32_16_1( L_sub( x[1], x[0] ), 16384); + tmp = Mpy_32_16_1( L_add( x[0], x[1] ), 16384 ); + x[1] = Mpy_32_16_1( L_sub( x[1], x[0] ), 16384 ); x[0] = tmp; - FOR ( i = 1; i <= sizeOfFft4; i++ ) + FOR( i = 1; i <= sizeOfFft4; i++ ) { - t1 = L_sub(x[2 * i], x[length - 2 * i]); - t2 = L_add(x[2 * i + 1], x[length - 2 * i + 1]); - t3 = L_add(Mpy_32_16_1(t1, w[i]), Mpy_32_16_1(t2, w[i + sizeOfFft4])); - t4 = L_sub(Mpy_32_16_1(t2, w[i]), Mpy_32_16_1(t1, w[i + sizeOfFft4])); - t1 = L_add(x[2 * i], x[length - 2 * i]); - t2 = L_sub(x[2 * i + 1], x[length - 2 * i + 1]); - - x[2 * i] = Mpy_32_16_1(L_sub( t1, t3 ), 16384); - x[2 * i + 1] = Mpy_32_16_1( L_sub( t4, t2 ), 16384); - x[length - 2 * i] = Mpy_32_16_1(L_add( t1, t3 ), 16384); - x[length - 2 * i + 1] = Mpy_32_16_1(L_add( t2, t4 ), 16384); + t1 = L_sub( x[2 * i], x[length - 2 * i] ); + t2 = L_add( x[2 * i + 1], x[length - 2 * i + 1] ); + t3 = L_add( Mpy_32_16_1( t1, w[i] ), Mpy_32_16_1( t2, w[i + sizeOfFft4] ) ); + t4 = L_sub( Mpy_32_16_1( t2, w[i] ), Mpy_32_16_1( t1, w[i + sizeOfFft4] ) ); + t1 = L_add( x[2 * i], x[length - 2 * i] ); + t2 = L_sub( x[2 * i + 1], x[length - 2 * i + 1] ); + + x[2 * i] = Mpy_32_16_1( L_sub( t1, t3 ), 16384 ); + x[2 * i + 1] = Mpy_32_16_1( L_sub( t4, t2 ), 16384 ); + x[length - 2 * i] = Mpy_32_16_1( L_add( t1, t3 ), 16384 ); + x[length - 2 * i + 1] = Mpy_32_16_1( L_add( t2, t4 ), 16384 ); } fft_fx( x, x + 1, sizeOfFft2, 2 ); - FOR ( i = 0; i < length; i += 2 ) + FOR( i = 0; i < length; i += 2 ) { - x[i] = Mpy_32_16_1(x[i], s1); - x[i + 1] = Mpy_32_16_1(x[i+1], s2); + x[i] = Mpy_32_16_1( x[i], s1 ); + x[i + 1] = Mpy_32_16_1( x[i + 1], s2 ); } BREAK; @@ -5440,20 +5440,20 @@ void rfft_fx( Word16 find_guarded_bits_fx( Word32 n ) { return n <= 1 ? 0 : n <= 2 ? 1 - : n <= 4 ? 2 - : n <= 8 ? 3 - : n <= 16 ? 4 - : n <= 32 ? 5 - : n <= 64 ? 6 - : n <= 128 ? 7 - : n <= 256 ? 8 - : n <= 512 ? 9 - : n <= 1024 ? 10 - : n <= 2048 ? 11 - : n <= 4096 ? 12 - : n <= 8192 ? 13 - : n <= 16384 ? 14 - : 15; + : n <= 4 ? 2 + : n <= 8 ? 3 + : n <= 16 ? 4 + : n <= 32 ? 5 + : n <= 64 ? 6 + : n <= 128 ? 7 + : n <= 256 ? 8 + : n <= 512 ? 9 + : n <= 1024 ? 10 + : n <= 2048 ? 11 + : n <= 4096 ? 12 + : n <= 8192 ? 13 + : n <= 16384 ? 14 + : 15; } Word16 L_norm_arr( Word32 *arr, Word16 size ) diff --git a/lib_com/ivas_fb_mixer.c b/lib_com/ivas_fb_mixer.c index 9c0c6b6d5..d3dceac37 100644 --- a/lib_com/ivas_fb_mixer.c +++ b/lib_com/ivas_fb_mixer.c @@ -961,7 +961,7 @@ void ivas_FB_mixer_close( } #ifdef IVAS_FLOAT_FIXED - FOR ( j = start_diff_band_non48k; j < num_bands; j++ ) + FOR( j = start_diff_band_non48k; j < num_bands; j++ ) { free( hFbMixer->pFb->fb_consts.ppFilterbank_FRs_non48k_fx[0][j] ); hFbMixer->pFb->fb_consts.ppFilterbank_FRs_non48k_fx[0][j] = NULL; diff --git a/lib_com/ivas_spar_com.c b/lib_com/ivas_spar_com.c index 2b03b5a37..a7299b89f 100644 --- a/lib_com/ivas_spar_com.c +++ b/lib_com/ivas_spar_com.c @@ -734,7 +734,7 @@ static void ivas_get_pred_coeffs_fx( Word16 dm_alpha_e, den_f_e, s_dm_f; prev_tmp_shift = 31; dm_alpha_e = 0; - Word16 dm_beta_re_e=0; + Word16 dm_beta_re_e = 0; IF( EQ_16( dyn_active_w_flag, 1 ) ) { @@ -843,7 +843,7 @@ static void ivas_get_pred_coeffs_fx( dm_beta_re = L_add( dm_beta_re, re ); // Q = 2*tmp_shift - 3 - 31 } - dm_beta_re_e = 31-(2 * tmp_shift - 3 - 31); + dm_beta_re_e = 31 - ( 2 * tmp_shift - 3 - 31 ); dm_w = cov_real[0][0][b]; // Q30 den_f = L_max( dm_w, 1 ); passive_g = L_deposit_l( BASOP_Util_Divide3232_Scale( dm_alpha[b], den_f, &s_div ) ); @@ -917,13 +917,13 @@ static void ivas_get_pred_coeffs_fx( /* quadratic activeW */ - num_f = BASOP_Util_Add_Mant32Exp( dm_beta_re, dm_beta_re_e, L_negate(L_shl( Mpy_32_32( dm_alpha[b], activew_quad_thresh ), 1 )), add(dm_alpha_e,(31-Q29)),&num_f_e); + num_f = BASOP_Util_Add_Mant32Exp( dm_beta_re, dm_beta_re_e, L_negate( L_shl( Mpy_32_32( dm_alpha[b], activew_quad_thresh ), 1 ) ), add( dm_alpha_e, ( 31 - Q29 ) ), &num_f_e ); - sqrt_val = L_shl( Mpy_32_32( Mpy_32_32( dm_alpha[b], dm_alpha[b] ), g_th_sq ), 2 );/*Q27*/ + sqrt_val = L_shl( Mpy_32_32( Mpy_32_32( dm_alpha[b], dm_alpha[b] ), g_th_sq ), 2 ); /*Q27*/ val_e = 4; - sqrt_val = BASOP_Util_Add_Mant32Exp( sqrt_val,4, Mpy_32_32( dm_beta_re, dm_beta_re ),2* dm_beta_re_e,&val_e); - sqrt_val = BASOP_Util_Add_Mant32Exp( sqrt_val, val_e, L_negate(L_shl( Mpy_32_32( Mpy_32_32( dm_beta_re, g_th_sq ), dm_w ), 2 )), add(dm_beta_re_e,4+1),&val_e); - //val_e = norm_l( sqrt_val ); + sqrt_val = BASOP_Util_Add_Mant32Exp( sqrt_val, 4, Mpy_32_32( dm_beta_re, dm_beta_re ), 2 * dm_beta_re_e, &val_e ); + sqrt_val = BASOP_Util_Add_Mant32Exp( sqrt_val, val_e, L_negate( L_shl( Mpy_32_32( Mpy_32_32( dm_beta_re, g_th_sq ), dm_w ), 2 ) ), add( dm_beta_re_e, 4 + 1 ), &val_e ); + // val_e = norm_l( sqrt_val ); sqrt_val = Sqrt32( sqrt_val, &val_e ); IF( LT_16( val_e, 0 ) ) { @@ -934,15 +934,15 @@ static void ivas_get_pred_coeffs_fx( sqrt_val = L_shl( sqrt_val, abs_s( val_e ) ); val_e = 0; } - num_f = BASOP_Util_Add_Mant32Exp( num_f, num_f_e, sqrt_val,0,&num_f_e); + num_f = BASOP_Util_Add_Mant32Exp( num_f, num_f_e, sqrt_val, 0, &num_f_e ); den_f = L_shl( Mpy_32_32( dm_beta_re, g_th_sq ), 1 ); - den_f_e = add( dm_beta_re_e , 4 ); + den_f_e = add( dm_beta_re_e, 4 ); den_f = L_max( den_f, 1 ); dm_g[b] = activew_quad_thresh; // Q29 DM_F[b] = BASOP_Util_Divide3232_Scale_cadence( Mpy_32_32( dm_g[b], num_f ), den_f, &s_dm_f ); - s_dm_f =add(s_dm_f,sub(add( 2 , num_f_e ) , den_f_e));/*Resultant exp for DM_F s_dm_f +( 2 + num_f_e ) - den_f_e*/ - div_shift = sub(s_dm_f, 1); + s_dm_f = add( s_dm_f, sub( add( 2, num_f_e ), den_f_e ) ); /*Resultant exp for DM_F s_dm_f +( 2 + num_f_e ) - den_f_e*/ + div_shift = sub( s_dm_f, 1 ); DM_F[b] = L_shl( DM_F[b], div_shift ); // Q30 } } diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 42503f11d..7a179371f 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -5573,4 +5573,4 @@ static ivas_error doSanityChecks_IVAS( return IVAS_ERR_OK; } -#endif \ No newline at end of file +#endif diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c index 465a91037..c0f50d4b7 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions.c @@ -179,11 +179,11 @@ static void matrixTransp2Mul( float Are[BINAURAL_CHANNELS][BINAURAL_CHANNELS], f static void ivas_masa_ext_rend_parambin_internal( MASA_EXT_REND_HANDLE hMasaExtRend, COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, float *output_f[], const int16_t subframe ); #ifdef IVAS_FLOAT_FIXED -static void formulate2x2MixingMatrix_fx(Word32 Ein1_fx, Word32 Ein2_fx, Word16 q_Ein, Word32 CinRe_fx, Word32 CinIm_fx, Word16 q_Cin, Word32 Eout1_fx, Word32 Eout2_fx, Word16 q_Eout, Word32 CoutRe_fx, Word32 CoutIm_fx, Word16 q_Cout, Word32 Q_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], Word32 Mre_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], Word32 Mim_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], Word16 *q_M, const Word16 regularizationFactor_fx); +static void formulate2x2MixingMatrix_fx( Word32 Ein1_fx, Word32 Ein2_fx, Word16 q_Ein, Word32 CinRe_fx, Word32 CinIm_fx, Word16 q_Cin, Word32 Eout1_fx, Word32 Eout2_fx, Word16 q_Eout, Word32 CoutRe_fx, Word32 CoutIm_fx, Word16 q_Cout, Word32 Q_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], Word32 Mre_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], Word32 Mim_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], Word16 *q_M, const Word16 regularizationFactor_fx ); -static void matrixMul_fx(Word32 Are[BINAURAL_CHANNELS][BINAURAL_CHANNELS], Word32 Aim[BINAURAL_CHANNELS][BINAURAL_CHANNELS], Word16 *q_A, Word32 Bre[BINAURAL_CHANNELS][BINAURAL_CHANNELS], Word32 Bim[BINAURAL_CHANNELS][BINAURAL_CHANNELS], Word16 *q_B, Word32 outRe[BINAURAL_CHANNELS][BINAURAL_CHANNELS], Word32 outIm[BINAURAL_CHANNELS][BINAURAL_CHANNELS], Word16 *q_out); +static void matrixMul_fx( Word32 Are[BINAURAL_CHANNELS][BINAURAL_CHANNELS], Word32 Aim[BINAURAL_CHANNELS][BINAURAL_CHANNELS], Word16 *q_A, Word32 Bre[BINAURAL_CHANNELS][BINAURAL_CHANNELS], Word32 Bim[BINAURAL_CHANNELS][BINAURAL_CHANNELS], Word16 *q_B, Word32 outRe[BINAURAL_CHANNELS][BINAURAL_CHANNELS], Word32 outIm[BINAURAL_CHANNELS][BINAURAL_CHANNELS], Word16 *q_out ); -static void matrixTransp2Mul_fx(Word32 Are[BINAURAL_CHANNELS][BINAURAL_CHANNELS], Word32 Aim[BINAURAL_CHANNELS][BINAURAL_CHANNELS], Word16 *q_A, Word32 Bre[BINAURAL_CHANNELS][BINAURAL_CHANNELS], Word32 Bim[BINAURAL_CHANNELS][BINAURAL_CHANNELS], Word16 *q_B, Word32 outRe[BINAURAL_CHANNELS][BINAURAL_CHANNELS], Word32 outIm[BINAURAL_CHANNELS][BINAURAL_CHANNELS], Word16 *q_out); +static void matrixTransp2Mul_fx( Word32 Are[BINAURAL_CHANNELS][BINAURAL_CHANNELS], Word32 Aim[BINAURAL_CHANNELS][BINAURAL_CHANNELS], Word16 *q_A, Word32 Bre[BINAURAL_CHANNELS][BINAURAL_CHANNELS], Word32 Bim[BINAURAL_CHANNELS][BINAURAL_CHANNELS], Word16 *q_B, Word32 outRe[BINAURAL_CHANNELS][BINAURAL_CHANNELS], Word32 outIm[BINAURAL_CHANNELS][BINAURAL_CHANNELS], Word16 *q_out ); #endif // 1 /*------------------------------------------------------------------------- @@ -2858,7 +2858,7 @@ static void ivas_dirac_dec_binaural_determine_processing_matrices( float CrCrossRe, CrCrossIm; float Mre[BINAURAL_CHANNELS][BINAURAL_CHANNELS], Mim[BINAURAL_CHANNELS][BINAURAL_CHANNELS], MdecRe[BINAURAL_CHANNELS][BINAURAL_CHANNELS], MdecIm[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; /* M = mixing matrix; Mdec = residual decorrelated signal mixing matrix */ #ifndef IVAS_FLOAT_FIXED - float prototypeMtx[BINAURAL_CHANNELS][BINAURAL_CHANNELS] = { { 1.0f, 0.05f }, { 0.05f, 1.0f } }; /* Prototype matrix determines a reference signal in mixing matrix determination */ + float prototypeMtx[BINAURAL_CHANNELS][BINAURAL_CHANNELS] = { { 1.0f, 0.05f }, { 0.05f, 1.0f } }; /* Prototype matrix determines a reference signal in mixing matrix determination */ #endif CrEneL = 0.0f; CrEneR = 0.0f; @@ -4375,147 +4375,145 @@ static void eig2x2_fx( q_U_2 = 0; /* Eigenvectors */ - FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) - { - IF( LT_16( *q_D, q_e ) ) - { + FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ){ + IF( LT_16( *q_D, q_e ) ){ tmp1 = L_sub( D_fx[ch], L_shr( e1, sub( q_e, *q_D ) ) ); - tmp2 = L_sub( D_fx[ch], L_shr( e2, sub( q_e, *q_D ) ) ); - q_tmp1 = *q_D; - move16(); - } - ELSE - { - tmp1 = L_sub( L_shr( D_fx[ch], sub( *q_D, q_e ) ), e1 ); - tmp2 = L_sub( L_shr( D_fx[ch], sub( *q_D, q_e ) ), e2 ); - q_tmp1 = q_e; - move16(); - } + tmp2 = L_sub( D_fx[ch], L_shr( e2, sub( q_e, *q_D ) ) ); + q_tmp1 = *q_D; + move16(); +} +ELSE +{ + tmp1 = L_sub( L_shr( D_fx[ch], sub( *q_D, q_e ) ), e1 ); + tmp2 = L_sub( L_shr( D_fx[ch], sub( *q_D, q_e ) ), e2 ); + q_tmp1 = q_e; + move16(); +} - IF( GT_32( abs( tmp2 ), abs( tmp1 ) ) ) - { - s_fx = tmp2; - move32(); - exp = sub( norm_l( s_fx ), 1 ); - tmp2 = Mpy_32_32( s_fx, s_fx ); - q_tmp2 = sub( add( q_tmp1, q_tmp1 ), 31 ); +IF( GT_32( abs( tmp2 ), abs( tmp1 ) ) ) +{ + s_fx = tmp2; + move32(); + exp = sub( norm_l( s_fx ), 1 ); + tmp2 = Mpy_32_32( s_fx, s_fx ); + q_tmp2 = sub( add( q_tmp1, q_tmp1 ), 31 ); - tmp2 = BASOP_Util_Add_Mant32Exp( crossSquare_fx, sub( 31, q_crossSquare ), tmp2, sub( 31, q_tmp2 ), &q_tmp2 ); - q_tmp2 = sub( 31, q_tmp2 ); + tmp2 = BASOP_Util_Add_Mant32Exp( crossSquare_fx, sub( 31, q_crossSquare ), tmp2, sub( 31, q_tmp2 ), &q_tmp2 ); + q_tmp2 = sub( 31, q_tmp2 ); - tmp3 = BASOP_Util_Add_Mant32Exp( tmp2, sub( 31, q_tmp2 ), epsilon_mant, epsilon_exp, &exp_tmp3 ); + tmp3 = BASOP_Util_Add_Mant32Exp( tmp2, sub( 31, q_tmp2 ), epsilon_mant, epsilon_exp, &exp_tmp3 ); - tmp2 = BASOP_Util_Divide3232_Scale_cadence( ONE_IN_Q30, tmp3, &exp ); - exp = sub( exp, sub( Q30, sub( 31, exp_tmp3 ) ) ); - normVal_fx = Sqrt32( tmp2, &exp ); - q_tmp2 = sub( 31, exp ); + tmp2 = BASOP_Util_Divide3232_Scale_cadence( ONE_IN_Q30, tmp3, &exp ); + exp = sub( exp, sub( Q30, sub( 31, exp_tmp3 ) ) ); + normVal_fx = Sqrt32( tmp2, &exp ); + q_tmp2 = sub( 31, exp ); - IF( LT_16( q_tmp1, q_c ) ) - { - c_re = L_shr( c_re, sub( q_c, q_tmp1 ) ); - c_im = L_shr( c_im, sub( q_c, q_tmp1 ) ); - q_c = q_tmp1; - move16(); - } - ELSE - { - s_fx = L_shr( s_fx, sub( q_tmp1, q_c ) ); - q_tmp1 = q_c; - move16(); - } + IF( LT_16( q_tmp1, q_c ) ) + { + c_re = L_shr( c_re, sub( q_c, q_tmp1 ) ); + c_im = L_shr( c_im, sub( q_c, q_tmp1 ) ); + q_c = q_tmp1; + move16(); + } + ELSE + { + s_fx = L_shr( s_fx, sub( q_tmp1, q_c ) ); + q_tmp1 = q_c; + move16(); + } - Ure_fx[0][ch] = Mpy_32_32( s_fx, normVal_fx ); - move32(); - Ure_fx[1][ch] = Mpy_32_32( c_re, normVal_fx ); - move32(); - Uim_fx[1][ch] = Mpy_32_32( c_im, normVal_fx ); - move32(); - q_U_1 = sub( add( q_tmp1, q_tmp2 ), 31 ); + Ure_fx[0][ch] = Mpy_32_32( s_fx, normVal_fx ); + move32(); + Ure_fx[1][ch] = Mpy_32_32( c_re, normVal_fx ); + move32(); + Uim_fx[1][ch] = Mpy_32_32( c_im, normVal_fx ); + move32(); + q_U_1 = sub( add( q_tmp1, q_tmp2 ), 31 ); - IF( q_U_2 != 0 ) - { - IF( LT_16( q_U_1, q_U_2 ) ) - { - Ure_fx[1][ch - 1] = L_shr( Ure_fx[1][ch - 1], sub( q_U_2, q_U_1 ) ); - Ure_fx[0][ch - 1] = L_shr( Ure_fx[0][ch - 1], sub( q_U_2, q_U_1 ) ); - Uim_fx[0][ch - 1] = L_shr( Uim_fx[0][ch - 1], sub( q_U_2, q_U_1 ) ); - q_U_2 = q_U_1; - } - ELSE IF( GT_16( q_U_1, q_U_2 ) ) - { - Ure_fx[1][ch] = L_shr( Ure_fx[1][ch], sub( q_U_1, q_U_2 ) ); - Ure_fx[0][ch] = L_shr( Ure_fx[0][ch], sub( q_U_1, q_U_2 ) ); - Uim_fx[1][ch] = L_shr( Uim_fx[1][ch], sub( q_U_1, q_U_2 ) ); - q_U_1 = q_U_2; - } - } + IF( q_U_2 != 0 ) + { + IF( LT_16( q_U_1, q_U_2 ) ) + { + Ure_fx[1][ch - 1] = L_shr( Ure_fx[1][ch - 1], sub( q_U_2, q_U_1 ) ); + Ure_fx[0][ch - 1] = L_shr( Ure_fx[0][ch - 1], sub( q_U_2, q_U_1 ) ); + Uim_fx[0][ch - 1] = L_shr( Uim_fx[0][ch - 1], sub( q_U_2, q_U_1 ) ); q_U_2 = q_U_1; } - ELSE + ELSE IF( GT_16( q_U_1, q_U_2 ) ) { - s_fx = tmp1; - move32(); + Ure_fx[1][ch] = L_shr( Ure_fx[1][ch], sub( q_U_1, q_U_2 ) ); + Ure_fx[0][ch] = L_shr( Ure_fx[0][ch], sub( q_U_1, q_U_2 ) ); + Uim_fx[1][ch] = L_shr( Uim_fx[1][ch], sub( q_U_1, q_U_2 ) ); + q_U_1 = q_U_2; + } + } + q_U_2 = q_U_1; +} +ELSE +{ + s_fx = tmp1; + move32(); - exp = sub( norm_l( s_fx ), 1 ); - tmp2 = Mpy_32_32( s_fx, s_fx ); - q_tmp2 = sub( add( q_tmp1, q_tmp1 ), 31 ); + exp = sub( norm_l( s_fx ), 1 ); + tmp2 = Mpy_32_32( s_fx, s_fx ); + q_tmp2 = sub( add( q_tmp1, q_tmp1 ), 31 ); - tmp2 = BASOP_Util_Add_Mant32Exp( crossSquare_fx, sub( 31, q_crossSquare ), tmp2, sub( 31, q_tmp2 ), &q_tmp2 ); - q_tmp2 = sub( 31, q_tmp2 ); + tmp2 = BASOP_Util_Add_Mant32Exp( crossSquare_fx, sub( 31, q_crossSquare ), tmp2, sub( 31, q_tmp2 ), &q_tmp2 ); + q_tmp2 = sub( 31, q_tmp2 ); - tmp3 = BASOP_Util_Add_Mant32Exp( tmp2, sub( 31, q_tmp2 ), epsilon_mant, epsilon_exp, &exp_tmp3 ); + tmp3 = BASOP_Util_Add_Mant32Exp( tmp2, sub( 31, q_tmp2 ), epsilon_mant, epsilon_exp, &exp_tmp3 ); - tmp2 = BASOP_Util_Divide3232_Scale_cadence( ONE_IN_Q30, tmp3, &exp ); - exp = sub( exp, sub( Q30, sub( 31, exp_tmp3 ) ) ); - normVal_fx = Sqrt32( tmp2, &exp ); - q_tmp2 = sub( 31, exp ); + tmp2 = BASOP_Util_Divide3232_Scale_cadence( ONE_IN_Q30, tmp3, &exp ); + exp = sub( exp, sub( Q30, sub( 31, exp_tmp3 ) ) ); + normVal_fx = Sqrt32( tmp2, &exp ); + q_tmp2 = sub( 31, exp ); - IF( LT_16( q_tmp1, q_c ) ) - { - c_re = L_shr( c_re, sub( q_c, q_tmp1 ) ); - c_im = L_shr( c_im, sub( q_c, q_tmp1 ) ); - q_c = q_tmp1; - move16(); - } - ELSE - { - s_fx = L_shr( s_fx, sub( q_tmp1, q_c ) ); - q_tmp1 = q_c; - move16(); - } + IF( LT_16( q_tmp1, q_c ) ) + { + c_re = L_shr( c_re, sub( q_c, q_tmp1 ) ); + c_im = L_shr( c_im, sub( q_c, q_tmp1 ) ); + q_c = q_tmp1; + move16(); + } + ELSE + { + s_fx = L_shr( s_fx, sub( q_tmp1, q_c ) ); + q_tmp1 = q_c; + move16(); + } - Ure_fx[1][ch] = Mpy_32_32( s_fx, normVal_fx ); - move32(); - Ure_fx[0][ch] = Mpy_32_32( c_re, normVal_fx ); - move32(); - Uim_fx[0][ch] = Mpy_32_32( -c_im, normVal_fx ); - move32(); - q_U_2 = sub( add( q_tmp1, q_tmp2 ), 31 ); + Ure_fx[1][ch] = Mpy_32_32( s_fx, normVal_fx ); + move32(); + Ure_fx[0][ch] = Mpy_32_32( c_re, normVal_fx ); + move32(); + Uim_fx[0][ch] = Mpy_32_32( -c_im, normVal_fx ); + move32(); + q_U_2 = sub( add( q_tmp1, q_tmp2 ), 31 ); - IF( q_U_1 != 0 ) - { - IF( LT_16( q_U_1, q_U_2 ) ) - { - Ure_fx[1][ch] = L_shr( Ure_fx[1][ch], sub( q_U_2, q_U_1 ) ); - Ure_fx[0][ch] = L_shr( Ure_fx[0][ch], sub( q_U_2, q_U_1 ) ); - Uim_fx[0][ch] = L_shr( Uim_fx[0][ch], sub( q_U_2, q_U_1 ) ); - q_U_2 = q_U_1; - } - ELSE IF( GT_16( q_U_1, q_U_2 ) ) - { - Ure_fx[1][ch - 1] = L_shr( Ure_fx[1][ch - 1], sub( q_U_1, q_U_2 ) ); - Ure_fx[0][ch - 1] = L_shr( Ure_fx[0][ch - 1], sub( q_U_1, q_U_2 ) ); - Uim_fx[1][ch - 1] = L_shr( Uim_fx[1][ch - 1], sub( q_U_1, q_U_2 ) ); - q_U_1 = q_U_2; - } - } + IF( q_U_1 != 0 ) + { + IF( LT_16( q_U_1, q_U_2 ) ) + { + Ure_fx[1][ch] = L_shr( Ure_fx[1][ch], sub( q_U_2, q_U_1 ) ); + Ure_fx[0][ch] = L_shr( Ure_fx[0][ch], sub( q_U_2, q_U_1 ) ); + Uim_fx[0][ch] = L_shr( Uim_fx[0][ch], sub( q_U_2, q_U_1 ) ); + q_U_2 = q_U_1; + } + ELSE IF( GT_16( q_U_1, q_U_2 ) ) + { + Ure_fx[1][ch - 1] = L_shr( Ure_fx[1][ch - 1], sub( q_U_1, q_U_2 ) ); + Ure_fx[0][ch - 1] = L_shr( Ure_fx[0][ch - 1], sub( q_U_1, q_U_2 ) ); + Uim_fx[1][ch - 1] = L_shr( Uim_fx[1][ch - 1], sub( q_U_1, q_U_2 ) ); q_U_1 = q_U_2; } } + q_U_1 = q_U_2; +} +} - *q_U = q_U_1 != 0 ? q_U_1 : q_U_2; +*q_U = q_U_1 != 0 ? q_U_1 : q_U_2; - return; +return; } #endif // IVAS_FLOAT_FIXED @@ -5433,7 +5431,7 @@ static void formulate2x2MixingMatrix_fx( } ELSE { - temp = BASOP_Util_Add_Mant32Exp(temp, sub(31, q_ein), EPSILON_MANT, EPSILON_EXP, &exp_temp); + temp = BASOP_Util_Add_Mant32Exp( temp, sub( 31, q_ein ), EPSILON_MANT, EPSILON_EXP, &exp_temp ); temp = BASOP_Util_Divide3232_Scale_cadence( E_out2, temp, &exp1 ); exp1 = sub( exp1, sub( q_eout, sub( 31, exp_temp ) ) ); -- GitLab