From 931b1f8a3688e5c0453df6659584710e8e9fd262 Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Fri, 10 Jan 2025 07:57:00 +0100 Subject: [PATCH] Fix for PEAQ binaural, where the input and reference binauralization had the same name --- .../test_param_file.py | 18 +----- tests/codec_be_on_mr_nonselection/test_sba.py | 19 +------ tests/renderer/utils.py | 55 +++++++++++++++---- 3 files changed, 47 insertions(+), 45 deletions(-) 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 905d5a6aad..2d90309601 100644 --- a/tests/codec_be_on_mr_nonselection/test_param_file.py +++ b/tests/codec_be_on_mr_nonselection/test_param_file.py @@ -509,7 +509,7 @@ def run_test( else ref_decoder_frontend.record_property ) - (odg_input, odg_test) = binauralize_input_and_output( + (odg_input, odg_test, odg_ref) = binauralize_input_and_output( record_property, props_to_record, test_info, @@ -524,22 +524,6 @@ def run_test( out_sr, ) - (_ , odg_ref) = binauralize_input_and_output( - record_property, - props_to_record, - test_info, - testv_file, - ref_output_file, - ref_output_file, - in_fmt, - output_config, - enc_opts, - dec_opts, - in_sr, - out_sr, - skip_input_rendering=True, - ) - # set to false per default even if this is no JBM case - makes later check for failure easier tracefile_last_rtp_numbers_differ = False diff --git a/tests/codec_be_on_mr_nonselection/test_sba.py b/tests/codec_be_on_mr_nonselection/test_sba.py index 576ffd8a2f..da39091567 100644 --- a/tests/codec_be_on_mr_nonselection/test_sba.py +++ b/tests/codec_be_on_mr_nonselection/test_sba.py @@ -1179,7 +1179,7 @@ def sba_dec( in_sr = sampling_rate out_sr = sampling_rate - (odg_input, odg_test) = binauralize_input_and_output( + (odg_input, odg_test, odg_ref) = binauralize_input_and_output( dut_decoder_frontend.record_property, props_to_record, test_info, @@ -1194,23 +1194,6 @@ def sba_dec( out_sr, ) - (_, odg_ref) = binauralize_input_and_output( - dut_decoder_frontend.record_property, - props_to_record, - test_info, - input_file, - ref_out_file, - ref_out_file, - in_fmt, - output_config, - enc_opts, - dec_opts, - in_sr, - out_sr, - skip_input_rendering=True, - ) - - allow_differing_lengths = False if compare_to_input: # If comparing to input, set input as reference and allow different length diff --git a/tests/renderer/utils.py b/tests/renderer/utils.py index 9942c3a175..caf21b23c5 100644 --- a/tests/renderer/utils.py +++ b/tests/renderer/utils.py @@ -393,16 +393,17 @@ def binauralize_input_and_output( dec_opts, in_sr, out_sr, - skip_input_rendering=False, ): # 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) - scene_out = str(tmp_dir.joinpath("scene_out.txt")) + scene_dut = str(tmp_dir.joinpath("scene_dut.txt")) + scene_ref = str(tmp_dir.joinpath("scene_ref.txt")) scene_in = str(tmp_dir.joinpath("scene_in.txt")) - # File names for binauralized input, if needed + # File names for binauralized signals, if needed + 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" @@ -462,9 +463,13 @@ def binauralize_input_and_output( 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. scene_description_file( - output_config, scene_out, n_obj, dut_output_file, out_meta_files + output_config, scene_dut, n_obj, dut_output_file, out_meta_files ) - dut_output_file = scene_out + dut_output_file = scene_dut + scene_description_file( + output_config, scene_ref, n_obj, ref_output_file, out_meta_files + ) + ref_output_file = scene_ref out_meta_files = None output_config = "META" @@ -523,16 +528,46 @@ def binauralize_input_and_output( sr=out_sr, render_for_peaq=True, ) + + check_and_makedir(str(Path(ref_output_file_binaural).parent)) + + run_renderer( + record_property, + props_to_record, + test_info, + output_config, + output_reformat, + metadata_input, + out_meta_files, + trj_file, + non_diegetic_pan, + name_extension, + refrot_file, + refvec_file, + refveclev_file, + config_file, + binary_suffix, + frame_size, + hrtf_file, + aeid, + in_file=ref_output_file, + out_file=ref_output_file_binaural, + sr=out_sr, + render_for_peaq=True, + ) + # Update output_config to rendered format output_config = output_reformat else: + # Signal already mono, stereo or binaural dut_output_file_binaural = dut_output_file + ref_output_file_binaural = ref_output_file - if in_fmt.upper() != output_config.upper() and not skip_input_rendering: + if in_fmt.upper() != output_config.upper(): # Render input to match output_config out_fmt = output_config - check_and_makedir(str(Path(ref_output_file_binaural).parent)) + check_and_makedir(str(Path(ref_input_file_binaural).parent)) run_renderer( record_property, @@ -554,13 +589,13 @@ def binauralize_input_and_output( hrtf_file, aeid, in_file=input_file, - out_file=ref_output_file_binaural, + out_file=ref_input_file_binaural, sr=in_sr, render_for_peaq=True, ) else: - ref_output_file_binaural = input_file - return (ref_output_file_binaural, dut_output_file_binaural) + ref_input_file_binaural = input_file + return (ref_input_file_binaural, dut_output_file_binaural, ref_output_file_binaural) def findstr(exp, s, one_element=True): -- GitLab