From 6931121b1f054b5b58defab6188b1fc4e8e149be Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Wed, 23 Apr 2025 08:53:18 +0200 Subject: [PATCH] fix split rendering tests api change of cmp_pcm for the split comparison broke them --- tests/split_rendering/utils.py | 143 +++++++++++++++++++-------------- 1 file changed, 82 insertions(+), 61 deletions(-) diff --git a/tests/split_rendering/utils.py b/tests/split_rendering/utils.py index 53de170c91..f9a1e86fc7 100644 --- a/tests/split_rendering/utils.py +++ b/tests/split_rendering/utils.py @@ -1,33 +1,33 @@ #!/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. +(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 sys @@ -39,7 +39,13 @@ from typing import Tuple import numpy as np import pytest -from tests.renderer.utils import check_BE, run_ivas_isar_enc_cmd, run_ivas_isar_dec_cmd, run_isar_post_rend_cmd, run_isar_ext_rend_cmd +from tests.renderer.utils import ( + check_BE, + run_ivas_isar_enc_cmd, + run_ivas_isar_dec_cmd, + run_isar_post_rend_cmd, + run_isar_ext_rend_cmd, +) from tests.split_rendering.constants import * from ..cmp_pcm import cmp_pcm from ..conftest import parse_properties @@ -62,8 +68,10 @@ def lc3plus_used(test_info, in_fmt, render_config): or ("default" in render_config and "external_split" in test_info.node.name) ) + FRAME_SIZE_RE = re.compile(r"(\d+)ms") + def transport_codec_frame_size_ms(test_info, in_fmt, render_config, pre_rend_fr): explicit_frame_size_ms = FRAME_SIZE_RE.search(render_config) @@ -154,7 +162,7 @@ def truncate_signal( def run_full_chain_split_rendering( record_property, - props_to_record, + props_to_record, test_info, in_fmt: str, bitrate: str, @@ -166,29 +174,31 @@ def run_full_chain_split_rendering( post_rend_fr: str = "20", pre_rend_fr: str = "20", get_mld=False, - mld_lim=0, + mld_lim=0, get_ssnr=False, get_odg=False, - get_odg_bin=False, + get_odg_bin=False, ) -> str: """ Runs the full split rendering chain consisting of the IVAS encoder, decoder and split renderer """ - check_xfail(test_info, in_fmt, render_config.name, pre_rend_fr, post_rend_fr, bitrate) + check_xfail( + test_info, in_fmt, render_config.name, pre_rend_fr, post_rend_fr, bitrate + ) with TemporaryDirectory() as tmp_dir: tmp_dir = Path(tmp_dir) cut_in_file = tmp_dir.joinpath("cut_input.wav") - #ivas_bitstream = tmp_dir.joinpath("ivas.192") + # ivas_bitstream = tmp_dir.joinpath("ivas.192") ivas_bitstream_stem = f"{in_fmt}_{bitrate}bps_{renderer_fmt}_split_full_config_{render_config.stem}_prerfr_{pre_rend_fr}_postrfr_{post_rend_fr}_ivas.192" - #split_bitstream = tmp_dir.joinpath("split.bit") + # split_bitstream = tmp_dir.joinpath("split.bit") split_bitstream_stem = f"{in_fmt}_{bitrate}bps_{renderer_fmt}_split_full_config_{render_config.stem}_prerfr_{pre_rend_fr}_postrfr_{post_rend_fr}_split.bit" if renderer_fmt == "BINAURAL_SPLIT_PCM": - #split_md_file = tmp_dir.joinpath("split_md.bin") + # split_md_file = tmp_dir.joinpath("split_md.bin") split_md_file_stem = f"{in_fmt}_{bitrate}bps_{renderer_fmt}_split_full_config_{render_config.stem}_prerfr_{pre_rend_fr}_postrfr_{post_rend_fr}_split_md.bit" - + out_file_stem = f"{in_fmt}_{bitrate}bps_{renderer_fmt}_split_full_config_{render_config.stem}_prerfr_{pre_rend_fr}_postrfr_{post_rend_fr}_.wav" if test_info.config.option.create_ref: @@ -206,7 +216,11 @@ def run_full_chain_split_rendering( if in_fmt.upper().startswith("OSBA"): # use same MD as ISM in_meta_files = FORMAT_TO_METADATA_FILES[f"ISM{in_fmt[5]}"] - elif in_fmt.upper().startswith("ISM") or in_fmt.upper().startswith("MASA") or in_fmt.upper().startswith("OMASA"): + elif ( + in_fmt.upper().startswith("ISM") + or in_fmt.upper().startswith("MASA") + or in_fmt.upper().startswith("OMASA") + ): in_meta_files = FORMAT_TO_METADATA_FILES[in_fmt] else: in_meta_files = None @@ -256,7 +270,7 @@ def run_full_chain_split_rendering( # run split renderer cmd = SPLIT_POST_REND_CMD[:] - #if test_info.config.option.create_ref: + # if test_info.config.option.create_ref: # cmd[0] += BIN_SUFFIX_MERGETARGET cmd[0] += binary_suffix cmd[4] = str(split_bitstream) @@ -283,35 +297,38 @@ def run_full_chain_split_rendering( cut, cut_fs = readfile(out_file) - if get_mld == False: - [diff_found, snr, gain_b, max_diff] = check_BE(test_info, ref, ref_fs, cut, cut_fs) - if diff_found : + if not get_mld: + [diff_found, snr, gain_b, max_diff] = check_BE( + test_info, ref, ref_fs, cut, cut_fs + ) + if diff_found: pytest.fail( f"CuT not BE to REF! SNR : {snr:3.2f} dB, Gain CuT: {gain_b:1.3f}, Max Diff = {int(max_diff)}" ) else: - # see constants.py output_differs, reason = cmp_pcm( out_file, out_file_ref, - "BINAURAL", + 2, # is always "BINAURAL" ref_fs, get_mld=get_mld, mld_lim=mld_lim, get_ssnr=get_ssnr, get_odg=get_odg, - get_odg_bin=get_odg_bin, + get_odg_bin=get_odg_bin, ) - + + # NOTE: split comparison not implemented for split rendering, always unpack values + reason = reason[0] + output_differs = output_differs[0] + props = parse_properties(reason, output_differs, props_to_record) for k, v in props.items(): record_property(k, v) - + if output_differs: pytest.fail(f"Output differs: ({reason})") - - - + return out_file @@ -330,10 +347,10 @@ def run_external_split_rendering( post_rend_fr: str = "20", pre_rend_fr: str = "20", get_mld=False, - mld_lim=0, + mld_lim=0, get_ssnr=False, get_odg=False, - get_odg_bin=False, + get_odg_bin=False, ) -> Tuple[np.ndarray, int]: """ Runs the exeternal split rendering chain consisting of @@ -399,7 +416,7 @@ def run_external_split_rendering( # run split renderer cmd = SPLIT_POST_REND_CMD[:] - #if test_info.config.option.create_ref: + # if test_info.config.option.create_ref: # cmd[0] += BIN_SUFFIX_MERGETARGET cmd[0] += binary_suffix cmd[4] = str(split_bitstream) @@ -434,8 +451,10 @@ def run_external_split_rendering( cut, cut_fs = readfile(out_file) if get_mld == False: - [diff_found, snr, gain_b, max_diff] = check_BE(test_info, ref, ref_fs, cut, cut_fs) - if diff_found : + [diff_found, snr, gain_b, max_diff] = check_BE( + test_info, ref, ref_fs, cut, cut_fs + ) + if diff_found: pytest.fail( f"CuT not BE to REF! SNR : {snr:3.2f} dB, Gain CuT: {gain_b:1.3f}, Max Diff = {int(max_diff)}" ) @@ -444,21 +463,23 @@ def run_external_split_rendering( output_differs, reason = cmp_pcm( out_file, out_file_ref, - "BINAURAL", + 2, # is always "BINAURAL", ref_fs, get_mld=get_mld, mld_lim=mld_lim, get_ssnr=get_ssnr, get_odg=get_odg, - get_odg_bin=get_odg_bin, + get_odg_bin=get_odg_bin, ) - + # NOTE: split comparison not implemented for split rendering, always unpack values + reason = reason[0] + output_differs = output_differs[0] + props = parse_properties(reason, output_differs, props_to_record) for k, v in props.items(): record_property(k, v) - + if output_differs: - pytest.fail(f"Output differs: ({reason})") - - + pytest.fail(f"Output differs: ({reason})") + return out_file -- GitLab