diff --git a/lib_com/cldfb.c b/lib_com/cldfb.c index ccca93784a001c3c9d164659c790dfdd3f772164..264973581d499c2bca37e191fb92b03541747fde 100644 --- a/lib_com/cldfb.c +++ b/lib_com/cldfb.c @@ -1829,54 +1829,43 @@ ivas_error openCldfb_ivas( ivas_error openCldfb_ivas_enc( HANDLE_CLDFB_FILTER_BANK *h_cldfb, /* i/o: filter bank handle */ CLDFB_TYPE type, /* i : analysis or synthesis */ - const int32_t sampling_rate, /* i : sampling rate */ + const Word32 sampling_rate, /* i : sampling rate */ CLDFB_PROTOTYPE prototype /* i : CLDFB version (1.25ms/5ms delay) */ ) { HANDLE_CLDFB_FILTER_BANK hs; - int16_t buf_len; + Word16 buf_len; - if ( ( hs = (HANDLE_CLDFB_FILTER_BANK) malloc( sizeof( CLDFB_FILTER_BANK ) ) ) == NULL ) + IF( ( hs = (HANDLE_CLDFB_FILTER_BANK) malloc( sizeof( CLDFB_FILTER_BANK ) ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for CLDFB" ); } hs->type = type; + move32(); hs->prototype = prototype; + move32(); -#ifndef IVAS_FLOAT_FIXED - configureCldfb_ivas_enc( hs, sampling_rate ); - hs->memory_flt = NULL; -#else configureCldfb_ivas_enc_fx( hs, sampling_rate ); -#endif hs->memory_length = 0; + move32(); - if ( type == CLDFB_ANALYSIS ) + IF( type == CLDFB_ANALYSIS ) { - buf_len = hs->p_filter_length - hs->no_channels; -#ifdef IVAS_FLOAT_FIXED + buf_len = sub( hs->p_filter_length, hs->no_channels ); hs->FilterStates = (Word16 *) malloc( ( 9 + 16 ) * CLDFB_getNumChannels( sampling_rate ) * sizeof( Word16 ) ); hs->FilterStates_eg = 0; -#endif + move16(); } - else + ELSE { buf_len = hs->p_filter_length; -#ifdef IVAS_FLOAT_FIXED + move16(); hs->FilterStates = (Word16 *) malloc( 2 * ( 9 + 16 ) * CLDFB_getNumChannels( sampling_rate ) * sizeof( Word16 ) ); hs->FilterStates_eg = 0; -#endif + move16(); } -#ifndef IVAS_FLOAT_FIXED - if ( ( hs->cldfb_state = (float *) malloc( buf_len * sizeof( float ) ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for CLDFB" ); - } - set_f( hs->cldfb_state, 0.0f, buf_len ); -#endif -#ifdef IVAS_FLOAT_FIXED if ( ( hs->cldfb_state_fx = (Word32 *) malloc( buf_len * sizeof( Word32 ) ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for CLDFB" ); @@ -1890,8 +1879,6 @@ ivas_error openCldfb_ivas_enc( move16(); set16_fx( hs->FilterStates, 0, i_mult( 9 + 16, hs->no_channels ) ); set16_fx( hs->FilterStates_e, 0, sizeof( hs->FilterStates_e ) / sizeof( hs->FilterStates_e[0] ) ); -#endif // IVAS_FLOAT_FIXED - *h_cldfb = hs; diff --git a/lib_com/fd_cng_com_fx.c b/lib_com/fd_cng_com_fx.c index ac1fa1a2bed39a739848645e8cccb8bef948783b..8c64e6c16bc6d35f35c85762bee94c92c72b5ed9 100644 --- a/lib_com/fd_cng_com_fx.c +++ b/lib_com/fd_cng_com_fx.c @@ -175,8 +175,10 @@ void initFdCngCom( HANDLE_FD_CNG_COM hFdCngCom, Word16 scale ) assert( 2048 /*1.0/(1<<4) Q15*/ < mult( scale, scale ) ); /* Exponent invScalingFactor: -16 = -(2*7 (scale) + 2 (8.0) */ hFdCngCom->invScalingFactor = shl( mult( scale, scale ), 1 ); + move16(); /* Exponent scalingFactor: -15 = -(2*7 (scale) + 2 (8.0) - 1 (1.0)) */ hFdCngCom->scalingFactor = div_s( 0x4000, hFdCngCom->invScalingFactor ); + move16(); /* Initialize the overlap-add */ set16_fx( hFdCngCom->timeDomainBuffer, 0, L_FRAME16k ); @@ -185,10 +187,8 @@ void initFdCngCom( HANDLE_FD_CNG_COM hFdCngCom, Word16 scale ) set16_fx( hFdCngCom->olapBufferAna_fx, 0, FFTLEN ); #endif // IVAS_FLOAT_FIXED - move16(); set16_fx( hFdCngCom->olapBufferSynth, 0, FFTLEN ); hFdCngCom->olapBufferSynth2 = NULL; - move16(); /* Initialize the comfort noise generation */ set32_fx( hFdCngCom->fftBuffer, 0, FFTLEN ); @@ -228,9 +228,9 @@ void initFdCngCom( HANDLE_FD_CNG_COM hFdCngCom, Word16 scale ) hFdCngCom->seed = 0; move16(); // hFdCngCom->seed2 = 1; - move16(); + // move16(); // hFdCngCom->seed3 = 2; - move16(); + // move16(); hFdCngCom->CngBitrate = -1; move16(); diff --git a/lib_com/gs_preech.c b/lib_com/gs_preech.c index 1fc23300e5901bb638620273ab41bd6432267568..f7964bed624ffb5b3fc0517888ecb2050fe11162 100644 --- a/lib_com/gs_preech.c +++ b/lib_com/gs_preech.c @@ -376,17 +376,17 @@ void pre_echo_att_ivas_fx( /*-------------------------------------------------------* * In normal cases, just compute the energy of the frame *-------------------------------------------------------*/ + Word16 exp_etmp = sub( 15, Q_new ); + etmp_fx = sum2_16_exp_fx( exc_fx, L_frame, &exp_etmp, 7 ); /* Q = 31-exp_etmp */ - etmp_fx = sum2_fx( exc_fx, L_frame ); /*2*Q_new+1 */ - - etmp_fx = L_shr( etmp_fx, add( 8 + 1 - 4, shl( Q_new, 1 ) ) ); /*2*Q_new+1 //INV_L_FRAME = 1/256 -> Q4*/ + etmp_fx = L_shr( etmp_fx, 8 ); /*31-exp_etmp//INV_L_FRAME = 1/256*/ - if ( EQ_16( L_frame, L_FRAME16k ) ) + IF( EQ_16( L_frame, L_FRAME16k ) ) { - etmp_fx = Mpy_32_16_1( etmp_fx, 26214 /* 0.8 in Q15 */ ); /*2*Q_new+1*/ + etmp_fx = Mpy_32_16_1( etmp_fx, 26214 /* 0.8 in Q15 */ ); /*31 - exp_etmp*/ } - *Last_frame_ener_fx = etmp_fx; - move32(); /*2*Q_new+1*/ + *Last_frame_ener_fx = L_shl( etmp_fx, sub( shl( Q_new, 1 ), sub( 30 /*31-1*/, exp_etmp ) ) ); /*2*Q_new+1*/ + move32(); /*2*Q_new+1*/ } return; diff --git a/lib_com/lerp.c b/lib_com/lerp.c index 42c44ef12905b2ba4c5c7ac84b37662e8cc4a760..17a39d53c62a1a3808eb33ef420e0a2cebf693cc 100644 --- a/lib_com/lerp.c +++ b/lib_com/lerp.c @@ -202,59 +202,59 @@ static void lerp_proc( const Word16 *f, Word16 *f_out, Word16 bufferNewSize, Wor * * *-------------------------------------------------------------*/ -void lerp( const Word16 *f, Word16 *f_out, Word16 bufferNewSize, Word16 bufferOldSize ) +void lerp( const Word16 *f /*Qx*/, Word16 *f_out /*Qx*/, Word16 bufferNewSize /*Q0*/, Word16 bufferOldSize /*Q0*/ ) { Word16 tmp1, tmp2, tmpexp; BASOP_Util_Divide_MantExp( bufferNewSize, 0, bufferOldSize, 0, &tmp1, &tmpexp ); - tmp1 = shr( tmp1, 3 ); /*Q12*/ - tmp1 = shl( tmp1, tmpexp ); + tmp1 = shr( tmp1, 3 ); /*Q12*/ + tmp1 = shl( tmp1, tmpexp ); /*Q12+tmpexp*/ BASOP_Util_Divide_MantExp( bufferOldSize, 0, bufferNewSize, 0, &tmp2, &tmpexp ); - tmp2 = shr( tmp2, 3 ); /*Q12*/ - tmp2 = shl( tmp2, tmpexp ); - IF( GT_16( tmp1, 16224 /*3,9609375 in Q12*/ ) ) + tmp2 = shr( tmp2, 3 ); /*Q12*/ + tmp2 = shl( tmp2, tmpexp ); /*Q12+tmpexp*/ + IF( GT_16( tmp1, 16224 /*3.9609375 in Q12*/ ) ) { - Word16 tmpNewSize = shl( bufferOldSize, 1 ); + Word16 tmpNewSize = shl( bufferOldSize, 1 ); /*Q0*/ WHILE( GT_16( bufferNewSize, bufferOldSize ) ) { BASOP_Util_Divide_MantExp( bufferNewSize, 0, bufferOldSize, 0, &tmp1, &tmpexp ); - tmp1 = shr( tmp1, 3 ); /*Q12*/ - tmp1 = shl( tmp1, tmpexp ); - if ( LE_16( tmp1, 16224 /*3,9609375 in Q12*/ ) ) + tmp1 = shr( tmp1, 3 ); /*Q12*/ + tmp1 = shl( tmp1, tmpexp ); /*Q12+tmpexp*/ + if ( LE_16( tmp1, 16224 /*3.9609375 in Q12*/ ) ) { - tmpNewSize = bufferNewSize; + tmpNewSize = bufferNewSize; /*Q0*/ move16(); } lerp_proc( f, f_out, tmpNewSize, bufferOldSize ); - f = f_out; - bufferOldSize = tmpNewSize; + f = f_out; /*Qx*/ + bufferOldSize = tmpNewSize; /*Q0*/ move16(); - tmpNewSize = shl( tmpNewSize, 1 ); + tmpNewSize = shl( tmpNewSize, 1 ); /*Q0*/ } } - ELSE IF( GT_16( tmp2, 16224 /*3,9609375 in Q12*/ ) ) + ELSE IF( GT_16( tmp2, 16224 /*3.9609375 in Q12*/ ) ) { Word16 tmpNewSize = shr( bufferOldSize, 1 ); WHILE( LT_16( bufferNewSize, bufferOldSize ) ) { BASOP_Util_Divide_MantExp( bufferOldSize, 0, bufferNewSize, 0, &tmp2, &tmpexp ); - tmp2 = shr( tmp2, 3 ); /*Q12*/ - tmp2 = shl( tmp2, tmpexp ); + tmp2 = shr( tmp2, 3 ); /*Q12*/ + tmp2 = shl( tmp2, tmpexp ); /*Q12+tmpexp*/ - if ( LE_16( tmp2, 16224 /*3,9609375 in Q12*/ ) ) + if ( LE_16( tmp2, 16224 /*3.9609375 in Q12*/ ) ) { - tmpNewSize = bufferNewSize; + tmpNewSize = bufferNewSize; /*Q0*/ move16(); } lerp_proc( f, f_out, tmpNewSize, bufferOldSize ); - f = f_out; - bufferOldSize = tmpNewSize; + f = f_out; /*Qx*/ + bufferOldSize = tmpNewSize; /*Q0*/ move16(); - tmpNewSize = shr( tmpNewSize, 1 ); + tmpNewSize = shr( tmpNewSize, 1 ); /*Q0*/ } } ELSE @@ -267,7 +267,7 @@ void lerp( const Word16 *f, Word16 *f_out, Word16 bufferNewSize, Word16 bufferOl * * * * *-------------------------------------------------------------*/ -static void lerp_proc( const Word16 *f, Word16 *f_out, Word16 bufferNewSize, Word16 bufferOldSize ) +static void lerp_proc( const Word16 *f /*Qx*/, Word16 *f_out /*Qx*/, Word16 bufferNewSize /*Q0*/, Word16 bufferOldSize /*Q0*/ ) { Word16 i, idx, n; @@ -276,29 +276,29 @@ static void lerp_proc( const Word16 *f, Word16 *f_out, Word16 bufferNewSize, Wor Word16 buf[2 * L_FRAME_MAX]; Word16 *ptr; - ptr = f_out; + ptr = f_out; /*Qx*/ test(); test(); test(); if ( ( ( f <= f_out ) && ( f + bufferOldSize >= f_out ) ) || ( ( f_out <= f ) && ( f_out + bufferNewSize >= f ) ) ) { - ptr = buf; + ptr = buf; /*Qx*/ } IF( EQ_16( bufferNewSize, bufferOldSize ) ) { - Copy( f, f_out, bufferNewSize ); + Copy( f, f_out, bufferNewSize ); /*Qx*/ return; } - shift = L_shl( L_deposit_l( div_s( bufferOldSize, shl( bufferNewSize, 4 ) ) ), 4 - shift_e + 16 ); + shift = L_shl( L_deposit_l( div_s( bufferOldSize, shl( bufferNewSize, 4 ) ) ), 4 - shift_e + 16 ); /*Q16*/ - pos = L_sub( L_shr( shift, 1 ), 32768l /*1.0f Q15*/ ); + pos = L_sub( L_shr( shift, 1 ), 32768l /*0.5f Q16*/ ); /*Q16*/ /* Adjust interpolation shift to avoid accessing beyond end of input buffer. */ if ( LT_32( shift, 19661l /*0.3f Q16*/ ) ) { - pos = L_sub( pos, 8520l /*0.13f Q16*/ ); + pos = L_sub( pos, 8520l /*0.13f Q16*/ ); /*Q16*/ } assert( pos_e == shift_e ); @@ -307,11 +307,11 @@ static void lerp_proc( const Word16 *f, Word16 *f_out, Word16 bufferNewSize, Wor IF( pos < 0 ) { - diff = shr( extract_l( pos ), 1 ); + diff = shr( extract_l( pos ), 1 ); /*Q15*/ /*buf[0]=f[0]+pos*(f[1]-f[0]);*/ move16(); #ifdef BASOP_NOGLOB - *ptr++ = add_sat( f[0], msu_r( L_mult( diff, f[1] ), diff, f[0] ) ); + *ptr++ = add_sat( f[0], msu_r( L_mult( diff, f[1] ), diff, f[0] ) ); /*Qx*/ #else *ptr++ = add( f[0], msu_r( L_mult( diff, f[1] ), diff, f[0] ) ); #endif @@ -319,13 +319,13 @@ static void lerp_proc( const Word16 *f, Word16 *f_out, Word16 bufferNewSize, Wor ELSE { - idx = extract_h( pos ); + idx = extract_h( pos ); /*Q0*/ - diff = lshr( extract_l( pos ), 1 ); + diff = lshr( extract_l( pos ), 1 ); /*Q15*/ move16(); #ifdef BASOP_NOGLOB - *ptr++ = add_sat( f[idx], msu_r_sat( L_mult( diff, f[idx + 1] ), diff, f[idx] ) ); + *ptr++ = add_sat( f[idx], msu_r_sat( L_mult( diff, f[idx + 1] ), diff, f[idx] ) ); /*Qx*/ #else *ptr++ = add( f[idx], msu_r( L_mult( diff, f[idx + 1] ), diff, f[idx] ) ); #endif @@ -337,21 +337,21 @@ static void lerp_proc( const Word16 *f, Word16 *f_out, Word16 bufferNewSize, Wor n = sub( bufferNewSize, 1 ); FOR( i = 1; i < n; i++ ) { - diff = lshr( extract_l( pos ), 1 ); + diff = lshr( extract_l( pos ), 1 ); /*Q15*/ if ( pos < 0 ) { - diff = sub( 16384 /*0.5f Q15*/, diff ); + diff = sub( 16384 /*0.5f Q15*/, diff ); /*Q15*/ } move16(); #ifdef BASOP_NOGLOB - *ptr++ = add_sat( f[idx], msu_r_sat( L_mult( diff, f[idx + 1] ), diff, f[idx] ) ); + *ptr++ = add_sat( f[idx], msu_r_sat( L_mult( diff, f[idx + 1] ), diff, f[idx] ) ); /*Qx*/ #else *ptr++ = add( f[idx], msu_r( L_mult( diff, f[idx + 1] ), diff, f[idx] ) ); #endif pos = L_add( pos, shift ); - idx = extract_h( pos ); + idx = extract_h( pos ); /*Q0*/ } /* last point */ @@ -363,11 +363,11 @@ static void lerp_proc( const Word16 *f, Word16 *f_out, Word16 bufferNewSize, Wor assert( idx <= 2 * L_FRAME_MAX ); /* diff = t - point;*/ - diff = lshr( extract_l( L_shr( L_sub( pos, L_deposit_h( idx ) ), 1 ) ), 1 ); + diff = lshr( extract_l( L_shr( L_sub( pos, L_deposit_h( idx ) ), 1 ) ), 1 ); /*Q15*/ move16(); #ifdef BASOP_NOGLOB - *ptr++ = add_sat( f[idx], shl_sat( msu_r_sat( L_mult( diff, f[idx + 1] ), diff, f[idx] ), 1 ) ); + *ptr++ = add_sat( f[idx], shl_sat( msu_r_sat( L_mult( diff, f[idx + 1] ), diff, f[idx] ), 1 ) ); /*Qx*/ #else *ptr++ = add( f[idx], shl( msu_r( L_mult( diff, f[idx + 1] ), diff, f[idx] ), 1 ) ); #endif @@ -376,12 +376,12 @@ static void lerp_proc( const Word16 *f, Word16 *f_out, Word16 bufferNewSize, Wor test(); IF( ( ( f <= f_out ) && ( f + bufferOldSize >= f_out ) ) || ( ( f_out <= f ) && ( f_out + bufferNewSize >= f ) ) ) { - Copy( buf, f_out, bufferNewSize ); + Copy( buf, f_out, bufferNewSize ); /*Qx*/ } } -static void lerp_proc32( Word32 *f, Word32 *f_out, Word16 bufferNewSize, Word16 bufferOldSize ) +static void lerp_proc32( Word32 *f /*Qx*/, Word32 *f_out /*Qx*/, Word16 bufferNewSize /*Q0*/, Word16 bufferOldSize /*Q0*/ ) { Word16 i, idx, n; @@ -390,29 +390,29 @@ static void lerp_proc32( Word32 *f, Word32 *f_out, Word16 bufferNewSize, Word16 Word32 buf[2 * L_FRAME_MAX]; Word32 *ptr; - ptr = f_out; + ptr = f_out; /*Qx*/ test(); test(); test(); if ( ( ( f <= f_out ) && ( f + bufferOldSize >= f_out ) ) || ( ( f_out <= f ) && ( f_out + bufferNewSize >= f ) ) ) { - ptr = buf; + ptr = buf; /*Qx*/ } IF( EQ_16( bufferNewSize, bufferOldSize ) ) { - Copy32( f, f_out, bufferNewSize ); + Copy32( f, f_out, bufferNewSize ); /*Qx*/ return; } - shift = L_shl( L_deposit_l( div_s( bufferOldSize, shl( bufferNewSize, 4 ) ) ), add( sub( 4, shift_e ), Q16 ) ); + shift = L_shl( L_deposit_l( div_s( bufferOldSize, shl( bufferNewSize, 4 ) ) ), add( sub( 4, shift_e ), Q16 ) ); /*Q16*/ - pos = L_sub( L_shr( shift, 1 ), 32768l /*1.0f Q15*/ ); + pos = L_sub( L_shr( shift, 1 ), 32768l /*0.5f Q16*/ ); /*Q16*/ /* Adjust interpolation shift to avoid accessing beyond end of input buffer. */ if ( LT_32( shift, 19661l /*0.3f Q16*/ ) ) { - pos = L_sub( pos, 8520l /*0.13f Q16*/ ); + pos = L_sub( pos, 8520l /*0.13f Q16*/ ); /*Q16*/ } assert( pos_e == shift_e ); @@ -421,22 +421,22 @@ static void lerp_proc32( Word32 *f, Word32 *f_out, Word16 bufferNewSize, Word16 IF( pos < 0 ) { - diff = shr( extract_l( pos ), 1 ); + diff = shr( extract_l( pos ), 1 ); /*Q15*/ /*buf[0]=f[0]+pos*(f[1]-f[0]);*/ - *ptr++ = L_add_sat( f[0], Mpy_32_16_1( L_sub( f[1], f[0] ), diff ) ); + *ptr++ = L_add_sat( f[0], Mpy_32_16_1( L_sub( f[1], f[0] ), diff ) ); /*Qx*/ move32(); } ELSE { - idx = extract_h( pos ); - diff = lshr( extract_l( pos ), 1 ); - *ptr++ = L_add_sat( f[idx], Mpy_32_16_1( L_sub( f[add( idx, 1 )], f[idx] ), diff ) ); + idx = extract_h( pos ); /*Q0*/ + diff = lshr( extract_l( pos ), 1 ); /*Q15*/ + *ptr++ = L_add_sat( f[idx], Mpy_32_16_1( L_sub( f[( idx + 1 )], f[idx] ), diff ) ); /*Qx*/ move32(); } - pos = L_add( pos, shift ); - idx = s_max( 0, extract_h( pos ) ); + pos = L_add( pos, shift ); /*Q16*/ + idx = s_max( 0, extract_h( pos ) ); /*Q0*/ n = sub( bufferNewSize, 1 ); FOR( i = 1; i < n; i++ ) @@ -444,11 +444,11 @@ static void lerp_proc32( Word32 *f, Word32 *f_out, Word16 bufferNewSize, Word16 diff = lshr( extract_l( pos ), 1 ); if ( pos < 0 ) { - diff = sub( 16384 /*0.5f Q15*/, diff ); + diff = sub( 16384 /*0.5f Q15*/, diff ); /*Q15*/ } - *ptr++ = L_add_sat( f[idx], Mpy_32_16_1( L_sub( f[idx + 1], f[idx] ), diff ) ); + *ptr++ = L_add_sat( f[idx], Mpy_32_16_1( L_sub( f[idx + 1], f[idx] ), diff ) ); /*Qx*/ move32(); - pos = L_add( pos, shift ); + pos = L_add( pos, shift ); /*Q16*/ idx = extract_h( pos ); } @@ -461,16 +461,16 @@ static void lerp_proc32( Word32 *f, Word32 *f_out, Word16 bufferNewSize, Word16 assert( idx <= 2 * L_FRAME_MAX ); /* diff = t - point;*/ - diff = lshr( extract_l( L_shr( L_sub( pos, L_deposit_h( idx ) ), 1 ) ), 1 ); + diff = lshr( extract_l( L_shr( L_sub( pos, L_deposit_h( idx ) ), 1 ) ), 1 ); /*Q15*/ - *ptr++ = L_add_sat( f[idx], L_shl_sat( Mpy_32_16_1( L_sub( f[add( idx, 1 )], f[idx] ), diff ), 1 ) ); + *ptr++ = L_add_sat( f[idx], L_shl_sat( Mpy_32_16_1( L_sub( f[( idx + 1 )], f[idx] ), diff ), 1 ) ); /*Qx*/ move32(); test(); test(); test(); IF( ( ( f <= f_out ) && ( f + bufferOldSize >= f_out ) ) || ( ( f_out <= f ) && ( f_out + bufferNewSize >= f ) ) ) { - Copy32( buf, f_out, bufferNewSize ); + Copy32( buf, f_out, bufferNewSize ); /*Qx*/ } } @@ -483,22 +483,22 @@ static void L_lerp_proc_fx( const Word32 *f_fx, Word32 *f_out_fx, const Word16 b * * *-------------------------------------------------------------*/ -void L_lerp_fx( Word32 *f, Word32 *f_out, Word16 bufferNewSize, Word16 bufferOldSize, Word16 *q ) +void L_lerp_fx( Word32 *f /*q*/, Word32 *f_out /*q*/, Word16 bufferNewSize /*Q0*/, Word16 bufferOldSize /*Q0*/, Word16 *q ) { Word16 tmpNewSize; Word16 tmp1, tmp2, tmp_e; - tmp1 = BASOP_Util_Divide1616_Scale( bufferNewSize, bufferOldSize, &tmp_e ); - tmp1 = shr( tmp1, sub( 15, tmp_e ) ); + tmp1 = BASOP_Util_Divide1616_Scale( bufferNewSize, bufferOldSize, &tmp_e ); /*Q15 - tmp_e*/ + tmp1 = shr( tmp1, sub( 15, tmp_e ) ); /*Q0*/ - tmp2 = BASOP_Util_Divide1616_Scale( bufferOldSize, bufferNewSize, &tmp_e ); - tmp2 = shr( tmp2, sub( 15, tmp_e ) ); + tmp2 = BASOP_Util_Divide1616_Scale( bufferOldSize, bufferNewSize, &tmp_e ); /*Q15 - tmp_e*/ + tmp2 = shr( tmp2, sub( 15, tmp_e ) ); /*Q0*/ Word16 guard_bits = add( s_max( tmp1, tmp2 ), 1 ); IF( LT_16( getScaleFactor32( f, bufferOldSize ), guard_bits ) ) { *q = sub( *q, guard_bits ); FOR( Word16 ind = 0; ind < bufferNewSize; ind++ ) { - f[ind] = L_shr( f[ind], guard_bits ); + f[ind] = L_shr( f[ind], guard_bits ); /*Q(guard_bits)*/ move32(); } #ifndef MSAN_FIX @@ -509,40 +509,40 @@ void L_lerp_fx( Word32 *f, Word32 *f_out, Word16 bufferNewSize, Word16 bufferOld IF( GT_32( L_mult0( 128, bufferNewSize ), L_mult0( bufferOldSize, 507 ) ) ) { - tmpNewSize = shl( bufferOldSize, 1 ); + tmpNewSize = shl( bufferOldSize, 1 ); /*Q0*/ WHILE( GT_16( bufferNewSize, bufferOldSize ) ) { if ( LE_32( L_mult0( 128, bufferNewSize ), L_mult0( bufferOldSize, 507 ) ) ) { - tmpNewSize = bufferNewSize; + tmpNewSize = bufferNewSize; /*Q0*/ move16(); } L_lerp_proc_fx( f, f_out, tmpNewSize, bufferOldSize ); f = f_out; - bufferOldSize = tmpNewSize; + bufferOldSize = tmpNewSize; /*Q0*/ move16(); - tmpNewSize = shl( tmpNewSize, 1 ); + tmpNewSize = shl( tmpNewSize, 1 ); /*Q0*/ } } ELSE IF( GT_32( L_mult0( 128, bufferOldSize ), L_mult0( bufferNewSize, 507 ) ) ) { - tmpNewSize = shr( bufferOldSize, 1 ); + tmpNewSize = shr( bufferOldSize, 1 ); /*Q0*/ WHILE( LT_16( bufferNewSize, bufferOldSize ) ) { if ( LE_32( L_mult0( 128, bufferOldSize ), L_mult0( bufferNewSize, 507 ) ) ) { - tmpNewSize = bufferNewSize; + tmpNewSize = bufferNewSize; /*Q0*/ move16(); } L_lerp_proc_fx( f, f_out, tmpNewSize, bufferOldSize ); - f = f_out; - bufferOldSize = tmpNewSize; + f = f_out; /*q*/ + bufferOldSize = tmpNewSize; /*Q0*/ move16(); - tmpNewSize = shr( tmpNewSize, 1 ); + tmpNewSize = shr( tmpNewSize, 1 ); /*Q0*/ } } ELSE @@ -552,46 +552,46 @@ void L_lerp_fx( Word32 *f, Word32 *f_out, Word16 bufferNewSize, Word16 bufferOld return; } -void L_lerp_fx_q11( Word32 *f, Word32 *f_out, Word16 bufferNewSize, Word16 bufferOldSize ) +void L_lerp_fx_q11( Word32 *f /*Q11*/, Word32 *f_out /*Q11*/, Word16 bufferNewSize /*Q0*/, Word16 bufferOldSize /*Q0*/ ) { Word16 tmpNewSize; IF( GT_32( L_mult0( 128, bufferNewSize ), L_mult0( bufferOldSize, 507 ) ) ) { - tmpNewSize = shl( bufferOldSize, 1 ); + tmpNewSize = shl( bufferOldSize, 1 ); /*Q0*/ WHILE( GT_16( bufferNewSize, bufferOldSize ) ) { if ( LE_32( L_mult0( 128, bufferNewSize ), L_mult0( bufferOldSize, 507 ) ) ) { - tmpNewSize = bufferNewSize; + tmpNewSize = bufferNewSize; /*Q0*/ move16(); } lerp_proc32( f, f_out, tmpNewSize, bufferOldSize ); - f = f_out; - bufferOldSize = tmpNewSize; + f = f_out; /*Q11*/ + bufferOldSize = tmpNewSize; /*Q0*/ move16(); - tmpNewSize = shl( tmpNewSize, 1 ); + tmpNewSize = shl( tmpNewSize, 1 ); /*Q0*/ } } ELSE IF( GT_32( L_mult0( 128, bufferOldSize ), L_mult0( bufferNewSize, 507 ) ) ) { - tmpNewSize = shr( bufferOldSize, 1 ); + tmpNewSize = shr( bufferOldSize, 1 ); /*Q0*/ WHILE( LT_16( bufferNewSize, bufferOldSize ) ) { if ( LE_32( L_mult0( 128, bufferOldSize ), L_mult0( bufferNewSize, 507 ) ) ) { - tmpNewSize = bufferNewSize; + tmpNewSize = bufferNewSize; /*Q0*/ move16(); } lerp_proc32( f, f_out, tmpNewSize, bufferOldSize ); f = f_out; - bufferOldSize = tmpNewSize; + bufferOldSize = tmpNewSize; /*Q0*/ move16(); - tmpNewSize = shr( tmpNewSize, 1 ); + tmpNewSize = shr( tmpNewSize, 1 ); /*Q0*/ } } ELSE @@ -608,10 +608,10 @@ void L_lerp_fx_q11( Word32 *f, Word32 *f_out, Word16 bufferNewSize, Word16 buffe * * *-------------------------------------------------------------*/ static void L_lerp_proc_fx( - const Word32 *f_fx, - Word32 *f_out_fx, - const Word16 bufferNewSize, - const Word16 bufferOldSize ) + const Word32 *f_fx, /*Qx*/ + Word32 *f_out_fx, /*Qx*/ + const Word16 bufferNewSize, /*Q0*/ + const Word16 bufferOldSize /*Q0*/ ) { Word16 i, idx; Word32 pos_fx, shift_fx, diff_fx; @@ -620,62 +620,62 @@ static void L_lerp_proc_fx( IF( EQ_16( bufferNewSize, bufferOldSize ) ) { - Copy32( f_fx, buf_fx, bufferNewSize ); - Copy32( buf_fx, f_out_fx, bufferNewSize ); + Copy32( f_fx, buf_fx, bufferNewSize ); /*Qx*/ + Copy32( buf_fx, f_out_fx, bufferNewSize ); /*Qx*/ return; } /* Using the basop code to avoid reading beyond end of input for bufferOldSize=320, bufferNewSize=640 */ - tmp = div_s( bufferOldSize, shl( bufferNewSize, 4 ) ); - shift_fx = L_shl( L_deposit_l( tmp ), 4 - 15 + 21 ); // q =21 - pos_fx = Mpy_32_32( L_sub( shift_fx, 1 << 21 ), 1073741824 ); + tmp = div_s( bufferOldSize, shl( bufferNewSize, 4 ) ); /*Q11*/ + shift_fx = L_shl( L_deposit_l( tmp ), 4 - 15 + 21 ); // q =21 + pos_fx = Mpy_32_32( L_sub( shift_fx, 1 << 21 ), ONE_IN_Q30 /*0.5f in Q31*/ ); /*Q21*/ - IF( LT_32( shift_fx, L_shr( 644245094, 31 - 21 ) ) ) + IF( LT_32( shift_fx, L_shr( 644245094 /*0.3 in Q31*/, 31 - 21 ) ) ) { - pos_fx = L_sub( pos_fx, L_shr( 279172874, 31 - 21 ) ); + pos_fx = L_sub( pos_fx, L_shr( 279172874 /*0.13 in Q31*/, 31 - 21 ) ); /*Q21*/ } /* first point of interpolation */ IF( pos_fx < 0 ) { - buf_fx[0] = L_add( f_fx[0], L_shl( Mpy_32_32( pos_fx, L_sub( f_fx[1], f_fx[0] ) ), 31 - 21 ) ); + buf_fx[0] = L_add( f_fx[0], L_shl( Mpy_32_32( pos_fx, L_sub( f_fx[1], f_fx[0] ) ), 31 - 21 ) ); /*Qx*/ move32(); } ELSE { idx = extract_l( L_shr( pos_fx, 21 ) ); - diff_fx = L_sub( pos_fx, L_shl( idx, 21 ) ); - buf_fx[0] = L_add( f_fx[idx], L_shl( Mpy_32_32( diff_fx, L_sub( f_fx[add( idx, 1 )], f_fx[idx] ) ), 31 - 21 ) ); + diff_fx = L_sub( pos_fx, L_shl( idx, 21 ) ); /*Q21*/ + buf_fx[0] = L_add( f_fx[idx], L_shl( Mpy_32_32( diff_fx, L_sub( f_fx[( idx + 1 )], f_fx[idx] ) ), 31 - 21 ) ); /*Qx*/ move32(); } - pos_fx = L_add( pos_fx, shift_fx ); + pos_fx = L_add( pos_fx, shift_fx ); /*Q21*/ FOR( i = 1; i < bufferNewSize - 1; i++ ) { idx = extract_l( L_shr( pos_fx, 21 ) ); - diff_fx = L_sub( pos_fx, L_shl( idx, 21 ) ); + diff_fx = L_sub( pos_fx, L_shl( idx, 21 ) ); /*Q21*/ - buf_fx[i] = L_add( f_fx[idx], L_shl( Mpy_32_32( diff_fx, L_sub( f_fx[idx + 1], f_fx[idx] ) ), 31 - 21 ) ); + buf_fx[i] = L_add( f_fx[idx], L_shl( Mpy_32_32( diff_fx, L_sub( f_fx[idx + 1], f_fx[idx] ) ), 31 - 21 ) ); /*Qx*/ move32(); - pos_fx = L_add( pos_fx, shift_fx ); + pos_fx = L_add( pos_fx, shift_fx ); /*Q21*/ } /* last point */ - idx = extract_l( L_shr( pos_fx, 21 ) ); + idx = extract_l( L_shr( pos_fx, 21 ) ); /*Q0*/ if ( GT_32( pos_fx, L_shl( sub( bufferOldSize, 1 ), 21 ) ) ) { idx = sub( bufferOldSize, 2 ); } - diff_fx = L_sub( pos_fx, L_shl( idx, 21 ) ); + diff_fx = L_sub( pos_fx, L_shl( idx, 21 ) ); /*Q21*/ - buf_fx[sub( bufferNewSize, 1 )] = L_add( f_fx[idx], L_shl( Mpy_32_32( diff_fx, L_sub( f_fx[add( idx, 1 )], f_fx[idx] ) ), 31 - 21 ) ); + buf_fx[( bufferNewSize - 1 )] = L_add( f_fx[idx], L_shl( Mpy_32_32( diff_fx, L_sub( f_fx[( idx + 1 )], f_fx[idx] ) ), 31 - 21 ) ); /*Qx*/ move32(); - Copy32( buf_fx, f_out_fx, bufferNewSize ); + Copy32( buf_fx, f_out_fx, bufferNewSize ); /*Qx*/ return; } diff --git a/lib_com/limit_t0_fx.c b/lib_com/limit_t0_fx.c index 9fc8ac789f413fc615468423adfaf268be19a78c..d3cff10d9733e7170b05ce287534cbfa63406be2 100644 --- a/lib_com/limit_t0_fx.c +++ b/lib_com/limit_t0_fx.c @@ -23,14 +23,14 @@ *-------------------------------------------------*/ void limit_T0_fx( - const Word16 L_frame, /* i : length of the frame */ - const Word16 delta, /* i : Half the close-loop searched interval */ - const Word16 pit_flag, /* i : selecting absolute(0) or delta(1) pitch quantization */ - const Word16 limit_flag, /* i : flag for Q limits (0=restrained, 1=extended) */ - const Word16 T0, /* i : rough pitch estimate around which the search is done */ - const Word16 T0_frac, /* i : pitch estimate fractional part */ - Word16 *T0_min, /* o : lower pitch limit */ - Word16 *T0_max /* o : higher pitch limit */ + const Word16 L_frame, /* i : length of the frame Q0*/ + const Word16 delta, /* i : Half the close-loop searched interval Q0*/ + const Word16 pit_flag, /* i : selecting absolute(0) or delta(1) pitch quantization Q0*/ + const Word16 limit_flag, /* i : flag for Q limits (0=restrained, 1=extended) Q0*/ + const Word16 T0, /* i : rough pitch estimate around which the search is done Q0*/ + const Word16 T0_frac, /* i : pitch estimate fractional part Q0*/ + Word16 *T0_min, /* o : lower pitch limit Q0*/ + Word16 *T0_max /* o : higher pitch limit Q0*/ ) { @@ -55,7 +55,7 @@ void limit_T0_fx( move16(); } - delta2 = sub( shl( delta, 1 ), 1 ); + delta2 = sub( shl( delta, 1 ), 1 ); /*Q0*/ T1 = T0; move16(); @@ -104,7 +104,7 @@ void limit_T0_fx( move16(); } - delta2 = sub( shl( delta, 1 ), 1 ); + delta2 = sub( shl( delta, 1 ), 1 ); /*Q0*/ move16(); T1 = T0; move16(); @@ -118,7 +118,7 @@ void limit_T0_fx( { /* subframes with absolute search: keep Q range */ *T0_min = s_max( *T0_min, pit_min ); - + move16(); *T0_max = add( *T0_min, delta2 ); move16(); IF( GT_16( *T0_max, pit_max ) ) @@ -136,6 +136,7 @@ void limit_T0_fx( move16(); *T0_min = s_max( *T0_min, L_INTERPOL ); + move16(); *T0_max = *T0_min + delta2; move16(); @@ -162,15 +163,15 @@ void limit_T0_fx( void limit_T0_voiced( const Word16 nbits, const Word16 res, - const Word16 T0, /* i : rough pitch estimate around which the search is done */ - const Word16 T0_frac, /* i : pitch estimate fractional part */ - const Word16 T0_res, /* i : pitch resolution */ - Word16 *T0_min, /* o : lower pitch limit */ - Word16 *T0_min_frac, /* o : lower pitch limit */ - Word16 *T0_max, /* o : higher pitch limit */ - Word16 *T0_max_frac, /* o : higher pitch limit */ - const Word16 pit_min, /* i : Minimum pitch lag */ - const Word16 pit_max /* i : Maximum pitch lag */ + const Word16 T0, /* i : rough pitch estimate around which the search is done Q0*/ + const Word16 T0_frac, /* i : pitch estimate fractional part Q0*/ + const Word16 T0_res, /* i : pitch resolution Q0*/ + Word16 *T0_min, /* o : lower pitch limit Q0*/ + Word16 *T0_min_frac, /* o : lower pitch limit Q0*/ + Word16 *T0_max, /* o : higher pitch limit Q0*/ + Word16 *T0_max_frac, /* o : higher pitch limit Q0*/ + const Word16 pit_min, /* i : Minimum pitch lag Q0*/ + const Word16 pit_max /* i : Maximum pitch lag Q0*/ ) { Word16 T1, temp1, temp2, res2; @@ -178,15 +179,15 @@ void limit_T0_voiced( assert( res > 1 && res <= 6 ); - res2 = res; + res2 = res; /*Q0*/ move16(); if ( EQ_16( res, 6 ) ) { - res2 = shr( res2, 1 ); + res2 = shr( res2, 1 ); /*Q0*/ } /* Mid-point */ - T1 = T0; + T1 = T0; /*Q0*/ test(); if ( GT_16( T0_res, 1 ) && GE_16( T0_frac, ( shr( T0_res, 1 ) ) ) ) { @@ -194,12 +195,12 @@ void limit_T0_voiced( } /* Lower-bound */ - temp1 = sub( i_mult( T1, res ), shl( 1, sub( nbits, 1 ) ) ); + temp1 = sub( i_mult( T1, res ), shl( 1, sub( nbits, 1 ) ) ); /*Q0*/ temp2 = mult( temp1, inv_T0_res[res2] ); if ( EQ_16( res, 6 ) ) { - temp2 = shr( temp2, 1 ); + temp2 = shr( temp2, 1 ); /*Q0*/ } *T0_min = temp2; @@ -217,7 +218,7 @@ void limit_T0_voiced( } /* Higher-bound */ - temp1 = add( i_mult( *T0_min, res ), add( *T0_min_frac, sub( shl( 1, nbits ), 1 ) ) ); + temp1 = add( i_mult( *T0_min, res ), add( *T0_min_frac, sub( shl( 1, nbits ), 1 ) ) ); /*Q0*/ temp2 = mult( temp1, inv_T0_res[res2] ); if ( EQ_16( res, 6 ) ) @@ -241,15 +242,15 @@ void limit_T0_voiced( temp1 = add( i_mult( *T0_max, res ), sub( *T0_max_frac, sub( shl( 1, nbits ), 1 ) ) ); - temp2 = mult( temp1, inv_T0_res[res2] ); + temp2 = mult( temp1, inv_T0_res[res2] ); /*Q0*/ if ( EQ_16( res, 6 ) ) { - temp2 = shr( temp2, 1 ); + temp2 = shr( temp2, 1 ); /*Q0*/ } move16(); *T0_min = temp2; - *T0_min_frac = sub( temp1, i_mult( temp2, res ) ); + *T0_min_frac = sub( temp1, i_mult( temp2, res ) ); /*Q0*/ move16(); } diff --git a/lib_com/lsf_tools_fx.c b/lib_com/lsf_tools_fx.c index d3694637ed3272fdba54c472168eabc6bbe5176b..ce812b19dce47b8174a8d6e06107051e10327b37 100644 --- a/lib_com/lsf_tools_fx.c +++ b/lib_com/lsf_tools_fx.c @@ -863,11 +863,13 @@ Word16 E_LPC_f_lsp_pol_get( const Word16 lsp[], Word32 f[], const Word16 n, cons Word16 b; Word32 b32; Word16 Ovf = 0; + move16(); Word16 Q_out; Word16 m2; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; + move16(); #endif Q_out = 31 - 23; @@ -876,7 +878,7 @@ Word16 E_LPC_f_lsp_pol_get( const Word16 lsp[], Word32 f[], const Word16 n, cons move16(); test(); - if ( past_Ovf && isMODE1 ) /* Currently this feature is implemented only in MODE1 */ + IF( past_Ovf && isMODE1 ) /* Currently this feature is implemented only in MODE1 */ { /* In some NB cases, overflow where detectected in f1 or f2 polynomial computation when it diff --git a/lib_com/prot.h b/lib_com/prot.h index d0f46467a6f8ed5f4f03e81e39c5deadf7385fd7..4f795250c8e9c2f253e7d11a575bd1cae30e65b6 100644 --- a/lib_com/prot.h +++ b/lib_com/prot.h @@ -9243,7 +9243,7 @@ ivas_error openCldfb_ivas( ivas_error openCldfb_ivas_enc( HANDLE_CLDFB_FILTER_BANK *h_cldfb, /* i/o: filter bank handle */ CLDFB_TYPE type, /* i : analysis or synthesis */ - const int32_t sampling_rate, /* i : sampling rate */ + const Word32 sampling_rate, /* i : sampling rate */ CLDFB_PROTOTYPE prototype /* i : CLDFB version (1.25ms/5ms delay) */ ); @@ -9969,12 +9969,6 @@ int16_t getResq( const int32_t total_brate /* i : total bitrate */ ); -int16_t getRestrictedMode( - const int16_t element_mode, /* i : IVAS element mode */ - const int32_t total_brate, /* i : total bitrate */ - const int16_t Opt_AMR_WB /* i : flag indicating AMR-WB IO mode */ -); - int16_t getMdctWindowLength( const int16_t fscale ); diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index be0a12fa6a8b85c74a01babdad01092493365304..df01a6775d6bfb620382b68939e6db6b56a2a560 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -3988,10 +3988,10 @@ Word16 getTnsAllowed( const Word16 element_mode /* i : IVAS element mode */ ); -int16_t getRestrictedMode( - const int16_t element_mode, /* i : IVAS element mode */ - const int32_t total_brate, /* i : total bitrate */ - const int16_t Opt_AMR_WB /* i : flag indicating AMR-WB IO mode */ +Word16 getRestrictedMode( + const Word16 element_mode, /* i : IVAS element mode */ + const Word32 total_brate, /* i : total bitrate */ + const Word16 Opt_AMR_WB /* i : flag indicating AMR-WB IO mode */ ); Word16 getMdctWindowLength_fx( diff --git a/lib_com/residu_fx.c b/lib_com/residu_fx.c index c2e6d43a6e48a315e4cb4daee8e391ccd84d652b..4a543c9ec92214aaa022a3a81aeaf8bb67f19795 100644 --- a/lib_com/residu_fx.c +++ b/lib_com/residu_fx.c @@ -155,11 +155,14 @@ void Residu3_fx( move16(); #endif q = add( norm_s( a[0] ), 1 ); - if ( shift != 0 ) + IF( shift != 0 ) + { q = add( q, shift ); + } FOR( i = 0; i < lg; i++ ) { s64 = 0; + move64(); FOR( j = 0; j <= 15; j++ ) { s64 = W_mac_16_16( s64, x[i - j], a[j] ); @@ -168,6 +171,7 @@ void Residu3_fx( s32 = W_shl_sat_l( s64, q ); #ifdef BASOP_NOGLOB y[i] = round_fx_o( s32, &Overflow ); + move16(); #else /* BASOP_NOGLOB */ y[i] = round_fx( s32 ); #endif diff --git a/lib_com/tcq_position_arith_fx.c b/lib_com/tcq_position_arith_fx.c index 2cc28e853648d32567d24f72cf1a0b432d8a5043..581ef7395240953b989c8d5f246e8390e08aa09e 100644 --- a/lib_com/tcq_position_arith_fx.c +++ b/lib_com/tcq_position_arith_fx.c @@ -2671,7 +2671,7 @@ Word16 GetScale_fx( ab = L_add( a, b ); - p_est = extract_h( L_shl( Pow2( extract_l( L_shr( ab, 15 ) ), L_and( ab, 0x7FFF ) ), 16 ) ); /* enable saturationof pow2 result */ + p_est = extract_h( L_shl( Pow2( extract_l( L_shr( ab, 15 ) ), extract_l( L_and( ab, 0x7FFF ) ) ), 16 ) ); /* enable saturationof pow2 result */ pulses = s_min( p_est, MAX_PULSES ); diff --git a/lib_com/tcx_mdct_window.c b/lib_com/tcx_mdct_window.c index c466a8271ba3aba1a70b70ba1cf9137c509e87a4..ae72d9cc68fcc8706794963bf3fd0214e214c9f0 100644 --- a/lib_com/tcx_mdct_window.c +++ b/lib_com/tcx_mdct_window.c @@ -414,6 +414,7 @@ void mdct_window_aldo( p1 = window_256kHz; /* Q15 */ p2 = window_256kHz + 592 - 1; /* Q15 */ d = 2; + move16(); BREAK; case 640 / 2: p1 = window_48kHz_fx + 1; /* Q15 */ @@ -431,6 +432,7 @@ void mdct_window_aldo( p1 = window_48kHz_fx + 1; /* Q15 */ p2 = window_48kHz_fx + 1110 - 2; /* Q15 */ d = 3; + move16(); BREAK; case 1920 / 2: p1 = window_48kHz_fx; /* Q15 */ diff --git a/lib_com/tcx_utils_fx.c b/lib_com/tcx_utils_fx.c index 1d3ddc310bf3ecc764f550ed84ab3bf4adee2fd8..7f961f74c6aef37b3d34f287294c2f5ffb2d3ecc 100644 --- a/lib_com/tcx_utils_fx.c +++ b/lib_com/tcx_utils_fx.c @@ -41,13 +41,13 @@ Word16 getInvFrameLen( /* returns 1/L_frame in Q21 format */ * ------------------------------------------------------------------ - */ void tcx_get_windows( TCX_CONFIG_HANDLE hTcxCfg, /* i : TCX configuration */ - const Word16 left_mode, /* i: overlap mode of left window half */ - const Word16 right_mode, /* i: overlap mode of right window half */ - Word16 *left_overlap, /* o: left overlap length */ - const PWord16 **left_win, /* o: left overlap window */ - Word16 *right_overlap, /* o: right overlap length */ - const PWord16 **right_win, /* o: right overlap window */ - const Word8 fullband /* i: fullband flag */ + const Word16 left_mode, /* i: overlap mode of left window half Q0*/ + const Word16 right_mode, /* i: overlap mode of right window half Q0*/ + Word16 *left_overlap, /* o: left overlap length Q0*/ + const PWord16 **left_win, /* o: left overlap window Q15*/ + Word16 *right_overlap, /* o: right overlap length Q0*/ + const PWord16 **right_win, /* o: right overlap window Q15*/ + const Word8 fullband /* i: fullband flag Q0*/ ) { /* LFE is only FULL_OVERLAP*/ IF( fullband == 0 ) @@ -55,25 +55,25 @@ void tcx_get_windows( /* Left part */ SWITCH( left_mode ) { - case TRANSITION_OVERLAP: /* ACELP->TCX transition */ - *left_overlap = hTcxCfg->tcx_mdct_window_trans_length; + case TRANSITION_OVERLAP: /* ACELP->TCX transition */ + *left_overlap = hTcxCfg->tcx_mdct_window_trans_length; /*Q0*/ move16(); - *left_win = hTcxCfg->tcx_mdct_window_trans; + *left_win = hTcxCfg->tcx_mdct_window_trans; /*Q15*/ BREAK; case MIN_OVERLAP: - *left_overlap = hTcxCfg->tcx_mdct_window_min_length; + *left_overlap = hTcxCfg->tcx_mdct_window_min_length; /*Q0*/ move16(); - *left_win = hTcxCfg->tcx_mdct_window_minimum; + *left_win = hTcxCfg->tcx_mdct_window_minimum; /*Q15*/ BREAK; case HALF_OVERLAP: - *left_overlap = hTcxCfg->tcx_mdct_window_half_length; + *left_overlap = hTcxCfg->tcx_mdct_window_half_length; /*Q0*/ move16(); - *left_win = hTcxCfg->tcx_mdct_window_half; + *left_win = hTcxCfg->tcx_mdct_window_half; /*Q15*/ BREAK; case FULL_OVERLAP: - *left_overlap = hTcxCfg->tcx_mdct_window_length; + *left_overlap = hTcxCfg->tcx_mdct_window_length; /*Q0*/ move16(); - *left_win = hTcxCfg->tcx_aldo_window_1_trunc; + *left_win = hTcxCfg->tcx_aldo_window_1_trunc; /*Q15*/ BREAK; default: assert( !"Not supported overlap" ); @@ -83,19 +83,19 @@ void tcx_get_windows( SWITCH( right_mode ) { case MIN_OVERLAP: - *right_overlap = hTcxCfg->tcx_mdct_window_min_length; + *right_overlap = hTcxCfg->tcx_mdct_window_min_length; /*Q0*/ move16(); - *right_win = hTcxCfg->tcx_mdct_window_minimum; + *right_win = hTcxCfg->tcx_mdct_window_minimum; /*Q15*/ BREAK; case HALF_OVERLAP: - *right_overlap = hTcxCfg->tcx_mdct_window_half_length; + *right_overlap = hTcxCfg->tcx_mdct_window_half_length; /*Q0*/ move16(); - *right_win = hTcxCfg->tcx_mdct_window_half; + *right_win = hTcxCfg->tcx_mdct_window_half; /*Q15*/ BREAK; case FULL_OVERLAP: - *right_overlap = hTcxCfg->tcx_mdct_window_delay; + *right_overlap = hTcxCfg->tcx_mdct_window_delay; /*Q0*/ move16(); - *right_win = hTcxCfg->tcx_aldo_window_2; + *right_win = hTcxCfg->tcx_aldo_window_2; /*Q15*/ BREAK; default: assert( !"Not supported overlap" ); @@ -106,20 +106,20 @@ void tcx_get_windows( /* Left part */ SWITCH( left_mode ) { - case TRANSITION_OVERLAP: /* ACELP->TCX transition */ - *left_overlap = hTcxCfg->tcx_mdct_window_trans_lengthFB; + case TRANSITION_OVERLAP: /* ACELP->TCX transition */ + *left_overlap = hTcxCfg->tcx_mdct_window_trans_lengthFB; /*Q0*/ move16(); - *left_win = hTcxCfg->tcx_mdct_window_transFB; + *left_win = hTcxCfg->tcx_mdct_window_transFB; /*Q15*/ BREAK; case MIN_OVERLAP: - *left_overlap = hTcxCfg->tcx_mdct_window_min_lengthFB; + *left_overlap = hTcxCfg->tcx_mdct_window_min_lengthFB; /*Q0*/ move16(); - *left_win = hTcxCfg->tcx_mdct_window_minimumFB; + *left_win = hTcxCfg->tcx_mdct_window_minimumFB; /*Q15*/ BREAK; case HALF_OVERLAP: - *left_overlap = hTcxCfg->tcx_mdct_window_half_lengthFB; + *left_overlap = hTcxCfg->tcx_mdct_window_half_lengthFB; /*Q0*/ move16(); - *left_win = hTcxCfg->tcx_mdct_window_halfFB; + *left_win = hTcxCfg->tcx_mdct_window_halfFB; /*Q15*/ BREAK; case RECTANGULAR_OVERLAP: *left_overlap = 0; @@ -127,9 +127,9 @@ void tcx_get_windows( *left_win = NULL; BREAK; case FULL_OVERLAP: - *left_overlap = hTcxCfg->tcx_mdct_window_lengthFB; + *left_overlap = hTcxCfg->tcx_mdct_window_lengthFB; /*Q0*/ move16(); - *left_win = hTcxCfg->tcx_aldo_window_1_FB_trunc; + *left_win = hTcxCfg->tcx_aldo_window_1_FB_trunc; /*Q15*/ BREAK; default: assert( !"Not supported overlap" ); @@ -139,14 +139,14 @@ void tcx_get_windows( SWITCH( right_mode ) { case MIN_OVERLAP: - *right_overlap = hTcxCfg->tcx_mdct_window_min_lengthFB; + *right_overlap = hTcxCfg->tcx_mdct_window_min_lengthFB; /*Q0*/ move16(); - *right_win = hTcxCfg->tcx_mdct_window_minimumFB; + *right_win = hTcxCfg->tcx_mdct_window_minimumFB; /*Q15*/ BREAK; case HALF_OVERLAP: - *right_overlap = hTcxCfg->tcx_mdct_window_half_lengthFB; + *right_overlap = hTcxCfg->tcx_mdct_window_half_lengthFB; /*Q0*/ move16(); - *right_win = hTcxCfg->tcx_mdct_window_halfFB; + *right_win = hTcxCfg->tcx_mdct_window_halfFB; /*Q15*/ BREAK; case RECTANGULAR_OVERLAP: *right_overlap = 0; @@ -154,9 +154,9 @@ void tcx_get_windows( *right_win = NULL; BREAK; case FULL_OVERLAP: - *right_overlap = hTcxCfg->tcx_mdct_window_delayFB; + *right_overlap = hTcxCfg->tcx_mdct_window_delayFB; /*Q0*/ move16(); - *right_win = hTcxCfg->tcx_aldo_window_2_FB; + *right_win = hTcxCfg->tcx_aldo_window_2_FB; /*Q15*/ BREAK; default: assert( !"Not supported overlap" ); @@ -165,48 +165,48 @@ void tcx_get_windows( } static void tcx_windowing_analysis( - Word16 const *signal, /* i: signal vector */ - Word16 L_frame, /* i: frame length */ - Word16 left_overlap, /* i: left overlap length */ - PWord16 const *left_win, /* i: left overlap window */ - Word16 right_overlap, /* i: right overlap length */ - PWord16 const *right_win, /* i: right overlap window */ - Word16 *output /* o: windowed signal vector */ + Word16 const *signal, /* i: signal vector Qx*/ + Word16 L_frame, /* i: frame length Q0*/ + Word16 left_overlap, /* i: left overlap length Q0*/ + PWord16 const *left_win, /* i: left overlap window Q15*/ + Word16 right_overlap, /* i: right overlap length Q0*/ + PWord16 const *right_win, /* i: right overlap window Q15*/ + Word16 *output /* o: windowed signal vector Qx*/ ) { Word16 w, n; /* Left overlap */ - n = shr( left_overlap, 1 ); + n = shr( left_overlap, 1 ); /*Q0*/ FOR( w = 0; w < n; w++ ) { - *output++ = mult_r( *signal++, left_win[w].v.im ); + *output++ = mult_r( *signal++, left_win[w].v.im ); /*Qx*/ move16(); } FOR( w = 0; w < n; w++ ) { - *output++ = mult_r( *signal++, left_win[n - 1 - w].v.re ); + *output++ = mult_r( *signal++, left_win[n - 1 - w].v.re ); /*Qx*/ move16(); } /* Non overlapping region */ - n = sub( L_frame, shr( add( left_overlap, right_overlap ), 1 ) ); + n = sub( L_frame, shr( add( left_overlap, right_overlap ), 1 ) ); /*Q0*/ FOR( w = 0; w < n; w++ ) { - *output++ = *signal++; + *output++ = *signal++; /*Qx*/ move16(); } /* Right overlap */ - n = shr( right_overlap, 1 ); + n = shr( right_overlap, 1 ); /*Q0*/ FOR( w = 0; w < n; w++ ) { - *output++ = mult_r( *signal++, right_win[w].v.re ); + *output++ = mult_r( *signal++, right_win[w].v.re ); /*Qx*/ move16(); } FOR( w = 0; w < n; w++ ) { - *output++ = mult_r( *signal++, right_win[n - 1 - w].v.im ); + *output++ = mult_r( *signal++, right_win[n - 1 - w].v.im ); /*Qx*/ move16(); } } @@ -217,16 +217,16 @@ static void tcx_windowing_analysis( *-------------------------------------------------------------------*/ void WindowSignal( TCX_CONFIG_HANDLE hTcxCfg, /* i : configuration of TCX */ - Word16 offset, /* i : left folding point offset relative to the input signal pointer */ - const Word16 left_overlap_mode, /* i : overlap mode of left window half */ - Word16 right_overlap_mode, /* i : overlap mode of right window half */ - Word16 *left_overlap_length, /* o : TCX window left overlap length */ - Word16 *right_overlap_length, /* o : TCX window right overlap length */ - const Word16 in[], /* i : input signal */ - Word16 *L_frame, /* i/o: frame length */ - Word16 out[], /* o : output windowed signal */ - const Word16 truncate_aldo, /* i : nonzero to truncate long ALDO slope */ - const Word8 fullband /* i : fullband flag */ + Word16 offset, /* i : left folding point offset relative to the input signal pointer Q0*/ + const Word16 left_overlap_mode, /* i : overlap mode of left window half Q0*/ + Word16 right_overlap_mode, /* i : overlap mode of right window half Q0*/ + Word16 *left_overlap_length, /* o : TCX window left overlap length Q0*/ + Word16 *right_overlap_length, /* o : TCX window right overlap length Q0*/ + const Word16 in[], /* i : input signal Qx*/ + Word16 *L_frame, /* i/o: frame length Q0*/ + Word16 out[], /* o : output windowed signal Qx*/ + const Word16 truncate_aldo, /* i : nonzero to truncate long ALDO slope Q0*/ + const Word8 fullband /* i : fullband flag Q0*/ ) { Word16 l, r; @@ -248,15 +248,15 @@ void WindowSignal( /* Increase frame size for 5ms */ IF( fullband == 0 ) { - *L_frame = add( *L_frame, hTcxCfg->tcx5Size ); + *L_frame = add( *L_frame, hTcxCfg->tcx5Size ); /*Q0*/ move16(); - offset = negate( shr( hTcxCfg->tcx_mdct_window_trans_length, 1 ) ); + offset = negate( shr( hTcxCfg->tcx_mdct_window_trans_length, 1 ) ); /*Q0*/ } ELSE { - *L_frame = add( *L_frame, hTcxCfg->tcx5SizeFB ); + *L_frame = add( *L_frame, hTcxCfg->tcx5SizeFB ); /*Q0*/ move16(); - offset = negate( shr( hTcxCfg->tcx_mdct_window_trans_lengthFB, 1 ) ); + offset = negate( shr( hTcxCfg->tcx_mdct_window_trans_lengthFB, 1 ) ); /*Q0*/ } } @@ -264,7 +264,7 @@ void WindowSignal( * Windowing * *-----------------------------------------------------------*/ - tcx_windowing_analysis( in - shr( l, 1 ) + offset, *L_frame, l, left_win, r, right_win, out ); + tcx_windowing_analysis( in - sub( shr( l, 1 ), offset ), *L_frame, l, left_win, r, right_win, out ); test(); test(); IF( EQ_16( left_overlap_mode, FULL_OVERLAP ) && truncate_aldo ) @@ -273,22 +273,22 @@ void WindowSignal( Word16 i, tmp; const PWord16 *p; - p = hTcxCfg->tcx_mdct_window_minimum; - tmp = shr( hTcxCfg->tcx_mdct_window_min_length, 1 ); + p = hTcxCfg->tcx_mdct_window_minimum; /*Q15*/ + tmp = shr( hTcxCfg->tcx_mdct_window_min_length, 1 ); /*Q0*/ IF( fullband != 0 ) { - p = hTcxCfg->tcx_mdct_window_minimumFB; - tmp = shr( hTcxCfg->tcx_mdct_window_min_lengthFB, 1 ); + p = hTcxCfg->tcx_mdct_window_minimumFB; /*Q15*/ + tmp = shr( hTcxCfg->tcx_mdct_window_min_lengthFB, 1 ); /*Q0*/ } FOR( i = 0; i < tmp; i++ ) { - out[i] = mult_r( out[i], p[i].v.im ); + out[i] = mult_r( out[i], p[i].v.im ); /*Qx*/ move16(); } FOR( i = 0; i < tmp; i++ ) { - out[i + tmp] = mult_r( out[i + tmp], p[tmp - 1 - i].v.re ); + out[i + tmp] = mult_r( out[i + tmp], p[tmp - 1 - i].v.re ); /*Qx*/ move16(); } } @@ -305,25 +305,25 @@ void WindowSignal( *-------------------------------------------------------------------*/ void tcx_windowing_synthesis_current_frame( - Word16 *signal, /* i/o: signal vector */ - const PWord16 *window, /* i: TCX window vector */ - const PWord16 *window_half, /* i: TCX window vector for half-overlap window */ - const PWord16 *window_min, /* i: TCX minimum overlap window */ - const Word16 window_length, /* i: TCX window length */ - const Word16 window_half_length, /* i: TCX half window length */ - const Word16 window_min_length, /* i: TCX minimum overlap length */ - const Word16 left_rect, /* i: left part is rectangular */ - const Word16 left_mode, /* i: overlap mode of left window half */ - Word16 *acelp_zir, /* i: acelp ZIR */ - const Word16 *old_syn, - const Word16 *syn_overl, - const Word16 *A_zir, - const PWord16 *window_trans, - Word16 acelp_zir_len, - const Word16 acelp_mem_len, - const Word16 last_core_bfi, /* i : last core */ - const Word8 last_is_cng, - const Word16 fullbandScale ) + Word16 *signal, /* i/o: signal vector Qx*/ + const PWord16 *window, /* i: TCX window vector Q15*/ + const PWord16 *window_half, /* i: TCX window vector for half-overlap window Q15*/ + const PWord16 *window_min, /* i: TCX minimum overlap window Q15*/ + const Word16 window_length, /* i: TCX window length Q0*/ + const Word16 window_half_length, /* i: TCX half window length Q0*/ + const Word16 window_min_length, /* i: TCX minimum overlap length Q0*/ + const Word16 left_rect, /* i: left part is rectangular Q0*/ + const Word16 left_mode, /* i: overlap mode of left window half Q0*/ + Word16 *acelp_zir, /* i: acelp ZIR Qx*/ + const Word16 *old_syn, /*Qx*/ + const Word16 *syn_overl, /*Qx*/ + const Word16 *A_zir, /*Q12*/ + const PWord16 *window_trans, /*Q15*/ + Word16 acelp_zir_len, /*Q0*/ + const Word16 acelp_mem_len, /*Q0*/ + const Word16 last_core_bfi, /* i : last core Q0*/ + const Word8 last_is_cng, /*Q0*/ + const Word16 fullbandScale /*Q0*/ ) { Word16 i, overlap, n, tmp, tmp2; @@ -332,7 +332,7 @@ void tcx_windowing_synthesis_current_frame( /* Init */ - overlap = shr( window_length, 1 ); + overlap = shr( window_length, 1 ); /*Q0*/ /* Past-frame is TCX concealed as CNG and current-frame is TCX */ test(); @@ -353,14 +353,14 @@ void tcx_windowing_synthesis_current_frame( #else lerp( acelp_zir, tmp_buf, acelp_zir_len, idiv1616U( shl( acelp_zir_len, LD_FSCALE_DENOM ), fullbandScale ) ); #endif - acelp_zir = tmp_buf; + acelp_zir = tmp_buf; /*Qx*/ } FOR( i = 0; i < acelp_zir_len; i++ ) { /*signal[i] *= (float)(i)/(float)(acelp_zir_len); signal[i] += acelp_zir[i]*(float)(acelp_zir_len-i)/(float)(acelp_zir_len);*/ - signal[i] = add( mult_r( signal[i], div_s( i, acelp_zir_len ) ), mult_r( acelp_zir[i], div_s( sub( acelp_zir_len, i ), acelp_zir_len ) ) ); + signal[i] = add( mult_r( signal[i], div_s( i, acelp_zir_len ) ), mult_r( acelp_zir[i], div_s( sub( acelp_zir_len, i ), acelp_zir_len ) ) ); /*Qx*/ move16(); } } @@ -377,21 +377,21 @@ void tcx_windowing_synthesis_current_frame( IF( fullbandScale == 0 ) { - tmp = shl( acelp_mem_len, 1 ); + tmp = shl( acelp_mem_len, 1 ); /*Qx*/ /*OLA with ACELP*/ FOR( i = 0; i < acelp_mem_len; i++ ) { /*window decoded TCX with aliasing*/ - tmp2 = mult_r( signal[i + overlap - acelp_mem_len], window_trans[i].v.im ); + tmp2 = mult_r( signal[i + overlap - acelp_mem_len], window_trans[i].v.im ); /*Qx*/ /*Time TDAC: 1)forward part of ACELP*/ #ifdef BASOP_NOGLOB - tmp2 = add_sat( tmp2, mult_r( old_syn[acelp_zir_len - tmp + i], mult_r( window_trans[i].v.re, window_trans[i].v.re ) ) ); + tmp2 = add_sat( tmp2, mult_r( old_syn[acelp_zir_len - tmp + i], mult_r( window_trans[i].v.re, window_trans[i].v.re ) ) ); /*Qx*/ /*Time TDAC: 1)reward part of ACELP*/ - tmp2 = add_sat( tmp2, mult_r( old_syn[acelp_zir_len - i - 1], mult_r( window_trans[i].v.im, window_trans[i].v.re ) ) ); + tmp2 = add_sat( tmp2, mult_r( old_syn[acelp_zir_len - i - 1], mult_r( window_trans[i].v.im, window_trans[i].v.re ) ) ); /*Qx*/ #else tmp2 = add( tmp2, mult_r( old_syn[acelp_zir_len - tmp + i], mult_r( window_trans[i].v.re, window_trans[i].v.re ) ) ); @@ -399,35 +399,35 @@ void tcx_windowing_synthesis_current_frame( tmp2 = add( tmp2, mult_r( old_syn[acelp_zir_len - i - 1], mult_r( window_trans[i].v.im, window_trans[i].v.re ) ) ); #endif move16(); - signal[i + overlap - acelp_mem_len] = tmp2; + signal[i + overlap - acelp_mem_len] = tmp2; /*Qx*/ } FOR( ; i < tmp; i++ ) { /*window decoded TCX with aliasing*/ - tmp2 = mult_r( signal[i + overlap - acelp_mem_len], window_trans[tmp - 1 - i].v.re ); + tmp2 = mult_r( signal[i + overlap - acelp_mem_len], window_trans[tmp - 1 - i].v.re ); /*Qx*/ /*Time TDAC: 1)forward part of ACELP*/ #ifdef BASOP_NOGLOB - tmp2 = add_sat( tmp2, mult_r( old_syn[acelp_zir_len - tmp + i], mult_r( window_trans[tmp - 1 - i].v.im, window_trans[tmp - 1 - i].v.im ) ) ); + tmp2 = add_sat( tmp2, mult_r( old_syn[acelp_zir_len - tmp + i], mult_r( window_trans[tmp - 1 - i].v.im, window_trans[tmp - 1 - i].v.im ) ) ); /*Qx*/ #else tmp2 = add( tmp2, mult_r( old_syn[acelp_zir_len - tmp + i], mult_r( window_trans[tmp - 1 - i].v.im, window_trans[tmp - 1 - i].v.im ) ) ); #endif /*Time TDAC: 1)reward part of ACELP*/ #ifdef BASOP_NOGLOB - tmp2 = add_sat( tmp2, mult_r( old_syn[acelp_zir_len - i - 1], mult_r( window_trans[tmp - 1 - i].v.re, window_trans[tmp - 1 - i].v.im ) ) ); + tmp2 = add_sat( tmp2, mult_r( old_syn[acelp_zir_len - i - 1], mult_r( window_trans[tmp - 1 - i].v.re, window_trans[tmp - 1 - i].v.im ) ) ); /*Qx*/ #else tmp2 = add( tmp2, mult_r( old_syn[acelp_zir_len - i - 1], mult_r( window_trans[tmp - 1 - i].v.re, window_trans[tmp - 1 - i].v.im ) ) ); #endif move16(); - signal[i + overlap - acelp_mem_len] = tmp2; + signal[i + overlap - acelp_mem_len] = tmp2; /*Qx*/ } FOR( i = 0; i < M; i++ ) { move16(); #ifdef BASOP_NOGLOB - signal[overlap + acelp_mem_len - M + i] = sub_sat( signal[overlap + acelp_mem_len - M + i], old_syn[acelp_zir_len - M + i] ); + signal[overlap + acelp_mem_len - M + i] = sub_sat( signal[overlap + acelp_mem_len - M + i], old_syn[acelp_zir_len - M + i] ); /*Qx*/ #else signal[overlap + acelp_mem_len - M + i] = sub( signal[overlap + acelp_mem_len - M + i], old_syn[acelp_zir_len - M + i] ); #endif @@ -444,11 +444,11 @@ void tcx_windowing_synthesis_current_frame( } ELSE { - tmp = extract_l( L_shr( L_mult0( acelp_zir_len, fullbandScale ), LD_FSCALE_DENOM ) ); + tmp = extract_l( L_shr( L_mult0( acelp_zir_len, fullbandScale ), LD_FSCALE_DENOM ) ); /*Q0*/ lerp( acelp_zir, tmp_buf, tmp, acelp_zir_len ); - acelp_zir_len = tmp; + acelp_zir_len = tmp; /*Q0*/ move16(); - acelp_zir = tmp_buf; + acelp_zir = tmp_buf; /*Qx*/ IF( GE_16( acelp_zir_len, 2 * 64 ) ) @@ -456,25 +456,25 @@ void tcx_windowing_synthesis_current_frame( /* apply a simple low-pass to the ZIR, to avoid potentially unmasked HF content */ FOR( i = 2; i < acelp_zir_len; i++ ) { - L_tmp = L_mult( acelp_zir[i - 2], 8192 ); - L_tmp = L_mac( L_tmp, acelp_zir[i - 1], 11469 ); - acelp_zir[i] = mac_r( L_tmp, acelp_zir[i], 13107 ); + L_tmp = L_mult( acelp_zir[i - 2], 8192 /*0.25 in Q15*/ ); + L_tmp = L_mac( L_tmp, acelp_zir[i - 1], 11469 /*0.35 in Q15*/ ); + acelp_zir[i] = mac_r( L_tmp, acelp_zir[i], 13107 /*0.40 in Q15*/ ); /*Qx*/ move16(); } - L_tmp = L_mult( acelp_zir[acelp_zir_len - 1], 13107 ); - L_tmp = L_mac( L_tmp, acelp_zir[acelp_zir_len - 1], 11469 ); - acelp_zir[acelp_zir_len - 1] = mac_r( L_tmp, acelp_zir[acelp_zir_len - 2], 8192 ); + L_tmp = L_mult( acelp_zir[acelp_zir_len - 1], 13107 /*0.40 in Q15*/ ); + L_tmp = L_mac( L_tmp, acelp_zir[acelp_zir_len - 1], 11469 /*0.35 in Q15*/ ); + acelp_zir[acelp_zir_len - 1] = mac_r( L_tmp, acelp_zir[acelp_zir_len - 2], 8192 /*0.25 in Q15*/ ); /*Qx*/ move16(); L_tmp = L_mult( acelp_zir[acelp_zir_len - 2], 13107 ); L_tmp = L_mac( L_tmp, acelp_zir[acelp_zir_len - 1], 11469 ); - acelp_zir[acelp_zir_len - 2] = mac_r( L_tmp, acelp_zir[acelp_zir_len - 1], 8192 ); + acelp_zir[acelp_zir_len - 2] = mac_r( L_tmp, acelp_zir[acelp_zir_len - 1], 8192 ); /*Qx*/ move16(); FOR( i = acelp_zir_len - 3; i >= 0; i-- ) { L_tmp = L_mult( acelp_zir[i], 13107 ); L_tmp = L_mac( L_tmp, acelp_zir[i + 1], 11469 ); - acelp_zir[i] = mac_r( L_tmp, acelp_zir[i + 2], 8192 ); + acelp_zir[i] = mac_r( L_tmp, acelp_zir[i + 2], 8192 ); /*Qx*/ move16(); } } @@ -485,7 +485,7 @@ void tcx_windowing_synthesis_current_frame( /*remove reconstructed ZIR and add ACELP ZIR*/ move16(); #ifdef BASOP_NOGLOB - signal[i + overlap + acelp_mem_len] = sub_sat( signal[i + overlap + acelp_mem_len], mult_r_sat( acelp_zir[i], div_s( sub_sat( acelp_zir_len, i ), acelp_zir_len ) ) ); + signal[i + overlap + acelp_mem_len] = sub_sat( signal[i + overlap + acelp_mem_len], mult_r_sat( acelp_zir[i], div_s( sub_sat( acelp_zir_len, i ), acelp_zir_len ) ) ); /*Qx*/ #else signal[i + overlap + acelp_mem_len] = sub( signal[i + overlap + acelp_mem_len], mult_r( acelp_zir[i], div_s( sub( acelp_zir_len, i ), acelp_zir_len ) ) ); #endif @@ -494,45 +494,45 @@ void tcx_windowing_synthesis_current_frame( /* Rectangular window (past-frame is TCX) */ ELSE IF( left_rect == 1 && last_core_bfi != ACELP_CORE ) { - n = add( overlap, acelp_mem_len ); + n = add( overlap, acelp_mem_len ); /*q0*/ FOR( i = 0; i < n; i++ ) { move16(); signal[i] = 0; } - n = shr( window_length, 1 ); + n = shr( window_length, 1 ); /*q0*/ FOR( i = 0; i < n; i++ ) { move16(); - signal[i + overlap + acelp_mem_len] = mult_r( signal[i + overlap + acelp_mem_len], window[i].v.im ); + signal[i + overlap + acelp_mem_len] = mult_r( signal[i + overlap + acelp_mem_len], window[i].v.im ); /*Qx*/ } FOR( ; i < window_length; i++ ) { move16(); - signal[i + overlap + acelp_mem_len] = mult_r( signal[i + overlap + acelp_mem_len], window[window_length - 1 - i].v.re ); + signal[i + overlap + acelp_mem_len] = mult_r( signal[i + overlap + acelp_mem_len], window[window_length - 1 - i].v.re ); /*Qx*/ } } /* Normal window (past-frame is ACELP) */ ELSE IF( left_rect != 1 && last_core_bfi == ACELP_CORE ) { - n = shr( window_length, 1 ); + n = shr( window_length, 1 ); /*q0*/ FOR( i = 0; i < n; i++ ) { move16(); - signal[i] = mult_r( signal[i], window[i].v.im ); + signal[i] = mult_r( signal[i], window[i].v.im ); /*Qx*/ } FOR( ; i < window_length; i++ ) { move16(); - signal[i] = mult_r( signal[i], window[window_length - 1 - i].v.re ); + signal[i] = mult_r( signal[i], window[window_length - 1 - i].v.re ); /*Qx*/ } FOR( i = 0; i < window_length /*acelp_zir_len*/; i++ ) { move16(); - signal[i] = add( signal[i], syn_overl[i] ); + signal[i] = add( signal[i], syn_overl[i] ); /*Qx*/ } } /* Normal window (past-frame is TCX) */ @@ -540,23 +540,23 @@ void tcx_windowing_synthesis_current_frame( { IF( EQ_16( left_mode, 2 ) ) /* min. overlap */ { - n = shr( sub( window_length, window_min_length ), 1 ); + n = shr( sub( window_length, window_min_length ), 1 ); /*q0*/ FOR( i = 0; i < n; i++ ) { *signal++ = 0; move16(); } - n = shr( window_min_length, 1 ); + n = shr( window_min_length, 1 ); /*q0*/ FOR( i = 0; i < n; i++ ) { - *signal = mult_r( *signal, window_min[i].v.im ); + *signal = mult_r( *signal, window_min[i].v.im ); /*Qx*/ move16(); signal++; } FOR( i = 0; i < n; i++ ) { - *signal = mult_r( *signal, window_min[n - 1 - i].v.re ); + *signal = mult_r( *signal, window_min[n - 1 - i].v.re ); /*Qx*/ move16(); signal++; } @@ -575,13 +575,13 @@ void tcx_windowing_synthesis_current_frame( FOR( w = 0; w < n; w++ ) { move16(); - signal[i] = mult_r( signal[i], window_half[w].v.im ); + signal[i] = mult_r( signal[i], window_half[w].v.im ); /*Qx*/ i = add( i, 1 ); } FOR( w = 0; w < n; w++ ) { move16(); - signal[i] = mult_r( signal[i], window_half[window_half_length / 2 - 1 - w].v.re ); + signal[i] = mult_r( signal[i], window_half[window_half_length / 2 - 1 - w].v.re ); /*Qx*/ i = add( i, 1 ); } } @@ -592,12 +592,12 @@ void tcx_windowing_synthesis_current_frame( FOR( i = 0; i < n; i++ ) { move16(); - signal[i] = mult_r( signal[i], window[i].v.im ); + signal[i] = mult_r( signal[i], window[i].v.im ); /*Qx*/ } FOR( ; i < window_length; i++ ) { move16(); - signal[i] = mult_r( signal[i], window[window_length - 1 - i].v.re ); + signal[i] = mult_r( signal[i], window[window_length - 1 - i].v.re ); /*Qx*/ } } } @@ -610,14 +610,14 @@ void tcx_windowing_synthesis_current_frame( * *-------------------------------------------------------------------*/ void tcx_windowing_synthesis_past_frame( - Word16 *signal, /* i/o: signal vector */ - const PWord16 *window, /* i: TCX window vector */ - const PWord16 *window_half, /* i: TCX window vector for half-overlap window */ - const PWord16 *window_min, /* i: TCX minimum overlap window */ - const Word16 window_length, /* i: TCX window length */ - const Word16 window_half_length, /* i: TCX half window length */ - const Word16 window_min_length, /* i: TCX minimum overlap length */ - const Word16 right_mode /* i: overlap mode (left_mode of current frame) */ + Word16 *signal, /* i/o: signal vector Qx*/ + const PWord16 *window, /* i: TCX window vector Q15*/ + const PWord16 *window_half, /* i: TCX window vector for half-overlap window Q15*/ + const PWord16 *window_min, /* i: TCX minimum overlap window Q15*/ + const Word16 window_length, /* i: TCX window length Q0*/ + const Word16 window_half_length, /* i: TCX half window length Q0*/ + const Word16 window_min_length, /* i: TCX minimum overlap length Q0*/ + const Word16 right_mode /* i: overlap mode (left_mode of current frame) Q0*/ ) { @@ -625,23 +625,23 @@ void tcx_windowing_synthesis_past_frame( IF( EQ_16( right_mode, 2 ) ) /* min. overlap */ { - signal += shr( sub( window_length, window_min_length ), 1 ); + signal += shr( sub( window_length, window_min_length ), 1 ); /*Qx*/ n = shr( window_min_length, 1 ); FOR( i = 0; i < n; i++ ) { - *signal = mult_r( *signal, window_min[i].v.re ); + *signal = mult_r( *signal, window_min[i].v.re ); /*Qx*/ move16(); signal++; } FOR( i = 0; i < n; i++ ) { - *signal = mult_r( *signal, window_min[n - 1 - i].v.im ); + *signal = mult_r( *signal, window_min[n - 1 - i].v.im ); /*Qx*/ move16(); signal++; } - n = shr( sub( window_length, window_min_length ), 1 ); + n = shr( sub( window_length, window_min_length ), 1 ); /*Q0*/ FOR( i = 0; i < n; i++ ) { *signal = 0; @@ -653,17 +653,17 @@ void tcx_windowing_synthesis_past_frame( { Word16 w; - i = shr( sub( window_length, window_half_length ), 1 ); - n = shr( window_half_length, 1 ); + i = shr( sub( window_length, window_half_length ), 1 ); /*Q0*/ + n = shr( window_half_length, 1 ); /*Q0*/ FOR( w = 0; w < n; w++ ) { - signal[i] = mult_r( signal[i], window_half[w].v.re ); + signal[i] = mult_r( signal[i], window_half[w].v.re ); /*Qx*/ move16(); i = add( i, 1 ); } FOR( w = 0; w < n; w++ ) { - signal[i] = mult_r( signal[i], window_half[window_half_length / 2 - 1 - w].v.im ); + signal[i] = mult_r( signal[i], window_half[window_half_length / 2 - 1 - w].v.im ); /*Qx*/ move16(); i = add( i, 1 ); } @@ -676,13 +676,13 @@ void tcx_windowing_synthesis_past_frame( ELSE /* normal full/maximum overlap */ { - n = shr( window_length, 1 ); + n = shr( window_length, 1 ); /*Q0*/ FOR( i = 0; i < n; i++ ) { move16(); - signal[i] = mult_r( signal[i], window[i].v.re ); + signal[i] = mult_r( signal[i], window[i].v.re ); /*Qx*/ move16(); - signal[window_length - 1 - i] = mult_r( signal[window_length - 1 - i], window[i].v.im ); + signal[window_length - 1 - i] = mult_r( signal[window_length - 1 - i], window[i].v.im ); /*Qx*/ } } } @@ -693,14 +693,14 @@ void tcx_windowing_synthesis_past_frame( *-------------------------------------------------------------------*/ void lpc2mdct( - Word16 *lpcCoeffs, - const Word16 lpcOrder, - Word16 *mdct_gains, + Word16 *lpcCoeffs, /*Q12*/ + const Word16 lpcOrder, /*Q0*/ + Word16 *mdct_gains, /*Q15 - mdct_gains_exp*/ Word16 *mdct_gains_exp, - Word16 *mdct_inv_gains, + Word16 *mdct_inv_gains, /*Q15 - mdct_inv_gains_exp*/ Word16 *mdct_inv_gains_exp, - const Word16 length, - const Word16 noInverse ) + const Word16 length, /*Q0*/ + const Word16 noInverse /*Q0*/ ) { Word32 ComplexData[2 * FDNS_NPTS]; Word16 i, j, k, sizeN, step, scale, s, tmp16; @@ -714,7 +714,7 @@ void lpc2mdct( #endif assert( length <= FDNS_NPTS ); - sizeN = shl( length, 1 ); + sizeN = shl( length, 1 ); /*Q0*/ BASOP_getTables( NULL, &ptwiddle, &step, sizeN ); /*ODFT*/ @@ -722,9 +722,9 @@ void lpc2mdct( /* pre-twiddle */ FOR( i = 0; i <= lpcOrder; i++ ) { - ComplexData[2 * i] = L_mult( lpcCoeffs[i], ptwiddle->v.re ); + ComplexData[2 * i] = L_mult( lpcCoeffs[i], ptwiddle->v.re ); /*Q12*/ move32(); - ComplexData[2 * i + 1] = L_negate( L_mult( lpcCoeffs[i], ptwiddle->v.im ) ); + ComplexData[2 * i + 1] = L_negate( L_mult( lpcCoeffs[i], ptwiddle->v.im ) ); /*Q12*/ move32(); ptwiddle += step; } @@ -757,17 +757,17 @@ void lpc2mdct( { /* half length FFT */ scale = add( norm_s( lpcCoeffs[0] ), 1 ); - BASOP_cfft( (cmplx *) ComplexData, FDNS_NPTS, &scale, workBuffer ); + BASOP_cfft( (cmplx *) ComplexData, FDNS_NPTS, &scale, workBuffer ); /*Q31 - scale*/ /*Get amplitude*/ j = sub( length, 1 ); k = 0; FOR( i = 0; i < length / 2; i++ ) { s = sub( norm_l( L_max( L_abs( ComplexData[2 * i] ), L_abs( ComplexData[2 * i + 1] ) ) ), 1 ); - tmp16 = extract_h( L_shl( ComplexData[2 * i], s ) ); - tmp32 = L_mult( tmp16, tmp16 ); - tmp16 = extract_h( L_shl( ComplexData[2 * i + 1], s ) ); - tmp16 = mac_r( tmp32, tmp16, tmp16 ); + tmp16 = extract_h( L_shl( ComplexData[2 * i], s ) ); /*Q15 - scale + s*/ + tmp32 = L_mult( tmp16, tmp16 ); /*Q15 - 2*(scale - s)*/ + tmp16 = extract_h( L_shl( ComplexData[2 * i + 1], s ) ); /*Q15 - scale + s*/ + tmp16 = mac_r( tmp32, tmp16, tmp16 ); /*Q15 - 2*(scale - s)*/ s = shl( sub( scale, s ), 1 ); if ( tmp16 == 0 ) { @@ -779,10 +779,10 @@ void lpc2mdct( tmp16 = 1; move16(); } - BASOP_Util_Sqrt_InvSqrt_MantExp( tmp16, s, &g, &g_e, &ig, &ig_e ); + BASOP_Util_Sqrt_InvSqrt_MantExp( tmp16, s, &g, &g_e, &ig, &ig_e ); /*Q15 - ig_e*/ if ( mdct_gains != 0 ) { - mdct_gains[k] = g; + mdct_gains[k] = g; /*Q15 - g_e*/ move16(); } if ( mdct_gains_exp != 0 ) @@ -792,7 +792,7 @@ void lpc2mdct( } if ( mdct_inv_gains != 0 ) { - mdct_inv_gains[k] = ig; + mdct_inv_gains[k] = ig; /*Q15 - ig_e*/ move16(); } if ( mdct_inv_gains_exp != 0 ) @@ -802,10 +802,10 @@ void lpc2mdct( } k = add( k, 1 ); s = sub( norm_l( L_max( L_abs( ComplexData[2 * j] ), L_abs( ComplexData[2 * j + 1] ) ) ), 1 ); - tmp16 = extract_h( L_shl( ComplexData[2 * j], s ) ); - tmp32 = L_mult( tmp16, tmp16 ); - tmp16 = extract_h( L_shl( ComplexData[2 * j + 1], s ) ); - tmp16 = mac_r( tmp32, tmp16, tmp16 ); + tmp16 = extract_h( L_shl( ComplexData[2 * j], s ) ); /*Q15 - scale + s*/ + tmp32 = L_mult( tmp16, tmp16 ); /*Q15 - 2*(scale - s)*/ + tmp16 = extract_h( L_shl( ComplexData[2 * j + 1], s ) ); /*Q15 - scale + s*/ + tmp16 = mac_r( tmp32, tmp16, tmp16 ); /*Q15 - 2*(scale - s)*/ s = shl( sub( scale, s ), 1 ); if ( tmp16 == 0 ) { @@ -820,7 +820,7 @@ void lpc2mdct( BASOP_Util_Sqrt_InvSqrt_MantExp( tmp16, s, &g, &g_e, &ig, &ig_e ); if ( mdct_gains != 0 ) { - mdct_gains[k] = g; + mdct_gains[k] = g; /*Q15 - g_e*/ move16(); } if ( mdct_gains_exp != 0 ) @@ -830,7 +830,7 @@ void lpc2mdct( } if ( mdct_inv_gains != 0 ) { - mdct_inv_gains[k] = ig; + mdct_inv_gains[k] = ig; /*Q15 - ig_e*/ move16(); } if ( mdct_inv_gains_exp != 0 ) @@ -845,13 +845,13 @@ void lpc2mdct( } void lpc2mdct_2( - Word16 *lpcCoeffs, - const Word16 lpcOrder, - Word16 mdct_gains_fx[], + Word16 *lpcCoeffs, /*Q12*/ + const Word16 lpcOrder, /*Q0*/ + Word16 mdct_gains_fx[], /*Q15 - mdct_gains_e*/ Word16 mdct_gains_e[], - Word16 mdct_inv_gains_fx[], + Word16 mdct_inv_gains_fx[], /*Q15 - mdct_inv_gains_e*/ Word16 mdct_inv_gains_e[], - const Word16 length ) + const Word16 length /*Q0*/ ) { Word16 i, sizeN, j, k, step, scale, s, tmp16; Word16 g, g_e, ig, ig_e; @@ -860,16 +860,16 @@ void lpc2mdct_2( const PWord16 *ptwiddle; assert( length <= FDNS_NPTS ); - sizeN = shl( length, 1 ); + sizeN = shl( length, 1 ); /*Q0*/ BASOP_getTables( NULL, &ptwiddle, &step, sizeN ); /* ODFT */ FOR( i = 0; i < lpcOrder + 1; i++ ) { - RealData_fx[i] = L_mult( lpcCoeffs[i], ptwiddle->v.re ); + RealData_fx[i] = L_mult( lpcCoeffs[i], ptwiddle->v.re ); /*Q12*/ move32(); - ImagData_fx[i] = L_negate( L_mult( lpcCoeffs[i], ptwiddle->v.im ) ); + ImagData_fx[i] = L_negate( L_mult( lpcCoeffs[i], ptwiddle->v.im ) ); /*Q12*/ move32(); ptwiddle += step; } @@ -884,7 +884,7 @@ void lpc2mdct_2( /* half length FFT */ scale = add( norm_s( lpcCoeffs[0] ), 1 ); - BASOP_cfft_ivas( RealData_fx, ImagData_fx, 1, &scale ); + BASOP_cfft_ivas( RealData_fx, ImagData_fx, 1, &scale ); /*Q31 - scale*/ /*Get amplitude*/ j = sub( FDNS_NPTS, 1 ); @@ -896,11 +896,11 @@ void lpc2mdct_2( { s = sub( norm_l( L_max( L_abs( RealData_fx[i] ), L_abs( ImagData_fx[i] ) ) ), 1 ); - tmp16 = extract_h( L_shl( RealData_fx[i], s ) ); - tmp32 = L_mult( tmp16, tmp16 ); + tmp16 = extract_h( L_shl( RealData_fx[i], s ) ); /*Q15 - scale + s*/ + tmp32 = L_mult( tmp16, tmp16 ); /*Q15 - 2*(scale - s)*/ - tmp16 = extract_h( L_shl( ImagData_fx[i], s ) ); - tmp16 = mac_r( tmp32, tmp16, tmp16 ); + tmp16 = extract_h( L_shl( ImagData_fx[i], s ) ); /*Q15 - scale + s*/ + tmp16 = mac_r( tmp32, tmp16, tmp16 ); /*Q15 - 2*(scale - s)*/ s = shl( sub( scale, s ), 1 ); @@ -919,7 +919,7 @@ void lpc2mdct_2( if ( mdct_gains_fx != NULL ) { - mdct_gains_fx[k] = g; + mdct_gains_fx[k] = g; /*Q15 - g_e*/ move16(); } @@ -931,7 +931,7 @@ void lpc2mdct_2( if ( mdct_inv_gains_fx != NULL ) { - mdct_inv_gains_fx[k] = ig; + mdct_inv_gains_fx[k] = ig; /*Q15 - ig_e*/ move16(); } @@ -946,11 +946,11 @@ void lpc2mdct_2( s = sub( norm_l( L_max( L_abs( RealData_fx[j] ), L_abs( ImagData_fx[j] ) ) ), 1 ); - tmp16 = extract_h( L_shl( RealData_fx[j], s ) ); - tmp32 = L_mult( tmp16, tmp16 ); + tmp16 = extract_h( L_shl( RealData_fx[j], s ) ); /*Q15 - scale + s*/ + tmp32 = L_mult( tmp16, tmp16 ); /*Q15 - 2*(scale - s)*/ - tmp16 = extract_h( L_shl( ImagData_fx[j], s ) ); - tmp16 = mac_r( tmp32, tmp16, tmp16 ); + tmp16 = extract_h( L_shl( ImagData_fx[j], s ) ); /*Q15 - scale + s*/ + tmp16 = mac_r( tmp32, tmp16, tmp16 ); /*Q15 - 2*(scale - s)*/ s = shl( sub( scale, s ), 1 ); @@ -1006,9 +1006,9 @@ void lpc2mdct_2( * \param gains_exp shaping gains exponents */ void mdct_shaping( - Word32 x[], - const Word16 lg, - const Word16 gains[], + Word32 x[], /*Qx*/ + const Word16 lg, /*Q0*/ + const Word16 gains[], /*Q15 - gains_exp*/ const Word16 gains_exp[] /*const Word16 nBands*/ /*Parameter added in IVAS, but always equal to FDNS_NPTS */ ) @@ -1016,7 +1016,7 @@ void mdct_shaping( Word16 i, k, l; Word16 m, n, k1, k2, j; - Word32 *px = x; + Word32 *px = x; /*Qx*/ Word16 const *pgains = gains; Word16 const *pgainsexp = gains_exp; #ifdef BASOP_NOGLOB_DECLARE_LOCAL @@ -1024,21 +1024,21 @@ void mdct_shaping( #endif /* FDNS_NPTS = 64 */ - k = shr( lg, 6 ); + k = shr( lg, 6 ); /*Q0*/ m = s_and( lg, 0x3F ); IF( m != 0 ) { IF( LE_16( m, FDNS_NPTS / 2 ) ) { - n = idiv1616U( FDNS_NPTS, m ); + n = idiv1616U( FDNS_NPTS, m ); /*Q0*/ k1 = k; move16(); k2 = add( k, 1 ); } ELSE { - n = idiv1616U( FDNS_NPTS, sub( FDNS_NPTS, m ) ); + n = idiv1616U( FDNS_NPTS, sub( FDNS_NPTS, m ) ); /*Q0*/ k1 = add( k, 1 ); k2 = k; move16(); @@ -1072,7 +1072,7 @@ void mdct_shaping( FOR( l = 0; l < k; l++ ) { - *x = L_shl( Mpy_32_16_r( *x, *gains ), *gains_exp ); + *x = L_shl( Mpy_32_16_r( *x, *gains ), *gains_exp ); /*Qx*/ move32(); x++; } @@ -1086,13 +1086,13 @@ void mdct_shaping( { FOR( l = 0; l < k; l++ ) { - x = &px[l]; + x = &px[l]; /*Qx*/ gains = pgains; gains_exp = pgainsexp; FOR( i = 0; i < FDNS_NPTS; i++ ) { #ifdef BASOP_NOGLOB - *x = L_shl_o( Mpy_32_16_r( *x, *gains ), *gains_exp, &Overflow ); + *x = L_shl_o( Mpy_32_16_r( *x, *gains ), *gains_exp, &Overflow ); /*Qx*/ #else *x = L_shl( Mpy_32_16_r( *x, *gains ), *gains_exp ); #endif @@ -1106,13 +1106,13 @@ void mdct_shaping( } void mdct_shaping_16( - const Word16 x[], - const Word16 lg, - const Word16 lg_total, - const Word16 gains[], + const Word16 x[], /*Qx*/ + const Word16 lg, /*Q0*/ + const Word16 lg_total, /*Q0*/ + const Word16 gains[], /*15 - gains_exp*/ const Word16 gains_exp[], Word16 gains_max_exp, - Word32 y[] ) + Word32 y[] /*Qx*/ ) { Word16 i, k, l; Word16 m, gain_exp; @@ -1123,7 +1123,7 @@ void mdct_shaping_16( Word16 const *pgains_exp; /* FDNS_NPTS = 64 */ - k = shr( lg, 6 ); + k = shr( lg, 6 ); /*Q0*/ m = s_and( lg, 0x3F ); assert( m == 0 ); @@ -1135,13 +1135,13 @@ void mdct_shaping_16( } FOR( l = 0; l < k; l++ ) { - px = &x[l]; - py = &y[l]; - pgains = gains; + px = &x[l]; /*Qx*/ + py = &y[l]; /*Qx*/ + pgains = gains; /*15 - gains_exp*/ pgains_exp = gains_exp_loc; FOR( i = 0; i < FDNS_NPTS; i++ ) { - *py = L_shl( L_mult( *px, *pgains ), *pgains_exp ); + *py = L_shl( L_mult( *px, *pgains ), *pgains_exp ); /*Qx*/ move32(); px += k; py += k; @@ -1154,16 +1154,16 @@ void mdct_shaping_16( gain_exp = sub( gains_exp[FDNS_NPTS - 1], gains_max_exp ); FOR( i = lg; i < lg_total; i++ ) { - y[i] = L_shl( L_mult( x[i], gains[FDNS_NPTS - 1] ), gain_exp ); + y[i] = L_shl( L_mult( x[i], gains[FDNS_NPTS - 1] ), gain_exp ); /*Qx*/ move32(); } } void mdct_noiseShaping_ivas_fx( - Word32 x_fx[], + Word32 x_fx[], /*Q31 - x_e*/ Word16 *x_e, - const Word16 lg, - const Word16 gains_fx[], + const Word16 lg, /*Q0*/ + const Word16 gains_fx[], /*Q15 - gains_exp*/ const Word16 gains_exp[] /*const Word16 nBands*/ /*Parameter added in IVAS, but always equal to FDNS_NPTS */ ) @@ -1174,7 +1174,7 @@ void mdct_noiseShaping_ivas_fx( j = 0; move16(); /* FDNS_NPTS = 64 */ - k = shr( lg, 6 ); + k = shr( lg, 6 ); /*Q0*/ m = s_and( lg, 0x3F ); Word16 max_e = MIN16B; @@ -1188,14 +1188,14 @@ void mdct_noiseShaping_ivas_fx( { IF( LE_16( m, FDNS_NPTS / 2 ) ) { - n = idiv1616U( FDNS_NPTS, m ); + n = idiv1616U( FDNS_NPTS, m ); /*Q0*/ k1 = k; move16(); k2 = add( k, 1 ); } ELSE { - n = idiv1616U( FDNS_NPTS, sub( FDNS_NPTS, m ) ); + n = idiv1616U( FDNS_NPTS, sub( FDNS_NPTS, m ) ); /*Q0*/ k1 = add( k, 1 ); k2 = k; move16(); @@ -1224,9 +1224,9 @@ void mdct_noiseShaping_ivas_fx( FOR( l = 0; l < k; l++ ) { - x_fx[i] = Mpy_32_16_1( x_fx[i], gains_fx[j] ); + x_fx[i] = Mpy_32_16_1( x_fx[i], gains_fx[j] ); /*Q31 - x_e*/ move32(); - x_fx[i] = L_shr( x_fx[i], sub( max_e, add( *x_e, gains_exp[j] ) ) ); + x_fx[i] = L_shr( x_fx[i], sub( max_e, add( *x_e, gains_exp[j] ) ) ); /*Q31 - max_e*/ move32(); i = add( i, 1 ); } @@ -1239,9 +1239,9 @@ void mdct_noiseShaping_ivas_fx( { FOR( l = 0; l < k; l++ ) { - x_fx[i] = Mpy_32_16_1( x_fx[i], gains_fx[j] ); + x_fx[i] = Mpy_32_16_1( x_fx[i], gains_fx[j] ); /*Q31 - x_e*/ move32(); - x_fx[i] = L_shr( x_fx[i], sub( max_e, add( *x_e, gains_exp[j] ) ) ); + x_fx[i] = L_shr( x_fx[i], sub( max_e, add( *x_e, gains_exp[j] ) ) ); /*Q31 - max_e*/ move32(); i = add( i, 1 ); } @@ -1257,9 +1257,9 @@ void mdct_noiseShaping_ivas_fx( void mdct_noiseShaping_interp( - Word32 x[], - const Word16 lg, - Word16 gains[], + Word32 x[], /*Qx*/ + const Word16 lg, /*Q0*/ + Word16 gains[], /*Q15 - gains_exp*/ Word16 gains_exp[] ) { Word16 i, j, jp, jn, k, l; @@ -1267,7 +1267,7 @@ void mdct_noiseShaping_interp( assert( lg % FDNS_NPTS == 0 ); - k = shr( lg, 6 ); /* FDNS_NPTS = 64 */ + k = shr( lg, 6 ); /* FDNS_NPTS = 64 Q0*/ IF( gains ) { @@ -1283,11 +1283,11 @@ void mdct_noiseShaping_interp( FOR( i = 0; i < lg; i += 4 ) { - pg = gains[jp]; + pg = gains[jp]; /*Q15 - gains_exp*/ move16(); - g = gains[j]; + g = gains[j]; /*Q15 - gains_exp*/ move16(); - ng = gains[jn]; + ng = gains[jn]; /*Q15 - gains_exp*/ move16(); /* common exponent for pg and g */ @@ -1298,16 +1298,16 @@ void mdct_noiseShaping_interp( g = shl( g, tmp ); e = s_max( gains_exp[j], gains_exp[jp] ); - tmp = mac_r( L_mult( pg, 12288 /*0.375f Q15*/ ), g, 20480 /*0.625f Q15*/ ); - x[i] = L_shl( Mpy_32_16_1( x[i], tmp ), e ); + tmp = mac_r( L_mult( pg, 12288 /*0.375f Q15*/ ), g, 20480 /*0.625f Q15*/ ); /*Q15 - gains_exp*/ + x[i] = L_shl( Mpy_32_16_1( x[i], tmp ), e ); /*Qx*/ move32(); - tmp = mac_r( L_mult( pg, 4096 /*0.125f Q15*/ ), g, 28672 /*0.875f Q15*/ ); - x[i + 1] = L_shl( Mpy_32_16_1( x[i + 1], tmp ), e ); + tmp = mac_r( L_mult( pg, 4096 /*0.125f Q15*/ ), g, 28672 /*0.875f Q15*/ ); /*Q15 - gains_exp*/ + x[i + 1] = L_shl( Mpy_32_16_1( x[i + 1], tmp ), e ); /*Qx*/ move32(); /* common exponent for g and ng */ - g = gains[j]; + g = gains[j]; /*Q15 - gains_exp*/ move16(); tmp = sub( gains_exp[j], gains_exp[jn] ); if ( tmp > 0 ) @@ -1316,12 +1316,12 @@ void mdct_noiseShaping_interp( g = shl( g, tmp ); e = s_max( gains_exp[j], gains_exp[jn] ); - tmp = mac_r( L_mult( g, 28672 /*0.875f Q15*/ ), ng, 4096 /*0.125f Q15*/ ); - x[i + 2] = L_shl( Mpy_32_16_1( x[i + 2], tmp ), e ); + tmp = mac_r( L_mult( g, 28672 /*0.875f Q15*/ ), ng, 4096 /*0.125f Q15*/ ); /*Q15 - gains_exp*/ + x[i + 2] = L_shl( Mpy_32_16_1( x[i + 2], tmp ), e ); /*Qx*/ move32(); - tmp = mac_r( L_mult( g, 20480 /*0.625f Q15*/ ), ng, 12288 /*0.375f Q15*/ ); - x[i + 3] = L_shl( Mpy_32_16_1( x[i + 3], tmp ), e ); + tmp = mac_r( L_mult( g, 20480 /*0.625f Q15*/ ), ng, 12288 /*0.375f Q15*/ ); /*Q15 - gains_exp*/ + x[i + 3] = L_shl( Mpy_32_16_1( x[i + 3], tmp ), e ); /*Qx*/ move32(); jp = j; @@ -1342,11 +1342,11 @@ void mdct_noiseShaping_interp( FOR( i = 0; i < lg; i += 5 ) { - pg = gains[jp]; + pg = gains[jp]; /*Q15 - gains_exp*/ move16(); - g = gains[j]; + g = gains[j]; /*Q15 - gains_exp*/ move16(); - ng = gains[jn]; + ng = gains[jn]; /*Q15 - gains_exp*/ move16(); /* common exponent for pg and g */ @@ -1357,20 +1357,20 @@ void mdct_noiseShaping_interp( g = shl( g, tmp ); e = s_max( gains_exp[j], gains_exp[jp] ); - tmp = mac_r( L_mult( pg, 13107 /*0.40f Q15*/ ), g, 19661 /*0.60f Q15*/ ); - x[i] = L_shl( Mpy_32_16_1( x[i], tmp ), e ); + tmp = mac_r( L_mult( pg, 13107 /*0.40f Q15*/ ), g, 19661 /*0.60f Q15*/ ); /*Q15 - gains_exp*/ + x[i] = L_shl( Mpy_32_16_1( x[i], tmp ), e ); /*Qx*/ move32(); - tmp = mac_r( L_mult( pg, 6554 /*0.20f Q15*/ ), g, 26214 /*0.80f Q15*/ ); - x[i + 1] = L_shl( Mpy_32_16_1( x[i + 1], tmp ), e ); + tmp = mac_r( L_mult( pg, 6554 /*0.20f Q15*/ ), g, 26214 /*0.80f Q15*/ ); /*Q15 - gains_exp*/ + x[i + 1] = L_shl( Mpy_32_16_1( x[i + 1], tmp ), e ); /*Qx*/ move32(); - x[i + 2] = L_shl( Mpy_32_16_1( x[i + 2], gains[j] ), gains_exp[j] ); + x[i + 2] = L_shl( Mpy_32_16_1( x[i + 2], gains[j] ), gains_exp[j] ); /*Qx*/ move32(); /* common exponent for g and ng */ - g = gains[j]; + g = gains[j]; /*Q15 - gains_exp*/ move16(); tmp = sub( gains_exp[j], gains_exp[jn] ); if ( tmp > 0 ) @@ -1379,12 +1379,12 @@ void mdct_noiseShaping_interp( g = shl( g, tmp ); e = s_max( gains_exp[j], gains_exp[jn] ); - tmp = mac_r( L_mult( g, 26214 /*0.80f Q15*/ ), ng, 6554 /*0.20f Q15*/ ); - x[i + 3] = L_shl( Mpy_32_16_1( x[i + 3], tmp ), e ); + tmp = mac_r( L_mult( g, 26214 /*0.80f Q15*/ ), ng, 6554 /*0.20f Q15*/ ); /*Q15 - gains_exp*/ + x[i + 3] = L_shl( Mpy_32_16_1( x[i + 3], tmp ), e ); /*Qx*/ move32(); - tmp = mac_r( L_mult( g, 19661 /*0.60f Q15*/ ), ng, 13107 /*0.40f Q15*/ ); - x[i + 4] = L_shl( Mpy_32_16_1( x[i + 4], tmp ), e ); + tmp = mac_r( L_mult( g, 19661 /*0.60f Q15*/ ), ng, 13107 /*0.40f Q15*/ ); /*Q15 - gains_exp*/ + x[i + 4] = L_shl( Mpy_32_16_1( x[i + 4], tmp ), e ); /*Qx*/ move32(); jp = j; @@ -1400,7 +1400,7 @@ void mdct_noiseShaping_interp( { FOR( l = 0; l < k; l++ ) { - *x = L_shl( Mpy_32_16_1( *x, *gains ), *gains_exp ); + *x = L_shl( Mpy_32_16_1( *x, *gains ), *gains_exp ); /*Qx*/ move32(); x++; } @@ -1413,10 +1413,10 @@ void mdct_noiseShaping_interp( } void PsychAdaptLowFreqDeemph( - Word32 x[], - const Word16 lpcGains[], + Word32 x[], /*Qx*/ + const Word16 lpcGains[], /*Q15 - lpcGains_e*/ const Word16 lpcGains_e[], - Word16 lf_deemph_factors[] ) + Word16 lf_deemph_factors[] /*Q15*/ ) { Word16 i; Word16 max_val, max_e, fac, min, min_e, tmp, tmp_e; @@ -1428,11 +1428,11 @@ void PsychAdaptLowFreqDeemph( assert( lpcGains[0] >= 0x4000 ); - max_val = lpcGains[0]; + max_val = lpcGains[0]; /*Q15 - lpcGains_e*/ move16(); max_e = lpcGains_e[0]; move16(); - min = lpcGains[0]; + min = lpcGains[0]; /*Q15 - lpcGains_e*/ move16(); min_e = lpcGains_e[0]; move16(); @@ -1442,7 +1442,7 @@ void PsychAdaptLowFreqDeemph( { IF( compMantExp16Unorm( lpcGains[i], lpcGains_e[i], min, min_e ) < 0 ) { - min = lpcGains[i]; + min = lpcGains[i]; /*Q15 - lpcGains_e*/ move16(); min_e = lpcGains_e[i]; move16(); @@ -1450,7 +1450,7 @@ void PsychAdaptLowFreqDeemph( IF( compMantExp16Unorm( lpcGains[i], lpcGains_e[i], max_val, max_e ) > 0 ) { - max_val = lpcGains[i]; + max_val = lpcGains[i]; /*Q15 - lpcGains_e*/ move16(); max_e = lpcGains_e[i]; move16(); @@ -1465,7 +1465,7 @@ void PsychAdaptLowFreqDeemph( /* fac = tmp = (float)pow(max_val / min, 0.0078125f); */ tmp_e = min_e; move16(); - tmp = Inv16( min, &tmp_e ); + tmp = Inv16( min, &tmp_e ); /*Q15 - tmp_e*/ L_tmp = L_shl( L_mult( tmp, max_val ), add( tmp_e, max_e ) ); /* Q31 */ L_tmp = BASOP_Util_Log2( L_tmp ); /* Q25 */ L_tmp = L_shr( L_tmp, 7 ); /* 0.0078125f = 1.f/(1<<7) */ @@ -1488,19 +1488,19 @@ void PsychAdaptLowFreqDeemph( lf_deemph_factors[i] = mult_r( lf_deemph_factors[i], fac ); move16(); } - fac = mult_r( fac, tmp ); + fac = mult_r( fac, tmp ); /* Q15 */ } } } void AdaptLowFreqDeemph( - Word32 x[], + Word32 x[], /*Q31 - x_e*/ Word16 x_e, - Word16 tcx_lpc_shaped_ari, - Word16 lpcGains[], + Word16 tcx_lpc_shaped_ari, /*Q0*/ + Word16 lpcGains[], /*Q15 - lpcGains_e*/ Word16 lpcGains_e[], - const Word16 lg, - Word16 lf_deemph_factors[] ) + const Word16 lg, /*Q0*/ + Word16 lf_deemph_factors[] /*Q15*/ ) { Word16 i, i_max, i_max_old, lg_4; @@ -1529,13 +1529,13 @@ void AdaptLowFreqDeemph( move32(); if ( x[i] < 0 ) - tmp32 = L_add( x[i], v2 ); + tmp32 = L_add( x[i], v2 ); /*Q31 - x_e*/ if ( x[i] > 0 ) - tmp32 = L_sub( x[i], v2 ); + tmp32 = L_sub( x[i], v2 ); /*Q31 - x_e*/ assert( tmp32 != 0 ); - x[i] = tmp32; + x[i] = tmp32; /*Q31 - x_e*/ move32(); i_max = i; move16(); @@ -1546,14 +1546,14 @@ void AdaptLowFreqDeemph( /* 2. expand value range of all xi up to i_max: two extra steps */ FOR( i = 0; i < i_max; i++ ) { - x[i] = L_shr( x[i], 1 ); + x[i] = L_shr( x[i], 1 ); /*Q31 - x_e*/ move32(); - lf_deemph_factors[i] = shr( lf_deemph_factors[i], 1 ); + lf_deemph_factors[i] = shr( lf_deemph_factors[i], 1 ); /*Q15*/ move16(); } /* 3. find first magnitude maximum in lower quarter of spectrum */ - i_max_old = i_max; + i_max_old = i_max; /*Q0*/ move16(); IF( i_max_old >= 0 ) @@ -1567,10 +1567,10 @@ void AdaptLowFreqDeemph( { assert( x[i] != 0 ); if ( x[i] < 0 ) - tmp32 = L_add( x[i], v2 ); + tmp32 = L_add( x[i], v2 ); /*Q31 - x_e*/ if ( x[i] >= 0 ) - tmp32 = L_sub( x[i], v2 ); - x[i] = tmp32; + tmp32 = L_sub( x[i], v2 ); /*Q31 - x_e*/ + x[i] = tmp32; /*Q31 - x_e*/ move32(); i_max = i; move16(); @@ -1582,14 +1582,14 @@ void AdaptLowFreqDeemph( /* 4. expand value range of all xi up to i_max: two extra steps */ FOR( i = 0; i < i_max; i++ ) { - x[i] = L_shr( x[i], 1 ); + x[i] = L_shr( x[i], 1 ); /*Q31 - x_e*/ move32(); - lf_deemph_factors[i] = shr( lf_deemph_factors[i], 1 ); + lf_deemph_factors[i] = shr( lf_deemph_factors[i], 1 ); /*Q15*/ move16(); } /* 5. always expand two lines; lines could be at index 0 and 1! */ - i_max = s_max( i_max, i_max_old ); + i_max = s_max( i_max, i_max_old ); /*Q0*/ i = add( i_max, 1 ); IF( x[i] < 0 ) @@ -1598,17 +1598,17 @@ void AdaptLowFreqDeemph( if ( tmp32 > 0 ) { - lf_deemph_factors[i] = shr( lf_deemph_factors[i], 1 ); + lf_deemph_factors[i] = shr( lf_deemph_factors[i], 1 ); /*Q15*/ move16(); } if ( tmp32 <= 0 ) { - x[i] = L_add( x[i], v2 ); + x[i] = L_add( x[i], v2 ); /*Q31 - x_e*/ move32(); } if ( tmp32 > 0 ) { - x[i] = L_shr( x[i], 1 ); + x[i] = L_shr( x[i], 1 ); /*Q31 - x_e*/ move32(); } } @@ -1618,17 +1618,17 @@ void AdaptLowFreqDeemph( if ( tmp32 < 0 ) { - lf_deemph_factors[i] = shr( lf_deemph_factors[i], 1 ); + lf_deemph_factors[i] = shr( lf_deemph_factors[i], 1 ); /*Q15*/ move16(); } if ( tmp32 >= 0 ) { - x[i] = L_sub( x[i], v2 ); + x[i] = L_sub( x[i], v2 ); /*Q31 - x_e*/ move32(); } if ( tmp32 < 0 ) { - x[i] = L_shr( x[i], 1 ); + x[i] = L_shr( x[i], 1 ); /*Q31 - x_e*/ move32(); } } @@ -1640,17 +1640,17 @@ void AdaptLowFreqDeemph( if ( tmp32 > 0 ) { - lf_deemph_factors[i] = shr( lf_deemph_factors[i], 1 ); + lf_deemph_factors[i] = shr( lf_deemph_factors[i], 1 ); /*Q15*/ move16(); } if ( tmp32 <= 0 ) { - x[i] = L_add( x[i], v2 ); + x[i] = L_add( x[i], v2 ); /*Q31 - x_e*/ move32(); } if ( tmp32 > 0 ) { - x[i] = L_shr( x[i], 1 ); + x[i] = L_shr( x[i], 1 ); /*Q31 - x_e*/ move32(); } } @@ -1660,17 +1660,17 @@ void AdaptLowFreqDeemph( if ( tmp32 < 0 ) { - lf_deemph_factors[i] = shr( lf_deemph_factors[i], 1 ); + lf_deemph_factors[i] = shr( lf_deemph_factors[i], 1 ); /*Q15*/ move16(); } if ( tmp32 >= 0 ) { - x[i] = L_sub( x[i], v2 ); + x[i] = L_sub( x[i], v2 ); /*Q31 - x_e*/ move32(); } if ( tmp32 < 0 ) { - x[i] = L_shr( x[i], 1 ); + x[i] = L_shr( x[i], 1 ); /*Q31 - x_e*/ move32(); } } @@ -1682,17 +1682,17 @@ void AdaptLowFreqDeemph( } void tcx_noise_filling( - Word32 *Q, + Word32 *Q, /*Q31 - Q_e*/ Word16 Q_e, Word16 seed, - const Word16 iFirstLine, - const Word16 lowpassLine, - const Word16 nTransWidth, - const Word16 L_frame, - const Word16 tiltCompFactor, - Word16 fac_ns, - Word16 *infoTCXNoise, - const Word16 element_mode /* i : IVAS element mode */ + const Word16 iFirstLine, /*Q0*/ + const Word16 lowpassLine, /*Q0*/ + const Word16 nTransWidth, /*Q0*/ + const Word16 L_frame, /*Q0*/ + const Word16 tiltCompFactor, /*Q15*/ + Word16 fac_ns, /*Q15*/ + Word16 *infoTCXNoise, /*Q0*/ + const Word16 element_mode /* i : IVAS element mode Q0*/ ) { Word16 i, m, segmentOffset; @@ -1704,14 +1704,14 @@ void tcx_noise_filling( /* get inverse frame length */ - tmp1 = getInvFrameLen( L_frame ); + tmp1 = getInvFrameLen( L_frame ); /*Q21*/ /* tilt_factor = (float)pow(max_val(0.375f, tiltCompFactor), 1.0f/(float)L_frame); */ tmp32 = BASOP_Util_Log2( L_deposit_h( s_max( 0x3000, tiltCompFactor ) ) ); /* 6Q25 */ - tmp32 = L_shr( Mpy_32_16_1( tmp32, tmp1 ), 6 ); + tmp32 = L_shr( Mpy_32_16_1( tmp32, tmp1 ), 6 ); /*Q25*/ BASOP_SATURATE_WARNING_OFF_EVS; #ifdef BASOP_NOGLOB - tilt_factor = round_fx_sat( BASOP_Util_InvLog2( tmp32 ) ); + tilt_factor = round_fx_sat( BASOP_Util_InvLog2( tmp32 ) ); /*Q15*/ #else tilt_factor = round_fx( BASOP_Util_InvLog2( tmp32 ) ); #endif @@ -1720,7 +1720,7 @@ void tcx_noise_filling( /* find last nonzero line below iFirstLine, use it as start offset */ i = iFirstLine; move16(); - tmp1 = shr( iFirstLine, 1 ); + tmp1 = shr( iFirstLine, 1 ); /*Q0*/ IF( EQ_16( element_mode, IVAS_CPE_MDCT ) ) /* ... but only in mono or parametric stereo since it may cause binaural unmasking in discrete stereo */ { segmentOffset = i; @@ -1738,7 +1738,7 @@ void tcx_noise_filling( /* fac_ns *= (float)pow(tilt_factor, (float)i); */ FOR( m = 0; m < i; m++ ) { - fac_ns = mult_r( fac_ns, tilt_factor ); + fac_ns = mult_r( fac_ns, tilt_factor ); /*Q15*/ } i = add( i, 1 ); segmentOffset = i; @@ -1749,7 +1749,7 @@ void tcx_noise_filling( FOR( ; i < lowpassLine; i++ ) { - fac_ns = mult_r( fac_ns, tilt_factor ); + fac_ns = mult_r( fac_ns, tilt_factor ); /*Q15*/ IF( Q[i] != 0 ) { @@ -1758,8 +1758,8 @@ void tcx_noise_filling( /* RMS-normalize current noise-filled segment */ tmp1 = BASOP_Util_Divide3216_Scale( nrg, sub( i, segmentOffset ), &s ); /* mean */ s = add( s, 9 - 15 ); /* scaling */ - tmp1 = ISqrt16( tmp1, &s ); /* 1/RMS */ - tmp1 = mult_r( tmp1, inv_int[nTransWidth] ); /* compensate win */ + tmp1 = ISqrt16( tmp1, &s ); /* 1/RMS Q15 - s*/ + tmp1 = mult_r( tmp1, inv_int[nTransWidth] ); /* compensate win Q15 - s*/ s = add( s, sub( 16, Q_e ) ); /* scaling */ tmp2 = sub( i, win ); @@ -1767,7 +1767,7 @@ void tcx_noise_filling( { FOR( m = segmentOffset; m < tmp2; m++ ) { - Q[m] = L_shl( Mpy_32_16_1( Q[m], tmp1 ), s ); + Q[m] = L_shl( Mpy_32_16_1( Q[m], tmp1 ), s ); /*Q31 - Q_e*/ move32(); } } @@ -1776,7 +1776,7 @@ void tcx_noise_filling( tmp1 = extract_l( L_mult0( tmp2, win ) ); FOR( m = sub( i, win ); m < i; m++ ) { - Q[m] = L_shl( Mpy_32_16_1( Q[m], tmp1 ), s ); + Q[m] = L_shl( Mpy_32_16_1( Q[m], tmp1 ), s ); /*Q31 - Q_e*/ move32(); win = sub( win, 1 ); tmp1 = sub( tmp1, tmp2 ); @@ -1794,7 +1794,7 @@ void tcx_noise_filling( } Random( &seed ); - Q[i] = L_mult0( mult( seed, fac_ns ), win ); + Q[i] = L_mult0( mult( seed, fac_ns ), win ); /*Q31 - Q_e*/ move32(); tmp1 = shr( seed, 4 ); @@ -1813,30 +1813,30 @@ void tcx_noise_filling( /* RMS-normalize uppermost noise-filled segment */ tmp1 = BASOP_Util_Divide3216_Scale( nrg, sub( lowpassLine, segmentOffset ), &s ); /* mean */ s = add( s, 9 - 15 ); /* compensate energy scaling */ - tmp1 = ISqrt16( tmp1, &s ); /* 1/RMS */ - tmp1 = mult_r( tmp1, inv_int[nTransWidth] ); /* compensate win */ + tmp1 = ISqrt16( tmp1, &s ); /* 1/RMS Q15 - s*/ + tmp1 = mult_r( tmp1, inv_int[nTransWidth] ); /* compensate win Q15 - s*/ s = add( s, sub( 16, Q_e ) ); /* compensate noise scaling */ FOR( m = segmentOffset; m < lowpassLine; m++ ) { - Q[m] = L_shl( Mpy_32_16_1( Q[m], tmp1 ), s ); + Q[m] = L_shl( Mpy_32_16_1( Q[m], tmp1 ), s ); /*Q31 - Q_e*/ move32(); } } } void tcx_noise_filling_with_shift( - Word32 *Q, + Word32 *Q, /*Q31 - Q_e*/ Word16 *Q_e, - Word16 seed, - const Word16 iFirstLine, - const Word16 lowpassLine, - const Word16 nTransWidth, - const Word16 L_frame, - const Word16 tiltCompFactor, - Word16 fac_ns, - Word16 *infoTCXNoise, - const Word16 element_mode /* i : IVAS element mode */ + Word16 seed, /*Q0*/ + const Word16 iFirstLine, /*Q0*/ + const Word16 lowpassLine, /*Q0*/ + const Word16 nTransWidth, /*Q0*/ + const Word16 L_frame, /*Q0*/ + const Word16 tiltCompFactor, /*Q0*/ + Word16 fac_ns, /*Q15*/ + Word16 *infoTCXNoise, /*Q0*/ + const Word16 element_mode /* i : IVAS element mode Q0*/ ) { Word16 i, m, segmentOffset; @@ -1850,14 +1850,14 @@ void tcx_noise_filling_with_shift( set16_fx( new_Q_e, *Q_e, N_MAX ); /* get inverse frame length */ - tmp1 = getInvFrameLen( L_frame ); + tmp1 = getInvFrameLen( L_frame ); /*Q21*/ /* tilt_factor = (float)pow(max_val(0.375f, tiltCompFactor), 1.0f/(float)L_frame); */ tmp32 = BASOP_Util_Log2( L_deposit_h( s_max( 0x3000, tiltCompFactor ) ) ); /* 6Q25 */ - tmp32 = L_shr( Mpy_32_16_1( tmp32, tmp1 ), 6 ); + tmp32 = L_shr( Mpy_32_16_1( tmp32, tmp1 ), 6 ); /*Q25*/ BASOP_SATURATE_WARNING_OFF_EVS; #ifdef BASOP_NOGLOB - tilt_factor = round_fx_sat( BASOP_Util_InvLog2( tmp32 ) ); + tilt_factor = round_fx_sat( BASOP_Util_InvLog2( tmp32 ) ); /*Q15*/ #else tilt_factor = round_fx( BASOP_Util_InvLog2( tmp32 ) ); #endif @@ -1884,7 +1884,7 @@ void tcx_noise_filling_with_shift( /* fac_ns *= (float)pow(tilt_factor, (float)i); */ FOR( m = 0; m < i; m++ ) { - fac_ns = mult_r( fac_ns, tilt_factor ); + fac_ns = mult_r( fac_ns, tilt_factor ); /*Q15*/ } i = add( i, 1 ); segmentOffset = i; @@ -1896,7 +1896,7 @@ void tcx_noise_filling_with_shift( FOR( ; i < lowpassLine; i++ ) { - fac_ns = mult_r( fac_ns, tilt_factor ); + fac_ns = mult_r( fac_ns, tilt_factor ); /*Q15*/ IF( Q[i] != 0 ) { @@ -1906,8 +1906,8 @@ void tcx_noise_filling_with_shift( tmp1 = BASOP_Util_Divide3216_Scale( nrg, sub( i, segmentOffset ), &s ); /* mean */ // Q-factor of nrg is -8. exp = 31-(-8) = 39 s = add( s, 39 - 15 ); /* scaling */ - tmp1 = ISqrt16( tmp1, &s ); /* 1/RMS */ - tmp1 = mult_r( tmp1, inv_int[nTransWidth] ); /* compensate win */ + tmp1 = ISqrt16( tmp1, &s ); /* 1/RMS Q15 - s*/ + tmp1 = mult_r( tmp1, inv_int[nTransWidth] ); /* compensate win Q15 - s*/ tmp2 = sub( i, win ); IF( LT_16( segmentOffset, tmp2 ) ) @@ -1916,32 +1916,32 @@ void tcx_noise_filling_with_shift( { Word16 nrm = 31; move16(); - Q[m] = Mpy_32_16_1( Q[m], tmp1 ); + Q[m] = Mpy_32_16_1( Q[m], tmp1 ); /*Q31 - Q_e*/ move32(); IF( Q[m] ) { nrm = norm_l( Q[m] ); } - Q[m] = L_shl( Q[m], nrm ); + Q[m] = L_shl( Q[m], nrm ); /*Q31 - Q_e + nrm*/ move32(); new_Q_e[m] = sub( add( new_Q_e[m], s ), nrm ); move32(); } } - tmp2 = mult( tmp1, inv_int[nTransWidth] ); - tmp1 = extract_l( L_mult0( tmp2, win ) ); + tmp2 = mult( tmp1, inv_int[nTransWidth] ); /*Q15 - s*/ + tmp1 = extract_l( L_mult0( tmp2, win ) ); /*Q15 - s*/ FOR( m = sub( i, win ); m < i; m++ ) { Word16 nrm = 31; - Q[m] = Mpy_32_16_1( Q[m], tmp1 ); + Q[m] = Mpy_32_16_1( Q[m], tmp1 ); /*Q31 - Q_e*/ move32(); IF( Q[m] ) { nrm = norm_l( Q[m] ); } - Q[m] = L_shl( Q[m], nrm ); + Q[m] = L_shl( Q[m], nrm ); /*Q31 - Q_e*/ move32(); new_Q_e[m] = sub( add( new_Q_e[m], s ), nrm ); move32(); @@ -1970,12 +1970,12 @@ void tcx_noise_filling_with_shift( { nrm = norm_l( Q[i] ); } - Q[i] = L_shl( Q[i], nrm ); + Q[i] = L_shl( Q[i], nrm ); /*Q31 - Q_e*/ move32(); new_Q_e[i] = sub( 31, nrm ); tmp1 = shr( seed, 4 ); - nrg = L_mac0( nrg, tmp1, tmp1 ); /* sum up energy of current noise segment */ + nrg = L_mac0( nrg, tmp1, tmp1 ); /* sum up energy of current noise segment Q-8*/ IF( infoTCXNoise ) /* set noiseflags for IGF */ { @@ -1991,8 +1991,8 @@ void tcx_noise_filling_with_shift( tmp1 = BASOP_Util_Divide3216_Scale( nrg, sub( lowpassLine, segmentOffset ), &s ); /* mean */ // Q-factor of nrg is -8. exp = 31-(-8) = 39 s = add( s, 39 - 15 ); /* compensate energy scaling */ - tmp1 = ISqrt16( tmp1, &s ); /* 1/RMS */ - tmp1 = mult_r( tmp1, inv_int[nTransWidth] ); /* compensate win */ + tmp1 = ISqrt16( tmp1, &s ); /* 1/RMS Q15 - s*/ + tmp1 = mult_r( tmp1, inv_int[nTransWidth] ); /* compensate win Q15 - s*/ FOR( m = segmentOffset; m < lowpassLine; m++ ) { @@ -2003,13 +2003,13 @@ void tcx_noise_filling_with_shift( - flt Q[m] = (Q[m] * 2^(new_Q_e[m] - 31)) / (nTransWidth*nTransWidth) - flt tmp1 = (tmp1 * 2^(s - 15)) * (nTransWidth*nTransWidth) */ - Q[m] = Mpy_32_16_1( Q[m], tmp1 ); + Q[m] = Mpy_32_16_1( Q[m], tmp1 ); /*Q15 - Q_e - s*/ move32(); IF( Q[m] ) { nrm = norm_l( Q[m] ); } - Q[m] = L_shl( Q[m], nrm ); + Q[m] = L_shl( Q[m], nrm ); /*Q15 - Q_e - s + nrm*/ move32(); new_Q_e[m] = add( new_Q_e[m], s - nrm ); move32(); @@ -2025,7 +2025,7 @@ void tcx_noise_filling_with_shift( FOR( i = 0; i < lowpassLine; i++ ) { - Q[i] = L_shr( Q[i], sub( max_e, new_Q_e[i] ) ); + Q[i] = L_shr( Q[i], sub( max_e, new_Q_e[i] ) ); /*Q31 - Q_e*/ move32(); } @@ -2040,13 +2040,13 @@ void tcx_noise_filling_with_shift( void InitTnsConfigs( - const Word16 bwidth, - const Word16 L_frame, + const Word16 bwidth, /*Q0*/ + const Word16 L_frame, /*Q0*/ STnsConfig tnsConfig[2][2], - const Word16 igfStopFreq, - const Word32 total_brate, - const Word16 element_mode, - const Word16 MCT_flag ) + const Word16 igfStopFreq, /*Q0*/ + const Word32 total_brate, /*Q0*/ + const Word16 element_mode, /*Q0*/ + const Word16 MCT_flag /*Q0*/ ) { IF( GT_32( total_brate, ACELP_32k ) ) { @@ -2058,13 +2058,13 @@ void InitTnsConfigs( #ifdef IVAS_FLOAT_FIXED void InitTnsConfigs_ivas_fx( - const Word16 bwidth, - const Word16 L_frame, + const Word16 bwidth, /*Q0*/ + const Word16 L_frame, /*Q0*/ STnsConfig tnsConfig[2][2], - const Word16 igfStopFreq, - const Word32 total_brate, - const Word16 element_mode, - const Word16 MCT_flag ) + const Word16 igfStopFreq, /*Q0*/ + const Word32 total_brate, /*Q0*/ + const Word16 element_mode, /*Q0*/ + const Word16 MCT_flag /*Q0*/ ) { IF( GT_32( total_brate, ACELP_32k ) ) { @@ -2078,8 +2078,8 @@ void InitTnsConfigs_ivas_fx( void SetTnsConfig( TCX_CONFIG_HANDLE hTcxCfg, /* i : configuration of TCX */ - const Word16 isTCX20, - const Word16 isAfterACELP ) + const Word16 isTCX20, /*Q0*/ + const Word16 isAfterACELP /*Q0*/ ) { move16(); hTcxCfg->pCurrentTnsConfig = &hTcxCfg->tnsConfig[isTCX20][isAfterACELP]; @@ -2095,10 +2095,10 @@ void SetTnsConfig( void SetAllowTnsOnWhite( STnsConfig tnsConfig[2][2], /* o : updated TNS configurations */ - const Word8 allowTnsOnWhite /* i : flag for TNS in whiteded domain mode */ + const Word8 allowTnsOnWhite /* i : flag for TNS in whiteded domain mode Q0*/ ) { - tnsConfig[0][0].allowTnsOnWhite = allowTnsOnWhite; + tnsConfig[0][0].allowTnsOnWhite = allowTnsOnWhite; /*Q0*/ move16(); tnsConfig[0][1].allowTnsOnWhite = allowTnsOnWhite; move16(); @@ -2112,14 +2112,14 @@ void SetAllowTnsOnWhite( #undef IVAS_CODE_TCX_UTIL void tcx_get_gain( - Word32 *x, /* i: spectrum 1 */ + Word32 *x, /* i: spectrum 1 Q31 - x_e*/ Word16 x_e, /* i: spectrum 1 exponent */ - Word32 *y, /* i: spectrum 2 */ + Word32 *y, /* i: spectrum 2 Q31 - y_e*/ Word16 y_e, /* i: spectrum 2 exponent */ - Word16 n, /* i: length */ - Word16 *gain, /* o: gain */ + Word16 n, /* i: length Q0*/ + Word16 *gain, /* o: gain Q15 - gain_e*/ Word16 *gain_e, /* o: gain exponent */ - Word32 *en_y, /* o: energy of y (optional) */ + Word32 *en_y, /* o: energy of y (optional) Q31 - en_y_e*/ Word16 *en_y_e /* o: energy of y exponent (optional) */ ) { @@ -2138,14 +2138,14 @@ void tcx_get_gain( FOR( i = 0; i < n; i++ ) { if ( x[i] > 0 ) - maxX = L_max( maxX, x[i] ); + maxX = L_max( maxX, x[i] ); /*Q31 - x_e*/ if ( x[i] < 0 ) - minX = L_min( minX, x[i] ); + minX = L_min( minX, x[i] ); /*Q31 - x_e*/ if ( y[i] > 0 ) - maxY = L_max( maxY, y[i] ); + maxY = L_max( maxY, y[i] ); /*Q31 - y_e*/ if ( y[i] < 0 ) - minY = L_min( minY, y[i] ); + minY = L_min( minY, y[i] ); /*Q31 - y_e*/ } sx = s_min( norm_l( maxX ), norm_l( minX ) ); sy = s_min( norm_l( maxY ), norm_l( minY ) ); @@ -2156,9 +2156,9 @@ void tcx_get_gain( corr = L_deposit_l( 0 ); FOR( i = 0; i < n; i++ ) { - tmp = round_fx( L_shl( y[i], sy ) ); - ener = L_mac0( ener, tmp, tmp ); - corr = L_mac0( corr, tmp, round_fx( L_shl( x[i], sx ) ) ); + tmp = round_fx( L_shl( y[i], sy ) ); /*Q15 - y_e + sy*/ + ener = L_mac0( ener, tmp, tmp ); /*Q30 - 2*(y_e - sy)*/ + corr = L_mac0( corr, tmp, round_fx( L_shl( x[i], sx ) ) ); /*Q30 - 2*(x_e - sx + y_e - sy)*/ } if ( ener == 0 ) @@ -2168,15 +2168,15 @@ void tcx_get_gain( corr_e = add( sub( add( x_e, y_e ), add( sx, sy ) ), 1 ); tmp = sub( norm_l( corr ), 1 ); - corr = L_shl( corr, tmp ); + corr = L_shl( corr, tmp ); /*Q31 - corr_e + tmp*/ corr_e = sub( corr_e, tmp ); tmp = norm_l( ener ); - ener = L_shl( ener, tmp ); + ener = L_shl( ener, tmp ); /*Q31 - ener_e + tmp*/ ener_e = sub( ener_e, tmp ); #ifdef BASOP_NOGLOB - tmp = div_s( abs_s( round_fx_o( corr, &Overflow ) ), round_fx_o( ener, &Overflow ) ); + tmp = div_s( abs_s( round_fx_o( corr, &Overflow ) ), round_fx_o( ener, &Overflow ) ); /*Q15 - (corr_e - ener_e)*/ #else tmp = div_s( abs_s( round_fx( corr ) ), round_fx( ener ) ); #endif @@ -2190,7 +2190,7 @@ void tcx_get_gain( if ( en_y != NULL ) { - *en_y = ener; + *en_y = ener; /*Q31 - ener_e*/ move32(); } if ( en_y_e != NULL ) @@ -2248,37 +2248,37 @@ void init_TCX_config_dec( /* TEMPORARY */ #endif void init_TCX_config( TCX_CONFIG_HANDLE hTcxCfg, - Word16 L_frame, - Word16 fscale, - Word16 L_frameTCX, - Word16 fscaleFB ) + Word16 L_frame, /*Q0*/ + Word16 fscale, /*Q0*/ + Word16 L_frameTCX, /*Q0*/ + Word16 fscaleFB /*Q0*/ ) { /* Initialize the TCX MDCT windows */ - hTcxCfg->tcx_mdct_window_length = extract_l( L_shr( L_mult0( L_LOOK_12k8, fscale ), LD_FSCALE_DENOM ) ); + hTcxCfg->tcx_mdct_window_length = extract_l( L_shr( L_mult0( L_LOOK_12k8, fscale ), LD_FSCALE_DENOM ) ); /*Q0*/ move16(); - hTcxCfg->tcx_mdct_window_delay = hTcxCfg->tcx_mdct_window_length; + hTcxCfg->tcx_mdct_window_delay = hTcxCfg->tcx_mdct_window_length; /*Q0*/ move16(); hTcxCfg->tcx_mdct_window_half_length = extract_l( L_shr( L_mult0( L_LOOK_12k8 - NS2SA( 12800, 5000000L ), fscale ), LD_FSCALE_DENOM ) ); move16(); - hTcxCfg->tcx_mdct_window_min_length = shr( L_frame, 4 ); /* 1.25ms */ + hTcxCfg->tcx_mdct_window_min_length = shr( L_frame, 4 ); /* 1.25ms Q0*/ move16(); - hTcxCfg->tcx_mdct_window_trans_length = shr( L_frame, 4 ); /* 1.25ms */ + hTcxCfg->tcx_mdct_window_trans_length = shr( L_frame, 4 ); /* 1.25ms Q0*/ move16(); - hTcxCfg->tcx5Size = shr( L_frame, 2 ); /* 5ms */ + hTcxCfg->tcx5Size = shr( L_frame, 2 ); /* 5ms Q0*/ move16(); - hTcxCfg->tcx_mdct_window_lengthFB = extract_l( L_shr( L_mult0( L_LOOK_12k8, fscaleFB ), LD_FSCALE_DENOM ) ); + hTcxCfg->tcx_mdct_window_lengthFB = extract_l( L_shr( L_mult0( L_LOOK_12k8, fscaleFB ), LD_FSCALE_DENOM ) ); /*Q0*/ move16(); - hTcxCfg->tcx_mdct_window_delayFB = hTcxCfg->tcx_mdct_window_lengthFB; + hTcxCfg->tcx_mdct_window_delayFB = hTcxCfg->tcx_mdct_window_lengthFB; /*Q0*/ move16(); - hTcxCfg->tcx_mdct_window_half_lengthFB = extract_l( L_shr( L_mult0( L_LOOK_12k8 - NS2SA( 12800, 5000000L ), fscaleFB ), LD_FSCALE_DENOM ) ); + hTcxCfg->tcx_mdct_window_half_lengthFB = extract_l( L_shr( L_mult0( L_LOOK_12k8 - NS2SA( 12800, 5000000L ), fscaleFB ), LD_FSCALE_DENOM ) ); /*Q0*/ move16(); - hTcxCfg->tcx_mdct_window_min_lengthFB = shr( L_frameTCX, 4 ); /* 1.25ms */ + hTcxCfg->tcx_mdct_window_min_lengthFB = shr( L_frameTCX, 4 ); /* 1.25ms Q0*/ move16(); - hTcxCfg->tcx_mdct_window_trans_lengthFB = shr( L_frameTCX, 4 ); /* 1.25ms */ + hTcxCfg->tcx_mdct_window_trans_lengthFB = shr( L_frameTCX, 4 ); /* 1.25ms Q0*/ move16(); - hTcxCfg->tcx5SizeFB = shr( L_frameTCX, 2 ); /* 5ms */ + hTcxCfg->tcx5SizeFB = shr( L_frameTCX, 2 ); /* 5ms Q0*/ move16(); mdct_window_sine( hTcxCfg->tcx_mdct_window, hTcxCfg->tcx_mdct_window_length ); mdct_window_sine( hTcxCfg->tcx_mdct_window_half, hTcxCfg->tcx_mdct_window_half_length ); diff --git a/lib_enc/core_enc_init.c b/lib_enc/core_enc_init.c index ef2e5408b18e99e06ecb4d61c33b717a457580a3..95e3f74f6b8dbde28c72f8a8c9c91a4fd4364f50 100644 --- a/lib_enc/core_enc_init.c +++ b/lib_enc/core_enc_init.c @@ -1944,26 +1944,26 @@ static void init_modes_ivas_fx( IF( LT_32( n, FRAME_SIZE_NB - 1 ) ) { test(); - IF( FrameSizeConfig[n].frame_bits <= st->bits_frame_nominal && FrameSizeConfig[n + 1].frame_bits > st->bits_frame_nominal ) + IF( LE_32( FrameSizeConfig[n].frame_bits, st->bits_frame_nominal ) && GT_32( FrameSizeConfig[n + 1].frame_bits, st->bits_frame_nominal ) ) { st->frame_size_index = n; move16(); st->bits_frame = st->bits_frame_nominal; move16(); - st->bits_frame_core = st->bits_frame_nominal - FrameSizeConfig[n].transmission_bits - FrameSizeConfig[n].bandwidth_bits - FrameSizeConfig[n].reserved_bits; + st->bits_frame_core = sub( sub( sub( st->bits_frame_nominal, FrameSizeConfig[n].transmission_bits ), FrameSizeConfig[n].bandwidth_bits ), FrameSizeConfig[n].reserved_bits ); move16(); BREAK; } } ELSE { - IF( FrameSizeConfig[n].frame_bits <= st->bits_frame_nominal ) + IF( LE_32( FrameSizeConfig[n].frame_bits, st->bits_frame_nominal ) ) { st->frame_size_index = n; move16(); st->bits_frame = st->bits_frame_nominal; move16(); - st->bits_frame_core = st->bits_frame_nominal - FrameSizeConfig[n].transmission_bits - FrameSizeConfig[n].bandwidth_bits - FrameSizeConfig[n].reserved_bits; + st->bits_frame_core = sub( sub( sub( st->bits_frame_nominal, FrameSizeConfig[n].transmission_bits ), FrameSizeConfig[n].bandwidth_bits ), FrameSizeConfig[n].reserved_bits ); move16(); BREAK; } diff --git a/lib_enc/gs_enc_fx.c b/lib_enc/gs_enc_fx.c index e1cd71e0a1a82b83a0fbf69656dd758c0bcacf9d..4e1d5ef30987a31f5b3e5271d0c57fa755ababfb 100644 --- a/lib_enc/gs_enc_fx.c +++ b/lib_enc/gs_enc_fx.c @@ -684,7 +684,7 @@ void encod_audio_ivas_fx( * Remove potential pre-echo in case an onset has been detected *--------------------------------------------------------------------------------------*/ - pre_echo_att_fx( &hGSCEnc->Last_frame_ener_fx, exc, attack_flag, Q_exc, st_fx->last_coder_type, st_fx->L_frame ); + pre_echo_att_ivas_fx( &hGSCEnc->Last_frame_ener_fx, exc, attack_flag, Q_exc, st_fx->last_coder_type, st_fx->L_frame ); /*--------------------------------------------------------------------------------------* * Update BWE excitation diff --git a/lib_enc/ivas_cpe_enc.c b/lib_enc/ivas_cpe_enc.c index 4d18891c48eeee1745739735ea06731fc570a23d..7948c6e178145145263cc7f1b4d2730ea2baeef9 100644 --- a/lib_enc/ivas_cpe_enc.c +++ b/lib_enc/ivas_cpe_enc.c @@ -382,15 +382,6 @@ ivas_error ivas_cpe_enc_fx( stereo_switching_enc_fx( hCPE, sts[0]->old_input_signal_fx, input_frame, q_inp ); #ifdef IVAS_FLOAT_FIXED_CONVERSIONS - - if ( hCPE->element_mode > IVAS_CPE_DFT && hCPE->input_mem[0] != NULL && hCPE->element_mode != IVAS_CPE_MDCT ) - { - for ( n = 0; n < CPE_CHANNELS; n++ ) - { - fixedToFloat_arr( hCPE->input_mem_fx[n], hCPE->input_mem[n], q_inp, STEREO_DFT_OVL_MAX * input_frame / L_FRAME48k ); - } - } - if ( hCPE->element_mode == IVAS_CPE_DFT ) { for ( n = 0; n < CPE_CHANNELS; n++ ) @@ -467,7 +458,7 @@ ivas_error ivas_cpe_enc_fx( #ifdef IVAS_FLOAT_FIXED_CONVERSIONS floatToFixed_arr16( sts[n]->input, sts[n]->input_fx, -1, input_frame ); #endif - RunTransientDetection_ivas_fx( sts[n]->input_fx, input_frame, sts[n]->hTranDet ); + RunTransientDetection_ivas_fx( sts[n]->input_fx, input_frame, sts[n]->hTranDet, -1 ); sts[n]->hTranDet->subblockEnergies.subblockNrg_e = 31 - Q7; sts[n]->hTranDet->subblockEnergies.accSubblockNrg_e = 31 - Q7; move16(); @@ -616,9 +607,7 @@ ivas_error ivas_cpe_enc_fx( #ifndef MSAN_FIX hCPE->hStereoDft->q_input_mem_itd[i] = Q_factor_arr( &hCPE->hStereoDft->input_mem_itd[i][0], STEREO_DFT_OVL_MAX ); #endif // MSAN_FIX - hCPE->q_input_mem[i] = Q_factor_arr( &hCPE->input_mem[i][0], NS2SA( input_Fs, STEREO_DFT_OVL_NS ) ); floatToFixed_arr( sts[i]->old_input_signal, sts[i]->old_input_signal_fx, sts[i]->q_inp, 1965 ); - floatToFixed_arr( &hCPE->input_mem[i][0], &hCPE->input_mem_fx[i][0], hCPE->q_input_mem[i], NS2SA( input_Fs, STEREO_DFT_OVL_NS ) ); #ifndef MSAN_FIX floatToFixed_arr( &hCPE->hStereoDft->input_mem_itd[i][0], &hCPE->hStereoDft->input_mem_itd_fx[i][0], hCPE->hStereoDft->q_input_mem_itd[i], STEREO_DFT_OVL_MAX ); #endif // MSAN_FIX @@ -758,9 +747,7 @@ ivas_error ivas_cpe_enc_fx( FOR( int16_t i = 0; i < CPE_CHANNELS; i++ ) { sts[i]->q_inp = Q_factor_arr( sts[i]->old_input_signal, 1965 ); // check length - hCPE->q_input_mem[i] = Q_factor_arr( &hCPE->input_mem[i][0], NS2SA( input_Fs, STEREO_DFT_OVL_NS ) ); floatToFixed_arr( sts[i]->old_input_signal, sts[i]->old_input_signal_fx, sts[i]->q_inp, 1965 ); - floatToFixed_arr( &hCPE->input_mem[i][0], &hCPE->input_mem_fx[i][0], hCPE->q_input_mem[i], NS2SA( input_Fs, STEREO_DFT_OVL_NS ) ); } floatToFixed_arr( hCPE->hCoreCoder[0]->voicing, hCPE->hCoreCoder[0]->voicing_fx, 15, 3 ); if ( hCPE->element_mode == IVAS_CPE_DFT && hCPE->hStereoDft->res_cod_mode[STEREO_DFT_OFFSET] ) @@ -775,7 +762,6 @@ ivas_error ivas_cpe_enc_fx( { FOR( int16_t i = 0; i < CPE_CHANNELS; i++ ) { - fixedToFloat_arr( &hCPE->input_mem_fx[i][0], &hCPE->input_mem[i][0], hCPE->q_input_mem[i], NS2SA( input_Fs, STEREO_DFT_OVL_NS ) ); fixedToFloat_arr( sts[i]->old_input_signal_fx, sts[i]->old_input_signal, sts[i]->q_inp, 1965 ); } } @@ -835,7 +821,6 @@ ivas_error ivas_cpe_enc_fx( FOR( i = 0; i < CPE_CHANNELS; i++ ) { - fixedToFloat_arr( &hCPE->input_mem_fx[i][0], &hCPE->input_mem[i][0], hCPE->q_input_mem[i], NS2SA( input_Fs, STEREO_DFT_OVL_NS ) ); me2f_buf( hCPE->hStereoDft->DFT_fx[i], hCPE->hStereoDft->DFT_fx_e[i], hCPE->hStereoDft->DFT[i], STEREO_DFT_N_MAX_ENC ); } /*local fix2flt*/ @@ -2188,23 +2173,6 @@ ivas_error create_cpe_enc( * Input memory buffer: allocate and initialize *-----------------------------------------------------------------*/ - for ( n = 0; n < CPE_CHANNELS; n++ ) - { - if ( ivas_format == STEREO_FORMAT || ivas_format == MASA_FORMAT || ( ivas_format == MC_FORMAT && st_ivas->mc_mode == MC_MODE_MCMASA ) || ivas_format == MASA_ISM_FORMAT ) - { - if ( ( hCPE->input_mem[n] = (float *) malloc( sizeof( float ) * NS2SA( input_Fs, STEREO_DFT_OVL_NS ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DFT stereo memory\n" ) ); - } - - set_zero( hCPE->input_mem[n], NS2SA( input_Fs, STEREO_DFT_OVL_NS ) ); - } - else - { - hCPE->input_mem[n] = NULL; - } - } - // This should be removed when actual create_cpe_enc_fx #ifdef IVAS_FLOAT_FIXED FOR( n = 0; n < CPE_CHANNELS; n++ ) @@ -2506,31 +2474,10 @@ ivas_error create_cpe_enc_fx( } ELSE { - hCPE->input_mem[n] = NULL; hCPE->input_mem_fx[n] = NULL; } } - -#ifdef IVAS_FLOAT_FIXED_CONVERSIONS // TODO: To be removed later - for ( n = 0; n < CPE_CHANNELS; n++ ) - { - if ( ivas_format == STEREO_FORMAT || ivas_format == MASA_FORMAT || ( ivas_format == MC_FORMAT && st_ivas->mc_mode == MC_MODE_MCMASA ) || ivas_format == MASA_ISM_FORMAT ) - { - if ( ( hCPE->input_mem[n] = (float *) malloc( sizeof( float ) * NS2SA( input_Fs, STEREO_DFT_OVL_NS ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DFT stereo memory\n" ) ); - } - - set_zero( hCPE->input_mem[n], NS2SA( input_Fs, STEREO_DFT_OVL_NS ) ); - } - else - { - hCPE->input_mem[n] = NULL; - } - } -#endif - /*-----------------------------------------------------------------* * stereo classifier: allocate and initialize *-----------------------------------------------------------------*/ @@ -2548,7 +2495,7 @@ ivas_error create_cpe_enc_fx( IF( EQ_16( cpe_id, sub( st_ivas->nCPE, 1 ) ) ) { - IF( ( error = ivas_initialize_MD_bstr_enc( &( hCPE->hMetaData ), st_ivas ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_initialize_MD_bstr_enc( &( hCPE->hMetaData ), st_ivas ) ), IVAS_ERR_OK ) ) { return error; } @@ -2570,16 +2517,17 @@ ivas_error create_cpe_enc_fx( IF( GT_16( st_ivas->nCPE, 1 ) ) { st->total_brate = hCPE->element_brate; /* dummy initialization for getting right pointers initialization of input buffers in init_coder_ace_plus() */ + move32(); } ELSE { st->total_brate = L_shr( hCPE->element_brate, CPE_CHANNELS ); /* dummy initialization for getting right pointers initialization of input buffers in init_coder_ace_plus() */ + move32(); } - move32(); st->mct_chan_mode = MCT_CHAN_MODE_REGULAR; move32(); - IF( ( error = init_encoder_ivas_fx( st, st_ivas, n, hEncoderConfig->var_SID_rate_flag, hEncoderConfig->interval_SID, 0, ISM_MODE_NONE, hCPE->element_brate ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = init_encoder_ivas_fx( st, st_ivas, n, hEncoderConfig->var_SID_rate_flag, hEncoderConfig->interval_SID, 0, ISM_MODE_NONE, hCPE->element_brate ) ), IVAS_ERR_OK ) ) { return error; } @@ -2620,7 +2568,7 @@ ivas_error create_cpe_enc_fx( { FOR( n = 0; n < CPE_CHANNELS; n++ ) { - IF( ( error = front_vad_create_fx( &( hCPE->hFrontVad[n] ), hEncoderConfig ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = front_vad_create_fx( &( hCPE->hFrontVad[n] ), hEncoderConfig ) ), IVAS_ERR_OK ) ) { return error; } @@ -2640,7 +2588,7 @@ ivas_error create_cpe_enc_fx( IF( EQ_16( hCPE->element_mode, IVAS_CPE_DFT ) ) { - IF( ( error = stereo_dft_enc_create_fx( &( hCPE->hStereoDft ), input_Fs, max_bwidth ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = stereo_dft_enc_create_fx( &( hCPE->hStereoDft ), input_Fs, max_bwidth ) ), IVAS_ERR_OK ) ) { return error; } @@ -2709,7 +2657,7 @@ ivas_error create_cpe_enc_fx( test(); IF( EQ_16( hCPE->element_mode, IVAS_CPE_MDCT ) && LE_32( element_brate, MAX_MDCT_ITD_BRATE ) && EQ_16( ivas_format, STEREO_FORMAT ) ) { - IF( ( error = initMdctItdHandling( hCPE->hStereoMdct, input_Fs ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = initMdctItdHandling( hCPE->hStereoMdct, input_Fs ) ), IVAS_ERR_OK ) ) { return error; } @@ -2741,14 +2689,9 @@ void destroy_cpe_enc( } FOR( n = 0; n < CPE_CHANNELS; n++ ){ - IF( hCPE->input_mem[n] != NULL ){ - free( hCPE->input_mem[n] ); - hCPE->input_mem[n] = NULL; -} #ifdef IVAS_FLOAT_FIXED -IF( hCPE->input_mem_fx[n] != NULL ) -{ - free( hCPE->input_mem_fx[n] ); + IF( hCPE->input_mem_fx[n] != NULL ){ + free( hCPE->input_mem_fx[n] ); hCPE->input_mem_fx[n] = NULL; } #endif diff --git a/lib_enc/ivas_ism_enc.c b/lib_enc/ivas_ism_enc.c index e81b89e136450e3c5669fae6827ae71a7e0c5622..335b524a363e674bdfbbab61de23fe23f0fb0673 100644 --- a/lib_enc/ivas_ism_enc.c +++ b/lib_enc/ivas_ism_enc.c @@ -558,7 +558,7 @@ ivas_error ivas_ism_enc_fx( #ifdef IVAS_FLOAT_FIXED_CONVERSIONS fixedToFloat_arrL( st->input32_fx, st->input, q_data, input_frame ); #endif - RunTransientDetection_ivas_fx( st->input_fx, input_frame, st->hTranDet ); + RunTransientDetection_ivas_fx( st->input_fx, input_frame, st->hTranDet, -1 ); st->hTranDet->subblockEnergies.subblockNrg_e = 31 - Q7; st->hTranDet->subblockEnergies.accSubblockNrg_e = 31 - Q7; move16(); diff --git a/lib_enc/ivas_mc_param_enc.c b/lib_enc/ivas_mc_param_enc.c index 4c5c7905eff34e4eb24a90852641cebcdd81f359..22de8cfe65f7d0b4748cf3ce74adea784220624f 100644 --- a/lib_enc/ivas_mc_param_enc.c +++ b/lib_enc/ivas_mc_param_enc.c @@ -892,7 +892,7 @@ void ivas_param_mc_enc_fx( #else Copy_Scale_sig_32_16( data_dmx_fx[ch], data_dmx_fx16[ch], input_frame, -Q1 - Q11 ); // Q11 -> Q(-1) #endif - RunTransientDetection_ivas_fx( data_dmx_fx16[ch], input_frame, st_ivas->hCPE[cpe_idx]->hCoreCoder[ch - cpe_idx * CPE_CHANNELS]->hTranDet ); + RunTransientDetection_ivas_fx( data_dmx_fx16[ch], input_frame, st_ivas->hCPE[cpe_idx]->hCoreCoder[ch - cpe_idx * CPE_CHANNELS]->hTranDet, -1 ); ivas_param_mc_transient_detection_fx( hParamMC, st_ivas->hCPE[cpe_idx]->hCoreCoder[ch - cpe_idx * CPE_CHANNELS]->hTranDet, &bAttackPresent[ch], &attackIdx[ch] ); } @@ -984,7 +984,7 @@ void ivas_param_mc_enc_fx( set32_fx( data_f_fx[ch], 0, input_frame ); set16_fx( data_f_fx16, 0, input_frame ); - RunTransientDetection_ivas_fx( data_f_fx16, input_frame, st_ivas->hCPE[cpe_idx]->hCoreCoder[ch - cpe_idx * CPE_CHANNELS]->hTranDet ); + RunTransientDetection_ivas_fx( data_f_fx16, input_frame, st_ivas->hCPE[cpe_idx]->hCoreCoder[ch - cpe_idx * CPE_CHANNELS]->hTranDet, -1 ); } } diff --git a/lib_enc/ivas_osba_enc.c b/lib_enc/ivas_osba_enc.c index f9fcd6ca90106990f209827e3a7992bf91045ca6..7c5a22c8e420e03606d7fdf3934d3989780a035e 100644 --- a/lib_enc/ivas_osba_enc.c +++ b/lib_enc/ivas_osba_enc.c @@ -434,14 +434,14 @@ ivas_error ivas_osba_enc_reconfig( move16(); ivas_spar_enc_close_fx( &( st_ivas->hSpar ), hEncoderConfig->input_Fs, hEncoderConfig->nchan_inp, spar_reconfig_flag ); - IF( ( error = ivas_spar_enc_open( st_ivas, spar_reconfig_flag ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_spar_enc_open( st_ivas, spar_reconfig_flag ) ), IVAS_ERR_OK ) ) { return error; } } st_ivas->hSpar->spar_reconfig_flag = spar_reconfig_flag; move16(); - IF( ( error = ivas_dirac_enc_reconfigure( st_ivas ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_dirac_enc_reconfigure( st_ivas ) ), IVAS_ERR_OK ) ) { return error; } @@ -457,12 +457,15 @@ ivas_error ivas_osba_enc_reconfig( FOR( i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++ ) { q_direction[dir].band_data[j].energy_ratio_index[i] = 0; + move32(); q_direction[dir].band_data[j].energy_ratio_index_mod[i] = 0; + move32(); } } } } hSpar->enc_param_start_band = hDirAC->hConfig->enc_param_start_band; + move16(); /*-----------------------------------------------------------------* * Allocate, initialize, and configure SCE/CPE/MCT handles @@ -472,6 +475,7 @@ ivas_error ivas_osba_enc_reconfig( IF( old_ism_mode == ISM_MODE_NONE && EQ_32( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) ) { st_ivas->nCPE = add( st_ivas->nCPE, shr( add( st_ivas->hEncoderConfig->nchan_ism, 1 ), 1 ) ); + move16(); } ELSE IF( EQ_32( old_ism_mode, ISM_SBA_MODE_DISC ) && st_ivas->ism_mode == ISM_MODE_NONE ) { @@ -480,6 +484,7 @@ ivas_error ivas_osba_enc_reconfig( ELSE IF( EQ_32( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) ) { st_ivas->nCPE = add( st_ivas->nCPE, shr( add( st_ivas->hEncoderConfig->nchan_ism, 1 ), 1 ) ); + move16(); nCPE_old = st_ivas->nCPE; move16(); nchan_transport_old = st_ivas->nchan_transport; @@ -489,7 +494,7 @@ ivas_error ivas_osba_enc_reconfig( Word16 tmp_e; Word32 bitrate_per_chan = L_deposit_h( BASOP_Util_Divide3216_Scale( ivas_total_brate, st_ivas->nchan_transport, &tmp_e ) ); bitrate_per_chan = L_shr( bitrate_per_chan, sub( 15, tmp_e ) ); - IF( ( error = ivas_corecoder_enc_reconfig_fx( st_ivas, nSCE_old, nCPE_old, nchan_transport_old, bitrate_per_chan, imult3216( bitrate_per_chan, CPE_CHANNELS ), MC_MODE_NONE ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_corecoder_enc_reconfig_fx( st_ivas, nSCE_old, nCPE_old, nchan_transport_old, bitrate_per_chan, imult3216( bitrate_per_chan, CPE_CHANNELS ), MC_MODE_NONE ) ), IVAS_ERR_OK ) ) { return error; } diff --git a/lib_enc/ivas_sce_enc.c b/lib_enc/ivas_sce_enc.c index 43f9a93227c5a975a6e428380b25ebeab1b32feb..a6d14e7231c647c0e787ae38206a81b297d00754 100644 --- a/lib_enc/ivas_sce_enc.c +++ b/lib_enc/ivas_sce_enc.c @@ -103,6 +103,7 @@ ivas_error ivas_sce_enc_fx( IVAS_FORMAT ivas_format; ivas_error error; Word16 flag_16k_smc; + Word16 q_input; /*stores q for input_fx*/ push_wmops( "ivas_sce_enc" ); @@ -117,8 +118,14 @@ ivas_error ivas_sce_enc_fx( /*------------------------------------------------------------------* * Initialization - general *-----------------------------------------------------------------*/ - Copy32( data_fx, st->input32_fx, input_frame ); // Q(q_data_fx) - Copy_Scale_sig32_16( st->input32_fx, st->input_fx, input_frame, sub( Q16 - 1, q_data_fx ) ); // Q(q_data_fx) -> Q(-1) + Copy32( data_fx, st->input32_fx, input_frame ); // Q(q_data_fx) + q_input = sub( add( L_norm_arr( st->input32_fx, input_frame ), q_data_fx ), 16 ); + if ( GE_16( q_input, -1 ) ) + { + q_input = -1; + move16(); + } + Copy_Scale_sig32_16( st->input32_fx, st->input_fx, input_frame, sub( add( Q16, q_input ), q_data_fx ) ); // Q(q_data_fx) -> Q(q_input) #ifdef IVAS_FLOAT_FIXED_CONVERSIONS fixedToFloat_arrL( st->input32_fx, st->input, q_data_fx, input_frame ); @@ -152,7 +159,7 @@ ivas_error ivas_sce_enc_fx( test(); IF( NE_32( ivas_format, MC_FORMAT ) || NE_32( st_ivas->mc_mode, MC_MODE_PARAMMC ) ) { - RunTransientDetection_ivas_fx( st->input_fx, input_frame, st->hTranDet ); + RunTransientDetection_ivas_fx( st->input_fx, input_frame, st->hTranDet, q_input ); st->hTranDet->subblockEnergies.subblockNrg_e = 31 - Q7; st->hTranDet->subblockEnergies.accSubblockNrg_e = 31 - Q7; move16(); diff --git a/lib_enc/ivas_stat_enc.h b/lib_enc/ivas_stat_enc.h index ce900485d464a456d0bd9f7b388e88ba54cfa126..515008c0f40f5a3c9627f8214c3d75e8ade4d94c 100644 --- a/lib_enc/ivas_stat_enc.h +++ b/lib_enc/ivas_stat_enc.h @@ -1561,7 +1561,7 @@ typedef struct cpe_enc_data_structure STEREO_CNG_ENC_HANDLE hStereoCng; /* Stereo CNG data structure */ FRONT_VAD_ENC_HANDLE hFrontVad[CPE_CHANNELS]; - float *input_mem[CPE_CHANNELS]; /* input channels buffers memory; needed to be up-to-date for TD->DFT stereo switching */ + // float *input_mem[CPE_CHANNELS]; /* input channels buffers memory; needed to be up-to-date for TD->DFT stereo switching */ Word32 brate_surplus; /* bitrate surplus for bitrate adaptation in combined format coding */ Word16 *input_mem_fx[CPE_CHANNELS]; /* input channels buffers memory; needed to be up-to-date for TD->DFT stereo switching */ diff --git a/lib_enc/ivas_stereo_dft_enc.c b/lib_enc/ivas_stereo_dft_enc.c index 52c669b13cde15a844b9becc27e63104ad3756bf..24d57bb0e781231dc5b0c0a6230a797697898b18 100644 --- a/lib_enc/ivas_stereo_dft_enc.c +++ b/lib_enc/ivas_stereo_dft_enc.c @@ -1344,6 +1344,7 @@ void stereo_enc_itd_init_fx( ) { hItd->prev_itd = 0; + move16(); set32_fx( hItd->itd_fx, 0, STEREO_DFT_ENC_DFT_NB ); set32_fx( hItd->deltaItd_fx, 0, STEREO_DFT_ENC_DFT_NB ); set16_fx( hItd->td_itd, 0, STEREO_DFT_ENC_DFT_NB ); @@ -1351,40 +1352,64 @@ void stereo_enc_itd_init_fx( set16_fx( hItd->itd_index, 0, STEREO_DFT_ENC_DFT_NB ); set32_fx( hItd->xcorr_smooth_fx, 0, STEREO_DFT_N_32k_ENC ); hItd->xcorr_smooth_fx_e = 0; + move16(); hItd->lp_phat_peak_fx = 0; + move32(); hItd->itd_hangover = 0; + move16(); hItd->itd_cnt = 0; + move16(); hItd->prev_sum_nrg_L_lb_fx = 0; + move32(); hItd->prev_sum_nrg_L_lb_fx_e = 0; + move16(); set32_fx( hItd->prev_xcorr_lb_fx, 0, STEREO_DFT_XCORR_LB_MAX ); hItd->prev_xcorr_lb_fx_e = 0; + move16(); set32_fx( hItd->E_band_n_fx, ITD_VAD_E_BAND_N_INIT, STEREO_DFT_ITD_VAD_BAND_NUM ); hItd->vad_frm_cnt = 0; + move16(); hItd->pre_vad = 0; + move16(); hItd->itd_nonzero_cnt = 0; + move16(); set32_fx( hItd->acorr_L_fx, 0, STEREO_DFT_BAND_MAX ); hItd->acorr_L_fx_e = 0; + move16(); set32_fx( hItd->acorr_R_fx, 0, STEREO_DFT_BAND_MAX ); hItd->acorr_R_fx_e = 0; + move16(); hItd->cohSNR_fx = 983040; /*Q16*/ + move32(); hItd->itd_thres_fx = 0; + move32(); hItd->valid_itd_cnt = 0; - + move16(); hItd->detected_itd_flag = 0; + move16(); hItd->itd_tracking = 0; + move16(); hItd->prev_max_fx = 0; + move32(); hItd->prev_index = 0; + move16(); hItd->prev_avg_max_fx = 0; + move32(); hItd->prev_avg_max_fx_e = 0; + move16(); hItd->currFlatness_fx = 0; - + move16(); /* Xtalk classifier */ hItd->prev_m1_fx = 0; + move32(); hItd->prev_m2_fx = 0; + move32(); hItd->prev_itd1 = 0; + move16(); hItd->prev_itd2 = 0; - + move16(); hItd->hybrid_itd_max = 0; + move16(); return; } diff --git a/lib_enc/ivas_stereo_dmx_evs.c b/lib_enc/ivas_stereo_dmx_evs.c index d3be66ae9380a39e63900cd17d841475cec965f3..c4f14de998568c237465deea970b0c2f35f10ab6 100644 --- a/lib_enc/ivas_stereo_dmx_evs.c +++ b/lib_enc/ivas_stereo_dmx_evs.c @@ -208,17 +208,17 @@ static void calc_energy_fx( const Word32 ratio_float_fx ); static void create_M_signal_fx( - const Word32 srcL_fx[], /* i : Lch input signal Q16 */ - const Word32 srcR_fx[], /* i : Rch input signal Q16 */ - Word32 dmx_fx[], /* o : output signal Q31 */ - const Word32 w_curr_fx, /* i : adapting weight Q31 */ - const int16_t input_frame, /* i : input frame length per channel */ - const Word32 wnd_fx[], /* i : window coef Q31 */ - Word32 *w_prev_fx, /* i/o: adapting prev weight Q31*/ - Word32 *dmx_energy_fx, /* i/o: downmix signal energy dmx_energy_fx_e */ - Word16 *dmx_energy_fx_e, /* i/o: downmix signal energy */ - Word32 *src_energy_fx, /* i/o: input signal energy src_energy_fx_e */ - Word16 *src_energy_fx_e /* i/o: input signal energy */ + const Word32 srcL_fx[], /* i : Lch input signal Q16 */ + const Word32 srcR_fx[], /* i : Rch input signal Q16 */ + Word32 dmx_fx[], /* o : output signal Q31 */ + const Word32 w_curr_fx, /* i : adapting weight Q31 */ + const Word16 input_frame, /* i : input frame length per channel */ + const Word32 wnd_fx[], /* i : window coef Q31 */ + Word32 *w_prev_fx, /* i/o: adapting prev weight Q31*/ + Word32 *dmx_energy_fx, /* i/o: downmix signal energy dmx_energy_fx_e */ + Word16 *dmx_energy_fx_e, /* i/o: downmix signal energy */ + Word32 *src_energy_fx, /* i/o: input signal energy src_energy_fx_e */ + Word16 *src_energy_fx_e /* i/o: input signal energy */ ); static Word32 find_poc_peak_fx( STEREO_DMX_EVS_POC_HANDLE hPOC, /* i/o: phase only correlation structure */ @@ -2571,17 +2571,17 @@ static void adapt_gain( *-------------------------------------------------------------------*/ #ifdef IVAS_FLOAT_FIXED static void create_M_signal_fx( - const Word32 srcL_fx[], /* i : Lch input signal Q16 */ - const Word32 srcR_fx[], /* i : Rch input signal Q16 */ - Word32 dmx_fx[], /* o : output signal Q31 */ - const Word32 w_curr_fx, /* i : adapting weight Q31 */ - const int16_t input_frame, /* i : input frame length per channel */ - const Word32 wnd_fx[], /* i : window coef Q31 */ - Word32 *w_prev_fx, /* i/o: adapting prev weight Q31*/ - Word32 *dmx_energy_fx, /* i/o: downmix signal energy dmx_energy_fx_e */ - Word16 *dmx_energy_fx_e, /* i/o: downmix signal energy */ - Word32 *src_energy_fx, /* i/o: input signal energy src_energy_fx_e */ - Word16 *src_energy_fx_e /* i/o: input signal energy */ + const Word32 srcL_fx[], /* i : Lch input signal Q16 */ + const Word32 srcR_fx[], /* i : Rch input signal Q16 */ + Word32 dmx_fx[], /* o : output signal Q31 */ + const Word32 w_curr_fx, /* i : adapting weight Q31 */ + const Word16 input_frame, /* i : input frame length per channel */ + const Word32 wnd_fx[], /* i : window coef Q31 */ + Word32 *w_prev_fx, /* i/o: adapting prev weight Q31*/ + Word32 *dmx_energy_fx, /* i/o: downmix signal energy dmx_energy_fx_e */ + Word16 *dmx_energy_fx_e, /* i/o: downmix signal energy */ + Word32 *src_energy_fx, /* i/o: input signal energy src_energy_fx_e */ + Word16 *src_energy_fx_e /* i/o: input signal energy */ ) { Word32 amp_mod_fx[CPE_CHANNELS]; @@ -2593,8 +2593,16 @@ static void create_M_signal_fx( /* Initialization */ eps_fx = 1024; // 1024.0f in Q0 move32(); - Lbias_fx = ( w_prev_fx[2] == 0 ) ? 1073741824 : 67108864; // 4.0f in Q28 : 0.25f in Q28 - move32(); + IF( w_prev_fx[2] == 0 ) + { + Lbias_fx = 1073741824; // 4.0f in Q28 + move32(); + } + ELSE + { + Lbias_fx = 67108864; // 0.25f in Q28 + move32(); + } weighted_ave_fx( srcL_fx, srcR_fx, dmx_fx, w_curr_fx, w_prev_fx[0], input_frame, wnd_fx ); calc_energy_fx( srcL_fx, srcL_fx, src_energy_fx, src_energy_fx_e, input_frame, STEREO_DMX_EVS_DMX_EGY_FORGETTING_FX ); calc_energy_fx( srcR_fx, srcR_fx, src_energy_fx + 1, src_energy_fx_e + 1, input_frame, STEREO_DMX_EVS_DMX_EGY_FORGETTING_FX ); diff --git a/lib_enc/ivas_stereo_mdct_stereo_enc.c b/lib_enc/ivas_stereo_mdct_stereo_enc.c index da0cff0fe2b2f1dbe9906acc275bf3c41e8c485d..40adc73a1b6b2dd0ef70b03107a2c59b8f24bb18 100644 --- a/lib_enc/ivas_stereo_mdct_stereo_enc.c +++ b/lib_enc/ivas_stereo_mdct_stereo_enc.c @@ -133,9 +133,13 @@ static void dft_ana_init( ) { hDft_ana->N = extract_l( Mpy_32_16_1( input_Fs, 656 ) ); + move16(); hDft_ana->NFFT = extract_l( Mpy_32_16_1( input_Fs, 1311 ) ); + move16(); hDft_ana->dft_ovl = extract_l( Mpy_32_16_1( input_Fs, 287 ) ); + move16(); hDft_ana->dft_zp = extract_l( Mpy_32_16_1( input_Fs, 185 ) ); + move16(); hDft_ana->dft_trigo_32k_fx = dft_trigo_32k_fx; @@ -143,12 +147,14 @@ static void dft_ana_init( { hDft_ana->dft_trigo_fx = dft_trigo_32k_fx; hDft_ana->dft_trigo_step = STEREO_DFT_TRIGO_SRATE_16k_STEP; + move16(); hDft_ana->win_ana_fx = win_ana_16k_fx; } ELSE IF( EQ_32( input_Fs, 32000 ) ) { hDft_ana->dft_trigo_fx = dft_trigo_32k_fx; hDft_ana->dft_trigo_step = STEREO_DFT_TRIGO_SRATE_32k_STEP; + move16(); hDft_ana->win_ana_fx = win_ana_32k_fx; } ELSE @@ -156,6 +162,7 @@ static void dft_ana_init( assert( input_Fs == 48000 ); hDft_ana->dft_trigo_fx = dft_trigo_48k_fx; hDft_ana->dft_trigo_step = STEREO_DFT_TRIGO_SRATE_48k_STEP; + move16(); hDft_ana->win_ana_fx = win_ana_48k_fx; } diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index a48d3bbd0d6927a286f82821e811e2f736aa89f8..cfb2ba9d262cb2c401c26a06c188f1c4e94cd08f 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -1096,9 +1096,10 @@ void RunTransientDetection_fx( Word16 const *i, Word16 nSamplesAvailable, struct void RunTransientDetection_ivas_fx( - const Word16 *input_fx, /* i : input signal Q: -1 */ - const int16_t length, /* i : frame length */ - TRAN_DET_HANDLE hTranDet /* i/o: transient detection handle */ + const Word16 *input_fx, /* i : input signal Q: q_input */ + const Word16 length, /* i : frame length */ + TRAN_DET_HANDLE hTranDet, /* i/o: transient detection handle */ + Word16 q_input /*i: stores q for input_fx*/ ); /** Get the average temporal flatness measure using subblock energies aligned with the TCX. diff --git a/lib_enc/transient_detection_fx.c b/lib_enc/transient_detection_fx.c index 4c9907b2846451300ecbbacbc882f6df07d5edec..f15a3862e0127c82a0067d795c1b86dc338713c8 100644 --- a/lib_enc/transient_detection_fx.c +++ b/lib_enc/transient_detection_fx.c @@ -540,9 +540,10 @@ void RunTransientDetection_fx( Word16 const *input, Word16 nSamplesAvailable, Tr #ifdef IVAS_FLOAT_FIXED void RunTransientDetection_ivas_fx( - const Word16 *input_fx, /* i : input signal Q: -1 */ - const Word16 length, /* i : frame length */ - TRAN_DET_HANDLE hTranDet /* i/o: transient detection handle */ + const Word16 *input_fx, /* i : input signal Q: q_input */ + const Word16 length, /* i : frame length */ + TRAN_DET_HANDLE hTranDet, /* i/o: transient detection handle */ + Word16 q_input /*i: stores q for input_fx*/ ) { @@ -560,7 +561,7 @@ void RunTransientDetection_ivas_fx( /* Update subblock energies. */ #ifdef MSAN_FIX - Scale_sig( filteredInput_fx, length, 8 ); + Scale_sig( filteredInput_fx, length, sub( 7, q_input ) ); // q7 #else Scale_sig( filteredInput_fx, L_FRAME_MAX, 8 ); #endif diff --git a/lib_enc/vad_fx.c b/lib_enc/vad_fx.c index 18a71e2942870b6b33a0faffd5a4422a74dc63af..1326cc457f72ad5f38502d5872447453cd741867 100644 --- a/lib_enc/vad_fx.c +++ b/lib_enc/vad_fx.c @@ -146,8 +146,11 @@ void wb_vad_init_ivas_fx( /* is set to max (-> start with hangover) */ hVAD->vad_flag_reg_H = L_deposit_l( 0 ); + move32(); hVAD->vad_flag_reg_L = L_deposit_l( 0 ); + move32(); hVAD->vad_prim_reg = L_deposit_l( 0 ); + move32(); hVAD->vad_flag_cnt_50 = 0; move16(); hVAD->vad_prim_cnt_16 = 0; @@ -1985,12 +1988,10 @@ Word16 wb_vad_ivas_fx( if ( hNoiseEst == NULL ) { hNoiseEst = st_fx->hNoiseEst; - move16(); } if ( hVAD == NULL ) { - move16(); hVAD = st_fx->hVAD; } if ( LT_16( lp_speech_fx, -100 * 256 ) ) @@ -2079,10 +2080,8 @@ Word16 wb_vad_ivas_fx( sign_thr_HE_SAD = 40; move16(); /* 2.5f Q4 */ - ; min_snr_HE_SAD = 3; move16(); /* 0.2f Q4 */ - ; } ELSE /* NB input */ { @@ -2103,10 +2102,8 @@ Word16 wb_vad_ivas_fx( move16(); /* .25 *Q4 MIN_SNR */ sign_thr_HE_SAD = 42; move16(); /* 2.65f Q4 */ - ; min_snr_HE_SAD = 1; move16(); /* 0.05f Q4 */ - ; } hangover_short = 0; @@ -2313,7 +2310,7 @@ Word16 wb_vad_ivas_fx( } } - if ( LT_32( L_snr, 2 * ( 1 << 4 ) ) ) + IF( LT_32( L_snr, 2 * ( 1 << 4 ) ) ) { nb_sig_snr = sub( nb_sig_snr, 1 ); /* nb_sig_snr--; */ } @@ -2368,7 +2365,7 @@ Word16 wb_vad_ivas_fx( tmp1 = tmp; move16(); /* ftmp1 = ftmp; */ sub( 0, 0 ); - if ( i < 7 ) + IF( i < 7 ) { #ifdef BASOP_NOGLOB tmp1 = add_o( tmp, 3277, &Overflow ); /*.4 in Q13 ftmp1 = ftmp + 0.4f; */ @@ -2410,6 +2407,7 @@ Word16 wb_vad_ivas_fx( norm_tmp = norm_l( tmp1 ); scaled_tmp = L_shl( tmp1, norm_tmp ); /*13+norm_tmp*/ L_msnr = scaled_tmp; + move32(); L_msnr_e = sub( 18, norm_tmp ); FOR( j = 1; j < stmp; j++ ) { @@ -2462,11 +2460,11 @@ Word16 wb_vad_ivas_fx( /* float saves all snrs in an snr[] vector , in fix we only save two bands */ - if ( EQ_16( i, 18 ) ) + IF( EQ_16( i, 18 ) ) { L_snr18 = L_add( L_snr, 0 ); /*Q4 */ } - if ( EQ_16( i, 19 ) ) + IF( EQ_16( i, 19 ) ) { L_snr19 = L_add( L_snr, 0 ); /* Q4 */ } @@ -2531,6 +2529,7 @@ Word16 wb_vad_ivas_fx( /* Separated SNR_SUM outlier modification */ L_snr_sum_ol = L_snr_sum; /* snr_sum_ol = snr_sum; */ + move32(); test(); test(); @@ -2590,7 +2589,6 @@ Word16 wb_vad_ivas_fx( *---------------------------------------------------------------------*/ lp_snr = sub( lp_speech_fx, lp_noise_fx ); /*Q8*/ - sub( 0, 0 ); IF( LT_16( lp_snr, hNoiseEst->sign_dyn_lp_fx ) ) { lp_snr = add( lp_snr, 1 << 8 ); /* lp_snr += 1; */ @@ -2608,16 +2606,19 @@ Word16 wb_vad_ivas_fx( L_tmp = L_mac( L_tmp, nc, (Word16) 32767 ); /* Q8+Q15+1 = Q24 */ thr1 = mac_r( L_tmp, lp_snr, nk ); /* Q8+Q15+1 - 16 --> Q8 */ + test(); IF( st_fx->element_mode > EVS_MONO && hNoiseEst->first_noise_updt_cnt < 100 ) { /* lower threshold during warmup time */ thr1 = sub( thr1, 2560 ); L_vad_thr = 0; + move32(); } IF( GT_16( lp_snr, (Word16) 20 * ( 1 << 8 ) ) ) /* if (lp_snr > 20.0f )*/ { - IF( st_fx->element_mode == EVS_MONO || hNoiseEst->first_noise_updt_cnt >= 100 ) + test(); + IF( st_fx->element_mode == EVS_MONO || GE_16( hNoiseEst->first_noise_updt_cnt, 100 ) ) { /* thr1 = thr1 + 0.3f * (lp_snr - 20.0f); */ thr1 = add( thr1, mult( 9830, sub( lp_snr, (Word16) 20 * ( 1 << 8 ) ) ) ); /* Q15*Q8+1 -16 --> Q8 */ @@ -2628,6 +2629,7 @@ Word16 wb_vad_ivas_fx( if ( EQ_16( st_fx->max_band, 16 ) && GT_16( lp_snr, 40 * 256 ) && GT_16( thr1, 6600 ) && LT_16( lp_speech_fx, 11520 ) ) { thr1 = 6600; + move16(); } } } @@ -2667,8 +2669,8 @@ Word16 wb_vad_ivas_fx( test(); /*_DIFF_FLOAT_FIX_ -> the conditions around Opt_SC_VBR_fx are invertered compared to float ### st_fx->Opt_SC_VBR!=0 vs !st_fx->Opt_SC_VBR #####*/ test(); - IF( ( snr_outlier_index <= 4 && ( st_fx->last_coder_type > UNVOICED ) && !st_fx->Opt_SC_VBR ) || - ( snr_outlier_index <= 4 && ( last_7k2_coder_type > UNVOICED ) && st_fx->Opt_SC_VBR ) ) + IF( ( LE_16( snr_outlier_index, 4 ) && ( st_fx->last_coder_type > UNVOICED ) && !st_fx->Opt_SC_VBR ) || + ( LE_16( snr_outlier_index, 4 ) && ( last_7k2_coder_type > UNVOICED ) && st_fx->Opt_SC_VBR ) ) { @@ -2696,7 +2698,7 @@ Word16 wb_vad_ivas_fx( #else /* BASOP_NOGLOB */ tmp2 = round_fx( L_shl( L_tmp2, 14 ) ); /* Q10(high word)+ 14 -16 --> Q8*/ #endif - if ( L_tmp2 > 0 ) + IF( L_tmp2 > 0 ) { thr1_ol = add( thr1_ol, tmp2 ); /* Q24 >>16 + Q8 */ } @@ -2718,6 +2720,7 @@ Word16 wb_vad_ivas_fx( flag_he1 = 1; move16(); /* he1 primary decision */ hVAD->nb_active_frames_he1 = add( hVAD->nb_active_frames_he1, 1 ); /* Counter of consecutive active speech frames */ + move16(); IF( GE_16( hVAD->nb_active_frames_he1, ACTIVE_FRAMES_FX ) ) { @@ -2729,14 +2732,16 @@ Word16 wb_vad_ivas_fx( /* inside HO period */ test(); - if ( sub( hVAD->hangover_cnt_he1, HANGOVER_LONG_HE_FX ) < 0 && hVAD->hangover_cnt_he1 != 0 ) + IF( sub( hVAD->hangover_cnt_he1, HANGOVER_LONG_HE_FX ) < 0 && hVAD->hangover_cnt_he1 != 0 ) { hVAD->hangover_cnt_he1 = add( hVAD->hangover_cnt_he1, 1 ); + move16(); } - if ( hVAD->soft_hangover > 0 ) + IF( hVAD->soft_hangover > 0 ) { hVAD->soft_hangover = sub( hVAD->soft_hangover, 1 ); + move16(); } } ELSE @@ -2768,7 +2773,6 @@ Word16 wb_vad_ivas_fx( IF( LT_16( hVAD->bcg_flux_fx, 640 ) ) { hangover_hd = add( shr( hangover_hd, 1 ), 1 ); - move16(); } /* VAD hangover for he1 */ @@ -2780,6 +2784,7 @@ Word16 wb_vad_ivas_fx( flag_he1 = 1; move16(); hVAD->soft_hangover = sub( hVAD->soft_hangover, 1 ); + move16(); } ELSE { @@ -2801,6 +2806,7 @@ Word16 wb_vad_ivas_fx( flag_he1 = 1; move16(); hVAD->hangover_cnt_he1 = add( hVAD->hangover_cnt_he1, 1 ); + move16(); } @@ -2816,11 +2822,13 @@ Word16 wb_vad_ivas_fx( { /*st->bcg_flux = 0.9f * st->bcg_flux + (1-0.9f)*(st->bcg_flux+50);*/ hVAD->bcg_flux_fx = mac_r( L_mult( hVAD->bcg_flux_fx, 29491 ), add( hVAD->bcg_flux_fx, 800 ), 3277 ); /*Q4 */ + move16(); } ELSE { /*st->bcg_flux = 0.9f * st->bcg_flux + (1-0.9f)*snr_sumt*/ hVAD->bcg_flux_fx = mac_r( L_mult( hVAD->bcg_flux_fx, 29491 ), snr_sumt, 3277 ); /*Q4 */ + move16(); } } ELSE @@ -2829,11 +2837,13 @@ Word16 wb_vad_ivas_fx( { /*st->bcg_flux = 0.99f * st->bcg_flux + (1-0.99f)*(st->bcg_flux+10);*/ hVAD->bcg_flux_fx = mac_r( L_mult( hVAD->bcg_flux_fx, 32440 ), add( hVAD->bcg_flux_fx, 160 ), 328 ); /*Q4 */ + move16(); } ELSE { /*st->bcg_flux = 0.99f * st->bcg_flux + (1-0.99f)*snr_sumt;*/ hVAD->bcg_flux_fx = mac_r( L_mult( hVAD->bcg_flux_fx, 32440 ), snr_sumt, 328 ); /*Q4 */ + move16(); } } } @@ -2845,11 +2855,13 @@ Word16 wb_vad_ivas_fx( { /*st->bcg_flux = 0.95f * st->bcg_flux + (1-0.95f)*(st->bcg_flux-30);*/ hVAD->bcg_flux_fx = mac_r( L_mult( hVAD->bcg_flux_fx, 31131 ), sub( hVAD->bcg_flux_fx, 480 ), 1638 ); /*Q4 */ + move16(); } ELSE { /*st->bcg_flux = 0.95f * st->bcg_flux + (1-0.95f)*snr_sumt;*/ hVAD->bcg_flux_fx = mac_r( L_mult( hVAD->bcg_flux_fx, 31131 ), snr_sumt, 1638 ); /*Q4 */ + move16(); } } ELSE @@ -2858,16 +2870,19 @@ Word16 wb_vad_ivas_fx( { /*st->bcg_flux = 0.9992f * st->bcg_flux + (1-0.9992f)*(st->bcg_flux-10);*/ hVAD->bcg_flux_fx = mac_r( L_mult( hVAD->bcg_flux_fx, 32742 ), sub( hVAD->bcg_flux_fx, 160 ), 26 ); /*Q4 */ + move16(); } ELSE { /*st->bcg_flux = 0.9992f * st->bcg_flux + (1-0.9992f)*snr_sumt;*/ hVAD->bcg_flux_fx = mac_r( L_mult( hVAD->bcg_flux_fx, 32742 ), snr_sumt, 26 ); /*Q4 */ + move16(); } } } hVAD->bcg_flux_init = s_max( hVAD->bcg_flux_init, 0 ); + move16(); } flag = 0; @@ -2885,6 +2900,7 @@ Word16 wb_vad_ivas_fx( move16(); hVAD->nb_active_frames = add( hVAD->nb_active_frames, 1 ); /* Counter of consecutive active speech frames */ + move16(); IF( GE_16( hVAD->nb_active_frames, ACTIVE_FRAMES_FX ) ) { @@ -2896,9 +2912,10 @@ Word16 wb_vad_ivas_fx( /* inside HO period */ test(); - if ( LT_16( hVAD->hangover_cnt, HANGOVER_LONG_FX ) && hVAD->hangover_cnt != 0 ) + IF( LT_16( hVAD->hangover_cnt, HANGOVER_LONG_FX ) && hVAD->hangover_cnt != 0 ) { hVAD->hangover_cnt = add( hVAD->hangover_cnt, 1 ); + move16(); } } ELSE @@ -2918,14 +2935,16 @@ Word16 wb_vad_ivas_fx( { test(); test(); - if ( EQ_16( st_fx->element_mode, EVS_MONO ) && ( LT_16( lp_snr, th_clean ) ) && ( st_fx->Opt_SC_VBR != 0 ) && ( GE_16( hVAD->hangover_cnt, 2 ) ) ) + test(); + if ( ( st_fx->element_mode == EVS_MONO ) && ( LT_16( lp_snr, th_clean ) ) && ( st_fx->Opt_SC_VBR != 0 ) && ( GE_16( hVAD->hangover_cnt, 2 ) ) ) { *noisy_speech_HO = 1; move16(); } test(); test(); - if ( EQ_16( st_fx->element_mode, EVS_MONO ) && ( GE_16( lp_snr, th_clean ) ) && ( st_fx->Opt_SC_VBR != 0 ) && ( GE_16( hVAD->hangover_cnt, 2 ) ) ) + test(); + if ( ( st_fx->element_mode == EVS_MONO ) && ( GE_16( lp_snr, th_clean ) ) && ( st_fx->Opt_SC_VBR != 0 ) && ( GE_16( hVAD->hangover_cnt, 2 ) ) ) { *clean_speech_HO = 1; move16(); @@ -2972,6 +2991,7 @@ Word16 wb_vad_ivas_fx( IF( GT_16( snr_sum, thr1 ) ) /* Speech present, possibly in hangover */ { hVAD->nb_active_frames = add( hVAD->nb_active_frames, 1 ); /* Counter of consecutive active speech frames */ + move16(); IF( GE_16( hVAD->nb_active_frames, ACTIVE_FRAMES_FX ) ) { hVAD->nb_active_frames = ACTIVE_FRAMES_FX; @@ -2995,6 +3015,7 @@ Word16 wb_vad_ivas_fx( IF( LT_16( hVAD->hangover_cnt, HANGOVER_LONG_NB_FX ) ) { hVAD->hangover_cnt = add( hVAD->hangover_cnt, 1 ); + move16(); IF( LT_16( lp_snr, 4864 ) ) /*19.0f Q8*/ /* very low SNR */ @@ -3018,7 +3039,7 @@ Word16 wb_vad_ivas_fx( tmp = 282; move16(); /* 1.10f; */ } - if ( LT_16( lp_snr, th_clean ) ) + IF( LT_16( lp_snr, th_clean ) ) { thr2 = sub( thr1_nb_mod, tmp ); /*thr2 = thr1 - [ 1.10 || 1.3 ];*/ } @@ -3041,11 +3062,11 @@ Word16 wb_vad_ivas_fx( st_fx->localVAD = 0; move16(); - if ( EQ_16( st_fx->element_mode, EVS_MONO ) ) + if ( st_fx->element_mode == EVS_MONO ) { *NB_speech_HO = 1; + move16(); } - move16(); } thr1 = thr1_nb_mod; move16(); /* needed for st_fx->vadnoise_fx update below */ @@ -3072,7 +3093,7 @@ Word16 wb_vad_ivas_fx( } } - if ( st_fx->hSC_VBR != NULL ) + IF( st_fx->hSC_VBR != NULL ) { /* SC-VBR */ st_fx->hSC_VBR->vadsnr_fx = snr_sum; @@ -3083,17 +3104,21 @@ Word16 wb_vad_ivas_fx( /* Updates */ hVAD->prim_act_quick_fx = mult_r( 26214, hVAD->prim_act_quick_fx ); /*Q15 */ + move16(); if ( st_fx->localVAD != 0 ) { hVAD->prim_act_quick_fx = add( 6554, hVAD->prim_act_quick_fx ); /*Q15 */ + move16(); } hVAD->prim_act_slow_fx = mult_r( 32440, hVAD->prim_act_slow_fx ); /*Q15 */ + move16(); if ( st_fx->localVAD != 0 ) { hVAD->prim_act_slow_fx = add( 328, hVAD->prim_act_slow_fx ); /*Q15 */ + move16(); } tmp = hVAD->prim_act_slow_fx; @@ -3105,18 +3130,22 @@ Word16 wb_vad_ivas_fx( } /*st->prim_act = 0.1f * tmp + (1.0f-0.1f)* st->prim_act;*/ hVAD->prim_act_fx = mac_r( L_mult( 3277, tmp ), 29491, hVAD->prim_act_fx ); - + move16(); hVAD->prim_act_quick_he_fx = mult_r( 26214, hVAD->prim_act_quick_he_fx ); /*Q15 */ + move16(); if ( *localVAD_HE_SAD != 0 ) { hVAD->prim_act_quick_he_fx = add( 6554, hVAD->prim_act_quick_he_fx ); /*Q15 */ + move16(); } hVAD->prim_act_slow_he_fx = mult_r( 32440, hVAD->prim_act_slow_he_fx ); /*Q15 */ + move16(); if ( *localVAD_HE_SAD != 0 ) { hVAD->prim_act_slow_he_fx = add( 328, hVAD->prim_act_slow_he_fx ); /*Q15 */ + move16(); } tmp = hVAD->prim_act_slow_he_fx; @@ -3127,42 +3156,50 @@ Word16 wb_vad_ivas_fx( move16(); } hVAD->prim_act_he_fx = mac_r( L_mult( 3277, tmp ), 29491, hVAD->prim_act_he_fx ); - + move16(); if ( L_and( hVAD->vad_flag_reg_H, (Word32) 0x40000L ) != 0 ) /* 0x4000L = 0x01L << 18 */ { hVAD->vad_flag_cnt_50 = sub( hVAD->vad_flag_cnt_50, 1 ); + move16(); } hVAD->vad_flag_reg_H = L_shl( L_and( hVAD->vad_flag_reg_H, (Word32) 0x3fffffffL ), 1 ); - + move32(); if ( L_and( hVAD->vad_flag_reg_L, (Word32) 0x40000000L ) != 0 ) { hVAD->vad_flag_reg_H = L_or( hVAD->vad_flag_reg_H, 0x01L ); + move32(); } hVAD->vad_flag_reg_L = L_shl( L_and( hVAD->vad_flag_reg_L, (Word32) 0x3fffffffL ), 1 ); - + move32(); IF( flag != 0 ) /* should not include the extra DTX hangover */ { hVAD->vad_flag_reg_L = L_or( hVAD->vad_flag_reg_L, 0x01L ); + move32(); hVAD->vad_flag_cnt_50 = add( hVAD->vad_flag_cnt_50, 1 ); + move16(); } if ( L_and( hVAD->vad_prim_reg, (Word32) 0x8000L ) != 0 ) /* 0x8000L = 1L << 15 */ { hVAD->vad_prim_cnt_16 = sub( hVAD->vad_prim_cnt_16, 1 ); + move16(); } hVAD->vad_prim_reg = L_shl( L_and( hVAD->vad_prim_reg, (Word32) 0x3fffffffL ), 1 ); + move32(); IF( st_fx->localVAD != 0 ) { hVAD->vad_prim_reg = L_or( hVAD->vad_prim_reg, 0x01L ); + move32(); hVAD->vad_prim_cnt_16 = add( hVAD->vad_prim_cnt_16, 1 ); + move16(); } return flag;