Loading tests/split_rendering/test_voip_be_splitrend_vs_binaural.py 0 → 100644 +154 −0 Original line number Diff line number Diff line #!/usr/bin/env python3 """ (C) 2022-2025 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, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other contributors to this repository. All Rights Reserved. This software is protected by copyright law and by international treaties. The IVAS codec Public Collaboration consisting of 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, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other contributors to this repository retain full ownership rights in their respective contributions in the software. This notice grants no license of any kind, including but not limited to patent license, nor is any license granted by implication, estoppel or otherwise. Contributors are required to enter into the IVAS codec Public Collaboration agreement before making contributions. This software is provided "AS IS", without any express or implied warranties. The software is in the development stage. It is intended exclusively for experts who have experience with such software and solely for the purpose of inspection. All implied warranties of non-infringement, merchantability and fitness for a particular purpose are hereby disclaimed and excluded. Any dispute, controversy or claim arising under or in relation to providing this software shall be submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and the United Nations Convention on Contracts on the International Sales of Goods. """ import pytest from tempfile import TemporaryDirectory from pathlib import Path import filecmp from tests.split_rendering.utils import * from tests.split_rendering.constants import SCRIPTS_DIR, TESTV_DIR from tests.test_be_for_jbm_neutral_dly_profile import ( INPUT_FILES, get_options_cod, ) from pyaudio3dtools import audioarray, audiofile IN_FORMATS = [ "MC_5_1", "ISM4", "FOA", "MASA2TC", ] DELAY_PROFILES = ["dly_error_profile_0.dat", "dly_error_profile_5.dat"] # Compares PCM output and tracefile from a VoIP BINAURAL_SPLIT_PCM chain with equivalent BINAURAL # chain to ensure time-scaling and other JBM operations are BE between the two. @pytest.mark.parametrize("in_format", IN_FORMATS) @pytest.mark.parametrize("delay_profile", DELAY_PROFILES) def test_voip_be_splitrend_vs_binaural( in_format, delay_profile, dut_encoder_frontend, dut_decoder_frontend, ivas_bitrate=128000, ): with TemporaryDirectory() as tmp_dir: tmp_dir = Path(tmp_dir) sampling_rate_khz = 48 delay_profile_path = SCRIPTS_DIR / "dly_error_profiles" / delay_profile delay_profile_id = int(delay_profile[-5]) # run encoder bitstream_file = (tmp_dir / f"{in_format}-dly{delay_profile_id}.192").absolute() dtx = False wav_in = TESTV_DIR / INPUT_FILES[in_format] dut_encoder_frontend.run( ivas_bitrate, sampling_rate_khz, wav_in, bitstream_file, add_option_list=get_options_cod(in_format, dtx), run_dir=tmp_dir, ) def run_decoder(out_format): options = [] # With CLDFB pose correction (default with BINAURAL_SPLIT_PCM), a 20 ms audio frame is # rendered with only one head position (first of the 4 per frame). If we want to compare # the output from BINAURAL_SPLIT_PCM to output from BINAURAL, the head trajectory must # be static. head_traj = Path(SCRIPTS_DIR / "trajectories/const000.csv") options.extend(["-T", str(head_traj)]) wav_out = ( tmp_dir / f"{in_format}-{ivas_bitrate}-{out_format}-dly{delay_profile_id}.wav" ).absolute() trace_out = wav_out.with_suffix(".trace") options.extend(["-Tracefile", str(trace_out), "-no_delay_cmp"]) if out_format == "BINAURAL_SPLIT_PCM": isar_md_file = wav_out.with_suffix(".isarmd") options.extend(["-om", str(isar_md_file)]) else: isar_md_file = None dut_decoder_frontend.run( out_format, sampling_rate_khz, bitstream_file, wav_out, netsim_profile=delay_profile_path, add_option_list=options, ) return wav_out, trace_out, isar_md_file wav_out_bin, trace_out_bin, _ = run_decoder("BINAURAL") wav_out_sr, trace_out_sr, _ = run_decoder("BINAURAL_SPLIT_PCM") # Note regarding delay alignment: both output audio files contain the same decoder delay. # # - When outputting to BINAURAL with -no_delay_cmp, decoder delay is present in the audio # output, as expected. # # - When outputting to BINAURAL_SPLIT_PCM, decoder delay is never compensated in output # audio (irrespective of the -no_delay_cmp flag). The delay value is saved in the ISAR # metadata file and compensated at the post-rendering stage. audio_sr, _ = audiofile.readfile(str(wav_out_sr)) audio_bin, _ = audiofile.readfile(str(wav_out_bin)) # Ensure audio and tracefiles are BE audio_cmp_result = audioarray.compare( audio_bin, audio_sr, fs=sampling_rate_khz * 1000, per_frame=False ) tracefiles_equal = filecmp.cmp(trace_out_bin, trace_out_sr) failed = not audio_cmp_result["bitexact"] or not tracefiles_equal if failed: message = [] if not audio_cmp_result["bitexact"]: message.append( "Difference found between delay-aligned BINAURAL audio and BINAURAL_SPLIT_PCM audio! " f"Max abs diff: {audio_cmp_result['max_abs_diff']}" ) if not tracefiles_equal: message.append( "Difference found between BINAURAL tracefile and BINAURAL_SPLIT_PCM tracefile!" ) pytest.fail("; ".join(message)) Loading
tests/split_rendering/test_voip_be_splitrend_vs_binaural.py 0 → 100644 +154 −0 Original line number Diff line number Diff line #!/usr/bin/env python3 """ (C) 2022-2025 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, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other contributors to this repository. All Rights Reserved. This software is protected by copyright law and by international treaties. The IVAS codec Public Collaboration consisting of 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, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other contributors to this repository retain full ownership rights in their respective contributions in the software. This notice grants no license of any kind, including but not limited to patent license, nor is any license granted by implication, estoppel or otherwise. Contributors are required to enter into the IVAS codec Public Collaboration agreement before making contributions. This software is provided "AS IS", without any express or implied warranties. The software is in the development stage. It is intended exclusively for experts who have experience with such software and solely for the purpose of inspection. All implied warranties of non-infringement, merchantability and fitness for a particular purpose are hereby disclaimed and excluded. Any dispute, controversy or claim arising under or in relation to providing this software shall be submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and the United Nations Convention on Contracts on the International Sales of Goods. """ import pytest from tempfile import TemporaryDirectory from pathlib import Path import filecmp from tests.split_rendering.utils import * from tests.split_rendering.constants import SCRIPTS_DIR, TESTV_DIR from tests.test_be_for_jbm_neutral_dly_profile import ( INPUT_FILES, get_options_cod, ) from pyaudio3dtools import audioarray, audiofile IN_FORMATS = [ "MC_5_1", "ISM4", "FOA", "MASA2TC", ] DELAY_PROFILES = ["dly_error_profile_0.dat", "dly_error_profile_5.dat"] # Compares PCM output and tracefile from a VoIP BINAURAL_SPLIT_PCM chain with equivalent BINAURAL # chain to ensure time-scaling and other JBM operations are BE between the two. @pytest.mark.parametrize("in_format", IN_FORMATS) @pytest.mark.parametrize("delay_profile", DELAY_PROFILES) def test_voip_be_splitrend_vs_binaural( in_format, delay_profile, dut_encoder_frontend, dut_decoder_frontend, ivas_bitrate=128000, ): with TemporaryDirectory() as tmp_dir: tmp_dir = Path(tmp_dir) sampling_rate_khz = 48 delay_profile_path = SCRIPTS_DIR / "dly_error_profiles" / delay_profile delay_profile_id = int(delay_profile[-5]) # run encoder bitstream_file = (tmp_dir / f"{in_format}-dly{delay_profile_id}.192").absolute() dtx = False wav_in = TESTV_DIR / INPUT_FILES[in_format] dut_encoder_frontend.run( ivas_bitrate, sampling_rate_khz, wav_in, bitstream_file, add_option_list=get_options_cod(in_format, dtx), run_dir=tmp_dir, ) def run_decoder(out_format): options = [] # With CLDFB pose correction (default with BINAURAL_SPLIT_PCM), a 20 ms audio frame is # rendered with only one head position (first of the 4 per frame). If we want to compare # the output from BINAURAL_SPLIT_PCM to output from BINAURAL, the head trajectory must # be static. head_traj = Path(SCRIPTS_DIR / "trajectories/const000.csv") options.extend(["-T", str(head_traj)]) wav_out = ( tmp_dir / f"{in_format}-{ivas_bitrate}-{out_format}-dly{delay_profile_id}.wav" ).absolute() trace_out = wav_out.with_suffix(".trace") options.extend(["-Tracefile", str(trace_out), "-no_delay_cmp"]) if out_format == "BINAURAL_SPLIT_PCM": isar_md_file = wav_out.with_suffix(".isarmd") options.extend(["-om", str(isar_md_file)]) else: isar_md_file = None dut_decoder_frontend.run( out_format, sampling_rate_khz, bitstream_file, wav_out, netsim_profile=delay_profile_path, add_option_list=options, ) return wav_out, trace_out, isar_md_file wav_out_bin, trace_out_bin, _ = run_decoder("BINAURAL") wav_out_sr, trace_out_sr, _ = run_decoder("BINAURAL_SPLIT_PCM") # Note regarding delay alignment: both output audio files contain the same decoder delay. # # - When outputting to BINAURAL with -no_delay_cmp, decoder delay is present in the audio # output, as expected. # # - When outputting to BINAURAL_SPLIT_PCM, decoder delay is never compensated in output # audio (irrespective of the -no_delay_cmp flag). The delay value is saved in the ISAR # metadata file and compensated at the post-rendering stage. audio_sr, _ = audiofile.readfile(str(wav_out_sr)) audio_bin, _ = audiofile.readfile(str(wav_out_bin)) # Ensure audio and tracefiles are BE audio_cmp_result = audioarray.compare( audio_bin, audio_sr, fs=sampling_rate_khz * 1000, per_frame=False ) tracefiles_equal = filecmp.cmp(trace_out_bin, trace_out_sr) failed = not audio_cmp_result["bitexact"] or not tracefiles_equal if failed: message = [] if not audio_cmp_result["bitexact"]: message.append( "Difference found between delay-aligned BINAURAL audio and BINAURAL_SPLIT_PCM audio! " f"Max abs diff: {audio_cmp_result['max_abs_diff']}" ) if not tracefiles_equal: message.append( "Difference found between BINAURAL tracefile and BINAURAL_SPLIT_PCM tracefile!" ) pytest.fail("; ".join(message))