From 0bc257f53878680637c5c2bf09a42d9847d06de9 Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Fri, 21 Feb 2025 10:14:48 +0100 Subject: [PATCH 1/2] Add --input_scaling parameter to inverse input scaling before cmp_pcm --- tests/cmp_pcm.py | 7 +++++++ tests/codec_be_on_mr_nonselection/test_param_file.py | 1 + tests/codec_be_on_mr_nonselection/test_sba.py | 1 + tests/conftest.py | 7 +++++++ tests/renderer/utils.py | 3 ++- 5 files changed, 18 insertions(+), 1 deletion(-) diff --git a/tests/cmp_pcm.py b/tests/cmp_pcm.py index cb779ff517..10b3a41d30 100755 --- a/tests/cmp_pcm.py +++ b/tests/cmp_pcm.py @@ -41,6 +41,7 @@ def cmp_pcm( ref_jbm_tf: Optional[Path] = None, cut_jbm_tf: Optional[Path] = None, quiet: Optional[bool] = False, + input_scaling=1, ) -> tuple[int, str]: """ Compare 2 PCM files for bitexactness @@ -89,6 +90,11 @@ def cmp_pcm( return 1, reason + # If input_scaling is applied, revert the scaling + if input_scaling != 1: + s1 = np.round(s1/input_scaling, 0) # Need rounding for max abs diff search + s2 = np.round(s2/input_scaling, 0) + cmp_result = pyaudio3dtools.audioarray.compare( s1, s2, @@ -256,6 +262,7 @@ if __name__ == "__main__": parser.add_argument("--get_odg", action="store_true") parser.add_argument("--get_ssnr", action="store_true") parser.add_argument("--allow_differing_lengths", action="store_true") + parser.add_argument("--input_scaling", type=float, default=1, dest="input_scaling", help="If input scaling is applied, apply the INVERSE scaling before comparison") parser.add_argument("--quiet", action="store_true") args = vars(parser.parse_args()) 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 e4928584cf..e860baa2d2 100644 --- a/tests/codec_be_on_mr_nonselection/test_param_file.py +++ b/tests/codec_be_on_mr_nonselection/test_param_file.py @@ -605,6 +605,7 @@ def run_test( odg_ref=odg_ref, ref_jbm_tf=ref_tracefile_dec, cut_jbm_tf=dut_tracefile_dec, + input_scaling=test_info.config.option.input_scaling, ) cmp_result_msg += reason diff --git a/tests/codec_be_on_mr_nonselection/test_sba.py b/tests/codec_be_on_mr_nonselection/test_sba.py index 55c7dcf3fe..b89d5820cf 100644 --- a/tests/codec_be_on_mr_nonselection/test_sba.py +++ b/tests/codec_be_on_mr_nonselection/test_sba.py @@ -1266,6 +1266,7 @@ def sba_dec( odg_input=odg_input, odg_test=odg_test, odg_ref=odg_ref, + input_scaling=test_info.config.option.input_scaling, ) text_to_parse = reason diff --git a/tests/conftest.py b/tests/conftest.py index 07cd5be183..c66fdc2a46 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -298,6 +298,13 @@ def pytest_addoption(parser): default=False, ) + parser.addoption( + "--input_scaling", + action="store", + help="If input scaling is applied, apply the INVERSE scaling before comparison.", + type=float, + default=1, + ) @pytest.fixture(scope="session", autouse=True) def update_ref(request): diff --git a/tests/renderer/utils.py b/tests/renderer/utils.py index 8170e1e06c..908c3a7190 100644 --- a/tests/renderer/utils.py +++ b/tests/renderer/utils.py @@ -386,7 +386,8 @@ def run_renderer( get_odg_bin=get_odg_bin, odg_input=odg_input, odg_test=odg_test, - odg_ref=odg_ref, + odg_ref=odg_ref, + input_scaling=test_info.config.option.input_scaling, ) props = parse_properties(reason, output_differs, props_to_record) -- GitLab From 0ec7e6d7b26753965e09346eb1c41f50ee20499d Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Mon, 3 Mar 2025 10:27:32 +0100 Subject: [PATCH 2/2] Change to use scalefac in cmp_pcm which is multiplied directly with the signals to be compared --- tests/cmp_pcm.py | 12 ++++++------ tests/codec_be_on_mr_nonselection/test_param_file.py | 2 +- tests/codec_be_on_mr_nonselection/test_sba.py | 2 +- tests/conftest.py | 4 ++-- tests/renderer/utils.py | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/tests/cmp_pcm.py b/tests/cmp_pcm.py index 10b3a41d30..127820525a 100755 --- a/tests/cmp_pcm.py +++ b/tests/cmp_pcm.py @@ -41,7 +41,7 @@ def cmp_pcm( ref_jbm_tf: Optional[Path] = None, cut_jbm_tf: Optional[Path] = None, quiet: Optional[bool] = False, - input_scaling=1, + scalefac=1, ) -> tuple[int, str]: """ Compare 2 PCM files for bitexactness @@ -90,10 +90,10 @@ def cmp_pcm( return 1, reason - # If input_scaling is applied, revert the scaling - if input_scaling != 1: - s1 = np.round(s1/input_scaling, 0) # Need rounding for max abs diff search - s2 = np.round(s2/input_scaling, 0) + # Apply scalefac if specified. Useful in case scaling has been applied on the input, and the inverse is scaling is supplied in scalefac. + if scalefac != 1: + s1 = np.round(s1*scalefac, 0) # Need rounding for max abs diff search + s2 = np.round(s2*scalefac, 0) cmp_result = pyaudio3dtools.audioarray.compare( s1, @@ -262,7 +262,7 @@ if __name__ == "__main__": parser.add_argument("--get_odg", action="store_true") parser.add_argument("--get_ssnr", action="store_true") parser.add_argument("--allow_differing_lengths", action="store_true") - parser.add_argument("--input_scaling", type=float, default=1, dest="input_scaling", help="If input scaling is applied, apply the INVERSE scaling before comparison") + parser.add_argument("--scalefac", type=float, default=1, dest="scalefac", help="Scale factor to be applied before comparing the output. Useful when input scaling has been applied.") parser.add_argument("--quiet", action="store_true") args = vars(parser.parse_args()) 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 e860baa2d2..d55d62aec4 100644 --- a/tests/codec_be_on_mr_nonselection/test_param_file.py +++ b/tests/codec_be_on_mr_nonselection/test_param_file.py @@ -605,7 +605,7 @@ def run_test( odg_ref=odg_ref, ref_jbm_tf=ref_tracefile_dec, cut_jbm_tf=dut_tracefile_dec, - input_scaling=test_info.config.option.input_scaling, + scalefac=test_info.config.option.scalefac, ) cmp_result_msg += reason diff --git a/tests/codec_be_on_mr_nonselection/test_sba.py b/tests/codec_be_on_mr_nonselection/test_sba.py index b89d5820cf..e6283f16b3 100644 --- a/tests/codec_be_on_mr_nonselection/test_sba.py +++ b/tests/codec_be_on_mr_nonselection/test_sba.py @@ -1266,7 +1266,7 @@ def sba_dec( odg_input=odg_input, odg_test=odg_test, odg_ref=odg_ref, - input_scaling=test_info.config.option.input_scaling, + scalefac=test_info.config.option.scalefac, ) text_to_parse = reason diff --git a/tests/conftest.py b/tests/conftest.py index c66fdc2a46..92f62cea45 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -299,9 +299,9 @@ def pytest_addoption(parser): ) parser.addoption( - "--input_scaling", + "--scalefac", action="store", - help="If input scaling is applied, apply the INVERSE scaling before comparison.", + help="Scale factor to be applied before comparing the output. Useful when input scaling has been applied.", type=float, default=1, ) diff --git a/tests/renderer/utils.py b/tests/renderer/utils.py index 908c3a7190..2fe99734ca 100644 --- a/tests/renderer/utils.py +++ b/tests/renderer/utils.py @@ -387,7 +387,7 @@ def run_renderer( odg_input=odg_input, odg_test=odg_test, odg_ref=odg_ref, - input_scaling=test_info.config.option.input_scaling, + scalefac=test_info.config.option.scalefac, ) props = parse_properties(reason, output_differs, props_to_record) -- GitLab