Commit 06809cf5 authored by Jan Kiene's avatar Jan Kiene
Browse files

first version with single experiment OPs and limited parameters

parent e5742479
Loading
Loading
Loading
Loading
+3 −4
Original line number Diff line number Diff line
@@ -42,10 +42,9 @@ scripts/out/
scripts/self_test_summary.txt
scripts/cppp/
binary/
tests/renderer/cut
tests/renderer/ref
tests/dut
tests/ref
tests/**/[c|d]ut
tests/**/ref
tests/*/testv
scripts/testv/*_cut*.pcm
# default reference binary name
IVAS_cod_ref
+41 −0
Original line number Diff line number Diff line
import tempfile
import filecmp
from pathlib import Path
import subprocess
from .constants import TESTV_PATH, REF_PATH, DUT_PATH


def get_testvector_for_exp_cat_and_testset(experiment, category, testset):
    fname = f"{experiment}-cat{category}-{testset}-input.wav"
    return TESTV_PATH.joinpath(fname).absolute()


def get_out_bitstream_and_synthesis_name(input_signal, bitrate, dtx, fer):
    dtx_str = "DTXon" if dtx else "DTXoff"
    fer_str = "FER_5perc" if fer else "FER_0perc"
    suffix = [".192", ".wav"]
    return [DUT_PATH.joinpath(f"{input_signal.name}-{bitrate}bps-{dtx_str}-{fer_str}{s}") for s in suffix]


def get_error_pattern_for_exp_cat_and_testset(experiment, category, testset):
    ep_file = TESTV_PATH.joinpath(f"{experiment}-cat{category}-{testset}-ep.192")
    return ep_file


def apply_error_pattern_on_bitstream(in_bitstream: Path, error_pattern: Path, out_bitstream: Path):
    # temporary file only really needed if same name is given for in and out bs
    with tempfile.TemporaryDirectory() as tmpdir:
        if in_bitstream == out_bitstream:
            in_bitstream = Path(tmpdir).joinpath(in_bitstream.name)
        
        cmd = ["eid-xor", "-vbr", "-fer", in_bitstream, error_pattern, out_bitstream]

        subprocess.run(cmd)


def is_be_to_reference(dut_file: Path):
    assert dut_file.parent == DUT_PATH

    # TODO: handle .wav files differently
    ref_file = REF_PATH.joinpath(dut_file.name)
    return filecmp.cmp(ref_file, dut_file)
 No newline at end of file
+8 −0
Original line number Diff line number Diff line
from pathlib import Path

HERE = Path(__file__).parent
TESTV_PATH = HERE.joinpath("testv")
REF_PATH = HERE.joinpath("ref")
DUT_PATH = HERE.joinpath("dut")

SAMPLING_RATE = 48
 No newline at end of file
+37 −0
Original line number Diff line number Diff line
import pytest
from . import get_testvector_for_exp_cat_and_testset, get_out_bitstream_and_synthesis_name, apply_error_pattern_on_bitstream, get_error_pattern_for_exp_cat_and_testset, is_be_to_reference

P800_1_BITRATES = [13200, 16400, 24400, 32000, 48000, 13200, 16400, 24400, 32000, 48000, 24400, 13200]
P800_1_DTX = 10 * [False] +  2 * [True]
P800_1_FER = 5 * [False] + 5 * [True] + [False, True]
# TODO: use correct range
P800_1_CATEGORIES = range(1, 3)
P800_1_TESTSETS = ["a", "d"]
P800_1_PARAMS = list(zip(P800_1_BITRATES, P800_1_DTX, P800_1_FER))


@pytest.mark.create_ref
@pytest.mark.parametrize("bitrate,dtx,fer", P800_1_PARAMS)
@pytest.mark.parametrize("category", P800_1_CATEGORIES)
@pytest.mark.parametrize("testset", P800_1_TESTSETS)
def test_p800_1(bitrate, dtx, fer, category, testset, dut_encoder_frontend, dut_decoder_frontend, update_ref):
    sampling_rate = 48
    output_mode = "STEREO"
    options = ["-stereo"]

    testv = get_testvector_for_exp_cat_and_testset("P800-1", category, testset)
    dut_bitstream, dut_output = get_out_bitstream_and_synthesis_name(testv, bitrate, dtx, fer)
    dut_encoder_frontend.run(bitrate, sampling_rate, testv, dut_bitstream, dtx_mode=dtx, add_option_list=options)

    if update_ref != 1 and not is_be_to_reference(dut_bitstream):
        pytest.fail("Bitstream file differs from reference")

    if fer:
        error_pattern = get_error_pattern_for_exp_cat_and_testset("P800-1", category, testset)
        apply_error_pattern_on_bitstream(dut_bitstream, error_pattern, dut_bitstream)

    dut_decoder_frontend.run(output_mode, sampling_rate, dut_bitstream, dut_output)

    # TODO: also compare metadata if present
    if update_ref != 1 and not is_be_to_reference(dut_output):
        pytest.fail("Decoder output differs from reference")
 No newline at end of file