diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index c43692ea91768f9c409e3151706a85f31ee22e31..85d2fff74a2be52af26dfcad302625c452d345a2 100755 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -1413,6 +1413,9 @@ typedef enum #ifdef FIX_563_PARAMMC_LIMITER #define PARAM_MC_ENER_LIMIT_MAX_DELTA_FAC (15.0f) #endif +#ifdef FIX_580_PARAMMC_ENER_BURSTS +#define PARAM_MC_NUM_ATTACK_ILD_THRESH (3) +#endif #define PARAM_MC_LFE_ON_THRESH (8000.0f) #define PARAM_MC_BAND_TO_MDCT_BAND_RATIO 16 /* Ratio of resolution of CLDFB Bands to MDCT Bands */ #define PARAM_MC_SLOT_ENC_NS 2500000L diff --git a/lib_com/ivas_rom_com.c b/lib_com/ivas_rom_com.c index 0368b1970081ae2b7e558f0279af5fdce1db0677..5677a3cc9b48b95616b71944fc1583ce2ae16e89 100644 --- a/lib_com/ivas_rom_com.c +++ b/lib_com/ivas_rom_com.c @@ -1803,7 +1803,6 @@ const int16_t param_mc_band_grouping_14[14 + 1] = 0, 1, 2, 3, 4, 5, 6, 8, 10, 13, 16, 20, 28, 40, 60 }; - const int16_t param_mc_coding_band_mapping_14[14] = { 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0 diff --git a/lib_com/options.h b/lib_com/options.h index dbe71e39f142d2918d9527e0b18e9efaa8cc078f..68e40038025d149c5dd85f456e557d35d1dc1b9f 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -58,7 +58,7 @@ #ifdef DEBUGGING -/*#define DEBUG_MODE_INFO*/ /* output most important parameters to the subdirectory "res/" */ +/*#define DEBUG_MODE_INFO*/ /* output most important parameters to the subdirectory "res/" */ #ifdef DEBUG_MODE_INFO /*#define DEBUG_MODE_ACELP*/ /* output most important ACELP core parameters to the subdirectory "res/" */ /*#define DEBUG_MODE_TCX*/ /* output most important TCX core parameters to the subdirectory "res/" */ @@ -66,7 +66,7 @@ /*#define DEBUG_MODE_TD*/ /* output most important TD stereo parameters to the subdirectory "res/ */ /*#define DEBUG_MODE_DIRAC*/ /* output most important DIRAC parameters to the subdirectory "res/" */ /*#define DEBUG_MODE_MDCT*/ /* output most important MDCT parameters to the subdirectory "res/" */ -/*#define DEBUG_MODE_PARAM_MC */ /* output Parametric MC paramters to the subdirectory "res/" */ +/*#define DEBUG_MODE_PARAM_MC*/ /* output Parametric MC paramters to the subdirectory "res/" */ /*#define DEBUG_MODE_PARAM_ISM*/ /* output Parametric ISM paramters to the subdirectory "res/" */ /*#define DEBUG_MODE_INFO_TWEAK*/ /* enable command line switch to specify subdirectory for debug info output inside "./res/" */ /*#define DEBUG_MODE_INFO_PLC */ /* define to output PLC related parameters */ @@ -158,7 +158,7 @@ #define FIX_UNCLR_ISSUE /* VoiceAge: issue 574: Fix UNCLR mis-classifications in noisy speech stereo */ #define FIX_TCX_LOWRATE_LIMITATION /* VA: issue 577: TCX bitrate limitation only when DEBUGGING is active */ #define FIX_575_LOW_OVERLAP_PLC_RECOVERY /* FhG: Issue 575 fix for PLC and transistion to TCX5*/ - +#define FIX_580_PARAMMC_ENER_BURSTS /* FhG: issue 580: energy bursts due to ILD holding when energy relations change too much */ /* ################## End DEVELOPMENT switches ######################### */ /* clang-format on */ diff --git a/lib_enc/ivas_mc_param_enc.c b/lib_enc/ivas_mc_param_enc.c index 66ca82b4cf88399ec66b79256eaa99e201e3063f..fe4f8e8cfcc54912cb246b4f5eb1ea9f0735537f 100644 --- a/lib_enc/ivas_mc_param_enc.c +++ b/lib_enc/ivas_mc_param_enc.c @@ -35,6 +35,9 @@ #include "options.h" #include "cnst.h" #include "rom_enc.h" +#ifdef FIX_580_PARAMMC_ENER_BURSTS +#include "ivas_rom_enc.h" +#endif #include "rom_com.h" #include "prot.h" #include "ivas_prot.h" @@ -75,7 +78,6 @@ static void ivas_param_mc_encode_parameter( int16_t *idx_in, HANDLE_IVAS_PARAM_M static void ivas_param_mc_range_encoder( const int16_t *seq_in, const int16_t num_symbols, const uint16_t *cum_freq, const uint16_t *sym_freq, const uint16_t tot_shift, const int16_t max_nb_bits, uint16_t *bit_buffer, int16_t *bit_pos ); - /*------------------------------------------------------------------------- * ivas_param_mc_enc_open() * @@ -213,6 +215,14 @@ ivas_error ivas_param_mc_enc_open( /* Init total/dmx ener factors */ set_f( hParamMC->ener_fac, 0.0f, PARAM_MC_MAX_PARAMETER_BANDS ); +#ifdef FIX_580_PARAMMC_ENER_BURSTS + /* init previous ILDs */ + for ( i = 0; i < PARAM_MC_MAX_PARAMETER_BANDS; i++ ) + { + set_zero( hParamMC->prev_ilds[i], PARAM_MC_SZ_ILD_MAP ); + } +#endif + st_ivas->hParamMC = hParamMC; return error; @@ -349,6 +359,7 @@ ivas_error ivas_param_mc_enc_reconfig( /* Init total/dmx ener factors */ set_f( hParamMC->ener_fac, 0.0f, PARAM_MC_MAX_PARAMETER_BANDS ); + return error; } @@ -483,7 +494,9 @@ void ivas_param_mc_enc( hParamMC->hMetadataPMC.attackIndex = 0; } +#ifndef FIX_580_PARAMMC_ENER_BURSTS band_step = hParamMC->hMetadataPMC.bAttackPresent ? PARAM_MC_TRANSIENT_BAND_STEP : 1; +#endif } break; #ifdef DEBUGGING @@ -493,10 +506,14 @@ void ivas_param_mc_enc( } /* Encoding */ - /* parameter estimation*/ ivas_param_mc_param_est_enc( hParamMC, data_f, Cy_sum, Cx_sum, input_frame, nchan_inp, st_ivas->nchan_transport ); +#ifdef FIX_580_PARAMMC_ENER_BURSTS + band_step = hParamMC->hMetadataPMC.bAttackPresent ? PARAM_MC_TRANSIENT_BAND_STEP : 1; +#endif + + /* ILD parameter quantization */ for ( k = 0; k < hParamMC->hMetadataPMC.nbands_coded; k += band_step ) { @@ -830,6 +847,65 @@ static void ivas_param_mc_param_est_enc( } } +#ifdef FIX_580_PARAMMC_ENER_BURSTS + if ( !hParamMC->hMetadataPMC.bAttackPresent ) + { + const PARAM_MC_ILD_MAPPING *h_ild_mapping; + int16_t ild_attack; + ild_attack = 0; + h_ild_mapping = hParamMC->hMetadataPMC.ild_mapping_conf; + /* create ILDs for to non transmitted parameter bands (only lower half) */ + for ( cur_param_band = 0; cur_param_band < hParamMC->hMetadataPMC.num_parameter_bands / 2; cur_param_band++ ) + { + float ILD[PARAM_MC_SZ_ILD_MAP]; + int16_t k; + int16_t num_ilds_to_code; + + if ( cur_param_band >= PARAM_MC_MAX_BAND_LFE ) + { + num_ilds_to_code = hParamMC->hMetadataPMC.ild_mapping_conf->ild_map_size_wo_lfe; + } + else + { + num_ilds_to_code = hParamMC->hMetadataPMC.ild_mapping_conf->ild_map_size_lfe; + } + if ( hParamMC->hMetadataPMC.param_frame_idx != hParamMC->hMetadataPMC.coding_band_mapping[cur_param_band] ) + { + float Nrg[MAX_CICP_CHANNELS]; + + /* get ICLDs */ + for ( k = 0; k < nchan_input; ++k ) + { + Nrg[k] = Cy_sum[cur_param_band][k][k]; + } + for ( k = 0; k < num_ilds_to_code; ++k ) + { + float ref_ener = 0.0f; + int16_t ref_channel_cnt; + int16_t ref_channel_idx; + + for ( ref_channel_cnt = 0; ref_channel_cnt < h_ild_mapping->num_ref_channels[k]; ref_channel_cnt++ ) + { + ref_channel_idx = h_ild_mapping->ref_channel_idx[k][ref_channel_cnt]; + ref_ener += Cx_sum[cur_param_band][ref_channel_idx][ref_channel_idx]; + } + ILD[k] = 10.0f * log10f( ( Nrg[h_ild_mapping->ild_index[k]] + EPSILON ) / ( hParamMC->hMetadataPMC.ild_factors[k] * ref_ener + EPSILON ) ); + if ( hParamMC->prev_ilds[cur_param_band][k] - ILD[k] > param_mc_ild_diff_threshold[cur_param_band] ) + { + ild_attack++; + } + } + } + } + /* check if the ILDs change too much -> go into transient mode... */ + if ( ild_attack > PARAM_MC_NUM_ATTACK_ILD_THRESH ) + { + hParamMC->hMetadataPMC.bAttackPresent = 1; + } + } +#endif + + if ( hParamMC->hMetadataPMC.bAttackPresent ) { /* combine bands */ @@ -883,6 +959,7 @@ static void ivas_param_mc_param_est_enc( band_step = 2; } + /* map complex covariances to real values */ for ( cur_param_band = 0; cur_param_band < hParamMC->max_param_band_abs_cov; cur_param_band += band_step ) { @@ -1289,8 +1366,16 @@ static void ivas_param_mc_quantize_ilds( ref_ener += Cx[ref_channel_idx][ref_channel_idx]; } ILD[k] = 10.0f * log10f( ( Nrg[h_ild_mapping->ild_index[k]] + EPSILON ) / ( hParamMC->hMetadataPMC.ild_factors[k] * ref_ener + EPSILON ) ); +#ifdef FIX_580_PARAMMC_ENER_BURSTS + hParamMC->prev_ilds[freq_idx][k] = ILD[k]; + if ( hParamMC->hMetadataPMC.bAttackPresent && ( ( freq_idx + 1 ) < hParamMC->hMetadataPMC.nbands_coded ) ) + { + hParamMC->prev_ilds[freq_idx + 1][k] = ILD[k]; + } +#endif } + /* quantize parameters */ ivas_param_mc_parameter_quantizer( ILD, num_ilds_to_code, hParamMC->hMetadataPMC.ild_coding.quantizer_size, hParamMC->hMetadataPMC.ild_coding.quantizer, ILD_idx, ILD_q ); diff --git a/lib_enc/ivas_rom_enc.c b/lib_enc/ivas_rom_enc.c index 45651008836d2e2f33a52992d2cb3e9b77da220b..a031d6df288ee817f891256e8bbb9cd3e1d724d8 100644 --- a/lib_enc/ivas_rom_enc.c +++ b/lib_enc/ivas_rom_enc.c @@ -837,5 +837,13 @@ const HUFF_TABLE huff_beta_table[2] = const int16_t mc_paramupmix_fb_remix_order[4] = {0, 1, 2, 3}; +#ifdef FIX_580_PARAMMC_ENER_BURSTS +/*----------------------------------------------------------------------------------* + * ParamMC ROM tables + *----------------------------------------------------------------------------------*/ +const float param_mc_ild_diff_threshold[20] = { 8.0f, 8.0f, 10.0f, 20.0f, + 20.0f, 20.0f, 20.0f, 20.0f, + 20.0f, 20.0f, 20.0f, 20.0f }; +#endif /* clang-format on */ diff --git a/lib_enc/ivas_rom_enc.h b/lib_enc/ivas_rom_enc.h index c208259ed6052b15f17bc946754c8fa311b5e395..170bf3182035352994fe7e57ae24d55cc84bb24f 100644 --- a/lib_enc/ivas_rom_enc.h +++ b/lib_enc/ivas_rom_enc.h @@ -130,4 +130,12 @@ extern const HUFF_TABLE huff_alpha_table[2]; extern const HUFF_TABLE huff_beta_table[2]; extern const int16_t mc_paramupmix_fb_remix_order[4]; +#ifdef FIX_580_PARAMMC_ENER_BURSTS +/*----------------------------------------------------------------------------------* + * ParamMC ROM tables + *----------------------------------------------------------------------------------*/ +extern const float param_mc_ild_diff_threshold[20]; +#endif + + #endif diff --git a/lib_enc/ivas_stat_enc.h b/lib_enc/ivas_stat_enc.h index 295c8ed8388f7b562b733e0dd8d472f2778466aa..6a5964e86c0885892b62bfac3d21b724e4549b77 100644 --- a/lib_enc/ivas_stat_enc.h +++ b/lib_enc/ivas_stat_enc.h @@ -727,6 +727,9 @@ typedef struct ivas_param_mc_enc_data_structure int16_t lfe_index; int16_t icc_map_index[PARAM_MC_PARAMETER_FRAMES][PARAM_MC_SZ_ICC_MAP]; int16_t max_param_band_abs_cov; +#ifdef FIX_580_PARAMMC_ENER_BURSTS + float prev_ilds[PARAM_MC_MAX_PARAMETER_BANDS][PARAM_MC_SZ_ILD_MAP]; +#endif float ener_fac[PARAM_MC_MAX_PARAMETER_BANDS];