diff --git a/tests/cmp_pcm.py b/tests/cmp_pcm.py index cb779ff51765cbdfa91e4eb75005b99513dac29c..127820525a6895c8dcb46daf236137710297466d 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, + scalefac=1, ) -> tuple[int, str]: """ Compare 2 PCM files for bitexactness @@ -89,6 +90,11 @@ def cmp_pcm( return 1, reason + # 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, 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("--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 31d29b115191a01604c080d75f351a464aac7ac9..ac2d84d1e7af645500434e259bb2337f341c7f85 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, + 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 fa49ce7a9d8dcb587876ef7cde30fd37f12bd084..ce6d073942435741f6ab4ab7337e4a0df24c5265 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, + scalefac=test_info.config.option.scalefac, ) text_to_parse = reason diff --git a/tests/conftest.py b/tests/conftest.py index dd907002941d4c6f382722d9b93ed4262517218f..3b75cbc5570f91cd98259ef7a31fe7464e9b8d8c 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -298,6 +298,13 @@ def pytest_addoption(parser): default=False, ) + parser.addoption( + "--scalefac", + action="store", + help="Scale factor to be applied before comparing the output. Useful when input scaling has been applied.", + 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 6f78f1db72e2820878bf402b367f81f2e45998ec..2be90224a61b8c8dc61cf5a8696015bfb2218228 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, + scalefac=test_info.config.option.scalefac, ) props = parse_properties(reason, output_differs, props_to_record)