diff --git a/ci/smoke_test.sh b/ci/smoke_test.sh index 1e758b6263807a7e435581c54c2486e3d9b0008b..e6ccc1ffa5851d08e5e9275536b5430b233bf925 100755 --- a/ci/smoke_test.sh +++ b/ci/smoke_test.sh @@ -56,6 +56,7 @@ fi cfg=./scripts/config/ci_linux.json dly_profile=./scripts/dly_error_profiles/dly_error_profile_10.dat ism_md_cmd="--metadata_files /usr/local/ltv/ltvISM1.csv /usr/local/ltv/ltvISM2.csv /usr/local/ltv/ltvISM3.csv /usr/local/ltv/ltvISM4.csv" +duration_arg="-U 1:2" if [ $BUILD -eq 1 ];then # Enable memory macros to find unbalanced memory allocations/deallocations @@ -79,20 +80,20 @@ fi ism_modes=$(./scripts/runIvasCodec.py -l | grep ISM) non_ism_modes=$(./scripts/runIvasCodec.py -l | grep -v ISM) echo "\n======================= 1. non-ism modes no FEC =======================\n\n" -./scripts/runIvasCodec.py -m $non_ism_modes -p $cfg -U 1 $WORKERS | tee smoke_test_output.txt +./scripts/runIvasCodec.py -m $non_ism_modes -p $cfg $duration_arg $WORKERS | tee smoke_test_output.txt echo "\n======================= 2. ism modes no FEC =======================\n\n" -./scripts/runIvasCodec.py -m $ism_modes -p $cfg -U 1 $WORKERS $ism_md_cmd | tee smoke_test_output.txt +./scripts/runIvasCodec.py -m $ism_modes -p $cfg $duration_arg $WORKERS $ism_md_cmd | tee smoke_test_output.txt # run the decoding again, but with 15% frame loss echo "\n======================= 3. all modes with FEC =======================\n\n" -./scripts/runIvasCodec.py -p $cfg -U 1 $WORKERS -D="-fec 15" --decoder_only | tee smoke_test_output_plc.txt +./scripts/runIvasCodec.py -p $cfg $duration_arg $WORKERS -D="-fec 15" --decoder_only | tee smoke_test_output_plc.txt # run JBM modes - EXT is excluded as not supported yet modes_with_no_ext_out=$(./scripts/runIvasCodec.py -l | grep -v MASA | grep -v ISM) modes_with_ext_out=$(./scripts/runIvasCodec.py -l | grep 'MASA\|ISM' | grep -v ISM+) echo "\n======================= 4. JBM, modes with no EXT =======================\n\n" -./scripts/runIvasCodec.py -m $modes_with_no_ext_out -p $cfg -U 1 $WORKERS --decoder_only --jbm_file $dly_profile | tee smoke_test_output_jbm_noEXT.txt +./scripts/runIvasCodec.py -m $modes_with_no_ext_out -p $cfg $duration_arg $WORKERS --decoder_only --jbm_file $dly_profile | tee smoke_test_output_jbm_noEXT.txt echo "\n======================= 5. JBM, modes with EXT =======================\n\n" -./scripts/runIvasCodec.py -m $modes_with_ext_out -p $cfg -U 1 $WORKERS --decoder_only --jbm_file $dly_profile --oc BINAURAL BINAURAL_ROOM mono stereo FOA HOA3 5_1 7_1_4 | tee -a smoke_test_output_jbm_noEXT.txt +./scripts/runIvasCodec.py -m $modes_with_ext_out -p $cfg $duration_arg $WORKERS --decoder_only --jbm_file $dly_profile --oc BINAURAL BINAURAL_ROOM mono stereo FOA HOA3 5_1 7_1_4 | tee -a smoke_test_output_jbm_noEXT.txt # run all modes with binaural output using external files modes_with_bin_out="SBA PlanarSBA MASA MC ISM1 ISM2 ISM3 ISM4" @@ -101,14 +102,14 @@ bin_out_modes="BINAURAL BINAURAL_ROOM" echo "\n======================= 6. binaural out with HRTF files - WB =======================\n\n" wb_modes=$(./scripts/runIvasCodec.py -l -C $modes_with_bin_out | grep _wb_) hrtf_wb="../scripts/binauralRenderer_interface/binaural_renderers_hrtf_data/ivas_binaural_16kHz.bin" -./scripts/runIvasCodec.py -p $cfg -m $wb_modes -U 1 $WORKERS -D="-hrtf ${hrtf_wb}" --decoder_only --oc $bin_out_modes | tee -a smoke_test_output_hrtf.txt +./scripts/runIvasCodec.py -p $cfg -m $wb_modes $duration_arg $WORKERS -D="-hrtf ${hrtf_wb}" --decoder_only --oc $bin_out_modes | tee -a smoke_test_output_hrtf.txt echo "\n======================= 7. binaural out with HRTF files - SWB =======================\n\n" swb_modes=$(./scripts/runIvasCodec.py -l -C $modes_with_bin_out | grep _swb_) hrtf_swb="../scripts/binauralRenderer_interface/binaural_renderers_hrtf_data/ivas_binaural_32kHz.bin" -./scripts/runIvasCodec.py -p $cfg -m $swb_modes -U 1 $WORKERS -D="-hrtf ${hrtf_swb}" --decoder_only --oc $bin_out_modes | tee -a smoke_test_output_hrtf.txt +./scripts/runIvasCodec.py -p $cfg -m $swb_modes $duration_arg $WORKERS -D="-hrtf ${hrtf_swb}" --decoder_only --oc $bin_out_modes | tee -a smoke_test_output_hrtf.txt echo "\n======================= 8. binaural out with HRTF files - FB =======================\n\n" fb_modes=$(./scripts/runIvasCodec.py -l -C $modes_with_bin_out | grep _fb_) hrtf_fb="../scripts/binauralRenderer_interface/binaural_renderers_hrtf_data/ivas_binaural_48kHz.bin" -./scripts/runIvasCodec.py -p $cfg -m $fb_modes -U 1 $WORKERS -D="-hrtf ${hrtf_fb}" --decoder_only --oc $bin_out_modes | tee -a smoke_test_output_hrtf.txt +./scripts/runIvasCodec.py -p $cfg -m $fb_modes $duration_arg $WORKERS -D="-hrtf ${hrtf_fb}" --decoder_only --oc $bin_out_modes | tee -a smoke_test_output_hrtf.txt diff --git a/scripts/pyivastest/IvasModeRunner.py b/scripts/pyivastest/IvasModeRunner.py index 114991c3743c06e610ea85f784dba0843d75e70a..cabf7d424bb45dd19eeb61782e831bf5fc4aa4b7 100644 --- a/scripts/pyivastest/IvasModeRunner.py +++ b/scripts/pyivastest/IvasModeRunner.py @@ -183,6 +183,7 @@ class IvasModeRunner(IvasModeCollector.IvasModeCollector): self.flat_output_structure = flat_output_structure self.limit_duration = False self.max_duration = 0.0 + self.start_time = 0.0 self.encoder_cmdline_options = [] self.decoder_cmdline_options = [] self.run_encoder = True @@ -541,7 +542,7 @@ class IvasModeRunner(IvasModeCollector.IvasModeCollector): str(sample_rate_in), "_", config["cmd"]["in_config"].upper(), - "_L{}s".format("_".join(str(self.max_duration).split("."))), + "_L{}-{}s".format("_".join(str(self.start_time).split(".")), "_".join(str(self.max_duration).split("."))), ".pcm", ] ) @@ -606,16 +607,19 @@ class IvasModeRunner(IvasModeCollector.IvasModeCollector): # check if the given length with -U is longer than the file itself and avoid cutting then if do_limit_duration: - cut_len_samples = int(float(self.max_duration) * fs) - in_len = sig.shape[0] + # first check if start time exceeds signal length + start_time_samples = int(float(self.start_time) * fs) + if start_time_samples >= in_len: + raise RuntimeError("Signal is shorter than given start time") + + cut_len_samples = int(float(self.max_duration) * fs) - # no need to cut anything if given length is bigger than signal length - if cut_len_samples < in_len: - out_len = int(float(self.max_duration) * fs) - sig = ar.cut(sig, (0, out_len)) + if cut_len_samples + start_time_samples < in_len or start_time_samples > 0: + out_len = min(cut_len_samples, in_len - start_time_samples) + sig = ar.cut(sig, (start_time_samples, out_len)) - pcm_log.write("Limit signal length to {} samples".format(out_len)) + pcm_log.write("Limit signal length to {}:{} samples".format(start_time_samples, out_len)) af.writefile(pcm_name_cpy_transformed, sig, fs) resamp_in_path = pcm_name_cpy_transformed diff --git a/scripts/pyivastest/IvasScriptsCommon.py b/scripts/pyivastest/IvasScriptsCommon.py index a3876a2b4ee73d429b39a3e90deb17e267449dbe..ec501d0154219e3556f656024e1aa8de4eb38130 100644 --- a/scripts/pyivastest/IvasScriptsCommon.py +++ b/scripts/pyivastest/IvasScriptsCommon.py @@ -242,8 +242,8 @@ class IvasScriptArgParser(argparse.ArgumentParser): "-U", "--limit_duration", default=None, - help="limit dUration of input file to X seconds", - type=float, + help="limit dUration by specifying start and end of input signal in seconds. Can be either a single float value (will be interpreted as length), or by giving as start: (will be interpreted as start), or by giving as start:end", + type=str, ) self.add_argument( "-f", "--fer_file", default="", help="frame error pattern file" @@ -548,7 +548,23 @@ def runner_setup(runner, args): if args["limit_duration"]: runner.limit_duration = True - runner.max_duration = args["limit_duration"] + + # parse given argument + arg = args["limit_duration"] + start = 0 + + try: + end = float(arg) + except ValueError: + try: + start, end = arg.split(':') + start = float(start) + end = float(end) + except ValueError: + raise ValueError(f"Given duration string {arg} is invalid") + + runner.max_duration = end + runner.start_time = start if "fer_file" in args.keys() or "ber_file" in args.keys(): # assert that the eid-xor tool is there