diff --git a/tests/codec_be_on_mr_nonselection/test_param_file.py b/tests/codec_be_on_mr_nonselection/test_param_file.py index 6df169bf0421d4fe3abf5325537843260f295844..e09ec73c5ff4cd1271f23e04de2944a12e93e142 100644 --- a/tests/codec_be_on_mr_nonselection/test_param_file.py +++ b/tests/codec_be_on_mr_nonselection/test_param_file.py @@ -1,5 +1,4 @@ -__copyright__ = \ -""" +__copyright__ = """ (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, @@ -29,12 +28,12 @@ accordance with the laws of the Federal Republic of Germany excluding its confli the United Nations Convention on Contracts on the International Sales of Goods. """ -__doc__ = \ -""" +__doc__ = """ Execute tests specified via a parameter file. """ import os +from pathlib import Path import errno import platform import filecmp @@ -59,6 +58,7 @@ VALID_DEC_OUTPUT_CONF = [ "HOA3", "BINAURAL", "BINAURAL_ROOM_IR", + "BINAURAL_ROOM_REVERB", "EXT", ] @@ -157,8 +157,8 @@ def test_param_file_tests( sba_br_switching_dtx = 0 if ( not bitrate.isdigit() - and "-dtx" in enc_opts.split() - and "-sba" in enc_opts.split() + and "-dtx" in enc_split + and "-sba" in enc_split and testv_file.split("/")[1].startswith("stv") ): sba_br_switching_dtx = 1 @@ -284,27 +284,30 @@ def test_param_file_tests( tracefile_dec, ) - # get metadata file paths from decoder stdout - md_out_files = list() - for line in stdout.split("\n"): - line_strip = line.strip() - if line_strip.startswith("Output metadata file"): - line_split = line_strip.split() - md_file = os.path.basename(line_split[-1]) - md_out_files.append(md_file) - if update_ref in [0, 2]: dut_output_file = f"{dut_base_path}/param_file/dec/{output_file}" ref_output_file = f"{reference_path}/param_file/dec/{output_file}" fs = int(sampling_rate) * 1000 - output_differs, reason = cmp_pcm(dut_output_file, ref_output_file, output_config, fs) + output_differs, reason = cmp_pcm( + dut_output_file, ref_output_file, output_config, fs + ) + + md_out_files = get_expected_md_files(ref_output_file, enc_split, output_config) metadata_differs = False for md_file in md_out_files: - print(md_file) - dut_metadata_file = f"{dut_base_path}/param_file/dec/{md_file}" - ref_metadata_file = f"{reference_path}/param_file/dec/{md_file}" - metadata_differs = not filecmp.cmp(dut_metadata_file, ref_metadata_file) + dut_metadata_file = Path(f"{dut_base_path}/param_file/dec/{md_file}") + ref_metadata_file = Path(f"{reference_path}/param_file/dec/{md_file}") + try: + if not filecmp.cmp(dut_metadata_file, ref_metadata_file): + print("Output metadata differs for file: " + md_file) + metadata_differs = True + except FileNotFoundError: + if not dut_metadata_file.exists(): + print(f"DUT output metadata missing for expected file: " + md_file) + if not ref_metadata_file.exists(): + print(f"REF output metadata missing for expected file: " + md_file) + metadata_differs = True if output_differs or metadata_differs: msg = "Difference between ref and dut in " @@ -411,9 +414,17 @@ def simulate( ref_out_file = f"{ref_out_dir}/{netsim_outfile}" if platform.system() == "Windows": - netsim = [os.path.join(rootdir, "scripts", "tools", "Win32", "networkSimulator_g192.exe")] + netsim = [ + os.path.join( + rootdir, "scripts", "tools", "Win32", "networkSimulator_g192.exe" + ) + ] elif platform.system() in ["Linux", "Darwin"]: - netsim = [os.path.join(rootdir, "scripts", "tools", platform.system(), "networkSimulator_g192")] + netsim = [ + os.path.join( + rootdir, "scripts", "tools", platform.system(), "networkSimulator_g192" + ) + ] else: assert False, f"networkSimulator_g192 not available for {platform.system()}" @@ -500,3 +511,34 @@ def decode( stdout = decoder_frontend.stdout return stdout + + +def get_expected_md_files(ref_output_file, enc_opts, output_config): + """ + Based on input and output configs, get the filenames of MD files that are expected to being output by the decoder + """ + + if output_config.upper() != "EXT": + return list() + + md_files = list() + enc_opts_upper = [o.upper() for o in enc_opts] + md_filename = Path(ref_output_file).name + + if any([o in enc_opts_upper for o in ["-MASA", "-ISM_MASA"]]): + # always only one MD file, just add ending + md_files.append(md_filename + ".met") + + for ism_opt in ["-ISM", "-ISM_MASA", "-ISM_SBA"]: + # for ism MD, there are three modes that may output MD files + # try to find any of them in the encoder options + md_tmpl = md_filename + ".{}.csv" + try: + idx = enc_opts_upper.index(ism_opt) + ism_num = int(enc_opts[idx + 1]) + md_files.extend([md_tmpl.format(i) for i in range(ism_num)]) + break + except ValueError: + pass + + return md_files