Commit 29e1d626 authored by Jan Kiene's avatar Jan Kiene
Browse files

Merge branch 'ci/add-sanity-check-for-ext-output' into 'main'

[CI] add sanity check for ext output

See merge request !1576
parents 9f58d491 848ef56b
Loading
Loading
Loading
Loading
Loading
+22 −0
Original line number Diff line number Diff line
@@ -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
+5 −3
Original line number Diff line number Diff line
@@ -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.")
+1 −0
Original line number Diff line number Diff line
@@ -50,6 +50,7 @@ from pyaudio3dtools import audiofile
CUT_FROM = "0.0"
GAIN = "1.0"
FILE_IDS = [
    "stvST",
    "stv51MC",
    "stv71MC",
    "stv512MC",
+115 −0
Original line number Diff line number Diff line
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!")