Commit 4ba4617e authored by Vidhya VP's avatar Vidhya VP
Browse files

Merge branch...

Merge branch '300-sba-decoder-13-2-and-16-4kbps-crashes-if-decoded-bitstream-starts-with-sid' into 'main'

Added test cases for initial SID frame

See merge request !634
parents d61d22c1 b9b6c7ad
Loading
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -35,7 +35,8 @@ import argparse
import os.path
import sys

SID_BITS = {35, 48, 88, 100}
#SID_BITS = {35, 48, 88, 100}
SID_BITS = {35, 48, 104}
SYNC_WORDS = {b"!k", b" k"}


@@ -86,7 +87,6 @@ def cut_bs(fp, fp_out, start_frame=0, start_with_sid=False):
        fp_out.write(n_bits_bs)
        fp_out.write(fp.read(n_bits * 2))
        fr_cnt += 1

    return (fr_cnt, cut_cnt)


+13 −3
Original line number Diff line number Diff line
@@ -45,7 +45,7 @@ from conftest import DecoderFrontend
tag_list = ['stvFOA']
plc_patterns = ['PLperc12mblen5', 'PLperc40mblen50', 'PLperc42mblen2']
dtx_set = ['0', '1']
ivas_br_list = ['32000', '64000', '96000', '256000']
ivas_br_list = ['13200','16400','32000', '64000', '96000', '256000']
sampling_rate_list = ['48', '32', '16']
agc_list = [-1, 0, 1]

