diff --git a/scripts/cut_bs.py b/scripts/cut_bs.py index 5fee9845e743fb26b0f3552b09e26b31cf3d0954..c0ae6e19330bd70f8e04ee7e67a56e062689043d 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_sba_bs_dec_plc.py b/tests/test_sba_bs_dec_plc.py index 4920a9c59cec4cae613850989fb2802065dbf37a..8dae57823f6030f6adaa11d08d9e8f868ec24096 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,15 @@ 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','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 == '1' and agc == 0 and fs != '16': + SID = 1 + else: + pytest.skip() tag = tag + fs + 'c' # dec @@ -106,6 +111,7 @@ def test_sba_plc_system( fs, ivas_br, dtx, + SID, plc_pattern, update_ref, agc, @@ -125,6 +131,7 @@ def sba_dec_plc( sampling_rate, ivas_br, dtx, + SID, plc_pattern, update_ref, agc, @@ -147,6 +154,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 6825ee12ba3d162a21759cbab87d8a8aa8d2aaaa..9f0a6fed368d131600500a0ff8044ef512914466 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','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: - 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, @@ -372,9 +386,11 @@ 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': + 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"