From 30b64a5be322ee705ff3d41cf471bf589a5b12ac Mon Sep 17 00:00:00 2001 From: Shikha Shetgeri <100861@ittiam.com> Date: Thu, 11 May 2023 19:46:52 +0530 Subject: [PATCH 1/5] Added two test cases for initial SID frame --- scripts/config/self_test.prm | 7 +++++++ scripts/cut_bs.py | 6 +++--- tests/test_param_file.py | 35 +++++++++++++++++++++++++++++++++-- 3 files changed, 43 insertions(+), 5 deletions(-) diff --git a/scripts/config/self_test.prm b/scripts/config/self_test.prm index 429abcf2e6..5ed7f65782 100644 --- a/scripts/config/self_test.prm +++ b/scripts/config/self_test.prm @@ -649,6 +649,13 @@ ../IVAS_dec HOA3 32 bit testv/stv3OA32c.wav_sw_32-32_DTX_HOA3.tst +// SBA FOA at 13.2 kbps , 32kHz in, 32kHz out, DTX on, BINAURAL out, SID as first frame +../IVAS_cod -dtx -sba 1 13200 32 testv/stvFOA32c.wav bit +../IVAS_dec BINAURAL 32 bit testv/stvFOA32c.wav_BINAURAL_13200_32-32_DTX_SID.tst + +// SBA FOA at 24.4 kbps, 32kHz in, 32kHz out, DTX on, BINAURAL out, SID as first frame +../IVAS_cod -dtx -sba 1 24400 32 testv/stvFOA32c.wav bit +../IVAS_dec BINAURAL 32 bit testv/stvFOA32c.wav_BINAURAL_13200_32-32_DTX_SID.tst // MASA 1dir 1TC at 13.2 kbps, 48kHz in, 48kHz out, BINAURAL out ../IVAS_cod -masa 1 testv/stv1MASA1TC48c.met 13200 48 testv/stv1MASA1TC48c.wav bit diff --git a/scripts/cut_bs.py b/scripts/cut_bs.py index 5fee9845e7..c0ae6e1933 100755 --- a/scripts/cut_bs.py +++ b/scripts/cut_bs.py @@ -35,11 +35,12 @@ import argparse import os.path import sys -SID_BITS = {35, 48, 88, 100} +#SID_BITS = {35, 48, 88, 100} +SID_BITS = {35, 48, 104} SYNC_WORDS = {b"!k", b" k"} -def cut_bs(fp, fp_out, start_frame=0, start_with_sid=False): +def cut_bs(fp, fp_out, start_frame = 0, start_with_sid = False): # cut until start frame fr_cnt = 0 cut_cnt = 0 @@ -86,7 +87,6 @@ def cut_bs(fp, fp_out, start_frame=0, start_with_sid=False): fp_out.write(n_bits_bs) fp_out.write(fp.read(n_bits * 2)) fr_cnt += 1 - return (fr_cnt, cut_cnt) diff --git a/tests/test_param_file.py b/tests/test_param_file.py index 7774d59403..7b3f172daf 100644 --- a/tests/test_param_file.py +++ b/tests/test_param_file.py @@ -43,7 +43,7 @@ from cmp_pcm import cmp_pcm from cut_pcm import cut_samples from conftest import EncoderFrontend, DecoderFrontend from testconfig import PARAM_FILE - +from cut_bs import cut_bs VALID_DEC_OUTPUT_CONF = [ "MONO", @@ -162,6 +162,17 @@ def test_param_file_tests( sba_br_switching_dtx = 1 cut_file = pre_proc_input(testv_file, fs) testv_file = cut_file + #SID + sba_dtx_first_SID = 0 + if ( + bitrate.isdigit() + and "-dtx" in enc_opts.split() + and "-sba" in enc_opts.split() + and "SID" in tag_str.split('_') + ): + sba_dtx_first_SID = 1 + cut_file = pre_proc_input(testv_file, fs) + testv_file = cut_file # bitrate can be a filename: remove leading "../" if bitrate.startswith("../"): @@ -188,7 +199,27 @@ def test_param_file_tests( enc_split, update_ref, ) - if sba_br_switching_dtx == 1: + # SID : Update bitstream + if sba_dtx_first_SID == 1: + dut_out_dir = f"{dut_base_path}\\param_file\\enc" + ref_out_dir = f"{reference_path}\\param_file\\enc" + ref_out_file = f"{ref_out_dir}\\{bitstream_file}" + dut_out_file = f"{dut_out_dir}\\{bitstream_file}" + ref_out_file_cut = ref_out_file +"_cut" + dut_out_file_cut = dut_out_file +"_cut" + + if update_ref == 1 or update_ref == 2 and not os.path.exists(ref_out_file): + with open(ref_out_file, "rb") as fp_in: + with open(ref_out_file_cut, "wb") as fp_out: + fr_cnt, cut_cnt = cut_bs(fp_in, fp_out, 0, True) + if update_ref in [0, 2]: + with open(dut_out_file, "rb") as fp_in: + with open(dut_out_file_cut, "wb") as fp_out: + fr_cnt, cut_cnt = cut_bs(fp_in, fp_out, 0, True) + + bitstream_file = bitstream_file +"_cut" + + if sba_br_switching_dtx == 1 or sba_dtx_first_SID == 1: is_exist = os.path.exists(cut_file) if is_exist: os.remove(cut_file) -- GitLab From d1b226baab278b19b0288ec4d07a5bf9f2e0d186 Mon Sep 17 00:00:00 2001 From: Shikha Shetgeri <100861@ittiam.com> Date: Fri, 12 May 2023 15:07:39 +0530 Subject: [PATCH 2/5] path correction --- tests/test_param_file.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/test_param_file.py b/tests/test_param_file.py index 7b3f172daf..96bb83b1b4 100644 --- a/tests/test_param_file.py +++ b/tests/test_param_file.py @@ -201,10 +201,10 @@ def test_param_file_tests( ) # SID : Update bitstream if sba_dtx_first_SID == 1: - dut_out_dir = f"{dut_base_path}\\param_file\\enc" - ref_out_dir = f"{reference_path}\\param_file\\enc" - ref_out_file = f"{ref_out_dir}\\{bitstream_file}" - dut_out_file = f"{dut_out_dir}\\{bitstream_file}" + dut_out_dir = f"{dut_base_path}/param_file/enc" + ref_out_dir = f"{reference_path}/param_file/enc" + ref_out_file = f"{ref_out_dir}/{bitstream_file}" + dut_out_file = f"{dut_out_dir}/{bitstream_file}" ref_out_file_cut = ref_out_file +"_cut" dut_out_file_cut = dut_out_file +"_cut" -- GitLab From 17652aadbef1e93a2b7282e88c2a089806e46332 Mon Sep 17 00:00:00 2001 From: Vidhya V P <100825@ittiam.com> Date: Mon, 15 May 2023 18:52:09 +0530 Subject: [PATCH 3/5] Moved the added test cases in param file [x] Added the new test cases to SBA pytests --- scripts/config/self_test.prm | 7 ----- tests/test_param_file.py | 35 ++------------------- tests/test_sba_bs_dec_plc.py | 19 +++++++++-- tests/test_sba_bs_enc.py | 61 ++++++++++++++++++++++++++++++------ 4 files changed, 70 insertions(+), 52 deletions(-) diff --git a/scripts/config/self_test.prm b/scripts/config/self_test.prm index 5ed7f65782..429abcf2e6 100644 --- a/scripts/config/self_test.prm +++ b/scripts/config/self_test.prm @@ -649,13 +649,6 @@ ../IVAS_dec HOA3 32 bit testv/stv3OA32c.wav_sw_32-32_DTX_HOA3.tst -// SBA FOA at 13.2 kbps , 32kHz in, 32kHz out, DTX on, BINAURAL out, SID as first frame -../IVAS_cod -dtx -sba 1 13200 32 testv/stvFOA32c.wav bit -../IVAS_dec BINAURAL 32 bit testv/stvFOA32c.wav_BINAURAL_13200_32-32_DTX_SID.tst - -// SBA FOA at 24.4 kbps, 32kHz in, 32kHz out, DTX on, BINAURAL out, SID as first frame -../IVAS_cod -dtx -sba 1 24400 32 testv/stvFOA32c.wav bit -../IVAS_dec BINAURAL 32 bit testv/stvFOA32c.wav_BINAURAL_13200_32-32_DTX_SID.tst // MASA 1dir 1TC at 13.2 kbps, 48kHz in, 48kHz out, BINAURAL out ../IVAS_cod -masa 1 testv/stv1MASA1TC48c.met 13200 48 testv/stv1MASA1TC48c.wav bit diff --git a/tests/test_param_file.py b/tests/test_param_file.py index 96bb83b1b4..7774d59403 100644 --- a/tests/test_param_file.py +++ b/tests/test_param_file.py @@ -43,7 +43,7 @@ from cmp_pcm import cmp_pcm from cut_pcm import cut_samples from conftest import EncoderFrontend, DecoderFrontend from testconfig import PARAM_FILE -from cut_bs import cut_bs + VALID_DEC_OUTPUT_CONF = [ "MONO", @@ -162,17 +162,6 @@ def test_param_file_tests( sba_br_switching_dtx = 1 cut_file = pre_proc_input(testv_file, fs) testv_file = cut_file - #SID - sba_dtx_first_SID = 0 - if ( - bitrate.isdigit() - and "-dtx" in enc_opts.split() - and "-sba" in enc_opts.split() - and "SID" in tag_str.split('_') - ): - sba_dtx_first_SID = 1 - cut_file = pre_proc_input(testv_file, fs) - testv_file = cut_file # bitrate can be a filename: remove leading "../" if bitrate.startswith("../"): @@ -199,27 +188,7 @@ def test_param_file_tests( enc_split, update_ref, ) - # SID : Update bitstream - if sba_dtx_first_SID == 1: - dut_out_dir = f"{dut_base_path}/param_file/enc" - ref_out_dir = f"{reference_path}/param_file/enc" - ref_out_file = f"{ref_out_dir}/{bitstream_file}" - dut_out_file = f"{dut_out_dir}/{bitstream_file}" - ref_out_file_cut = ref_out_file +"_cut" - dut_out_file_cut = dut_out_file +"_cut" - - if update_ref == 1 or update_ref == 2 and not os.path.exists(ref_out_file): - with open(ref_out_file, "rb") as fp_in: - with open(ref_out_file_cut, "wb") as fp_out: - fr_cnt, cut_cnt = cut_bs(fp_in, fp_out, 0, True) - if update_ref in [0, 2]: - with open(dut_out_file, "rb") as fp_in: - with open(dut_out_file_cut, "wb") as fp_out: - fr_cnt, cut_cnt = cut_bs(fp_in, fp_out, 0, True) - - bitstream_file = bitstream_file +"_cut" - - if sba_br_switching_dtx == 1 or sba_dtx_first_SID == 1: + if sba_br_switching_dtx == 1: is_exist = os.path.exists(cut_file) if is_exist: os.remove(cut_file) diff --git a/tests/test_sba_bs_dec_plc.py b/tests/test_sba_bs_dec_plc.py index 4920a9c59c..47e2c02680 100644 --- a/tests/test_sba_bs_dec_plc.py +++ b/tests/test_sba_bs_dec_plc.py @@ -45,7 +45,7 @@ from conftest import DecoderFrontend tag_list = ['stvFOA'] plc_patterns = ['PLperc12mblen5', 'PLperc40mblen50', 'PLperc42mblen2'] dtx_set = ['0', '1'] -ivas_br_list = ['32000', '64000', '96000', '256000'] +ivas_br_list = ['13200','16400','32000', '64000', '96000', '256000'] sampling_rate_list = ['48', '32', '16'] agc_list = [-1, 0, 1] @@ -89,10 +89,18 @@ def test_sba_plc_system( fs, agc ): - if dtx == '1' and ivas_br not in ['32000', '64000']: + SID = 0 + if dtx == '1' and ivas_br not in ['13200', '64000']: # skip high bitrates for DTX until DTX issue is resolved pytest.skip() - + if ivas_br == '13200' or ivas_br == '16400': + if dtx == '0' and agc == 1: + pytest.skip() + if ivas_br == '13200' or ivas_br == '16400': + if dtx == '1' and agc == 0 and fs != '16': + SID = 1 + else: + pytest.skip() tag = tag + fs + 'c' # dec @@ -106,6 +114,7 @@ def test_sba_plc_system( fs, ivas_br, dtx, + SID, plc_pattern, update_ref, agc, @@ -125,6 +134,7 @@ def sba_dec_plc( sampling_rate, ivas_br, dtx, + SID, plc_pattern, update_ref, agc, @@ -147,6 +157,9 @@ def sba_dec_plc( plc_file = f"{test_vector_path}/{plc_pattern}.g192" ref_in_pkt = f"{reference_path}/sba_bs/pkt/{tag_out}.pkt" ref_in_pkt_dutenc = f"{reference_path}/sba_bs/pkt/{tag_out}_dutenc.pkt" + if SID == 1: + ref_in_pkt = f"{reference_path}/sba_bs/pkt/{tag_out}_SID_cut.pkt" + ref_in_pkt_dutenc = f"{reference_path}/sba_bs/pkt/{tag_out}_SID_dutenc_cut.pkt" dut_out_raw = f"{dut_out_dir}/{plc_tag_out}.raw" ref_out_raw = f"{ref_out_dir}/{plc_tag_out}.raw" diff --git a/tests/test_sba_bs_enc.py b/tests/test_sba_bs_enc.py index 6825ee12ba..6ad6b6e9f3 100644 --- a/tests/test_sba_bs_enc.py +++ b/tests/test_sba_bs_enc.py @@ -42,8 +42,9 @@ import pytest from cmp_pcm import cmp_pcm from cut_pcm import cut_samples from conftest import EncoderFrontend, DecoderFrontend - +from cut_bs import cut_bs # params + tag_list = ['stvFOA'] tag_list_HOA2 = ['stv2OA'] tag_list_HOA3 = ['stv3OA'] @@ -53,7 +54,7 @@ dtx_set = ['0', '1'] dict_fsample_bw = {'48': '3', '32': '2', '16': '1'} dict_bw_idx = {'FB': '3', 'SWB': '2', 'WB': '1'} dict_bw_tag = {'SWB': '_ForceSWB', 'WB': '_ForceWB'} -ivas_br_FOA = ['32000','64000', '96000', '160000', '256000', '384000', '512000','sw_24k4_256k.bin'] +ivas_br_FOA = ['13200','16400','32000','64000', '96000', '160000', '256000', '384000', '512000','sw_24k4_256k.bin'] ivas_br_HOA2 = ['256000', '384000', '512000'] ivas_br_HOA3 = ['256000', '384000', '512000'] @@ -116,6 +117,7 @@ def test_bypass_enc( fs, ivas_br, dtx, + None, max_bw, bypass, agc, @@ -134,6 +136,7 @@ def test_bypass_enc( fs, ivas_br, dtx, + None, max_bw, bypass, agc, @@ -166,12 +169,17 @@ def test_sba_enc_system( fs, agc, ): - if dtx == '1' and ivas_br not in ['32000', '64000']: + SID = 0 + if dtx == '1' and ivas_br not in ['13200', '64000']: # skip high bitrates for DTX until DTX issue is resolved pytest.skip() if ivas_br == 'sw_24k4_256k.bin' and agc != 1: - pytest.skip() - + pytest.skip() + if ivas_br == '13200' or ivas_br == '16400': + if dtx == '1' and agc == 0 and fs != '16': + SID = 1 + else: + pytest.skip() tag = tag + fs + 'c' max_bw = "FB" bypass = -1 @@ -195,6 +203,7 @@ def test_sba_enc_system( fs, ivas_br, dtx, + SID, max_bw, bypass, agc, @@ -215,6 +224,7 @@ def test_sba_enc_system( fs, ivas_br, dtx, + SID, max_bw, bypass, agc, @@ -262,6 +272,7 @@ def test_spar_hoa2_enc_system( fs, ivas_br, dtx, + None, max_bw, bypass, agc, @@ -279,6 +290,7 @@ def test_spar_hoa2_enc_system( fs, ivas_br, dtx, + None, max_bw, bypass, agc, @@ -326,6 +338,7 @@ def test_spar_hoa3_enc_system( fs, ivas_br, dtx, + None, max_bw, bypass, agc, @@ -343,6 +356,7 @@ def test_spar_hoa3_enc_system( fs, ivas_br, dtx, + None, max_bw, bypass, agc, @@ -375,6 +389,8 @@ def test_sba_enc_BWforce_system( 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 == '13200' or ivas_br == '16400': + pytest.skip() if ivas_br == 'sw_24k4_256k.bin': pytest.skip() fs = sample_rate_bw_idx[0] @@ -397,6 +413,7 @@ def test_sba_enc_BWforce_system( fs, ivas_br, dtx, + None, bw, bypass, agc, @@ -415,6 +432,7 @@ def test_sba_enc_BWforce_system( fs, ivas_br, dtx, + None, bw, bypass, agc, @@ -437,6 +455,7 @@ def sba_enc( sampling_rate, ivas_br, dtx, + SID, ivas_max_bw, bypass, agc, @@ -468,16 +487,23 @@ def sba_enc( short_tag_ext = "" if agc != -1: short_tag_ext += f'_AGC{agc}' + if SID == 1: + short_tag_ext += f'_SID' # 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}" + if SID == 1: + long_tag_ext += f"_SID" 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" - + if SID == 1: + dut_pkt_file_cut = f"{dut_out_dir}/{tag_out}{long_tag_ext}_cut.pkt" + ref_pkt_file_cut = f"{ref_out_dir}/{tag_out}{short_tag_ext}_cut.pkt" + ref_pkt_file_dutenc_cut = f"{ref_out_dir}/{tag_out}{short_tag_ext}_dutenc_cut.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 @@ -539,7 +565,21 @@ def sba_enc( dtx_mode=dtx_mode, ) - + if SID == 1: + if ref_encoder_path: + with open(ref_pkt_file, "rb") as fp_in: + with open(ref_pkt_file_cut, "wb") as fp_out: + fr_cnt, cut_cnt = cut_bs(fp_in, fp_out, 0, True) + with open(ref_pkt_file_dutenc, "rb") as fp_in: + with open(ref_pkt_file_dutenc_cut, "wb") as fp_out: + fr_cnt, cut_cnt = cut_bs(fp_in, fp_out, 0, True) + os.remove(ref_pkt_file) + os.remove(ref_pkt_file_dutenc) + if update_ref == 0: + with open(dut_pkt_file, "rb") as fp_in: + with open(dut_pkt_file_cut, "wb") as fp_out: + fr_cnt, cut_cnt = cut_bs(fp_in, fp_out, 0, True) + os.remove(dut_pkt_file) def sba_dec( decoder_frontend, ref_decoder_path, @@ -549,6 +589,7 @@ def sba_dec( sampling_rate, ivas_br, dtx, + SID, ivas_max_bw, bypass, agc, @@ -571,11 +612,13 @@ def sba_dec( # 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}" - + if SID == 1: + short_tag_ext += f'_SID_cut' # 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}" - + if SID == 1: + long_tag_ext += f"_SID_cut" dut_out_dir = f"{dut_base_path}/sba_bs/raw" ref_out_dir = f"{reference_path}/sba_bs/raw" -- GitLab From ed32cc34ec9628e14c7e53d7617f7321055dc48c Mon Sep 17 00:00:00 2001 From: Vidhya V P <100825@ittiam.com> Date: Tue, 16 May 2023 12:29:14 +0530 Subject: [PATCH 4/5] Revoked a few changes [x] To avoid unnecessary skipping of test cases. --- tests/test_sba_bs_dec_plc.py | 2 +- tests/test_sba_bs_enc.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/test_sba_bs_dec_plc.py b/tests/test_sba_bs_dec_plc.py index 47e2c02680..46139da622 100644 --- a/tests/test_sba_bs_dec_plc.py +++ b/tests/test_sba_bs_dec_plc.py @@ -90,7 +90,7 @@ def test_sba_plc_system( agc ): SID = 0 - if dtx == '1' and ivas_br not in ['13200', '64000']: + if dtx == '1' and ivas_br not in ['13200','16400','32000', '64000']: # skip high bitrates for DTX until DTX issue is resolved pytest.skip() if ivas_br == '13200' or ivas_br == '16400': diff --git a/tests/test_sba_bs_enc.py b/tests/test_sba_bs_enc.py index 6ad6b6e9f3..9f0a6fed36 100644 --- a/tests/test_sba_bs_enc.py +++ b/tests/test_sba_bs_enc.py @@ -170,7 +170,7 @@ def test_sba_enc_system( agc, ): SID = 0 - if dtx == '1' and ivas_br not in ['13200', '64000']: + if dtx == '1' and ivas_br not in ['13200','16400','32000','64000']: # skip high bitrates for DTX until DTX issue is resolved pytest.skip() if ivas_br == 'sw_24k4_256k.bin' and agc != 1: @@ -386,7 +386,7 @@ def test_sba_enc_BWforce_system( tag, sample_rate_bw_idx, ): - if dtx == '1' and ivas_br not in ['32000', '64000']: + 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 == '13200' or ivas_br == '16400': -- GitLab From b0f7b2b46d0ae57b191ca41a93a0b499d1345aeb Mon Sep 17 00:00:00 2001 From: Vidhya V P <100825@ittiam.com> Date: Tue, 16 May 2023 13:30:28 +0530 Subject: [PATCH 5/5] Minor clean-up changes --- tests/test_sba_bs_dec_plc.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/tests/test_sba_bs_dec_plc.py b/tests/test_sba_bs_dec_plc.py index 46139da622..8dae57823f 100644 --- a/tests/test_sba_bs_dec_plc.py +++ b/tests/test_sba_bs_dec_plc.py @@ -93,9 +93,6 @@ def test_sba_plc_system( if dtx == '1' and ivas_br not in ['13200','16400','32000', '64000']: # skip high bitrates for DTX until DTX issue is resolved pytest.skip() - if ivas_br == '13200' or ivas_br == '16400': - if dtx == '0' and agc == 1: - pytest.skip() if ivas_br == '13200' or ivas_br == '16400': if dtx == '1' and agc == 0 and fs != '16': SID = 1 -- GitLab