@@ -89,10 +89,15 @@ def test_sba_plc_system(
    fs,
    agc
):
    if dtx == '1' and ivas_br not in ['32000', '64000']:
    SID = 0
    if dtx == '1' and ivas_br not in ['13200','16400','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 agc == 0 and fs != '16':
            SID = 1
        else:
            pytest.skip()
    tag = tag + fs + 'c'

    # dec
@@ -106,6 +111,7 @@ def test_sba_plc_system(
        fs,
        ivas_br,
        dtx,
        SID,
        plc_pattern,
        update_ref,
        agc,
@@ -125,6 +131,7 @@ def sba_dec_plc(
    sampling_rate,
    ivas_br,
    dtx,
    SID,
    plc_pattern,
    update_ref,
    agc,
@@ -147,6 +154,9 @@ def sba_dec_plc(
    plc_file = f"{test_vector_path}/{plc_pattern}.g192"
    ref_in_pkt = f"{reference_path}/sba_bs/pkt/{tag_out}.pkt"
    ref_in_pkt_dutenc = f"{reference_path}/sba_bs/pkt/{tag_out}_dutenc.pkt"
    if SID == 1:
        ref_in_pkt = f"{reference_path}/sba_bs/pkt/{tag_out}_SID_cut.pkt"
        ref_in_pkt_dutenc = f"{reference_path}/sba_bs/pkt/{tag_out}_SID_dutenc_cut.pkt"

    dut_out_raw = f"{dut_out_dir}/{plc_tag_out}.raw"
    ref_out_raw = f"{ref_out_dir}/{plc_tag_out}.raw"
+53 −10
Original line number Diff line number Diff line
@@ -42,8 +42,9 @@ import pytest
from cmp_pcm import cmp_pcm
from cut_pcm import cut_samples
from conftest import EncoderFrontend, DecoderFrontend

from cut_bs import cut_bs
# params

tag_list = ['stvFOA']
tag_list_HOA2 = ['stv2OA']
tag_list_HOA3 = ['stv3OA']
@@ -53,7 +54,7 @@ dtx_set = ['0', '1']
dict_fsample_bw = {'48': '3', '32': '2', '16': '1'}
dict_bw_idx = {'FB': '3', 'SWB': '2', 'WB': '1'}
dict_bw_tag = {'SWB': '_ForceSWB', 'WB': '_ForceWB'}
ivas_br_FOA = ['32000','64000', '96000', '160000', '256000', '384000', '512000','sw_24k4_256k.bin']
ivas_br_FOA = ['13200','16400','32000','64000', '96000', '160000', '256000', '384000', '512000','sw_24k4_256k.bin']
ivas_br_HOA2 = ['256000', '384000', '512000']
ivas_br_HOA3 = ['256000', '384000', '512000']

@@ -116,6 +117,7 @@ def test_bypass_enc(
        fs,
        ivas_br,
        dtx,
        None,
        max_bw,
        bypass,
        agc,
@@ -134,6 +136,7 @@ def test_bypass_enc(
        fs,
        ivas_br,
        dtx,
        None,
        max_bw,
        bypass,
        agc,
@@ -166,12 +169,17 @@ def test_sba_enc_system(
    fs,
    agc,
):
    if dtx == '1' and ivas_br not in ['32000', '64000']:
    SID = 0
    if dtx == '1' and ivas_br not in ['13200','16400','32000','64000']:
        # skip high bitrates for DTX until DTX issue is resolved
        pytest.skip()
    if ivas_br == 'sw_24k4_256k.bin' and agc != 1:
        pytest.skip()
    
    if ivas_br == '13200' or ivas_br == '16400':
        if dtx == '1' and agc == 0 and fs != '16':
            SID = 1
        else:
            pytest.skip()
    tag = tag + fs + 'c'
    max_bw = "FB"
    bypass = -1
@@ -195,6 +203,7 @@ def test_sba_enc_system(
        fs,
        ivas_br,
        dtx,
        SID,
        max_bw,
        bypass,
        agc,
@@ -215,6 +224,7 @@ def test_sba_enc_system(
        fs,
        ivas_br,
        dtx,
        SID,
        max_bw,
        bypass,
        agc,
@@ -262,6 +272,7 @@ def test_spar_hoa2_enc_system(
        fs,
        ivas_br,
        dtx,
        None,
        max_bw,
        bypass,
        agc,
@@ -279,6 +290,7 @@ def test_spar_hoa2_enc_system(
        fs,
        ivas_br,
        dtx,
        None,
        max_bw,
        bypass,
        agc,
@@ -326,6 +338,7 @@ def test_spar_hoa3_enc_system(
        fs,
        ivas_br,
        dtx,
        None,
        max_bw,
        bypass,
        agc,
@@ -343,6 +356,7 @@ def test_spar_hoa3_enc_system(
        fs,
        ivas_br,
        dtx,
        None,
        max_bw,
        bypass,
        agc,
@@ -375,6 +389,8 @@ def test_sba_enc_BWforce_system(
    if dtx == '1' and ivas_br not in ['32000','64000']:
        # skip high bitrates for DTX until DTX issue is resolved
        pytest.skip()
    if ivas_br == '13200' or ivas_br == '16400':
        pytest.skip()
    if ivas_br == 'sw_24k4_256k.bin':
        pytest.skip()
    fs = sample_rate_bw_idx[0]
@@ -397,6 +413,7 @@ def test_sba_enc_BWforce_system(
        fs,
        ivas_br,
        dtx,
        None,
        bw,
        bypass,
        agc,
@@ -415,6 +432,7 @@ def test_sba_enc_BWforce_system(
        fs,
        ivas_br,
        dtx,
        None,
        bw,
        bypass,
        agc,
@@ -437,6 +455,7 @@ def sba_enc(
    sampling_rate,
    ivas_br,
    dtx,
    SID,
    ivas_max_bw,
    bypass,
    agc,
@@ -468,16 +487,23 @@ def sba_enc(
    short_tag_ext = ""
    if agc != -1:
        short_tag_ext += f'_AGC{agc}'
    if SID == 1:
        short_tag_ext += f'_SID'
    # we update only bypass = 0/2 (bypass 1 is the same as the baseline)
    if bypass in [0, 2]:
        short_tag_ext += f"_pca{bypass}"
    # to avoid conflicting names in case of parallel test execution, differentiate all cases
    long_tag_ext = f"_AGC{agc}" if agc != -1 else "_AGC-unspecified"
    long_tag_ext += f"_pca{bypass}"
    if SID == 1:
        long_tag_ext += f"_SID"
    dut_pkt_file = f"{dut_out_dir}/{tag_out}{long_tag_ext}.pkt"
    ref_pkt_file = f"{ref_out_dir}/{tag_out}{short_tag_ext}.pkt"
    ref_pkt_file_dutenc = f"{ref_out_dir}/{tag_out}{short_tag_ext}_dutenc.pkt"

    if SID == 1:
        dut_pkt_file_cut = f"{dut_out_dir}/{tag_out}{long_tag_ext}_cut.pkt"
        ref_pkt_file_cut = f"{ref_out_dir}/{tag_out}{short_tag_ext}_cut.pkt"
        ref_pkt_file_dutenc_cut = f"{ref_out_dir}/{tag_out}{short_tag_ext}_dutenc_cut.pkt"
    input_path = f"{test_vector_path}/{tag_in}{in_extension}"
    agc_op = agc if agc != -1 else None
    bypass_mode = bypass if bypass >= 0 else None
@@ -539,7 +565,21 @@ def sba_enc(
            dtx_mode=dtx_mode,
        )


    if SID == 1:
        if ref_encoder_path:
            with open(ref_pkt_file, "rb") as fp_in:
                    with open(ref_pkt_file_cut, "wb") as fp_out:
                        fr_cnt, cut_cnt = cut_bs(fp_in, fp_out, 0, True)
            with open(ref_pkt_file_dutenc, "rb") as fp_in:
                with open(ref_pkt_file_dutenc_cut, "wb") as fp_out:
                    fr_cnt, cut_cnt = cut_bs(fp_in, fp_out, 0, True)
            os.remove(ref_pkt_file)
            os.remove(ref_pkt_file_dutenc)
        if update_ref == 0:
            with open(dut_pkt_file, "rb") as fp_in:
                    with open(dut_pkt_file_cut, "wb") as fp_out:
                        fr_cnt, cut_cnt = cut_bs(fp_in, fp_out, 0, True)
            os.remove(dut_pkt_file)         
def sba_dec(
    decoder_frontend,
    ref_decoder_path,
@@ -549,6 +589,7 @@ def sba_dec(
    sampling_rate,
    ivas_br,
    dtx,
    SID,
    ivas_max_bw,
    bypass,
    agc,
@@ -571,11 +612,13 @@ def sba_dec(
    # we update only bypass = 0/2 (bypass 1 is the same as the baseline)
    if bypass in [0, 2]:
        short_tag_ext += f"_pca{bypass}"

    if SID == 1:
       short_tag_ext += f'_SID_cut'
    # to avoid conflicting names in case of parallel test execution, differentiate all cases
    long_tag_ext = f"_AGC{agc}" if agc != -1 else "_AGC-unspecified"
    long_tag_ext += f"_pca{bypass}"

    if SID == 1:
        long_tag_ext += f"_SID_cut"
    dut_out_dir = f"{dut_base_path}/sba_bs/raw"
    ref_out_dir = f"{reference_path}/sba_bs/raw"