diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 1aab20d0ec84e3c559fadb210b1ecbd4be5ae403..65770f002f6fa750e1b36cca3128b26a22a55c03 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -384,12 +384,12 @@ ivas_error create_cpe_dec( ivas_error create_mct_dec_fx( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ); -#endif // IVAS_FLOAT_FIXED +#else // IVAS_FLOAT_FIXED ivas_error create_mct_dec( Decoder_Struct *st_ivas /* i/o: IVAS decoder handle */ ); - +#endif ivas_error mct_dec_reconfigure( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const uint16_t b_nchan_change /* i : flag indicating different channel count */ @@ -4553,24 +4553,12 @@ void ivas_dirac_dec_get_response( const int16_t ambisonics_order ); #ifdef IVAS_FLOAT_FIXED -void ivas_dirac_dec_get_response_fixed( - const Word16 azimuth, - const Word16 elevation, - Word32 *response, - const Word16 ambisonics_order ); - -void ivas_dirac_dec_get_response_fixed_Q( - const Word16 azimuth, - const Word16 elevation, - Word32 *response, - const Word16 ambisonics_order, - Word16 Q); - void ivas_dirac_dec_get_response_fx( const Word16 azimuth, const Word16 elevation, Word32 * response, - const Word16 ambisonics_order); + const Word16 ambisonics_order, + Word16 Q_out); #endif void calculate_hodirac_sector_parameters( diff --git a/lib_com/ivas_spar_com.c b/lib_com/ivas_spar_com.c index f37d9ce7d95109c786fd169e1c2fcc3f548c1f36..aa762741c9d81d877734661cd29565310fcf5d04 100644 --- a/lib_com/ivas_spar_com.c +++ b/lib_com/ivas_spar_com.c @@ -3284,7 +3284,7 @@ void ivas_get_spar_md_from_dirac_fx( if ( n_ts > 1 ) { // ivas_dirac_dec_get_response( (int16_t) azi_dirac[band][i_ts], (int16_t) ele_dirac[band][i_ts], response_avg, order ); - ivas_dirac_dec_get_response_fx( (int16_t) L_shr( azi_dirac_fx[band][i_ts], Q22 ), (int16_t) L_shr( ele_dirac_fx[band][i_ts], Q22 ), response_avg_fx, order ); + ivas_dirac_dec_get_response_fx( (int16_t) L_shr( azi_dirac_fx[band][i_ts], Q22 ), (int16_t) L_shr( ele_dirac_fx[band][i_ts], Q22 ), response_avg_fx, order, Q30 ); /*for ( int l = 0; l < MAX_OUTPUT_CHANNELS; l++ ) { response_avg[l] = (float) response_avg_fx[l] / ( 1 << 30 ); @@ -3293,7 +3293,7 @@ void ivas_get_spar_md_from_dirac_fx( else if ( useLowerRes ) { // ivas_dirac_dec_get_response( (int16_t) azi_dirac[band][0], (int16_t) ele_dirac[band][0], response_avg, order ); - ivas_dirac_dec_get_response_fx( (int16_t) L_shr( azi_dirac_fx[band][0], Q22 ), (int16_t) L_shr( ele_dirac_fx[band][0], Q22 ), response_avg_fx, order ); + ivas_dirac_dec_get_response_fx( (int16_t) L_shr( azi_dirac_fx[band][0], Q22 ), (int16_t) L_shr( ele_dirac_fx[band][0], Q22 ), response_avg_fx, order, Q30 ); /*for ( int l = 0; l < MAX_OUTPUT_CHANNELS; l++ ) { response_avg[l] = (float) response_avg_fx[l] / ( 1 << 30 ); @@ -3304,7 +3304,7 @@ void ivas_get_spar_md_from_dirac_fx( for ( block = 0; block < MAX_PARAM_SPATIAL_SUBFRAMES; block++ ) { // ivas_dirac_dec_get_response( (int16_t) azi_dirac[band][block], (int16_t) ele_dirac[band][block], &( response[block][0] ), order ); - ivas_dirac_dec_get_response_fx( (int16_t) L_shr( azi_dirac_fx[band][block], Q22 ), (int16_t) L_shr( ele_dirac_fx[band][block], Q22 ), &( response_fx[block][0] ), order ); + ivas_dirac_dec_get_response_fx( (int16_t) L_shr( azi_dirac_fx[band][block], Q22 ), (int16_t) L_shr( ele_dirac_fx[band][block], Q22 ), &( response_fx[block][0] ), order, Q30 ); /*for ( int l = 0; l < MAX_OUTPUT_CHANNELS; l++ ) { response[block][l] = (float) response_fx[block][l] / ( 1 << 30 ); @@ -4060,128 +4060,13 @@ void ivas_dirac_dec_get_response( #ifdef IVAS_FLOAT_FIXED /*------------------------------------------------------------------------- - * ivas_dirac_dec_get_response_fixed() + * ivas_dirac_dec_get_response_fx() * * Block Q of 29 is maintained * calculate reponse, 1 degree resolution * Input azimuth and elevation are expected in Q0 *------------------------------------------------------------------------*/ -void ivas_dirac_dec_get_response_fixed( - const Word16 azimuth, - const Word16 elevation, - Word32 *response, - const Word16 ambisonics_order ) -{ - Word16 index_azimuth, index_elevation; - Word16 el, e, az; - Word32 cos_1, cos_2, sin_1, cos_az[3]; - Word32 sin_az[3]; - Word32 f, c; - Word16 l, m; - Word16 b, b1, b_2, b1_2, a; - - index_azimuth = ( azimuth + 180 ) % 360; - index_elevation = elevation + 90; - e = index_elevation > 90 ? -1 : 1; - el = index_elevation > 90 ? 180 - index_elevation : index_elevation; - - az = index_azimuth > 180 ? 360 - index_azimuth : index_azimuth; - f = index_azimuth > 180 ? -( 1 << Q29 ) : ( 1 << Q29 ); - - cos_1 = dirac_gains_trg_term_int[az][0] >> 1; // Q29 - cos_2 = Mpy_32_32( cos_1, cos_1 ); // Q27 - sin_1 = Mpy_32_32( f, dirac_gains_trg_term_int[az][1] >> 1 ); // Q27 - cos_az[0] = cos_1; // Q29 - cos_az[1] = L_sub( Mpy_32_32( ( 1 << Q30 ), cos_2 ), ( 1 << Q25 ) ) << 4; // Q29 - cos_az[2] = L_sub( Mpy_32_32( Mpy_32_32( ( 1 << Q30 ), cos_1 ), cos_az[1] ) << 4, cos_az[0] ); // Q29 - sin_az[0] = sin_1 << 2; // Q29 - sin_az[1] = Mpy_32_32( Mpy_32_32( sin_1, ( 1 << Q30 ) ), cos_1 ) << 6; // Q29 - sin_az[2] = Mpy_32_32( sin_1, L_sub( L_shl_sat( Mpy_32_32( ( 1 << Q30 ), cos_2 ), 5 ), ( 1 << 29 ) ) ) << 4; - - response[0] = ( 1 << 29 ); - /* Un-optimized code - for reference */ - /* for( l = 1; l<= ambisonics_order; l++ ) */ - /* { */ - /* int16_t b, b1, a; */ - /* float c; */ - /* for( m = 0; m < l; m++ ) */ - /* { */ - /* b = l*l+m; */ - /* a = dirac_gains_P_idx[b]; */ - /* c = SQRT2 * dirac_gains_norm_term[a] * dirac_gains_Pnm[el][a]; */ - - /* if( m%2 == 1 ) */ - /* { */ - /* c = c*e; */ - /* } */ - - /* response[b] = c * sin_az[l-m-1]; */ - - /* b1 = l*l+2*l-m; */ - /* response[b1] = c * cos_az[l-m-1]; */ - - /* } */ - - /* b = l*l+l; */ - /* a = dirac_gains_P_idx[b]; */ - /* c = dirac_gains_norm_term[a] * dirac_gains_Pnm[el][a]; */ - /* if( l%2 == 1) */ - /* { */ - /* c = c*e; */ - /* } */ - - /* response[b] = c; */ - /* } */ - - FOR( l = 1; l <= ambisonics_order; l++ ) - { - b_2 = l * l; - b1_2 = l * l + 2 * l; - FOR( m = 0; m < l; m += 2 ) - { - b = b_2 + m; - a = dirac_gains_P_idx[b]; - c = Mpy_32_32( Mpy_32_32( SQRT2_FIXED, dirac_gains_norm_term_int[a] ), dirac_gains_Pnm_int[el][a] ); // Q25 - - response[b] = Mpy_32_32( c, sin_az[l - m - 1] ) << 6; // Q29 - - b1 = b1_2 - m; - response[b1] = Mpy_32_32( c, cos_az[l - m - 1] ) << 6; // Q29 - } - - FOR( m = 1; m < l; m += 2 ) - { - b = b_2 + m; - a = dirac_gains_P_idx[b]; - c = Mpy_32_32( Mpy_32_32( SQRT2_FIXED, dirac_gains_norm_term_int[a] ), dirac_gains_Pnm_int[el][a] ); // Q25 - IF( e == -1 ) - { - c = -c; - } - - response[b] = Mpy_32_32( c, sin_az[l - m - 1] ) << 6; // Q29 - - b1 = b1_2 - m; - response[b1] = Mpy_32_32( c, cos_az[l - m - 1] ) << 6; // Q29 - } - - b = b_2 + l; - a = dirac_gains_P_idx[b]; - c = Mpy_32_32( dirac_gains_norm_term_int[a], dirac_gains_Pnm_int[el][a] ); // Q26 - IF( l % 2 == 1 ) - { - IF( e == -1 ) - { - c = -c; - } - } - - response[b] = c << 3; // Q29 - } - - return; -} Word32 local_result_table[91][9] = { { -1518500224, @@ -6193,7 +6078,8 @@ void ivas_dirac_dec_get_response_fx( const Word16 azimuth, const Word16 elevation, Word32 *response_fx, - const Word16 ambisonics_order ) + const Word16 ambisonics_order, + Word16 Q_out ) { // float response[MAX_OUTPUT_CHANNELS]; int16_t index_azimuth, index_elevation; @@ -6203,7 +6089,7 @@ void ivas_dirac_dec_get_response_fx( // float sin_az[3]; Word32 sin_az_fx[3]; // float f, c; - Word32 f_fx, c_fx; + Word32 f_fx; Word32 c_fx_better; int16_t l, m; int16_t b, b1, b_2, b1_2, a; @@ -6239,7 +6125,7 @@ void ivas_dirac_dec_get_response_fx( sin_az_fx[2] = L_shl_sat( Mpy_32_32( sin_1_fx, ( cos_2_fx - ONE_IN_Q29 ) ), 2 ); // response[0] = 1.0f; - response_fx[0] = ONE_IN_Q30; + response_fx[0] = L_shl_sat( 1, Q_out ); /* Un-optimized code - for reference */ /* for( l = 1; l<= ambisonics_order; l++ ) */ /* { */ @@ -6283,16 +6169,16 @@ void ivas_dirac_dec_get_response_fx( b = b_2 + m; a = dirac_gains_P_idx[b]; // c = SQRT2 * dirac_gains_norm_term[a] * dirac_gains_Pnm[el][a]; - c_fx = Mpy_32_32( SQRT2_FIXED, Mpy_32_32( dirac_gains_norm_term_fx[a], dirac_gains_Pnm_int[el][a] ) ); + // c_fx = Mpy_32_32( SQRT2_FIXED, Mpy_32_32( dirac_gains_norm_term_fx[a], dirac_gains_Pnm_int[el][a] ) ); c_fx_better = local_result_table[el][a]; // response[b] = c * sin_az[l - m - 1]; - response_fx[b] = Mpy_32_32( L_shl( c_fx, 3 ), sin_az_fx[l - m - 1] ); - response_fx[b] = Mpy_32_32( c_fx_better, sin_az_fx[l - m - 1] ); + // response_fx[b] = Mpy_32_32( L_shl( c_fx, 3 ), sin_az_fx[l - m - 1] ); + response_fx[b] = L_shl_sat( Mpy_32_32( c_fx_better, sin_az_fx[l - m - 1] ), sub( Q_out, 30 ) ); // Q_out b1 = b1_2 - m; // response[b1] = c * cos_az[l - m - 1]; - response_fx[b1] = Mpy_32_32( L_shl( c_fx, 3 ), cos_az_fx[l - m - 1] ); - response_fx[b1] = Mpy_32_32( c_fx_better, cos_az_fx[l - m - 1] ); + // response_fx[b1] = Mpy_32_32( L_shl( c_fx, 3 ), cos_az_fx[l - m - 1] ); + response_fx[b1] = L_shl_sat( Mpy_32_32( c_fx_better, cos_az_fx[l - m - 1] ), sub( Q_out, 30 ) ); // Q_out } for ( m = 1; m < l; m += 2 ) @@ -6300,159 +6186,42 @@ void ivas_dirac_dec_get_response_fx( b = b_2 + m; a = dirac_gains_P_idx[b]; // c = SQRT2 * dirac_gains_norm_term[a] * dirac_gains_Pnm[el][a]; - c_fx = Mpy_32_32( SQRT2_FIXED, Mpy_32_32( dirac_gains_norm_term_fx[a], dirac_gains_Pnm_int[el][a] ) ); + // c_fx = Mpy_32_32( SQRT2_FIXED, Mpy_32_32( dirac_gains_norm_term_fx[a], dirac_gains_Pnm_int[el][a] ) ); c_fx_better = local_result_table[el][a]; if ( e == -1 ) { - c_fx = L_negate( c_fx ); + // c_fx = L_negate( c_fx ); c_fx_better = L_negate( c_fx_better ); } // c = c * e; // response[b] = c * sin_az[l - m - 1]; - response_fx[b] = Mpy_32_32( L_shl( c_fx, 3 ), sin_az_fx[l - m - 1] ); - response_fx[b] = Mpy_32_32( c_fx_better, sin_az_fx[l - m - 1] ); + // response_fx[b] = Mpy_32_32( L_shl( c_fx, 3 ), sin_az_fx[l - m - 1] ); + response_fx[b] = L_shl_sat( Mpy_32_32( c_fx_better, sin_az_fx[l - m - 1] ), sub( Q_out, 30 ) ); // Q_out b1 = b1_2 - m; // response[b1] = c * cos_az[l - m - 1]; - response_fx[b1] = Mpy_32_32( L_shl( c_fx, 3 ), cos_az_fx[l - m - 1] ); - response_fx[b1] = Mpy_32_32( c_fx_better, cos_az_fx[l - m - 1] ); + // response_fx[b1] = Mpy_32_32( L_shl( c_fx, 3 ), cos_az_fx[l - m - 1] ); + response_fx[b1] = L_shl_sat( Mpy_32_32( c_fx_better, cos_az_fx[l - m - 1] ), sub( Q_out, 30 ) ); // Q_out } b = b_2 + l; a = dirac_gains_P_idx[b]; // c = dirac_gains_norm_term[a] * dirac_gains_Pnm[el][a]; - c_fx = Mpy_32_32( dirac_gains_norm_term_fx[a], dirac_gains_Pnm_int[el][a] ); + // c_fx = Mpy_32_32( dirac_gains_norm_term_fx[a], dirac_gains_Pnm_int[el][a] ); c_fx_better = local_result_table_2[el][a]; if ( l % 2 == 1 ) { // c = c * e; if ( e == -1 ) { - c_fx = L_negate( c_fx ); + // c_fx = L_negate( c_fx ); c_fx_better = L_negate( c_fx_better ); } } // response[b] = c; - response_fx[b] = L_shl( c_fx, 2 ); - response_fx[b] = c_fx_better; - } - - return; -} - -void ivas_dirac_dec_get_response_fixed_Q( - const Word16 azimuth, - const Word16 elevation, - Word32 *response, - const Word16 ambisonics_order, - Word16 Q_out ) -{ - Word16 index_azimuth, index_elevation; - Word16 el, e, az; - Word32 cos_1, cos_2, sin_1, cos_az[3]; - Word32 sin_az[3]; - Word32 f, c; - Word16 l, m; - Word16 b, b1, b_2, b1_2, a; - - index_azimuth = ( azimuth + 180 ) % 360; - index_elevation = elevation + 90; - e = index_elevation > 90 ? -1 : 1; - el = index_elevation > 90 ? 180 - index_elevation : index_elevation; - - az = index_azimuth > 180 ? 360 - index_azimuth : index_azimuth; - f = index_azimuth > 180 ? -( 1 << Q29 ) : ( 1 << Q29 ); - - cos_1 = dirac_gains_trg_term_int[az][0] >> 1; // Q29 - cos_2 = Mpy_32_32( cos_1, cos_1 ); // Q27 - sin_1 = Mpy_32_32( f, dirac_gains_trg_term_int[az][1] >> 1 ); // Q27 - cos_az[0] = cos_1; // Q29 - cos_az[1] = L_sub( Mpy_32_32( ( 1 << Q30 ), cos_2 ), ( 1 << Q25 ) ) << 4; // Q29 - cos_az[2] = L_sub( Mpy_32_32( Mpy_32_32( ( 1 << Q30 ), cos_1 ), cos_az[1] ) << 4, cos_az[0] ); // Q29 - sin_az[0] = sin_1 << 2; // Q29 - sin_az[1] = Mpy_32_32( Mpy_32_32( sin_1, ( 1 << Q30 ) ), cos_1 ) << 6; // Q29 - sin_az[2] = Mpy_32_32( sin_1, L_sub( L_shl_sat( Mpy_32_32( ( 1 << Q30 ), cos_2 ), 5 ), ( 1 << 29 ) ) ) << 4; - - response[0] = L_shl( 1, Q_out ); - /* Un-optimized code - for reference */ - /* for( l = 1; l<= ambisonics_order; l++ ) */ - /* { */ - /* int16_t b, b1, a; */ - /* float c; */ - /* for( m = 0; m < l; m++ ) */ - /* { */ - /* b = l*l+m; */ - /* a = dirac_gains_P_idx[b]; */ - /* c = SQRT2 * dirac_gains_norm_term[a] * dirac_gains_Pnm[el][a]; */ - - /* if( m%2 == 1 ) */ - /* { */ - /* c = c*e; */ - /* } */ - - /* response[b] = c * sin_az[l-m-1]; */ - - /* b1 = l*l+2*l-m; */ - /* response[b1] = c * cos_az[l-m-1]; */ - - /* } */ - - /* b = l*l+l; */ - /* a = dirac_gains_P_idx[b]; */ - /* c = dirac_gains_norm_term[a] * dirac_gains_Pnm[el][a]; */ - /* if( l%2 == 1) */ - /* { */ - /* c = c*e; */ - /* } */ - - /* response[b] = c; */ - /* } */ - - FOR( l = 1; l <= ambisonics_order; l++ ) - { - b_2 = l * l; - b1_2 = l * l + 2 * l; - FOR( m = 0; m < l; m += 2 ) - { - b = b_2 + m; - a = dirac_gains_P_idx[b]; - c = Mpy_32_32( Mpy_32_32( SQRT2_FIXED, dirac_gains_norm_term_int[a] ), dirac_gains_Pnm_int[el][a] ); // Q25 - - response[b] = L_shl( Mpy_32_32( c, sin_az[l - m - 1] ), Q_out - Q23 ); // Q_out - - b1 = b1_2 - m; - response[b1] = L_shl( Mpy_32_32( c, cos_az[l - m - 1] ), Q_out - Q23 ); // Q_out - } - - FOR( m = 1; m < l; m += 2 ) - { - b = b_2 + m; - a = dirac_gains_P_idx[b]; - c = Mpy_32_32( Mpy_32_32( SQRT2_FIXED, dirac_gains_norm_term_int[a] ), dirac_gains_Pnm_int[el][a] ); // Q25 - IF( e == -1 ) - { - c = -c; - } - - response[b] = L_shl( Mpy_32_32( c, sin_az[l - m - 1] ), Q_out - Q23 ); // Q29 - - b1 = b1_2 - m; - response[b1] = L_shl( Mpy_32_32( c, cos_az[l - m - 1] ), Q_out - Q23 ); // Q29 - } - - b = b_2 + l; - a = dirac_gains_P_idx[b]; - c = Mpy_32_32( dirac_gains_norm_term_int[a], dirac_gains_Pnm_int[el][a] ); // Q26 - IF( l % 2 == 1 ) - { - IF( e == -1 ) - { - c = -c; - } - } - - response[b] = L_shl( c, Q_out - Q26 ); // Q29 + // response_fx[b] = L_shl( c_fx, 2 ); + response_fx[b] = L_shl_sat( c_fx_better, sub( Q_out, 30 ) ); // Q_out } return; diff --git a/lib_dec/ACcontextMapping_dec_fx.c b/lib_dec/ACcontextMapping_dec_fx.c index f2ec7d5735bc8e740d4182b590b887ed1b2c2a36..01298f6ddb2f3eb99d434673f8fc6b3af43f862e 100644 --- a/lib_dec/ACcontextMapping_dec_fx.c +++ b/lib_dec/ACcontextMapping_dec_fx.c @@ -371,9 +371,11 @@ Word16 RCcontextMapping_decode2_no_mem_s17_LCS_fx( start_bit_pos = st->next_bit_pos; lsbs_bit_pos = add( start_bit_pos, sub( nbbits, 1 ) ); n = 0; + move16(); k = 1; + move16(); nt_half = shr( nt, 1 ); - + move16(); WHILE( LT_16( k, nt_half ) ) { n = add( n, 1 ); @@ -381,16 +383,17 @@ Word16 RCcontextMapping_decode2_no_mem_s17_LCS_fx( } bits_tups = n; - - n = get_next_indice_fx( st, n ) + 1; + move16(); + n = add( get_next_indice_fx( st, n ), 1 ); t = 0; - + move16(); lastnz = shl( n, 1 ); - IF( GT_16( lastnz, nt ) ) + if ( GT_16( lastnz, nt ) ) { st->BER_detect = 1; + move16(); return 0; } @@ -411,13 +414,16 @@ Word16 RCcontextMapping_decode2_no_mem_s17_LCS_fx( ELSE { rateFlag = 0; + move16(); } /* Init */ c[0] = c[1] = 0; - + move16(); + move16(); /* mapped domain */ numPeakIndicesOrig = hm_cfg->numPeakIndices; + move16(); hm_cfg->numPeakIndices = s_min( hm_cfg->numPeakIndices, lastnz ); numHoleIndices = sub( lastnz, hm_cfg->numPeakIndices ); @@ -425,18 +431,22 @@ Word16 RCcontextMapping_decode2_no_mem_s17_LCS_fx( FOR( k = numHoleIndices; k < hm_cfg->numHoleIndices; ++k ) { hm_cfg->holeIndices[k] = add( hm_cfg->holeIndices[k], nt ); + move16(); } ii[0] = numPeakIndicesOrig; + move16(); ii[1] = 0; - + move16(); p1 = p2 = 0; /* to avoid compilation warnings */ - + move16(); + move16(); /* Start Decoding */ /* Initialize range decoder */ rc_uni_dec_init_fx( &rc_st_dec, &st->bit_stream[st->next_bit_pos], nbbits ); /* (nbbits + 30) entries are read by the decoder */ nbbits_m2 = nbbits; + move16(); rest_bits = negate( nbbits_m2 ); /* Main Loop through the 2-tuples */ @@ -448,25 +458,27 @@ Word16 RCcontextMapping_decode2_no_mem_s17_LCS_fx( /* Get context */ ctx = &c[s_or( p1, p2 )]; - t = add( *ctx, rateFlag ); IF( LT_16( nt_half, idx ) ) { - t = add( t, 1 << NBITS_CONTEXT ); + t = add( t, shl( 1, NBITS_CONTEXT ) ); } esc_nb = 0; + move16(); r = 0; - + move16(); + test(); /* BER detection: Check max value of context t leading to out-of-bound access to ari_lookup_s17_LC[]*/ - IF( ( GE_16( t, ( 1 << ( NBITS_CONTEXT + NBITS_RATEQ ) ) ) ) || lsbs_bit_pos <= 0 ) + IF( ( GE_16( t, ( 1 << ( NBITS_CONTEXT + NBITS_RATEQ ) ) ) ) || ( lsbs_bit_pos <= 0 ) ) { st->BER_detect = 1; return 0; } a = b = 0; - + move16(); + move16(); /* MSBs decoding */ FOR( lev = 0; lev < 15 && lsbs_bit_pos > 0; ++lev ) { @@ -484,12 +496,16 @@ Word16 RCcontextMapping_decode2_no_mem_s17_LCS_fx( a = add( a, shl( get_indice_1_fx( st, lsbs_bit_pos-- ), lev ) ); b = add( b, shl( get_indice_1_fx( st, lsbs_bit_pos-- ), lev ) ); } - + test(); + test(); IF( ( LT_16( lsbs_bit_pos, -1 ) && GE_16( r, VAL_ESC ) ) || GT_16( lev, 14 ) ) { x[a1_i] = 0; + move16(); x[b1_i] = 0; + move16(); st->BER_detect = 1; + move16(); return 0; } @@ -515,15 +531,16 @@ Word16 RCcontextMapping_decode2_no_mem_s17_LCS_fx( /* Store decoded data */ x[a1_i] = a; + move16(); x[b1_i] = b; - + move16(); /* Update context for next 2-tuple */ IF( EQ_32( p1, p2 ) ) { /* peak-peak or hole-hole context */ lev = sub( esc_nb, 1 ); - IF( LE_16( lev, 0 ) ) + IF( lev <= 0 ) { t = add( 1, imult1616( add( a1, b1 ), add( lev, 2 ) ) ); } @@ -542,12 +559,14 @@ Word16 RCcontextMapping_decode2_no_mem_s17_LCS_fx( { /* update first context */ c[p1] = update_mixed_context( c[p1], a ); + move16(); } IF( idx2 & 1 ) { /* update second context */ c[p2] = update_mixed_context( c[p2], b ); + move16(); } } } @@ -565,6 +584,7 @@ Word16 RCcontextMapping_decode2_no_mem_s17_LCS_fx( /* Decode signs */ n = nt; + move16(); } ELSE /* if(!hm_cfg) */ { @@ -575,10 +595,12 @@ Word16 RCcontextMapping_decode2_no_mem_s17_LCS_fx( IF( GT_16( nbbits, 400 ) ) { rateFlag = 2; + move16(); } ELSE { rateFlag = 0; + move16(); } /* Start Decoding */ @@ -586,27 +608,32 @@ Word16 RCcontextMapping_decode2_no_mem_s17_LCS_fx( rc_uni_dec_init_fx( &rc_st_dec, &st->bit_stream[st->next_bit_pos], nbbits ); /* (nbbits + 30) entries are read by the decoder */ nbbits_m2 = nbbits; + move16(); rest_bits = negate( nbbits_m2 ); t = 0; + move16(); s = 0; - + move16(); /* Main Loop through the 2-tuples */ FOR( k = 0; k < lastnz; k += 2 ) { rateQ = add( rateFlag, (Word16) GT_16( k, ( nt_half ) ) ); - + test(); /* BER detection: Check max value of context t leading to out-of-bound access to ari_lookup_s17_LC[]*/ - IF( ( GE_16( t, ( 1 << ( NBITS_CONTEXT ) ) ) ) || lsbs_bit_pos <= 0 ) + IF( ( GE_16( t, ( 1 << ( NBITS_CONTEXT ) ) ) ) || ( lsbs_bit_pos <= 0 ) ) { st->BER_detect = 1; + move16(); return 0; } a = b = 0; + move16(); esc_nb = 0; + move16(); r = 0; - + move16(); /* MSBs decoding */ FOR( lev = 0; lev < 15 && lsbs_bit_pos > 0; ++lev ) { @@ -624,12 +651,16 @@ Word16 RCcontextMapping_decode2_no_mem_s17_LCS_fx( a = add( a, shl( get_indice_1_fx( st, lsbs_bit_pos-- ), lev ) ); b = add( b, shl( get_indice_1_fx( st, lsbs_bit_pos-- ), lev ) ); } - + test(); + test(); IF( ( LT_16( lsbs_bit_pos, -1 ) && GE_16( r, VAL_ESC ) ) || GT_16( lev, 14 ) ) { x[k + 0] = 0; + move16(); x[k + 1] = 0; + move16(); st->BER_detect = 1; + move16(); return 0; } @@ -655,8 +686,9 @@ Word16 RCcontextMapping_decode2_no_mem_s17_LCS_fx( /* Store decoded data */ x[k + 0] = a; + move16(); x[k + 1] = b; - + move16(); /* Update context for next 2-tuple */ IF( LT_16( esc_nb, 2 ) ) { @@ -674,6 +706,7 @@ Word16 RCcontextMapping_decode2_no_mem_s17_LCS_fx( /* Decode signs */ n = lastnz; + move16(); } /* end of if(hm_cfg) */ FOR( k = 0; k < n; k++ ) @@ -681,6 +714,7 @@ Word16 RCcontextMapping_decode2_no_mem_s17_LCS_fx( IF( x[k] > 0 ) { x[k] = imult1616( x[k], sub( 1, shl( get_next_indice_1_fx( st ), 1 ) ) ); + move16(); } } @@ -690,6 +724,7 @@ Word16 RCcontextMapping_decode2_no_mem_s17_LCS_fx( FOR( k = 0; k < resQBits; ++k ) { x[nt + k] = get_indice_1_fx( st, sub( lsbs_bit_pos, k ) ); + move16(); } /* Set bitstream pointer to end of buffer */ diff --git a/lib_dec/TonalComponentDetection.c b/lib_dec/TonalComponentDetection.c index 76ee5e1798e64efa70770ae1480a3004b559bc82..12908a001493d61153fab0aaafb6a171ee2f3a64 100644 --- a/lib_dec/TonalComponentDetection.c +++ b/lib_dec/TonalComponentDetection.c @@ -45,11 +45,8 @@ #include "stat_com.h" #include "wmc_auto.h" #include "ivas_prot.h" -#ifdef IVAS_FLOAT_FIXED -#include "ivas_prot_fx.h" -#endif // IVAS_FLOAT_FIXED - +#ifndef IVAS_FLOAT_FIXED /*---------------------------------------------------------------------* * Local function prototypes *---------------------------------------------------------------------*/ @@ -889,3 +886,4 @@ static void findTonalComponents( return; } +#endif diff --git a/lib_dec/TonalComponentDetection_fx.c b/lib_dec/TonalComponentDetection_fx.c index 55a2623182dbd98657fc01e9760fa84ac57b0bae..4a576bfe0f97a2bef57f1ee810d435a12405e202 100644 --- a/lib_dec/TonalComponentDetection_fx.c +++ b/lib_dec/TonalComponentDetection_fx.c @@ -64,24 +64,29 @@ void ivas_DetectTonalComponents_fx( { Word16 F0; Word16 thresholdModification[L_FRAME_MAX], lastMDCTSpect_exp; - Word32 pScaledMdctSpectrum[L_FRAME_MAX] = { 0 }; + Word32 pScaledMdctSpectrum[L_FRAME_MAX]; Word16 nBands; Word32 sns_int_scf_fx[FDNS_NPTS]; Word16 q_pScaledMdctSpectrum; + set32_fx( pScaledMdctSpectrum, 0, L_FRAME_MAX ); + FOR( Word16 i = 0; i < nSamples; i++ ) { pScaledMdctSpectrum[i] = L_shl( lastMDCTSpectrum[i], 16 ); // Q31 - lastMDCTSpectrum_exp + move32(); } #ifdef MSAN_FIX FOR( Word16 i = 0; i < FDNS_NPTS; i++ ) { - sns_int_scf_fx[i] = L_shl_sat( scaleFactors[i], 1 + scaleFactors_exp[i] ); // Q16 + sns_int_scf_fx[i] = L_shl_sat( scaleFactors[i], add( 1, scaleFactors_exp[i] ) ); // Q16 + move32(); } #endif IF( psychParamsCurrent == NULL ) { nBands = FDNS_NPTS; + move16(); // PMT("add nBands argument to mdct_shaping_16") mdct_shaping_16( lastMDCTSpectrum, nSamplesCore, nSamples, scaleFactors, scaleFactors_exp, scaleFactors_max_e, pScaledMdctSpectrum ); @@ -92,23 +97,25 @@ void ivas_DetectTonalComponents_fx( #ifndef MSAN_FIX FOR( Word16 i = 0; i < FDNS_NPTS; i++ ) { - sns_int_scf_fx[i] = L_shl( scaleFactors[i], 1 + scaleFactors_exp[i] ); // Q16 + sns_int_scf_fx[i] = L_shl( scaleFactors[i], add( 1, scaleFactors_exp[i] ) ); // Q16 } #endif - q_pScaledMdctSpectrum = 31 - lastMDCTSpectrum_exp; + q_pScaledMdctSpectrum = sub( 31, lastMDCTSpectrum_exp ); sns_shape_spectrum_fx( pScaledMdctSpectrum, &q_pScaledMdctSpectrum, psychParamsCurrent, sns_int_scf_fx, 16, nSamplesCore ); - q_pScaledMdctSpectrum = q_pScaledMdctSpectrum + 1; - Word16 tmp_e = 31 - q_pScaledMdctSpectrum; + q_pScaledMdctSpectrum = add( q_pScaledMdctSpectrum, 1 ); + Word16 tmp_e = sub( 31, q_pScaledMdctSpectrum ); nBands = psychParamsCurrent->nBands; + move16(); // till nSamplesCore different Q and nSamples - nSamplesCore in different Q - Scale_sig32( pScaledMdctSpectrum + nSamplesCore, nSamples - nSamplesCore, lastMDCTSpectrum_exp - tmp_e ); - lastMDCTSpect_exp = 31 - q_pScaledMdctSpectrum; + Scale_sig32( pScaledMdctSpectrum + nSamplesCore, sub( nSamples, nSamplesCore ), sub( lastMDCTSpectrum_exp, tmp_e ) ); + lastMDCTSpect_exp = sub( 31, q_pScaledMdctSpectrum ); } - for ( int i = nSamplesCore; i < nSamples; ++i ) + FOR( Word16 i = nSamplesCore; i < nSamples; ++i ) { Word64 tmp = W_mult_32_32( pScaledMdctSpectrum[i], sns_int_scf_fx[nBands - 1] ); // q_pScaledMdctSpectrum + 16 + 1 pScaledMdctSpectrum[i] = W_extract_h( W_shl( tmp, Q15 ) ); // q_pScaledMdctSpectrum + move32(); } /* Find peak candidates in the last frame. */ @@ -390,6 +397,7 @@ static void getEnvelope( sum = L_deposit_l( 0 ); level = 31089 /*LEVEL_ABOVE_ENVELOPE Q12*/; /*Q12*/ + move16(); FOR( i = 0; i < n2; i++ ) { @@ -424,13 +432,14 @@ static void getEnvelope( { sum = L_sub( sum, powerSpec[i - n1] ); tmp = Mpy_32_16_1( sum, level ); - envelope[i] = Mpy_32_16_1( tmp, InvIntTable[nSamples - ( i - nHalfFilterLength )] ); + envelope[i] = Mpy_32_16_1( tmp, InvIntTable[sub( nSamples, sub( i, nHalfFilterLength ) )] ); move32(); } FOR( i = 1; i < nSamples - 1; i++ ) { smoothedSpectrum[i] = L_add( L_add( Mpy_32_16_1( powerSpec[i - 1], 3072 /*0.75f Q12*/ ), L_shr( powerSpec[i], LEVEL_EXP ) ), Mpy_32_16_1( powerSpec[i + 1], 3072 /*0.75f Q12*/ ) ); + move32(); } move32(); @@ -663,7 +672,7 @@ static void CorrectF0( ELSE { test(); - IF( EQ_16( nSameDiff, nMostCommonDiff ) && ( abs_s( sub( iMostCommonDiff, pHarmonicIndexes[0] ) ) > abs_s( sub( sortedDiff[i - 1], pHarmonicIndexes[0] ) ) ) ) + IF( EQ_16( nSameDiff, nMostCommonDiff ) && GT_16( abs_s( sub( iMostCommonDiff, pHarmonicIndexes[0] ) ), abs_s( sub( sortedDiff[i - 1], pHarmonicIndexes[0] ) ) ) ) { nMostCommonDiff = nSameDiff; move16(); @@ -718,6 +727,7 @@ static void CorrectF0( ELSE { F0 = 0; + move16(); } } /* Otherwise if there are at least 3 distances between peaks with length 1 and if the 1st harmonic is in pHarmonicIndexes then keep the original F0 */ @@ -1040,6 +1050,9 @@ static void findTonalComponents( } /* Side lobe increase must be 2 times smaller than the decrease to the foot */ /* Eq. to 2.0f*powerSpectrum[lowerIdx-1]/powerSpectrum[lowerIdx] > powerSpectrum[lowerIdx]/powerSpectrum[j] */ + test(); + test(); + test(); IF( ( EQ_16( element_mode, EVS_MONO ) && GT_32( Mpy_32_32( L_shl( powerSpectrum[upperIdx + 1], 1 ), powerSpectrum[j] ), Mpy_32_32( powerSpectrum[upperIdx], powerSpectrum[upperIdx] ) ) ) || ( NE_16( element_mode, EVS_MONO ) && ( GT_64( W_mult_32_32( L_shl( powerSpectrum[upperIdx + 1], 1 ), powerSpectrum[j] ), W_mult_32_32( powerSpectrum[upperIdx], powerSpectrum[upperIdx] ) ) ) ) ) { diff --git a/lib_dec/acelp_core_dec_ivas_fx.c b/lib_dec/acelp_core_dec_ivas_fx.c index 89559d6c22194fa910a0bf00236833b1518f2a72..3679bde9824c1958c816a91bbefcc5de0eef00ff 100644 --- a/lib_dec/acelp_core_dec_ivas_fx.c +++ b/lib_dec/acelp_core_dec_ivas_fx.c @@ -103,18 +103,18 @@ ivas_error acelp_core_dec_ivas_fx( Word16 old_bwe_exc_fx[( ( PIT16k_MAX + ( L_FRAME16k + 1 ) + L_SUBFR16k ) * 2 )]; /* excitation buffer */ #endif Word16 *bwe_exc_fx; /* Excitation for SWB TBE */ - int16_t i, j, int_fs; - int16_t tc_subfr; - int16_t allow_cn_step; + Word16 i, j, int_fs; + Word16 tc_subfr; + Word16 allow_cn_step; Word16 temp_buf_fx[L_FRAME16k + L_SYN_MEM]; - int16_t last_pulse_pos; - int16_t T0_tmp; - int16_t do_WI; + Word16 last_pulse_pos; + Word16 T0_tmp; + Word16 do_WI; Word16 dct_buffer_fx[DCT_L_POST]; Word16 exc_buffer_fx[DCT_L_POST]; Word16 dct_exc_tmp_fx[L_FRAME16k]; - int16_t nb_bits; /* number of bits */ - int16_t indice; /* parameter indices to write */ + Word16 nb_bits; /* number of bits */ + Word16 indice; /* parameter indices to write */ Word16 gain_buf_fx[NB_SUBFR16k]; Word16 syn_fx_tmp2[L_FRAME_16k]; Word16 pitch_buf_tmp[NB_SUBFR16k]; @@ -125,14 +125,16 @@ ivas_error acelp_core_dec_ivas_fx( Word32 *realBuffer_fx[CLDFB_NO_COL_MAX], *imagBuffer_fx[CLDFB_NO_COL_MAX]; Word32 realBufferTmp_fx[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; Word32 imagBufferTmp_fx[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; - int16_t LSF_Q_prediction; /* LSF prediction mode */ + Word16 LSF_Q_prediction; /* LSF prediction mode */ Word16 avoid_lpc_burst_on_recovery; Word16 tmpF_fx; - int16_t uc_two_stage_flag; - int16_t tdm_lp_reuse_flag, tdm_low_rate_mode, tdm_Pitch_reuse_flag; + Word16 uc_two_stage_flag; + Word16 tdm_lp_reuse_flag, tdm_low_rate_mode, tdm_Pitch_reuse_flag; Word16 *old_exc_s_fx; /* Start of last excitation frame */ Word16 *p_tdm_Pri_pitch_buf_fx; - int16_t local_element_mode; + Word16 local_element_mode; + Word16 tmp_e = 0; + move16(); ivas_error error; Word32 bpf_error_signal_fx[L_FRAME16k]; @@ -146,46 +148,53 @@ ivas_error acelp_core_dec_ivas_fx( Word16 tmp; error = IVAS_ERR_OK; - - if ( st->element_mode == IVAS_CPE_MDCT && nchan_out == 1 && st->idchan == 1 && last_element_brate <= IVAS_SID_5k2 ) + test(); + test(); + test(); + IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && EQ_16( nchan_out, 1 ) && EQ_16( st->idchan, 1 ) && LE_32( last_element_brate, IVAS_SID_5k2 ) ) { /* In MDCT-Stereo DTX with mono output, we can skip CNG for the second channel, except for the first inactive frame following an active period */ return error; } push_wmops( "acelp_core_dec" ); - - output_frame = (int16_t) ( st->output_Fs / FRAMES_PER_SEC ); + tmp = BASOP_Util_Divide3232_Scale( st->output_Fs, FRAMES_PER_SEC, &tmp_e ); + output_frame = shr( tmp, sub( 15, tmp_e ) ); + // output_frame = (int16_t) ( st->output_Fs / FRAMES_PER_SEC ); /*----------------------------------------------------------------* * stereo SID and CNG frames processing *----------------------------------------------------------------*/ - if ( st->core_brate <= SID_2k40 && st->element_mode == IVAS_CPE_DFT && nchan_out == 2 ) + test(); + test(); + IF( LE_32( st->core_brate, SID_2k40 ) && EQ_16( st->element_mode, IVAS_CPE_DFT ) && EQ_16( nchan_out, 2 ) ) { - if ( st->cng_type == FD_CNG ) + IF( EQ_16( st->cng_type, FD_CNG ) ) { configureFdCngDec_fx( st->hFdCngDec, st->bwidth, ACELP_14k25, st->L_frame, st->last_L_frame, st->element_mode ); Word16 old_NoiseEstExp = st->hFdCngDec->hFdCngCom->sidNoiseEstExp; /* Only run parameter decoding in SID frames */ - if ( st->core_brate == SID_2k40 ) + IF( EQ_32( st->core_brate, SID_2k40 ) ) { FdCng_decodeSID_ivas_fx( st ); - rescale_fdCngDec( st->hFdCngDec, old_NoiseEstExp - st->hFdCngDec->hFdCngCom->sidNoiseEstExp ); + rescale_fdCngDec( st->hFdCngDec, sub( old_NoiseEstExp, st->hFdCngDec->hFdCngCom->sidNoiseEstExp ) ); } - for ( i = 0; i < NPART; i++ ) + FOR( i = 0; i < NPART; i++ ) { st->hFdCngDec->hFdCngCom->sidNoiseEstLp[i] = L_add( Mpy_32_32( STEREO_DFT_FD_FILT_Q31, st->hFdCngDec->hFdCngCom->sidNoiseEstLp[i] ), Mpy_32_32( STEREO_DFT_FD_FILT_COMP_Q31, st->hFdCngDec->hFdCngCom->sidNoiseEst[i] ) ); + move32(); } ApplyFdCng_ivas_fx( NULL, 0, NULL, 0, NULL, NULL, NULL, st, 0, 0 ); - if ( st->hFdCngDec->hFdCngCom->cngNoiseLevelExp < 0 ) + IF( LT_16( st->hFdCngDec->hFdCngCom->cngNoiseLevelExp, 0 ) ) { Scale_sig32( st->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN, st->hFdCngDec->hFdCngCom->cngNoiseLevelExp ); st->hFdCngDec->hFdCngCom->cngNoiseLevelExp = 0; + move16(); } } - else + ELSE { configureFdCngDec_fx( st->hFdCngDec, st->bwidth, ACELP_14k25, st->L_frame, st->last_L_frame, st->element_mode ); @@ -216,150 +225,191 @@ ivas_error acelp_core_dec_ivas_fx( *----------------------------------------------------------------*/ /* open CLDFB buffer up to CLDFB_NO_CHANNELS_MAX bands for 48kHz */ - for ( i = 0; i < CLDFB_NO_COL_MAX; i++ ) + FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ ) { set32_fx( realBufferTmp_fx[i], 0, CLDFB_NO_CHANNELS_MAX ); set32_fx( imagBufferTmp_fx[i], 0, CLDFB_NO_CHANNELS_MAX ); realBuffer_fx[i] = realBufferTmp_fx[i]; + move32(); imagBuffer_fx[i] = imagBufferTmp_fx[i]; + move32(); } /*----------------------------------------------------------------* * Initialization *----------------------------------------------------------------*/ LSF_Q_prediction = -1; - + move16(); set_s( syn_tmp_fx, 0, L_SUBFR ); psyn_fx = syn_tmp_fx + L_SUBFR; syn1_tmp_fx[0] = 0; + move16(); syn1_tmp_fx[1] = 0; + move16(); syn1_fx = syn1_tmp_fx + 2; st->bpf_off = 0; - - if ( st->last_core == HQ_CORE || st->last_core == TCX_20_CORE || st->last_core == TCX_10_CORE || ( st->element_mode == IVAS_CPE_DFT && st->last_core_brate <= SID_2k40 ) || ( st->element_mode == IVAS_CPE_MDCT && st->last_core_brate <= SID_2k40 ) ) + move16(); + test(); + test(); + test(); + test(); + IF( EQ_16( st->last_core, HQ_CORE ) || EQ_16( st->last_core, TCX_20_CORE ) || EQ_16( st->last_core, TCX_10_CORE ) || ( EQ_16( st->element_mode, IVAS_CPE_DFT ) && st->last_core_brate <= SID_2k40 ) || ( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && LE_32( st->last_core_brate, SID_2k40 ) ) ) { /* in case of HQ->ACELP switching, do not apply BPF */ st->bpf_off = 1; - + move16(); if ( st->hPFstat != NULL ) { /* in case of core switching, reset post-filter memories */ st->hPFstat->on = 0; + move16(); } if ( st->hGSCDec != NULL ) { /* reset the GSC pre echo energy threshold in case of switching */ st->hGSCDec->Last_frame_ener_fx = MAX_32; + move32(); } } - if ( st->hGSCDec != NULL && st->prev_bfi > 0 ) + IF( st->hGSCDec != NULL && ( st->prev_bfi > 0 ) ) { /* reset the GSC pre echo energy threshold in case of FEC */ st->hGSCDec->Last_frame_ener_fx = MAX_32; + move32(); } - - if ( ( st->element_mode == IVAS_CPE_DFT || st->element_mode == IVAS_CPE_TD ) && ( st->last_core_brate == SID_2k40 || st->last_core_brate == FRAME_NO_DATA ) ) + test(); + test(); + test(); + IF( ( EQ_16( st->element_mode, IVAS_CPE_DFT ) || EQ_16( st->element_mode, IVAS_CPE_TD ) ) && ( EQ_32( st->last_core_brate, SID_2k40 ) || EQ_32( st->last_core_brate, FRAME_NO_DATA ) ) ) { set_s( st->hFdCngDec->hFdCngCom->olapBufferSynth2, 0, FFTLEN ); set_s( hStereoCng->olapBufferSynth22_fx, 0, FFTLEN ); } st->clas_dec = st->last_good; - + move16(); enr_q_fx = 0; + move32(); Es_pred_fx = 0; + move16(); tmp_noise_fx = 0; - + move16(); Copy( st->old_exc_fx, old_exc_fx, L_EXC_MEM_DEC ); exc_fx = old_exc_fx + L_EXC_MEM_DEC; - if ( st->hWIDec != NULL ) + IF( st->hWIDec != NULL ) { Copy( st->hWIDec->old_exc2_fx, old_exc2_fx, L_EXC_MEM ); } - else + ELSE { set_s( old_exc2_fx, 0, L_EXC_MEM ); } exc2_fx = old_exc2_fx + L_EXC_MEM; - if ( st->hBWE_TD != NULL ) + IF( st->hBWE_TD != NULL ) { Copy( st->hBWE_TD->old_bwe_exc_fx, old_bwe_exc_fx, PIT16k_MAX * 2 ); bwe_exc_fx = old_bwe_exc_fx + PIT16k_MAX * 2; } - else + ELSE { bwe_exc_fx = NULL; } last_pulse_pos = 0; + move16(); do_WI = 0; + move16(); st->GSC_noisy_speech = 0; + move16(); st->relax_prev_lsf_interp = 0; + move16(); set_s( gain_buf_fx, 0, NB_SUBFR16k ); - if ( st->L_frame == L_FRAME ) + IF( EQ_16( st->L_frame, L_FRAME ) ) { st->gamma = GAMMA1; + move16(); st->inv_gamma = GAMMA1_INV; + move16(); st->preemph_fac = PREEMPH_FAC; + move16(); int_fs = INT_FS_12k8; + move16(); } - else + ELSE { st->gamma = GAMMA16k; + move16(); st->inv_gamma = GAMMA16k_INV; + move16(); st->preemph_fac = PREEMPH_FAC_16k; + move16(); int_fs = INT_FS_16k; + move16(); } - + test(); /* reset post-filter in case of switching */ - if ( st->hPFstat != NULL && st->hPFstat->on == 0 ) + IF( st->hPFstat != NULL && ( st->hPFstat->on == 0 ) ) { st->hPFstat->reset = 1; + move16(); } avoid_lpc_burst_on_recovery = 0; - if ( st->last_con_tcx && NE_16( st->L_frameTCX_past, st->L_frame ) && st->last_core != 0 ) + move16(); + test(); + test(); + IF( st->last_con_tcx && NE_16( st->L_frameTCX_past, st->L_frame ) && ( st->last_core != 0 ) ) { avoid_lpc_burst_on_recovery = 1; + move16(); } - + test(); /* TD stereo parameters */ - if ( st->element_mode == IVAS_CPE_TD && st->idchan == 1 ) + IF( EQ_16( st->element_mode, IVAS_CPE_TD ) && EQ_16( st->idchan, 1 ) ) { tdm_lp_reuse_flag = hStereoTD->tdm_lp_reuse_flag; + move16(); tdm_low_rate_mode = hStereoTD->tdm_low_rate_mode; + move16(); tdm_Pitch_reuse_flag = hStereoTD->tdm_Pitch_reuse_flag; + move16(); p_tdm_Pri_pitch_buf_fx = hStereoTD->tdm_Pri_pitch_buf_fx; } - else + ELSE { tdm_lp_reuse_flag = 0; + move16(); tdm_low_rate_mode = 0; - if ( st->element_mode == IVAS_SCE && st->low_rate_mode ) + move16(); + test(); + IF( EQ_16( st->element_mode, IVAS_SCE ) && st->low_rate_mode ) { tdm_low_rate_mode = 1; + move16(); } tdm_Pitch_reuse_flag = 0; + move16(); p_tdm_Pri_pitch_buf_fx = NULL; } /*----------------------------------------------------------------* * Updates in case of internal sampling rate switching *----------------------------------------------------------------*/ - - if ( st->last_L_frame != st->L_frame && ( st->last_core == ACELP_CORE || st->last_core == AMR_WB_CORE ) ) + test(); + test(); + IF( NE_16( st->last_L_frame, st->L_frame ) && ( EQ_16( st->last_core, ACELP_CORE ) || EQ_16( st->last_core, AMR_WB_CORE ) ) ) { - int16_t dec; + Word16 dec; - if ( st->hPFstat->on != 0 ) + IF( ( st->hPFstat->on != 0 ) ) { - int16_t mem_syn_r_size_old, mem_syn_r_size_new; + Word16 mem_syn_r_size_old, mem_syn_r_size_new; mem_syn_r_size_old = mult_r( 2048, st->last_L_frame ); mem_syn_r_size_new = mult_r( 2048, st->L_frame ); lerp( st->hPFstat->mem_stp + L_SYN_MEM - mem_syn_r_size_old, st->hPFstat->mem_stp + L_SYN_MEM - mem_syn_r_size_new, mem_syn_r_size_new, mem_syn_r_size_old ); @@ -378,11 +428,11 @@ ivas_error acelp_core_dec_ivas_fx( Copy( st->lsf_old_fx, st->lsf_adaptive_mean_fx, M ); /* Reset LPC mem */ - if ( st->sr_core == INT_FS_16k ) + IF( EQ_32( st->sr_core, INT_FS_16k ) ) { Copy( GEWB2_Ave_fx, st->mem_AR_fx, M ); } - else + ELSE { Copy( GEWB_Ave_fx, st->mem_AR_fx, M ); } @@ -390,9 +440,11 @@ ivas_error acelp_core_dec_ivas_fx( /* update synthesis filter memories */ dec = DEC; - if ( st->element_mode != EVS_MONO ) + move16(); + IF( NE_16( st->element_mode, EVS_MONO ) ) { dec = DEC_IVAS; + move16(); } synth_mem_updt2( st->L_frame, st->last_L_frame, st->old_exc_fx, st->mem_syn_r, st->mem_syn2_fx, NULL, dec ); Copy( st->old_exc_fx, old_exc_fx, L_EXC_MEM_DEC ); @@ -408,14 +460,17 @@ ivas_error acelp_core_dec_ivas_fx( IF( EQ_16( st->last_L_frame, L_FRAME32k ) ) { tmpF_fx = 13107; + move16(); } ELSE IF( EQ_16( st->last_L_frame, 512 ) ) { tmpF_fx = 16384; + move16(); } ELSE /* st->last_L_frame == L_FRAME16k */ { tmpF_fx = 26214; + move16(); } FOR( i = NB_SUBFR16k - NB_SUBFR; i < NB_SUBFR16k; i++ ) @@ -446,8 +501,9 @@ ivas_error acelp_core_dec_ivas_fx( { tmpF_fx = 20480; // Q14 exp = 1; + move16(); } - + move16(); FOR( i = 2 * NB_SUBFR - 1; i >= NB_SUBFR; i-- ) { st->old_pitch_buf_fx[i + 2] = Mpy_32_16_1( L_shl( st->old_pitch_buf_fx[i], exp ), tmpF_fx ); @@ -503,23 +559,27 @@ ivas_error acelp_core_dec_ivas_fx( { tmpF_fx = 20480; // Q14 exp = 1; + move16(); } + move16(); st->bfi_pitch_fx = mult_r( shl_sat( st->bfi_pitch_fx, exp ), tmpF_fx ); st->bfi_pitch_frame = L_FRAME16k; move16(); } } - - if ( st->last_bwidth == NB && st->bwidth != NB && st->ini_frame != 0 ) + test(); + test(); + IF( EQ_16( st->last_bwidth, NB ) && NE_16( st->bwidth, NB ) && ( st->ini_frame != 0 ) ) { st->rate_switching_reset = 1; + move16(); } /*----------------------------------------------------------------------* * GOOD frame *----------------------------------------------------------------------*/ - if ( !st->bfi ) + IF( !st->bfi ) { /*----------------------------------------------------------------* @@ -527,18 +587,24 @@ ivas_error acelp_core_dec_ivas_fx( *----------------------------------------------------------------*/ tc_subfr = -1; - if ( st->coder_type == TRANSITION ) + move16(); + IF( EQ_16( st->coder_type, TRANSITION ) ) { - tc_subfr = tc_classif( st ); + tc_subfr = tc_classif_fx( st, st->L_frame ); } /*----------------------------------------------------------------* * Decoding of GSC IVAS mode *----------------------------------------------------------------*/ - - if ( st->element_mode > EVS_MONO && st->idchan == 0 && !( st->core_brate == FRAME_NO_DATA || st->core_brate == SID_2k40 ) && !tdm_low_rate_mode ) + test(); + test(); + test(); + test(); + IF( GT_16( st->element_mode, EVS_MONO ) && EQ_16( st->idchan, 0 ) && !( EQ_32( st->core_brate, FRAME_NO_DATA ) || EQ_32( st->core_brate, SID_2k40 ) ) && !tdm_low_rate_mode ) { - if ( st->coder_type == AUDIO || ( st->coder_type == INACTIVE && st->total_brate <= MAX_GSC_INACTIVE_BRATE ) ) + test(); + test(); + IF( EQ_16( st->coder_type, AUDIO ) || ( EQ_16( st->coder_type, INACTIVE ) && LE_32( st->total_brate, MAX_GSC_INACTIVE_BRATE ) ) ) { st->GSC_IVAS_mode = get_next_indice( st, 2 ); } @@ -547,48 +613,55 @@ ivas_error acelp_core_dec_ivas_fx( /*----------------------------------------------------------------* * Decoding of inactive CNG frames *----------------------------------------------------------------*/ - - if ( st->core_brate == FRAME_NO_DATA || st->core_brate == SID_2k40 ) + test(); + IF( EQ_32( st->core_brate, FRAME_NO_DATA ) || EQ_32( st->core_brate, SID_2k40 ) ) { /* decode CNG parameters */ - if ( st->cng_type == LP_CNG ) + IF( EQ_16( st->cng_type, LP_CNG ) ) { CNG_dec_fx( st, last_element_mode, Aq_fx, lsp_new_fx, lsf_new_fx, &allow_cn_step, sid_bw, q_env_fx ); - for ( int nsf = 0; nsf < NB_SUBFR16k; nsf++ ) + FOR( Word32 nsf = 0; nsf < NB_SUBFR16k; nsf++ ) { - Scale_sig( Aq_fx + ( nsf * ( M + 1 ) ), M + 1, norm_s( Aq_fx[nsf * ( M + 1 )] ) - Q2 ); - Aq_fx[nsf * ( M + 1 )] = ONE_IN_Q12; + Scale_sig( Aq_fx + ( nsf * ( M + 1 ) ), M + 1, sub( norm_s( Aq_fx[imult3216( nsf, add( M, 1 ) )] ), Q2 ) ); + Aq_fx[imult3216( nsf, M + 1 )] = ONE_IN_Q12; + move16(); } - Copy( Aq_fx, st->Aq_cng, M + 1 ); + Copy( Aq_fx, st->Aq_cng, add( M, 1 ) ); /* comfort noise generation */ local_element_mode = st->element_mode; - if ( ( nchan_out == 1 && st->element_mode == IVAS_CPE_DFT ) || ( st->masa_sid_format == 1 ) ) + move16(); + test(); + test(); + IF( ( EQ_16( nchan_out, 1 ) && EQ_16( st->element_mode, IVAS_CPE_DFT ) ) || EQ_16( st->masa_sid_format, 1 ) ) { local_element_mode = IVAS_SCE; /* For DFT Stereo mono decoding, run CNG_exc as in SCE */ + move16(); } CNG_exc_fx( st->core_brate, st->L_frame, &st->hTdCngDec->Enew_fx, &st->hTdCngDec->cng_seed, exc_fx, exc2_fx, &st->lp_ener_fx, st->last_core_brate, &st->first_CNG, &( st->hTdCngDec->cng_ener_seed ), bwe_exc_fx, allow_cn_step, &st->hTdCngDec->last_allow_cn_step, st->prev_Q_exc, st->Q_exc, st->hTdCngDec->num_ho, q_env_fx, st->hTdCngDec->lp_env_fx, st->hTdCngDec->old_env_fx, st->hTdCngDec->exc_mem_fx, st->hTdCngDec->exc_mem1_fx, sid_bw, &st->hTdCngDec->cng_ener_seed1, exc3_fx, st->Opt_AMR_WB, local_element_mode ); } - else + ELSE { - if ( st->core_brate == SID_2k40 && st->element_mode != IVAS_CPE_MDCT ) + IF( EQ_32( st->core_brate, SID_2k40 ) && NE_16( st->element_mode, IVAS_CPE_MDCT ) ) { Word16 old_NoiseEstExp = st->hFdCngDec->hFdCngCom->sidNoiseEstExp; FdCng_decodeSID_ivas_fx( st ); - rescale_fdCngDec( st->hFdCngDec, old_NoiseEstExp - st->hFdCngDec->hFdCngCom->sidNoiseEstExp ); - Scale_sig( st->hFdCngDec->hFdCngCom->A_cng, M + 1, norm_s( st->hFdCngDec->hFdCngCom->A_cng[0] ) - Q2 ); + rescale_fdCngDec( st->hFdCngDec, sub( old_NoiseEstExp, st->hFdCngDec->hFdCngCom->sidNoiseEstExp ) ); + Scale_sig( st->hFdCngDec->hFdCngCom->A_cng, M + 1, sub( norm_s( st->hFdCngDec->hFdCngCom->A_cng[0] ), Q2 ) ); *sid_bw = 0; + move16(); } - if ( st->element_mode == IVAS_CPE_DFT ) + IF( EQ_16( st->element_mode, IVAS_CPE_DFT ) ) { assert( nchan_out == 1 ); - for ( i = 0; i < NPART; i++ ) + FOR( i = 0; i < NPART; i++ ) { st->hFdCngDec->hFdCngCom->sidNoiseEstLp[i] = L_add( Mpy_32_32( STEREO_DFT_FD_FILT_Q31, st->hFdCngDec->hFdCngCom->sidNoiseEstLp[i] ), Mpy_32_32( STEREO_DFT_FD_FILT_COMP_Q31, st->hFdCngDec->hFdCngCom->sidNoiseEst[i] ) ); + move32(); } Word16 new_sidNoiseEstExp = 31 - Q4; Scale_sig32( st->hFdCngDec->hFdCngCom->sidNoiseEstLp, NPART, st->hFdCngDec->hFdCngCom->sidNoiseEstExp - new_sidNoiseEstExp ); @@ -600,21 +673,23 @@ ivas_error acelp_core_dec_ivas_fx( ApplyFdCng_ivas_fx( psyn_fx, st->Q_syn, NULL, 0, realBuffer_fx, imagBuffer_fx, NULL, st, 0, ( st->coder_type == AUDIO && !st->GSC_noisy_speech ) ); - if ( st->hFdCngDec->hFdCngCom->cngNoiseLevelExp < 0 ) + IF( LT_16( st->hFdCngDec->hFdCngCom->cngNoiseLevelExp, 0 ) ) { Scale_sig32( st->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN, st->hFdCngDec->hFdCngCom->cngNoiseLevelExp ); st->hFdCngDec->hFdCngCom->cngNoiseLevelExp = 0; + move16(); } } - if ( !read_sid_info ) + IF( !read_sid_info ) { Word32 noise_lvl_highest_fx; noise_lvl_highest_fx = st->hFdCngDec->hFdCngCom->cngNoiseLevel[st->hFdCngDec->hFdCngCom->stopFFTbin - st->hFdCngDec->hFdCngCom->startBand - 1]; - for ( int16_t b = st->hFdCngDec->hFdCngCom->stopFFTbin - st->hFdCngDec->hFdCngCom->startBand; b < st->hFdCngDec->hFdCngCom->stopBand; b++ ) + FOR( Word16 b = st->hFdCngDec->hFdCngCom->stopFFTbin - st->hFdCngDec->hFdCngCom->startBand; b < st->hFdCngDec->hFdCngCom->stopBand; b++ ) { st->hFdCngDec->hFdCngCom->cngNoiseLevel[b] = noise_lvl_highest_fx; + move32(); } } @@ -634,6 +709,8 @@ ivas_error acelp_core_dec_ivas_fx( move16(); } i = st->Q_exc; + move16(); + test(); IF( st->hMusicPF && st->hGSCDec ) { Rescale_exc( st->hMusicPF->dct_post_old_exc_fx, exc_fx, bwe_exc_fx, st->hGSCDec->last_exc_dct_in_fx, st->L_frame, @@ -652,26 +729,30 @@ ivas_error acelp_core_dec_ivas_fx( Copy_Scale_sig( exc2_fx, exc2_fx, st->L_frame, sub( st->Q_exc, i ) ); /* update past excitation signals for LD music post-filter */ - if ( st->hMusicPF != NULL ) + IF( st->hMusicPF != NULL ) { Copy( st->hMusicPF->dct_post_old_exc_fx + L_FRAME, st->hMusicPF->dct_post_old_exc_fx, DCT_L_POST - L_FRAME - OFFSET2 ); Copy( exc2_fx, st->hMusicPF->dct_post_old_exc_fx + ( DCT_L_POST - L_FRAME - OFFSET2 ), L_FRAME ); /* Update music post processing values */ /* Filter energies update */ - for ( i = 0; i < DCT_L_POST; i++ ) + FOR( i = 0; i < DCT_L_POST; i++ ) { st->hMusicPF->filt_lfE_fx[i] = add( 9830, mult_r( 22937, st->hMusicPF->filt_lfE_fx[i] ) ); + move16(); } } /* synthesis at 12.8kHz sampling rate */ Aq_fx[0] = ONE_IN_Q12; + move16(); syn_12k8_fx( st->L_frame, Aq_fx, exc2_fx, psyn_fx, st->mem_syn2_fx, 1, st->Q_exc, st->Q_syn ); syn_12k8_fx( st->L_frame, Aq_fx, exc3_fx, syn1_fx, st->mem_syn3_fx, 1, st->Q_exc, st->Q_syn ); st->Q_syn_cng = st->Q_syn; + move16(); st->Q_exc_cng = st->Q_exc; + move16(); /* reset the decoder */ CNG_reset_dec_fx( st, pitch_buf_fx, voice_factors_fx ); @@ -683,7 +764,7 @@ ivas_error acelp_core_dec_ivas_fx( /* save and delay synthesis to be used by SWB BWE */ Copy_Scale_sig( syn1_fx, temp_buf_fx, st->L_frame, sub( -1, st->Q_syn ) ); - if ( st->hBWE_FD != NULL ) + IF( st->hBWE_FD != NULL ) { save_old_syn_fx( st->L_frame, syn1_fx, old_syn_12k8_16k_fx, st->hBWE_FD->old_syn_12k8_16k_fx, st->preemph_fac, &st->hBWE_FD->mem_deemph_old_syn_fx ); } @@ -693,7 +774,7 @@ ivas_error acelp_core_dec_ivas_fx( * Decoding of all other frames *----------------------------------------------------------------*/ - else + ELSE { /*-----------------------------------------------------------------* @@ -701,27 +782,34 @@ ivas_error acelp_core_dec_ivas_fx( *-----------------------------------------------------------------*/ nb_bits = 0; + move16(); st->acelp_cfg.FEC_mode = 0; + move16(); uc_two_stage_flag = 0; - - if ( !st->nelp_mode_dec && !st->ppp_mode_dec ) + move16(); + test(); + IF( !st->nelp_mode_dec && !st->ppp_mode_dec ) { - int16_t tc_subfr_tmp; + Word16 tc_subfr_tmp; tc_subfr_tmp = tc_subfr; - if ( tc_subfr_tmp < L_SUBFR ) + move16(); + if ( LT_16( tc_subfr_tmp, L_SUBFR ) ) { tc_subfr_tmp = 0; + move16(); } - if ( tc_subfr == TC_0_192 ) + if ( EQ_16( tc_subfr, TC_0_192 ) ) { nb_bits = -1; + move16(); } config_acelp1_IVAS( DEC, st->total_brate, st->core_brate, st->core, st->extl_orig, st->extl_brate_orig, st->L_frame, st->GSC_noisy_speech, &( st->acelp_cfg ), st->next_bit_pos, st->coder_type, tc_subfr_tmp, 1, &nb_bits, unbits, st->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st->idchan, st->active_cnt, tdm_Pitch_reuse_flag, st->tdm_LRTD_flag, st->GSC_IVAS_mode ); - - if ( st->coder_type == TRANSITION && tc_subfr < L_SUBFR && st->L_frame == L_FRAME ) + test(); + test(); + IF( EQ_16( st->coder_type, TRANSITION ) && LT_16( tc_subfr, L_SUBFR ) && EQ_16( st->L_frame, L_FRAME ) ) { config_acelp1_IVAS( DEC, st->total_brate, st->core_brate, st->core, st->extl_orig, st->extl_brate_orig, st->L_frame, -1, &( st->acelp_cfg ), st->next_bit_pos, st->coder_type, tc_subfr, 2, &nb_bits, unbits, st->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st->idchan, st->active_cnt, tdm_Pitch_reuse_flag, st->tdm_LRTD_flag, st->GSC_IVAS_mode ); } @@ -730,8 +818,10 @@ ivas_error acelp_core_dec_ivas_fx( /*-----------------------------------------------------------------* * After CNG period, use the most up-to-date LSPs *-----------------------------------------------------------------*/ - - if ( st->hTdCngDec != NULL && ( st->last_core_brate == FRAME_NO_DATA || st->last_core_brate == SID_2k40 ) ) + test(); + test(); + test(); + IF( st->hTdCngDec != NULL && ( EQ_32( st->last_core_brate, FRAME_NO_DATA ) || EQ_32( st->last_core_brate, SID_2k40 ) ) ) { Copy( st->lspCNG_fx, st->lsp_old_fx, M ); lsp2lsf_fx( st->lspCNG_fx, st->lsf_old_fx, M, int_fs ); @@ -741,40 +831,43 @@ ivas_error acelp_core_dec_ivas_fx( * Reset higher ACELP pre-quantizer in case of switching *-----------------------------------------------------------------*/ - if ( !st->use_acelp_preq ) + IF( !st->use_acelp_preq ) { st->mem_preemp_preQ_fx = 0; st->last_nq_preQ = 0; st->last_code_preq = 0; + move16(); + move16(); + move16(); } st->use_acelp_preq = 0; - + move16(); /*-----------------------------------------------------------------* * LSF de-quantization and interpolation *-----------------------------------------------------------------*/ - if ( !tdm_lp_reuse_flag ) + IF( !tdm_lp_reuse_flag ) { lsf_dec_fx( st, tc_subfr, Aq_fx, &LSF_Q_prediction, lsf_new_fx, lsp_new_fx, lsp_mid_fx, tdm_low_rate_mode /*, tdm_lsfQ_PCh*/ ); } - else + ELSE { const Word16 *pt_interp_2_fx; - if ( st->active_cnt != 1 ) + IF( NE_16( st->active_cnt, 1 ) ) { - int16_t beta_index; + Word16 beta_index; beta_index = get_next_indice( st, TDM_IC_LSF_PRED_BITS ); tdm_SCh_lsf_reuse_fx( DEC, st->element_brate, lsf_new_fx, lsp_new_fx, tdm_lsfQ_PCh_fx, NULL, &beta_index ); } - else + ELSE { Copy( tdm_lspQ_PCh_fx, lsp_new_fx, M ); Copy( tdm_lsfQ_PCh_fx, lsf_new_fx, M ); } - if ( st->rate_switching_reset ) + IF( st->rate_switching_reset ) { /* extrapolation in case of unstable LSF convert */ Copy( lsp_new_fx, st->lsp_old_fx, M ); @@ -782,12 +875,15 @@ ivas_error acelp_core_dec_ivas_fx( } pt_interp_2_fx = interpol_frac_fx; - if ( tdm_low_rate_mode == 1 && st->coder_type > UNVOICED ) + move16(); + test(); + IF( EQ_16( tdm_low_rate_mode, 1 ) && GT_16( st->coder_type, UNVOICED ) ) { pt_interp_2_fx = interpol_frac2_fx; + move16(); } - if ( st->active_cnt == 1 ) + IF( EQ_16( st->active_cnt, 1 ) ) { Copy( lsp_new_fx, st->lsp_old_fx, M ); lsp2lsf_fx( lsp_new_fx, st->lsf_old_fx, M, st->sr_core ); @@ -802,13 +898,15 @@ ivas_error acelp_core_dec_ivas_fx( for ( int nsf = 0; nsf < NB_SUBFR16k; nsf++ ) { #else - FOR( int nsf = 0; nsf < st->nb_subfr; nsf++ ) + FOR( Word32 nsf = 0; nsf < st->nb_subfr; nsf++ ) #endif { - Scale_sig( Aq_fx + ( nsf * ( M + 1 ) ), M + 1, norm_s( Aq_fx[nsf * ( M + 1 )] ) - Q2 ); - Aq_fx[nsf * ( M + 1 )] = ONE_IN_Q12; + Scale_sig( Aq_fx + ( nsf * ( M + 1 ) ), M + 1, sub( norm_s( Aq_fx[imult3216( nsf, add( M, 1 ) )] ), Q2 ) ); + Aq_fx[imult3216( nsf, add( M, 1 ) )] = ONE_IN_Q12; + move16(); } - if ( st->last_core == HQ_CORE && st->element_mode > EVS_MONO ) + test(); + IF( EQ_16( st->last_core, HQ_CORE ) && GT_16( st->element_mode, EVS_MONO ) ) { /* Prepare ACB memory from last HQ frame */ old_exc_s_fx = st->old_exc_fx + L_EXC_MEM_DEC - st->L_frame; @@ -821,17 +919,17 @@ ivas_error acelp_core_dec_ivas_fx( Scale_sig( old_exc_fx + L_EXC_MEM_DEC - st->L_frame, st->L_frame, st->Q_exc ); #endif } - - if ( st->last_core != ACELP_CORE && st->element_mode > EVS_MONO ) + test(); + IF( NE_16( st->last_core, ACELP_CORE ) && GT_16( st->element_mode, EVS_MONO ) ) { /* Prepare ACB memory of old_bwe_exc */ - if ( st->L_frame == L_FRAME ) + IF( EQ_16( st->L_frame, L_FRAME ) ) { lerp( old_exc_fx, old_bwe_exc_fx, L_EXC_MEM_DEC * HIBND_ACB_L_FAC, L_EXC_MEM_DEC ); } - else + ELSE { - lerp( old_exc_fx, old_bwe_exc_fx, L_EXC_MEM_DEC * 2, L_EXC_MEM_DEC ); + lerp( old_exc_fx, old_bwe_exc_fx, shl( L_EXC_MEM_DEC, 1 ), L_EXC_MEM_DEC ); } } @@ -839,20 +937,27 @@ ivas_error acelp_core_dec_ivas_fx( * FEC - first good frame after lost frame(s) (possibility to correct the ACB) *-----------------------------------------------------------------*/ - if ( st->acelp_cfg.FEC_mode > 0 ) + IF( st->acelp_cfg.FEC_mode > 0 ) { last_pulse_pos = 0; - + move16(); /* decode the last glottal pulse position */ T0_tmp = FEC_pos_dec_fx( st, &last_pulse_pos, &enr_q_fx, nb_bits ); - - if ( st->last_core != HQ_CORE || ( st->last_core == HQ_CORE && st->last_con_tcx ) ) + test(); + test(); + IF( NE_16( st->last_core, HQ_CORE ) || ( EQ_16( st->last_core, HQ_CORE ) && st->last_con_tcx ) ) { - if ( st->clas_dec == SIN_ONSET && last_pulse_pos != 0 && st->prev_bfi == 1 ) + test(); + test(); + test(); + test(); + test(); + test(); + IF( EQ_16( st->clas_dec, SIN_ONSET ) && NE_16( last_pulse_pos, 0 ) && EQ_16( st->prev_bfi, 1 ) ) { FEC_SinOnset_fx( old_exc_fx + L_EXC_MEM_DEC - L_EXC_MEM, last_pulse_pos, T0_tmp, enr_q_fx, Aq_fx, st->L_frame, st->Q_exc ); } - else if ( ( st->coder_type == GENERIC || st->coder_type == VOICED ) && last_pulse_pos != 0 && st->old_bfi_cnt == 1 && st->hWIDec != NULL ) + ELSE IF( ( EQ_16( st->coder_type, GENERIC ) || EQ_16( st->coder_type, VOICED ) ) && NE_16( last_pulse_pos, 0 ) && EQ_16( st->old_bfi_cnt, 1 ) && st->hWIDec != NULL ) { do_WI = FEC_enhACB_fx( st->L_frame, st->last_L_frame, old_exc_fx + L_EXC_MEM_DEC - L_EXC_MEM, T0_tmp, last_pulse_pos, st->bfi_pitch_fx ); } @@ -863,8 +968,13 @@ ivas_error acelp_core_dec_ivas_fx( * In case of first frame after an erasure and transition from voiced to unvoiced or inactive * redo the LPC interpolation *------------------------------------------------------------*/ - - if ( st->stab_fac_fx == 0 && st->old_bfi_cnt > 0 && st->clas_dec != VOICED_CLAS && st->clas_dec != ONSET && st->relax_prev_lsf_interp == 0 && !( st->element_mode == IVAS_CPE_TD && st->idchan == 1 ) ) + test(); + test(); + test(); + test(); + test(); + test(); + IF( ( st->stab_fac_fx == 0 ) && ( st->old_bfi_cnt > 0 ) && NE_16( st->clas_dec, VOICED_CLAS ) && NE_16( st->clas_dec, ONSET ) && ( st->relax_prev_lsf_interp == 0 ) && !( EQ_16( st->element_mode, IVAS_CPE_TD ) && EQ_16( st->idchan, 1 ) ) ) { int_lsp4_fx( st->L_frame, st->lsp_old_fx, lsp_mid_fx, lsp_new_fx, Aq_fx, M, 2 ); } @@ -873,7 +983,7 @@ ivas_error acelp_core_dec_ivas_fx( * Decoding of the scaled predicted innovation energy *---------------------------------------------------------------*/ - if ( nb_bits > 0 ) + IF( GT_16( nb_bits, 0 ) ) { indice = get_next_indice( st, nb_bits ); Es_pred_dec_fx( &Es_pred_fx, indice, nb_bits, uc_two_stage_flag ); @@ -882,25 +992,26 @@ ivas_error acelp_core_dec_ivas_fx( /*------------------------------------------------------------* * Decode excitation according to coding type *------------------------------------------------------------*/ - - if ( tdm_low_rate_mode ) /* tdm stereo low rate mode */ + test(); + test(); + IF( tdm_low_rate_mode ) /* tdm stereo low rate mode */ { - if ( st->coder_type <= UNVOICED ) + IF( LE_16( st->coder_type, UNVOICED ) ) { tdm_low_rate_dec_fx( st, dct_exc_tmp_fx /*, &tmp_noise*/, pitch_buf_fx, voice_factors_fx, exc_fx, exc2_fx, bwe_exc_fx, lsf_new_fx ); tmp_noise_fx = shr_r( st->lp_gainc_fx, 3 ); /*Q0*/ } - else /* GENERIC */ + ELSE /* GENERIC */ { decod_gen_2sbfr_ivas_fx( st, sharpFlag, Aq_fx, pitch_buf_fx, voice_factors_fx, exc_fx, exc2_fx, bwe_exc_fx, gain_buf_fx, tdm_Pitch_reuse_flag, p_tdm_Pri_pitch_buf_fx ); - if ( st->element_mode == IVAS_CPE_TD ) + IF( EQ_16( st->element_mode, IVAS_CPE_TD ) ) { tmp_noise_fx = shr_r( st->lp_gainc_fx, 3 ); /*Q0*/ } } } - else if ( st->nelp_mode_dec ) + ELSE IF( st->nelp_mode_dec ) { /* SC-VBR - NELP frames */ Scale_sig( exc_fx - L_EXC_MEM, L_EXC_MEM, -st->Q_exc ); @@ -910,29 +1021,30 @@ ivas_error acelp_core_dec_ivas_fx( decod_nelp_fx( st, &tmp_noise_fx, pitch_buf_fx, exc_fx, exc2_fx, voice_factors_fx, bwe_exc_fx, &st->Q_exc, st->bfi, gain_buf_fx ); Rescale_exc( st->hMusicPF->dct_post_old_exc_fx, exc_fx, NULL, st->hGSCDec->last_exc_dct_in_fx, L_FRAME, 0, (Word32) 0, &( st->Q_exc ), st->Q_subfr, exc2_fx, L_FRAME, st->coder_type ); } - else if ( st->coder_type == UNVOICED ) + ELSE IF( EQ_16( st->coder_type, UNVOICED ) ) { /* UNVOICED frames */ decod_unvoiced_ivas_fx( st, Aq_fx, Es_pred_fx, uc_two_stage_flag, st->coder_type, &tmp_noise_fx, pitch_buf_fx, voice_factors_fx, exc_fx, exc2_fx, bwe_exc_fx, gain_buf_fx ); tmp_noise_fx = shr_r( st->lp_gainc_fx, 3 ); /*Q0*/ } - else if ( st->ppp_mode_dec ) + ELSE IF( st->ppp_mode_dec ) { Scale_sig( exc_fx - L_EXC_MEM, L_EXC_MEM, -st->Q_exc ); st->Q_exc = 0; + move16(); /* SC-VBR - PPP frames */ - if ( ( error = decod_ppp_fx( st, Aq_fx, pitch_buf_fx, exc_fx, exc2_fx, st->bfi, gain_buf_fx, voice_factors_fx, bwe_exc_fx ) ) != IVAS_ERR_OK ) + IF( ( error = decod_ppp_fx( st, Aq_fx, pitch_buf_fx, exc_fx, exc2_fx, st->bfi, gain_buf_fx, voice_factors_fx, bwe_exc_fx ) ) != IVAS_ERR_OK ) { return error; } Rescale_exc( st->hMusicPF->dct_post_old_exc_fx, exc_fx, NULL, st->hGSCDec->last_exc_dct_in_fx, L_FRAME, 0, (Word32) 0, &( st->Q_exc ), st->Q_subfr, exc2_fx, L_FRAME, st->coder_type ); } - else if ( st->coder_type == TRANSITION ) + ELSE IF( EQ_16( st->coder_type, TRANSITION ) ) { decod_tran_fx( st, st->L_frame, tc_subfr, Aq_fx, Es_pred_fx, pitch_buf_fx, voice_factors_fx, exc_fx, exc2_fx, bwe_exc_fx, unbits, sharpFlag, gain_buf_fx ); } - else if ( st->coder_type == AUDIO || ( st->coder_type == INACTIVE && st->inactive_coder_type_flag ) ) + ELSE IF( EQ_16( st->coder_type, AUDIO ) || ( EQ_16( st->coder_type, INACTIVE ) && st->inactive_coder_type_flag ) ) { /* AUDIO and INACTIVE frames (coded by GSC technology) */ decod_audio_ivas_fx( st, dct_exc_tmp_fx, Aq_fx, pitch_buf_fx, voice_factors_fx, exc_fx, exc2_fx, bwe_exc_fx, lsf_new_fx, gain_buf_fx @@ -943,15 +1055,15 @@ ivas_error acelp_core_dec_ivas_fx( ); tmp_noise_fx = shr_r( st->lp_gainc_fx, 3 ); /*Q0*/ } - else + ELSE { /* GENERIC, VOICED and INACTIVE frames (coded by AVQ technology) */ - if ( ( error = decod_gen_voic_ivas_fx( st, st->L_frame, sharpFlag, Aq_fx, Es_pred_fx, do_WI, pitch_buf_fx, voice_factors_fx, exc_fx, exc2_fx, bwe_exc_fx, unbits, gain_buf_fx, tdm_Pitch_reuse_flag, p_tdm_Pri_pitch_buf_fx ) ) != IVAS_ERR_OK ) + IF( ( error = decod_gen_voic_ivas_fx( st, st->L_frame, sharpFlag, Aq_fx, Es_pred_fx, do_WI, pitch_buf_fx, voice_factors_fx, exc_fx, exc2_fx, bwe_exc_fx, unbits, gain_buf_fx, tdm_Pitch_reuse_flag, p_tdm_Pri_pitch_buf_fx ) ) != IVAS_ERR_OK ) { return error; } - if ( st->element_mode == IVAS_CPE_TD ) + IF( EQ_16( st->element_mode, IVAS_CPE_TD ) ) { tmp_noise_fx = shr_r( st->lp_gainc_fx, 3 ); /*Q0*/ } @@ -961,7 +1073,7 @@ ivas_error acelp_core_dec_ivas_fx( syn_12k8_fx( st->L_frame, Aq_fx, exc_fx, temp_buf_fx, st->mem_syn1_fx, 1, st->Q_exc, -1 ); /* save and delay synthesis to be used by SWB BWE */ - if ( st->hBWE_FD != NULL ) + IF( st->hBWE_FD != NULL ) { save_old_syn_fx( st->L_frame, temp_buf_fx, old_syn_12k8_16k_fx, st->hBWE_FD->old_syn_12k8_16k_fx, st->preemph_fac, &st->hBWE_FD->mem_deemph_old_syn_fx ); } @@ -975,8 +1087,11 @@ ivas_error acelp_core_dec_ivas_fx( /*------------------------------------------------------------* * Decode information and modify the excitation signal of stationary unvoiced frames *------------------------------------------------------------*/ - - if ( !( st->idchan == 1 && st->element_mode == IVAS_CPE_TD ) && st->nelp_mode_dec != 1 && !( st->element_mode == IVAS_SCE && tdm_low_rate_mode ) ) + test(); + test(); + test(); + test(); + IF( !( EQ_16( st->idchan, 1 ) && EQ_16( st->element_mode, IVAS_CPE_TD ) ) && NE_16( st->nelp_mode_dec, 1 ) && !( EQ_16( st->element_mode, IVAS_SCE ) && tdm_low_rate_mode ) ) { stat_noise_uv_dec_fx( st, lsp_new_fx, lsp_mid_fx, Aq_fx, exc2_fx, uc_two_stage_flag ); } @@ -987,23 +1102,31 @@ ivas_error acelp_core_dec_ivas_fx( *------------------------------------------------------------*/ /* update past excitation signals for LD music post-filter */ - if ( st->hMusicPF != NULL ) + IF( st->hMusicPF != NULL ) { - Copy( st->hMusicPF->dct_post_old_exc_fx + L_FRAME, st->hMusicPF->dct_post_old_exc_fx, DCT_L_POST - L_FRAME - OFFSET2 ); + Copy( st->hMusicPF->dct_post_old_exc_fx + L_FRAME, st->hMusicPF->dct_post_old_exc_fx, sub( sub( DCT_L_POST, L_FRAME ), OFFSET2 ) ); Copy( exc2_fx, st->hMusicPF->dct_post_old_exc_fx + ( DCT_L_POST - L_FRAME - OFFSET2 ), L_FRAME ); - Copy( st->hMusicPF->dct_post_old_exc_fx, exc_buffer_fx, DCT_L_POST - OFFSET2 ); + Copy( st->hMusicPF->dct_post_old_exc_fx, exc_buffer_fx, sub( DCT_L_POST, OFFSET2 ) ); } + test(); + test(); + test(); - if ( ( st->coder_type == AUDIO && !st->GSC_noisy_speech ) || ( st->GSC_IVAS_mode >= 1 && st->L_frame == L_FRAME ) ) + IF( ( EQ_16( st->coder_type, AUDIO ) && !st->GSC_noisy_speech ) || ( GE_16( st->GSC_IVAS_mode, 1 ) && EQ_16( st->L_frame, L_FRAME ) ) ) { - int16_t last_coder_type = st->last_coder_type; - - if ( ( st->idchan == 1 && st->element_mode == IVAS_CPE_TD ) || ( st->GSC_IVAS_mode >= 1 && st->GSC_noisy_speech == 0 ) ) + Word16 last_coder_type = st->last_coder_type; + move16(); + test(); + test(); + test(); + IF( ( EQ_16( st->idchan, 1 ) && EQ_16( st->element_mode, IVAS_CPE_TD ) ) || ( GE_16( st->GSC_IVAS_mode, 1 ) && ( st->GSC_noisy_speech == 0 ) ) ) { last_coder_type = AUDIO; + move16(); } Word16 qdct = 0; + move16(); /* Extrapolation of the last future part, windowing and high resolution DCT transform */ Prep_music_postP_fx( exc_buffer_fx, dct_buffer_fx, st->hMusicPF->filt_lfE_fx, st->last_core, st->element_mode, pitch_buf_fx, st->hMusicPF->LDm_enh_lp_gbin_fx, st->Q_exc, &qdct ); @@ -1016,7 +1139,7 @@ ivas_error acelp_core_dec_ivas_fx( &st->Q_syn, st->mem_syn_clas_estim_fx, 0, &st->mem_deemph_fx, st->hBPF->pst_old_syn_fx, &st->hBPF->pst_mem_deemp_err_fx, &st->agc_mem_fx[1], st->hPFstat, temp_buf_fx, mem_tmp_fx ); } - else + ELSE { /* Core synthesis at 12.8kHz or 16kHz */ i = 1; @@ -1031,7 +1154,7 @@ ivas_error acelp_core_dec_ivas_fx( move16(); test(); test(); - if ( EQ_16( st->coder_type, INACTIVE ) && st->flag_cna && GE_16( round_fx( L_shl( st->lp_noise, 1 ) ), 15 << 7 ) ) + IF( EQ_16( st->coder_type, INACTIVE ) && st->flag_cna && GE_16( round_fx( L_shl( st->lp_noise, 1 ) ), 15 << 7 ) ) { k = 1; move16(); @@ -1043,9 +1166,9 @@ ivas_error acelp_core_dec_ivas_fx( Copy( st->mem_syn2_fx, mem_tmp_fx, M ); syn_12k8_fx( st->L_frame, Aq_fx, exc2_fx, psyn_fx, st->mem_syn2_fx, 1, st->Q_exc, st->Q_syn ); - if ( st->hMusicPF != NULL ) + IF( st->hMusicPF != NULL ) { - for ( i = 0; i < DCT_L_POST; i++ ) + FOR( i = 0; i < DCT_L_POST; i++ ) { st->hMusicPF->filt_lfE_fx[i] = round_fx( L_mac( ( 1228 << ( 16 ) ), 22938, st->hMusicPF->filt_lfE_fx[i] ) ); } @@ -1078,9 +1201,11 @@ ivas_error acelp_core_dec_ivas_fx( FEC_scale_syn_fx( st->L_frame, &update_flg, st->clas_dec, st->last_good, psyn_fx, pitch_buf_tmp, st->enr_old_fx, enr_q_fx, st->coder_type, LSF_Q_prediction, &st->scaling_flag, &st->lp_ener_FEC_av, &st->lp_ener_FEC_max, st->bfi, st->total_brate, st->prev_bfi, st->last_core_brate, exc_fx, exc2_fx, Aq_fx, &st->old_enr_LP, mem_tmp_fx, st->mem_syn2_fx, st->Q_exc, st->Q_syn, avoid_lpc_burst_on_recovery, 0 ); - + test(); + test(); + test(); /* estimate the pitch-synchronous speech energy per sample to be used when normal operation recovers */ - if ( ( st->idchan == 1 && st->element_mode == IVAS_CPE_TD && st->total_brate <= ACELP_7k20 ) || ( st->total_brate == ACELP_7k20 ) || ( st->total_brate == ACELP_8k00 ) ) + IF( ( EQ_16( st->idchan, 1 ) && EQ_16( st->element_mode, IVAS_CPE_TD ) && LE_32( st->total_brate, ACELP_7k20 ) ) || EQ_32( st->total_brate, ACELP_7k20 ) || EQ_32( st->total_brate, ACELP_8k00 ) ) { frame_ener_fx( st->L_frame, st->clas_dec, psyn_fx, pitch_buf_tmp[sub( shr( st->L_frame, 6 ), 1 )], &st->enr_old_fx, st->L_frame, st->Q_syn, 3, 0 ); } @@ -1092,15 +1217,17 @@ ivas_error acelp_core_dec_ivas_fx( * BAD frame *----------------------------------------------------------------*/ - else + ELSE { /* SC-VBR */ - IF( EQ_16( st->last_nelp_mode_dec, 1 ) ) + if ( EQ_16( st->last_nelp_mode_dec, 1 ) ) { st->nelp_mode_dec = 1; move16(); } - + test(); + test(); + test(); /* long burst frame erasures */ IF( GT_16( st->nbLostCmpt, 5 ) && GE_16( st->clas_dec, VOICED_CLAS ) && LT_16( st->clas_dec, INACTIVE_CLAS ) ) { @@ -1116,13 +1243,14 @@ ivas_error acelp_core_dec_ivas_fx( for ( int nsf = 0; nsf < NB_SUBFR16k; nsf++ ) { #else - FOR( int nsf = 0; nsf < st->nb_subfr; nsf++ ) + FOR( Word32 nsf = 0; nsf < st->nb_subfr; nsf++ ) { #endif - Scale_sig( Aq_fx + ( nsf * ( M + 1 ) ), M + 1, norm_s( Aq_fx[nsf * ( M + 1 )] ) - Q2 ); - Aq_fx[nsf * ( M + 1 )] = ONE_IN_Q12; + Scale_sig( Aq_fx + ( nsf * ( M + 1 ) ), M + 1, sub( norm_s( Aq_fx[imult3216( nsf, add( M, 1 ) )] ), Q2 ) ); + Aq_fx[imult3216( nsf, add( M, 1 ) )] = ONE_IN_Q12; + move16(); } - if ( st->nelp_mode_dec == 1 ) + IF( EQ_16( st->nelp_mode_dec, 1 ) ) { /* SC-VBR */ Scale_sig( exc_fx - L_EXC_MEM, L_EXC_MEM, -st->Q_exc ); @@ -1131,10 +1259,10 @@ ivas_error acelp_core_dec_ivas_fx( decod_nelp_fx( st, &tmp_noise_fx, pitch_buf_fx, exc_fx, exc2_fx, voice_factors_fx, bwe_exc_fx, &st->Q_exc, st->bfi, gain_buf_fx ); FEC_pitch_fx = pitch_buf_fx[3]; - + move16(); Rescale_exc( st->hMusicPF->dct_post_old_exc_fx, exc_fx, NULL, st->hGSCDec->last_exc_dct_in_fx, L_FRAME, 0, (Word32) 0, &( st->Q_exc ), st->Q_subfr, exc2_fx, L_FRAME, st->coder_type ); } - else + ELSE { /* calculation of excitation signal */ FEC_exc_estim_fx( st, st->L_frame, exc_fx, exc2_fx, dct_exc_tmp_fx, pitch_buf_fx, voice_factors_fx, &FEC_pitch_fx, bwe_exc_fx, lsf_new_fx, &st->Q_exc, &tmp_noise_fx ); @@ -1146,13 +1274,14 @@ ivas_error acelp_core_dec_ivas_fx( /* SC-VBR */ st->prev_gain_pit_dec_fx = st->lp_gainp_fx; + move16(); } /* synthesis for ACELP core switching and SWB BWE */ syn_12k8_fx( st->L_frame, Aq_fx, exc_fx, temp_buf_fx, st->mem_syn1_fx, 1, st->Q_exc, -1 ); /* save and delay synthesis to be used by SWB BWE */ - if ( st->hBWE_FD != NULL ) + IF( st->hBWE_FD != NULL ) { save_old_syn_fx( st->L_frame, temp_buf_fx, old_syn_12k8_16k_fx, st->hBWE_FD->old_syn_12k8_16k_fx, st->preemph_fac, &st->hBWE_FD->mem_deemph_old_syn_fx ); } @@ -1161,21 +1290,23 @@ ivas_error acelp_core_dec_ivas_fx( Inac_switch_ematch_ivas_fx( exc2_fx, dct_exc_tmp_fx, st->hGSCDec->lt_ener_per_band_fx, st->coder_type, st->L_frame, st->total_brate, st->Q_exc, st->bfi, st->last_core, st->last_codec_mode, tdm_low_rate_mode, st->element_mode ); /* update past excitation signals for LD music post-filter */ - if ( st->hMusicPF != NULL ) + IF( st->hMusicPF != NULL ) { Copy( st->hMusicPF->dct_post_old_exc_fx + L_FRAME, st->hMusicPF->dct_post_old_exc_fx, DCT_L_POST - L_FRAME - OFFSET2 ); Copy( exc2_fx, st->hMusicPF->dct_post_old_exc_fx + ( DCT_L_POST - L_FRAME - OFFSET2 ), L_FRAME ); /* Update music post processing values */ /* Filter energies update */ - for ( i = 0; i < DCT_L_POST; i++ ) + FOR( i = 0; i < DCT_L_POST; i++ ) { - st->hMusicPF->filt_lfE_fx[i] = round_fx( L_mac( ( 1228 << ( 16 ) ), 22938, st->hMusicPF->filt_lfE_fx[i] ) ); + st->hMusicPF->filt_lfE_fx[i] = round_fx( L_mac( L_shl( 1228, ( 16 ) ), 22938, st->hMusicPF->filt_lfE_fx[i] ) ); + move16(); } /* Update circular buffer, keep last energy difference unchanged */ - for ( i = 1; i < MAX_LT; i++ ) + FOR( i = 1; i < MAX_LT; i++ ) { st->hMusicPF->LDm_lt_diff_etot_fx[i - 1] = st->hMusicPF->LDm_lt_diff_etot_fx[i]; + move16(); } } @@ -1185,7 +1316,7 @@ ivas_error acelp_core_dec_ivas_fx( move16(); test(); test(); - if ( EQ_16( st->coder_type, INACTIVE ) && st->flag_cna && GE_16( round_fx( L_shl( st->lp_noise, 1 ) ), 15 << 7 ) ) + IF( EQ_16( st->coder_type, INACTIVE ) && st->flag_cna && GE_16( round_fx( L_shl( st->lp_noise, 1 ) ), 15 << 7 ) ) { k = 1; move16(); @@ -1193,30 +1324,31 @@ ivas_error acelp_core_dec_ivas_fx( Rescale_mem( st->Q_exc, &st->prev_Q_syn, &st->Q_syn, st->mem_syn2_fx, st->mem_syn_clas_estim_fx, 4, &st->mem_deemph_fx, st->hBPF->pst_old_syn_fx, &st->hBPF->pst_mem_deemp_err_fx, &st->agc_mem_fx[1], st->hPFstat, 1, k, temp_buf_fx ); - - if ( ( st->total_brate == ACELP_7k20 ) || ( st->total_brate == ACELP_8k00 ) ) + test(); + IF( ( st->total_brate == ACELP_7k20 ) || ( st->total_brate == ACELP_8k00 ) ) { Copy( st->mem_syn2_fx, mem_tmp_fx, M ); } syn_12k8_fx( st->L_frame, Aq_fx, exc2_fx, psyn_fx, st->mem_syn2_fx, 1, st->Q_exc, st->Q_syn ); /* update buffer for classifier */ - if ( st->hWIDec != NULL ) + IF( st->hWIDec != NULL ) { Copy( exc2_fx + st->L_frame - L_EXC_MEM, st->hWIDec->old_exc2_fx, L_EXC_MEM ); Copy( psyn_fx + st->L_frame - L_EXC_MEM, st->hWIDec->old_syn2_fx, L_EXC_MEM ); } st->prev_Q_exc_fr = st->Q_exc; st->prev_Q_syn_fr = st->Q_syn; - + move16(); + move16(); Copy( psyn_fx + st->L_frame - L_SYN_MEM_CLAS_ESTIM, st->mem_syn_clas_estim_fx, L_SYN_MEM_CLAS_ESTIM ); /*------------------------------------------------------------* * FEC - Smooth the speech energy evolution when recovering after a BAD frame * (smoothing is performed in the excitation domain and signal is resynthesized after) *------------------------------------------------------------*/ - - if ( ( st->total_brate == ACELP_7k20 ) || ( st->total_brate == ACELP_8k00 ) ) + test(); + IF( EQ_32( st->total_brate, ACELP_7k20 ) || EQ_32( st->total_brate, ACELP_8k00 ) ) { Copy_Scale_sig( pitch_buf_fx, pitch_buf_tmp, NB_SUBFR16k, -Q6 ); @@ -1228,7 +1360,7 @@ ivas_error acelp_core_dec_ivas_fx( /* estimate the pitch-synchronous speech energy per sample to be used when normal operation recovers */ frame_ener_fx( st->L_frame, st->last_good, psyn_fx, shr( add( FEC_pitch_fx, 32 ), 6 ), &st->enr_old_fx, st->L_frame, st->Q_syn, 3, 0 ); - if ( st->nelp_mode_dec != 1 ) + IF( NE_16( st->nelp_mode_dec, 1 ) ) { /* modify the excitation signal of stationary unvoiced frames */ stat_noise_uv_mod_fx( st->coder_type, 0, st->lsp_old_fx, lsp_new_fx, lsp_new_fx, Aq_fx, exc2_fx, st->Q_exc, 1, &st->ge_sm_fx, @@ -1265,10 +1397,11 @@ ivas_error acelp_core_dec_ivas_fx( ELSE { st->hPFstat->on = 0; + move16(); nb_post_filt_fx( st->L_frame, st->hPFstat, &st->psf_lp_noise_fx, tmp_noise_fx, psyn_fx, Aq_fx, pitch_buf_tmp, AUDIO, st->BER_detect, 0 ); } } - else + ELSE { st->psf_lp_noise_fx = round_fx( L_shl( st->lp_noise, 1 ) ); } @@ -1284,7 +1417,7 @@ ivas_error acelp_core_dec_ivas_fx( Copy( syn_fx_tmp2, psyn_fx, st->L_frame ); IF( st->hTcxDec != NULL ) { - Copy_Scale_sig( psyn_fx + st->L_frame / 2, st->hTcxDec->old_syn_Overl, st->L_frame / 2, sub( -1, st->Q_syn ) ); /*Q-1*/ + Copy_Scale_sig( psyn_fx + st->L_frame / 2, st->hTcxDec->old_syn_Overl, shr( st->L_frame, 1 ), sub( -1, st->Q_syn ) ); /*Q-1*/ } Copy_Scale_sig( psyn_fx + st->L_frame - M - 1, st->syn, M + 1, sub( 0, st->Q_syn ) ); /*Q0*/ @@ -1295,10 +1428,11 @@ ivas_error acelp_core_dec_ivas_fx( test(); test(); test(); - + test(); IF( st->hPFstat != NULL && GE_16( st->last_bwidth, WB ) && ( GT_32( st->core_brate, ACELP_24k40 ) || GT_16( st->element_mode, EVS_MONO ) ) && LE_32( st->core_brate, ACELP_32k ) ) { st->hPFstat->on = 1; + move16(); /*----ftf conversions---*/ Copy( psyn_fx, temp_buf_fx + L_SYN_MEM, L_FRAME16k ); @@ -1317,30 +1451,39 @@ ivas_error acelp_core_dec_ivas_fx( Residu3_fx( Aq_fx, temp_buf_fx + M, temp_buf_fx + M + L_SUBFR, L_SUBFR, 1 ); E_UTIL_synthesis( 1, Aq_fx, temp_buf_fx + M + L_SUBFR, temp_buf_fx, L_SUBFR, st->hPFstat->mem_stp + L_SYN_MEM - M, 0, M ); scale_st_fx( psyn_fx, temp_buf_fx, &st->hPFstat->gain_prec, L_SUBFR ); - Copy( temp_buf_fx, psyn_fx, L_SUBFR / 2 ); + Copy( temp_buf_fx, psyn_fx, ( L_SUBFR >> 1 ) ); blend_subfr2_fx( temp_buf_fx + L_SUBFR / 2, psyn_fx + L_SUBFR / 2, psyn_fx + L_SUBFR / 2 ); } st->hPFstat->on = 0; + move16(); } /*----------------------------------------------------------------* * Comfort noise addition *----------------------------------------------------------------*/ - - if ( ( st->hFdCngDec != NULL || st->idchan == 1 ) && st->element_mode != IVAS_CPE_MDCT ) + test(); + test(); + IF( ( st->hFdCngDec != NULL || EQ_16( st->idchan, 1 ) ) && NE_16( st->element_mode, IVAS_CPE_MDCT ) ) { - if ( st->element_mode == IVAS_CPE_TD || st->flag_cna || ( st->cng_type == FD_CNG && st->total_brate <= ACELP_32k ) || ( st->cng_type == LP_CNG && st->core_brate <= SID_2k40 ) ) + test(); + test(); + test(); + test(); + IF( EQ_16( st->element_mode, IVAS_CPE_TD ) || st->flag_cna || ( EQ_16( st->cng_type, FD_CNG ) && LE_32( st->total_brate, ACELP_32k ) ) || ( EQ_16( st->cng_type, LP_CNG ) && LE_32( st->core_brate, SID_2k40 ) ) ) { /*VAD only for non inactive frame*/ - st->VAD = st->VAD && ( st->coder_type != INACTIVE ); - - if ( st->idchan == 0 && ( st->flag_cna || ( st->cng_type == FD_CNG && st->total_brate <= ACELP_32k ) || ( st->cng_type == LP_CNG && st->core_brate <= SID_2k40 ) ) ) + st->VAD = st->VAD && NE_16( st->coder_type, INACTIVE ); + test(); + test(); + test(); + test(); + IF( EQ_16( st->idchan, 0 ) && ( st->flag_cna || ( EQ_16( st->cng_type, FD_CNG ) && LE_32( st->total_brate, ACELP_32k ) ) || ( EQ_16( st->cng_type, LP_CNG ) && LE_32( st->core_brate, SID_2k40 ) ) ) ) { /*Noisy speech detector*/ noisy_speech_detection_fx( st->hFdCngDec, st->VAD, psyn_fx, st->Q_syn ); st->hFdCngDec->hFdCngCom->likelihood_noisy_speech = mult_r( st->hFdCngDec->hFdCngCom->likelihood_noisy_speech, 32440 /*0.99 Q15*/ ); - IF( st->hFdCngDec->hFdCngCom->flag_noisy_speech != 0 ) + IF( NE_16( st->hFdCngDec->hFdCngCom->flag_noisy_speech, 0 ) ) { st->hFdCngDec->hFdCngCom->likelihood_noisy_speech = add( st->hFdCngDec->hFdCngCom->likelihood_noisy_speech, 328 /*0.01 Q15*/ ); move16(); @@ -1353,8 +1496,8 @@ ivas_error acelp_core_dec_ivas_fx( st->lp_noise = st->hFdCngDec->lp_noise; move32(); } - - if ( st->element_mode != IVAS_CPE_TD && !st->cng_ism_flag ) + test(); + IF( NE_16( st->element_mode, IVAS_CPE_TD ) && !st->cng_ism_flag ) { /*Noise estimate*/ @@ -1367,46 +1510,49 @@ ivas_error acelp_core_dec_ivas_fx( /*==========================================================*/ ApplyFdCng_ivas_fx( psyn_fx, st->Q_syn, NULL, 0, realBuffer_fx, imagBuffer_fx, NULL, st, 0, ( st->coder_type == AUDIO && !st->GSC_noisy_speech ) ); /*==========================================================*/ - if ( st->hFdCngDec->partNoiseShape_exp < 0 ) + IF( st->hFdCngDec->partNoiseShape_exp < 0 ) { Scale_sig32( st->hFdCngDec->partNoiseShape, NPART, st->hFdCngDec->partNoiseShape_exp ); st->hFdCngDec->partNoiseShape_exp = 0; } - if ( st->hFdCngDec->hFdCngCom->cngNoiseLevelExp < 0 ) + IF( st->hFdCngDec->hFdCngCom->cngNoiseLevelExp < 0 ) { Scale_sig32( st->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN, st->hFdCngDec->hFdCngCom->cngNoiseLevelExp ); st->hFdCngDec->hFdCngCom->cngNoiseLevelExp = 0; } } - if ( !st->cna_dirac_flag ) + IF( !st->cna_dirac_flag ) { + test(); + test(); /* CNA: Generate additional comfort noise to mask potential coding artefacts */ - if ( st->flag_cna && !( st->coder_type == AUDIO && !( st->element_mode > EVS_MONO && st->GSC_noisy_speech ) ) ) + IF( st->flag_cna && !( EQ_16( st->coder_type, AUDIO ) && !( GT_16( st->element_mode, EVS_MONO ) && st->GSC_noisy_speech ) ) ) { - if ( st->element_mode == IVAS_CPE_TD && nchan_out == 2 ) + test(); + IF( EQ_16( st->element_mode, IVAS_CPE_TD ) && EQ_16( nchan_out, 2 ) ) { - if ( hStereoCng->flag_cna_fade ) + IF( hStereoCng->flag_cna_fade ) { generate_stereo_masking_noise_fx( psyn_fx, st->Q_syn, st, hStereoTD, flag_sec_CNA, 1, hStereoCng, nchan_out ); hStereoCng->flag_cna_fade = 0; } - else + ELSE { - if ( st->element_mode != last_element_mode && st->idchan == 0 ) + IF( NE_16( st->element_mode, last_element_mode ) && ( st->idchan == 0 ) ) { /* Clear memory for secondary channel CNA */ - set_s( hStereoCng->olapBufferSynth22_fx, 0, st->hFdCngDec->hFdCngCom->frameSize / 2 ); + set_s( hStereoCng->olapBufferSynth22_fx, 0, shr( st->hFdCngDec->hFdCngCom->frameSize, 1 ) ); } generate_stereo_masking_noise_fx( psyn_fx, st->Q_syn, st, hStereoTD, flag_sec_CNA, 0, hStereoCng, nchan_out ); } } - else if ( st->element_mode != IVAS_CPE_DFT ) + ELSE IF( NE_16( st->element_mode, IVAS_CPE_DFT ) ) { - if ( st->idchan == 0 ) + IF( st->idchan == 0 ) { - if ( st->element_mode != last_element_mode ) + IF( NE_16( st->element_mode, last_element_mode ) ) { set_s( st->hFdCngDec->hFdCngCom->olapBufferSynth2, 0, st->hFdCngDec->hFdCngCom->fftlen ); } @@ -1414,75 +1560,79 @@ ivas_error acelp_core_dec_ivas_fx( } } } - else if ( st->flag_cna && st->coder_type == AUDIO && ( ( st->last_core == ACELP_CORE && !( st->last_coder_type == AUDIO && !( st->element_mode > EVS_MONO && st->Last_GSC_noisy_speech_flag ) ) ) || st->last_core == TCX_20_CORE ) ) + ELSE IF( st->flag_cna && EQ_16( st->coder_type, AUDIO ) && ( ( EQ_16( st->last_core, ACELP_CORE ) && !( EQ_16( st->last_coder_type, AUDIO ) && !( GT_16( st->element_mode, EVS_MONO ) && st->Last_GSC_noisy_speech_flag ) ) ) || EQ_16( st->last_core, TCX_20_CORE ) ) ) { - if ( st->element_mode == IVAS_CPE_TD && nchan_out == 2 ) + IF( EQ_16( st->element_mode, IVAS_CPE_TD ) && EQ_16( nchan_out, 2 ) ) { generate_stereo_masking_noise_fx( psyn_fx, st->Q_syn, st, hStereoTD, flag_sec_CNA, 1, hStereoCng, nchan_out ); hStereoCng->flag_cna_fade = 1; + move16(); } - else + ELSE { - FOR( i = 0; i < st->hFdCngDec->hFdCngCom->frameSize / 2; i++ ) + FOR( i = 0; i < shr( st->hFdCngDec->hFdCngCom->frameSize, 1 ); i++ ) { - psyn_fx[i] = add( psyn_fx[i], shr_r( mult_r( st->hFdCngDec->hFdCngCom->olapBufferSynth2[i + 5 * st->hFdCngDec->hFdCngCom->frameSize / 4], st->hFdCngDec->hFdCngCom->fftlenFac ), -st->Q_syn ) ); + psyn_fx[i] = add( psyn_fx[i], shr_r( mult_r( st->hFdCngDec->hFdCngCom->olapBufferSynth2[i + imult1616( 5, shr( st->hFdCngDec->hFdCngCom->frameSize, 2 ) )], st->hFdCngDec->hFdCngCom->fftlenFac ), -st->Q_syn ) ); move16(); } } } - else + ELSE { if ( hStereoCng != NULL ) { hStereoCng->flag_cna_fade = 1; hStereoCng->enableSecCNA = 0; + move16(); + move16(); } } - if ( st->element_mode == IVAS_CPE_TD ) + IF( EQ_16( st->element_mode, IVAS_CPE_TD ) ) { /*Noise estimate*/ - if ( st->idchan == 0 && ( nchan_out == 2 || ( st->core_brate != FRAME_NO_DATA && st->core_brate != SID_2k40 ) ) ) + IF( ( st->idchan == 0 ) && ( EQ_16( nchan_out, 2 ) || ( NE_32( st->core_brate, FRAME_NO_DATA ) && NE_32( st->core_brate, SID_2k40 ) ) ) ) { ApplyFdCng_ivas_fx( psyn_fx, st->Q_syn, NULL, 0, realBuffer_fx, imagBuffer_fx, NULL, st, 0, ( st->coder_type == AUDIO && !st->GSC_noisy_speech ) ); - if ( st->hFdCngDec->partNoiseShape_exp < 0 ) + IF( st->hFdCngDec->partNoiseShape_exp < 0 ) { Scale_sig32( st->hFdCngDec->partNoiseShape, NPART, -st->hFdCngDec->partNoiseShape_exp ); st->hFdCngDec->partNoiseShape_exp = 0; } - if ( st->hFdCngDec->partNoiseShape_exp < 0 ) + IF( st->hFdCngDec->partNoiseShape_exp < 0 ) { Scale_sig32( st->hFdCngDec->partNoiseShape, NPART, st->hFdCngDec->partNoiseShape_exp ); st->hFdCngDec->partNoiseShape_exp = 0; } - if ( st->hFdCngDec->hFdCngCom->cngNoiseLevelExp < 0 ) + IF( st->hFdCngDec->hFdCngCom->cngNoiseLevelExp < 0 ) { Scale_sig32( st->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN, st->hFdCngDec->hFdCngCom->cngNoiseLevelExp ); st->hFdCngDec->hFdCngCom->cngNoiseLevelExp = 0; } + move16(); } } } } - if ( !st->cna_dirac_flag ) + IF( !st->cna_dirac_flag ) { - if ( st->flag_cna == 0 && st->L_frame == L_FRAME16k && st->last_flag_cna == 1 && ( ( st->last_core == ACELP_CORE && !( st->last_coder_type == AUDIO && !( st->element_mode > EVS_MONO && st->Last_GSC_noisy_speech_flag ) ) ) || st->last_core == AMR_WB_CORE ) ) + IF( ( st->flag_cna == 0 ) && EQ_16( st->L_frame, L_FRAME16k ) && EQ_16( st->last_flag_cna, 1 ) && ( ( EQ_16( st->last_core, ACELP_CORE ) && !( EQ_16( st->last_coder_type, AUDIO ) && !( GT_16( st->element_mode, EVS_MONO ) && st->Last_GSC_noisy_speech_flag ) ) ) || EQ_16( st->last_core, AMR_WB_CORE ) ) ) { - FOR( i = 0; i < st->hFdCngDec->hFdCngCom->frameSize / 2; i++ ) + FOR( i = 0; i < shr( st->hFdCngDec->hFdCngCom->frameSize, 1 ); i++ ) { - psyn_fx[i] = add( psyn_fx[i], shr_r( mult_r( st->hFdCngDec->hFdCngCom->olapBufferSynth2[i + 5 * st->hFdCngDec->hFdCngCom->frameSize / 4], st->hFdCngDec->hFdCngCom->fftlenFac ), -st->Q_syn ) ); + psyn_fx[i] = add( psyn_fx[i], shr_r( mult_r( st->hFdCngDec->hFdCngCom->olapBufferSynth2[i + imult1616( 5, shr( st->hFdCngDec->hFdCngCom->frameSize, 2 ) )], st->hFdCngDec->hFdCngCom->fftlenFac ), -st->Q_syn ) ); move16(); } } - if ( st->flag_cna == 0 || ( st->coder_type == AUDIO && !( st->element_mode > EVS_MONO && st->GSC_noisy_speech ) ) ) + IF( ( st->flag_cna == 0 ) || ( EQ_16( st->coder_type, AUDIO ) && !( GT_16( st->element_mode, EVS_MONO ) && st->GSC_noisy_speech ) ) ) { - if ( st->idchan == 0 ) + IF( st->idchan == 0 ) { set_s( st->hFdCngDec->hFdCngCom->olapBufferSynth2, 0, st->hFdCngDec->hFdCngCom->fftlen ); } - if ( hStereoCng != NULL && st->idchan == 0 ) + IF( hStereoCng != NULL && ( st->idchan == 0 ) ) { set_s( hStereoCng->olapBufferSynth22_fx, 0, st->hFdCngDec->hFdCngCom->fftlen ); } @@ -1496,14 +1646,14 @@ ivas_error acelp_core_dec_ivas_fx( *----------------------------------------------------------------*/ /* check if the CLDFB works on the right sample rate */ - if ( ( st->cldfbAna->no_channels * st->cldfbAna->no_col ) != st->L_frame ) + IF( NE_16( imult1616( st->cldfbAna->no_channels, st->cldfbAna->no_col ), st->L_frame ) ) { - resampleCldfb_ivas_fx( st->cldfbAna, st->L_frame * FRAMES_PER_SEC ); - resampleCldfb_ivas_fx( st->cldfbBPF, st->L_frame * FRAMES_PER_SEC ); + resampleCldfb_ivas_fx( st->cldfbAna, L_mult0( st->L_frame, FRAMES_PER_SEC ) ); + resampleCldfb_ivas_fx( st->cldfbBPF, L_mult0( st->L_frame, FRAMES_PER_SEC ) ); - if ( st->ini_frame > 0 ) + IF( st->ini_frame > 0 ) { - st->cldfbSyn->bandsToZero = st->cldfbSyn->no_channels - st->cldfbAna->no_channels; + st->cldfbSyn->bandsToZero = sub( st->cldfbSyn->no_channels, st->cldfbAna->no_channels ); } } @@ -1512,10 +1662,11 @@ ivas_error acelp_core_dec_ivas_fx( Word32 pitch_buf_fx_q20[12]; Scale_sig32( st->old_pitch_buf_fx, 2 * NB_SUBFR16k + 2, Q4 ); - Word16 lim = st->L_frame / 64; - for ( Word16 lp = 0; lp < lim; lp++ ) + Word16 lim = shr( st->L_frame, 6 ); + FOR( Word16 lp = 0; lp < lim; lp++ ) { pitch_buf_fx_q20[lp] = L_shl( pitch_buf_fx[lp], Q14 ); + move32(); } bpf_pitch_coherence_ivas_fx( st, pitch_buf_fx_q20 ); Scale_sig32( st->old_pitch_buf_fx, 2 * NB_SUBFR16k + 2, -Q4 ); @@ -1543,8 +1694,8 @@ ivas_error acelp_core_dec_ivas_fx( Word32 syn_tmp_32_fx[L_FRAME16k + L_SUBFR], *syn_32_fx; set32_fx( syn_tmp_32_fx, 0, L_FRAME16k + L_SUBFR ); syn_32_fx = syn_tmp_32_fx + L_SUBFR; - - if ( st->element_mode != IVAS_CPE_DFT || use_cldfb_for_dft ) + test(); + IF( NE_16( st->element_mode, IVAS_CPE_DFT ) || use_cldfb_for_dft ) { /* analysis of the synthesis at internal sampling rate */ Word32 realBufferSave_fx[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; @@ -1573,37 +1724,38 @@ ivas_error acelp_core_dec_ivas_fx( for ( i = 0; i < L_FRAME16k; i++ ) #endif { - syn_32_fx[i] = L_shr( L_deposit_h( psyn_fx[i] ), 4 + st->Q_syn ); // Q12 + syn_32_fx[i] = L_shr( L_deposit_h( psyn_fx[i] ), add( 4, st->Q_syn ) ); // Q12 + move32(); } Word16 offset = sub( st->cldfbAna->p_filter_length, st->cldfbAna->no_channels ); Scale_sig32( st->cldfbAna->cldfb_state_fx, offset, 1 ); // Q12 st->cldfbAna->Q_cldfb_state = Q12; - + move16(); cldfbAnalysis_ivas_fx( syn_32_fx, realBuffer_fx, imagBuffer_fx, -1, st->cldfbAna ); Scale_sig32( st->cldfbAna->cldfb_state_fx, offset, -1 ); // Q11 st->cldfbAna->Q_cldfb_state = Q11; - + move16(); /* analysis and add the BPF error signal */ Word32 tmp_bpf_error_signal_fx[L_FRAME16k]; Word16 q_bpf_error_signal; Word16 cldfb_state_offset = sub( st->cldfbBPF->p_filter_length, st->cldfbBPF->no_channels ); q_bpf_error_signal = Q6; - + move16(); #ifdef MSAN_FIX Copy_Scale_sig_16_32( bpf_error_signal_16fx, tmp_bpf_error_signal_fx, st->L_frame, q_bpf_error_signal - st->Q_syn ); // Q6 #else Copy_Scale_sig_16_32( bpf_error_signal_16fx, tmp_bpf_error_signal_fx, L_FRAME16k, q_bpf_error_signal - st->Q_syn ); // Q6 #endif - for ( i = 0; i < CLDFB_NO_COL_MAX; i++ ) + FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ ) { Scale_sig32( realBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, -Q7 ); // Q0 Scale_sig32( imagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, -Q7 ); // Q0 } Scale_sig32( st->cldfbBPF->cldfb_state_fx, cldfb_state_offset, q_bpf_error_signal - Q10 ); // q_bpf_error_signal (Q6) st->cldfbBPF->Q_cldfb_state = q_bpf_error_signal; - + move16(); tmp = -1; move16(); IF( st->bpf_off ) @@ -1613,9 +1765,9 @@ ivas_error acelp_core_dec_ivas_fx( } addBassPostFilter_ivas_fx( tmp_bpf_error_signal_fx, tmp, realBuffer_fx, imagBuffer_fx, st->cldfbBPF ); - Scale_sig32( st->cldfbBPF->cldfb_state_fx, cldfb_state_offset, -( q_bpf_error_signal - Q10 ) ); // Q10 + Scale_sig32( st->cldfbBPF->cldfb_state_fx, cldfb_state_offset, -( sub( q_bpf_error_signal, Q10 ) ) ); // Q10 st->cldfbBPF->Q_cldfb_state = Q10; - + move16(); /* set output mask for upsampling */ IF( EQ_16( st->bwidth, NB ) ) { @@ -1627,58 +1779,67 @@ ivas_error acelp_core_dec_ivas_fx( /* in case of BW switching, re-init to default */ st->cldfbSyn->bandsToZero = sub( st->cldfbSyn->no_channels, st->cldfbAna->no_channels ); } - + test(); IF( !st->cng_sba_flag || EQ_16( st->element_mode, IVAS_CPE_MDCT ) ) { + test(); + test(); + test(); /*WB/SWB-FD_CNG*/ IF( ( EQ_32( st->core_brate, FRAME_NO_DATA ) || EQ_32( st->core_brate, SID_2k40 ) ) && ( EQ_16( st->cng_type, FD_CNG ) ) && ( LE_16( st->hFdCngDec->hFdCngCom->numCoreBands, st->cldfbSyn->no_channels ) ) ) { Word16 tmpBufferScale = 0; + move16(); generate_comfort_noise_dec_hf_ivas_fx( realBuffer_fx, imagBuffer_fx, /*realBuffer, imagBuffer,*/ &tmpBufferScale, st->hFdCngDec->hFdCngCom, st->cng_ism_flag ); /* Fixed to float */ FOR( i = 0; i < st->hFdCngDec->hFdCngCom->numSlots; i++ ) { - Scale_sig32( realBuffer_fx[i] + st->hFdCngDec->hFdCngCom->numCoreBands, st->hFdCngDec->hFdCngCom->regularStopBand - st->hFdCngDec->hFdCngCom->numCoreBands, ( tmpBufferScale + 15 ) - Q31 ); // Q0 - Scale_sig32( imagBuffer_fx[i] + st->hFdCngDec->hFdCngCom->numCoreBands, st->hFdCngDec->hFdCngCom->regularStopBand - st->hFdCngDec->hFdCngCom->numCoreBands, ( tmpBufferScale + 15 ) - Q31 ); // Q0 + Scale_sig32( realBuffer_fx[i] + st->hFdCngDec->hFdCngCom->numCoreBands, sub( st->hFdCngDec->hFdCngCom->regularStopBand, st->hFdCngDec->hFdCngCom->numCoreBands ), sub( add( tmpBufferScale, 15 ), Q31 ) ); // Q0 + Scale_sig32( imagBuffer_fx[i] + st->hFdCngDec->hFdCngCom->numCoreBands, sub( st->hFdCngDec->hFdCngCom->regularStopBand, st->hFdCngDec->hFdCngCom->numCoreBands ), sub( add( tmpBufferScale, 15 ), Q31 ) ); // Q0 } - IF( st->hFdCngDec->hFdCngCom->regularStopBand < st->cldfbSyn->no_channels ) + IF( LT_16( st->hFdCngDec->hFdCngCom->regularStopBand, st->cldfbSyn->no_channels ) ) { st->cldfbSyn->bandsToZero = sub( st->cldfbSyn->no_channels, st->hFdCngDec->hFdCngCom->regularStopBand ); } ELSE { st->cldfbSyn->bandsToZero = 0; + move16(); } } } - if ( save_hb_synth_fx16 != NULL ) + IF( save_hb_synth_fx16 != NULL ) { /* save and then zero-out lowband */ Word16 Q_real = 0, Q_imag = 0; Word32 max_real = 0, max_imag = 0; - for ( i = 0; i < CLDFB_NO_COL_MAX; i++ ) + move16(); + move16(); + move32(); + move32(); + FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ ) { - for ( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ ) + FOR( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ ) { max_real = max( max_real, L_abs( realBuffer_fx[i][j] ) ); max_imag = max( max_imag, L_abs( imagBuffer_fx[i][j] ) ); } } Word32 max_val = max( max_real, max_imag ); - Q_imag = norm_l( max_val ) - 3 /* Guard bits */; + Q_imag = sub( norm_l( max_val ), 3 ) /* Guard bits */; Q_real = Q_imag; - - for ( i = 0; i < CLDFB_NO_COL_MAX; i++ ) + move16(); + FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ ) { scale_sig32( realBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real ); scale_sig32( imagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_imag ); } - scale_sig32( st->cldfbSynHB->cldfb_state_fx, st->cldfbSynHB->p_filter_length, ( Q_real - 1 ) - Q10 ); // (Q_real-1) + scale_sig32( st->cldfbSynHB->cldfb_state_fx, st->cldfbSynHB->p_filter_length, sub( sub( Q_real, 1 ), Q10 ) ); // (Q_real-1) st->cldfbSynHB->Q_cldfb_state = sub( Q_real, 1 ); - Scale_sig32( save_hb_synth_fx, L_FRAME48k, Q_real - 1 ); + Scale_sig32( save_hb_synth_fx, L_FRAME48k, sub( Q_real, 1 ) ); FOR( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ ) { @@ -1686,20 +1847,24 @@ ivas_error acelp_core_dec_ivas_fx( { realBufferSave_fx[i][j] = realBuffer_fx[i][j]; imagBufferSave_fx[i][j] = imagBuffer_fx[i][j]; + move32(); + move32(); IF( j < st->hFdCngDec->hFdCngCom->numCoreBands && i < st->hFdCngDec->hFdCngCom->numSlots ) { realBuffer_fx[i][j] = 0; imagBuffer_fx[i][j] = 0; + move32(); + move32(); } } } cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, save_hb_synth_fx, -1, st->cldfbSynHB ); - Scale_sig32( save_hb_synth_fx, L_FRAME48k, -( Q_real - 1 ) ); // Q0 - Scale_sig32( st->cldfbSynHB->cldfb_state_fx, st->cldfbSynHB->p_filter_length, Q10 - ( Q_real - 1 ) ); // Q10 + Scale_sig32( save_hb_synth_fx, L_FRAME48k, -( sub( Q_real, 1 ) ) ); // Q0 + Scale_sig32( st->cldfbSynHB->cldfb_state_fx, st->cldfbSynHB->p_filter_length, sub( Q10, sub( Q_real, 1 ) ) ); // Q10 st->cldfbSynHB->Q_cldfb_state = Q10; - + move16(); /* restore lowband */ FOR( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ ) { @@ -1707,59 +1872,67 @@ ivas_error acelp_core_dec_ivas_fx( { realBuffer_fx[i][j] = realBufferSave_fx[i][j]; imagBuffer_fx[i][j] = imagBufferSave_fx[i][j]; + move32(); + move32(); } } - Scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, ( Q_real - 1 ) - Q10 ); // Q_real-1 + Scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( sub( Q_real, 1 ), Q10 ) ); // Q_real-1 st->cldfbSynHB->Q_cldfb_state = sub( Q_real, 1 ); cldfbSynthesis_ivas_fx( pRealSave_fx, pImagSave_fx, synth_fx, -1, st->cldfbSyn ); - Scale_sig32( synth_fx, L_FRAME48k, -( Q_real - 1 ) ); - Scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, Q10 - ( Q_real - 1 ) ); // Q10 + Scale_sig32( synth_fx, L_FRAME48k, -sub( Q_real, 1 ) ); + Scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( Q10, sub( Q_real, 1 ) ) ); // Q10 st->cldfbSynHB->Q_cldfb_state = Q10; + move16(); } - else + ELSE { /* synthesis of the combined signal */ Word16 Q_real = 0, Q_imag = 0; Word32 max_real = 0, max_imag = 0; - for ( i = 0; i < CLDFB_NO_COL_MAX; i++ ) + move16(); + move16(); + move32(); + move32(); + FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ ) { - for ( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ ) + FOR( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ ) { max_real = max( max_real, L_abs( realBuffer_fx[i][j] ) ); max_imag = max( max_imag, L_abs( imagBuffer_fx[i][j] ) ); } } Word32 max_val = max( max_real, max_imag ); - Q_imag = norm_l( max_val ) - 3 /* Guard bits */; + Q_imag = sub( norm_l( max_val ), 3 ) /* Guard bits */; Q_real = Q_imag; - - for ( i = 0; i < CLDFB_NO_COL_MAX; i++ ) + move16(); + FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ ) { scale_sig32( realBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real ); scale_sig32( imagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real ); } - scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, ( Q_real - 1 ) - Q10 ); //(Q_real - 1) - st->cldfbSyn->Q_cldfb_state = Q_real - 1; + scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( sub( Q_real, 1 ), Q10 ) ); //(Q_real - 1) + st->cldfbSyn->Q_cldfb_state = sub( Q_real, 1 ); #ifndef MSAN_FIX Scale_sig32( synth_fx, L_FRAME48k, Q_real - 1 ); #endif cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, synth_fx, -1, st->cldfbSyn ); #ifdef MSAN_FIX - scale_sig32( synth_fx, output_frame, -( Q_real - 1 ) ); + scale_sig32( synth_fx, output_frame, -sub( Q_real, 1 ) ); #else Scale_sig32( synth_fx, L_FRAME48k, -( Q_real - 1 ) ); #endif - scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, Q10 - ( Q_real - 1 ) ); // Q10 + scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( Q10, sub( Q_real, 1 ) ) ); // Q10 st->cldfbSyn->Q_cldfb_state = Q10; + move16(); } /* save synthesis - needed in case of core switching */ Copy32( synth_fx, st->previoussynth_fx_32, output_frame ); // Q0 } - else + ELSE { - int16_t nSamples = NS2SA( st->L_frame * FRAMES_PER_SEC, FRAME_SIZE_NS /*DELAY_CLDFB_NS*/ ); /* IVAS-64: optimization is likely possible here (don't resample the whole frame) */ + Word16 nSamples = NS2SA( st->L_frame * FRAMES_PER_SEC, FRAME_SIZE_NS /*DELAY_CLDFB_NS*/ ); /* IVAS-64: optimization is likely possible here (don't resample the whole frame) */ /* analysis of the synthesis at internal sampling rate - needed for DFT stereo -> TD stereo switching */ #ifndef MSAN_FIX @@ -1768,37 +1941,38 @@ ivas_error acelp_core_dec_ivas_fx( FOR( i = 0; i < st->L_frame; i++ ) #endif { - syn_32_fx[i] = L_shr( L_deposit_h( psyn_fx[i] ), 4 + st->Q_syn ); + syn_32_fx[i] = L_shr( L_deposit_h( psyn_fx[i] ), add( 4, st->Q_syn ) ); + move32(); } Word16 offset = sub( st->cldfbAna->p_filter_length, st->cldfbAna->no_channels ); Scale_sig32( st->cldfbAna->cldfb_state_fx, offset, 1 ); // Q12 st->cldfbAna->Q_cldfb_state = Q12; + move16(); cldfbAnalysis_ivas_fx( syn_32_fx + st->L_frame - nSamples, realBuffer_fx, imagBuffer_fx, nSamples, st->cldfbAna ); Scale_sig32( st->cldfbAna->cldfb_state_fx, offset, -1 ); // Q11 st->cldfbAna->Q_cldfb_state = Q11; - - /* analysis and add the BPF error signal - needed for DFT stereo -> TD stereo switching */ + move16(); /* analysis and add the BPF error signal - needed for DFT stereo -> TD stereo switching */ Word32 tmp_bpf_error_signal_fx[L_FRAME16k]; Word16 q_bpf_error_signal; Word16 cldfb_state_offset = sub( st->cldfbBPF->p_filter_length, st->cldfbBPF->no_channels ); // Get Q-factor q_bpf_error_signal = Q6; - - Copy_Scale_sig_16_32( bpf_error_signal_16fx, tmp_bpf_error_signal_fx, L_FRAME16k, q_bpf_error_signal - st->Q_syn ); // Q6 - for ( i = 0; i < CLDFB_NO_COL_MAX; i++ ) + move16(); + Copy_Scale_sig_16_32( bpf_error_signal_16fx, tmp_bpf_error_signal_fx, L_FRAME16k, sub( q_bpf_error_signal, st->Q_syn ) ); // Q6 + FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ ) { Scale_sig32( realBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, -Q7 ); // Q0 Scale_sig32( imagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, -Q7 ); // Q0 } - Scale_sig32( st->cldfbBPF->cldfb_state_fx, cldfb_state_offset, q_bpf_error_signal - Q10 ); // q_bpf_error_signal (Q6) + Scale_sig32( st->cldfbBPF->cldfb_state_fx, cldfb_state_offset, sub( q_bpf_error_signal, Q10 ) ); // q_bpf_error_signal (Q6) st->cldfbBPF->Q_cldfb_state = q_bpf_error_signal; - + move16(); tmp = 0; move16(); - IF( !st->bpf_off ) + if ( !st->bpf_off ) { tmp = nSamples; move16(); @@ -1806,29 +1980,33 @@ ivas_error acelp_core_dec_ivas_fx( addBassPostFilter_ivas_fx( tmp_bpf_error_signal_fx + st->L_frame - nSamples, tmp, realBuffer_fx, imagBuffer_fx, st->cldfbBPF ); - Scale_sig32( st->cldfbBPF->cldfb_state_fx, cldfb_state_offset, -( q_bpf_error_signal - Q10 ) ); // Q10 + Scale_sig32( st->cldfbBPF->cldfb_state_fx, cldfb_state_offset, -sub( q_bpf_error_signal, Q10 ) ); // Q10 st->cldfbBPF->Q_cldfb_state = Q10; /* synthesis of the combined signal - needed for DFT stereo -> TD stereo switching */ Word16 Q_real = 0, Q_imag = 0; Word32 max_real = 0, max_imag = 0; - for ( i = 0; i < CLDFB_NO_COL_MAX; i++ ) + move16(); + move16(); + move32(); + move32(); + FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ ) { - for ( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ ) + FOR( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ ) { max_real = max( max_real, L_abs( realBuffer_fx[i][j] ) ); max_imag = max( max_imag, L_abs( imagBuffer_fx[i][j] ) ); } } Word32 max_val = max( max_real, max_imag ); - Q_imag = norm_l( max_val ) - 3 /* Guard bits */; + Q_imag = sub( norm_l( max_val ), 3 ) /* Guard bits */; Q_real = Q_imag; - - for ( i = 0; i < CLDFB_NO_COL_MAX; i++ ) + move16(); + FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ ) { scale_sig32( realBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real ); scale_sig32( imagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real ); } - scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, ( Q_real - 1 ) - Q10 ); //(Q_real - 1) + scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( sub( Q_real, 1 ), Q10 ) ); //(Q_real - 1) #ifndef MSAN_FIX Scale_sig32( synth_fx, L_FRAME48k, Q_real - 1 ); #endif @@ -1836,14 +2014,14 @@ ivas_error acelp_core_dec_ivas_fx( cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, synth_fx /*dummy*/, NS2SA( st->output_Fs, FRAME_SIZE_NS /*DELAY_CLDFB_NS*/ ), st->cldfbSyn ); #ifdef MSAN_FIX - Scale_sig32( synth_fx, output_frame, -( Q_real - 1 ) ); + Scale_sig32( synth_fx, output_frame, -sub( Q_real, 1 ) ); #else Scale_sig32( synth_fx, L_FRAME48k, -( Q_real - 1 ) ); #endif - Scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, Q10 - ( Q_real - 1 ) ); + Scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( Q10, sub( Q_real, 1 ) ) ); st->cldfbSyn->Q_cldfb_state = Q10; - - if ( st->p_bpf_noise_buf_32 ) + move16(); + IF( st->p_bpf_noise_buf_32 ) { Copy_Scale_sig_16_32( bpf_error_signal_16fx, bpf_error_signal_fx, st->L_frame, -1 ); // Q_syn-1 Copy32( bpf_error_signal_fx, st->p_bpf_noise_buf_32, st->L_frame ); @@ -1858,15 +2036,15 @@ ivas_error acelp_core_dec_ivas_fx( #ifndef MSAN_FIX Scale_sig( syn_tmp_fx, L_FRAME16k + L_SUBFR, -st->Q_syn ); #else - Scale_sig( syn_tmp_fx, st->L_frame + L_SUBFR, -st->Q_syn ); + Scale_sig( syn_tmp_fx, add( st->L_frame, L_SUBFR ), -st->Q_syn ); #endif - if ( st->element_mode > EVS_MONO ) + IF( GT_16( st->element_mode, EVS_MONO ) ) { Copy( psyn_fx, output_fx, st->L_frame ); } st->Q_syn2 = 0; - + move16(); /*-----------------------------------------------------------------* * Bandwidth extension 6kHz-7kHz *-----------------------------------------------------------------*/ @@ -1884,6 +2062,7 @@ ivas_error acelp_core_dec_ivas_fx( { #ifndef FIX_774_ENERGY_BURST Word16 tmp_exp = 0; + move16(); #endif #ifdef MSAN_FIX Copy_Scale_sig_32_16( synth_fx, synth_fx16, output_frame, 0 ); @@ -1908,10 +2087,11 @@ ivas_error acelp_core_dec_ivas_fx( IF( st->hBWE_FD != NULL ) { st->hBWE_FD->memExp1 = tmp_exp; + move16(); } ELSE { - Scale_sig( st->hBWE_zero->mem_hf_fx, L_FIR - 1, -tmp_exp ); + Scale_sig( st->hBWE_zero->mem_hf_fx, sub( L_FIR, 1 ), -tmp_exp ); } #endif } @@ -1928,24 +2108,40 @@ ivas_error acelp_core_dec_ivas_fx( * Populate parameters for SWB TBE *-----------------------------------------------------------------*/ - if ( st->hBWE_TD != NULL ) + IF( st->hBWE_TD != NULL ) { - if ( ( !st->bfi && st->prev_bfi ) || ( st->last_vbr_hw_BWE_disable_dec == 1 && st->vbr_hw_BWE_disable_dec == 0 ) || ( ( st->extl == SWB_TBE || st->extl == WB_TBE || st->extl == FB_TBE ) && st->last_extl != SWB_TBE && st->last_extl != WB_TBE && st->last_extl != FB_TBE ) || ( st->idchan == 1 && st->element_mode == IVAS_CPE_TD && !st->tdm_LRTD_flag ) ) + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + IF( ( !st->bfi && st->prev_bfi ) || ( EQ_16( st->last_vbr_hw_BWE_disable_dec, 1 ) && ( st->vbr_hw_BWE_disable_dec == 0 ) ) || ( ( EQ_16( st->extl, SWB_TBE ) || EQ_16( st->extl, WB_TBE ) || EQ_16( st->extl, FB_TBE ) ) && NE_16( st->last_extl, SWB_TBE ) && NE_16( st->last_extl, WB_TBE ) && NE_16( st->last_extl, FB_TBE ) ) || ( EQ_16( st->idchan, 1 ) && EQ_16( st->element_mode, IVAS_CPE_TD ) && !st->tdm_LRTD_flag ) ) { st->hBWE_TD->bwe_non_lin_prev_scale_fx = 0; + move32(); set_s( st->hBWE_TD->old_bwe_exc_extended_fx, 0, NL_BUFF_OFFSET ); } - - if ( !st->ppp_mode_dec && ( st->idchan == 0 || st->element_mode != IVAS_CPE_TD || ( st->idchan == 1 && st->element_mode == IVAS_CPE_TD && st->tdm_LRTD_flag ) ) ) + test(); + test(); + test(); + test(); + test(); + IF( !st->ppp_mode_dec && ( EQ_16( st->idchan, 0 ) || NE_16( st->element_mode, IVAS_CPE_TD ) || ( EQ_16( st->idchan, 1 ) && EQ_16( st->element_mode, IVAS_CPE_TD ) && st->tdm_LRTD_flag ) ) ) { Copy_Scale_sig_16_32( st->hBWE_TD->old_bwe_exc_extended_fx, bwe_exc_extended_fx, NL_BUFF_OFFSET, ( 2 * st->Q_exc - ( st->prev_Q_bwe_exc - 16 ) ) ); non_linearity_ivas_fx( bwe_exc_fx, bwe_exc_extended_fx + NL_BUFF_OFFSET, L_FRAME32k, &st->hBWE_TD->bwe_non_lin_prev_scale_fx, st->Q_exc, st->coder_type, voice_factors_fx, st->L_frame ); Copy_Scale_sig_32_16( bwe_exc_extended_fx + L_FRAME32k, st->hBWE_TD->old_bwe_exc_extended_fx, NL_BUFF_OFFSET, -( 2 * st->Q_exc - ( st->prev_Q_bwe_exc - 16 ) ) ); } - - if ( st->core_brate == FRAME_NO_DATA || st->core_brate == SID_2k40 ) + test(); + IF( EQ_32( st->core_brate, FRAME_NO_DATA ) || EQ_32( st->core_brate, SID_2k40 ) ) { st->hBWE_TD->bwe_non_lin_prev_scale_fx = 0; + move32(); } } /*----------------------------------------------------------------------* @@ -1953,7 +2149,7 @@ ivas_error acelp_core_dec_ivas_fx( *----------------------------------------------------------------------*/ updt_dec_fx( st, old_exc_fx, pitch_buf_fx, Es_pred_fx, Aq_fx, lsf_new_fx, lsp_new_fx, voice_factors_fx, old_bwe_exc_fx, gain_buf_fx ); - + test(); IF( GT_32( st->core_brate, SID_2k40 ) && st->hTdCngDec != NULL && st->hFdCngDec != NULL ) { /* update CNG parameters in active frames */ @@ -1965,7 +2161,7 @@ ivas_error acelp_core_dec_ivas_fx( /* Set 16k LSP flag for CNG buffer */ st->hTdCngDec->ho_16k_lsp[st->hTdCngDec->ho_circ_ptr] = 0; move16(); - IF( NE_16( st->L_frame, L_FRAME ) ) + if ( NE_16( st->L_frame, L_FRAME ) ) { st->hTdCngDec->ho_16k_lsp[st->hTdCngDec->ho_circ_ptr] = 1; move16(); @@ -1973,7 +2169,7 @@ ivas_error acelp_core_dec_ivas_fx( } { - if ( save_hb_synth_fx16 ) + IF( save_hb_synth_fx16 ) { Copy_Scale_sig_32_16( save_hb_synth_fx, save_hb_synth_fx16, L_FRAME48k, 0 ); } @@ -1985,6 +2181,7 @@ ivas_error acelp_core_dec_ivas_fx( if ( st->hFdCngDec ) { st->hFdCngDec->hFdCngCom->A_cng[0] = ONE_IN_Q12; + move16(); } } diff --git a/lib_dec/dec_tcx.c b/lib_dec/dec_tcx.c index 586470bac65a4f875f70d0acedea57b360e77101..921e84976d7eaaeb324e6af7cbe9189d821f861b 100644 --- a/lib_dec/dec_tcx.c +++ b/lib_dec/dec_tcx.c @@ -495,32 +495,7 @@ void IMDCT( edxt( x, xn_buf + overlap / 2 + nz, L_frame, kernel_type, TRUE ); } v_multc( xn_buf + overlap / 2 + nz, (float) sqrt( (float) L_frame / NORM_MDCT_FACTOR ), tmp, L_frame ); -#ifndef IVAS_FLOAT_FIXED_UNIT_TESTING window_ola_ext( tmp, xn_buf, old_out, L_frame, hTcxCfg->tcx_last_overlap_mode, hTcxCfg->tcx_curr_overlap_mode, kernel_type ); -#ifdef DUMPS_ENABLED - dbgwrite_txt( xn_buf, L_frame + ( L_frame * N_ZERO_MDCT_NS / FRAME_SIZE_NS ), "xn_buf_float.txt", NULL ); - dbgwrite_txt( old_out, L_frame, "old_out_float.txt", NULL ); -#endif -#else - Word32 xn_buf_fx[1200] = { 0 }, tmp_fx[1200], old_out_fx[1200]; - for ( int i = 0; i < L_frame; i++ ) - { - old_out_fx[i] = old_out[i] * ( 1 << Q15 ); - tmp_fx[i] = tmp[i] * ( 1 << Q15 ); - } - - window_ola_ext_fx( tmp_fx, xn_buf_fx, old_out_fx, L_frame, hTcxCfg->tcx_last_overlap_mode, hTcxCfg->tcx_curr_overlap_mode, kernel_type ); - - for ( int i = 0; i < L_frame; i++ ) - { - old_out[i] = (float) old_out_fx[i] / ( 1 << Q15 ); - xn_buf[i] = (float) xn_buf_fx[i] / ( 1 << Q15 ); - } -#ifdef DUMPS_ENABLED - dbgwrite_txt( xn_buf, L_frame + ( L_frame * N_ZERO_MDCT_NS / FRAME_SIZE_NS ), "xn_buf_fixed.txt", NULL ); - dbgwrite_txt( old_out, L_frame, "old_out_fixed.txt", NULL ); -#endif -#endif // IVAS_FLOAT_FIXED_UNIT_TESTING } else { diff --git a/lib_dec/igf_dec.c b/lib_dec/igf_dec.c index 2afd2cb8a4edfc3a680d73d1a34315d782565148..c6d72f5d8370a2dbc070f5f9186e347e148c4163 100644 --- a/lib_dec/igf_dec.c +++ b/lib_dec/igf_dec.c @@ -1174,11 +1174,7 @@ void IGFDecApplyMono_flt( nShift = igfGridIdx == IGF_GRID_LB_SHORT ? 2 : 1; set_s( hIGFDec->flag_sparse, 0, ( N_MAX_TCX - IGF_START_MN ) / nShift ); -#ifndef IVAS_FLOAT_FIXED set_f( hIGFDec->virtualSpec_float, 0.f, ( N_MAX_TCX - IGF_START_MN ) / nShift ); -#else - set_val_Word32( hIGFDec->virtualSpec, 0, ( N_MAX_TCX - IGF_START_MN ) / nShift ); -#endif hPrivateData = &hIGFDec->igfData; hGrid = &hPrivateData->igfInfo.grid[igfGridIdx]; @@ -1276,13 +1272,8 @@ void IGFDecApplyStereo_flt( nShift = igfGridIdx == IGF_GRID_LB_SHORT ? 2 : 1; set_s( hIGFDecL->flag_sparse, 0, ( N_MAX_TCX - IGF_START_MN ) / nShift ); set_s( hIGFDecR->flag_sparse, 0, ( N_MAX_TCX - IGF_START_MN ) / nShift ); -#ifndef IVAS_FLOAT_FIXED set_f( hIGFDecL->virtualSpec_float, 0.f, ( N_MAX_TCX - IGF_START_MN ) / nShift ); set_f( hIGFDecR->virtualSpec_float, 0.f, ( N_MAX_TCX - IGF_START_MN ) / nShift ); -#else - set_val_Word32( hIGFDecL->virtualSpec, 0, ( N_MAX_TCX - IGF_START_MN ) / nShift ); - set_val_Word32( hIGFDecR->virtualSpec, 0, ( N_MAX_TCX - IGF_START_MN ) / nShift ); -#endif hPrivateDataL = &hIGFDecL->igfData; hGrid = &hPrivateDataL->igfInfo.grid[igfGridIdx]; @@ -1428,13 +1419,7 @@ void IGFDecSetMode_flt( hIGFDec->flag_sparse = &hIGFDec->flag_sparseBuf[0]; hIGFDec->infoTCXNoise_ptr = &hIGFDec->infoTCXNoise_evs[0]; hIGFDec->virtualSpec_float = &hIGFDec->virtualSpecBuf[0]; -#ifdef IVAS_FLOAT_FIXED - hIGFDec->virtualSpec_fx = &hIGFDec->virtualSpec[0]; -#endif hIGFDec->igfData.pSpecFlat_float = &hIGFDec->igfData.pSpecFlatBuf[0]; -#ifdef IVAS_FLOAT_FIXED - hIGFDec->igfData.pSpecFlat = &hIGFDec->igfData.pSpecFlatBuf_fx[0]; -#endif hIGFDec->igfData.igfInfo.nfSeed = &hIGFDec->igfData.igfInfo.nfSeedBuf[0]; return; @@ -1496,9 +1481,6 @@ void IGFDecReplicateTCX10State_flt( mvs2s( &hIGFDec->infoTCXNoise_evs[( IGF_START_MX ) / 2], &hIGFDec->infoTCXNoise_evs[0], ( IGF_START_MX ) / 2 ); mvr2r( &hIGFDec->virtualSpecBuf[( N_MAX_TCX - IGF_START_MN ) / 2], &hIGFDec->virtualSpecBuf[0], ( N_MAX_TCX - IGF_START_MN ) / 2 ); mvr2r( &hIGFDec->igfData.pSpecFlatBuf[IGF_START_MX / 2], &hIGFDec->igfData.pSpecFlatBuf[0], IGF_START_MX / 2 ); -#ifdef IVAS_FLOAT_FIXED - Copy32( &hIGFDec->igfData.pSpecFlatBuf_fx[IGF_START_MX / 2], &hIGFDec->igfData.pSpecFlatBuf_fx[0], IGF_START_MX / 2 ); -#endif hIGFDec->igfData.igfInfo.nfSeedBuf[0] = hIGFDec->igfData.igfInfo.nfSeedBuf[1]; diff --git a/lib_dec/ivas_binRenderer_internal.c b/lib_dec/ivas_binRenderer_internal.c index 910469008c4f814d4d122b5c8f449997883983d6..a00fa71eeab6aa52a4a56f897631e7139a7f68d7 100644 --- a/lib_dec/ivas_binRenderer_internal.c +++ b/lib_dec/ivas_binRenderer_internal.c @@ -1927,7 +1927,7 @@ ivas_error ivas_binRenderer_open_fx( { FOR( k = 0; k < 11; k++ ) { - ivas_dirac_dec_get_response_fixed( (Word16) L_shr_r( ls_azimuth_CICP19_fx[k], 22 ), (Word16) L_shr_r( ls_elevation_CICP19_fx[k], 22 ), hBinRenderer->hReverb->foa_enc_fx[k], 1 ); + ivas_dirac_dec_get_response_fx( (Word16) L_shr_r( ls_azimuth_CICP19_fx[k], 22 ), (Word16) L_shr_r( ls_elevation_CICP19_fx[k], 22 ), hBinRenderer->hReverb->foa_enc_fx[k], 1, Q29 ); // Q29: hBinRenderer->hReverb->foa_enc_fx[k] } } diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 5e18e1750804834d110c20d76b21f4db0b56dba4..234fe1e114ce192e1f1579b287653a184de19ff8 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -1965,7 +1965,7 @@ ivas_error ivas_init_decoder_fx( IF( st_ivas->nCPE > 1 ) { - IF( ( error = create_mct_dec( st_ivas ) ) != IVAS_ERR_OK ) + IF( ( error = create_mct_dec_fx( st_ivas ) ) != IVAS_ERR_OK ) { return error; } @@ -2127,7 +2127,7 @@ ivas_error ivas_init_decoder_fx( IF( st_ivas->nCPE > 1 ) { - IF( ( error = create_mct_dec( st_ivas ) ) != IVAS_ERR_OK ) + IF( ( error = create_mct_dec_fx( st_ivas ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_dec/ivas_ism_param_dec.c b/lib_dec/ivas_ism_param_dec.c index 982467cbe7569632ee46caca1cda6952320d568c..1d3614c37b736bf3054aa640f985cd1e71a3584a 100644 --- a/lib_dec/ivas_ism_param_dec.c +++ b/lib_dec/ivas_ism_param_dec.c @@ -1922,7 +1922,7 @@ void ivas_ism_dec_digest_tc_fx( /*get HOA gets for direction (ACN/SN3D)*/ Word16 azi = shr( extract_h( st_ivas->hIsmMetaData[i]->azimuth_fx ), 22 - 16 ); Word16 ele = shr( extract_h( st_ivas->hIsmMetaData[i]->elevation_fx ), 22 - 16 ); - ivas_dirac_dec_get_response_fx( azi, ele, st_ivas->hIsmRendererData->gains_fx[i], st_ivas->hIntSetup.ambisonics_order ); + ivas_dirac_dec_get_response_fx( azi, ele, st_ivas->hIsmRendererData->gains_fx[i], st_ivas->hIntSetup.ambisonics_order, Q30 ); } } } diff --git a/lib_dec/ivas_ism_renderer.c b/lib_dec/ivas_ism_renderer.c index 663af323dbca1666fb5c4ba9d1130e410924ba9f..f766a5b959c7f4505fe064683d7186fef73812a7 100644 --- a/lib_dec/ivas_ism_renderer.c +++ b/lib_dec/ivas_ism_renderer.c @@ -1104,7 +1104,7 @@ void ivas_omasa_separate_object_render_jbm_fx( } ELSE { - ivas_dirac_dec_get_response_fixed( azimuth, elevation, gains_fx, hDirACRend->hOutSetup.ambisonics_order ); + ivas_dirac_dec_get_response_fx( azimuth, elevation, gains_fx, hDirACRend->hOutSetup.ambisonics_order, Q29 ); } FOR( j = 0; j < nchan_out_woLFE; j++ ) diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 4556baaf5abae9aa77278d228ee8e3429b46d092..fa512cf9c4d7b005c5b17d33537109a206614c2b 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -3167,17 +3167,6 @@ ivas_error ivas_jbm_dec_render_fx( scale_sig32( st_ivas->hParamMC->h_freq_domain_decorr_ap_state->decorr_buffer_fx, st_ivas->hParamMC->h_freq_domain_decorr_ap_state->decorr_buffer_len, tmp ); st_ivas->hParamMC->h_freq_domain_decorr_ap_state->q_decorr_buffer += tmp; } - test(); - IF( ( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) ) - { - test(); - IF( st_ivas->hCombinedOrientationData && EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) ) - { - Word16 Q_hoa_encoder = 31; - move16(); - floatToFixed_arrL( st_ivas->hParamMC->hoa_encoder, st_ivas->hParamMC->hoa_encoder_fx, Q_hoa_encoder, st_ivas->hTransSetup.nchan_out_woLFE * MAX_INTERN_CHANNELS ); - } - } /* CLDFB synthesis */ FOR( Word16 ch = 0; ch < nchan_out_cldfb; ch++ ) { diff --git a/lib_dec/ivas_mc_param_dec.c b/lib_dec/ivas_mc_param_dec.c index 2badc75fe8c305eaad49e57fce71e49deb527360..5160804714a598b9f6de41a8de37065315876d8e 100644 --- a/lib_dec/ivas_mc_param_dec.c +++ b/lib_dec/ivas_mc_param_dec.c @@ -214,9 +214,6 @@ ivas_error ivas_param_mc_dec_open_fx( mc_ls_setup = ivas_mc_map_output_config_to_mc_ls_setup_fx( st_ivas->transport_config ); nchan_out_transport = st_ivas->hTransSetup.nchan_out_woLFE + st_ivas->hTransSetup.num_lfe; hParamMC->hoa_encoder_fx = NULL; -#if 1 /*TODO: To be removed later(floating pointer initialization)*/ - hParamMC->hoa_encoder = NULL; -#endif /* determine the synthesis config */ if ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM || st_ivas->renderer_type == RENDERER_BINAURAL_OBJECTS_TD || st_ivas->transport_config == output_config ) @@ -491,12 +488,6 @@ ivas_error ivas_param_mc_dec_open_fx( /* Head or external rotation */ if ( ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) && ( st_ivas->hDecoderConfig->Opt_Headrotation || st_ivas->hDecoderConfig->Opt_ExternalOrientation ) ) { -#if 1 /*TODO : To be removed later*/ - IF( ( hParamMC->hoa_encoder = (float *) malloc( st_ivas->hTransSetup.nchan_out_woLFE * MAX_INTERN_CHANNELS * sizeof( float ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Parametric MC\n" ) ); - } -#endif IF( ( hParamMC->hoa_encoder_fx = (Word32 *) malloc( st_ivas->hTransSetup.nchan_out_woLFE * MAX_INTERN_CHANNELS * sizeof( Word32 ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Parametric MC\n" ) ); @@ -2246,13 +2237,6 @@ void ivas_param_mc_dec_close_fx( free( hParamMC->Cldfb_ImagBuffer_tc_fx ); hParamMC->Cldfb_ImagBuffer_tc_fx = NULL; } -#ifdef IVAS_FLOAT_FIXED_TO_BE_REMOVED /*TODO: To be removed later(Floating point memory dealloc)------------------------------- */ - IF( hParamMC->hoa_encoder != NULL ) - { - free( hParamMC->hoa_encoder ); - hParamMC->hoa_encoder = NULL; - } -#endif /***********************************ends here************************************************/ free( *hParamMC_out ); *hParamMC_out = NULL; diff --git a/lib_dec/ivas_mc_paramupmix_dec.c b/lib_dec/ivas_mc_paramupmix_dec.c index dec62f973ae0e9d888ef3e257f9473653256d68d..43dfffa4e71fe66fd51df9f8b576fa95da526e40 100644 --- a/lib_dec/ivas_mc_paramupmix_dec.c +++ b/lib_dec/ivas_mc_paramupmix_dec.c @@ -343,7 +343,6 @@ ivas_error ivas_mc_paramupmix_dec_open( } compute_hoa_encoder_mtx_fx( st_ivas->hTransSetup.ls_azimuth_fx, st_ivas->hTransSetup.ls_elevation_fx, hMCParamUpmix->hoa_encoder_fx, st_ivas->hTransSetup.nchan_out_woLFE, HEAD_ROTATION_HOA_ORDER ); // compute_hoa_encoder_mtx( st_ivas->hTransSetup.ls_azimuth, st_ivas->hTransSetup.ls_elevation, hMCParamUpmix->hoa_encoder, st_ivas->hTransSetup.nchan_out_woLFE, HEAD_ROTATION_HOA_ORDER ); - Scale_sig32( hMCParamUpmix->hoa_encoder_fx, st_ivas->hTransSetup.nchan_out_woLFE * MAX_INTERN_CHANNELS, Q2 ); // Q29=>Q31 } /* allocate transport channels*/ diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c index 3d115b9f4b246d9f35da960b522c5e873a23f28e..3e11870eb439bf0e678bf8102cfb424b1448f6cd 100644 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -781,7 +781,7 @@ ivas_error create_mct_dec_fx( return IVAS_ERR_OK; } -#endif // IVAS_FLOAT_FIXED +#else // IVAS_FLOAT_FIXED ivas_error create_mct_dec( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ @@ -873,18 +873,10 @@ ivas_error create_mct_dec( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for MDCT Stereo \n" ) ); } -#ifndef IVAS_FLOAT_FIXED initMdctStereoDecData( hMCT->hBlockData[n]->hStereoMdct, st_ivas->hCPE[0]->hCoreCoder[0]->igf, st_ivas->hCPE[0]->hCoreCoder[0]->hIGFDec->igfData.igfInfo.grid, cp_bitrate, SWB ); -#else - initMdctStereoDecData_fx( hMCT->hBlockData[n]->hStereoMdct, st_ivas->hCPE[0]->hCoreCoder[0]->igf, st_ivas->hCPE[0]->hCoreCoder[0]->hIGFDec->igfData.igfInfo.grid, cp_bitrate, SWB ); -#endif hMCT->hBlockData[n]->hStereoMdct->use_itd = 0; hMCT->hBlockData[n]->hStereoMdct->reverse_dmx = 0; -#ifndef IVAS_FLOAT_FIXED hMCT->hBlockData[n]->hStereoMdct->smooth_ratio = 1.f; -#else - hMCT->hBlockData[n]->hStereoMdct->smooth_ratio_fx = ONE_IN_Q26; -#endif } for ( ; n < MCT_MAX_BLOCKS; n++ ) { @@ -907,7 +899,7 @@ ivas_error create_mct_dec( return IVAS_ERR_OK; } - +#endif /*------------------------------------------------------------------------- * mct_dec_reconfigure() diff --git a/lib_dec/ivas_sba_rendering_internal.c b/lib_dec/ivas_sba_rendering_internal.c index 6d87d5f8157945a079212ffe192ce0c7d6ed0d4d..86da344d9f6a1df1b72dd0c8638a22c3b89154ca 100644 --- a/lib_dec/ivas_sba_rendering_internal.c +++ b/lib_dec/ivas_sba_rendering_internal.c @@ -249,11 +249,12 @@ void ivas_mc2sba_fx( azimuth = (Word16) L_shr( hIntSetup.ls_azimuth_fx[idx_in], 22 ); elevation = (Word16) L_shr( hIntSetup.ls_elevation_fx[idx_in], 22 ); idx_in++; - ivas_dirac_dec_get_response_fixed( + ivas_dirac_dec_get_response_fx( azimuth, elevation, gains_fx, /*Q-29*/ - sba_order ); + sba_order, + Q29 ); /* get HOA response for direction (ACN/SN3D)*/ FOR( j = 0; j < sba_num_chans; j++ ) diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index e8beec6d0567943af5ce07fe44ca075eb547a6fc..272cc4582d9c0301a752c14f51a2987195e9dd9a 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -894,10 +894,10 @@ typedef struct ivas_param_mc_dec_data_structure HANDLE_DIRAC_DECORR_PARAMS h_freq_domain_decorr_ap_params; HANDLE_DIRAC_DECORR_STATE h_freq_domain_decorr_ap_state; #ifdef IVAS_FLOAT_FIXED - Word32 *hoa_encoder_fx; -#endif // IVAS_FLOAT_FIXED - + Word32 *hoa_encoder_fx; // Q31 +#else float *hoa_encoder; +#endif // IVAS_FLOAT_FIXED } PARAM_MC_DEC_DATA, *PARAM_MC_DEC_HANDLE; @@ -925,7 +925,7 @@ typedef struct ivas_mc_paramupmix_dec_data_structure Word16 *param_interpolator_fx; // Q15 Word32 alpha_sf_fx[MC_PARAMUPMIX_COMBINATIONS][IVAS_MAX_NUM_BANDS]; // Q28 Word32 beta_sf_fx[MC_PARAMUPMIX_COMBINATIONS][IVAS_MAX_NUM_BANDS]; // Q28 - Word32 *hoa_encoder_fx; + Word32 *hoa_encoder_fx; // Q31 #else float alphas[MC_PARAMUPMIX_COMBINATIONS][IVAS_MAX_NUM_BANDS]; float betas[MC_PARAMUPMIX_COMBINATIONS][IVAS_MAX_NUM_BANDS]; diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 2b979de694193760f10c43c485928f3d6de5793b..11a38a393600230a769cb8464b42c8bb12064af9 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -792,8 +792,6 @@ ivas_error IVAS_DEC_FeedFrame_Serial( { fixedToFloat_arrL( hParamMC->diff_proto_info->proto_fac_fx[i], hParamMC->diff_proto_info->proto_fac[i], 26, hParamMC->diff_proto_info->num_source_chan_diff[i] ); } - IF( hParamMC->hoa_encoder_fx ) - fixedToFloat_arrL( hParamMC->hoa_encoder_fx, hParamMC->hoa_encoder, Q29, hIvasDec->st_ivas->hTransSetup.nchan_out_woLFE * MAX_INTERN_CHANNELS ); } } #endif @@ -1218,8 +1216,6 @@ static ivas_error IVAS_DEC_Setup( fixedToFloat_arrL( hParamMC->diff_proto_info->proto_fac_fx[i], hParamMC->diff_proto_info->proto_fac[i], 26, hParamMC->diff_proto_info->num_source_chan_diff[i] ); } } - IF( hParamMC->hoa_encoder_fx ) - fixedToFloat_arrL( hParamMC->hoa_encoder_fx, hParamMC->hoa_encoder, Q29, st_ivas->hTransSetup.nchan_out_woLFE * MAX_INTERN_CHANNELS ); } } @@ -1280,8 +1276,6 @@ static ivas_error IVAS_DEC_Setup( { fixedToFloat_arrL( st_ivas->hParamMC->diff_proto_info->proto_fac_fx[i], st_ivas->hParamMC->diff_proto_info->proto_fac[i], 26, st_ivas->hParamMC->diff_proto_info->num_source_chan_diff[i] ); } - IF( st_ivas->hParamMC->hoa_encoder_fx ) - fixedToFloat_arrL( st_ivas->hParamMC->hoa_encoder_fx, st_ivas->hParamMC->hoa_encoder, Q29, st_ivas->hTransSetup.nchan_out_woLFE * MAX_INTERN_CHANNELS ); } } } diff --git a/lib_dec/tns_base_dec.c b/lib_dec/tns_base_dec.c index f23f4f6aae38cd5ee40d637b2d156cbb5a561f05..0f88f4aca0e308da1f5297c540afcc3c4403ddf4 100644 --- a/lib_dec/tns_base_dec.c +++ b/lib_dec/tns_base_dec.c @@ -42,7 +42,7 @@ #include "stat_com.h" #include "wmc_auto.h" - +#ifndef IVAS_FLOAT_FIXED /*---------------------------------------------------------------------* * ReadTnsData_ivas() * @@ -141,3 +141,4 @@ int16_t DecodeTnsData_ivas( return ( pTnsData->nFilters > 0 ) ? TRUE : FALSE; } +#endif diff --git a/lib_dec/tonalMDCTconcealment.c b/lib_dec/tonalMDCTconcealment.c index 922d0a25263cc3b0cf058a273d7f0715007d6d0a..a9b293e4e94f9a642b02db47851fe929fd2bba2a 100644 --- a/lib_dec/tonalMDCTconcealment.c +++ b/lib_dec/tonalMDCTconcealment.c @@ -53,7 +53,7 @@ /*******************************************************/ /*-------------- public functions -------------------- */ /*******************************************************/ - +#ifndef IVAS_FLOAT_FIXED ivas_error TonalMDCTConceal_Init_ivas( TonalMDCTConcealPtr hTonalMDCTConc, const uint16_t nSamples, @@ -126,7 +126,6 @@ ivas_error TonalMDCTConceal_Init_ivas( return IVAS_ERR_OK; } -#ifndef IVAS_FLOAT_FIXED void TonalMDCTConceal_SaveFreqSignal_ivas( TonalMDCTConcealPtr hTonalMDCTConc, const float *mdctSpectrum, @@ -1079,11 +1078,11 @@ void TonalMdctConceal_create_concealment_noise_ivas_fx( Word32 noise_shape_buffer[L_FRAME48k]; Word16 noise_shape_buffer_e[L_FRAME48k]; Word16 start_idx, stop_idx, noise_shape_buffer_common_exp = MIN16B_FLT_FX, last_scf_e, temp_e; + move16(); Word32 *cngNoiseLevelPtr; Word32 last_scf; Word16 c_e, c_inv_e; - move16(); push_wmops( "create_conc_noise" ); @@ -1119,7 +1118,7 @@ void TonalMdctConceal_create_concealment_noise_ivas_fx( move16(); IF( st->tonal_mdct_plc_active ) { - max_noise_line = s_max( max_noise_line, hTonalMDCTConc->pTCI->upperIndex[hTonalMDCTConc->pTCI->numIndexes - 1] + 1 ); + max_noise_line = s_max( max_noise_line, extract_l( L_add( hTonalMDCTConc->pTCI->upperIndex[hTonalMDCTConc->pTCI->numIndexes - 1], 1 ) ) ); } /* first lost frame is handled separately */ @@ -1640,16 +1639,43 @@ void TonalMdctConceal_whiten_noise_shape_ivas_fx( psychParams = st->hTonalMDCTConc->psychParams; hFdCngCom = st->hFdCngDec->hFdCngCom; - inc = ( ( EQ_32( whitening_mode, ON_FIRST_LOST_FRAME ) ? st->core : st->last_core ) > TCX_20_CORE ) ? 2 : 1; + IF( EQ_32( whitening_mode, ON_FIRST_LOST_FRAME ) ) + { + IF( GT_16( st->core, TCX_20_CORE ) ) + { + inc = 2; + move16(); + } + ELSE + { + inc = 1; + move16(); + } + } + ELSE + { + IF( GT_16( st->last_core, TCX_20_CORE ) ) + { + inc = 2; + move16(); + } + ELSE + { + inc = 1; + move16(); + } + } start_idx = shr( hFdCngCom->startBand, sub( inc, 1 ) ); stop_idx = shr( L_frame, sub( inc, 1 ) ); noiseLevelPtr = hFdCngCom->cngNoiseLevel; noiseLevelPtr_exp = hFdCngCom->cngNoiseLevelExp; + move16(); set32_fx( whitenend_noise_shape, 0, start_idx ); FOR( Word16 j = start_idx; j < stop_idx; j++ ) { whitenend_noise_shape[j] = *noiseLevelPtr; + move32(); noiseLevelPtr += inc; } @@ -1657,7 +1683,7 @@ void TonalMdctConceal_whiten_noise_shape_ivas_fx( { Word32 scf[SNS_NPTS]; - sns_compute_scf_fx( whitenend_noise_shape, psychParams, L_frame, scf, ( 31 - noiseLevelPtr_exp ) ); + sns_compute_scf_fx( whitenend_noise_shape, psychParams, L_frame, scf, sub( 31, noiseLevelPtr_exp ) ); sns_interpolate_scalefactors_fx( scfs_int, scf, ENC ); sns_interpolate_scalefactors_fx( scfs_bg, scf, DEC ); @@ -1674,7 +1700,7 @@ void TonalMdctConceal_whiten_noise_shape_ivas_fx( q_wns = sub( 31, noiseLevelPtr_exp ); sns_shape_spectrum_fx( whitenend_noise_shape, &q_wns, psychParams, scfs_for_shaping, Q16, L_frame ); - Copy32( whitenend_noise_shape + start_idx, hFdCngCom->cngNoiseLevel, stop_idx - start_idx ); + Copy32( whitenend_noise_shape + start_idx, hFdCngCom->cngNoiseLevel, sub( stop_idx, start_idx ) ); hFdCngCom->cngNoiseLevelExp = sub( 30, q_wns ); } ELSE diff --git a/lib_dec/tonalMDCTconcealment_fx.c b/lib_dec/tonalMDCTconcealment_fx.c index f64ef3a7b0467902b05bb562022192b028f6a105..a41fd48f5da453a865adc731097d0b6e872519cf 100644 --- a/lib_dec/tonalMDCTconcealment_fx.c +++ b/lib_dec/tonalMDCTconcealment_fx.c @@ -84,10 +84,7 @@ ivas_error TonalMDCTConceal_Init( hTonalMDCTConc->secondLastBlockData.blockIsConcealed = 0; move16(); - // hTonalMDCTConc->pTCI_fix = (TonalComponentsInfo_fix *)hTonalMDCTConc->timeDataBuffer; move16(); - - hTonalMDCTConc->lastPitchLag = L_deposit_l( 0 ); IF( NE_16( hTonalMDCTConc->nSamples, nSamples ) ) @@ -122,14 +119,12 @@ ivas_error TonalMDCTConceal_Init( move16(); move16(); /* just the second half of the second last pcm output is needed */ - hTonalMDCTConc->secondLastPcmOut = &hTonalMDCTConc->timeDataBuffer[sub( ( 3 * L_FRAME_MAX ) / 2, 3 * ( s_min( L_FRAME_MAX, nSamples ) ) / 2 )]; + hTonalMDCTConc->secondLastPcmOut = &hTonalMDCTConc->timeDataBuffer[sub( ( 3 * L_FRAME_MAX ) / 2, shr( imult1616( 3, ( s_min( L_FRAME_MAX, nSamples ) ) ), 1 ) )]; hTonalMDCTConc->lastPcmOut = &hTonalMDCTConc->timeDataBuffer[sub( ( 3 * L_FRAME_MAX ) / 2, s_min( L_FRAME_MAX, nSamples ) )]; /* If the second last frame was lost, we reuse saved TonalComponentsInfo and don't update pcm buffers */ -#if 1 - // TO do enable when only fix code is present currently disabled due to float array in structure - // assert(sizeof(*hTonalMDCTConc->pTCI) <= (hTonalMDCTConc->lastPcmOut-hTonalMDCTConc->timeDataBuffer)*sizeof(hTonalMDCTConc->timeDataBuffer[0])); -#endif + assert( sizeof( *hTonalMDCTConc->pTCI ) <= ( hTonalMDCTConc->lastPcmOut - hTonalMDCTConc->timeDataBuffer ) * sizeof( hTonalMDCTConc->timeDataBuffer[0] ) ); + return IVAS_ERR_OK; } ivas_error TonalMDCTConceal_Init_ivas_fx( @@ -193,8 +188,6 @@ ivas_error TonalMDCTConceal_Init_ivas_fx( move16(); hTonalMDCTConc->pTCI = (TonalComponentsInfo *) hTonalMDCTConc->timeDataBuffer; - // hTonalMDCTConc->pTCI = &hTonalMDCTConc->pTCI1; - move16(); hTonalMDCTConc->lastPitchLag = L_deposit_l( 0 ); @@ -498,6 +491,7 @@ void TonalMDCTConceal_SaveFreqSignal_ivas_fx( { /* Store new data */ hTonalMDCTConc->last_block_nrg = 0; + move32(); FOR( i = 0; i < infoIGFStartLine; i++ ) { @@ -505,12 +499,13 @@ void TonalMDCTConceal_SaveFreqSignal_ivas_fx( hTonalMDCTConc->last_block_nrg = L_add( hTonalMDCTConc->last_block_nrg, L_shr( L_mult0( tmp, tmp ), 16 ) ); } - hTonalMDCTConc->last_block_nrg_exp = 31 - ( ( 15 - mdctSpectrum_exp ) * 2 - 16 ); + hTonalMDCTConc->last_block_nrg_exp = sub( 31, sub( shl( sub( 15, mdctSpectrum_exp ), 1 ), 16 ) ); /* Store new data */ s = getScaleFactor32( mdctSpectrum, nNewSamples ); max_exp = 0; + move16(); FOR( i = 0; i < hTonalMDCTConc->nScaleFactors; i++ ) { hTonalMDCTConc->lastBlockData.scaleFactors_exp[i] = scaleFactors_exp[i]; @@ -520,6 +515,7 @@ void TonalMDCTConceal_SaveFreqSignal_ivas_fx( /*s = sub(s, max_exp);*/ hTonalMDCTConc->lastBlockData.scaleFactors_max_e = max_exp; + move16(); FOR( i = 0; i < nNewSamples; i++ ) { @@ -529,6 +525,7 @@ void TonalMDCTConceal_SaveFreqSignal_ivas_fx( hTonalMDCTConc->lastBlockData.spectralData_exp = sub( mdctSpectrum_exp, s ); move16(); + move16(); hTonalMDCTConc->lastBlockData.gain_tcx_exp = gain_tcx_exp; Copy( scaleFactors, hTonalMDCTConc->lastBlockData.scaleFactors, hTonalMDCTConc->nScaleFactors ); } @@ -651,6 +648,7 @@ static void FindPhaseDifferences( /* o if ( s_and( k, 1 ) != 0 ) { phaseDiff[i] = -12868 /*-EVS_PI 3Q12*/; + move16(); } } ELSE @@ -662,6 +660,7 @@ static void FindPhaseDifferences( /* o if ( s_and( k, 1 ) != 0 ) { phaseDiff[i] = 0 /*0 Q13*/; /*2Q13*/ + move16(); } } ELSE @@ -683,6 +682,7 @@ static void FindPhaseDifferences( /* o { L_tmp = L_shl( L_tmp, sfn ); sfn = 0; + move16(); } a = L_sub( m, L_tmp ); /*sf*/ @@ -697,13 +697,13 @@ static void FindPhaseDifferences( /* o ELSE { sfd = 0; + move16(); L_tmp = L_shl( L_tmp, sf ); } L_tmp = L_add( n, L_tmp ); fractional = BASOP_util_atan2( a, L_tmp, sub( sfn, sfd ) ); /*2Q13*/ L_tmp = L_mult( fractional, 28672 /*BANDWIDTH/2.0f Q13*/ ); /*2Q13*2Q13=4Q27*/ - move16(); /* fractional is in the range 0..+pi */ /* we need to stay in the range -2pi..+2pi */ @@ -739,22 +739,21 @@ static void ivas_CalcPowerSpecAndDetectTonalComponents_fx( Word16 nSamples; Word16 i; Word16 floorPowerSpectrum; /* Minimum significant value of a spectral line in the power spectrum */ -#ifdef MSAN_FIX - Word32 powerSpectrum[L_FRAME_MAX] = { 0 }; -#else Word32 powerSpectrum[L_FRAME_MAX]; -#endif Word16 invScaleFactors[FDNS_NPTS]; Word16 invScaleFactors_exp[FDNS_NPTS]; Word16 powerSpectrum_exp, tmp_exp, old_exp; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; + move32(); #endif // Word16 nBands; Word32 invScaleFactors_fx[FDNS_NPTS]; Word16 old_power_spectrum_q, power_spectrum_q; + set32_fx( powerSpectrum, 0, L_FRAME_MAX ); + nSamples = hTonalMDCTConc->nNonZeroSamples; move16(); @@ -783,22 +782,6 @@ static void ivas_CalcPowerSpecAndDetectTonalComponents_fx( set32_fx( powerSpectrum + hTonalMDCTConc->nSamples, 0, sub( hTonalMDCTConc->nSamplesCore, hTonalMDCTConc->nSamples ) ); } - // DetectTonalComponents(hTonalMDCTConc->pTCI->indexOfTonalPeak, - // hTonalMDCTConc->pTCI->lowerIndex, - // hTonalMDCTConc->pTCI->upperIndex, - // &hTonalMDCTConc->pTCI->numIndexes, - // hTonalMDCTConc->lastPitchLag, - // pitchLag, - // hTonalMDCTConc->lastBlockData.spectralData, - // add(hTonalMDCTConc->lastBlockData.spectralData_exp,hTonalMDCTConc->lastBlockData.gain_tcx_exp), - // hTonalMDCTConc->lastBlockData.scaleFactors, - // hTonalMDCTConc->lastBlockData.scaleFactors_exp, - // hTonalMDCTConc->lastBlockData.scaleFactors_max_e, - // powerSpectrum, - // nSamples, - // hTonalMDCTConc->nSamplesCore, - // floorPowerSpectrum); - ivas_DetectTonalComponents_fx( (Word16 *) hTonalMDCTConc->pTCI->indexOfTonalPeak, (Word16 *) hTonalMDCTConc->pTCI->lowerIndex, (Word16 *) hTonalMDCTConc->pTCI->upperIndex, @@ -820,15 +803,16 @@ static void ivas_CalcPowerSpecAndDetectTonalComponents_fx( IF( hTonalMDCTConc->pTCI->numIndexes > 0 ) { - hTonalMDCTConc->secondLastPowerSpectrum = hTonalMDCTConc->secondLastBlockData.spectralData; /*sqrtFLOAT(powerSpectrum, powerSpectrum, nSamples);*/ old_exp = powerSpectrum_exp; + move16(); powerSpectrum_exp = mult_r( sub( powerSpectrum_exp, 2 ), 1 << 14 ); /*remove 2 bits of headroom from CalcPowerSpec*/ FOR( i = 0; i < nSamples; i++ ) { tmp_exp = old_exp; + move16(); powerSpectrum[i] = Sqrt32( powerSpectrum[i], &tmp_exp ); powerSpectrum[i] = L_shr( powerSpectrum[i], sub( powerSpectrum_exp, tmp_exp ) ); move32(); @@ -842,9 +826,9 @@ static void ivas_CalcPowerSpecAndDetectTonalComponents_fx( invScaleFactors[i] = Inv16( hTonalMDCTConc->secondLastBlockData.scaleFactors[i], &invScaleFactors_exp[i] ); } - - power_spectrum_q = 31 - powerSpectrum_exp; + power_spectrum_q = sub( 31, powerSpectrum_exp ); old_power_spectrum_q = power_spectrum_q; + move16(); /* here mdct_shaping() is intentionally used rather then mdct_shaping_16() */ IF( psychParamsCurrent == NULL ) { @@ -854,22 +838,25 @@ static void ivas_CalcPowerSpecAndDetectTonalComponents_fx( { FOR( i = 0; i < FDNS_NPTS; i++ ) { - invScaleFactors_fx[i] = L_shl( invScaleFactors[i], 1 + invScaleFactors_exp[i] ); // Q16 + invScaleFactors_fx[i] = L_shl( invScaleFactors[i], add( 1, invScaleFactors_exp[i] ) ); // Q16 + move32(); } sns_shape_spectrum_fx( powerSpectrum, &power_spectrum_q, psychParamsCurrent, invScaleFactors_fx, 16, hTonalMDCTConc->nSamplesCore ); - power_spectrum_q++; + power_spectrum_q = add( power_spectrum_q, 1 ); // sns_shape_spectrum(powerSpectrum, psychParamsCurrent, invScaleFactors, hTonalMDCTConc->nSamplesCore); // nBands = psychParamsCurrent->nBands; } - IF( old_power_spectrum_q < power_spectrum_q ) - Scale_sig32( powerSpectrum, hTonalMDCTConc->nSamplesCore, old_power_spectrum_q - power_spectrum_q ); + IF( LT_16( old_power_spectrum_q, power_spectrum_q ) ) + { + Scale_sig32( powerSpectrum, hTonalMDCTConc->nSamplesCore, sub( old_power_spectrum_q, power_spectrum_q ) ); + } ELSE { - Scale_sig32( powerSpectrum + hTonalMDCTConc->nSamplesCore, nSamples - hTonalMDCTConc->nSamplesCore, power_spectrum_q - old_power_spectrum_q ); - powerSpectrum_exp = 31 - power_spectrum_q; + Scale_sig32( powerSpectrum + hTonalMDCTConc->nSamplesCore, sub( nSamples, hTonalMDCTConc->nSamplesCore ), sub( power_spectrum_q, old_power_spectrum_q ) ); + powerSpectrum_exp = sub( 31, power_spectrum_q ); } Scale_sig32( powerSpectrum, nSamples, -3 ); /*Adding guard bits*/ - powerSpectrum_exp += 3; + powerSpectrum_exp = add( powerSpectrum_exp, 3 ); FOR( i = hTonalMDCTConc->nSamplesCore; i < nSamples; i++ ) { powerSpectrum[i] = L_shl( Mpy_32_16_1( powerSpectrum[i], invScaleFactors[FDNS_NPTS - 1] ), invScaleFactors_exp[FDNS_NPTS - 1] ); @@ -884,6 +871,7 @@ static void ivas_CalcPowerSpecAndDetectTonalComponents_fx( #else hTonalMDCTConc->secondLastPowerSpectrum[i] = round_fx( powerSpectrum[i] ); #endif + move32(); } powerSpectrum_exp = sub( powerSpectrum_exp, hTonalMDCTConc->secondLastBlockData.gain_tcx_exp ); @@ -916,6 +904,7 @@ static void CalcPowerSpecAndDetectTonalComponents( Word16 powerSpectrum_exp, tmp_exp, old_exp; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; + move32(); #endif @@ -973,10 +962,12 @@ static void CalcPowerSpecAndDetectTonalComponents( /*sqrtFLOAT(powerSpectrum, powerSpectrum, nSamples);*/ old_exp = powerSpectrum_exp; + move16(); powerSpectrum_exp = mult_r( sub( powerSpectrum_exp, 2 ), 1 << 14 ); /*remove 2 bits of headroom from CalcPowerSpec*/ FOR( i = 0; i < nSamples; i++ ) { tmp_exp = old_exp; + move16(); powerSpectrum[i] = Sqrt32( powerSpectrum[i], &tmp_exp ); powerSpectrum[i] = L_shr( powerSpectrum[i], sub( powerSpectrum_exp, tmp_exp ) ); move32(); @@ -1024,6 +1015,7 @@ static void CalcPowerSpecAndDetectTonalComponents( #else hTonalMDCTConc->secondLastPowerSpectrum[i] = round_fx( powerSpectrum[i] ); #endif + move32(); } powerSpectrum_exp = sub( powerSpectrum_exp, hTonalMDCTConc->secondLastBlockData.gain_tcx_exp ); @@ -1083,7 +1075,9 @@ void TonalMDCTConceal_Detect( nSamples = hTonalMDCTConc->nSamples; move16(); secondLastMDST_exp = 16; /*time signal Q-1*/ + move16(); secondLastMDCT_exp = 16; /*time signal Q-1*/ + move16(); test(); test(); test(); @@ -1100,6 +1094,7 @@ void TonalMDCTConceal_Detect( CalcMDXT( hTonalMDCTConc, 0, hTonalMDCTConc->secondLastPcmOut, secondLastMDST, &secondLastMDST_exp ); CalcMDXT( hTonalMDCTConc, 1, hTonalMDCTConc->secondLastPcmOut, secondLastMDCT, &secondLastMDCT_exp ); hTonalMDCTConc->nNonZeroSamples = 0; + move16(); FOR( i = 0; i < hTonalMDCTConc->nSamples; i++ ) { if ( hTonalMDCTConc->secondLastBlockData.spectralData[i] != 0 ) @@ -1220,7 +1215,9 @@ void TonalMDCTConceal_Detect_ivas_fx( nSamples = hTonalMDCTConc->nSamples; move16(); secondLastMDST_exp = 16; /*time signal Q-1*/ + move16(); secondLastMDCT_exp = 16; /*time signal Q-1*/ + move16(); test(); test(); test(); @@ -1237,6 +1234,7 @@ void TonalMDCTConceal_Detect_ivas_fx( CalcMDXT( hTonalMDCTConc, 0, hTonalMDCTConc->secondLastPcmOut, secondLastMDST, &secondLastMDST_exp ); CalcMDXT( hTonalMDCTConc, 1, hTonalMDCTConc->secondLastPcmOut, secondLastMDCT, &secondLastMDCT_exp ); hTonalMDCTConc->nNonZeroSamples = 0; + move16(); FOR( i = 0; i < hTonalMDCTConc->nSamples; i++ ) { if ( hTonalMDCTConc->secondLastBlockData.spectralData[i] != 0 ) @@ -1270,7 +1268,6 @@ void TonalMDCTConceal_Detect_ivas_fx( } secondLastMDCT_exp = sub( secondLastMDCT_exp, s ); move16(); - // CalcPowerSpecAndDetectTonalComponents(hTonalMDCTConc, secondLastMDST, secondLastMDST_exp, secondLastMDCT, secondLastMDCT_exp, pitchLag); ivas_CalcPowerSpecAndDetectTonalComponents_fx( hTonalMDCTConc, secondLastMDST, secondLastMDST_exp, secondLastMDCT, secondLastMDCT_exp, pitchLag, psychParamsCurrent, element_mode ); } ELSE @@ -1287,14 +1284,13 @@ void TonalMDCTConceal_Detect_ivas_fx( } ELSE { - // sns_shape_spectrum(powerSpectrum, psychParamsCurrent, hTonalMDCTConc->secondLastBlockData.scaleFactors, hTonalMDCTConc->nSamplesCore); Word16 power_spectrum_q; FOR( i = 0; i < FDNS_NPTS; i++ ) { - sns_int_scf_fx[i] = L_shl( hTonalMDCTConc->secondLastBlockData.scaleFactors[i], 1 + hTonalMDCTConc->secondLastBlockData.scaleFactors_exp[i] ); // Q16 + sns_int_scf_fx[i] = L_shl( hTonalMDCTConc->secondLastBlockData.scaleFactors[i], add( 1, hTonalMDCTConc->secondLastBlockData.scaleFactors_exp[i] ) ); // Q16 + move32(); } sns_shape_spectrum_fx( powerSpectrum, &power_spectrum_q, psychParamsCurrent, sns_int_scf_fx, 16, hTonalMDCTConc->nSamplesCore ); - // nBands = psychParamsCurrent->nBands; } powerSpectrum_exp = getScaleFactor32( powerSpectrum, nSamples ); powerSpectrum_exp = sub( powerSpectrum_exp, 3 ); /*extra 3 bits of headroom for MA filter in getEnvelope*/ @@ -1365,7 +1361,7 @@ void TonalMDCTConceal_InsertNoise_ivas_fx( Word16 last_block_nrg_correct_e; crossfadeGain = crossfadeGain_const; - + move16(); push_wmops( "InsertNoise" ); g = sub( MAX16B, crossfadeGain ); @@ -1373,10 +1369,12 @@ void TonalMDCTConceal_InsertNoise_ivas_fx( IF( !hTonalMDCTConc->lastBlockData.blockIsConcealed ) { rnd = 1977; + move16(); } ELSE { rnd = *pSeed; + move16(); } /* based on what is done in tcx_noise_filling() */ @@ -1384,6 +1382,7 @@ void TonalMDCTConceal_InsertNoise_ivas_fx( hTonalMDCTConc->faded_signal_nrg = L_deposit_h( 0 ); L_tmp = 805306368l /*0.375f Q31*/; + move32(); inv_exp = 15; move16(); inv_samples = Inv16( hTonalMDCTConc->lastBlockData.nSamples, &inv_exp ); @@ -1401,8 +1400,10 @@ void TonalMDCTConceal_InsertNoise_ivas_fx( nrgWhiteNoise = L_deposit_h( 0 ); last_block_nrg_correct = L_deposit_h( 0 ); last_block_nrg_correct_e = 0; - + move16(); exp_last = exp_noise = 0; + move16(); + move16(); IF( !hTonalMDCTConc->lastBlockData.blockIsValid ) { @@ -1421,19 +1422,23 @@ void TonalMDCTConceal_InsertNoise_ivas_fx( IF( GT_32( concealment_noise[i], 0 ) ) { mdctSpectrum[i] = L_shl( L_deposit_l( hTonalMDCTConc->lastBlockData.spectralData[i] ), 16 ); + move32(); } ELSE { mdctSpectrum[i] = L_negate( L_shl( L_deposit_l( hTonalMDCTConc->lastBlockData.spectralData[i] ), 16 ) ); + move32(); } } FOR( l = crossOverFreq; l < hTonalMDCTConc->lastBlockData.nSamples; l++ ) { mdctSpectrum[l] = L_shl( L_deposit_l( hTonalMDCTConc->lastBlockData.spectralData[l] ), 16 ); + move32(); } *mdctSpectrum_exp = hTonalMDCTConc->lastBlockData.spectralData_exp; + move16(); } /* actual fadeout is done in this case */ ELSE @@ -1442,7 +1447,9 @@ void TonalMDCTConceal_InsertNoise_ivas_fx( Word16 exp_num, exp_den; exp_num = cngLevelBackgroundTrace_bfi_e; + move16(); exp_den = hTonalMDCTConc->curr_noise_nrg_exp; + move16(); ld = norm_l( cngLevelBackgroundTrace_bfi ); num = L_shl( cngLevelBackgroundTrace_bfi, ld ); @@ -1481,16 +1488,20 @@ void TonalMDCTConceal_InsertNoise_ivas_fx( IF( exp < 0 ) { *mdctSpectrum_exp = SPEC_EXP_DEC; + move16(); } ELSE { exp = 0; + move16(); } FOR( i = 0; i < crossOverFreq; i++ ) { Word16 x = hTonalMDCTConc->lastBlockData.spectralData[i]; + move16(); Word32 y = concealment_noise[i]; + move32(); IF( GT_16( g, 0 ) ) { @@ -1537,14 +1548,16 @@ void TonalMDCTConceal_InsertNoise_ivas_fx( IF( LT_16( l, crossOverFreq ) ) { Word16 x = hTonalMDCTConc->lastBlockData.spectralData[l]; + move16(); Word32 y = concealment_noise[l]; + move32(); last_block_nrg_correct = L_add( last_block_nrg_correct, Mpy_32_16_1( L_msu( 0, x, fac ), x ) ); // exp = 2 * x_exp + ld y = L_negate( Mpy_32_32( y, y ) ); hTonalMDCTConc->curr_noise_nrg = BASOP_Util_Add_Mant32Exp( hTonalMDCTConc->curr_noise_nrg, hTonalMDCTConc->curr_noise_nrg_exp, y, 2 * concealment_noise_e, &hTonalMDCTConc->curr_noise_nrg_exp ); } } } - last_block_nrg_correct_e = hTonalMDCTConc->lastBlockData.spectralData_exp * 2 + ld; + last_block_nrg_correct_e = add( shl( hTonalMDCTConc->lastBlockData.spectralData_exp, 1 ), ld ); /* if fadeout has not started yet, only apply sign scrambling */ IF( GE_16( crossfadeGain, CROSSFADE_THRESHOLD ) ) @@ -1554,10 +1567,12 @@ void TonalMDCTConceal_InsertNoise_ivas_fx( IF( GT_32( concealment_noise[l], 0 ) ) { mdctSpectrum[l] = L_shl( L_deposit_l( hTonalMDCTConc->lastBlockData.spectralData[l] ), 16 ); + move32(); } ELSE { mdctSpectrum[l] = L_negate( L_shl( L_deposit_l( hTonalMDCTConc->lastBlockData.spectralData[l] ), 16 ) ); + move32(); } } FOR( i = 1; i < hTonalMDCTConc->pTCI->numIndexes; i++ ) @@ -1567,10 +1582,12 @@ void TonalMDCTConceal_InsertNoise_ivas_fx( IF( GT_32( concealment_noise[l], 0 ) ) { mdctSpectrum[l] = L_shl( L_deposit_l( hTonalMDCTConc->lastBlockData.spectralData[l] ), 16 ); + move32(); } ELSE { mdctSpectrum[l] = L_negate( L_shl( L_deposit_l( hTonalMDCTConc->lastBlockData.spectralData[l] ), 16 ) ); + move32(); } } } @@ -1580,19 +1597,23 @@ void TonalMDCTConceal_InsertNoise_ivas_fx( IF( GT_32( concealment_noise[l], 0 ) ) { mdctSpectrum[l] = L_shl( L_deposit_l( hTonalMDCTConc->lastBlockData.spectralData[l] ), 16 ); + move32(); } ELSE { mdctSpectrum[l] = L_negate( L_shl( L_deposit_l( hTonalMDCTConc->lastBlockData.spectralData[l] ), 16 ) ); + move32(); } } FOR( l = crossOverFreq; l < hTonalMDCTConc->lastBlockData.nSamples; l++ ) { mdctSpectrum[l] = L_shl( L_deposit_l( hTonalMDCTConc->lastBlockData.spectralData[l] ), 16 ); + move32(); } *mdctSpectrum_exp = hTonalMDCTConc->lastBlockData.spectralData_exp; + move16(); } /* actual fadeout is done in this case */ ELSE @@ -1601,7 +1622,9 @@ void TonalMDCTConceal_InsertNoise_ivas_fx( Word16 exp_num, exp_den; exp_num = cngLevelBackgroundTrace_bfi_e; + move16(); exp_den = hTonalMDCTConc->curr_noise_nrg_exp; + move16(); ld = norm_l( cngLevelBackgroundTrace_bfi ); num = L_shl( cngLevelBackgroundTrace_bfi, ld ); @@ -1628,6 +1651,7 @@ void TonalMDCTConceal_InsertNoise_ivas_fx( { g = shr( g, exp ); *mdctSpectrum_exp = hTonalMDCTConc->lastBlockData.spectralData_exp; + move16(); } ELSE { @@ -1640,16 +1664,20 @@ void TonalMDCTConceal_InsertNoise_ivas_fx( IF( exp < 0 ) { *mdctSpectrum_exp = SPEC_EXP_DEC; + move16(); } ELSE { exp = 0; + move16(); } FOR( l = 0; l < hTonalMDCTConc->pTCI->lowerIndex[0]; l++ ) { Word16 x = hTonalMDCTConc->lastBlockData.spectralData[l]; + move16(); Word32 y = concealment_noise[l]; + move32(); IF( GT_16( g, 0 ) ) { @@ -1672,7 +1700,9 @@ void TonalMDCTConceal_InsertNoise_ivas_fx( FOR( l = hTonalMDCTConc->pTCI->upperIndex[i - 1] + 1; l < hTonalMDCTConc->pTCI->lowerIndex[i]; l++ ) { Word16 x = hTonalMDCTConc->lastBlockData.spectralData[l]; + move16(); Word32 y = concealment_noise[l]; + move32(); L_tmp = Mpy_32_16_1( y, g ); L_tmp2 = L_msu( L_tmp, crossfadeGain, x ); @@ -1681,6 +1711,7 @@ void TonalMDCTConceal_InsertNoise_ivas_fx( L_tmp2 = L_mac( L_tmp, crossfadeGain, x ); } mdctSpectrum[l] = L_shl( L_tmp2, exp ); + move32(); hTonalMDCTConc->faded_signal_nrg = L_add( hTonalMDCTConc->faded_signal_nrg, Mpy_32_32( mdctSpectrum[l], mdctSpectrum[l] ) ); } @@ -1689,7 +1720,9 @@ void TonalMDCTConceal_InsertNoise_ivas_fx( FOR( l = hTonalMDCTConc->pTCI->upperIndex[hTonalMDCTConc->pTCI->numIndexes - 1] + 1; l < crossOverFreq; l++ ) { Word16 x = hTonalMDCTConc->lastBlockData.spectralData[l]; + move16(); Word32 y = concealment_noise[l]; + move32(); L_tmp = Mpy_32_16_1( y, g ); L_tmp2 = L_msu( L_tmp, crossfadeGain, x ); @@ -1698,6 +1731,7 @@ void TonalMDCTConceal_InsertNoise_ivas_fx( L_tmp2 = L_mac( L_tmp, crossfadeGain, x ); } mdctSpectrum[l] = L_shl( L_tmp2, exp ); + move32(); hTonalMDCTConc->faded_signal_nrg = L_add( hTonalMDCTConc->faded_signal_nrg, Mpy_32_32( mdctSpectrum[l], mdctSpectrum[l] ) ); } @@ -1705,6 +1739,7 @@ void TonalMDCTConceal_InsertNoise_ivas_fx( FOR( l = crossOverFreq; l < hTonalMDCTConc->lastBlockData.nSamples; l++ ) { mdctSpectrum[l] = L_deposit_h( 0 ); + move32(); } hTonalMDCTConc->faded_signal_nrg_exp = shl( *mdctSpectrum_exp, 1 ); @@ -1715,7 +1750,7 @@ void TonalMDCTConceal_InsertNoise_ivas_fx( Flag flag; flag = EQ_16( hTonalMDCTConc->curr_noise_nrg_exp, 0 ) && GT_32( hTonalMDCTConc->curr_noise_nrg, MDCT_ST_PLC_FADEOUT_MIN_NOISE_NRG_Q31 ); flag = flag || GT_16( hTonalMDCTConc->curr_noise_nrg_exp, 0 ); - + test(); IF( GT_32( hTonalMDCTConc->faded_signal_nrg, 0 ) && flag ) { Word16 num_exp, den_exp; @@ -1724,7 +1759,9 @@ void TonalMDCTConceal_InsertNoise_ivas_fx( num = BASOP_Util_Add_Mant32Exp( hTonalMDCTConc->last_block_nrg, hTonalMDCTConc->last_block_nrg_exp, L_negate( last_block_nrg_correct ), last_block_nrg_correct_e, &num_exp ); den = hTonalMDCTConc->faded_signal_nrg; + move32(); den_exp = hTonalMDCTConc->faded_signal_nrg_exp; + move16(); ld = norm_l( num ); num = L_shl( num, ld ); @@ -1747,6 +1784,7 @@ void TonalMDCTConceal_InsertNoise_ivas_fx( FOR( i = 0; i < crossOverFreq; i++ ) { mdctSpectrum[i] = Mpy_32_16_1( mdctSpectrum[i], tmp ); + move32(); } *mdctSpectrum_exp = add( *mdctSpectrum_exp, exp ); } @@ -1777,6 +1815,7 @@ void TonalMDCTConceal_InsertNoise_ivas_fx( { set32_fx( mdctSpectrum, 0, crossOverFreq ); *mdctSpectrum_exp = SPEC_EXP_DEC; + move16(); } ELSE { @@ -1794,7 +1833,7 @@ void TonalMDCTConceal_InsertNoise_ivas_fx( exp = sub( exp_last, exp_noise ); - IF( nrgNoiseInLastFrame > nrgWhiteNoise ) + IF( GT_32( nrgNoiseInLastFrame, nrgWhiteNoise ) ) { nrgNoiseInLastFrame = L_shr( nrgNoiseInLastFrame, 1 ); exp = add( exp, 1 ); @@ -1811,6 +1850,7 @@ void TonalMDCTConceal_InsertNoise_ivas_fx( { g = shr( g, exp ); *mdctSpectrum_exp = hTonalMDCTConc->lastBlockData.spectralData_exp; + move16(); } ELSE { @@ -1823,18 +1863,22 @@ void TonalMDCTConceal_InsertNoise_ivas_fx( IF( exp < 0 ) { *mdctSpectrum_exp = SPEC_EXP_DEC; + move16(); } ELSE { exp = 0; + move16(); } } FOR( i = 0; i < crossOverFreq; i++ ) { Word16 const x = hTonalMDCTConc->lastBlockData.spectralData[i]; + move16(); Word32 const y = mdctSpectrum[i]; + move32(); - IF( GT_16( g, 0 ) ) + IF( g > 0 ) { L_tmp = Mpy_32_16_1( y, g ); } @@ -1868,6 +1912,7 @@ ELSE FOR( l = 0; l < hTonalMDCTConc->pTCI->lowerIndex[0]; l++ ) { Word16 x = hTonalMDCTConc->lastBlockData.spectralData[l]; + move16(); Word32 y; rnd = extract_l( L_mac0( 13849, rnd, 31821 ) ); @@ -1885,17 +1930,19 @@ ELSE FOR( i = 1; i < hTonalMDCTConc->pTCI->numIndexes; i++ ) { - tmp = round_fx( BASOP_Util_fPow( L_deposit_h( tiltFactor ), 0, L_deposit_h( hTonalMDCTConc->pTCI->upperIndex[i - 1] - hTonalMDCTConc->pTCI->lowerIndex[i - 1] + 1 ), 15, &exp ) ); + tmp = round_fx( BASOP_Util_fPow( L_deposit_h( tiltFactor ), 0, L_deposit_h( (UWord16) L_add( L_sub( hTonalMDCTConc->pTCI->upperIndex[i - 1], hTonalMDCTConc->pTCI->lowerIndex[i - 1] ), 1 ) ), 15, &exp ) ); tmp = shl( tmp, exp ); tilt = mult_r( tilt, tmp ); // Q15 FOR( l = hTonalMDCTConc->pTCI->lowerIndex[i]; l <= hTonalMDCTConc->pTCI->upperIndex[i]; l++ ) { mdctSpectrum[l] = L_deposit_l( 0 ); + move32(); } FOR( l = hTonalMDCTConc->pTCI->upperIndex[i - 1] + 1; l < hTonalMDCTConc->pTCI->lowerIndex[i]; l++ ) { Word16 x = hTonalMDCTConc->lastBlockData.spectralData[l]; + move16(); Word32 y; rnd = extract_l( L_mac0( 13849, rnd, 31821 ) ); @@ -1913,7 +1960,7 @@ ELSE } tmp = round_fx( BASOP_Util_fPow( L_deposit_h( tiltFactor ), 0, - L_deposit_h( hTonalMDCTConc->pTCI->upperIndex[hTonalMDCTConc->pTCI->numIndexes - 1] - hTonalMDCTConc->pTCI->lowerIndex[hTonalMDCTConc->pTCI->numIndexes - 1] + 1 ), 15, &exp ) ); + L_deposit_h( extract_l( L_add( L_sub( hTonalMDCTConc->pTCI->upperIndex[hTonalMDCTConc->pTCI->numIndexes - 1], hTonalMDCTConc->pTCI->lowerIndex[hTonalMDCTConc->pTCI->numIndexes - 1] ), 1 ) ) ), 15, &exp ) ); BASOP_SATURATE_WARNING_OFF_EVS /*next op may result in 32768*/ #ifdef BASOP_NOGLOB tmp = shl_sat( tmp, exp ); @@ -1926,6 +1973,7 @@ ELSE FOR( l = add( hTonalMDCTConc->pTCI->upperIndex[hTonalMDCTConc->pTCI->numIndexes - 1], 1 ); l < crossOverFreq; l++ ) { Word16 x = hTonalMDCTConc->lastBlockData.spectralData[l]; + move16(); Word32 y; rnd = extract_l( L_mac0( 13849, rnd, 31821 ) ); y = L_mult( tilt, rnd ); @@ -1944,6 +1992,7 @@ ELSE { set32_fx( mdctSpectrum, 0, crossOverFreq ); *mdctSpectrum_exp = SPEC_EXP_DEC; + move16(); } ELSE { @@ -1959,7 +2008,7 @@ ELSE exp = sub( exp_last, exp_noise ); - IF( nrgNoiseInLastFrame > nrgWhiteNoise ) + IF( GT_32( nrgNoiseInLastFrame, nrgWhiteNoise ) ) { nrgNoiseInLastFrame = L_shr( nrgNoiseInLastFrame, 1 ); exp = add( exp, 1 ); @@ -1975,6 +2024,7 @@ ELSE { g = shr( g, exp ); *mdctSpectrum_exp = hTonalMDCTConc->lastBlockData.spectralData_exp; + move16(); } ELSE { @@ -1987,16 +2037,20 @@ ELSE IF( exp < 0 ) { *mdctSpectrum_exp = SPEC_EXP_DEC; + move16(); } ELSE { exp = 0; + move16(); } FOR( l = 0; l < hTonalMDCTConc->pTCI->lowerIndex[0]; l++ ) { Word16 const x = hTonalMDCTConc->lastBlockData.spectralData[l]; + move16(); Word32 const y = mdctSpectrum[l]; + move32(); IF( GT_16( g, 0 ) ) { @@ -2017,7 +2071,9 @@ ELSE FOR( l = hTonalMDCTConc->pTCI->upperIndex[i - 1] + 1; l < hTonalMDCTConc->pTCI->lowerIndex[i]; l++ ) { Word16 const x = hTonalMDCTConc->lastBlockData.spectralData[l]; + move16(); Word32 const y = mdctSpectrum[l]; + move32(); IF( GT_16( g, 0 ) ) { @@ -2043,13 +2099,16 @@ ELSE FOR( l = hTonalMDCTConc->pTCI->lowerIndex[i]; l <= hTonalMDCTConc->pTCI->upperIndex[i]; l++ ) { mdctSpectrum[l] = L_deposit_l( 0 ); + move32(); } } FOR( l = add( hTonalMDCTConc->pTCI->upperIndex[hTonalMDCTConc->pTCI->numIndexes - 1], 1 ); l < crossOverFreq; l++ ) { Word16 const x = hTonalMDCTConc->lastBlockData.spectralData[l]; + move16(); Word32 const y = mdctSpectrum[l]; + move32(); IF( GT_16( g, 0 ) ) { @@ -2075,6 +2134,7 @@ ELSE } *pSeed = rnd; +move16(); pop_wmops(); @@ -2128,6 +2188,7 @@ void TonalMDCTConceal_InsertNoise( /* may just become active if the very first frame is lost */ set32_fx( mdctSpectrum, 0, hTonalMDCTConc->nSamples ); *mdctSpectrum_exp = SPEC_EXP_DEC; + move16(); } #ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT else if ( concealment_noise != NULL ) @@ -2323,6 +2384,7 @@ void TonalMDCTConceal_InsertNoise( { #ifndef IVAS_CODE_CNG_FIX185_PLC_FADEOUT L_tmp = 805306368l /*0.375f Q31*/; + move32(); inv_exp = 15; move16(); inv_samples = Inv16( hTonalMDCTConc->lastBlockData.nSamples, &inv_exp ); @@ -2352,6 +2414,7 @@ void TonalMDCTConceal_InsertNoise( FOR( i = 0; i < crossOverFreq; i++ ) { Word16 x = hTonalMDCTConc->lastBlockData.spectralData[i]; + move16(); Word32 y; rnd = extract_l( L_mac0( 13849, rnd, 31821 ) ); y = L_mult( tilt, rnd ); @@ -2370,6 +2433,7 @@ void TonalMDCTConceal_InsertNoise( { set32_fx( mdctSpectrum, 0, crossOverFreq ); *mdctSpectrum_exp = SPEC_EXP_DEC; + move16(); } ELSE { @@ -2387,7 +2451,7 @@ void TonalMDCTConceal_InsertNoise( exp = sub( exp_last, exp_noise ); - IF( nrgNoiseInLastFrame > nrgWhiteNoise ) + IF( GT_32( nrgNoiseInLastFrame, nrgWhiteNoise ) ) { nrgNoiseInLastFrame = L_shr( nrgNoiseInLastFrame, 1 ); exp = add( exp, 1 ); @@ -2404,6 +2468,7 @@ void TonalMDCTConceal_InsertNoise( { g = shr( g, exp ); *mdctSpectrum_exp = hTonalMDCTConc->lastBlockData.spectralData_exp; + move16(); } ELSE { @@ -2416,17 +2481,21 @@ void TonalMDCTConceal_InsertNoise( IF( exp < 0 ) { *mdctSpectrum_exp = SPEC_EXP_DEC; + move16(); } ELSE { exp = 0; + move16(); } } FOR( i = 0; i < crossOverFreq; i++ ) { Word16 const x = hTonalMDCTConc->lastBlockData.spectralData[i]; + move16(); Word32 const y = mdctSpectrum[i]; + move32(); if ( g > 0 ) { @@ -2457,6 +2526,7 @@ void TonalMDCTConceal_InsertNoise( FOR( l = hTonalMDCTConc->pTCI->lowerIndex[0]; l <= hTonalMDCTConc->pTCI->upperIndex[0]; l++ ) { mdctSpectrum[l] = L_deposit_l( 0 ); + move32(); } ld = sub( 14, norm_s( hTonalMDCTConc->lastBlockData.nSamples ) ); @@ -2464,6 +2534,7 @@ void TonalMDCTConceal_InsertNoise( FOR( l = 0; l < hTonalMDCTConc->pTCI->lowerIndex[0]; l++ ) { Word16 x = hTonalMDCTConc->lastBlockData.spectralData[l]; + move16(); Word32 y; rnd = extract_l( L_mac0( 13849, rnd, 31821 ) ); y = L_mult( tilt, rnd ); @@ -2481,18 +2552,20 @@ void TonalMDCTConceal_InsertNoise( FOR( i = 1; i < hTonalMDCTConc->pTCI->numIndexes; i++ ) { /*tilt *= (float)pow(tiltFactor, hTonalMDCTConc->pTCI->upperIndex[i-1]-hTonalMDCTConc->pTCI->lowerIndex[i-1]+1);*/ - tmp = round_fx( BASOP_Util_fPow( L_deposit_h( tiltFactor ), 0, L_deposit_h( hTonalMDCTConc->pTCI->upperIndex[i - 1] - hTonalMDCTConc->pTCI->lowerIndex[i - 1] + 1 ), 15, &exp ) ); + tmp = round_fx( BASOP_Util_fPow( L_deposit_h( tiltFactor ), 0, L_deposit_h( (UWord16) L_add( L_sub( hTonalMDCTConc->pTCI->upperIndex[i - 1], hTonalMDCTConc->pTCI->lowerIndex[i - 1] ), 1 ) ), 15, &exp ) ); tmp = shl( tmp, exp ); tilt = mult_r( tilt, tmp ); FOR( l = hTonalMDCTConc->pTCI->lowerIndex[i]; l <= hTonalMDCTConc->pTCI->upperIndex[i]; l++ ) { mdctSpectrum[l] = L_deposit_l( 0 ); + move32(); } FOR( l = hTonalMDCTConc->pTCI->upperIndex[i - 1] + 1; l < hTonalMDCTConc->pTCI->lowerIndex[i]; l++ ) { Word16 x = hTonalMDCTConc->lastBlockData.spectralData[l]; + move16(); Word32 y; rnd = extract_l( L_mac0( 13849, rnd, 31821 ) ); y = L_mult( tilt, rnd ); @@ -2508,7 +2581,7 @@ void TonalMDCTConceal_InsertNoise( } } - tmp = round_fx( BASOP_Util_fPow( L_deposit_h( tiltFactor ), 0, L_deposit_h( hTonalMDCTConc->pTCI->upperIndex[hTonalMDCTConc->pTCI->numIndexes - 1] - hTonalMDCTConc->pTCI->lowerIndex[hTonalMDCTConc->pTCI->numIndexes - 1] + 1 ), 15, &exp ) ); + tmp = round_fx( BASOP_Util_fPow( L_deposit_h( tiltFactor ), 0, L_deposit_h( (UWord16) L_add( L_sub( hTonalMDCTConc->pTCI->upperIndex[hTonalMDCTConc->pTCI->numIndexes - 1], hTonalMDCTConc->pTCI->lowerIndex[hTonalMDCTConc->pTCI->numIndexes - 1] ), 1 ) ), 15, &exp ) ); BASOP_SATURATE_WARNING_OFF_EVS /*next op may result in 32768*/ #ifdef BASOP_NOGLOB tmp = shl_sat( tmp, exp ); @@ -2521,6 +2594,7 @@ void TonalMDCTConceal_InsertNoise( FOR( l = add( hTonalMDCTConc->pTCI->upperIndex[hTonalMDCTConc->pTCI->numIndexes - 1], 1 ); l < crossOverFreq; l++ ) { Word16 x = hTonalMDCTConc->lastBlockData.spectralData[l]; + move16(); Word32 y; rnd = extract_l( L_mac0( 13849, rnd, 31821 ) ); y = L_mult( tilt, rnd ); @@ -2539,6 +2613,7 @@ void TonalMDCTConceal_InsertNoise( { set32_fx( mdctSpectrum, 0, crossOverFreq ); *mdctSpectrum_exp = SPEC_EXP_DEC; + move16(); } ELSE { @@ -2554,7 +2629,7 @@ void TonalMDCTConceal_InsertNoise( exp = sub( exp_last, exp_noise ); - IF( nrgNoiseInLastFrame > nrgWhiteNoise ) + IF( GT_32( nrgNoiseInLastFrame, nrgWhiteNoise ) ) { nrgNoiseInLastFrame = L_shr( nrgNoiseInLastFrame, 1 ); exp = add( exp, 1 ); @@ -2570,6 +2645,7 @@ void TonalMDCTConceal_InsertNoise( { g = shr( g, exp ); *mdctSpectrum_exp = hTonalMDCTConc->lastBlockData.spectralData_exp; + move16(); } ELSE { @@ -2583,16 +2659,20 @@ void TonalMDCTConceal_InsertNoise( IF( exp < 0 ) { *mdctSpectrum_exp = SPEC_EXP_DEC; + move16(); } ELSE { exp = 0; + move16(); } FOR( l = 0; l < hTonalMDCTConc->pTCI->lowerIndex[0]; l++ ) { Word16 const x = hTonalMDCTConc->lastBlockData.spectralData[l]; + move16(); Word32 const y = mdctSpectrum[l]; + move32(); if ( g > 0 ) { @@ -2613,7 +2693,9 @@ void TonalMDCTConceal_InsertNoise( FOR( l = hTonalMDCTConc->pTCI->upperIndex[i - 1] + 1; l < hTonalMDCTConc->pTCI->lowerIndex[i]; l++ ) { Word16 const x = hTonalMDCTConc->lastBlockData.spectralData[l]; + move16(); Word32 const y = mdctSpectrum[l]; + move32(); if ( g > 0 ) { @@ -2639,13 +2721,16 @@ void TonalMDCTConceal_InsertNoise( FOR( l = hTonalMDCTConc->pTCI->lowerIndex[i]; l <= hTonalMDCTConc->pTCI->upperIndex[i]; l++ ) { mdctSpectrum[l] = L_deposit_l( 0 ); + move32(); } } FOR( l = add( hTonalMDCTConc->pTCI->upperIndex[hTonalMDCTConc->pTCI->numIndexes - 1], 1 ); l < crossOverFreq; l++ ) { Word16 const x = hTonalMDCTConc->lastBlockData.spectralData[l]; + move16(); Word32 const y = mdctSpectrum[l]; + move32(); if ( g > 0 ) { @@ -2692,7 +2777,7 @@ void TonalMDCTConceal_Apply( Word16 nSamples; - IF( hTonalMDCTConc->lastBlockData.blockIsValid & hTonalMDCTConc->secondLastBlockData.blockIsValid ) + IF( s_and( hTonalMDCTConc->lastBlockData.blockIsValid, hTonalMDCTConc->secondLastBlockData.blockIsValid ) ) { assert( hTonalMDCTConc->pTCI->numIndexes > 0 ); @@ -2767,6 +2852,7 @@ void TonalMDCTConceal_Apply( mdctSpectrum[l] = Mpy_32_16_1( powerSpectrum[l], getCosWord16( extract_l( currentPhase ) ) ); move32(); mdctSpectrum[l] = L_shr( mdctSpectrum[l], exp ); + move32(); } } } @@ -2796,6 +2882,7 @@ void TonalMDCTConceal_Apply_ivas_fx( Word16 *tmp_secondLastPowerSpectrum = hTonalMDCTConc->secondLastPowerSpectrum; Word16 tmp_secondLastPowerSpectrum_exp = hTonalMDCTConc->secondLastPowerSpectrum_exp; + move16(); Word16 max_nSamples = s_max( hTonalMDCTConc->nNonZeroSamples, hTonalMDCTConc->nSamplesCore ); @@ -2806,9 +2893,10 @@ void TonalMDCTConceal_Apply_ivas_fx( FOR( i = 0; i < FDNS_NPTS; i++ ) { scaleFactors[i] = L_shr( L_deposit_h( hTonalMDCTConc->secondLastBlockData.scaleFactors[i] ), sub( hTonalMDCTConc->secondLastBlockData.scaleFactors_max_e, hTonalMDCTConc->secondLastBlockData.scaleFactors_exp[i] ) ); + move32(); } - IF( hTonalMDCTConc->lastBlockData.blockIsValid & hTonalMDCTConc->secondLastBlockData.blockIsValid ) + IF( s_and( hTonalMDCTConc->lastBlockData.blockIsValid, hTonalMDCTConc->secondLastBlockData.blockIsValid ) ) { assert( hTonalMDCTConc->pTCI->numIndexes > 0 ); @@ -2825,6 +2913,7 @@ void TonalMDCTConceal_Apply_ivas_fx( move16(); Word16 exp1 = powerSpectrum_exp; + move16(); IF( psychParamsCurrent == NULL ) { @@ -2844,6 +2933,7 @@ void TonalMDCTConceal_Apply_ivas_fx( FOR( Word16 c = 0; c < hTonalMDCTConc->nSamplesCore; c++ ) { powerSpectrum[c] = L_shr( powerSpectrum[c], 1 ); + move32(); } /* adding guard bit */ @@ -2851,6 +2941,7 @@ void TonalMDCTConceal_Apply_ivas_fx( FOR( Word16 c = 0; c < FDNS_NPTS; c++ ) { scaleFactors[c] = L_shr( scaleFactors[c], 1 ); + move32(); } sns_shape_spectrum_fx( powerSpectrum, &q_ps, psychParamsCurrent, scaleFactors, q_sf, hTonalMDCTConc->nSamplesCore ); @@ -2862,11 +2953,14 @@ void TonalMDCTConceal_Apply_ivas_fx( } Word16 exp_left = powerSpectrum_exp; + move16(); Word16 exp_right = exp1; + move16(); FOR( Word16 c = hTonalMDCTConc->nSamplesCore; c < nSamples; c++ ) { powerSpectrum[c] = Mpy_32_16_1( powerSpectrum[c], hTonalMDCTConc->secondLastBlockData.scaleFactors[nBands - 1] ); + move32(); } exp_right = add( exp_right, hTonalMDCTConc->secondLastBlockData.scaleFactors_exp[nBands - 1] ); @@ -2896,12 +2990,12 @@ void TonalMDCTConceal_Apply_ivas_fx( IF( !hTonalMDCTConc->lastBlockData.blockIsConcealed ) { - IF( hTonalMDCTConc->secondLastBlockData.tonalConcealmentActive != 0 ) + if ( hTonalMDCTConc->secondLastBlockData.tonalConcealmentActive != 0 ) { hTonalMDCTConc->nFramesLost = add( hTonalMDCTConc->nFramesLost, 2 ); /*Q1*/ move16(); } - IF( hTonalMDCTConc->secondLastBlockData.tonalConcealmentActive == 0 ) + if ( hTonalMDCTConc->secondLastBlockData.tonalConcealmentActive == 0 ) { hTonalMDCTConc->nFramesLost = 3; /*Q1*/ move16(); diff --git a/lib_dec/transition_dec.c b/lib_dec/transition_dec.c index c417947d7b00ab4a5d57c28c53df847e7426eabe..a219d8882e8b3482a48338765d3722d9e24a25b2 100644 --- a/lib_dec/transition_dec.c +++ b/lib_dec/transition_dec.c @@ -41,7 +41,7 @@ #include "rom_com.h" #include "prot.h" #include "wmc_auto.h" - +#ifndef IVAS_FLOAT_FIXED /*----------------------------------------------------------------------* * Local function prototypes *----------------------------------------------------------------------*/ @@ -764,3 +764,4 @@ int16_t tc_classif( return ( tc_subfr ); } +#endif diff --git a/lib_dec/transition_dec_fx.c b/lib_dec/transition_dec_fx.c index 7cd7820364185e5467c978434e44d8af0ca8af7c..46bb39bf9974d5ae801ec7b5f787f468f3982031 100644 --- a/lib_dec/transition_dec_fx.c +++ b/lib_dec/transition_dec_fx.c @@ -61,14 +61,15 @@ void transition_dec_fx( (void) ( Opt_AMR_WB ); #endif - i_subfridx = shr( i_subfr, 6 ); /*i_subfr / L_SUBFR*/ + i_subfridx = i_subfr / L_SUBFR; /*i_subfr / L_SUBFR*/ /* Set limit_flag to 0 for restrained limits, and 1 for extended limits */ limit_flag = 0; - + move16(); /*---------------------------------------------------------------------* * zero adaptive contribution (glottal shape codebook search not * in first subframe(s) ) *---------------------------------------------------------------------*/ + test(); IF( GT_16( tc_subfr, add( i_subfr, TC_0_192 ) ) ) { set16_fx( &exc[i_subfr], 0, L_SUBFR ); @@ -219,7 +220,7 @@ void transition_dec_fx( FOR( i = 0; i < L_SUBFR * HIBND_ACB_L_FAC; i++ ) { - bwe_exc[i + i_subfr * HIBND_ACB_L_FAC] = bwe_exc[i + i_subfr * HIBND_ACB_L_FAC - offset]; + bwe_exc[add( i, i_subfr * HIBND_ACB_L_FAC )] = bwe_exc[sub( add( i, i_subfr * HIBND_ACB_L_FAC ), offset )]; move16(); } } @@ -248,7 +249,7 @@ void transition_dec_fx( FOR( i = 0; i < L_SUBFR * HIBND_ACB_L_FAC; i++ ) { - bwe_exc[i + i_subfr * HIBND_ACB_L_FAC] = bwe_exc[i + i_subfr * HIBND_ACB_L_FAC - offset]; + bwe_exc[add( i, i_subfr * HIBND_ACB_L_FAC )] = bwe_exc[sub( add( i, i_subfr * HIBND_ACB_L_FAC ), offset )]; move16(); } } @@ -299,7 +300,7 @@ void transition_dec_fx( } /* biterror detection mechanism */ - IF( GT_16( add( ( *T0 << 2 ), *T0_frac ), add( ( PIT_MAX << 2 ), 2 ) ) ) + IF( GT_16( add( shl( *T0, 2 ), *T0_frac ), add( ( PIT_MAX << 2 ), 2 ) ) ) { *T0 = L_SUBFR; move16(); @@ -316,7 +317,8 @@ void transition_dec_fx( move16(); /* penality for 2 ptrs initialization */ FOR( i = 0; i < L_SUBFR * HIBND_ACB_L_FAC; i++ ) { - bwe_exc[i + i_subfr * HIBND_ACB_L_FAC] = bwe_exc[i + i_subfr * HIBND_ACB_L_FAC - offset]; + bwe_exc[add( i, i_subfr * HIBND_ACB_L_FAC )] = bwe_exc[sub( add( i, i_subfr * HIBND_ACB_L_FAC ), offset )]; + move16(); } } ELSE IF( ( EQ_16( i_subfr, 3 * L_SUBFR ) ) && ( EQ_16( tc_subfr, TC_0_128 ) ) ) @@ -337,7 +339,7 @@ void transition_dec_fx( move16(); /* penality for 2 ptrs initialization */ FOR( i = 0; i < L_SUBFR * HIBND_ACB_L_FAC; i++ ) { - bwe_exc[i + i_subfr * HIBND_ACB_L_FAC] = bwe_exc[i + i_subfr * HIBND_ACB_L_FAC - offset]; + bwe_exc[add( i, i_subfr * HIBND_ACB_L_FAC )] = bwe_exc[sub( add( i, i_subfr * HIBND_ACB_L_FAC ), offset )]; move16(); } } @@ -358,7 +360,7 @@ void transition_dec_fx( move16(); /* penality for 2 ptrs initialization */ FOR( i = 0; i < L_SUBFR * HIBND_ACB_L_FAC; i++ ) { - bwe_exc[i + i_subfr * HIBND_ACB_L_FAC] = bwe_exc[i + i_subfr * HIBND_ACB_L_FAC - offset]; + bwe_exc[add( i, i_subfr * HIBND_ACB_L_FAC )] = bwe_exc[sub( add( i, i_subfr * HIBND_ACB_L_FAC ), offset )]; move16(); } } @@ -455,7 +457,6 @@ void transition_dec_fx( } ELSE /* L_frame == L_FRAME16k */ { - test(); if ( GE_16( i_subfr, 2 * L_SUBFR ) ) { limit_flag = 1; @@ -512,7 +513,7 @@ void transition_dec_fx( } /* biterror detection mechanism */ - IF( GT_16( add( ( *T0 << 2 ), *T0_frac ), ( ( 2 * L_SUBFR ) << 2 ) ) ) + IF( GT_16( add( shl( *T0, 2 ), *T0_frac ), ( ( 2 * L_SUBFR ) << 2 ) ) ) { *T0 = L_SUBFR; move16(); @@ -554,7 +555,7 @@ void transition_dec_fx( { /* bwe_exc[i + i_subfr * 2] = bwe_exc[i + i_subfr * 2 - *T0 * 2 */ /* - (int) ((float) *T0_frac * 0.5f + 4 + 0.5f) + 4];*/ - bwe_exc[i + i_subfr * 2] = bwe_exc[i + i_subfr * 2 - offset]; + bwe_exc[add( i, i_subfr * 2 )] = bwe_exc[sub( add( i, i_subfr * 2 ), offset )]; } lp_filt_exc_dec_fx( st_fx, MODE1, i_subfr, L_SUBFR, L_frame, st_fx->acelp_cfg.ltf_mode, exc ); @@ -638,6 +639,7 @@ static void tc_dec_fx( Word16 index; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; + move32(); #endif /*----------------------------------------------------------------* * find the number of bits @@ -661,7 +663,7 @@ static void tc_dec_fx( *T0_frac = 0; move16(); } - ELSE IF( ( tc_subfr == 3 * L_SUBFR ) ) + ELSE IF( EQ_16( tc_subfr, 3 * L_SUBFR ) ) { i = (Word16) get_next_indice( st_fx, nBits ); @@ -756,6 +758,7 @@ static void tc_dec_fx( if ( imp_sign == 0 ) { gain_trans = negate( gain_trans ); + move16(); } /* local max for scaling need */ @@ -781,7 +784,7 @@ static void tc_dec_fx( move16(); /* penalty for exc + i_subfr initialisation */ FOR( i = 0; i < j; i++ ) { - exc[i + i_subfr] = 0; + exc[add( i, i_subfr )] = 0; move16(); } j = s_min( L_SUBFR, add( imp_pos, L_IMPULSE2 ) ); @@ -792,6 +795,7 @@ static void tc_dec_fx( #else exc[i + i_subfr] = round_fx( L_shl( L_mult( pt_shape[i], gain_trans ), sc ) ); /* (Qx * Q14 ) */ #endif + move16(); } FOR( ; i < L_SUBFR; i++ ) { @@ -836,7 +840,7 @@ Word16 tc_classif_fx( #endif IF( EQ_16( st_fx->L_frame, L_FRAME ) ) { - if ( get_next_indice( st_fx, 1 ) ) + IF( get_next_indice( st_fx, 1 ) ) { tc_subfr = TC_0_0; move16(); diff --git a/lib_dec/updt_dec_fx.c b/lib_dec/updt_dec_fx.c index fb846b91a9f6da889416b36ae7d7bf12a32201b1..a92130a62da642c24d702f1157b9c1a84bf18036 100644 --- a/lib_dec/updt_dec_fx.c +++ b/lib_dec/updt_dec_fx.c @@ -36,6 +36,7 @@ void updt_dec_fx( /* update old excitation buffer */ Copy( &old_exc_fx[st_fx->L_frame], st_fx->old_exc_fx, L_EXC_MEM_DEC ); + test(); IF( !st_fx->Opt_AMR_WB && hBWE_TD != NULL ) { Copy( &old_bwe_exc_fx[L_FRAME32k], hBWE_TD->old_bwe_exc_fx, PIT16k_MAX * 2 ); @@ -47,6 +48,7 @@ void updt_dec_fx( /* update last coding type */ st_fx->last_coder_type = st_fx->coder_type; + move16(); test(); test(); test(); @@ -55,11 +57,11 @@ void updt_dec_fx( st_fx->last_coder_type = UNVOICED; move16(); } - test(); - test(); IF( st_fx->hGSCDec != NULL ) { - IF( ( NE_16( st_fx->coder_type, AUDIO ) || st_fx->Last_GSC_noisy_speech_flag != 0 ) && st_fx->hGSCDec->Last_GSC_pit_band_idx > 0 ) + test(); + test(); + if ( ( NE_16( st_fx->coder_type, AUDIO ) || st_fx->Last_GSC_noisy_speech_flag != 0 ) && st_fx->hGSCDec->Last_GSC_pit_band_idx > 0 ) { st_fx->hGSCDec->Last_GSC_pit_band_idx = 0; move16(); /*The temporal contribution of the GSC is meaningless after 1 frame lost for inactive & unvoiced content */ @@ -100,7 +102,8 @@ void updt_dec_fx( } } test(); - IF( st_fx->hGSCDec != NULL && st_fx->coder_type != AUDIO && st_fx->coder_type != INACTIVE ) + test(); + IF( st_fx->hGSCDec != NULL && NE_16( st_fx->coder_type, AUDIO ) && NE_16( st_fx->coder_type, INACTIVE ) ) { st_fx->hGSCDec->noise_lev = NOISE_LEVEL_SP3; move16(); @@ -131,7 +134,7 @@ void updt_dec_fx( st_fx->old_pitch_buf_fx[len + i] = L_mult0( pitch_buf_fx[i], 1 << 10 ); move32(); } - Copy( &st_fx->mem_pitch_gain[2], &st_fx->mem_pitch_gain[st_fx->L_frame / L_SUBFR + 2], st_fx->L_frame / L_SUBFR ); + Copy( &st_fx->mem_pitch_gain[2], &st_fx->mem_pitch_gain[add( st_fx->L_frame / L_SUBFR, 2 )], st_fx->L_frame / L_SUBFR ); IF( EQ_16( st_fx->L_frame, L_FRAME ) ) { st_fx->mem_pitch_gain[2] = gain_buf[3]; @@ -189,7 +192,7 @@ void updt_dec_fx( move16(); /*core switching updates*/ - Copy( &Aq[( st_fx->L_frame / L_SUBFR - 1 ) * ( M + 1 )], st_fx->old_Aq_12_8_fx, M + 1 ); + Copy( &Aq[imult1616( sub( st_fx->L_frame / L_SUBFR, 1 ), ( M + 1 ) )], st_fx->old_Aq_12_8_fx, M + 1 ); st_fx->old_Es_pred_fx = Es_pred; move16(); @@ -233,13 +236,13 @@ void updt_IO_switch_dec_fx( } /* reset TD BWE buffers */ st_fx->last_voice_factor_fx = 0; + move16(); IF( hBWE_TD != NULL ) { set16_fx( hBWE_TD->old_bwe_exc_fx, 0, PIT16k_MAX * 2 ); set16_fx( hBWE_TD->old_bwe_exc_extended_fx, 0, NL_BUFF_OFFSET ); hBWE_TD->bwe_non_lin_prev_scale_fx = 0; move16(); - move16(); wb_tbe_extras_reset_fx( hBWE_TD->mem_genSHBexc_filt_down_wb2_fx, hBWE_TD->mem_genSHBexc_filt_down_wb3_fx ); wb_tbe_extras_reset_synth_fx( hBWE_TD->state_lsyn_filt_shb_fx, hBWE_TD->state_lsyn_filt_dwn_shb_fx, hBWE_TD->state_32and48k_WB_upsample_fx, hBWE_TD->mem_resamp_HB_fx ); @@ -249,7 +252,9 @@ void updt_IO_switch_dec_fx( hBWE_TD->syn_overlap_fx, hBWE_TD->state_syn_shbexc_fx, &hBWE_TD->tbe_demph_fx, &hBWE_TD->tbe_premph_fx, hBWE_TD->mem_stp_swb_fx, &( hBWE_TD->gain_prec_swb_fx ) ); set16_fx( st_fx->GainShape_Delay, 0, NUM_SHB_SUBFR / 2 ); hBWE_TD->prev_pow_exc16kWhtnd_fx32 = 1; /*Q0 1.f*/ - hBWE_TD->prev_mix_factor_fx = 32767; /*Q15 1.f*/ + move32(); + hBWE_TD->prev_mix_factor_fx = 32767; /*Q15 1.f*/ + move16(); swb_tbe_reset_synth_fx( hBWE_TD->genSHBsynth_Hilbert_Mem_fx, hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx ); } @@ -259,12 +264,13 @@ void updt_IO_switch_dec_fx( move16(); set16_fx( hBWE_TD->fb_state_lpc_syn_fx, 0, LPC_SHB_ORDER ); hBWE_TD->fb_tbe_demph_fx = 0; + move16(); fb_tbe_reset_synth_fx( hBWE_TD->fbbwe_hpf_mem_fx, hBWE_TD->fbbwe_hpf_mem_fx_Q, &hBWE_TD->prev_fbbwe_ratio_fx ); } hBWE_FD->prev_Energy_wb_fx = L_deposit_l( 0 ); hBWE_FD->prev_weight_fx = 6554; + move16(); } - move16(); IF( hBWE_FD != NULL ) { @@ -286,11 +292,11 @@ void updt_IO_switch_dec_fx( set16_fx( st_fx->delay_buf_out_fx, 0, HQ_DELTA_MAX * HQ_DELAY_COMP ); /* reset the unvoiced/audio signal improvement memories */ - IF( st_fx->hGSCDec != NULL ) + if ( st_fx->hGSCDec != NULL ) { st_fx->hGSCDec->seed_tcx = 15687; + move16(); } - move16(); st_fx->hAmrwb_IO->UV_cnt_fx = 30; st_fx->hAmrwb_IO->LT_UV_cnt_fx = ( 60 << 6 ); @@ -340,9 +346,10 @@ void updt_IO_switch_dec_fx( move16(); /* reset the unvoiced/audio signal improvement memories */ - IF( st_fx->hGSCDec != NULL ) + if ( st_fx->hGSCDec != NULL ) { st_fx->hGSCDec->seed_tcx = 15687; + move16(); } Copy( st_fx->hAmrwb_IO->lt_diff_etot_fx, tmp_buf, MAX_LT ); @@ -393,7 +400,7 @@ void updt_bw_switching_fx( const Word16 Qpost ) { test(); - IF( st_fx->output_Fs == 32000 && st_fx->bwidth == SWB ) + IF( EQ_32( st_fx->output_Fs, 32000 ) && EQ_16( st_fx->bwidth, SWB ) ) { #ifdef BASOP_NOGLOB st_fx->tilt_swb_fx = round_fx_sat( L_shl_sat( calc_tilt_bwe_fx( synth, Qpost, L_FRAME32k ), 3 ) ); @@ -465,6 +472,7 @@ void updt_dec_common_fx( move16(); st_fx->prev_old_bfi = st_fx->prev_bfi; + move16(); st_fx->prev_bfi = st_fx->bfi; move16(); if ( NE_16( st_fx->core, AMR_WB_CORE ) ) @@ -506,21 +514,24 @@ void updt_dec_common_fx( IF( st_fx->use_partial_copy ) { st_fx->prev_rf_frame_type = st_fx->rf_frame_type; + move16(); } ELSE { st_fx->prev_rf_frame_type = INACTIVE; + move16(); } - if ( EQ_16( st_fx->m_frame_type, ACTIVE_FRAME ) && ( st_fx->bfi != 1 || st_fx->use_partial_copy != 0 ) ) + if ( EQ_16( st_fx->m_frame_type, ACTIVE_FRAME ) && ( NE_16( st_fx->bfi, 1 ) || st_fx->use_partial_copy != 0 ) ) { st_fx->rf_flag_last = st_fx->rf_flag; + move16(); } IF( EQ_16( st_fx->codec_mode, MODE1 ) ) { test(); - if ( !st_fx->bfi && ( st_fx->core_brate > SID_2k40 || ( GT_32( st_fx->core_brate, SID_1k75 ) && EQ_16( st_fx->core, AMR_WB_CORE ) ) ) ) + if ( !st_fx->bfi && ( GT_32( st_fx->core_brate, SID_2k40 ) || ( GT_32( st_fx->core_brate, SID_1k75 ) && EQ_16( st_fx->core, AMR_WB_CORE ) ) ) ) { move16(); st_fx->last_active_brate = st_fx->total_brate; @@ -607,10 +618,12 @@ void updt_dec_common_fx( IF( EQ_16( st_fx->use_partial_copy, 1 ) && EQ_16( st_fx->rf_frame_type, RF_NELP ) ) { st_fx->last_nelp_mode_dec = 1; + move16(); } ELSE { st_fx->last_nelp_mode_dec = 0; + move16(); } } @@ -633,10 +646,12 @@ void updt_dec_common_fx( IF( EQ_16( st_fx->core, HQ_CORE ) ) { st_fx->prev_coder_type = GENERIC; + move16(); } ELSE IF( NE_16( st_fx->core, AMR_WB_CORE ) ) { st_fx->prev_coder_type = st_fx->coder_type; + move16(); } test(); @@ -673,8 +688,6 @@ void updt_dec_common_fx( } /* update bandwidth switching parameters */ - test(); - test(); st_fx->last_flag_cna = st_fx->flag_cna; move16(); if ( st_fx->hFdCngDec != NULL ) @@ -686,8 +699,10 @@ void updt_dec_common_fx( if ( GT_16( st_fx->element_mode, EVS_MONO ) ) { st_fx->m_old_frame_type = st_fx->m_frame_type; + move16(); } - + test(); + test(); /* update bandwidth switching parameters */ IF( EQ_16( st_fx->core, AMR_WB_CORE ) ) { @@ -716,6 +731,8 @@ void updt_dec_common_fx( /* synchronisation of CNG seeds*/ test(); test(); + test(); + test(); IF( st_fx->hTdCngDec != NULL && ( st_fx->bfi || ( NE_32( st_fx->core_brate, FRAME_NO_DATA ) && NE_32( st_fx->core_brate, SID_2k40 ) ) ) && NE_16( st_fx->core, AMR_WB_CORE ) ) { Random( &( st_fx->hTdCngDec->cng_seed ) ); @@ -733,11 +750,12 @@ void updt_dec_common_fx( st_fx->last_total_brate_ber = st_fx->total_brate; move32(); - if ( st_fx->bfi == 0 ) + IF( st_fx->bfi == 0 ) { st_fx->last_total_brate = st_fx->total_brate; st_fx->last_bits_frame_nominal = st_fx->bits_frame_nominal; move32(); + move32(); } st_fx->last_low_rate_mode = st_fx->low_rate_mode; move16(); @@ -757,7 +775,7 @@ static void ivas_updt_bw_switching_fx( const Word16 Qpost ) { test(); - IF( st_fx->output_Fs == 32000 && st_fx->bwidth == SWB ) + IF( EQ_32( st_fx->output_Fs, 32000 ) && EQ_16( st_fx->bwidth, SWB ) ) { #ifdef BASOP_NOGLOB st_fx->tilt_swb_fx = ivas_calc_tilt_bwe_fx( synth, Qpost, L_FRAME32k ); @@ -778,7 +796,7 @@ static void ivas_updt_bw_switching_fx( st_fx->last_inner_frame = L_FRAME32k; move16(); test(); - IF( EQ_16( st_fx->bwidth, WB ) && EQ_16( st_fx->bws_cnt, 0 ) ) + if ( EQ_16( st_fx->bwidth, WB ) && ( st_fx->bws_cnt == 0 ) ) { st_fx->last_inner_frame = L_FRAME16k; move16(); @@ -834,6 +852,7 @@ void ivas_updt_dec_common_fx( move16(); st_fx->prev_old_bfi = st_fx->prev_bfi; + move16(); st_fx->prev_bfi = st_fx->bfi; move16(); IF( NE_16( st_fx->core, AMR_WB_CORE ) ) @@ -850,6 +869,7 @@ void ivas_updt_dec_common_fx( IF( st_fx->hHQ_nbfec != NULL ) { st_fx->hHQ_nbfec->prev_last_core = st_fx->last_core; + move16(); } IF( st_fx->hTcxDec != NULL ) @@ -859,6 +879,8 @@ void ivas_updt_dec_common_fx( } test(); test(); + test(); + test(); IF( ( GE_16( st_fx->rf_frame_type, RF_TCXFD ) && LE_16( st_fx->rf_frame_type, RF_TCXTD2 ) && st_fx->use_partial_copy && st_fx->bfi ) || !st_fx->bfi ) { test(); @@ -866,7 +888,7 @@ void ivas_updt_dec_common_fx( test(); test(); - IF( st_fx->bfi && ( LE_16( st_fx->last_good, UNVOICED_TRANSITION ) ) && ( GT_16( st_fx->clas_dec, UNVOICED_TRANSITION ) ) && st_fx->last_con_tcx && st_fx->hTcxDec != NULL ) + if ( st_fx->bfi && ( LE_16( st_fx->last_good, UNVOICED_TRANSITION ) ) && ( GT_16( st_fx->clas_dec, UNVOICED_TRANSITION ) ) && st_fx->last_con_tcx && st_fx->hTcxDec != NULL ) { hTcxDec->tcxConceal_recalc_exc = 1; move16(); @@ -877,21 +899,27 @@ void ivas_updt_dec_common_fx( IF( st_fx->use_partial_copy ) { st_fx->prev_rf_frame_type = st_fx->rf_frame_type; + move16(); } ELSE { st_fx->prev_rf_frame_type = INACTIVE; + move16(); } - - IF( EQ_16( st_fx->m_frame_type, ACTIVE_FRAME ) && ( st_fx->bfi != 0 || st_fx->use_partial_copy != 0 ) ) + test(); + test(); + if ( EQ_16( st_fx->m_frame_type, ACTIVE_FRAME ) && ( st_fx->bfi != 0 || st_fx->use_partial_copy != 0 ) ) { st_fx->rf_flag_last = st_fx->rf_flag; + move16(); } IF( EQ_16( st_fx->codec_mode, MODE1 ) ) { test(); - IF( !st_fx->bfi && ( st_fx->core_brate > SID_2k40 || ( GT_32( st_fx->core_brate, SID_1k75 ) && EQ_16( st_fx->core, AMR_WB_CORE ) ) ) ) + test(); + test(); + if ( !st_fx->bfi && ( GT_32( st_fx->core_brate, SID_2k40 ) || ( GT_32( st_fx->core_brate, SID_1k75 ) && EQ_16( st_fx->core, AMR_WB_CORE ) ) ) ) { move16(); st_fx->last_active_brate = st_fx->total_brate; @@ -907,25 +935,26 @@ void ivas_updt_dec_common_fx( if ( st_fx->hHQ_core != NULL ) { st_fx->hHQ_core->last_hq_core_type = hq_core_type_fx; + move16(); } } ELSE IF( EQ_16( st_fx->codec_mode, MODE2 ) ) { test(); - IF( ( !st_fx->bfi ) && ( st_fx->last_is_cng == 0 ) ) + if ( ( !st_fx->bfi ) && ( st_fx->last_is_cng == 0 ) ) { move16(); st_fx->last_active_brate = st_fx->total_brate; } /* INFO: moved from update_decoder_LPD_cng() */ - IF( NE_16( st_fx->m_frame_type, ACTIVE_FRAME ) ) + if ( NE_16( st_fx->m_frame_type, ACTIVE_FRAME ) ) { move16(); st_fx->last_is_cng = 1; } - IF( !st_fx->bfi ) + if ( !st_fx->bfi ) { st_fx->last_core = st_fx->core; } @@ -962,19 +991,21 @@ void ivas_updt_dec_common_fx( st->stab_fac_smooth_lt = ENV_SMOOTH_FAC * st->stab_fac + ( 1.0f - ENV_SMOOTH_FAC ) * st->stab_fac_smooth_lt; } #else - if ( st_fx->element_mode != EVS_MONO ) + IF( st_fx->element_mode != EVS_MONO ) { Word16 q_div = sub( Q31, shl( Qpostd, 1 ) ); - Word16 output_frame = NS2SA( st_fx->output_Fs, FRAME_SIZE_NS ); + Word16 output_frame = NS2SA_fx2( st_fx->output_Fs, FRAME_SIZE_NS ); + move16(); Word32 sum_val = sum_32_32_fx( synth, output_frame ); Word32 div_val = BASOP_Util_Divide3232_Scale( sum_val, output_frame, &q_div ); Word32 log_energy = L_add( L_shl( L_deposit_l( add( q_div, sub( Q31, shl( Qpostd, 1 ) ) ) ), Q15 ), L_shr( BASOP_Util_Log2( L_shl( L_add( div_val, EPSILON_FX ), Q16 ) ), Q10 ) ); Word32 log_energy_diff = L_abs( L_sub( st_fx->log_energy_old_fx, log_energy ) ); st_fx->log_energy_old_fx = log_energy; + move32(); st_fx->log_energy_diff_lt_fx = Madd_32_16( Mpy_32_16_1( log_energy_diff, ENV_SMOOTH_FAC_FX ), st_fx->log_energy_diff_lt_fx, sub( MAX_16, ENV_SMOOTH_FAC_FX ) ); - if ( st_fx->core == HQ_CORE ) + IF( EQ_16( st_fx->core, HQ_CORE ) ) { st_fx->stab_fac_fx = extract_l( L_min( MAX_16, L_add( L_shr( STAB_FAC_EST1_FX, Q15 ), Madd_32_32( L_shr( Mpy_32_16_1( STAB_FAC_EST2_FX, st_fx->hHQ_core->mem_env_delta ), Q15 ), STAB_FAC_EST3_FX, st_fx->log_energy_diff_lt_fx ) ) ) ); st_fx->stab_fac_fx = s_max( 0, st_fx->stab_fac_fx ); @@ -983,12 +1014,16 @@ void ivas_updt_dec_common_fx( L_mult( sub( MAX_16, ENV_SMOOTH_FAC_FX ), st_fx->stab_fac_smooth_lt_fx ) ) ); } #endif + + test(); + test(); + test(); #ifdef NON_BE_1055_RESET_LP_MEMORIES - IF( ( LE_32( st_fx->core_brate, SID_2k40 ) && EQ_16( st_fx->cng_type, FD_CNG ) ) || ( st_fx->tcxonly && ( EQ_16( st_fx->codec_mode, MODE2 ) || GT_16( st_fx->element_mode, EVS_MONO ) ) ) ) + test(); + IF( ( LE_32( st_fx->core_brate, SID_2k40 ) && EQ_16( st_fx->cng_type, FD_CNG ) ) || ( st_fx->tcxonly && ( EQ_16( st_fx->codec_mode, MODE2 ) || ( st_fx->element_mode > EVS_MONO ) ) ) ) #else IF( ( ( LE_32( st_fx->core_brate, SID_2k40 ) ) && EQ_16( st_fx->cng_type, FD_CNG ) ) || ( st_fx->tcxonly && EQ_16( st_fx->codec_mode, MODE2 ) ) ) #endif - { /* reset LP memories */ set16_fx( st_fx->mem_MA_fx, 0, M ); @@ -1007,10 +1042,12 @@ void ivas_updt_dec_common_fx( IF( EQ_16( st_fx->use_partial_copy, 1 ) && EQ_16( st_fx->rf_frame_type, RF_NELP ) ) { st_fx->last_nelp_mode_dec = 1; + move16(); } ELSE { st_fx->last_nelp_mode_dec = 0; + move16(); } } @@ -1033,17 +1070,22 @@ void ivas_updt_dec_common_fx( IF( EQ_16( st_fx->core, HQ_CORE ) ) { st_fx->prev_coder_type = GENERIC; + move16(); } ELSE IF( NE_16( st_fx->core, AMR_WB_CORE ) ) { st_fx->prev_coder_type = st_fx->coder_type; + move16(); } + test(); + test(); + test(); test(); IF( ( GT_32( st_fx->core_brate, SID_2k40 ) || ( GT_32( st_fx->core_brate, SID_1k75 ) && EQ_16( st_fx->core, AMR_WB_CORE ) ) ) && EQ_16( st_fx->first_CNG, 1 ) && st_fx->hTdCngDec != NULL ) { - IF( GE_16( st_fx->hTdCngDec->act_cnt, BUF_DEC_RATE ) ) + if ( GE_16( st_fx->hTdCngDec->act_cnt, BUF_DEC_RATE ) ) { st_fx->hTdCngDec->act_cnt = 0; move16(); @@ -1053,20 +1095,19 @@ void ivas_updt_dec_common_fx( test(); - IF( ( EQ_16( st_fx->hTdCngDec->act_cnt, BUF_DEC_RATE ) ) && ( st_fx->hTdCngDec->ho_hist_size > 0 ) ) + if ( ( EQ_16( st_fx->hTdCngDec->act_cnt, BUF_DEC_RATE ) ) && ( st_fx->hTdCngDec->ho_hist_size > 0 ) ) { st_fx->hTdCngDec->ho_hist_size = sub( st_fx->hTdCngDec->ho_hist_size, 1 ); } - // st_fx->hTdCngDec->act_cnt2 = add(st_fx->hTdCngDec->act_cnt2, 1); - - IF( GE_16( st_fx->hTdCngDec->act_cnt2, MIN_ACT_CNG_UPD ) ) + if ( GE_16( st_fx->hTdCngDec->act_cnt2, MIN_ACT_CNG_UPD ) ) { st_fx->hTdCngDec->act_cnt2 = MIN_ACT_CNG_UPD; move16(); } } + test(); test(); test(); if ( LE_32( st_fx->core_brate, SID_2k40 ) && st_fx->first_CNG == 0 && ( EQ_16( st_fx->cng_type, LP_CNG ) || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) ) @@ -1086,12 +1127,15 @@ void ivas_updt_dec_common_fx( move16(); } - if ( GT_16( st_fx->element_mode, EVS_MONO ) ) + if ( st_fx->element_mode > EVS_MONO ) { st_fx->m_old_frame_type = st_fx->m_frame_type; + move16(); } /* update bandwidth switching parameters */ + test(); + test(); IF( EQ_16( st_fx->core, AMR_WB_CORE ) ) { st_fx->last_bwidth = WB; @@ -1119,6 +1163,8 @@ void ivas_updt_dec_common_fx( /* synchronisation of CNG seeds*/ test(); test(); + test(); + test(); IF( st_fx->hTdCngDec != NULL && ( st_fx->bfi || ( NE_32( st_fx->core_brate, FRAME_NO_DATA ) && NE_32( st_fx->core_brate, SID_2k40 ) ) ) && NE_16( st_fx->core, AMR_WB_CORE ) ) { Random( &( st_fx->hTdCngDec->cng_seed ) ); @@ -1136,11 +1182,12 @@ void ivas_updt_dec_common_fx( st_fx->last_total_brate_ber = st_fx->total_brate; move32(); - if ( st_fx->bfi == 0 ) + IF( st_fx->bfi == 0 ) { st_fx->last_total_brate = st_fx->total_brate; st_fx->last_bits_frame_nominal = st_fx->bits_frame_nominal; move32(); + move32(); } st_fx->last_low_rate_mode = st_fx->low_rate_mode; move16(); @@ -1206,12 +1253,14 @@ void update_decoder_LPD_cng( Copy( st->syn, synth_buf, 1 + M ); Copy( timeDomainBuffer, synth, st->L_frame ); Copy( synth + st->L_frame - ( 1 + M ), st->syn, 1 + M ); - Copy( hTcxDec->old_synth + st->L_frame, hTcxDec->old_synth, hTcxDec->old_synth_len - st->L_frame ); - Copy( synth, hTcxDec->old_synth + hTcxDec->old_synth_len - st->L_frame, st->L_frame ); - bufferCopyFx( synth + st->L_frame - ( st->L_frame / 2 ), hTcxDec->old_syn_Overl, st->L_frame / 2, 0 /*Qf_syn*/, -1 /*Qf_old_xnq*/, 0, 0 /*Q_old_xnq*/ ); + Copy( hTcxDec->old_synth + st->L_frame, hTcxDec->old_synth, sub( hTcxDec->old_synth_len, st->L_frame ) ); + Copy( synth, hTcxDec->old_synth + sub( hTcxDec->old_synth_len, st->L_frame ), st->L_frame ); + bufferCopyFx( synth + sub( st->L_frame, ( st->L_frame / 2 ) ), hTcxDec->old_syn_Overl, st->L_frame / 2, 0 /*Qf_syn*/, -1 /*Qf_old_xnq*/, 0, 0 /*Q_old_xnq*/ ); hTcxDec->tcxltp_last_gain_unmodified = 0; + move16(); hTcxDec->envWeighted = 0; + move16(); } /* Update pe-synth memory */ @@ -1219,7 +1268,9 @@ void update_decoder_LPD_cng( tmp = synth[-( 1 + M )]; st->Q_syn = E_UTIL_f_preemph3( synth - M, st->preemph_fac, M + st->L_frame, &tmp, 1 ); - st->prev_Q_syn = st->Q_syn = st->Q_syn - 1; + st->prev_Q_syn = st->Q_syn = sub( st->Q_syn, 1 ); + move16(); + move16(); Copy( synth + st->L_frame - M, st->mem_syn2_fx, M ); Copy( synth + st->L_frame - L_SYN_MEM, st->mem_syn_r, L_SYN_MEM ); @@ -1229,9 +1280,9 @@ void update_decoder_LPD_cng( { Scale_sig( st->old_exc_fx, L_EXC_MEM_DEC, sub( add( st->Q_syn, 1 ), st->Q_exc ) ); } - st->Q_exc = st->Q_syn + 1; + st->Q_exc = add( st->Q_syn, 1 ); Copy( st->old_exc_fx + st->L_frame, st->old_exc_fx, sub( L_EXC_MEM_DEC, st->L_frame ) ); - Residu3_fx( A, synth, st->old_exc_fx + L_EXC_MEM_DEC - st->L_frame, st->L_frame, 1 ); + Residu3_fx( A, synth, st->old_exc_fx + sub( L_EXC_MEM_DEC, st->L_frame ), st->L_frame, 1 ); /* Update LPC-related memories */ @@ -1267,7 +1318,7 @@ void update_decoder_LPD_cng( /* Reset TCX overlap */ move16(); move16(); - if ( st->hTcxCfg != NULL ) + IF( st->hTcxCfg != NULL ) { st->hTcxCfg->tcx_curr_overlap_mode = st->hTcxCfg->tcx_last_overlap_mode = ALDO_WINDOW; } diff --git a/lib_dec/vlpc_1st_dec.c b/lib_dec/vlpc_1st_dec.c index 6472bd3859c60d9bd03f5adf5091495e0db480bb..be759eb6110b4637418e92b2d08a061e19fe8f7f 100644 --- a/lib_dec/vlpc_1st_dec.c +++ b/lib_dec/vlpc_1st_dec.c @@ -40,7 +40,7 @@ #include "prot.h" #include "rom_com.h" #include "wmc_auto.h" - +#ifndef IVAS_FLOAT_FIXED /*------------------------------------------------------------------* * vlpc_1st_dec_flt() * @@ -66,3 +66,4 @@ void vlpc_1st_dec_flt( return; } +#endif diff --git a/lib_dec/vlpc_2st_dec.c b/lib_dec/vlpc_2st_dec.c index ac22f990a8038eb08159e9cdfd779080b7fec1da..fdb29ebe630918851d4eba0fcdffa00c0ba48e0d 100644 --- a/lib_dec/vlpc_2st_dec.c +++ b/lib_dec/vlpc_2st_dec.c @@ -38,13 +38,12 @@ #include "options.h" #include "prot.h" #include "wmc_auto.h" - +#ifndef IVAS_FLOAT_FIXED /*------------------------------------------------------------------* * vlpc_2st_dec_flt() * * *------------------------------------------------------------------*/ -#ifndef IVAS_FLOAT_FIXED void vlpc_2st_dec_flt( float *lsfq, /* i/o: i:1st stage o:1st+2nd stage */ int16_t *indx, /* i : index[] (4 bits per words) */ diff --git a/lib_dec/vlpc_2st_dec_fx.c b/lib_dec/vlpc_2st_dec_fx.c index 7629ab2c2628c01015b090d4557a573f153e9417..df4d8e53e3def8608ee562b012890035011ab6d3 100644 --- a/lib_dec/vlpc_2st_dec_fx.c +++ b/lib_dec/vlpc_2st_dec_fx.c @@ -51,18 +51,22 @@ void vlpc_2st_dec( IF( EQ_32( sr_core, 16000 ) ) { gap = 102; + move16(); } ELSE IF( EQ_32( sr_core, 25600 ) ) { gap = 64; + move16(); } ELSE IF( EQ_32( sr_core, 32000 ) ) { gap = 51; + move16(); } ELSE { gap = 34; + move16(); } reorder_lsf_fx( lsfq, gap, M, INT_FS_FX ); diff --git a/lib_dec/voiced_dec_fx.c b/lib_dec/voiced_dec_fx.c index 2095a76949ee2a2a6e393cbe7418f77793ead40a..e31032d4c867dd8674df277ee930729e1d03254f 100644 --- a/lib_dec/voiced_dec_fx.c +++ b/lib_dec/voiced_dec_fx.c @@ -52,6 +52,9 @@ ivas_error ppp_voiced_decoder_fx( { Word16 k, delta_lag_D = 0, temp, Ql, Qh, diff; Word16 upper_cut_off_freq_of_interest = 0, upper_cut_off_freq = 0; + move16(); + move16(); + move16(); Word16 pl, l, n, rem_fx; Word16 temp_l_fx, temp_pl_fx, interp_delay_fx[3]; Word32 logLag, Ltemp_q, Ltemp, rem32, temp32_fx, tempnH_fx; @@ -73,16 +76,17 @@ ivas_error ppp_voiced_decoder_fx( ivas_error error; error = IVAS_ERR_OK; + move32(); - IF( ( error = DTFS_new_fx( &TMPDTFS_FX ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = DTFS_new_fx( &TMPDTFS_FX ) ), IVAS_ERR_OK ) ) { IVAS_ERROR( error, "Error creating DTFS structure" ); } - IF( ( error = DTFS_new_fx( &CURRP_Q_D_FX ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = DTFS_new_fx( &CURRP_Q_D_FX ) ), IVAS_ERR_OK ) ) { IVAS_ERROR( error, "Error creating DTFS structure" ); } - IF( ( error = DTFS_new_fx( &dtfs_temp_fx ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = DTFS_new_fx( &dtfs_temp_fx ) ), IVAS_ERR_OK ) ) { IVAS_ERROR( error, "Error creating DTFS structure" ); } @@ -104,6 +108,7 @@ ivas_error ppp_voiced_decoder_fx( } temp_Fs = 8000; + move16(); if ( EQ_16( st_fx->bwidth, WB ) ) { @@ -168,7 +173,6 @@ ivas_error ppp_voiced_decoder_fx( set16_fx( pitch, s_min( MAX_LAG_PIT << 6, s_max( 19 << 6, shl( temp_l_fx, 6 ) ) ), NB_SUBFR ); /*Q6 */ } - if ( EQ_16( st_fx->last_coder_type, UNVOICED ) ) { pl = l; @@ -229,7 +233,7 @@ ivas_error ppp_voiced_decoder_fx( L_tmp = L_deposit_h( TMPDTFS_FX->lag_fx ); /*Q16 */ exp = norm_l( L_tmp ); tmp = Log2_norm_lc( L_shl( L_tmp, exp ) ); - exp = ( 30 - exp - 16 ); + exp = sub( sub( 30, exp ), 16 ); L_tmp = Mpy_32_16( exp, tmp, 12330 ); /* Q13 */ /* 10*log10(2) in Q12*/ logLag = L_shl( L_tmp, 10 ); /*Q23 */ @@ -320,10 +324,10 @@ ivas_error ppp_voiced_decoder_fx( exp = norm_s( CURRP_Q_D_FX->lag_fx ); tmp = div_s( shl( 1, sub( 14, exp ) ), CURRP_Q_D_FX->lag_fx ); /*29-exp */ #ifdef BASOP_NOGLOB - L_tmp = L_shl_sat( L_mult0( tmp, 12800 ), exp - 7 ); + L_tmp = L_shl_sat( L_mult0( tmp, 12800 ), sub( exp, 7 ) ); temp32_fx = round_fx_sat( L_tmp ); #else - L_tmp = L_shl( L_mult0( tmp, 12800 ), exp - 7 ); + L_tmp = L_shl( L_mult0( tmp, 12800 ), sub( exp, 7 ) ); temp32_fx = round_fx( L_tmp ); #endif diff = round_fx( L_shl( temp32_fx, 16 - 6 ) ); /*Q0 */ @@ -332,7 +336,7 @@ ivas_error ppp_voiced_decoder_fx( exp = norm_s( diff ); tmp = div_s( shl( 1, sub( 14, exp ) ), diff ); /*29-exp */ - L_tmp = L_shl( L_mult0( 4000, tmp ), exp - 7 ); + L_tmp = L_shl( L_mult0( 4000, tmp ), sub( exp, 7 ) ); tempnH_fx = extract_h( L_tmp ); CURRP_Q_D_FX->nH_4kHz_fx = round_fx( L_shl( tempnH_fx, 16 - 6 ) ); /*Q0 */ @@ -357,15 +361,17 @@ ivas_error ppp_voiced_decoder_fx( IF( bfi == 0 ) { - IF( ( error = ppp_quarter_decoder_fx( CURRP_Q_D_FX, dtfs_temp_fx->lag_fx, &( hSC_VBR->lastLgainD_fx ), - &( hSC_VBR->lastHgainD_fx ), hSC_VBR->lasterbD_fx, bfi, S_fx, C_fx, *dtfs_temp_fx, st_fx ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ppp_quarter_decoder_fx( CURRP_Q_D_FX, dtfs_temp_fx->lag_fx, &( hSC_VBR->lastLgainD_fx ), + &( hSC_VBR->lastHgainD_fx ), hSC_VBR->lasterbD_fx, bfi, S_fx, C_fx, *dtfs_temp_fx, st_fx ) ), + IVAS_ERR_OK ) ) { return error; } } - IF( ( error = WIsyn_fx( *dtfs_temp_fx, CURRP_Q_D_FX, lpc2_fx, &( hSC_VBR->ph_offset_D_fx ), out_fx, (Word16) L_FRAME, 0, - S_fx, C_fx, pf_temp1, pf_temp2, pf_temp, pf_n2 ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = WIsyn_fx( *dtfs_temp_fx, CURRP_Q_D_FX, lpc2_fx, &( hSC_VBR->ph_offset_D_fx ), out_fx, (Word16) L_FRAME, 0, + S_fx, C_fx, pf_temp1, pf_temp2, pf_temp, pf_n2 ) ), + IVAS_ERR_OK ) ) { return error; } @@ -406,19 +412,29 @@ void sc_vbr_dec_init( ) { hSC_VBR->nelp_dec_seed = 0; + move16(); hSC_VBR->firstTime_voiceddec = 1; + move16(); /* DTFS variables */ set16_fx( hSC_VBR->dtfs_dec_a_fx, 0, MAXLAG_WI ); set16_fx( hSC_VBR->dtfs_dec_b_fx, 0, MAXLAG_WI ); hSC_VBR->dtfs_dec_lag = 0; + move16(); hSC_VBR->dtfs_dec_nH = 0; + move16(); hSC_VBR->dtfs_dec_nH_4kHz = 0; + move16(); hSC_VBR->dtfs_dec_upper_cut_off_freq_of_interest_fx = 0; + move16(); hSC_VBR->dtfs_dec_upper_cut_off_freq_fx = 0; + move16(); hSC_VBR->ph_offset_D_fx = 0; + move16(); hSC_VBR->lastLgainD_fx = 0; + move16(); hSC_VBR->lastHgainD_fx = 0; + move16(); set16_fx( hSC_VBR->lasterbD_fx, 0, NUM_ERB_WB ); /* NELP decoder variables */ diff --git a/lib_dec/waveadjust_fec_dec.c b/lib_dec/waveadjust_fec_dec.c index 245d8bbf64cb7cd921b2b80cb688edcc73e9caf3..0931fe0d63a9a6732fcf12cebfc7226358c5964b 100644 --- a/lib_dec/waveadjust_fec_dec.c +++ b/lib_dec/waveadjust_fec_dec.c @@ -654,7 +654,7 @@ void waveform_adj2( return; } -#endif + /*-------------------------------------------------------------------* * set_state_ivas() @@ -694,22 +694,17 @@ void concealment_init( hPlcInfo->L_frameTCX = L_frameTCX; hPlcInfo->Pitch = 0; hPlcInfo->T_bfi = 0; -#ifndef IVAS_FLOAT_FIXED hPlcInfo->outx_new_n1 = 0.0f; hPlcInfo->nsapp_gain = 0.0f; -#endif -#ifndef IVAS_FLOAT_FIXED + hPlcInfo->nsapp_gain_n = 0.0f; hPlcInfo->ener_mean = 59.4260f; -#endif -#ifndef IVAS_FLOAT_FIXED hPlcInfo->ener = 0.0f; -#endif + hPlcInfo->zp = L_frameTCX; -#ifndef IVAS_FLOAT_FIXED + hPlcInfo->recovery_gain_float = 0.0f; hPlcInfo->step_concealgain = 0.0f; -#endif hPlcInfo->concealment_method = TCX_NONTONAL; hPlcInfo->subframe = 0; hPlcInfo->nbLostCmpt = 0; @@ -727,15 +722,14 @@ void concealment_init( { hPlcInfo->Transient[i] = 1; } -#ifndef IVAS_FLOAT_FIXED for ( i = 0; i < L_FRAME_MAX; i++ ) { hPlcInfo->data_reci2[i] = 0; } -#endif + return; } - +#endif /*-------------------------------------------------------------------* * concealment_decode() diff --git a/lib_dec/waveadjust_fec_dec_fx.c b/lib_dec/waveadjust_fec_dec_fx.c index ddbcb90df0378e8f51c07375fc10b3da0c0eb140..e7aadde27cd978e085693c2f13d4c2fe571e08f9 100644 --- a/lib_dec/waveadjust_fec_dec_fx.c +++ b/lib_dec/waveadjust_fec_dec_fx.c @@ -67,7 +67,7 @@ void concealment_update_x( Word16 bfi, Word16 curr_mode, Word16 tonality, Word32 ELSE { - IF( EQ_16( subframe, 0 ) ) + IF( subframe == 0 ) { set_state( plcInfo->Transient, curr_mode, MAX_POST_LEN ); @@ -80,7 +80,7 @@ void concealment_update_x( Word16 bfi, Word16 curr_mode, Word16 tonality, Word32 pitch_search_fx(), low_freq_rate is derived on the last good TCX-10 spectrum */ test(); - IF( !bfi || EQ_16( subframe, 0 ) ) + IF( !bfi || subframe == 0 ) { Word32 *ptr = data_reci2 + subframe; @@ -336,6 +336,8 @@ void get_maxConv_and_pitch_x( Word16 *s_LP, Word16 s, Word16 e, Word16 N, Word32 Word16 size_tmp = N; move16(); move16(); + move16(); + move16(); nbits = sub( 15, norm_s( sub( N, s ) ) ); FOR( t = s; t < e; t++ ) @@ -800,7 +802,8 @@ void concealment_init_x( Word16 N, void *_plcInfo ) move16(); plcInfo->subframe_fx = 0; move16(); - plcInfo->nbLostCmpt = (int16_t) L_deposit_l( 0 ); + plcInfo->nbLostCmpt = (Word16) L_deposit_l( 0 ); + move16(); plcInfo->seed = 21845; move16(); @@ -834,12 +837,15 @@ void concealment_init_ivas_fx( { Word16 i; hPlcInfo->L_frameTCX = L_frameTCX; + move16(); hPlcInfo->FrameSize = L_frameTCX; move16(); hPlcInfo->Pitch = 0; + move16(); hPlcInfo->Pitch_fx = 0; move16(); hPlcInfo->T_bfi = 0; + move16(); hPlcInfo->T_bfi_fx = 0; move16(); hPlcInfo->outx_new_n1_fx = 0; @@ -851,6 +857,7 @@ void concealment_init_ivas_fx( hPlcInfo->ener_mean_fx = L_deposit_l( 15213 ); hPlcInfo->ener_fx = L_deposit_l( 0 ); hPlcInfo->zp = L_frameTCX; + move16(); hPlcInfo->zp_fx = L_frameTCX; move16(); hPlcInfo->recovery_gain = 0; @@ -860,9 +867,11 @@ void concealment_init_ivas_fx( hPlcInfo->concealment_method = TCX_NONTONAL; move16(); hPlcInfo->subframe = 0; + move16(); hPlcInfo->subframe_fx = 0; move16(); hPlcInfo->nbLostCmpt = (Word16) L_deposit_l( 0 ); + move16(); hPlcInfo->seed = RANDOM_INITSEED; move16(); @@ -885,6 +894,7 @@ void concealment_init_ivas_fx( FOR( i = 0; i < L_FRAME_MAX; i++ ) { hPlcInfo->data_reci2_fx[i] = L_deposit_l( 0 ); + move32(); } return; } @@ -1149,9 +1159,13 @@ Word16 ffr_getSfWord16( /* o: measured headroom in range [0..15], FOR( i = 0; i < len_x; i++ ) { if ( x[i] >= 0 ) + { x_max = s_max( x_max, x[i] ); + } if ( x[i] < 0 ) + { x_min = s_min( x_min, x[i] ); + } } i_max = 0x10; @@ -1160,10 +1174,14 @@ Word16 ffr_getSfWord16( /* o: measured headroom in range [0..15], move16(); if ( x_max != 0 ) + { i_max = norm_s( x_max ); + } if ( x_min != 0 ) + { i_min = norm_s( x_min ); + } i = s_and( s_min( i_max, i_min ), 0xF ); @@ -1201,15 +1219,15 @@ static Word16 OverlapAdd_fx( Word16 *pitch125_data, Word16 *sbuf, Word16 n, Word { Word16 tmp; Word16 dat; - dat = shl( sbuf[n + i], s16MaxCoefNorm ); + dat = shl( sbuf[add( n, i )], s16MaxCoefNorm ); tmp = extract_l( L_shl( L_mult0( i, tmp16 ), s ) ); /* q15 */ - sbuf[n + i] = round_fx( L_add( L_shr( L_mult( dat, sub( 32767, tmp ) ), s16MaxCoefNorm ), - L_shr( L_mult( shl( pitch125_data[i], s16MaxCoefNorm2 ), tmp ), s16MaxCoefNorm2 ) ) ); + sbuf[add( n, i )] = round_fx( L_add( L_shr( L_mult( dat, sub( 32767, tmp ) ), s16MaxCoefNorm ), + L_shr( L_mult( shl( pitch125_data[i], s16MaxCoefNorm2 ), tmp ), s16MaxCoefNorm2 ) ) ); } FOR( i = n1; i < n2; i++ ) { - sbuf[n + i] = pitch125_data[i]; + sbuf[add( n, i )] = pitch125_data[i]; move16(); } @@ -1260,6 +1278,7 @@ static void add_noise( Word16 *const sbuf, } *outx_new_n1 = noise_seg[i - 1]; /*q0*/ + move16(); return; } @@ -1318,7 +1337,7 @@ static Word16 waveform_adj_fix( Word16 *overlapbuf, test(); test(); - IF( ( LT_16( pos1, pos2 ) ) && ( GT_16( pos3, pitch ) ) && ( LT_16( pos1, Framesizediv2 ) ) ) + if ( ( LT_16( pos1, pos2 ) ) && ( GT_16( pos3, pitch ) ) && ( LT_16( pos1, Framesizediv2 ) ) ) { pitch = add( i2, sub( pitch, i1 ) ); } @@ -1329,16 +1348,17 @@ static Word16 waveform_adj_fix( Word16 *overlapbuf, Word16 pitch125_data[L_FRAME_MAX]; move16(); move16(); + move16(); pitch125 = extract_l( ( L_shr( L_add( L_add( L_deposit_h( pitch ), L_mult( pitch, 8192 ) ), 32768 ), 16 ) ) ); Loverlap = sub( pitch125, pitch ); FOR( i = 0; i < pitch; i++ ) { - pitch125_data[i] = outdata2[Framesize - pitch + i]; + pitch125_data[i] = outdata2[add( sub( Framesize, pitch ), i )]; move16(); } FOR( i = 0; i < Loverlap; i++ ) { - pitch125_data[pitch + i] = outx_new[i]; + pitch125_data[add( pitch, i )] = outx_new[i]; move16(); } FOR( i = 0; i < Framesize; i++ ) @@ -1357,7 +1377,7 @@ static Word16 waveform_adj_fix( Word16 *overlapbuf, move16(); } - p_tmp[-1] = outdata2[Framesize - pitch - 1]; + p_tmp[-1] = outdata2[sub( sub( Framesize, pitch ), 1 )]; move16(); p_tmp[pitch125] = outx_new[Loverlap]; move16(); @@ -1375,6 +1395,7 @@ static Word16 waveform_adj_fix( Word16 *overlapbuf, #else pitch125_data[i] = round_fx( L_shr( L_add( ( L_mult( p_tmp[i], 20972 ) ), L_mac( L_mult( p_tmp[i - 1], 5898 ), p_tmp[i + 1], 5898 ) ), s16MaxCoefNorm ) ); #endif + move16(); } } @@ -1386,7 +1407,7 @@ static Word16 waveform_adj_fix( Word16 *overlapbuf, /* maximum pitch lag is 3/4 Framesize; pitch125_data is reused for temporary storage, since outdata2 (holding the pcm data of the last good frame) is still needed and overlapbuf overlaps outdata2 */ - Copy( &sbuf[Framesize / 4], pitch125_data, ( 3 * Framesize ) / 4 ); + Copy( &sbuf[Framesize / 4], pitch125_data, shr( imult1616( 3, Framesize ), 2 ) ); *nsapp_gain = 0; move16(); @@ -1398,7 +1419,7 @@ static Word16 waveform_adj_fix( Word16 *overlapbuf, /* save current (noisy) output from IMDCT */ mvr2r_Word16( outx_new, data_noise, tmp ); /* overlapbuf can now be filled with sbuf, needed for subsequently lost frames */ - Copy( pitch125_data, &overlapbuf[Framesize / 4], ( 3 * Framesize ) / 4 ); + Copy( pitch125_data, &overlapbuf[Framesize / 4], shr( imult1616( 3, Framesize ), 2 ) ); } FOR( i = 0; i < Framesize; i++ ) { @@ -1438,7 +1459,7 @@ void waveform_adj2_fix( Word16 *overlapbuf, Word16 tmp = vadmin( pitch, Framesizesubn ); FOR( i = 0; i < tmp; i++ ) { - sbuf[n + i] = overlapbuf[Framesizesubp + i]; + sbuf[add( n, i )] = overlapbuf[add( Framesizesubp, i )]; move16(); } n = add( n, pitch ); @@ -1454,7 +1475,7 @@ void waveform_adj2_fix( Word16 *overlapbuf, { Word16 size = Framesize; Word16 *noise_ptr = data_noise; - + move16(); /* use last (noisy) output from IMDCT for noise generation */ add_noise( sbuf, outx_new_n1, noise_ptr, size, nsapp_gain, nsapp_gain_n, 0 ); @@ -1522,7 +1543,7 @@ void waveform_adj2_fix( Word16 *overlapbuf, gain_zero_start = add( gain_zero_start, 1 ); } - IF( delay > 0 ) + if ( delay > 0 ) { Framesize = sub( Framesize, delay ); } @@ -1536,9 +1557,9 @@ void waveform_adj2_fix( Word16 *overlapbuf, dat = shl( sbuf[i], s16MaxCoefNorm ); temp_OUT = mult( *recovery_gain, sub( 32767, ratio ) ); #ifdef BASOP_NOGLOB - outx_new[i] = round_fx_sat( L_add_sat( L_shr_sat( L_mult( temp_OUT, dat ), s16MaxCoefNorm - 1 ), L_shr_sat( L_mult( shl( outx_new[i], s16MaxCoefNorm2 ), ratio ), s16MaxCoefNorm2 ) ) ); + outx_new[i] = round_fx_sat( L_add_sat( L_shr_sat( L_mult( temp_OUT, dat ), sub( s16MaxCoefNorm, 1 ) ), L_shr_sat( L_mult( shl( outx_new[i], s16MaxCoefNorm2 ), ratio ), s16MaxCoefNorm2 ) ) ); #else - outx_new[i] = round_fx( L_add( L_shr( L_mult( temp_OUT, dat ), s16MaxCoefNorm - 1 ), L_shr( L_mult( shl( outx_new[i], s16MaxCoefNorm2 ), ratio ), s16MaxCoefNorm2 ) ) ); + outx_new[i] = round_fx( L_add( L_shr( L_mult( temp_OUT, dat ), sub( s16MaxCoefNorm, 1 ) ), L_shr( L_mult( shl( outx_new[i], s16MaxCoefNorm2 ), ratio ), s16MaxCoefNorm2 ) ) ); #endif move16(); #ifdef BASOP_NOGLOB @@ -1555,6 +1576,7 @@ void waveform_adj2_fix( Word16 *overlapbuf, #else outx_new[i] = round_fx( L_shr( L_mult( shl( outx_new[i], s16MaxCoefNorm2 ), ratio ), s16MaxCoefNorm2 ) ); #endif + move16(); } if ( *recovery_gain < 0 ) @@ -1574,6 +1596,7 @@ void waveform_adj2_fix( Word16 *overlapbuf, dat = shl( sbuf[i], s16MaxCoefNorm ); tmp = extract_l( L_shr( L_mult( i, ptable ), tablescale ) ); outx_new[i] = round_fx( L_add( L_shr( L_mult( dat, sub( 32767, tmp ) ), s16MaxCoefNorm ), L_shr( L_mult( shl( outx_new[i], s16MaxCoefNorm2 ), tmp ), s16MaxCoefNorm2 ) ) ); + move16(); } } } diff --git a/lib_rend/ivas_allrad_dec.c b/lib_rend/ivas_allrad_dec.c index 98328dc5620199eb69277db0c950aa3504eea5bf..d99b2a1e760d40af54cdba0b48e27095905d7836 100644 --- a/lib_rend/ivas_allrad_dec.c +++ b/lib_rend/ivas_allrad_dec.c @@ -232,10 +232,10 @@ ivas_error ivas_sba_get_hoa_dec_matrix_fx( FOR( i = 0; i < num_td; i++ ) { /* spherical harmonics response for t-design, corresponding to ambisonic order */ - ivas_dirac_dec_get_response_fixed( + ivas_dirac_dec_get_response_fx( ( (Word16) L_shr( t_design_azi[i], 22 ) ) > 0 ? ( (Word16) L_shr( t_design_azi[i], 22 ) ) : ( (Word16) L_shr( t_design_azi[i], 22 ) ) + 1, ( (Word16) L_shr( t_design_ele[i], 22 ) ) > 0 ? ( (Word16) L_shr( t_design_ele[i], 22 ) ) : ( (Word16) L_shr( t_design_ele[i], 22 ) ) + 1, - Y_td_int, ambisonics_order ); + Y_td_int, ambisonics_order, Q29 ); FOR( j = 0; j < num_harm; j++ ) { Y_td_int[j] = L_shl( Mpy_32_32( Y_td_int[j], norm_sn3d_hoa3_int[j] ), Q1 ); // Q28 diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c index 1e7c7dedf9615d45623e5e78e59b80215d742315..59b022eff553431d360c3526bb1b9b0c3f3f5a01 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions.c @@ -6337,10 +6337,11 @@ static void hrtfShGetHrtf_fx( { Word32 shVec[HRTF_SH_CHANNELS]; - ivas_dirac_dec_get_response_fixed( aziDeg, - eleDeg, - shVec, - HRTF_SH_ORDER ); + ivas_dirac_dec_get_response_fx( aziDeg, + eleDeg, + shVec, + HRTF_SH_ORDER, + Q29 ); FOR( k = 0; k < HRTF_SH_CHANNELS; k++ ) { diff --git a/lib_rend/ivas_dirac_output_synthesis_dec.c b/lib_rend/ivas_dirac_output_synthesis_dec.c index 2390b1d5ff242215be6fa53024a4cab69e58e27c..8ae785ac5a54c19828c298f4fd25f4068e15c575 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec.c @@ -4391,11 +4391,11 @@ void ivas_dirac_dec_compute_directional_responses_fx( } ELSE { - ivas_dirac_dec_get_response_fixed_Q( azimuth[k], elevation[k], direct_response_hoa_fx, hDirACRend->hOutSetup.ambisonics_order, Q_direct_response_hoa ); + ivas_dirac_dec_get_response_fx( azimuth[k], elevation[k], direct_response_hoa_fx, hDirACRend->hOutSetup.ambisonics_order, Q_direct_response_hoa ); IF( hodirac_flag ) { - ivas_dirac_dec_get_response_fixed_Q( azimuth2[k], elevation2[k], direct_response_dir2_fx, hDirACRend->hOutSetup.ambisonics_order, Q_direct_response_dir2 ); + ivas_dirac_dec_get_response_fx( azimuth2[k], elevation2[k], direct_response_dir2_fx, hDirACRend->hOutSetup.ambisonics_order, Q_direct_response_dir2 ); } } @@ -4509,11 +4509,11 @@ void ivas_dirac_dec_compute_directional_responses_fx( { IF( hMasaIsm->ism_is_edited[dir] ) { - ivas_dirac_dec_get_response_fixed( hMasaIsm->azimuth_ism_edited[dir], hMasaIsm->elevation_ism_edited[dir], direct_response_temp_fx, hDirACRend->hOutSetup.ambisonics_order ); + ivas_dirac_dec_get_response_fx( hMasaIsm->azimuth_ism_edited[dir], hMasaIsm->elevation_ism_edited[dir], direct_response_temp_fx, hDirACRend->hOutSetup.ambisonics_order, Q29 ); } ELSE { - ivas_dirac_dec_get_response_fixed( hMasaIsm->azimuth_ism[dir][md_idx], hMasaIsm->elevation_ism[dir][md_idx], direct_response_temp_fx, hDirACRend->hOutSetup.ambisonics_order ); + ivas_dirac_dec_get_response_fx( hMasaIsm->azimuth_ism[dir][md_idx], hMasaIsm->elevation_ism[dir][md_idx], direct_response_temp_fx, hDirACRend->hOutSetup.ambisonics_order, Q29 ); } exp_direct_response_temp = 2; move16(); @@ -6246,13 +6246,13 @@ static void spreadCoherencePanningHoa_fx( Word32 gainCenter_fx; Word32 gainSide_fx; - ivas_dirac_dec_get_response_fixed_Q( azimuth, elevation, direct_response_fx, ambisonics_order, *Q_direct_response ); + ivas_dirac_dec_get_response_fx( azimuth, elevation, direct_response_fx, ambisonics_order, *Q_direct_response ); Word16 exp_Gain_side = 0, exp_Gain_center = 0; IF( GT_32( spreadCoh_fx, 0 ) ) { - ivas_dirac_dec_get_response_fixed_Q( azimuth + 30, elevation, direct_response_left_fx, ambisonics_order, *Q_direct_response ); - ivas_dirac_dec_get_response_fixed_Q( azimuth + 330, elevation, direct_response_right_fx, ambisonics_order, *Q_direct_response ); + ivas_dirac_dec_get_response_fx( azimuth + 30, elevation, direct_response_left_fx, ambisonics_order, *Q_direct_response ); + ivas_dirac_dec_get_response_fx( azimuth + 330, elevation, direct_response_right_fx, ambisonics_order, *Q_direct_response ); Word16 var_a, var_b, exp_a = 0; diff --git a/lib_rend/ivas_dirac_rend.c b/lib_rend/ivas_dirac_rend.c index 320138fc80c96c00dc13c340c76783ebac35d88f..6cb2491d799db64190ddd4c136144e925f347d3d 100644 --- a/lib_rend/ivas_dirac_rend.c +++ b/lib_rend/ivas_dirac_rend.c @@ -1874,7 +1874,7 @@ void compute_hoa_encoder_mtx_fx( num_sh = ivas_sba_get_nchan_fx( ambisonics_order, 0 ); FOR( k = 0; k < num_responses; k++ ) { - ivas_dirac_dec_get_response_fixed( shr( extract_h( azimuth[k] ), Q22 - Q16 ), shr( extract_h( elevation[k] ), Q22 - Q16 ), &response_fx[k * num_sh], ambisonics_order ); // Q29 + ivas_dirac_dec_get_response_fx( shr( extract_h( azimuth[k] ), Q22 - Q16 ), shr( extract_h( elevation[k] ), Q22 - Q16 ), &response_fx[k * num_sh], ambisonics_order, Q31 ); // Q29 } return; @@ -4135,7 +4135,7 @@ void ivas_dirac_dec_compute_diffuse_proto_fx( { /*DIRAC_SYNTHESIS_PSD_SHD: Virtual LS->HOA encoding*/ Word16 gb = find_guarded_bits_fx( hDirACRend->num_outputs_diff ); - diff_square_e = add( shl( add( 2, add( proto_e, gb ) ), 1 ), 1 ); + diff_square_e = add( shl( add( proto_e, gb ), 1 ), 1 ); max_e = add( s_max( diff_square_e, smooth_e ), 1 ); Scale_sig32( p_power_smooth_fx, h_dirac_output_synthesis_state->proto_power_diff_smooth_len, sub( smooth_e, max_e ) ); FOR( k = 0; k < hDirACRend->hOutSetup.nchan_out_woLFE; k++ ) @@ -4169,7 +4169,7 @@ void ivas_dirac_dec_compute_diffuse_proto_fx( p_diff_buffer_1_fx += 2; } } - diff_e = add( add( 2, proto_e ), gb ); + diff_e = add( proto_e, gb ); } h_dirac_output_synthesis_state->proto_power_diff_smooth_q = sub( 31, max_e ); diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index 3158cc8de05722e13a5aeed7683a44f3aa50f715..87b4f6d36e8d9e72e9e5dfbd411a07d28a6b7ff8 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -691,7 +691,7 @@ typedef struct ivas_dirac_rend_data_structure #else Word16 *frequency_axis_fx; /* Q0 */ Word16 *diffuse_response_function_fx; /* Q15 */ - Word32 *hoa_encoder_fx; /* Q29 */ + Word32 *hoa_encoder_fx; /* Q31 */ const Word32 *hoa_decoder; /* Q29 */ #endif /*Decoder parameters */ diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 63c64149ec63cb078c493ba215a5348f1fe8d44b..221c47a33b1b15b8f7b3b5a14853e030c429b9f8 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -3475,7 +3475,7 @@ static ivas_error updateLfePanGainsForAmbiOut( FOR( i = 0; i < numLfeIn; i++ ) { /* panning gains */ - ivas_dirac_dec_get_response_fixed( inputMc->lfeRouting.lfeOutputAzimuth_fx, inputMc->lfeRouting.lfeOutputElevation_fx, inputMc->lfeRouting.lfePanMtx_fx[i], outAmbiOrder ); + ivas_dirac_dec_get_response_fx( inputMc->lfeRouting.lfeOutputAzimuth_fx, inputMc->lfeRouting.lfeOutputElevation_fx, inputMc->lfeRouting.lfePanMtx_fx[i], outAmbiOrder, Q29 ); /* linear input gain */ v_multc_fixed( inputMc->lfeRouting.lfePanMtx_fx[i], inputMc->lfeRouting.lfeInputGain_fx, inputMc->lfeRouting.lfePanMtx_fx[i], IVAS_MAX_OUTPUT_CHANNELS ); @@ -3687,7 +3687,7 @@ static ivas_error updateMcPanGainsForAmbiOut( { ++ch_out; } - ivas_dirac_dec_get_response_fixed( (Word16) L_shr( spkAzi_fx[ch_in], 22 ), (Word16) L_shr( spkEle_fx[ch_in], 22 ), inputMc->panGains_fx[ch_out], outAmbiOrder ); + ivas_dirac_dec_get_response_fx( (Word16) L_shr( spkAzi_fx[ch_in], 22 ), (Word16) L_shr( spkEle_fx[ch_in], 22 ), inputMc->panGains_fx[ch_out], outAmbiOrder, Q29 ); FOR( i = 0; i < MAX_OUTPUT_CHANNELS; i++ ) { Word32 temp = inputMc->panGains_fx[ch_out][i]; @@ -3720,7 +3720,7 @@ static ivas_error updateMcPanGainsForAmbiOut( } } - ivas_dirac_dec_get_response_fixed( (Word16) L_shr( spkAzi_fx[ch_in], 22 ), (Word16) L_shr( spkEle_fx[ch_in], 22 ), inputMc->panGains_fx[ch_out], outAmbiOrder ); + ivas_dirac_dec_get_response_fx( (Word16) L_shr( spkAzi_fx[ch_in], 22 ), (Word16) L_shr( spkEle_fx[ch_in], 22 ), inputMc->panGains_fx[ch_out], outAmbiOrder, Q29 ); FOR( i = 0; i < MAX_OUTPUT_CHANNELS; i++ ) { Word32 temp = inputMc->panGains_fx[ch_out][i]; @@ -9684,10 +9684,11 @@ static ivas_error renderIsmToSba( // TODO tmu review when #215 is resolved azimuth_tmp = extract_l( L_shr( ismInput->previousPos.azimuth_fx, Q22 ) ); elevation_tmp = extract_l( L_shr( ismInput->previousPos.elevation_fx, Q22 ) ); - ivas_dirac_dec_get_response_fixed( azimuth_tmp, - elevation_tmp, - ismInput->prev_pan_gains_fx, - ambiOrderOut ); + ivas_dirac_dec_get_response_fx( azimuth_tmp, + elevation_tmp, + ismInput->prev_pan_gains_fx, + ambiOrderOut, + Q29 ); FOR( i = 0; i < MAX_OUTPUT_CHANNELS; i++ ) { ismInput->prev_pan_gains_fx[i] = L_shl_sat( ismInput->prev_pan_gains_fx[i], Q2 ); @@ -9700,10 +9701,11 @@ static ivas_error renderIsmToSba( // TODO tmu review when #215 is resolved azimuth_tmp = extract_l( L_shr( ismInput->currentPos.azimuth_fx, Q22 ) ); elevation_tmp = extract_l( L_shr( ismInput->currentPos.elevation_fx, Q22 ) ); - ivas_dirac_dec_get_response_fixed( azimuth_tmp, - elevation_tmp, - currentPanGains_fx, - ambiOrderOut ); + ivas_dirac_dec_get_response_fx( azimuth_tmp, + elevation_tmp, + currentPanGains_fx, + ambiOrderOut, + Q29 ); FOR( i = 0; i < MAX_OUTPUT_CHANNELS; i++ ) { currentPanGains_fx[i] = L_shl_sat( currentPanGains_fx[i], Q2 );