Loading tests/cmp_pcm.py +18 −8 Original line number Diff line number Diff line Loading @@ -12,7 +12,16 @@ import pyaudio3dtools import pyivastest def cmp_pcm(file1, file2, out_config, fs, get_mld=False, mld_lim=0, abs_tol=0) -> (int, str): def cmp_pcm( file1, file2, out_config, fs, get_mld=False, allow_differing_lengths=False, mld_lim=0, abs_tol=0, ) -> (int, str): """ Compare 2 PCM files for bitexactness """ Loading @@ -22,24 +31,26 @@ def cmp_pcm(file1, file2, out_config, fs, get_mld=False, mld_lim=0, abs_tol=0) - out_config = "MONO" if out_config == "" else out_config # out_config may be a string or a Path. Wrap in str() to avoid error in case it is a Path. if str(out_config).upper() not in pyivastest.constants.OC_TO_NCHANNELS: out_config_in_file_names = os.path.splitext(os.path.basename(out_config))[0] nchannels = ( pyivastest.IvasScriptsCommon.IvasScript.get_n_channels_from_ls_layout( out_config ) ) else: out_config_in_file_names = out_config nchannels = pyivastest.constants.OC_TO_NCHANNELS[out_config.upper()] s1, _ = pyaudio3dtools.audiofile.readfile(file1, nchannels, fs, outdtype=np.int16) s2, _ = pyaudio3dtools.audiofile.readfile(file2, nchannels, fs, outdtype=np.int16) nchannels = s1.shape[ 1 ] # In case of wav input, override the nchannels with the one from the wav header # In case of wav input, override the nchannels with the one from the wav header nchannels = s1.shape[1] if s1.shape != s2.shape: if allow_differing_lengths: # to allow for MLD comparison, shorten longer file min_len = min(s1.shape[0], s2.shape[0]) s1 = s1[:min_len, :] s2 = s2[:min_len, :] elif s1.shape != s2.shape: print( f"file size in samples: file 1 = {s1.shape[0]},", f"file 2 = {s2.shape[0]}", Loading @@ -54,7 +65,6 @@ def cmp_pcm(file1, file2, out_config, fs, get_mld=False, mld_lim=0, abs_tol=0) - s1, s2, fs, per_frame=False, get_mld=get_mld ) output_differs = 0 reason = "SUCCESS: Files are bitexact" Loading tests/codec_be_on_mr_nonselection/test_param_file.py +7 −0 Original line number Diff line number Diff line Loading @@ -324,6 +324,7 @@ def test_param_file_tests( # set to false per default even if this is no JBM case - makes later check for failure easier tracefile_lengths_differ = False if len(tracefile_dec) > 0: dut_tracefile_dec = f"{dut_base_path}/param_file/dec/{tracefile_dec}" ref_tracefile_dec = f"{reference_path}/param_file/dec/{tracefile_dec}" Loading @@ -334,6 +335,11 @@ def test_param_file_tests( dut_tracefile_len.shape[0] != ref_tracefile_len.shape[0] ) # same tf lengths -> likely no crash, assume length difference is due to difference in TSM # to get MLD and abs diff values for now - even though they might be meaningless due to # shift differences between the two signals - cut longer signal to shorter size allow_differing_lengths = not tracefile_lengths_differ fs = int(sampling_rate) * 1000 output_differs, reason = cmp_pcm( dut_output_file, Loading @@ -343,6 +349,7 @@ def test_param_file_tests( get_mld=get_mld, mld_lim=get_mld_lim, abs_tol=abs_tol, allow_differing_lengths=allow_differing_lengths, ) md_out_files = get_expected_md_files(ref_output_file, enc_split, output_config) Loading Loading
tests/cmp_pcm.py +18 −8 Original line number Diff line number Diff line Loading @@ -12,7 +12,16 @@ import pyaudio3dtools import pyivastest def cmp_pcm(file1, file2, out_config, fs, get_mld=False, mld_lim=0, abs_tol=0) -> (int, str): def cmp_pcm( file1, file2, out_config, fs, get_mld=False, allow_differing_lengths=False, mld_lim=0, abs_tol=0, ) -> (int, str): """ Compare 2 PCM files for bitexactness """ Loading @@ -22,24 +31,26 @@ def cmp_pcm(file1, file2, out_config, fs, get_mld=False, mld_lim=0, abs_tol=0) - out_config = "MONO" if out_config == "" else out_config # out_config may be a string or a Path. Wrap in str() to avoid error in case it is a Path. if str(out_config).upper() not in pyivastest.constants.OC_TO_NCHANNELS: out_config_in_file_names = os.path.splitext(os.path.basename(out_config))[0] nchannels = ( pyivastest.IvasScriptsCommon.IvasScript.get_n_channels_from_ls_layout( out_config ) ) else: out_config_in_file_names = out_config nchannels = pyivastest.constants.OC_TO_NCHANNELS[out_config.upper()] s1, _ = pyaudio3dtools.audiofile.readfile(file1, nchannels, fs, outdtype=np.int16) s2, _ = pyaudio3dtools.audiofile.readfile(file2, nchannels, fs, outdtype=np.int16) nchannels = s1.shape[ 1 ] # In case of wav input, override the nchannels with the one from the wav header # In case of wav input, override the nchannels with the one from the wav header nchannels = s1.shape[1] if s1.shape != s2.shape: if allow_differing_lengths: # to allow for MLD comparison, shorten longer file min_len = min(s1.shape[0], s2.shape[0]) s1 = s1[:min_len, :] s2 = s2[:min_len, :] elif s1.shape != s2.shape: print( f"file size in samples: file 1 = {s1.shape[0]},", f"file 2 = {s2.shape[0]}", Loading @@ -54,7 +65,6 @@ def cmp_pcm(file1, file2, out_config, fs, get_mld=False, mld_lim=0, abs_tol=0) - s1, s2, fs, per_frame=False, get_mld=get_mld ) output_differs = 0 reason = "SUCCESS: Files are bitexact" Loading
tests/codec_be_on_mr_nonselection/test_param_file.py +7 −0 Original line number Diff line number Diff line Loading @@ -324,6 +324,7 @@ def test_param_file_tests( # set to false per default even if this is no JBM case - makes later check for failure easier tracefile_lengths_differ = False if len(tracefile_dec) > 0: dut_tracefile_dec = f"{dut_base_path}/param_file/dec/{tracefile_dec}" ref_tracefile_dec = f"{reference_path}/param_file/dec/{tracefile_dec}" Loading @@ -334,6 +335,11 @@ def test_param_file_tests( dut_tracefile_len.shape[0] != ref_tracefile_len.shape[0] ) # same tf lengths -> likely no crash, assume length difference is due to difference in TSM # to get MLD and abs diff values for now - even though they might be meaningless due to # shift differences between the two signals - cut longer signal to shorter size allow_differing_lengths = not tracefile_lengths_differ fs = int(sampling_rate) * 1000 output_differs, reason = cmp_pcm( dut_output_file, Loading @@ -343,6 +349,7 @@ def test_param_file_tests( get_mld=get_mld, mld_lim=get_mld_lim, abs_tol=abs_tol, allow_differing_lengths=allow_differing_lengths, ) md_out_files = get_expected_md_files(ref_output_file, enc_split, output_config) Loading