diff --git a/lib_com/cnst.h b/lib_com/cnst.h index 890f1b017785dc3a772a18a6caabacb2bd8d8136..7dde79cee4a31ac525a476a3191b1098da8ba742 100644 --- a/lib_com/cnst.h +++ b/lib_com/cnst.h @@ -575,7 +575,7 @@ enum #define FRAMES_PER_SEC 50 #ifdef IVAS_FLOAT_FIXED #define MAX_PARAM_SPATIAL_SUB_FRAMES_PER_SEC 200 //(FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES) -#define ONE_BY_FRAMES_PER_SEC ((Word32)(0x028F5C29)) +#define ONE_BY_FRAMES_PER_SEC_Q31 ((Word32)(0x028F5C29)) #define FRAMES_PER_SEC_BY_2 (FRAMES_PER_SEC >> 1) #endif #define INV_FRAME_PER_SEC_Q15 656 diff --git a/lib_com/ivas_entropy_coder_common.c b/lib_com/ivas_entropy_coder_common.c index 9dcf130608de406b283f8c6b0db68de5443458f0..69ceb4ffff8a504850f80512a816fa0844d35e24 100644 --- a/lib_com/ivas_entropy_coder_common.c +++ b/lib_com/ivas_entropy_coder_common.c @@ -48,7 +48,31 @@ * wrap around *-----------------------------------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED void ivas_wrap_arround( + int16_t *pArr, + const int16_t min_val, + const int16_t max_val, + const int16_t length ) +{ + int16_t i; + + for ( i = 0; i < length; i++ ) + { + if ( pArr[i] < min_val ) + { + pArr[i] = max_val - min_val + pArr[i] + 1; + } + if ( pArr[i] > max_val ) + { + pArr[i] = min_val + pArr[i] - max_val - 1; + } + } + + return; +} +#else +void ivas_wrap_arround_fx( Word16 *pArr, const Word16 min_val, const Word16 max_val, @@ -61,15 +85,18 @@ void ivas_wrap_arround( IF( LT_16( pArr[i], min_val ) ) { pArr[i] = add( sub( max_val, min_val ), add( pArr[i], 1 ) ); + move16(); } IF( GT_16( pArr[i], max_val ) ) { pArr[i] = sub( add( min_val, pArr[i] ), add( max_val, 1 ) ); + move16(); } } return; } +#endif /*-----------------------------------------------------------------------------------------* @@ -78,7 +105,25 @@ void ivas_wrap_arround( * get cumulative frequency model *-----------------------------------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED void ivas_get_cum_freq_model( + const int16_t *pFreq_model, + const int16_t length, + int16_t *pCum_freq_model ) +{ + int16_t i; + + pCum_freq_model[length] = 0; + + for ( i = length; i > 0; i-- ) + { + pCum_freq_model[i - 1] = pCum_freq_model[i] + pFreq_model[i]; + } + + return; +} +#else +void ivas_get_cum_freq_model_fx( const Word16 *pFreq_model, const Word16 length, Word16 *pCum_freq_model ) @@ -86,14 +131,17 @@ void ivas_get_cum_freq_model( Word16 i; pCum_freq_model[length] = 0; + move16(); FOR( i = length; i > 0; i-- ) { pCum_freq_model[i - 1] = add( pCum_freq_model[i], pFreq_model[i] ); + move16(); } return; } +#endif /*-----------------------------------------------------------------------------------------* @@ -102,29 +150,87 @@ void ivas_get_cum_freq_model( * Map the ivas_arith_pred_r_consts and ivas_huff_pred_r_consts tables *-----------------------------------------------------------------------------------------*/ -Word16 ivas_map_num_pred_r_to_idx( +#ifndef IVAS_FLOAT_FIXED +int16_t ivas_map_num_pred_r_to_idx( + const int16_t num_quant_points_pred_r, + const int16_t active_w_flag ) +{ + int16_t pred_r_to_idx = -1; + if ( active_w_flag == 0 ) + { + switch ( num_quant_points_pred_r ) + { + case 1: + pred_r_to_idx = PRED_Q_1; + break; + case 7: + pred_r_to_idx = PRED_Q_7; + break; + case 15: + pred_r_to_idx = PRED_Q_15; + break; + case 21: + pred_r_to_idx = PRED_Q_21; + break; + case 31: + pred_r_to_idx = PRED_Q_31; + break; + default: + assert( !"Forbidden value for prediction quantization strategy index" ); + break; + } + } + else + { + switch ( num_quant_points_pred_r ) + { + case 7: + pred_r_to_idx = PRED_Q_7_ACTIVE_W; + break; + case 15: + pred_r_to_idx = PRED_Q_15_ACTIVE_W; + break; + case 21: + pred_r_to_idx = PRED_Q_21_ACTIVE_W; + break; + default: + assert( !"Forbidden value for prediction quantization strategy index" ); + break; + } + } + + return pred_r_to_idx; +} +#else +Word16 ivas_map_num_pred_r_to_idx_fx( const Word16 num_quant_points_pred_r, const Word16 active_w_flag ) { Word16 pred_r_to_idx = -1; - IF( EQ_16( active_w_flag, 0 ) ) + move16(); + IF( active_w_flag == 0 ) { SWITCH( num_quant_points_pred_r ) { case 1: pred_r_to_idx = PRED_Q_1; + move16(); BREAK; case 7: pred_r_to_idx = PRED_Q_7; + move16(); BREAK; case 15: pred_r_to_idx = PRED_Q_15; + move16(); BREAK; case 21: pred_r_to_idx = PRED_Q_21; + move16(); BREAK; case 31: pred_r_to_idx = PRED_Q_31; + move16(); BREAK; default: assert( !"Forbidden value for prediction quantization strategy index" ); @@ -137,12 +243,15 @@ Word16 ivas_map_num_pred_r_to_idx( { case 7: pred_r_to_idx = PRED_Q_7_ACTIVE_W; + move16(); BREAK; case 15: pred_r_to_idx = PRED_Q_15_ACTIVE_W; + move16(); BREAK; case 21: pred_r_to_idx = PRED_Q_21_ACTIVE_W; + move16(); BREAK; default: assert( !"Forbidden value for prediction quantization strategy index" ); @@ -152,6 +261,7 @@ Word16 ivas_map_num_pred_r_to_idx( return pred_r_to_idx; } +#endif /*-----------------------------------------------------------------------------------------* @@ -160,23 +270,54 @@ Word16 ivas_map_num_pred_r_to_idx( * Map the ivas_arith_drct_r_consts and ivas_huff_drct_r_consts tables *-----------------------------------------------------------------------------------------*/ -Word16 ivas_map_num_drct_r_to_idx( +#ifndef IVAS_FLOAT_FIXED +int16_t ivas_map_num_drct_r_to_idx( + const int16_t num_quant_points_drct_r ) +{ + int16_t drct_r_to_idx = -1; + switch ( num_quant_points_drct_r ) + { + case 1: + drct_r_to_idx = DRCT_Q_1; + break; + case 7: + drct_r_to_idx = DRCT_Q_7; + break; + case 9: + drct_r_to_idx = DRCT_Q_9; + break; + case 11: + drct_r_to_idx = DRCT_Q_11; + break; + default: + assert( !"Forbidden value for DRCT quantization strategy index" ); + break; + } + return drct_r_to_idx; +} +#else +Word16 ivas_map_num_drct_r_to_idx_fx( const Word16 num_quant_points_drct_r ) { Word16 drct_r_to_idx = -1; + move16(); SWITCH( num_quant_points_drct_r ) { case 1: drct_r_to_idx = DRCT_Q_1; + move16(); BREAK; case 7: drct_r_to_idx = DRCT_Q_7; + move16(); BREAK; case 9: drct_r_to_idx = DRCT_Q_9; + move16(); BREAK; case 11: drct_r_to_idx = DRCT_Q_11; + move16(); BREAK; default: assert( !"Forbidden value for DRCT quantization strategy index" ); @@ -184,6 +325,7 @@ Word16 ivas_map_num_drct_r_to_idx( } return drct_r_to_idx; } +#endif /*-----------------------------------------------------------------------------------------* @@ -192,29 +334,69 @@ Word16 ivas_map_num_drct_r_to_idx( * Map the ivas_arith_decd_r_consts and ivas_huff_decd_r_consts tables *-----------------------------------------------------------------------------------------*/ -Word16 ivas_map_num_decd_r_to_idx( +#ifndef IVAS_FLOAT_FIXED +int16_t ivas_map_num_decd_r_to_idx( + const int16_t num_quant_points_decd_r ) +{ + int16_t decd_r_to_idx = -1; + switch ( num_quant_points_decd_r ) + { + case 1: + decd_r_to_idx = DECD_Q_1; + break; + case 3: + decd_r_to_idx = DECD_Q_3; + break; + case 5: + decd_r_to_idx = DECD_Q_5; + break; + case 7: + decd_r_to_idx = DECD_Q_7; + break; + case 9: + decd_r_to_idx = DECD_Q_9; + break; + case 11: + decd_r_to_idx = DECD_Q_11; + break; + default: + assert( !"Forbidden value for DECD quantization strategy index" ); + break; + } + + return decd_r_to_idx; +} +#else +Word16 ivas_map_num_decd_r_to_idx_fx( const Word16 num_quant_points_decd_r ) { Word16 decd_r_to_idx = -1; + move16(); SWITCH( num_quant_points_decd_r ) { case 1: decd_r_to_idx = DECD_Q_1; + move16(); BREAK; case 3: decd_r_to_idx = DECD_Q_3; + move16(); BREAK; case 5: decd_r_to_idx = DECD_Q_5; + move16(); BREAK; case 7: decd_r_to_idx = DECD_Q_7; + move16(); BREAK; case 9: decd_r_to_idx = DECD_Q_9; + move16(); BREAK; case 11: decd_r_to_idx = DECD_Q_11; + move16(); BREAK; default: assert( !"Forbidden value for DECD quantization strategy index" ); @@ -223,15 +405,16 @@ Word16 ivas_map_num_decd_r_to_idx( return decd_r_to_idx; } +#endif -#ifndef IVAS_FLOAT_FIXED /*---------------------------------------------------------------------------------------- - * * Function ivas_spar_arith_com_init() * * arith coder init *---------------------------------------------------------------------------------------- - */ +#ifndef IVAS_FLOAT_FIXED static void ivas_spar_arith_com_init( ivas_arith_t *pArith, const ivas_freq_models_t *pFreq_models, @@ -333,12 +516,6 @@ static void ivas_spar_arith_com_init( return; } #else -/*---------------------------------------------------------------------------------------- - * - * Function ivas_spar_arith_com_init_fx() - * - * arith coder init - *---------------------------------------------------------------------------------------- - */ - static void ivas_spar_arith_com_init_fx( ivas_arith_t *pArith, const ivas_freq_models_t *pFreq_models, @@ -348,25 +525,29 @@ static void ivas_spar_arith_com_init_fx( { Word16 i, j; Word16 sum, log2_int, log2_frac; - Word32 tmp32, log2_int32, L_tmp2; + Word32 tmp32, log2_int32, L_tmp1, L_tmp2; pArith->vals = pFreq_models->vals; pArith->range = q_levels; + move16(); pArith->num_models = pFreq_models->num_models; + move16(); pArith->dyn_model_bits = ivas_get_bits_to_encode( pArith->num_models - 1 ); + move16(); pArith->pFreq_model = pFreq_models->freq_model[0]; - ivas_get_cum_freq_model( pArith->pFreq_model, pArith->range, pArith->cum_freq[0] ); + ivas_get_cum_freq_model_fx( pArith->pFreq_model, pArith->range, pArith->cum_freq[0] ); FOR( i = 0; i < pArith->num_models - 1; i++ ) { pArith->pAlt_freq_models[i] = pFreq_models->freq_model[i + 1]; - ivas_get_cum_freq_model( pArith->pAlt_freq_models[i], pArith->range, pArith->cum_freq[i + 1] ); + ivas_get_cum_freq_model_fx( pArith->pAlt_freq_models[i], pArith->range, pArith->cum_freq[i + 1] ); } - IF( EQ_16( enc_dec, ENC ) ) + IF( enc_dec == ENC ) { sum = 0; + move16(); FOR( i = 1; i < pArith->range + 1; i++ ) { sum = add( sum, pArith->pFreq_model[i] ); @@ -374,22 +555,23 @@ static void ivas_spar_arith_com_init_fx( log2_int = norm_s( sum ); tmp32 = L_deposit_h( shl( sum, log2_int ) ); log2_frac = Log2_norm_lc( tmp32 ); - log2_int32 = L_shl( (Word32) sub( sub( 30, log2_int ), 16 ), 15 ); - L_tmp2 = L_add( log2_int32, (Word32) log2_frac ); /* Q15 */ + log2_int32 = L_shl( sub( sub( 30, log2_int ), 16 ), 15 ); + L_tmp2 = L_add( log2_int32, log2_frac ); /* Q15 */ FOR( i = 1; i < pArith->range + 1; i++ ) { - Word32 L_tmp1; log2_int = norm_s( pArith->pFreq_model[i] ); tmp32 = L_deposit_h( shl( pArith->pFreq_model[i], log2_int ) ); log2_frac = Log2_norm_lc( tmp32 ); - log2_int32 = L_shl( (Word32) sub( sub( 30, log2_int ), 16 ), 15 ); - L_tmp1 = L_add( log2_int32, (Word32) log2_frac ); /* Q15 */ + log2_int32 = L_shl( sub( sub( 30, log2_int ), 16 ), 15 ); + L_tmp1 = L_add( log2_int32, log2_frac ); /* Q15 */ pArith->saved_dist_arr[0][i - 1] = L_sub( L_tmp1, L_tmp2 ); + move32(); } FOR( j = 0; j < pArith->num_models - 1; j++ ) { sum = 0; + move16(); FOR( i = 1; i < pArith->range + 1; i++ ) { sum = add( sum, pArith->pAlt_freq_models[j][i] ); @@ -397,38 +579,42 @@ static void ivas_spar_arith_com_init_fx( log2_int = norm_s( sum ); tmp32 = L_deposit_h( shl( sum, log2_int ) ); log2_frac = Log2_norm_lc( tmp32 ); - log2_int32 = L_shl( (Word32) sub( sub( 30, log2_int ), 16 ), 15 ); - L_tmp2 = L_add( log2_int32, (Word32) log2_frac ); /* Q15 */ + log2_int32 = L_shl( sub( sub( 30, log2_int ), 16 ), 15 ); + L_tmp2 = L_add( log2_int32, log2_frac ); /* Q15 */ FOR( i = 1; i < pArith->range + 1; i++ ) { - Word32 L_tmp1; log2_int = norm_s( pArith->pAlt_freq_models[j][i] ); tmp32 = L_deposit_h( shl( pArith->pAlt_freq_models[j][i], log2_int ) ); log2_frac = Log2_norm_lc( tmp32 ); - log2_int32 = L_shl( (Word32) sub( sub( 30, log2_int ), 16 ), 15 ); - L_tmp1 = L_add( log2_int32, (Word32) log2_frac ); /* Q15 */ + log2_int32 = L_shl( sub( sub( 30, log2_int ), 16 ), 15 ); + L_tmp1 = L_add( log2_int32, log2_frac ); /* Q15 */ pArith->saved_dist_arr[j + 1][i - 1] = L_sub( L_tmp1, L_tmp2 ); + move32(); } } } pArith_diff->vals = pFreq_models->diff_vals; pArith_diff->range = q_levels; + move16(); pArith_diff->num_models = pFreq_models->diff_num_models; + move16(); pArith_diff->dyn_model_bits = ivas_get_bits_to_encode( pArith_diff->num_models - 1 ); + move16(); pArith_diff->pFreq_model = pFreq_models->diff_freq_model[0]; - ivas_get_cum_freq_model( pArith_diff->pFreq_model, pArith_diff->range, pArith_diff->cum_freq[0] ); + ivas_get_cum_freq_model_fx( pArith_diff->pFreq_model, pArith_diff->range, pArith_diff->cum_freq[0] ); FOR( i = 0; i < pArith_diff->num_models - 1; i++ ) { pArith_diff->pAlt_freq_models[i] = pFreq_models->diff_freq_model[i + 1]; - ivas_get_cum_freq_model( pArith_diff->pAlt_freq_models[i], pArith_diff->range, pArith_diff->cum_freq[i + 1] ); + ivas_get_cum_freq_model_fx( pArith_diff->pAlt_freq_models[i], pArith_diff->range, pArith_diff->cum_freq[i + 1] ); } - IF( EQ_16( enc_dec, ENC ) ) + IF( enc_dec == ENC ) { sum = 0; + move16(); FOR( i = 1; i < pArith_diff->range + 1; i++ ) { sum = add( sum, pArith_diff->pFreq_model[i] ); @@ -436,22 +622,23 @@ static void ivas_spar_arith_com_init_fx( log2_int = norm_s( sum ); tmp32 = L_deposit_h( shl( sum, log2_int ) ); log2_frac = Log2_norm_lc( tmp32 ); - log2_int32 = L_shl( (Word32) sub( sub( 30, log2_int ), 16 ), 15 ); - L_tmp2 = L_add( log2_int32, (Word32) log2_frac ); /* Q15 */ + log2_int32 = L_shl( sub( sub( 30, log2_int ), 16 ), 15 ); + L_tmp2 = L_add( log2_int32, log2_frac ); /* Q15 */ FOR( i = 1; i < pArith_diff->range + 1; i++ ) { - Word32 L_tmp1; log2_int = norm_s( pArith_diff->pFreq_model[i] ); tmp32 = L_deposit_h( shl( pArith_diff->pFreq_model[i], log2_int ) ); log2_frac = Log2_norm_lc( tmp32 ); - log2_int32 = L_shl( (Word32) sub( sub( 30, log2_int ), 16 ), 15 ); - L_tmp1 = L_add( log2_int32, (Word32) log2_frac ); /* Q15 */ + log2_int32 = L_shl( sub( sub( 30, log2_int ), 16 ), 15 ); + L_tmp1 = L_add( log2_int32, log2_frac ); /* Q15 */ pArith_diff->saved_dist_arr[0][i - 1] = L_sub( L_tmp1, L_tmp2 ); + move32(); } FOR( j = 0; j < pArith_diff->num_models - 1; j++ ) { sum = 0; + move16(); FOR( i = 1; i < pArith_diff->range + 1; i++ ) { sum = add( sum, pArith_diff->pAlt_freq_models[j][i] ); @@ -459,17 +646,17 @@ static void ivas_spar_arith_com_init_fx( log2_int = norm_s( sum ); tmp32 = L_deposit_h( shl( sum, log2_int ) ); log2_frac = Log2_norm_lc( tmp32 ); - log2_int32 = L_shl( (Word32) sub( sub( 30, log2_int ), 16 ), 15 ); - L_tmp2 = L_add( log2_int32, (Word32) log2_frac ); /* Q15 */ + log2_int32 = L_shl( sub( sub( 30, log2_int ), 16 ), 15 ); + L_tmp2 = L_add( log2_int32, log2_frac ); /* Q15 */ FOR( i = 1; i < pArith_diff->range + 1; i++ ) { - Word32 L_tmp1; log2_int = norm_s( pArith_diff->pAlt_freq_models[j][i] ); tmp32 = L_deposit_h( shl( pArith_diff->pAlt_freq_models[j][i], log2_int ) ); log2_frac = Log2_norm_lc( tmp32 ); - log2_int32 = L_shl( (Word32) sub( sub( 30, log2_int ), 16 ), 15 ); - L_tmp1 = L_add( log2_int32, (Word32) log2_frac ); /* Q15 */ + log2_int32 = L_shl( sub( sub( 30, log2_int ), 16 ), 15 ); + L_tmp1 = L_add( log2_int32, log2_frac ); /* Q15 */ pArith_diff->saved_dist_arr[j + 1][i - 1] = L_sub( L_tmp1, L_tmp2 ); + move32(); } } } @@ -477,13 +664,46 @@ static void ivas_spar_arith_com_init_fx( return; } #endif + + /*-----------------------------------------------------------------------------------------* * Function ivas_spar_arith_coeffs_com_init() * * Init for Arithm. coding *-----------------------------------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED void ivas_spar_arith_coeffs_com_init( + ivas_arith_coeffs_t *pArith_coeffs, + ivas_spar_md_com_cfg *pSpar_cfg, + const int16_t table_idx, + const int16_t enc_dec ) +{ + int16_t i, pred_r_index, drct_r_index, decd_r_index; + int16_t num_quant_points_pred_r, num_quant_points_drct_r, num_quant_points_decd_r; + + for ( i = 0; i < MAX_QUANT_STRATS; i++ ) + { + num_quant_points_pred_r = ivas_spar_br_table_consts[table_idx].q_lvls[i][0]; /* 0: pred_r */ + pred_r_index = ivas_map_num_pred_r_to_idx( num_quant_points_pred_r, ivas_spar_br_table_consts[table_idx].active_w ); + ivas_spar_arith_com_init( &pArith_coeffs->pred_arith_re[i], &ivas_arith_pred_r_consts[pred_r_index], + &pArith_coeffs->pred_arith_re_diff[i], pSpar_cfg->quant_strat[i].PR.q_levels[0], enc_dec ); + + num_quant_points_drct_r = ivas_spar_br_table_consts[table_idx].q_lvls[i][1]; /* 1: drct_r */ + drct_r_index = ivas_map_num_drct_r_to_idx( num_quant_points_drct_r ); + ivas_spar_arith_com_init( &pArith_coeffs->drct_arith_re[i], &ivas_arith_drct_r_consts[drct_r_index], + &pArith_coeffs->drct_arith_re_diff[i], pSpar_cfg->quant_strat[i].C.q_levels[0], enc_dec ); + + num_quant_points_decd_r = ivas_spar_br_table_consts[table_idx].q_lvls[i][2]; /* 2: decd_r */ + decd_r_index = ivas_map_num_decd_r_to_idx( num_quant_points_decd_r ); + ivas_spar_arith_com_init( &pArith_coeffs->decd_arith_re[i], &ivas_arith_decd_r_consts[decd_r_index], + &pArith_coeffs->decd_arith_re_diff[i], pSpar_cfg->quant_strat[i].P_r.q_levels[0], enc_dec ); + } + + return; +} +#else +void ivas_spar_arith_coeffs_com_init_fx( ivas_arith_coeffs_t *pArith_coeffs, ivas_spar_md_com_cfg *pSpar_cfg, const Word16 table_idx, @@ -495,36 +715,27 @@ void ivas_spar_arith_coeffs_com_init( FOR( i = 0; i < MAX_QUANT_STRATS; i++ ) { num_quant_points_pred_r = ivas_spar_br_table_consts[table_idx].q_lvls[i][0]; /* 0: pred_r */ - pred_r_index = ivas_map_num_pred_r_to_idx( num_quant_points_pred_r, ivas_spar_br_table_consts[table_idx].active_w ); -#ifdef IVAS_FLOAT_FIXED + move16(); + pred_r_index = ivas_map_num_pred_r_to_idx_fx( num_quant_points_pred_r, ivas_spar_br_table_consts[table_idx].active_w ); ivas_spar_arith_com_init_fx( &pArith_coeffs->pred_arith_re[i], &ivas_arith_pred_r_consts[pred_r_index], &pArith_coeffs->pred_arith_re_diff[i], pSpar_cfg->quant_strat[i].PR.q_levels[0], enc_dec ); -#else - ivas_spar_arith_com_init( &pArith_coeffs->pred_arith_re[i], &ivas_arith_pred_r_consts[pred_r_index], - &pArith_coeffs->pred_arith_re_diff[i], pSpar_cfg->quant_strat[i].PR.q_levels[0], enc_dec ); -#endif + num_quant_points_drct_r = ivas_spar_br_table_consts[table_idx].q_lvls[i][1]; /* 1: drct_r */ - drct_r_index = ivas_map_num_drct_r_to_idx( num_quant_points_drct_r ); -#ifdef IVAS_FLOAT_FIXED + move16(); + drct_r_index = ivas_map_num_drct_r_to_idx_fx( num_quant_points_drct_r ); ivas_spar_arith_com_init_fx( &pArith_coeffs->drct_arith_re[i], &ivas_arith_drct_r_consts[drct_r_index], &pArith_coeffs->drct_arith_re_diff[i], pSpar_cfg->quant_strat[i].C.q_levels[0], enc_dec ); -#else - ivas_spar_arith_com_init( &pArith_coeffs->drct_arith_re[i], &ivas_arith_drct_r_consts[drct_r_index], - &pArith_coeffs->drct_arith_re_diff[i], pSpar_cfg->quant_strat[i].C.q_levels[0], enc_dec ); -#endif + num_quant_points_decd_r = ivas_spar_br_table_consts[table_idx].q_lvls[i][2]; /* 2: decd_r */ - decd_r_index = ivas_map_num_decd_r_to_idx( num_quant_points_decd_r ); -#ifdef IVAS_FLOAT_FIXED + move16(); + decd_r_index = ivas_map_num_decd_r_to_idx_fx( num_quant_points_decd_r ); ivas_spar_arith_com_init_fx( &pArith_coeffs->decd_arith_re[i], &ivas_arith_decd_r_consts[decd_r_index], &pArith_coeffs->decd_arith_re_diff[i], pSpar_cfg->quant_strat[i].P_r.q_levels[0], enc_dec ); -#else - ivas_spar_arith_com_init( &pArith_coeffs->decd_arith_re[i], &ivas_arith_decd_r_consts[decd_r_index], - &pArith_coeffs->decd_arith_re_diff[i], pSpar_cfg->quant_strat[i].P_r.q_levels[0], enc_dec ); -#endif } return; } +#endif /*-----------------------------------------------------------------------------------------* @@ -533,8 +744,37 @@ void ivas_spar_arith_coeffs_com_init( * Find min and max length in codebook and finalize initialization of ivas_huffman_cfg_t. *-----------------------------------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED static void ivas_huffman_dec_init_min_max_len( ivas_huffman_cfg_t *p_huff_cfg ) +{ + int16_t i, code_len; + const int16_t *codebook; + + codebook = p_huff_cfg->codebook; + + p_huff_cfg->min_len = p_huff_cfg->sym_len; + p_huff_cfg->max_len = 0; + + for ( i = 0; i < p_huff_cfg->sym_len; i++ ) + { + code_len = codebook[1]; + if ( p_huff_cfg->min_len > code_len ) + { + p_huff_cfg->min_len = code_len; + } + if ( p_huff_cfg->max_len < code_len ) + { + p_huff_cfg->max_len = code_len; + } + codebook = codebook + 3; + } + + return; +} +#else +static void ivas_huffman_dec_init_min_max_len_fx( + ivas_huffman_cfg_t *p_huff_cfg ) { Word16 i, code_len; const Word16 *codebook; @@ -542,24 +782,30 @@ static void ivas_huffman_dec_init_min_max_len( codebook = p_huff_cfg->codebook; p_huff_cfg->min_len = p_huff_cfg->sym_len; + move16(); p_huff_cfg->max_len = 0; + move16(); FOR( i = 0; i < p_huff_cfg->sym_len; i++ ) { code_len = codebook[1]; - IF( GT_16( p_huff_cfg->min_len, code_len ) ) + move16(); + if ( GT_16( p_huff_cfg->min_len, code_len ) ) { p_huff_cfg->min_len = code_len; + move16(); } - IF( LT_16( p_huff_cfg->max_len, code_len ) ) + if ( LT_16( p_huff_cfg->max_len, code_len ) ) { p_huff_cfg->max_len = code_len; + move16(); } codebook = codebook + 3; } return; } +#endif /*-----------------------------------------------------------------------------------------* @@ -568,7 +814,54 @@ static void ivas_huffman_dec_init_min_max_len( * Init for Huffman decoding *-----------------------------------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED void ivas_spar_huff_coeffs_com_init( + ivas_huff_coeffs_t *pHuff_coeffs, + ivas_spar_md_com_cfg *pSpar_cfg, + const int16_t table_idx, + const int16_t enc_dec ) +{ + int16_t i, pred_r_index, drct_r_index, decd_r_index; + int16_t num_quant_points_pred_r, num_quant_points_drct_r, num_quant_points_decd_r; + ivas_huffman_cfg_t *p_huff_cfg; + + for ( i = 0; i < MAX_QUANT_STRATS; i++ ) + { + p_huff_cfg = &pHuff_coeffs->pred_huff_re[i]; + num_quant_points_pred_r = ivas_spar_br_table_consts[table_idx].q_lvls[i][0]; /* 0: pred_r */ + pred_r_index = ivas_map_num_pred_r_to_idx( num_quant_points_pred_r, 0 ); + p_huff_cfg->codebook = &ivas_huff_pred_r_consts[pred_r_index].code_book[0][0]; + if ( enc_dec == DEC ) + { + p_huff_cfg->sym_len = pSpar_cfg->quant_strat[i].PR.q_levels[0]; + ivas_huffman_dec_init_min_max_len( p_huff_cfg ); + } + + p_huff_cfg = &pHuff_coeffs->drct_huff_re[i]; + num_quant_points_drct_r = ivas_spar_br_table_consts[table_idx].q_lvls[i][1]; /* 1: drct_r */ + drct_r_index = ivas_map_num_drct_r_to_idx( num_quant_points_drct_r ); + p_huff_cfg->codebook = &ivas_huff_drct_r_consts[drct_r_index].code_book[0][0]; + if ( enc_dec == DEC ) + { + p_huff_cfg->sym_len = pSpar_cfg->quant_strat[i].C.q_levels[0]; + ivas_huffman_dec_init_min_max_len( p_huff_cfg ); + } + + p_huff_cfg = &pHuff_coeffs->decd_huff_re[i]; + num_quant_points_decd_r = ivas_spar_br_table_consts[table_idx].q_lvls[i][2]; /* 2: decd_r */ + decd_r_index = ivas_map_num_decd_r_to_idx( num_quant_points_decd_r ); + p_huff_cfg->codebook = &ivas_huff_decd_r_consts[decd_r_index].code_book[0][0]; + if ( enc_dec == DEC ) + { + p_huff_cfg->sym_len = pSpar_cfg->quant_strat[i].P_r.q_levels[0]; + ivas_huffman_dec_init_min_max_len( p_huff_cfg ); + } + } + + return; +} +#else +void ivas_spar_huff_coeffs_com_init_fx( ivas_huff_coeffs_t *pHuff_coeffs, ivas_spar_md_com_cfg *pSpar_cfg, const Word16 table_idx, @@ -582,34 +875,41 @@ void ivas_spar_huff_coeffs_com_init( { p_huff_cfg = &pHuff_coeffs->pred_huff_re[i]; num_quant_points_pred_r = ivas_spar_br_table_consts[table_idx].q_lvls[i][0]; /* 0: pred_r */ - pred_r_index = ivas_map_num_pred_r_to_idx( num_quant_points_pred_r, 0 ); + move16(); + pred_r_index = ivas_map_num_pred_r_to_idx_fx( num_quant_points_pred_r, 0 ); p_huff_cfg->codebook = &ivas_huff_pred_r_consts[pred_r_index].code_book[0][0]; IF( EQ_16( enc_dec, DEC ) ) { p_huff_cfg->sym_len = pSpar_cfg->quant_strat[i].PR.q_levels[0]; - ivas_huffman_dec_init_min_max_len( p_huff_cfg ); + move16(); + ivas_huffman_dec_init_min_max_len_fx( p_huff_cfg ); } p_huff_cfg = &pHuff_coeffs->drct_huff_re[i]; num_quant_points_drct_r = ivas_spar_br_table_consts[table_idx].q_lvls[i][1]; /* 1: drct_r */ - drct_r_index = ivas_map_num_drct_r_to_idx( num_quant_points_drct_r ); + move16(); + drct_r_index = ivas_map_num_drct_r_to_idx_fx( num_quant_points_drct_r ); p_huff_cfg->codebook = &ivas_huff_drct_r_consts[drct_r_index].code_book[0][0]; IF( EQ_16( enc_dec, DEC ) ) { p_huff_cfg->sym_len = pSpar_cfg->quant_strat[i].C.q_levels[0]; - ivas_huffman_dec_init_min_max_len( p_huff_cfg ); + move16(); + ivas_huffman_dec_init_min_max_len_fx( p_huff_cfg ); } p_huff_cfg = &pHuff_coeffs->decd_huff_re[i]; num_quant_points_decd_r = ivas_spar_br_table_consts[table_idx].q_lvls[i][2]; /* 2: decd_r */ - decd_r_index = ivas_map_num_decd_r_to_idx( num_quant_points_decd_r ); + move16(); + decd_r_index = ivas_map_num_decd_r_to_idx_fx( num_quant_points_decd_r ); p_huff_cfg->codebook = &ivas_huff_decd_r_consts[decd_r_index].code_book[0][0]; IF( EQ_16( enc_dec, DEC ) ) { p_huff_cfg->sym_len = pSpar_cfg->quant_strat[i].P_r.q_levels[0]; - ivas_huffman_dec_init_min_max_len( p_huff_cfg ); + move16(); + ivas_huffman_dec_init_min_max_len_fx( p_huff_cfg ); } } return; } +#endif diff --git a/lib_com/ivas_omasa_com.c b/lib_com/ivas_omasa_com.c index c76621969b0f032ac5aae955509dcc5ca11c4883..afdac0d9bc934bdab993ab1eb7f5cac23dc75285 100644 --- a/lib_com/ivas_omasa_com.c +++ b/lib_com/ivas_omasa_com.c @@ -89,7 +89,7 @@ /*! r : ISM format mode */ #ifdef IVAS_FLOAT_FIXED -ISM_MODE ivas_omasa_ism_mode_select( +ISM_MODE ivas_omasa_ism_mode_select_fx( const Word32 ivas_total_brate, /* i : IVAS total bitrate */ const Word16 nchan_ism /* i : number of input ISM's */ ) @@ -169,6 +169,7 @@ ISM_MODE ivas_omasa_ism_mode_select( ELSE { ism_mode = ISM_MODE_NONE; + move16(); } BREAK; } @@ -258,7 +259,7 @@ ISM_MODE ivas_omasa_ism_mode_select( * ---------------------------------------------------------------*/ #ifdef IVAS_FLOAT_FIXED -void ivas_set_omasa_TC( +void ivas_set_omasa_TC_fx( const ISM_MODE ism_mode, /* i : ISM mode */ const Word16 nchan_ism, /* i : number of input ISMs */ Word16 *nSCE, /* o : number of SCEs */ @@ -331,7 +332,7 @@ void ivas_set_omasa_TC( /*! r: adjusted bitrate */ #ifdef IVAS_FLOAT_FIXED -Word32 ivas_interformat_brate( +Word32 ivas_interformat_brate_fx( const ISM_MODE ism_mode, /* i : ISM mode */ const Word16 nchan_ism, /* i : number of ISM channels */ const Word32 element_brate, /* i : element bitrate */ @@ -342,17 +343,32 @@ Word32 ivas_interformat_brate( Word32 element_brate_out; Word16 nBits, limit_low, limit_high; - nBits = extract_l( div_l( element_brate, shr( FRAMES_PER_SEC, 1 ) ) ); + nBits = extract_l( Mpy_32_32( element_brate, ONE_BY_FRAMES_PER_SEC_Q31 ) ); /* Q0 */ - IF( EQ_16( ism_imp, ISM_INACTIVE_IMP ) ) + IF( ism_imp == ISM_INACTIVE_IMP ) { nBits = BITS_ISM_INACTIVE; move16(); } ELSE { - IF( EQ_16( (Word16) ism_mode, (Word16) ISM_MASA_MODE_DISC ) && ( ( EQ_16( nchan_ism, 4 ) && EQ_32( element_brate, 24000 ) ) || ( EQ_16( nchan_ism, 3 ) && LE_32( element_brate, 24000 ) ) || ( EQ_16( nchan_ism, 2 ) && LE_32( element_brate, 11000 ) ) ) ) /* for border case in DISC mode */ + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + IF( EQ_16( ism_mode, ISM_MASA_MODE_DISC ) && ( ( EQ_16( nchan_ism, 4 ) && EQ_32( element_brate, 24000 ) ) || ( EQ_16( nchan_ism, 3 ) && LE_32( element_brate, 24000 ) ) || ( EQ_16( nchan_ism, 2 ) && LE_32( element_brate, 11000 ) ) ) ) /* for border case in DISC mode */ { + test(); + test(); + test(); + test(); + test(); + test(); IF( EQ_16( limit_flag, 1 ) && ( ( EQ_16( nchan_ism, 4 ) && EQ_32( element_brate, 24000 ) ) || ( EQ_16( nchan_ism, 3 ) && EQ_32( element_brate, 20000 ) ) || ( EQ_16( nchan_ism, 2 ) && LE_32( element_brate, 11000 ) ) ) ) { return element_brate; @@ -379,11 +395,12 @@ Word32 ivas_interformat_brate( } } } - ELSE IF( EQ_16( (Word16) ism_mode, (Word16) ISM_MASA_MODE_PARAM_ONE_OBJ ) || - ( EQ_16( (Word16) ism_mode, (Word16) ISM_MASA_MODE_DISC ) && EQ_32( element_brate, 9600 ) ) /* this condition corresponds to the ivas_total_brate = 24400 and 1 object */ + ELSE IF( EQ_16( ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) || + ( EQ_16( ism_mode, ISM_MASA_MODE_DISC ) && EQ_32( element_brate, 9600 ) ) /* this condition corresponds to the ivas_total_brate = 24400 and 1 object */ ) { - IF( EQ_16( (Word16) ism_mode, (Word16) ISM_MASA_MODE_PARAM_ONE_OBJ ) && EQ_32( element_brate, IVAS_13k2 ) ) + test(); + IF( EQ_16( ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) && EQ_32( element_brate, IVAS_13k2 ) ) { IF( EQ_16( ism_imp, ISM_LOW_IMP ) ) { @@ -414,7 +431,7 @@ Word32 ivas_interformat_brate( } } } - ELSE IF( EQ_16( (Word16) ism_mode, (Word16) ISM_MASA_MODE_MASA_ONE_OBJ ) && EQ_32( element_brate, 16000 ) ) + ELSE IF( EQ_16( ism_mode, ISM_MASA_MODE_MASA_ONE_OBJ ) && EQ_32( element_brate, 16000 ) ) { IF( EQ_16( ism_imp, ISM_LOW_IMP ) ) { @@ -447,7 +464,8 @@ Word32 ivas_interformat_brate( } limit_low = MIN_BRATE_SWB_BWE / FRAMES_PER_SEC; - IF( EQ_16( ism_imp, ISM_INACTIVE_IMP ) ) + move16(); + IF( ism_imp == ISM_INACTIVE_IMP ) { limit_low = BITS_ISM_INACTIVE; move16(); @@ -466,7 +484,7 @@ Word32 ivas_interformat_brate( move16(); } - nBits = check_bounds_s( nBits, limit_low, limit_high ); + nBits = check_bounds_s_fx( nBits, limit_low, limit_high ); element_brate_out = L_mult0( nBits, FRAMES_PER_SEC ); @@ -618,7 +636,7 @@ int32_t ivas_interformat_brate( * ---------------------------------------------------------------*/ #ifdef IVAS_FLOAT_FIXED -void ivas_combined_format_brate_sanity( +void ivas_combined_format_brate_sanity_fx( const Word32 element_brate, /* i : element bitrate */ const Word16 core, /* i : core */ const Word32 total_brate, /* i : total bitrate */ @@ -640,10 +658,10 @@ void ivas_combined_format_brate_sanity( { limit_high = ACELP_12k8_HIGH_LIMIT / FRAMES_PER_SEC; move16(); - nBits = extract_l( div_l( *core_brate, shr( FRAMES_PER_SEC, 1 ) ) ); + nBits = extract_l( Mpy_32_32( *core_brate, ONE_BY_FRAMES_PER_SEC_Q31 ) ); *diff_nBits = sub( nBits, limit_high ); - IF( GT_16( *diff_nBits, 0 ) ) + IF( *diff_nBits > 0 ) { IF( EQ_16( core, TCX_20_CORE ) || EQ_16( core, TCX_10_CORE ) ) { @@ -661,11 +679,11 @@ void ivas_combined_format_brate_sanity( * set inactive coder_type flag in ACELP core *-----------------------------------------------------------------*/ - IF( EQ_16( core, ACELP_CORE ) ) + IF( core == ACELP_CORE ) { *inactive_coder_type_flag = 0; /* AVQ by default */ move16(); - IF( LE_32( L_add( *core_brate, brate_diff ), MAX_GSC_INACTIVE_BRATE ) ) + if ( LE_32( L_add( *core_brate, brate_diff ), MAX_GSC_INACTIVE_BRATE ) ) { *inactive_coder_type_flag = 1; /* GSC */ move16(); @@ -729,6 +747,7 @@ void ivas_combined_format_brate_sanity( } #endif + /*--------------------------------------------------------------- * bits_index_ism_ratio() * @@ -737,7 +756,7 @@ void ivas_combined_format_brate_sanity( /*!r : number of bits for ISM ratio index */ #ifdef IVAS_FLOAT_FIXED -Word16 bits_index_ism_ratio( +Word16 bits_index_ism_ratio_fx( const Word16 nchan_ism /* i : number of objects */ ) { @@ -802,7 +821,7 @@ int16_t bits_index_ism_ratio( * * ---------------------------------------------------------------*/ - +#ifndef IVAS_FLOAT_FIXED void calculate_nbits_meta( const int16_t nchan_ism, float q_energy_ratio_ism[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS][MAX_NUM_OBJECTS], @@ -860,7 +879,7 @@ void calculate_nbits_meta( return; } -#ifdef IVAS_FLOAT_FIXED +#else static Word16 get_bits_ism( Word32 val ) { Word16 res; @@ -914,7 +933,7 @@ void calculate_nbits_meta_fx( const Word16 ism_imp ) { Word16 sf, band, obj; - Word32 priority[MAX_NUM_OBJECTS], max_p; + Word32 priority[MAX_NUM_OBJECTS], max_p; /* Q29 */ IF( GT_16( nchan_ism, 1 ) ) { @@ -925,7 +944,7 @@ void calculate_nbits_meta_fx( { FOR( obj = 0; obj < nchan_ism; obj++ ) { - priority[obj] = max( priority[obj], ( Mpy_32_32( q_energy_ratio_ism[sf][band][obj], L_sub( 1073741824, masa_to_total_energy_ratio[sf][band] ) ) ) ); // Qx - 1 + priority[obj] = L_max( priority[obj], ( Mpy_32_32( q_energy_ratio_ism[sf][band][obj], L_sub( 1073741824 /* 1.0f in Q30 */, masa_to_total_energy_ratio[sf][band] ) ) ) ); // Qx - 1 move32(); } } @@ -933,7 +952,7 @@ void calculate_nbits_meta_fx( } ELSE { - priority[0] = 536870912; + priority[0] = 536870912; /* 1.0f in Q29 */ move32(); } @@ -945,7 +964,7 @@ void calculate_nbits_meta_fx( { IF( EQ_16( ism_imp, 3 ) ) { - priority[obj] = 536870912; + priority[obj] = 536870912; /* 1.0f in Q29 */ move32(); } ELSE IF( EQ_16( ism_imp, 2 ) ) @@ -955,7 +974,7 @@ void calculate_nbits_meta_fx( } ELSE { - priority[obj] = max_p; + priority[obj] = max_p; /* Q29 */ move32(); } } @@ -966,6 +985,7 @@ void calculate_nbits_meta_fx( } #endif + /*--------------------------------------------------------------- * ivas_get_stereo_panning_gains() * @@ -1161,7 +1181,7 @@ void ivas_get_stereo_panning_gains_fx( /*! r: limitation flag */ #ifdef IVAS_FLOAT_FIXED -Word16 calculate_brate_limit_flag( +Word16 calculate_brate_limit_flag_fx( const Word16 ism_imp[], /* i : ISM importance flags */ const Word16 nchan_ism /* i : number of objects */ ) @@ -1178,17 +1198,19 @@ Word16 calculate_brate_limit_flag( FOR( n = 0; n < nchan_ism; n++ ) { brate_limit_flag = add( brate_limit_flag, ism_imp[n] ); - IF( EQ_16( ism_imp[n], 0 ) ) + if ( ism_imp[n] == 0 ) { nzeros = add( nzeros, 1 ); } } nchan_ism_sat = nchan_ism; - IF( EQ_16( nchan_ism & 1, 1 ) ) + if ( EQ_16( nchan_ism & 1, 1 ) ) { nchan_ism_sat = sub( nchan_ism, 1 ); } + + /* brate_limit_flag >= (int16_t) ( nchan_ism * 2.5f ) */ IF( GE_16( i_mult( 2, brate_limit_flag ), add( i_mult( 4, nchan_ism ), nchan_ism_sat ) ) ) { brate_limit_flag = 1; @@ -1196,7 +1218,7 @@ Word16 calculate_brate_limit_flag( } ELSE { - IF( GE_16( i_mult( 2, nzeros ), nchan_ism ) ) + if ( GE_16( i_mult( 2, nzeros ), nchan_ism ) ) { brate_limit_flag = -1; /* there is no limitation, on the contrary */ move16(); diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 91be1b984d0532881d4157656e91fcf57ef156f5..f7c387d2d85e1fd283d7d30c17634a54cc733835 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -2307,4 +2307,81 @@ MC_LS_SETUP ivas_mc_map_output_config_to_mc_ls_setup_fx( AUDIO_CONFIG ivas_mc_map_ls_setup_to_output_config_fx( const MC_LS_SETUP mc_ls_setup /* i : multi channel loudspeaker setup*/ ); + +void ivas_wrap_arround_fx( + Word16 *pArr, + const Word16 min_val, + const Word16 max_val, + const Word16 length ); + +void ivas_get_cum_freq_model_fx( + const Word16 *pFreq_model, + const Word16 length, + Word16 *pCum_freq_model ); + +Word16 ivas_map_num_pred_r_to_idx_fx( + const Word16 num_quant_points_pred_r, + const Word16 active_w_flag ); + +Word16 ivas_map_num_drct_r_to_idx_fx( + const Word16 num_quant_points_drct_r ); + +Word16 ivas_map_num_decd_r_to_idx_fx( + const Word16 num_quant_points_decd_r ); + +void ivas_spar_arith_coeffs_com_init_fx( + ivas_arith_coeffs_t *pArith_coeffs, + ivas_spar_md_com_cfg *pSpar_cfg, + const Word16 table_idx, + const Word16 enc_dec ); + +void ivas_spar_huff_coeffs_com_init_fx( + ivas_huff_coeffs_t *pHuff_coeffs, + ivas_spar_md_com_cfg *pSpar_cfg, + const Word16 table_idx, + const Word16 enc_dec ); + +ISM_MODE ivas_omasa_ism_mode_select_fx( + const Word32 ivas_total_brate, /* i : IVAS total bitrate */ + const Word16 nchan_ism /* i : number of input ISM's */ +); + +void ivas_set_omasa_TC_fx( + const ISM_MODE ism_mode, /* i : ISM mode */ + const Word16 nchan_ism, /* i : number of input ISMs */ + Word16 *nSCE, /* o : number of SCEs */ + Word16 *nCPE /* o : number of CPEs */ +); + +Word32 ivas_interformat_brate_fx( + const ISM_MODE ism_mode, /* i : ISM mode */ + const Word16 nchan_ism, /* i : number of ISM channels */ + const Word32 element_brate, /* i : element bitrate */ + const Word16 ism_imp, /* i : ISM importance flag */ + const Word16 limit_flag /* i : flag to limit the bitrate increase */ +); + +Word16 check_bounds_s_fx( + const Word16 value, /* i : Input value */ + const Word16 low, /* i : Low limit */ + const Word16 high /* i : High limit */ +); + +void ivas_combined_format_brate_sanity_fx( + const Word32 element_brate, /* i : element bitrate */ + const Word16 core, /* i : core */ + const Word32 total_brate, /* i : total bitrate */ + Word32 *core_brate, /* i/o: core bitrate */ + Word16 *inactive_coder_type_flag, /* o : inactive coder_type flag */ + Word16 *diff_nBits /* o : number of differential bits */ +); + +Word16 bits_index_ism_ratio_fx( + const Word16 nchan_ism /* i : number of objects */ +); + +Word16 calculate_brate_limit_flag_fx( + const Word16 ism_imp[], /* i : ISM importance flags */ + const Word16 nchan_ism /* i : number of objects */ +); #endif diff --git a/lib_com/ivas_stat_com.h b/lib_com/ivas_stat_com.h index 586d88f1a82379ae187eb315d874ff07e37e25f9..34b7942d628ace50d2d52d2ebf1f8008ab97a2f8 100644 --- a/lib_com/ivas_stat_com.h +++ b/lib_com/ivas_stat_com.h @@ -317,7 +317,7 @@ typedef struct ivas_arith_t int16_t range; int16_t num_models; #ifdef IVAS_FLOAT_FIXED - Word32 saved_dist_arr[IVAS_NUM_PROB_MODELS][IVAS_MAX_QUANT_LEVELS]; + Word32 saved_dist_arr[IVAS_NUM_PROB_MODELS][IVAS_MAX_QUANT_LEVELS]; /* Q15 */ #else float saved_dist_arr[IVAS_NUM_PROB_MODELS][IVAS_MAX_QUANT_LEVELS]; #endif diff --git a/lib_com/ivas_tools.c b/lib_com/ivas_tools.c index 91824fff94516d18d318267cf8b8013c56aecd93..dfc98c90deb164f1a52d12a6476fd6b8eada42e4 100644 --- a/lib_com/ivas_tools.c +++ b/lib_com/ivas_tools.c @@ -1161,6 +1161,20 @@ int16_t check_bounds_s( return value_adj; } +#ifdef IVAS_FLOAT_FIXED +Word16 check_bounds_s_fx( + const Word16 value, /* i : Input value */ + const Word16 low, /* i : Low limit */ + const Word16 high /* i : High limit */ +) +{ + Word16 value_adj; + + value_adj = s_min( s_max( value, low ), high ); + + return value_adj; +} +#endif /*-------------------------------------------------------------------* * check_bounds_l() diff --git a/lib_dec/ivas_core_dec.c b/lib_dec/ivas_core_dec.c index 8bbbd12e8b1480a97ae8de2e333f78aef3fdc950..4ee545e4923c21dc398826f47350f8350a45520e 100644 --- a/lib_dec/ivas_core_dec.c +++ b/lib_dec/ivas_core_dec.c @@ -401,7 +401,7 @@ ivas_error ivas_core_dec( test(); IF( hCPE != NULL && EQ_16( hCPE->element_mode, IVAS_CPE_DFT ) && hCPE->brate_surplus > 0 ) { - ivas_combined_format_brate_sanity( hCPE->element_brate, sts[0]->core, sts[0]->total_brate, &( sts[0]->core_brate ), &( sts[0]->inactive_coder_type_flag ), &tmps ); + ivas_combined_format_brate_sanity_fx( hCPE->element_brate, sts[0]->core, sts[0]->total_brate, &( sts[0]->core_brate ), &( sts[0]->inactive_coder_type_flag ), &tmps ); } /*------------------------------------------------------------------* diff --git a/lib_dec/ivas_entropy_decoder.c b/lib_dec/ivas_entropy_decoder.c index 01922f9c351bf01ec741b53db4193d071db93382..af8e4082afc9aefcddf041985670c7edec3c551b 100644 --- a/lib_dec/ivas_entropy_decoder.c +++ b/lib_dec/ivas_entropy_decoder.c @@ -38,6 +38,9 @@ #include "ivas_rom_com.h" #include #include "wmc_auto.h" +#ifdef IVAS_FLOAT_FIXED +#include "ivas_prot_fx.h" +#endif /*------------------------------------------------------------------------------------------* @@ -134,7 +137,11 @@ static void ivas_arithCoder_decode_array_diff( pOutput_arr[n] = add( sub( pSymbol_old[n], offset ), pOutput_arr[n] ); } +#ifndef IVAS_FLOAT_FIXED ivas_wrap_arround( pOutput_arr, 0, sub( pArith_diff->range, 1 ), length ); +#else + ivas_wrap_arround_fx( pOutput_arr, 0, sub( pArith_diff->range, 1 ), length ); +#endif FOR( n = 0; n < length; n++ ) { diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 234fe1e114ce192e1f1579b287653a184de19ff8..eb526f1f5a9e8ee43cefcebaa330850af7ecf0ba 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -210,7 +210,8 @@ ivas_error ivas_dec_setup( /* for the DISC mode the number of objects are written at the end of the bitstream, in the MASA metadata */ st_ivas->nchan_ism = 2 * st_ivas->bit_stream[ivas_total_brate / FRAMES_PER_SEC - 1] + st_ivas->bit_stream[ivas_total_brate / FRAMES_PER_SEC - 2] + 1; - st_ivas->ism_mode = ivas_omasa_ism_mode_select( ivas_total_brate, st_ivas->nchan_ism ); + st_ivas->ism_mode = ivas_omasa_ism_mode_select_fx( ivas_total_brate, st_ivas->nchan_ism ); + move32(); IF( GT_16( st_ivas->ini_frame, 0 ) ) { diff --git a/lib_dec/ivas_masa_dec.c b/lib_dec/ivas_masa_dec.c index 6dce33f67cb5e7c2b026244167650202cd1f48d0..2673ec268499e2735849586633fa26b96fa02b9d 100644 --- a/lib_dec/ivas_masa_dec.c +++ b/lib_dec/ivas_masa_dec.c @@ -4767,7 +4767,7 @@ static void read_ism_ratio_index_fx( IF( EQ_16( sf, 0 ) ) { - bits_index = bits_index_ism_ratio( nchan_ism ); + bits_index = bits_index_ism_ratio_fx( nchan_ism ); /* read coding type */ IF( EQ_32( bit_stream[( *next_bit_pos )--], 1 ) ) diff --git a/lib_dec/ivas_omasa_dec.c b/lib_dec/ivas_omasa_dec.c index d3b2595a0ade9c55469be22279ce4fc56ebe5a05..d239baccc9d718c2df27ef202e26a7557ee3c5eb 100644 --- a/lib_dec/ivas_omasa_dec.c +++ b/lib_dec/ivas_omasa_dec.c @@ -272,7 +272,7 @@ ivas_error ivas_omasa_dec_config_fx( move32(); /* save previous frame parameters */ - ism_mode_old = ivas_omasa_ism_mode_select( st_ivas->hDecoderConfig->last_ivas_total_brate, st_ivas->nchan_ism ); + ism_mode_old = ivas_omasa_ism_mode_select_fx( st_ivas->hDecoderConfig->last_ivas_total_brate, st_ivas->nchan_ism ); move16(); st_ivas->ism_mode = ism_mode_old; move16(); @@ -294,7 +294,7 @@ ivas_error ivas_omasa_dec_config_fx( move16(); /* set ism_mode of current frame */ - st_ivas->ism_mode = ivas_omasa_ism_mode_select( ivas_total_brate, st_ivas->nchan_ism ); + st_ivas->ism_mode = ivas_omasa_ism_mode_select_fx( ivas_total_brate, st_ivas->nchan_ism ); move16(); /*-----------------------------------------------------------------* @@ -343,7 +343,7 @@ ivas_error ivas_omasa_dec_config_fx( } } - ivas_set_omasa_TC( st_ivas->ism_mode, st_ivas->nchan_ism, &st_ivas->nSCE, &st_ivas->nCPE ); + ivas_set_omasa_TC_fx( st_ivas->ism_mode, st_ivas->nchan_ism, &st_ivas->nSCE, &st_ivas->nCPE ); /* re-configure hp20 memories */ IF( ( error = ivas_hp20_dec_reconfig_fx( st_ivas, nchan_hp20_old ) ) != IVAS_ERR_OK ) @@ -915,7 +915,8 @@ void ivas_set_surplus_brate_dec( test(); IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_MASA_ONE_OBJ ) || EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) ) { - *ism_total_brate = ivas_interformat_brate( st_ivas->ism_mode, 1, st_ivas->hSCE[0]->element_brate, st_ivas->hIsmMetaData[0]->ism_imp, 0 ); + *ism_total_brate = ivas_interformat_brate_fx( st_ivas->ism_mode, 1, st_ivas->hSCE[0]->element_brate, st_ivas->hIsmMetaData[0]->ism_imp, 0 ); + move32(); st_ivas->hCPE[0]->brate_surplus = L_sub( st_ivas->hSCE[0]->element_brate, *ism_total_brate ); @@ -941,8 +942,7 @@ void ivas_set_surplus_brate_dec( move16(); } - brate_limit_flag = calculate_brate_limit_flag( ism_imp, st_ivas->nchan_ism ); - move16(); + brate_limit_flag = calculate_brate_limit_flag_fx( ism_imp, st_ivas->nchan_ism ); ism_total_brate_ref = 0; move32(); @@ -972,7 +972,8 @@ void ivas_set_surplus_brate_dec( st_ivas->hSCE[n]->element_brate = element_brate[n]; move32(); - *ism_total_brate = L_add( *ism_total_brate, ivas_interformat_brate( ISM_MASA_MODE_DISC, st_ivas->nchan_ism, st_ivas->hSCE[n]->element_brate, st_ivas->hIsmMetaData[n]->ism_imp, brate_limit_flag ) ); + *ism_total_brate = L_add( *ism_total_brate, ivas_interformat_brate_fx( ISM_MASA_MODE_DISC, st_ivas->nchan_ism, st_ivas->hSCE[n]->element_brate, st_ivas->hIsmMetaData[n]->ism_imp, brate_limit_flag ) ); + move32(); test(); test(); diff --git a/lib_dec/ivas_spar_md_dec.c b/lib_dec/ivas_spar_md_dec.c index 125d7c7ae8ac8b1a4b09423260c6963da4a18b4f..44a771249cb699d3131618f7ff47998a285817d1 100644 --- a/lib_dec/ivas_spar_md_dec.c +++ b/lib_dec/ivas_spar_md_dec.c @@ -1033,8 +1033,8 @@ ivas_error ivas_spar_md_dec_init( PR_minmax_fx[1] = hMdDec->spar_md_cfg.quant_strat[0].PR.max_fx; ivas_spar_quant_dtx_init_fx( &hMdDec->spar_md, PR_minmax_fx ); - ivas_spar_arith_coeffs_com_init( &hMdDec->arith_coeffs, &hMdDec->spar_md_cfg, hMdDec->table_idx, DEC ); - ivas_spar_huff_coeffs_com_init( &hMdDec->huff_coeffs, &hMdDec->spar_md_cfg, hMdDec->table_idx, DEC ); + ivas_spar_arith_coeffs_com_init_fx( &hMdDec->arith_coeffs, &hMdDec->spar_md_cfg, hMdDec->table_idx, DEC ); + ivas_spar_huff_coeffs_com_init_fx( &hMdDec->huff_coeffs, &hMdDec->spar_md_cfg, hMdDec->table_idx, DEC ); hMdDec->spar_md_cfg.prev_quant_idx = -1; diff --git a/lib_dec/ivas_stereo_dft_dec_fx.c b/lib_dec/ivas_stereo_dft_dec_fx.c index 8a7f883ec7a39b976feabbb0a7b92143c49769c2..d11dd6ba2e7c938db20bc51b4c50a4cdaf85a63b 100644 --- a/lib_dec/ivas_stereo_dft_dec_fx.c +++ b/lib_dec/ivas_stereo_dft_dec_fx.c @@ -1396,7 +1396,7 @@ void stereo_dft_dec_fx( Word32 DFT_W, DFT_Y; Word16 q_samp_ratio = Q15; - output_frame = (Word16) Mpy_32_32( L_add( st0->output_Fs, FRAMES_PER_SEC_BY_2 ), ONE_BY_FRAMES_PER_SEC ); + output_frame = (Word16) Mpy_32_32( L_add( st0->output_Fs, FRAMES_PER_SEC_BY_2 ), ONE_BY_FRAMES_PER_SEC_Q31 ); /*------------------------------------------------------------------* * Initialization diff --git a/lib_enc/ivas_core_enc.c b/lib_enc/ivas_core_enc.c index db7f5d9d11e5062f175f3fc90962711d67fc204c..ebc6bd649cf2cc12072983b0593b6122d7ce99bf 100644 --- a/lib_enc/ivas_core_enc.c +++ b/lib_enc/ivas_core_enc.c @@ -39,6 +39,9 @@ #include "ivas_prot.h" #include "wmc_auto.h" #include +#ifdef IVAS_FLOAT_FIXED +#include "ivas_prot_fx.h" +#endif /*-------------------------------------------------------------------* @@ -183,11 +186,22 @@ ivas_error ivas_core_enc( * Sanity check in combined format coding *-----------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED diff_nBits = 0; if ( hCPE != NULL && hCPE->element_mode == IVAS_CPE_DFT && hCPE->brate_surplus > 0 ) { ivas_combined_format_brate_sanity( hCPE->element_brate, sts[0]->core, sts[0]->total_brate, &( sts[0]->core_brate ), &( sts[0]->inactive_coder_type_flag ), &diff_nBits ); } +#else + diff_nBits = 0; + move16(); + test(); + test(); + IF( hCPE != NULL && EQ_16( hCPE->element_mode, IVAS_CPE_DFT ) && hCPE->brate_surplus > 0 ) + { + ivas_combined_format_brate_sanity_fx( hCPE->element_brate, sts[0]->core, sts[0]->total_brate, &( sts[0]->core_brate ), &( sts[0]->inactive_coder_type_flag ), &diff_nBits ); + } +#endif /*---------------------------------------------------------------------* * Core Encoding diff --git a/lib_enc/ivas_entropy_coder.c b/lib_enc/ivas_entropy_coder.c index 757378034384d99db3b5f59ff599ca7d46e35aa7..14ed149e12b1a901742b6478ae3b11898e2e3d45 100644 --- a/lib_enc/ivas_entropy_coder.c +++ b/lib_enc/ivas_entropy_coder.c @@ -39,6 +39,9 @@ #include "math.h" #include #include "wmc_auto.h" +#ifdef IVAS_FLOAT_FIXED +#include "ivas_prot_fx.h" +#endif #ifndef IVAS_FLOAT_FIXED /*-----------------------------------------------------------------------------------------* @@ -286,7 +289,11 @@ static Word16 ivas_arithCoder_encode_array_diff( pIn_old_scratch[n] = sub( pIn_new[n], pIn_old_scratch[n] ); } +#ifndef IVAS_FLOAT_FIXED ivas_wrap_arround( pIn_old_scratch, pArith_diff->vals[0], pArith_diff->vals[pArith_diff->range - 1], length ); +#else + ivas_wrap_arround_fx( pIn_old_scratch, pArith_diff->vals[0], pArith_diff->vals[pArith_diff->range - 1], length ); +#endif arith_result = ivas_arith_encode_array( pIn_old_scratch, pArith_diff, hMetaData, length, wc_strat_arith ); IF( LT_16( arith_result, 0 ) ) diff --git a/lib_enc/ivas_init_enc.c b/lib_enc/ivas_init_enc.c index cc7ee8f2cfc163babef5ce0e1cb1e117ffb60379..1daf86b23182bbf690903ae3492cc2bf47f885c0 100644 --- a/lib_enc/ivas_init_enc.c +++ b/lib_enc/ivas_init_enc.c @@ -656,7 +656,12 @@ ivas_error ivas_init_encoder( int32_t ism_total_brate; int16_t k; +#ifndef IVAS_FLOAT_FIXED st_ivas->ism_mode = ivas_omasa_ism_mode_select( ivas_total_brate, hEncoderConfig->nchan_ism ); +#else + st_ivas->ism_mode = ivas_omasa_ism_mode_select_fx( ivas_total_brate, hEncoderConfig->nchan_ism ); + move32(); +#endif st_ivas->nchan_transport = 2; if ( ( error = ivas_ism_metadata_enc_create( st_ivas, hEncoderConfig->nchan_ism, element_brate_tmp ) ) != IVAS_ERR_OK ) @@ -1233,7 +1238,12 @@ ivas_error ivas_init_encoder_fx( int32_t ism_total_brate; int16_t k; +#ifndef IVAS_FLOAT_FIXED st_ivas->ism_mode = ivas_omasa_ism_mode_select( ivas_total_brate, hEncoderConfig->nchan_ism ); +#else + st_ivas->ism_mode = ivas_omasa_ism_mode_select_fx( ivas_total_brate, hEncoderConfig->nchan_ism ); + move32(); +#endif st_ivas->nchan_transport = 2; if ( ( error = ivas_ism_metadata_enc_create( st_ivas, hEncoderConfig->nchan_ism, element_brate_tmp ) ) != IVAS_ERR_OK ) diff --git a/lib_enc/ivas_ism_metadata_enc.c b/lib_enc/ivas_ism_metadata_enc.c index 2154f30422fde4109d7d925e02e0d3d9da183f70..0b4a5e2e9a8f949feef8eac9e0c90a98d343d3a9 100644 --- a/lib_enc/ivas_ism_metadata_enc.c +++ b/lib_enc/ivas_ism_metadata_enc.c @@ -40,6 +40,9 @@ #include "prot.h" #include #include "wmc_auto.h" +#ifdef IVAS_FLOAT_FIXED +#include "ivas_prot_fx.h" +#endif /*-----------------------------------------------------------------------* @@ -631,7 +634,11 @@ ivas_error ivas_ism_metadata_enc( int16_t brate_limit_flag; int32_t ism_total_brate_ref; ism_total_brate_ref = *ism_total_brate; +#ifndef IVAS_FLOAT_FIXED brate_limit_flag = calculate_brate_limit_flag( ism_imp, nchan_ism ); +#else + brate_limit_flag = calculate_brate_limit_flag_fx( ism_imp, nchan_ism ); +#endif bits_ism = (int16_t) ( *ism_total_brate / FRAMES_PER_SEC ); set_s( bits_element, bits_ism / nchan_ism, nchan_ism ); @@ -641,7 +648,12 @@ ivas_error ivas_ism_metadata_enc( *ism_total_brate = 0; for ( ch = 0; ch < nchan_ism; ch++ ) { +#ifndef IVAS_FLOAT_FIXED *ism_total_brate += ivas_interformat_brate( ism_mode, nchan_ism, hSCE[ch]->element_brate, ism_imp[ch], brate_limit_flag ); +#else + *ism_total_brate = L_add( *ism_total_brate, ivas_interformat_brate_fx( ism_mode, nchan_ism, hSCE[ch]->element_brate, ism_imp[ch], brate_limit_flag ) ); + move32(); +#endif if ( ism_imp[ch] > 1 && flag_omasa_ener_brate == 1 && brate_limit_flag >= 0 ) { @@ -760,7 +772,11 @@ ivas_error ivas_ism_metadata_enc_create( if ( st_ivas->hEncoderConfig->ivas_format == MASA_ISM_FORMAT ) { nchan_transport = MAX_PARAM_ISM_WAVE; +#ifndef IVAS_FLOAT_FIXED ivas_set_omasa_TC( st_ivas->ism_mode, n_ISms, &st_ivas->nSCE, &st_ivas->nCPE ); +#else + ivas_set_omasa_TC_fx( st_ivas->ism_mode, n_ISms, &st_ivas->nSCE, &st_ivas->nCPE ); +#endif } else if ( st_ivas->hEncoderConfig->ivas_format == SBA_ISM_FORMAT ) { diff --git a/lib_enc/ivas_masa_enc.c b/lib_enc/ivas_masa_enc.c index 2445f2e0d9373762e834f8e8daf0c2faac4da9e9..4cc597b980eaeb94a5e463e0002089ef7784bc0a 100644 --- a/lib_enc/ivas_masa_enc.c +++ b/lib_enc/ivas_masa_enc.c @@ -3635,7 +3635,11 @@ static int16_t encode_ratio_ism_subframe( bits_index = 0; if ( sf == 0 ) { +#ifndef IVAS_FLOAT_FIXED bits_index = bits_index_ism_ratio( nchan_ism ); +#else + bits_index = bits_index_ism_ratio_fx( nchan_ism ); +#endif nbits = 0; for ( b = 0; b < numCodingBands; b++ ) @@ -4126,7 +4130,20 @@ static void ivas_encode_masaism_metadata( } } +#ifndef IVAS_FLOAT_FIXED calculate_nbits_meta( nchan_ism, hOmasaData->q_energy_ratio_ism, hOmasaData->masa_to_total_energy_ratio, numSf, numCodingBands, bits_ism, idx_separated_object, ism_imp ); +#else + FOR( sf = 0; sf < numSf; ++sf ) + { + FOR( band = 0; band < numCodingBands; ++band ) + { + floatToFixed_arr32( hOmasaData->q_energy_ratio_ism[sf][band], hOmasaData->q_energy_ratio_ism_fx[sf][band], Q30, nchan_ism ); + hOmasaData->masa_to_total_energy_ratio_fx[sf][band] = floatToFixed_32( hOmasaData->masa_to_total_energy_ratio[sf][band], Q30 ); + } + } + + calculate_nbits_meta_fx( nchan_ism, hOmasaData->q_energy_ratio_ism_fx, hOmasaData->masa_to_total_energy_ratio_fx, numSf, numCodingBands, bits_ism, idx_separated_object, ism_imp ); +#endif /* quantize directions */ for ( obj = 0; obj < nchan_ism; obj++ ) diff --git a/lib_enc/ivas_omasa_enc.c b/lib_enc/ivas_omasa_enc.c index 1f5499f077b6ba94c298383577809601c502ed80..075135e4184b26058096abb3c1885ab8fca78f2a 100644 --- a/lib_enc/ivas_omasa_enc.c +++ b/lib_enc/ivas_omasa_enc.c @@ -216,13 +216,22 @@ ivas_error ivas_omasa_enc_config( ivas_total_brate = hEncoderConfig->ivas_total_brate; nSCE_old = st_ivas->nSCE; +#ifndef IVAS_FLOAT_FIXED st_ivas->ism_mode = ivas_omasa_ism_mode_select( ivas_total_brate, hEncoderConfig->nchan_ism ); +#else + st_ivas->ism_mode = ivas_omasa_ism_mode_select_fx( ivas_total_brate, hEncoderConfig->nchan_ism ); + move32(); +#endif st_ivas->nchan_transport = 2; /* reconfiguration in case of bitrate switching */ if ( hEncoderConfig->last_ivas_total_brate != ivas_total_brate ) { +#ifndef IVAS_FLOAT_FIXED ivas_set_omasa_TC( st_ivas->ism_mode, hEncoderConfig->nchan_ism, &st_ivas->nSCE, &st_ivas->nCPE ); +#else + ivas_set_omasa_TC_fx( st_ivas->ism_mode, hEncoderConfig->nchan_ism, &st_ivas->nSCE, &st_ivas->nCPE ); +#endif k = 0; while ( k < SIZE_IVAS_BRATE_TBL && ivas_total_brate != ivas_brate_tbl[k] ) @@ -673,7 +682,12 @@ void ivas_set_surplus_brate_enc( { if ( st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ ) { +#ifndef IVAS_FLOAT_FIXED st_ivas->hCPE[0]->brate_surplus = st_ivas->hSCE[0]->element_brate - ivas_interformat_brate( ISM_MASA_MODE_PARAM_ONE_OBJ, 1, st_ivas->hSCE[0]->element_brate, st_ivas->hIsmMetaData[0]->ism_imp, 0 ); +#else + st_ivas->hCPE[0]->brate_surplus = L_sub( st_ivas->hSCE[0]->element_brate, ivas_interformat_brate_fx( ISM_MASA_MODE_PARAM_ONE_OBJ, 1, st_ivas->hSCE[0]->element_brate, st_ivas->hIsmMetaData[0]->ism_imp, 0 ) ); + move32(); +#endif /* note: ISM st->total_brate is iset in ivas_sce_enc() */ } else if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC || st_ivas->ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ ) diff --git a/lib_enc/ivas_sce_enc.c b/lib_enc/ivas_sce_enc.c index ba36a7a2b1bab0dc04227605bb598821fc99e7d7..3e40937fb44f3d371aedf9c601c346f5a5444ee1 100644 --- a/lib_enc/ivas_sce_enc.c +++ b/lib_enc/ivas_sce_enc.c @@ -210,7 +210,12 @@ ivas_error ivas_sce_enc( { ivas_set_ism_importance_interformat( hSCE->element_brate, 1, st_ivas->hIsmMetaData, st_ivas->hSCE, st_ivas->hMasa->data.hOmasaData->lp_noise_CPE, &st_ivas->hIsmMetaData[0]->ism_imp ); +#ifndef IVAS_FLOAT_FIXED st->total_brate = ivas_interformat_brate( ISM_MASA_MODE_PARAM_ONE_OBJ, 1, hSCE->element_brate, st_ivas->hIsmMetaData[0]->ism_imp, 0 ) - nb_bits_metadata * FRAMES_PER_SEC; +#else + st->total_brate = L_sub( ivas_interformat_brate_fx( ISM_MASA_MODE_PARAM_ONE_OBJ, 1, hSCE->element_brate, st_ivas->hIsmMetaData[0]->ism_imp, 0 ), L_mult0( nb_bits_metadata, FRAMES_PER_SEC ) ); + move32(); +#endif } /*----------------------------------------------------------------* diff --git a/lib_enc/ivas_spar_md_enc.c b/lib_enc/ivas_spar_md_enc.c index b7a74310ea2142b73e5dbe2f38d573c83f5eecc3..88dc5ffc83ce551a19da84bb2038a9936896a289 100644 --- a/lib_enc/ivas_spar_md_enc.c +++ b/lib_enc/ivas_spar_md_enc.c @@ -342,8 +342,13 @@ ivas_error ivas_spar_md_enc_init( return IVAS_ERR_INTERNAL; } +#ifndef IVAS_FLOAT_FIXED ivas_spar_arith_coeffs_com_init( &hMdEnc->arith_coeffs, &hMdEnc->spar_md_cfg, table_idx, ENC ); ivas_spar_huff_coeffs_com_init( &hMdEnc->huff_coeffs, NULL, table_idx, ENC ); +#else + ivas_spar_arith_coeffs_com_init_fx( &hMdEnc->arith_coeffs, &hMdEnc->spar_md_cfg, table_idx, ENC ); + ivas_spar_huff_coeffs_com_init_fx( &hMdEnc->huff_coeffs, NULL, table_idx, ENC ); +#endif if ( hEncoderConfig->Opt_DTX_ON == 1 ) { @@ -408,8 +413,8 @@ ivas_error ivas_spar_md_enc_init_fx( return IVAS_ERR_INTERNAL; } - ivas_spar_arith_coeffs_com_init( &hMdEnc->arith_coeffs, &hMdEnc->spar_md_cfg, table_idx, ENC ); - ivas_spar_huff_coeffs_com_init( &hMdEnc->huff_coeffs, NULL, table_idx, ENC ); + ivas_spar_arith_coeffs_com_init_fx( &hMdEnc->arith_coeffs, &hMdEnc->spar_md_cfg, table_idx, ENC ); + ivas_spar_huff_coeffs_com_init_fx( &hMdEnc->huff_coeffs, NULL, table_idx, ENC ); #if 0 // Some issues IF (EQ_16(hEncoderConfig->Opt_DTX_ON, 1)) { diff --git a/lib_enc/lib_enc.c b/lib_enc/lib_enc.c index 6de215c499a6e0fb84b61417e9ab1ab55e774f1b..292956a0aab3b158469596d4014927b6c7f603e3 100644 --- a/lib_enc/lib_enc.c +++ b/lib_enc/lib_enc.c @@ -928,11 +928,14 @@ static ivas_error configureEncoder( } else if ( hEncoderConfig->ivas_format == MASA_ISM_FORMAT ) { +#ifndef IVAS_FLOAT_FIXED st_ivas->ism_mode = ivas_omasa_ism_mode_select( st_ivas->hEncoderConfig->ivas_total_brate, hEncoderConfig->nchan_ism ); -#ifndef IVAS_FLOAT_FIXED cpe_brate = calculate_cpe_brate_MASA_ISM( st_ivas->ism_mode, st_ivas->hEncoderConfig->ivas_total_brate, hEncoderConfig->nchan_ism ); #else + st_ivas->ism_mode = ivas_omasa_ism_mode_select_fx( st_ivas->hEncoderConfig->ivas_total_brate, hEncoderConfig->nchan_ism ); + move32(); + cpe_brate = calculate_cpe_brate_MASA_ISM_fx( st_ivas->ism_mode, st_ivas->hEncoderConfig->ivas_total_brate, hEncoderConfig->nchan_ism ); #endif @@ -1217,7 +1220,7 @@ static ivas_error configureEncoder_fx( } ELSE IF( EQ_32( hEncoderConfig->ivas_format, MASA_ISM_FORMAT ) ) { - st_ivas->ism_mode = ivas_omasa_ism_mode_select( st_ivas->hEncoderConfig->ivas_total_brate, hEncoderConfig->nchan_ism ); + st_ivas->ism_mode = ivas_omasa_ism_mode_select_fx( st_ivas->hEncoderConfig->ivas_total_brate, hEncoderConfig->nchan_ism ); cpe_brate = calculate_cpe_brate_MASA_ISM_fx( st_ivas->ism_mode, st_ivas->hEncoderConfig->ivas_total_brate, hEncoderConfig->nchan_ism );