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

port over plc test to have all sba tests in one file

parent 006d9429
Loading
Loading
Loading
Loading
+105 −2
Original line number Diff line number Diff line
@@ -42,6 +42,7 @@ from cut_bs import cut_from_start
from tests.cmp_pcm import cmp_pcm
from tests.conftest import DecoderFrontend, EncoderFrontend
from ..conftest import parse_properties
from ..constants import TESTV_DIR

# params

@@ -76,6 +77,11 @@ sample_rate_bw_idx_list = [("48", "SWB"), ("48", "WB"), ("32", "WB")]

AbsTol = "0"

# params for PLC test
tag_list_plc = tag_list
plc_patterns = ["PLperc12mblen5", "PLperc40mblen50", "PLperc42mblen2"]
ivas_br_plc = ["13200", "16400", "32000", "64000", "96000", "256000"]


def check_and_makedir(dir_path):
    if not os.path.exists(dir_path):
@@ -535,6 +541,86 @@ def test_sba_enc_BWforce_system(
        get_odg=get_odg,
    )

# assumption:
# - the needed reference bitstreams are created by test_sba_enc_system
# -> reference bitstreams are not any longer created as part of this test
# -> the parameters of this test (except additional parameter plc_pattern) need to be a subset of the parameters in test_sba_enc_system
# -> the reference generation for this test (reference decoder output) needs to be done after completion of test_sba_enc_system
#    -> therefore the marker create_ref_part2
@pytest.mark.create_ref_part2
@pytest.mark.parametrize("ivas_br", ivas_br_plc)
@pytest.mark.parametrize("dtx", dtx_set)
@pytest.mark.parametrize("tag", tag_list)
@pytest.mark.parametrize("plc_pattern", plc_patterns)
@pytest.mark.parametrize("fs", sample_rate_list)
@pytest.mark.parametrize("gain_flag", gain_list)
def test_sba_plc_system(
    record_property,
    props_to_record,
    dut_decoder_frontend: DecoderFrontend,
    ref_decoder_frontend,
    reference_path,
    dut_base_path,
    ref_decoder_path,
    update_ref,
    keep_files,
    ivas_br,
    dtx,
    tag,
    plc_pattern,
    fs,
    gain_flag,
    get_mld,
    get_mld_lim,
    abs_tol,
    get_ssnr,
    get_odg
):
    SID = 0
    if dtx == "1" and ivas_br not in ["13200", "16400", "24400", "32000", "64000"]:
        # skip high bitrates for DTX until DTX issue is resolved
        pytest.skip()
    if ivas_br == "13200" or ivas_br == "16400":
        if (
            dtx == "1"
            and gain_flag == 0
            and fs != "16"
            and plc_pattern == "PLperc12mblen5"
        ):
            SID = 1
        else:
            pytest.skip()
    if gain_flag == 1 and ivas_br not in ["13200", "16400", "24400", "32000"]:
        pytest.skip()
    tag = tag + fs + "c"

    # dec
    sba_dec(
        record_property,
        props_to_record,
        dut_decoder_frontend,
        ref_decoder_frontend,
        reference_path,
        dut_base_path,
        tag,
        fs,
        ivas_br,
        dtx,
        SID,
        "FB",
        "FOA",
        update_ref,
        gain_flag,
        keep_files,
        False,
        plc_pattern=plc_pattern,
        get_mld=get_mld,
        get_mld_lim=get_mld_lim,
        abs_tol=abs_tol,
        get_ssnr=get_ssnr,
        get_odg=get_odg,
    )


#########################################################
# -------------------- test function --------------------
@@ -691,6 +777,7 @@ def sba_dec(
    gain_flag,
    keep_files,
    decoder_only,
    plc_pattern=None,
    get_mld=False,
    get_mld_lim=0,
    pca=False,
@@ -724,6 +811,18 @@ def sba_dec(

    dut_in_pkt = f"{dut_base_path}/sba_bs/pkt/{tag_out}{long_tag_ext}.192"
    ref_in_pkt = f"{reference_path}/sba_bs/pkt/{tag_out}{short_tag_ext}.192"
    ref_in_pkt_dutenc = f"{reference_path}/sba_bs/pkt/{tag_out}{short_tag_ext}_dutenc.192"
    if SID == 1:
        if gain_flag != -1:
            ref_in_pkt_dutenc = f"{reference_path}/sba_bs/pkt/{tag_out}{f"_Gain{gain_flag}"}_SID_dutenc_cut.192"
        else:
            ref_in_pkt_dutenc = f"{reference_path}/sba_bs/pkt/{tag_out}_SID_dutenc_cut.192"

    plc_file = None
    if plc_pattern is not None:
        plc_file = f"{TESTV_DIR}/{plc_pattern}.g192"
        long_tag_ext = f"{long_tag_ext}_{plc_pattern}"
        short_tag_ext = f"{short_tag_ext}_{plc_pattern}"

    dut_out_raw = f"{dut_out_dir}/{tag_out}{long_tag_ext}.wav"
    ref_out_raw = f"{ref_out_dir}/{tag_out}{short_tag_ext}.wav"
@@ -738,10 +837,13 @@ def sba_dec(
            sampling_rate,
            ref_in_pkt,
            ref_out_raw,
            plc_file=plc_file,
        )

    if update_ref == 0:
        if decoder_only:
        if plc_file is not None:
            dut_in_pkt = ref_in_pkt_dutenc
        elif decoder_only:
            dut_in_pkt = ref_in_pkt

        # call DUT decoder
@@ -750,6 +852,7 @@ def sba_dec(
            sampling_rate,
            dut_in_pkt,
            dut_out_raw,
            plc_file=plc_file,
        )

        fs = int(sampling_rate) * 1000
@@ -776,5 +879,5 @@ def sba_dec(
        # remove DUT output files when test result is OK (to save disk space)
        if not keep_files:
            os.remove(dut_out_raw)
            if not decoder_only:
            if not decoder_only and plc_file is None:
                os.remove(dut_in_pkt)