Loading lib_com/ivas_prot.h +4 −16 Original line number Diff line number Diff line Loading @@ -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 */ Loading Loading @@ -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( Loading lib_com/ivas_spar_com.c +23 −254 Original line number Diff line number Diff line Loading @@ -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 ); Loading @@ -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 ); Loading @@ -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 ); Loading Loading @@ -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, Loading Loading @@ -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; Loading @@ -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; Loading Loading @@ -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++ ) */ /* { */ Loading Loading @@ -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 ) Loading @@ -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; Loading lib_dec/ACcontextMapping_dec_fx.c +57 −22 Original line number Diff line number Diff line Loading @@ -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 ); Loading @@ -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; } Loading @@ -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 ); Loading @@ -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 */ Loading @@ -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 ) { Loading @@ -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; } Loading @@ -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 ) ) ); } Loading @@ -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(); } } } Loading @@ -565,6 +584,7 @@ Word16 RCcontextMapping_decode2_no_mem_s17_LCS_fx( /* Decode signs */ n = nt; move16(); } ELSE /* if(!hm_cfg) */ { Loading @@ -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 */ Loading @@ -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 ) { Loading @@ -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; } Loading @@ -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 ) ) { Loading @@ -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++ ) Loading @@ -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(); } } Loading @@ -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 */ Loading lib_dec/TonalComponentDetection.c +2 −4 Original line number Diff line number Diff line Loading @@ -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 *---------------------------------------------------------------------*/ Loading Loading @@ -889,3 +886,4 @@ static void findTonalComponents( return; } #endif lib_dec/TonalComponentDetection_fx.c +24 −11 File changed.Preview size limit exceeded, changes collapsed. Show changes Loading
lib_com/ivas_prot.h +4 −16 Original line number Diff line number Diff line Loading @@ -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 */ Loading Loading @@ -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( Loading
lib_com/ivas_spar_com.c +23 −254 Original line number Diff line number Diff line Loading @@ -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 ); Loading @@ -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 ); Loading @@ -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 ); Loading Loading @@ -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, Loading Loading @@ -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; Loading @@ -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; Loading Loading @@ -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++ ) */ /* { */ Loading Loading @@ -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 ) Loading @@ -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; Loading
lib_dec/ACcontextMapping_dec_fx.c +57 −22 Original line number Diff line number Diff line Loading @@ -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 ); Loading @@ -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; } Loading @@ -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 ); Loading @@ -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 */ Loading @@ -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 ) { Loading @@ -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; } Loading @@ -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 ) ) ); } Loading @@ -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(); } } } Loading @@ -565,6 +584,7 @@ Word16 RCcontextMapping_decode2_no_mem_s17_LCS_fx( /* Decode signs */ n = nt; move16(); } ELSE /* if(!hm_cfg) */ { Loading @@ -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 */ Loading @@ -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 ) { Loading @@ -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; } Loading @@ -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 ) ) { Loading @@ -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++ ) Loading @@ -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(); } } Loading @@ -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 */ Loading
lib_dec/TonalComponentDetection.c +2 −4 Original line number Diff line number Diff line Loading @@ -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 *---------------------------------------------------------------------*/ Loading Loading @@ -889,3 +886,4 @@ static void findTonalComponents( return; } #endif
lib_dec/TonalComponentDetection_fx.c +24 −11 File changed.Preview size limit exceeded, changes collapsed. Show changes