Loading tests/cmp_pcm.py 0 → 100644 +34 −0 Original line number Diff line number Diff line import os import sys THIS_PATH = os.path.join(os.getcwd(), __file__) sys.path.append(os.path.join(os.path.dirname(THIS_PATH), "../scripts")) import pyaudio3dtools def cmp_pcm(file1, file2, nchannels, fs) -> (int, str): """ Compare 2 PCM files for bitexactness """ print("Cmp PCM Report") print("=====================") s1, _ = pyaudio3dtools.audiofile.readfile(file1, nchannels, fs) s2, _ = pyaudio3dtools.audiofile.readfile(file2, nchannels, fs) if s1.shape != s2.shape: print( f"file size in samples: file 1 = {s1.shape[0]},", f"file 2 = {s2.shape[0]}", ) return 1, "FAIL: File lengths differ" cmp_result = pyaudio3dtools.audioarray.compare(s1, s2, fs) if cmp_result["bitexact"]: return 0, "SUCCESS: Files are bitexact" else: diff_msg = f"MAXIMUM ABS DIFF ==> {cmp_result['max_abs_diff']} at sample num {cmp_result['max_abs_diff_pos_sample']}" print(diff_msg) return 1, "FAIL: Files have different content" tests/test_sba_bs_enc.py +4 −12 Original line number Diff line number Diff line Loading @@ -39,9 +39,10 @@ import os import errno import pytest from cmp_custom import cmp_custom from cmp_pcm import cmp_pcm from cut_pcm import cut_samples from conftest import EncoderFrontend, DecoderFrontend from testconfig import OC_TO_NCHANNELS # params tag_list = ['stvFOA'] Loading Loading @@ -593,17 +594,8 @@ def sba_dec( dut_out_raw, ) # -------------- compare cmd -------------- end_skip_samples = '0' cmp_result, reason = cmp_custom( dut_out_raw, ref_out_raw, "2", AbsTol, end_skip_samples ) fs = int(sampling_rate) * 1000 cmp_result, reason = cmp_pcm(dut_out_raw, ref_out_raw, OC_TO_NCHANNELS[output_config], fs) # report compare result assert cmp_result == 0, reason Loading tests/testconfig.py +21 −0 Original line number Diff line number Diff line Loading @@ -35,3 +35,24 @@ To configure test modules. """ PARAM_FILE = "scripts/config/self_test.prm" OC_TO_NCHANNELS = { "MONO": 1, "STEREO": 2, "BINAURAL": 2, "BINAURAL_ROOM": 2, "5_1": 6, "7_1": 8, "5_1_2": 8, "5_1_4": 10, "7_1_4": 12, "FOA": 4, "HOA2": 9, "HOA3": 16, "EXT": 1, "ISM1": 1, "ISM2": 2, "ISM3": 3, "ISM4": 4, "MASA1TC": 1, "MASA2TC": 2, } Loading
tests/cmp_pcm.py 0 → 100644 +34 −0 Original line number Diff line number Diff line import os import sys THIS_PATH = os.path.join(os.getcwd(), __file__) sys.path.append(os.path.join(os.path.dirname(THIS_PATH), "../scripts")) import pyaudio3dtools def cmp_pcm(file1, file2, nchannels, fs) -> (int, str): """ Compare 2 PCM files for bitexactness """ print("Cmp PCM Report") print("=====================") s1, _ = pyaudio3dtools.audiofile.readfile(file1, nchannels, fs) s2, _ = pyaudio3dtools.audiofile.readfile(file2, nchannels, fs) if s1.shape != s2.shape: print( f"file size in samples: file 1 = {s1.shape[0]},", f"file 2 = {s2.shape[0]}", ) return 1, "FAIL: File lengths differ" cmp_result = pyaudio3dtools.audioarray.compare(s1, s2, fs) if cmp_result["bitexact"]: return 0, "SUCCESS: Files are bitexact" else: diff_msg = f"MAXIMUM ABS DIFF ==> {cmp_result['max_abs_diff']} at sample num {cmp_result['max_abs_diff_pos_sample']}" print(diff_msg) return 1, "FAIL: Files have different content"
tests/test_sba_bs_enc.py +4 −12 Original line number Diff line number Diff line Loading @@ -39,9 +39,10 @@ import os import errno import pytest from cmp_custom import cmp_custom from cmp_pcm import cmp_pcm from cut_pcm import cut_samples from conftest import EncoderFrontend, DecoderFrontend from testconfig import OC_TO_NCHANNELS # params tag_list = ['stvFOA'] Loading Loading @@ -593,17 +594,8 @@ def sba_dec( dut_out_raw, ) # -------------- compare cmd -------------- end_skip_samples = '0' cmp_result, reason = cmp_custom( dut_out_raw, ref_out_raw, "2", AbsTol, end_skip_samples ) fs = int(sampling_rate) * 1000 cmp_result, reason = cmp_pcm(dut_out_raw, ref_out_raw, OC_TO_NCHANNELS[output_config], fs) # report compare result assert cmp_result == 0, reason Loading
tests/testconfig.py +21 −0 Original line number Diff line number Diff line Loading @@ -35,3 +35,24 @@ To configure test modules. """ PARAM_FILE = "scripts/config/self_test.prm" OC_TO_NCHANNELS = { "MONO": 1, "STEREO": 2, "BINAURAL": 2, "BINAURAL_ROOM": 2, "5_1": 6, "7_1": 8, "5_1_2": 8, "5_1_4": 10, "7_1_4": 12, "FOA": 4, "HOA2": 9, "HOA3": 16, "EXT": 1, "ISM1": 1, "ISM2": 2, "ISM3": 3, "ISM4": 4, "MASA1TC": 1, "MASA2TC": 2, }