diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 541aee3207a8605daae827aef53984471ce4d8d7..b0efa75256f97734e8d4eaff07c0d1e02a7aeab1 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1188,6 +1188,28 @@ check-bitexactness-hrtf-rom-and-file: expose_as: "logs-hrtf-loading" expire_in: "5 days" +check-bitexactness-ext-and-transport-format: + extends: + - .test-job-linux + - .rules-merge-request + stage: test + needs: ["build-codec-linux-cmake"] + timeout: "5 minutes" + script: + - *print-common-info + - cmake . + - make -j + - python3 tests/create_short_testvectors.py --cut_len 1.0 + - python3 -m pytest tests/test_be_for_ext_outputs.py --html=report.html --junit-xml=report-junit.xml --self-contained-html + artifacts: + paths: + - report.html + - report-junit.xml + when: always + name: "$CI_JOB_NAME--$CI_MERGE_REQUEST_ID--sha-$CI_COMMIT_SHA--ext-sanity-check" + expose_as: "logs-ext-sanity-check" + expire_in: "5 days" + # --------------------------------------------------------------- # Test jobs for main branch diff --git a/tests/conftest.py b/tests/conftest.py index c975e409c01ed4a2401e146d6946cdaba37bb7ba..6d9398524300be18eb97379aa5e936d783af28ac 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -312,6 +312,7 @@ class EncoderFrontend: pca: Optional[bool] = None, quiet_mode: Optional[bool] = True, add_option_list: Optional[list] = None, + run_dir: Optional[Path] = None, ) -> None: command = [self._path] @@ -347,7 +348,7 @@ class EncoderFrontend: try: result = run( - command, capture_output=True, check=False, timeout=self.timeout + command, capture_output=True, check=False, timeout=self.timeout, cwd=run_dir ) except TimeoutExpired: pytest.fail(f"{self._type} encoder run timed out after {self.timeout}s.") @@ -486,6 +487,7 @@ class DecoderFrontend: quiet_mode: Optional[bool] = True, plc_file: Optional[Path] = None, add_option_list: Optional[list] = None, + run_dir: Optional[Path] = None, ) -> None: command = [self._path] @@ -521,7 +523,7 @@ class DecoderFrontend: try: if not os.path.exists(str(input_bitstream_path) + eid_output_suffix): - result = run(eid_command, check=True) + result = run(eid_command, check=True, cwd=run_dir) except Exception: pytest.fail("eid-xor operation failed!") @@ -545,7 +547,7 @@ class DecoderFrontend: try: result = run( - command, capture_output=True, check=False, timeout=self.timeout + command, capture_output=True, check=False, timeout=self.timeout, cwd=run_dir ) except TimeoutExpired: pytest.fail(f"{self._type} decoder run timed out after {self.timeout}s.") diff --git a/tests/create_short_testvectors.py b/tests/create_short_testvectors.py index 87d05e001e189a4a93eeb1f02f27ff03d9ee1ab9..b90771cca18eac9f2ee65c5f7d548f896a41c39e 100755 --- a/tests/create_short_testvectors.py +++ b/tests/create_short_testvectors.py @@ -50,6 +50,7 @@ from pyaudio3dtools import audiofile CUT_FROM = "0.0" GAIN = "1.0" FILE_IDS = [ + "stvST", "stv51MC", "stv71MC", "stv512MC", diff --git a/tests/test_be_for_ext_outputs.py b/tests/test_be_for_ext_outputs.py new file mode 100644 index 0000000000000000000000000000000000000000..9be0966acdc62a65db922da105369caf61440341 --- /dev/null +++ b/tests/test_be_for_ext_outputs.py @@ -0,0 +1,115 @@ +import pytest +import pathlib +from filecmp import cmp +from tempfile import TemporaryDirectory +from .conftest import EncoderFrontend, DecoderFrontend + +HERE = pathlib.Path(__file__).parent.absolute() +TESTV_DIR = HERE.parent.joinpath("scripts/testv") + + +INPUT_FORMATS = [ + "stereo", + "5_1", + "5_1_2", + "5_1_4", + "7_1", + "7_1_4", + "FOA", + "HOA2", + "HOA3", +] +MC_FORMATS = INPUT_FORMATS[1:6] +SBA_FORMATS = INPUT_FORMATS[6:] + +INPUT_FILES = [ + "stvST48c_cut.wav", + "stv51MC48c_cut.wav", + "stv512MC48c_cut.wav", + "stv514MC48c_cut.wav", + "stv71MC48c_cut.wav", + "stv714MC48c_cut.wav", + "stvFOA48c_cut.wav", + "stv2OA48c_cut.wav", + "stv3OA48c_cut.wav", +] + +BITRATES = [ + 13200, + 16400, + 24400, + 32000, + 48000, + 64000, + 80000, + 96000, + 128000, + 160000, + 192000, + 256000, + 384000, + 512000, +] + + +def get_options(inp_format): + options = list() + if inp_format == "stereo": + options.append("-stereo") + elif inp_format in MC_FORMATS: + # this indicates MC mode + options.extend(["-mc", inp_format]) + elif inp_format in SBA_FORMATS: + try: + ambi_order = int(inp_format[-1]) + except ValueError: + ambi_order = 1 + options.extend(["-sba", str(ambi_order)]) + else: + assert f"Can't handle input format {inp_format}" + + return options + + +@pytest.mark.parametrize("inp_format,inp_file", zip(INPUT_FORMATS, INPUT_FILES)) +@pytest.mark.parametrize("bitrate", BITRATES) +def test_be_for_ext_output( + inp_format, + inp_file, + bitrate, + dut_encoder_frontend: EncoderFrontend, + dut_decoder_frontend: DecoderFrontend, +): + if inp_format == "stereo" and bitrate > 256000: + pytest.skip("Invalid bitrate for Stereo") + + with TemporaryDirectory() as tmp_dir: + tmp_dir = pathlib.Path(tmp_dir) + + # run encoder + bitstream_file = tmp_dir.joinpath(f"{inp_format}.192").absolute() + sampling_rate = 48 + input_file = TESTV_DIR.joinpath(inp_file) + options = get_options(inp_format) + dut_encoder_frontend.run( + bitrate, + sampling_rate, + input_file, + bitstream_file, + add_option_list=options, + run_dir=tmp_dir, + ) + + # run decoder with "native" output format + output_native = tmp_dir.joinpath(f"{inp_format}-to-{inp_format}.wav").absolute() + dut_decoder_frontend.run( + inp_format, sampling_rate, bitstream_file, output_native + ) + + # run decoder with "EXT" output + output_ext = tmp_dir.joinpath(f"{inp_format}-to-EXT.wav").absolute() + dut_decoder_frontend.run("EXT", sampling_rate, bitstream_file, output_ext) + + # check for BE + if not cmp(output_native, output_ext): + pytest.fail(f"{inp_format} -> {inp_format} and {inp_format} -> EXT not BE!")