Commit 9eaa3a96 authored by Vladimir Malenovsky's avatar Vladimir Malenovsky
Browse files

fix BWforce tests

parent 9dbe414c
Loading
Loading
Loading
Loading
Loading
+69 −61
Original line number Diff line number Diff line
@@ -660,21 +660,20 @@ def test_sba_enc_BWforce_system(
    gain_flag = -1
    sba_order = "+1"
    output_config = "FOA"
    dtx = "0"
    gain_flag = -1
    cut_gain = "1.0"
    plc_pattern = None
    cut_testv = False
    sampling_rate = sample_rate_bw_idx[0]
    max_bw = sample_rate_bw_idx[1]
    
    if dtx == "1" and bitrate not in ["32000", "64000"]:
        # skip high bitrates for DTX until DTX issue is resolved
        pytest.skip()
        
    if bitrate == "13200" or bitrate == "16400":
        pytest.skip()
    if bitrate == "sw_24k4_256k.bin":
    elif bitrate == "sw_24k4_256k.bin":
        pytest.skip()
    sampling_rate = sample_rate_bw_idx[0]
    max_bw = sample_rate_bw_idx[1]
        
    if "ltv" in tag:
        tag = f"ltv{sampling_rate}_FOA"
        cut_testv = False
@@ -817,18 +816,16 @@ def test_sba_plc_system(
    if dtx == "1" and bitrate not in ["13200", "16400", "24400", "32000", "64000"]:
        # skip high bitrates for DTX until DTX issue is resolved
        pytest.skip()
        
    if bitrate == "13200" or bitrate == "16400":
        if (
            dtx == "1"
            and gain_flag == 0
            and sampling_rate != "16"
            and plc_pattern == "PLperc12mblen5"
        ):
        if dtx == "1" and gain_flag == 0 and sampling_rate != "16" and plc_pattern == "PLperc12mblen5":
            sid = 1
        else:
            pytest.skip()
            
    if gain_flag == 1 and bitrate not in ["13200", "16400", "24400", "32000"]:
        pytest.skip()
        
    if "ltv" in tag:
        tag = f"ltv{sampling_rate}_FOA"
        cut_testv = False
@@ -930,49 +927,47 @@ def sba_enc(
    check_and_makedir(dut_out_dir)
    check_and_makedir(ref_out_dir)

    in_extension = ".wav"
    tag_out = tag
    
    tag_in = tag
    # sampling rate to BW mapping
    bw_idx = dict_fsample_bw[sampling_rate]
    if int(dict_bw_idx[max_bw]) < int(bw_idx):
        tag = tag + dict_bw_tag[max_bw]
        tag_out += dict_bw_tag[max_bw]

    tag_out = f"{tag}_ivasbr{bitrate[:-3]}k_DTX{dtx}"
    tag_out += f"_ivasbr{bitrate[:-3]}k_DTX{dtx}"
    if bitrate == "sw_24k4_256k.bin":
        bitrate = f"{br_switch_file_path}/sw_24k4_256k.bin"

    # to avoid conflicting names in case of parallel test execution, differentiate all cases
    tag_ext = ""
    if pca:
        tag_ext += "_pca"
        tag_out += "_pca"
    if gain_flag != -1:
        tag_ext += f"_Gain{gain_flag}"
        tag_out += f"_Gain{gain_flag}"
    if sid == 1:
        tag_ext += "_SID"
        tag_out += "_SID"
    if plc_pattern is not None:
        tag_ext += "_" + plc_pattern
    dut_pkt_file = f"{dut_out_dir}/{tag_out}{tag_ext}.192"
    ref_pkt_file = f"{ref_out_dir}/{tag_out}{tag_ext}.192"
        tag_out += "_" + plc_pattern
    dut_pkt_file = f"{dut_out_dir}/{tag_out}.192"
    ref_pkt_file = f"{ref_out_dir}/{tag_out}.192"
    if sid == 1:
        dut_pkt_file_cut = f"{dut_out_dir}/{tag_out}{tag_ext}_cut.192"
        ref_pkt_file_cut = f"{ref_out_dir}/{tag_out}{tag_ext}_cut.192"
    input_path = f"{test_vector_path}/{tag_in}{in_extension}"
        dut_pkt_file_cut = f"{dut_out_dir}/{tag_out}_cut.192"
        ref_pkt_file_cut = f"{ref_out_dir}/{tag_out}_cut.192"
    input_path = f"{test_vector_path}/{tag}.wav"
    dtx_mode = dtx == "1"

    if cut_testv:
        # use shortened and potentially gain adjusted input PCM file - create if not present
        # cut input PCM file: currently with mostly fixed (i.e. not test dependant) values
        if cut_gain == "1.0":
            cut_file = f"{test_vector_path}/{tag_in}_cut{in_extension}"
            cut_file = f"{test_vector_path}/{tag}_cut.wav"
        else:
            cut_file = f"{test_vector_path}/{tag_in}_cut_{cut_gain}{in_extension}"
            cut_file = f"{test_vector_path}/{tag}_cut_{cut_gain}.wav"

        input_path = cut_file

    if get_enc_stats:
        ref_stats_file = f"{ref_out_dir}/{tag_out}{tag_ext}.stats"
        dut_stats_file = f"{dut_out_dir}/{tag_out}{tag_ext}.stats"
        ref_stats_file = f"{ref_out_dir}/{tag_out}.stats"
        dut_stats_file = f"{dut_out_dir}/{tag_out}.stats"
    else:
        ref_stats_file = None
        dut_stats_file = None
@@ -1048,71 +1043,84 @@ def sba_dec(
    get_ssnr=False,
    get_odg=False,
):

    dut_out_dir = f"{dut_base_path}/sba_bs/raw"
    ref_out_dir = f"{reference_path}/sba_bs/raw"
    
    check_and_makedir(dut_out_dir)
    check_and_makedir(ref_out_dir)

    tag_in = tag
    tag_out = tag
    
    # sampling rate to BW mapping
    bw_idx = dict_fsample_bw[sampling_rate]
    if int(dict_bw_idx[max_bw]) < int(bw_idx):
        tag = tag + dict_bw_tag[max_bw]
        tag_out += dict_bw_tag[max_bw]
        
    tag_out = f"{tag}_ivasbr{bitrate[:-3]}k_DTX{dtx}"
    tag_out += f"_ivasbr{bitrate[:-3]}k_DTX{dtx}"
 
    # to avoid conflicting names in case of parallel test execution, differentiate all cases
    tag_ext = ""
    if pca:
        tag_ext += "_pca"
        tag_out += "_pca"
    if gain_flag != -1:
        tag_ext += f"_Gain{gain_flag}"
        tag_out += f"_Gain{gain_flag}"
    if sid == 1:
        tag_ext += "_SID"
        tag_out += "_SID"
    if plc_pattern is not None:
        tag_ext += "_" + plc_pattern
        tag_out += "_" + plc_pattern
    if sid == 1:
        tag_ext += "_cut"
        tag_out += "_cut"
        
    dut_out_dir = f"{dut_base_path}/sba_bs/raw"
    ref_out_dir = f"{reference_path}/sba_bs/raw"
    # to avoid conflicting names in case of parallel test execution, differentiate all cases
    if pca:
        tag_out += "_pca"
    if gain_flag != -1:
        tag_out += f"_Gain{gain_flag}"
    if sid == 1:
        tag_out += "_SID"
    if plc_pattern is not None:
        tag_out += "_" + plc_pattern

    dut_in_pkt = f"{dut_base_path}/sba_bs/pkt/{tag_out}{tag_ext}.192"
    ref_in_pkt = f"{reference_path}/sba_bs/pkt/{tag_out}{tag_ext}.192"
    dut_pkt_file = f"{dut_base_path}/sba_bs/pkt/{tag_out}.192"
    ref_pkt_file = f"{reference_path}/sba_bs/pkt/{tag_out}.192"

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

    dut_out_raw = f"{dut_out_dir}/{tag_out}{tag_ext}.wav"
    ref_out_raw = f"{ref_out_dir}/{tag_out}{tag_ext}.wav"

    check_and_makedir(dut_out_dir)
    check_and_makedir(ref_out_dir)
    dut_out_file = f"{dut_out_dir}/{tag_out}.wav"
    ref_out_file = f"{ref_out_dir}/{tag_out}.wav"

    if update_ref == 1:
        # call REF decoder
        ref_decoder_frontend.run(
            output_config,
            sampling_rate,
            ref_in_pkt,
            ref_out_raw,
            ref_pkt_file,
            ref_out_file,
            plc_file=plc_file,
        )

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

        # call DUT decoder
        dut_decoder_frontend.run(
            output_config,
            sampling_rate,
            dut_in_pkt,
            dut_out_raw,
            dut_pkt_file,
            dut_out_file,
            plc_file=plc_file,
        )

        sampling_rate_Hz = int(sampling_rate) * 1000
        cmp_result, reason = cmp_pcm(
            dut_out_raw,
            ref_out_raw,
            dut_out_file,
            ref_out_file,
            output_config,
            sampling_rate_Hz,
            get_mld=get_mld,
@@ -1133,8 +1141,8 @@ 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)
            os.remove(dut_out_file)
            if not decoder_only and plc_file is None:
                os.remove(dut_in_pkt)
                os.remove(dut_pkt_file)