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

no DTX for now

parent 83fd2cd8
Loading
Loading
Loading
Loading
+32 −29
Original line number Diff line number Diff line
@@ -6,57 +6,60 @@ from tempfile import TemporaryDirectory

from .constants import TESTV_DIR, SCRIPTS_DIR

sys.path.append(SCRIPTS_DIR)
sys.path.append(str(SCRIPTS_DIR))
from pyaudio3dtools import audiofile, audioarray


DTX_ON = "DTX_ON"
DTX_OFF = "DTX_OFF"


TESTCASES = [
    ["stereo", 32000, "EXT"],
    ["stereo", 48000, "7_1_4"],
    ["ISM4", 48000, "BINAURAL"],
    ["ISM3", 64000, "BINAURAL"],
    ["MASA1TC", 24400, "BINAURAL"],
    ["MASA2TC", 80000, "BINAURAL"],
    ["MC_5_1", 128000, "BINAURAL"],
    ["MC_5_1_4", 48000, "BINAURAL"],
    ["MC_7_1", 96000, "BINAURAL"],
    ["MC_7_1_4", 160000, "7_1_4"],
    ["HOA3", 64000, "BINAURAL"],
    ["FOA", 256000, "BINAURAL"],
    ["OMASA_ISM1", 512000, "BINAURAL"],
    ["OMASA_ISM2", 24400, "MONO"],
    ["OMASA_ISM3", 80000, "7_1_4"],
    ["OMASA_ISM4", 64000, "HOA3"],
    ["OSBA_ISM2_HOA2", 64000, "BINAURAL"],
    ["OSBA_ISM4_HOA2", 512000, "BINAURAL"],
    ["stereo", 32000, "EXT", "DTX_OFF"],
    ["stereo", 48000, "7_1_4", "DTX_OFF"],
    ["ISM4", 48000, "BINAURAL", "DTX_OFF"],
    ["ISM3", 64000, "BINAURAL", "DTX_OFF"],
    ["MASA1TC", 24400, "BINAURAL", "DTX_OFF"],
    ["MASA2TC", 80000, "BINAURAL", "DTX_OFF"],
    ["MC_5_1", 128000, "BINAURAL", "DTX_OFF"],
    ["MC_5_1_4", 48000, "BINAURAL", "DTX_OFF"],
    ["MC_7_1", 96000, "BINAURAL", "DTX_OFF"],
    ["MC_7_1_4", 160000, "7_1_4", "DTX_OFF"],
    ["HOA3", 64000, "BINAURAL", "DTX_OFF"],
    ["FOA", 256000, "BINAURAL", "DTX_OFF"],
    ["OMASA_ISM1", 512000, "BINAURAL", "DTX_OFF"],
    ["OMASA_ISM2", 24400, "MONO", "DTX_OFF"],
    ["OMASA_ISM3", 80000, "7_1_4", "DTX_OFF"],
    ["OMASA_ISM4", 64000, "HOA3", "DTX_OFF"],
    ["OSBA_ISM2_HOA2", 64000, "BINAURAL", "DTX_OFF"],
    ["OSBA_ISM4_HOA2", 512000, "BINAURAL", "DTX_OFF"],
]
DLY_PROFILE = SCRIPTS_DIR.joinpath("dly_error_profiles/dly_error_profile_0.dat")
JBM_NEUTRAL_DELAY_MS = 60

def get_options(in_format, bitrate):

def get_options(in_format, bitrate, dtx):
    options = list()

    if dtx:
        options.append("-dtx")

    SBA_FORMATS = ["FOA", "HOA2", "HOA3"]
    if in_format == "stereo":
        options.append("-dtx")
        options.append("-stereo")
    elif (match := re.fullmatch(r"ISM(\d)", in_format)) is not None:
        n_ism = int(match.groups()[0])
        options.append("-dtx")
        options.extend(f"-ism {n_ism}".split())
        for i in range(1, n_ism + 1):
            options.append(str(TESTV_DIR.joinpath(f"stvISM{i}.csv")))
    elif (match := re.fullmatch(r"MASA(\d)TC", in_format)) is not None:
        n_tcs = int(match.groups()[0])
        options.append("-dtx")
        options.extend(f"-masa {n_tcs}".split())
        options.append(str(TESTV_DIR.joinpath(f"stv2MASA{n_tcs}TC48c.met")))
    elif (match := re.fullmatch(r"MC_(.*)", in_format)) is not None:
        mc_format = match.groups()[0]
        options.extend(f"-mc {mc_format}".split())
    elif in_format in SBA_FORMATS:
        if bitrate <= 80000:
            options.append("-dtx")
        options.extend(f"-sba {SBA_FORMATS.index(in_format) + 1}".split())
    elif (match := re.fullmatch(r"OMASA_ISM(\d)", in_format)) is not None:
        n_ism = int(match.groups()[0])
@@ -100,9 +103,9 @@ INPUT_FILES = {
}


@pytest.mark.parametrize("in_format,bitrate,out_format", TESTCASES)
@pytest.mark.parametrize("in_format,bitrate,out_format,dtx", TESTCASES)
def test_be_for_jbm_neutral_dly_profile(
    in_format, bitrate, out_format, dut_encoder_frontend, dut_decoder_frontend
    in_format, bitrate, out_format, dtx, dut_encoder_frontend, dut_decoder_frontend
):
    with TemporaryDirectory() as tmp_dir:
        tmp_dir = pathlib.Path(tmp_dir)
@@ -111,7 +114,7 @@ def test_be_for_jbm_neutral_dly_profile(
        bitstream_file = tmp_dir.joinpath(f"{in_format}.192").absolute()
        sampling_rate_khz = 48
        input_file = TESTV_DIR.joinpath(INPUT_FILES[in_format])
        options = get_options(in_format, bitrate)
        options = get_options(in_format, bitrate, dtx == DTX_ON)
        dut_encoder_frontend.run(
            bitrate,
            sampling_rate_khz,