Commit a60697fd authored by Lauros Pajunen's avatar Lauros Pajunen
Browse files

Merge remote-tracking branch 'origin/main' into 1154-add-rtpdump-tests

parents 8eaee32d 7ca053bf
Loading
Loading
Loading
Loading
+19 −2
Original line number Diff line number Diff line
import numpy as np
from scipy.spatial.transform import Rotation


FRAMES_PER_SEC = 50
MAGIC_VAL_TO_SIGNAL_EULER_ANGLES = -3


def random_trajectory(duration_sec):
    n_frames = int(FRAMES_PER_SEC * duration_sec)
    trj = np.random.random((n_frames, 4))
    trj[:, 0] = -3
    trj[:, 0] = MAGIC_VAL_TO_SIGNAL_EULER_ANGLES
    trj[:, 1] *= 180
    trj[:, 2] *= 90
    trj[:, 3] *= 180
@@ -17,9 +19,24 @@ def random_trajectory(duration_sec):
def constant_trajectory(duration_sec, yaw=0, pitch=0, roll=0):
    n_frames = int(FRAMES_PER_SEC * duration_sec)
    trj = np.empty((n_frames, 4))
    trj[:, 0] = -3
    trj[:, 0] = MAGIC_VAL_TO_SIGNAL_EULER_ANGLES
    trj[:, 1] = yaw
    trj[:, 2] = pitch
    trj[:, 3] = roll
    return trj


def random_trajectory_quat(duration_sec):
    n_frames = int(FRAMES_PER_SEC * duration_sec)
    trj = Rotation.random(n_frames).as_quat()
    return trj


def constant_trajectory_quat(duration_sec, w=1, x=0, y=0, z=0):
    n_frames = int(FRAMES_PER_SEC * duration_sec)
    trj = np.empty((n_frames, 4))
    trj[:, 0] = w
    trj[:, 1] = x
    trj[:, 2] = y
    trj[:, 3] = z
    return trj
+46 −37
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ import argparse
import pathlib
import subprocess
import sys
import os
import numpy as np
import json

@@ -43,7 +44,7 @@ from collect_artifacts import (
    find_failed_files_for_sanitizer_test,
)
from combine_genpatt_and_jbm_profile import combine_error_profiles
from create_trajectories import random_trajectory
from create_trajectories import random_trajectory, random_trajectory_quat


SCRIPT_DIR = pathlib.Path("./scripts").resolve()
@@ -75,12 +76,17 @@ ARGS_FOR_OC = {
    "BINAURAL_ROOM_REVERB": BINAURAL_OUT_ARGS,
}

SEED_FOR_RANDOM = int(os.environ.get("CI_JOB_ID", 0))


def main(args):
    in_format = args.in_format
    out_formats = args.out_formats
    tests = args.tests
    run_fec = not args.skip_fec
    seed = SEED_FOR_RANDOM if args.inject_seed is None else args.inject_seed

    np.random.seed(seed)

    assert all([t in SUPPORTED_TESTS for t in tests])

@@ -92,7 +98,6 @@ def main(args):


def get_modes(in_format: str) -> list:

    in_format_for_script = in_format
    if in_format in MC_MODES:
        in_format_for_script = "MC"
@@ -134,7 +139,6 @@ def assemble_oc_dict(out_formats: list):


def get_md_file_command(in_format: str) -> list:

    cmd = list()
    if "ISM" in in_format:
        cmd.append("--ism_metadata_files")
@@ -145,8 +149,7 @@ def get_md_file_command(in_format: str) -> list:
    return cmd


def run_check(in_format: str, out_formats: list, tests: list, run_fec: bool = True):

def run_check(in_format: str, out_formats: list, tests: list, run_fec: bool):
    modes = get_modes(in_format)
    if len(modes) == 0:
        return 0
