From c86d51b9c2bbbe86aba90f62b378467d1dc624b9 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Tue, 1 Apr 2025 12:43:23 +0200 Subject: [PATCH] fix ref/cut signal order in cmp_pcm calls --- tests/codec_be_on_mr_nonselection/test_sba.py | 2 +- tests/renderer/utils.py | 81 ++++++++++--------- 2 files changed, 44 insertions(+), 39 deletions(-) diff --git a/tests/codec_be_on_mr_nonselection/test_sba.py b/tests/codec_be_on_mr_nonselection/test_sba.py index ce6d073942..f0e81e82d2 100644 --- a/tests/codec_be_on_mr_nonselection/test_sba.py +++ b/tests/codec_be_on_mr_nonselection/test_sba.py @@ -1252,8 +1252,8 @@ def sba_dec( sampling_rate_Hz = int(sampling_rate) * 1000 cmp_result, reason = cmp_pcm( - dut_out_file, ref_out_file, + dut_out_file, output_config, sampling_rate_Hz, get_mld=get_mld, diff --git a/tests/renderer/utils.py b/tests/renderer/utils.py index 2be90224a6..aac6a3d7c8 100644 --- a/tests/renderer/utils.py +++ b/tests/renderer/utils.py @@ -325,37 +325,37 @@ def run_renderer( odg_ref = out_file_ref[0:-4] + ".BINAURAL.wav" if out_fmt not in PEAQ_SUPPORTED_FMT: - if in_fmt in PEAQ_SUPPORTED_FMT: - new_fmt = in_fmt # MONO or STEREO + if in_fmt in PEAQ_SUPPORTED_FMT: + new_fmt = in_fmt # MONO or STEREO + else: + # If input is META which contains stereo, new_fmt needs to be STEREO. + if in_fmt == "META": + with open(in_file, "r") as scene: + if "STEREO" in scene.read(): + new_fmt = "STEREO" + else: + new_fmt = "BINAURAL" else: - # If input is META which contains stereo, new_fmt needs to be STEREO. - if in_fmt == "META": - with open(in_file,"r") as scene: - if "STEREO" in scene.read(): - new_fmt = "STEREO" - else: - new_fmt = "BINAURAL" - else: - new_fmt = "BINAURAL" - - # Render test to PEAQ supported format (MONO, STEREO or BINAURAL) - cmd2 = RENDERER_CMD[:] - cmd2[2] = str(out_file) # in_file - cmd2[4] = str(out_fmt) # in_fmt - cmd2[6] = odg_test # out_file - cmd2[8] = new_fmt # out_fmt - cmd2[10] = str(sr) - cmd2[0] += BIN_SUFFIX_MERGETARGET # Use IVAS_rend_ref for re-rendering - cmd2[0] += binary_suffix - if "MASA" in str(out_fmt): - cmd2.extend(["-im", out_file + ".met"]) - run_cmd(cmd2, test_info, env) - - # Render ref to BINAURAL with same settings as test - cmd2[2] = str(out_file_ref) # in_file - cmd2[6] = odg_ref # out_file - run_cmd(cmd2, test_info, env) - out_fmt_bin = new_fmt + new_fmt = "BINAURAL" + + # Render test to PEAQ supported format (MONO, STEREO or BINAURAL) + cmd2 = RENDERER_CMD[:] + cmd2[2] = str(out_file) # in_file + cmd2[4] = str(out_fmt) # in_fmt + cmd2[6] = odg_test # out_file + cmd2[8] = new_fmt # out_fmt + cmd2[10] = str(sr) + cmd2[0] += BIN_SUFFIX_MERGETARGET # Use IVAS_rend_ref for re-rendering + cmd2[0] += binary_suffix + if "MASA" in str(out_fmt): + cmd2.extend(["-im", out_file + ".met"]) + run_cmd(cmd2, test_info, env) + + # Render ref to BINAURAL with same settings as test + cmd2[2] = str(out_file_ref) # in_file + cmd2[6] = odg_ref # out_file + run_cmd(cmd2, test_info, env) + out_fmt_bin = new_fmt else: out_fmt_bin = out_fmt odg_test = out_file @@ -365,8 +365,8 @@ def run_renderer( # Render input to match out_fmt_bin using same config as input, but with IVAS_rend_ref cmd[0] += BIN_SUFFIX_MERGETARGET cmd[0] += binary_suffix - cmd[6] = odg_input # out_file - cmd[8] = out_fmt_bin # out_fmt + cmd[6] = odg_input # out_file + cmd[8] = out_fmt_bin # out_fmt run_cmd(cmd, test_info, env) else: odg_input = in_file @@ -374,8 +374,8 @@ def run_renderer( # see constants.py ref_fs = int(cmd[10]) * 1000 output_differs, reason = cmp_pcm( - out_file, out_file_ref, + out_file, out_fmt, ref_fs, get_mld=get_mld, @@ -455,7 +455,6 @@ def binauralize_input_and_output( in_sr, out_sr, ): - # Use current folder as location for temporary directory, since scene description does not handle spaces in path with tempfile.TemporaryDirectory(dir=".") as tmp_dir: tmp_dir = Path(tmp_dir) @@ -464,7 +463,7 @@ def binauralize_input_and_output( scene_in = str(tmp_dir.joinpath("scene_in.txt")) # File names for binauralized signals, if needed - ref_input_file_binaural = ref_output_file[0:-4] + ".INPUT.BINAURAL.wav" + ref_input_file_binaural = ref_output_file[0:-4] + ".INPUT.BINAURAL.wav" dut_output_file_binaural = dut_output_file[0:-4] + ".BINAURAL.wav" ref_output_file_binaural = ref_output_file[0:-4] + ".BINAURAL.wav" @@ -492,7 +491,7 @@ def binauralize_input_and_output( ",".join(line.split(",")[:2]) + "\n" ) # Keep only first two elements: azim, elev else: - md_out_file = "NULL" # Cannot truncate NULL, just insert it without modification + md_out_file = "NULL" # Cannot truncate NULL, just insert it without modification truncated_meta_files.append(md_out_file) in_meta_files = truncated_meta_files @@ -522,7 +521,9 @@ def binauralize_input_and_output( if "OSBA" in output_config or "OMASA" in output_config: if "OSBA" in output_config: - output_config = output_config[:-1] + '3' # Temporary fix to handle than IVAS_dec produces HOA3 for all OSBA configs. Needs to be removed when this fix is ported to BASOP. + output_config = ( + output_config[:-1] + "3" + ) # Temporary fix to handle than IVAS_dec produces HOA3 for all OSBA configs. Needs to be removed when this fix is ported to BASOP. scene_description_file( output_config, scene_dut, n_obj, dut_output_file, out_meta_files ) @@ -656,7 +657,11 @@ def binauralize_input_and_output( ) else: ref_input_file_binaural = input_file - return (ref_input_file_binaural, dut_output_file_binaural, ref_output_file_binaural) + return ( + ref_input_file_binaural, + dut_output_file_binaural, + ref_output_file_binaural, + ) def findstr(exp, s, one_element=True): -- GitLab