Commit e601077c authored by Jan Kiene's avatar Jan Kiene
Browse files

add sanity check test for ext being be to transport format

parent 3d8494da
Loading
Loading
Loading
Loading
+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.")
+85 −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",
]
        
INPUT_FILES = [
        "stvST48c.wav",
        "stv51MC48c.wav",
        "stv512MC48c.wav",
        "stv514MC48c.wav",
        "stv71MC48c.wav",
        "stv714MC48c.wav",
        "stvFOA48c.wav",
        "stv2OA48c.wav",
        "stv3OA48c.wav",
        ]

# TODO: add higher BRs
BITRATES = [13200, 16400, 24400, 32000, 48000, 64000, 80000, 96000, 128000, 160000, 192000, 256000]


def get_options(inp_format):
    options = list()
    if inp_format == "stereo":
        options.append("-stereo")
    elif "_" in inp_format:
        # this indicates MC mode
        options.extend(["-mc", inp_format])
    else:
        try:
            ambi_order = int(inp_format[-1])
        except ValueError:
            ambi_order = 1
        options.extend(["-sba", str(ambi_order)])

    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,
        ):
    
        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!")