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

Merge branch 'ci/add-jbm-to-ltv-sanitizer-tests' into 'main'

[CI]add jbm tests to ltv sanitizer tests

See merge request !1310
parents c9d96bcd 2e0f2028
Loading
Loading
Loading
Loading
Loading
+70 −0
Original line number Diff line number Diff line
#!/usr/bin/env python3
"""
   (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
   Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
   Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
   Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
   contributors to this repository. All Rights Reserved.

   This software is protected by copyright law and by international treaties.
   The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB,
   Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
   Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
   Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
   contributors to this repository retain full ownership rights in their respective contributions in
   the software. This notice grants no license of any kind, including but not limited to patent
   license, nor is any license granted by implication, estoppel or otherwise.

   Contributors are required to enter into the IVAS codec Public Collaboration agreement before making
   contributions.

   This software is provided "AS IS", without any express or implied warranties. The software is in the
   development stage. It is intended exclusively for experts who have experience with such software and
   solely for the purpose of inspection. All implied warranties of non-infringement, merchantability
   and fitness for a particular purpose are hereby disclaimed and excluded.

   Any dispute, controversy or claim arising under or in relation to providing this software shall be
   submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in
   accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and
   the United Nations Convention on Contracts on the International Sales of Goods.
"""

import argparse
import numpy as np


ERR_MAGIC_NUM_DLY_PROF = -1
ERR_MAGIC_NUM_G192 = 27424


def combine_error_profiles(genpatt_file, jbm_dly_profile, output_file):
    ep = np.fromfile(genpatt_file, dtype="int16")
    with open(jbm_dly_profile) as f:
        dly = np.asarray([int(l.strip()) for l in f.readlines()])

    # if one wants to differently-sized files, add wraparound/shorten logic here
    # in ci, file lengths will match
    assert len(ep) == len(dly)

    # remove lost frames already in the dly profile
    # replace with no delay (not there in the profile files, except the all-zero one)
    err_idx = np.where(dly == ERR_MAGIC_NUM_DLY_PROF)[0]
    dly[err_idx] = 0

    # insert lost frames based on .g192 file
    err_idx = np.where(ep == ERR_MAGIC_NUM_G192)[0]
    dly[err_idx] = -1
    
    with open(output_file, "w") as f:
        for d in dly:
            f.write(f"{int(d)}\n")


if __name__ == "__main__":
    parser = argparse.ArgumentParser()
    parser.add_argument("genpatt_file")
    parser.add_argument("jbm_dly_profile")
    parser.add_argument("output_file")
    args = parser.parse_args()

    combine_error_profiles(**vars(args))
+9 −6
Original line number Diff line number Diff line
@@ -40,19 +40,21 @@ from collect_artifacts import (
    find_failed_files_for_sanitizer_test,
    collect_for_sanitizer_test,
)
from combine_genpatt_and_jbm_profile import combine_error_profiles


SCRIPT_DIR = pathlib.Path("./scripts").resolve()
DURATION = "120"
CFG = "ci_linux_ltv.json"
SUPPORTED_TESTS = ["CLANG1", "CLANG2", "CLANG3", "VALGRIND"]
EP_FILE = "ep_015.g192"
GENPATT_CMD = f"gen-patt -tailstat -fer -g192 -gamma 0 -rate 0.15 -tol 0.001 -reset -n {int(DURATION) * 50} {EP_FILE}"
EIDXOR_CMD = "eid-xor -vbr -fer {bitstream} {ep_file} {out_file}"
DLY_PROFILE_IN = SCRIPT_DIR.joinpath("dly_error_profiles/dly_error_profile_5.dat")
DLY_PROFILE_OUT = "dly_profile.dat"
N_FRAMES_DLY_PROFILE = 7500
GENPATT_CMD = f"gen-patt -tailstat -fer -g192 -gamma 0 -rate 0.15 -tol 0.001 -reset -n {N_FRAMES_DLY_PROFILE} {EP_FILE}"
MC_MODES = ["5_1", "5_1_2", "5_1_4", "7_1", "7_1_4"]
AMBISONICS_MODES = ["HOA3", "HOA2", "FOA", "PlanarHOA3", "PlanarHOA2", "PlanarFOA"]

SCRIPT_DIR = pathlib.Path("./scripts").resolve()

CONSOLE_OUT_FILE = "output_san.txt"


@@ -186,6 +188,7 @@ def run_check(in_format: str, out_formats: list, tests: list, run_fec: bool = Tr

    # generate error pattern
    subprocess.call(GENPATT_CMD.split())
    combine_error_profiles(EP_FILE, DLY_PROFILE_IN, DLY_PROFILE_OUT)

    # cleanup to avoid script errors
    # we want "logs" and "dec" subfolders to be empty -> delete "dec" and rename "log"
@@ -203,10 +206,10 @@ def run_check(in_format: str, out_formats: list, tests: list, run_fec: bool = Tr
            # need empty log folder to avoid crashes
            path.mkdir()

    cmd_fec = cmd_no_fec + ["--decoder_only", "-f", EP_FILE]
    cmd_fec = cmd_no_fec + ["--decoder_only", "-J", DLY_PROFILE_OUT]
    print(
        "======== Script command line WITH plc: ========\n{}".format(
            " ".join(cmd_no_fec)
            " ".join(cmd_fec)
        )
    )