From efa307521d2be60ccf6713ea391abf6b9ab082ca Mon Sep 17 00:00:00 2001 From: Shikha Shetgeri <100861@ittiam.com> Date: Mon, 15 May 2023 18:13:55 +0530 Subject: [PATCH 1/3] Remove the agc flag bit from bitstream --- lib_com/ivas_agc_com.c | 30 ++++++++++++++++++++++++++++++ lib_com/ivas_prot.h | 11 ++++++++++- lib_com/options.h | 3 ++- lib_dec/ivas_spar_decoder.c | 11 +++++++++++ lib_enc/ivas_agc_enc.c | 3 ++- lib_enc/ivas_spar_encoder.c | 6 ++++++ 6 files changed, 61 insertions(+), 3 deletions(-) diff --git a/lib_com/ivas_agc_com.c b/lib_com/ivas_agc_com.c index e39b8df82d..98bd59b536 100644 --- a/lib_com/ivas_agc_com.c +++ b/lib_com/ivas_agc_com.c @@ -134,3 +134,33 @@ int16_t ivas_agc_debug_inout( FILE *inStream, float **in, int16_t n_channels, in return FALSE; } #endif + +#ifdef AGC_FLAG_DISABLE +/*-----------------------------------------------------------------------------------------* + * Function ivas_agc_enc_get_flag() + * + * This function determines if AGC is enabled or disabled. + *-----------------------------------------------------------------------------------------*/ + +/*! r: AGC enable flag */ +int16_t ivas_agc_get_flag( +#ifdef DEBUG_AGC_ENCODER_CMD_OPTION + int16_t agc_configuration, /* i : AGC configuration from command-line */ +#endif + int16_t nchan_transport /* i : number of transport channels */ +) +{ + int16_t agc_flag; + + /* AGC is enabled only if there is one transport channel. */ + agc_flag = (int16_t) ( nchan_transport == 1 ); + +#ifdef DEBUG_AGC_ENCODER_CMD_OPTION + /* If agc_configuration is not undefined, then this value decides on the state of * enablement, + otherwise AGC is enabled only if there is one transport channel. */ + agc_flag = ( agc_configuration != SBA_AGC_DEFAULT ) ? agc_configuration : agc_flag; +#endif + + return agc_flag; +} +#endif diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index dc803e58cb..43a3632e72 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -4368,12 +4368,21 @@ void ivas_sba_prototype_renderer_sf( /* AGC */ /*! r: AGC enable flag */ -int16_t ivas_agc_enc_get_flag( +#ifdef AGC_FLAG_DISABLE +int16_t ivas_agc_get_flag( #ifdef DEBUG_AGC_ENCODER_CMD_OPTION int16_t agc_configuration, /* i : AGC configuration from command-line */ #endif int16_t nchan_transport /* i : number of transport channels */ ); +#else +int16_t ivas_agc_enc_get_flag( +#ifdef DEBUG_AGC_ENCODER_CMD_OPTION + int16_t agc_configuration, /* i : AGC configuration from command-line */ +#endif + int16_t nchan_transport /* i : number of transport channels */ +); +#endif ivas_error ivas_spar_agc_enc_open( ivas_agc_enc_state_t **hAgcEnc, /* i/o: AGC decoder handle */ diff --git a/lib_com/options.h b/lib_com/options.h index 556b6f79b0..404d1f55b7 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -125,8 +125,9 @@ #endif /*#define SPAR_HOA_DBG*/ /* SPAR HOA debug statements */ /*#define DEBUG_BINAURAL_FILTER_DESIGN*/ /* debugging of Crend binaural filter design */ -#define DEBUG_AGC_ENCODER_CMD_OPTION /* Ability to force enable or disable AGC behaviour in DIRAC/SPAR via command line option */ +//#define DEBUG_AGC_ENCODER_CMD_OPTION /* Ability to force enable or disable AGC behaviour in DIRAC/SPAR via command line option */ #define DEBUG_JBM_CMD_OPTION /* ability for telling the decoder the frontend fetch size and to not delay compensate for bad frames at the beginning */ +#define AGC_FLAG_DISABLE /* to remove the AGC flag bit from the bitstream for the cases where AGC is now disabled */ #endif /* #################### End DEBUGGING switches ############################ */ diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c index 22d38997dd..0169dba191 100755 --- a/lib_dec/ivas_spar_decoder.c +++ b/lib_dec/ivas_spar_decoder.c @@ -784,7 +784,18 @@ static void ivas_spar_dec_MD( if ( ivas_total_brate > IVAS_SID_5k2 && !bfi && hSpar->hMdDec->dtx_vad ) { +#ifdef AGC_FLAG_DISABLE + if ( ivas_agc_get_flag( hSpar->hMdDec->spar_md_cfg.nchan_transport ) != 0 ) + { + hSpar->AGC_flag = get_next_indice( st0, 1 ); + } + else + { + hSpar->AGC_flag = ivas_agc_get_flag( hSpar->hMdDec->spar_md_cfg.nchan_transport ); + } +#else hSpar->AGC_flag = get_next_indice( st0, 1 ); +#endif ivas_agc_read_bits( hSpar->hAgcDec, st0, hSpar->hMdDec->spar_md_cfg.nchan_transport, hSpar->AGC_flag ); } diff --git a/lib_enc/ivas_agc_enc.c b/lib_enc/ivas_agc_enc.c index 83dbdad1e1..1a0af13003 100644 --- a/lib_enc/ivas_agc_enc.c +++ b/lib_enc/ivas_agc_enc.c @@ -59,7 +59,7 @@ extern FILE *agcOut; static int16_t ivas_agc_writeBits( FILE *stream, const int16_t n_channels, ivas_agc_enc_state_t *pState ); #endif - +#ifndef AGC_FLAG_DISABLE /*-----------------------------------------------------------------------------------------* * Function ivas_agc_enc_get_flag() * @@ -87,6 +87,7 @@ int16_t ivas_agc_enc_get_flag( return agc_flag; } +#endif /*-----------------------------------------------------------------------------------------* diff --git a/lib_enc/ivas_spar_encoder.c b/lib_enc/ivas_spar_encoder.c index 098654416a..0968168817 100644 --- a/lib_enc/ivas_spar_encoder.c +++ b/lib_enc/ivas_spar_encoder.c @@ -165,8 +165,12 @@ ivas_error ivas_spar_enc_open( /* AGC handle */ #ifdef DEBUG_AGC_ENCODER_CMD_OPTION hSpar->AGC_Enable = ivas_agc_enc_get_flag( hEncoderConfig->Opt_AGC_ON, nchan_transport ); +#else +#ifdef AGC_FLAG_DISABLE + hSpar->AGC_Enable = ivas_agc_get_flag( nchan_transport ); #else hSpar->AGC_Enable = ivas_agc_enc_get_flag( nchan_transport ); +#endif #endif hSpar->hAgcEnc = NULL; @@ -1035,6 +1039,7 @@ static ivas_error ivas_spar_enc_process( { ivas_agc_enc_process( hSpar->hAgcEnc, hMetaData, p_pcm_tmp, p_pcm_tmp, hSpar->hFbMixer->fb_cfg->num_out_chans, hEncoderConfig ); } +#ifndef AGC_FLAG_DISABLE else { /* IVAS_fmToDo: This AGC on/off bit should be removed when the command line option to force enable/disable AGC is @@ -1043,6 +1048,7 @@ static ivas_error ivas_spar_enc_process( * ivas_agc_enc_get_flag function should be moved to ivas_agc_com.c and renamed when this occurs. */ push_next_indice( hMetaData, 0, 1 ); } +#endif } #ifdef DEBUG_SBA_AUDIO_DUMP /* Dump audio signal after ivas_agc_enc_process */ -- GitLab From 78f50f1fb475371300a94084498a4c078d2f60a6 Mon Sep 17 00:00:00 2001 From: Shikha Shetgeri <100861@ittiam.com> Date: Mon, 15 May 2023 19:25:17 +0530 Subject: [PATCH 2/3] disabling agc --- tests/conftest.py | 4 ---- tests/test_sba_bs_dec_plc.py | 7 ------ tests/test_sba_bs_enc.py | 42 ++++-------------------------------- 3 files changed, 4 insertions(+), 49 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index ef5f46ffc9..d7a35a36e0 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -196,7 +196,6 @@ class EncoderFrontend: sba_order: Optional[str] = None, dtx_mode: Optional[bool] = False, max_band: Optional[str] = None, - agc_op: Optional[int] = None, bypass_mode: Optional[int] = None, quiet_mode: Optional[bool] = True, add_option_list: Optional[list] = None, @@ -213,9 +212,6 @@ class EncoderFrontend: if max_band is not None: command.extend(["-max_band", max_band]) - if agc_op is not None: - command.extend(["-agc", str(agc_op)]) - if bypass_mode is not None: command.extend(["-bypass", str(bypass_mode)]) diff --git a/tests/test_sba_bs_dec_plc.py b/tests/test_sba_bs_dec_plc.py index 4920a9c59c..529912725a 100644 --- a/tests/test_sba_bs_dec_plc.py +++ b/tests/test_sba_bs_dec_plc.py @@ -47,7 +47,6 @@ plc_patterns = ['PLperc12mblen5', 'PLperc40mblen50', 'PLperc42mblen2'] dtx_set = ['0', '1'] ivas_br_list = ['32000', '64000', '96000', '256000'] sampling_rate_list = ['48', '32', '16'] -agc_list = [-1, 0, 1] AbsTol = '0' @@ -73,7 +72,6 @@ def check_and_makedir(dir_path): @pytest.mark.parametrize("tag", tag_list) @pytest.mark.parametrize("plc_pattern", plc_patterns) @pytest.mark.parametrize("fs", sampling_rate_list) -@pytest.mark.parametrize("agc", agc_list) def test_sba_plc_system( dut_decoder_frontend: DecoderFrontend, test_vector_path, @@ -87,7 +85,6 @@ def test_sba_plc_system( tag, plc_pattern, fs, - agc ): if dtx == '1' and ivas_br not in ['32000', '64000']: # skip high bitrates for DTX until DTX issue is resolved @@ -108,7 +105,6 @@ def test_sba_plc_system( dtx, plc_pattern, update_ref, - agc, keep_files, ) @@ -127,15 +123,12 @@ def sba_dec_plc( dtx, plc_pattern, update_ref, - agc, keep_files, ): # ------------ run cmd ------------ tag_out = f"{tag}_ivasbr{ivas_br[:-3]}k_DTX{dtx}" - if agc != -1: - tag_out += f'_AGC{agc}' plc_tag_out = f"{tag_out}_{plc_pattern}" dut_out_dir = f"{dut_base_path}/sba_bs/raw" diff --git a/tests/test_sba_bs_enc.py b/tests/test_sba_bs_enc.py index 6825ee12ba..00407d6d1d 100644 --- a/tests/test_sba_bs_enc.py +++ b/tests/test_sba_bs_enc.py @@ -59,7 +59,6 @@ ivas_br_HOA3 = ['256000', '384000', '512000'] sample_rate_list = ['48', '32', '16'] bypass_list = [1, 2] -agc_list = [-1, 0, 1] sample_rate_bw_idx_list = [('48', 'SWB'), ('48', 'WB'), ('32', 'WB')] @@ -100,7 +99,6 @@ def test_bypass_enc( ivas_br = '256000' dtx = '0' max_bw = "FB" - agc = -1 sba_order = "+1" output_config = "FOA" @@ -118,7 +116,6 @@ def test_bypass_enc( dtx, max_bw, bypass, - agc, sba_order, update_ref, cut_testv=True @@ -136,7 +133,6 @@ def test_bypass_enc( dtx, max_bw, bypass, - agc, output_config, update_ref, keep_files, @@ -148,7 +144,6 @@ def test_bypass_enc( @pytest.mark.parametrize("dtx", dtx_set) @pytest.mark.parametrize("tag", tag_list) @pytest.mark.parametrize("fs", sample_rate_list) -@pytest.mark.parametrize("agc", agc_list) def test_sba_enc_system( dut_encoder_frontend: EncoderFrontend, dut_decoder_frontend: DecoderFrontend, @@ -164,12 +159,11 @@ def test_sba_enc_system( dtx, tag, fs, - agc, ): if dtx == '1' and ivas_br not in ['32000', '64000']: # skip high bitrates for DTX until DTX issue is resolved pytest.skip() - if ivas_br == 'sw_24k4_256k.bin' and agc != 1: + if ivas_br == 'sw_24k4_256k.bin': pytest.skip() tag = tag + fs + 'c' @@ -177,9 +171,7 @@ def test_sba_enc_system( bypass = -1 sba_order = "+1" output_config = "FOA" - if agc == 1: - cut_gain = "16.0" - elif dtx == '1': + if dtx == '1': cut_gain = ".004" else: cut_gain = "1.0" @@ -197,7 +189,6 @@ def test_sba_enc_system( dtx, max_bw, bypass, - agc, sba_order, update_ref, cut_gain=cut_gain, @@ -217,7 +208,6 @@ def test_sba_enc_system( dtx, max_bw, bypass, - agc, output_config, update_ref, keep_files, @@ -242,7 +232,6 @@ def test_spar_hoa2_enc_system( ): fs = '48' dtx = '0' - agc = -1 tag = tag + fs + 'c' max_bw = "FB" @@ -264,7 +253,6 @@ def test_spar_hoa2_enc_system( dtx, max_bw, bypass, - agc, sba_order, update_ref, ) @@ -281,7 +269,6 @@ def test_spar_hoa2_enc_system( dtx, max_bw, bypass, - agc, output_config, update_ref, keep_files, @@ -306,7 +293,6 @@ def test_spar_hoa3_enc_system( ): fs = '48' dtx = '0' - agc = -1 tag = tag + fs + 'c' max_bw = "FB" @@ -328,7 +314,6 @@ def test_spar_hoa3_enc_system( dtx, max_bw, bypass, - agc, sba_order, update_ref, ) @@ -345,7 +330,6 @@ def test_spar_hoa3_enc_system( dtx, max_bw, bypass, - agc, output_config, update_ref, keep_files, @@ -381,7 +365,6 @@ def test_sba_enc_BWforce_system( bw = sample_rate_bw_idx[1] tag = tag + fs + 'c' bypass = -1 - agc = -1 sba_order = "+1" output_config = "FOA" @@ -399,7 +382,6 @@ def test_sba_enc_BWforce_system( dtx, bw, bypass, - agc, sba_order, update_ref, cut_testv=True @@ -417,7 +399,6 @@ def test_sba_enc_BWforce_system( dtx, bw, bypass, - agc, output_config, update_ref, keep_files, @@ -439,7 +420,6 @@ def sba_enc( dtx, ivas_max_bw, bypass, - agc, sba_order, update_ref, cut_gain='1.0', @@ -466,20 +446,14 @@ def sba_enc( if ivas_br == 'sw_24k4_256k.bin': ivas_br = f"{br_switch_file_path}/sw_24k4_256k.bin" short_tag_ext = "" - if agc != -1: - short_tag_ext += f'_AGC{agc}' - # we update only bypass = 0/2 (bypass 1 is the same as the baseline) if bypass in [0, 2]: short_tag_ext += f"_pca{bypass}" - # to avoid conflicting names in case of parallel test execution, differentiate all cases - long_tag_ext = f"_AGC{agc}" if agc != -1 else "_AGC-unspecified" - long_tag_ext += f"_pca{bypass}" + long_tag_ext = f"_pca{bypass}" dut_pkt_file = f"{dut_out_dir}/{tag_out}{long_tag_ext}.pkt" ref_pkt_file = f"{ref_out_dir}/{tag_out}{short_tag_ext}.pkt" ref_pkt_file_dutenc = f"{ref_out_dir}/{tag_out}{short_tag_ext}_dutenc.pkt" input_path = f"{test_vector_path}/{tag_in}{in_extension}" - agc_op = agc if agc != -1 else None bypass_mode = bypass if bypass >= 0 else None dtx_mode = dtx == '1' @@ -507,7 +481,6 @@ def sba_enc( ref_pkt_file, sba_order=sba_order, max_band=ivas_max_bw, - agc_op=agc_op, bypass_mode=bypass_mode, dtx_mode=dtx_mode, ) @@ -520,7 +493,6 @@ def sba_enc( ref_pkt_file_dutenc, sba_order=sba_order, max_band=ivas_max_bw, - agc_op=agc_op, bypass_mode=bypass_mode, dtx_mode=dtx_mode, ) @@ -534,7 +506,6 @@ def sba_enc( dut_pkt_file, sba_order=sba_order, max_band=ivas_max_bw, - agc_op=agc_op, bypass_mode=bypass_mode, dtx_mode=dtx_mode, ) @@ -551,7 +522,6 @@ def sba_dec( dtx, ivas_max_bw, bypass, - agc, output_config, update_ref, keep_files, @@ -566,15 +536,11 @@ def sba_dec( tag_out = f"{tag}_ivasbr{ivas_br[:-3]}k_DTX{dtx}" short_tag_ext = "" - if agc != -1: - short_tag_ext += f'_AGC{agc}' - # we update only bypass = 0/2 (bypass 1 is the same as the baseline) if bypass in [0, 2]: short_tag_ext += f"_pca{bypass}" # to avoid conflicting names in case of parallel test execution, differentiate all cases - long_tag_ext = f"_AGC{agc}" if agc != -1 else "_AGC-unspecified" - long_tag_ext += f"_pca{bypass}" + long_tag_ext = f"_pca{bypass}" dut_out_dir = f"{dut_base_path}/sba_bs/raw" ref_out_dir = f"{reference_path}/sba_bs/raw" -- GitLab From ab7624626dc086924d82ce218d75a1953caabf05 Mon Sep 17 00:00:00 2001 From: Shikha Shetgeri <100861@ittiam.com> Date: Tue, 16 May 2023 14:22:59 +0530 Subject: [PATCH 3/3] addressing review comments --- lib_dec/ivas_spar_decoder.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c index 0169dba191..27b0b6b3d3 100755 --- a/lib_dec/ivas_spar_decoder.c +++ b/lib_dec/ivas_spar_decoder.c @@ -791,7 +791,7 @@ static void ivas_spar_dec_MD( } else { - hSpar->AGC_flag = ivas_agc_get_flag( hSpar->hMdDec->spar_md_cfg.nchan_transport ); + hSpar->AGC_flag = 0; } #else hSpar->AGC_flag = get_next_indice( st0, 1 ); -- GitLab