@@ -156,10 +159,10 @@ def run_check(in_format: str, out_formats: list, tests: list, run_fec: bool = Tr

    # create random trajectory files
    if "BINAURAL" in oc_str:
        trajectory_files = [HEAD_TRAJ_FILE, EXOF_TRAJ_FILE]
        for tf in trajectory_files:
        traj = random_trajectory(int(DURATION))
            np.savetxt(tf, traj, fmt="%.2f", delimiter=",")
        np.savetxt(HEAD_TRAJ_FILE, traj, fmt="%.2f", delimiter=",")
        traj_exof = random_trajectory_quat(int(DURATION))
        np.savetxt(EXOF_TRAJ_FILE, traj_exof, fmt="%.2f", delimiter=",")

    ### always run encoder and decoder with no frameloss
    cmd_no_fec = [
@@ -187,7 +190,7 @@ def run_check(in_format: str, out_formats: list, tests: list, run_fec: bool = Tr
    # resue decoder part of StereDmxEVS mode (it is basically a duplicate of "normal" mono run)
    if in_format == "StereoDmxEVS":
        panning = np.random.randint(-90, 91)
        cmd_no_fec += [f'-D=-non_diegetic_pan {panning}']
        cmd_no_fec += [f"-D=-non_diegetic_pan {panning}"]

    print(
        "======== Script command line WITHOUT plc: ========\n{}".format(
@@ -277,5 +280,11 @@ if __name__ == "__main__":
    parser.add_argument("out_formats", type=str, nargs="+")
    parser.add_argument("--tests", type=str, nargs="+", default=["CLANG1", "CLANG2"])
    parser.add_argument("--skip_fec", action="store_true")
    parser.add_argument(
        "--inject_seed",
        type=int,
        default=None,
        help="Value to use for seeding random generators",
    )

    sys.exit(main(parser.parse_args()))
+4 −1
Original line number Diff line number Diff line
@@ -199,7 +199,10 @@ ivas_error IVAS_RTP_PACK_UpdateHeader(

    header->ssrc = ssrc;
    header->CC = numCC;
    if ( csrc != NULL )
    {
        memcpy( header->CSRC, csrc, numCC & 0xF );
    }

    if ( ( numExtensionBytes > 0 ) && ( extData != NULL ) )
    {
+69 −61
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@ from typing import Tuple, Optional

import numpy as np
import pytest
import logging

from tests.renderer.constants import (
    BIN_SUFFIX_MERGETARGET,
@@ -235,80 +236,80 @@ def run_full_chain_split_rendering(
            in_meta_files = None

        # run encoder
        cmd = SPLIT_PRE_COD_CMD[:]
        enc_cmd = SPLIT_PRE_COD_CMD[:]

        if test_info.config.option.create_ref:
            cmd[0] += BIN_SUFFIX_MERGETARGET
        cmd[0] += binary_suffix
        cmd[1] = bitrate
            enc_cmd[0] += BIN_SUFFIX_MERGETARGET
        enc_cmd[0] += binary_suffix
        enc_cmd[1] = bitrate
        # if in REF or CUT creation mode use the comparetestv
        if test_info.config.option.create_ref or test_info.config.option.create_cut:
            in_file = FORMAT_TO_FILE_COMPARETEST[in_fmt]
            truncate_signal(in_file, cut_in_file)

            cmd[3] = str(cut_in_file)
            enc_cmd[3] = str(cut_in_file)
        else:
            cmd[3] = str(FORMAT_TO_FILE_SMOKETEST[in_fmt])
        cmd[4] = str(ivas_bitstream)
            enc_cmd[3] = str(FORMAT_TO_FILE_SMOKETEST[in_fmt])
        enc_cmd[4] = str(ivas_bitstream)

        if in_meta_files:
            cmd[1:1] = in_meta_files
            enc_cmd[1:1] = in_meta_files

        cmd[1:1] = FORMAT_TO_IVAS_COD_FORMAT[in_fmt]
        enc_cmd[1:1] = FORMAT_TO_IVAS_COD_FORMAT[in_fmt]

        run_ivas_isar_enc_cmd(cmd)
        run_ivas_isar_enc_cmd(enc_cmd)

        if delay_profile:
            rtp_bitstream = ivas_bitstream.with_suffix(".rtpg192")
            cmd = [
            netsim_cmd = [
                str(TOOLS_DIR / f"networkSimulator_g192{EXE_SUFFIX}"),
                str(delay_profile),
                str(ivas_bitstream),
                str(rtp_bitstream),
                str(tmp_dir / "tmp.netsimtrace"),
                "1",
                "0"
                "0",
            ]
            run_cmd(cmd, test_info=test_info)
            run_cmd(netsim_cmd, test_info=test_info)
            ivas_bitstream = rtp_bitstream

        # decode to split-rendering bitstream
        cmd = SPLIT_PRE_DEC_CMD[:]
        dec_cmd = SPLIT_PRE_DEC_CMD[:]

        if test_info.config.option.create_ref:
            cmd[0] += BIN_SUFFIX_MERGETARGET
        cmd[0] += binary_suffix
        cmd[2] = str(pre_trajectory)
        cmd[4] = str(render_config)
        cmd[6] = str(pre_rend_fr)
        cmd[7] = renderer_fmt
        cmd[9] = str(ivas_bitstream)
        cmd[10] = str(split_bitstream)
            dec_cmd[0] += BIN_SUFFIX_MERGETARGET
        dec_cmd[0] += binary_suffix
        dec_cmd[2] = str(pre_trajectory)
        dec_cmd[4] = str(render_config)
        dec_cmd[6] = str(pre_rend_fr)
        dec_cmd[7] = renderer_fmt
        dec_cmd[9] = str(ivas_bitstream)
        dec_cmd[10] = str(split_bitstream)

        if renderer_fmt == "BINAURAL_SPLIT_PCM":
            cmd[5:5] = ["-om", str(split_md_file)]
            dec_cmd[5:5] = ["-om", str(split_md_file)]

        if delay_profile:
            cmd[5:5] = ["-voip"]
            dec_cmd[5:5] = ["-voip"]

        run_ivas_isar_dec_cmd(cmd)
        run_ivas_isar_dec_cmd(dec_cmd)

        # run split renderer
        cmd = SPLIT_POST_REND_CMD[:]
        post_rend_cmd = SPLIT_POST_REND_CMD[:]

        if test_info.config.option.create_ref:
            cmd[0] += BIN_SUFFIX_MERGETARGET
        cmd[0] += binary_suffix
        cmd[4] = str(split_bitstream)
        cmd[6] = renderer_fmt
        cmd[8] = str(out_file)
        cmd[10] = str(post_trajectory)
        cmd[12] = post_rend_fr
            post_rend_cmd[0] += BIN_SUFFIX_MERGETARGET
        post_rend_cmd[0] += binary_suffix
        post_rend_cmd[4] = str(split_bitstream)
        post_rend_cmd[6] = renderer_fmt
        post_rend_cmd[8] = str(out_file)
        post_rend_cmd[10] = str(post_trajectory)
        post_rend_cmd[12] = post_rend_fr

        if renderer_fmt == "BINAURAL_SPLIT_PCM":
            cmd[7:7] = ["-im", str(split_md_file)]
            post_rend_cmd[7:7] = ["-im", str(split_md_file)]

        run_isar_post_rend_cmd(cmd)
        run_isar_post_rend_cmd(post_rend_cmd)

    if test_info.config.option.create_cut:
        # CUT creation mode will run a comparison with REF
@@ -335,6 +336,11 @@ def run_full_chain_split_rendering(
            record_property(k, v)

        if output_differs:
            logging.error(f"Encoder command line was: {' '.join(enc_cmd)}")
            if delay_profile:
                logging.error(f"Netsim command line was: {' '.join(netsim_cmd)}")
            logging.error(f"Decoder command line was: {' '.join(dec_cmd)}")
            logging.error(f"Post renderer command line was: {' '.join(post_rend_cmd)}")
            pytest.fail(f"Output differs: ({reason})")

    return out_file
@@ -399,52 +405,52 @@ def run_external_split_rendering(
            in_meta_files = None

        # generate split-rendering bitstream
        cmd = SPLIT_PRE_REND_CMD[:]
        split_pre_cmd = SPLIT_PRE_REND_CMD[:]

        if test_info.config.option.create_ref:
            cmd[0] += BIN_SUFFIX_MERGETARGET
        cmd[0] += binary_suffix
        cmd[4] = str(render_config)
            split_pre_cmd[0] += BIN_SUFFIX_MERGETARGET
        split_pre_cmd[0] += binary_suffix
        split_pre_cmd[4] = str(render_config)
        if is_comparetest:
            in_file = FORMAT_TO_FILE_COMPARETEST[in_fmt]
            truncate_signal(in_file, cut_in_file)

            cmd[6] = str(cut_in_file)
            split_pre_cmd[6] = str(cut_in_file)
        else:
            cmd[6] = str(FORMAT_TO_FILE_SMOKETEST[in_fmt])
        cmd[8] = in_fmt
        cmd[10] = str(split_bitstream)
        cmd[12] = renderer_fmt
        cmd[14] = str(pre_trajectory)
        cmd[16] = pre_rend_fr
            split_pre_cmd[6] = str(FORMAT_TO_FILE_SMOKETEST[in_fmt])
        split_pre_cmd[8] = in_fmt
        split_pre_cmd[10] = str(split_bitstream)
        split_pre_cmd[12] = renderer_fmt
        split_pre_cmd[14] = str(pre_trajectory)
        split_pre_cmd[16] = pre_rend_fr

        if renderer_fmt == "BINAURAL_SPLIT_PCM":
            cmd[13:13] = ["-om", str(split_md_file)]
            split_pre_cmd[13:13] = ["-om", str(split_md_file)]

        if in_meta_files:
            cmd[9:9] = ["-im", *in_meta_files]
            split_pre_cmd[9:9] = ["-im", *in_meta_files]

        run_isar_ext_rend_cmd(cmd)
        run_isar_ext_rend_cmd(split_pre_cmd)

        # run split renderer
        cmd = SPLIT_POST_REND_CMD[:]
        split_post_cmd = SPLIT_POST_REND_CMD[:]

        if test_info.config.option.create_ref:
            cmd[0] += BIN_SUFFIX_MERGETARGET
        cmd[0] += binary_suffix
        cmd[4] = str(split_bitstream)
        cmd[6] = renderer_fmt
        cmd[8] = str(out_file)
        cmd[10] = str(post_trajectory)
        cmd[12] = post_rend_fr
            split_post_cmd[0] += BIN_SUFFIX_MERGETARGET
        split_post_cmd[0] += binary_suffix
        split_post_cmd[4] = str(split_bitstream)
        split_post_cmd[6] = renderer_fmt
        split_post_cmd[8] = str(out_file)
        split_post_cmd[10] = str(post_trajectory)
        split_post_cmd[12] = post_rend_fr

        if renderer_fmt == "BINAURAL_SPLIT_PCM":
            cmd[7:7] = ["-im", str(split_md_file)]
            split_post_cmd[7:7] = ["-im", str(split_md_file)]

        if plc_error_pattern:
            cmd[1:1] = ["-prbfi", str(plc_error_pattern)]
            split_post_cmd[1:1] = ["-prbfi", str(plc_error_pattern)]

        run_isar_ext_rend_cmd(cmd)
        run_isar_ext_rend_cmd(split_post_cmd)

    if test_info.config.option.create_cut:
        # CUT creation mode will run a comparison with REF
@@ -474,6 +480,8 @@ def run_external_split_rendering(
            record_property(k, v)

        if output_differs:
            logging.error(f"Split Pre command line was: {' '.join(split_pre_cmd)}")
            logging.error(f"Split Post command line was: {' '.join(split_post_cmd)}")
            pytest.fail(f"Output differs: ({reason})")

    return out_file