Skip to content
......@@ -54,6 +54,13 @@ def pytest_addoption(parser):
type=pathlib.Path,
default='./bin/IVAS_rend',
)
parser.addoption(
"--isar_post_renderer_path",
action="store",
help="path to renderer binary ISAR_post_rend(.exe)",
type=pathlib.Path,
default='./bin/ISAR_post_rend',
)
@pytest.fixture(scope="session")
......@@ -69,3 +76,8 @@ def decoder_path(request) -> str:
@pytest.fixture(scope="session")
def renderer_path(request) -> str:
return str(request.config.option.renderer_path.absolute())
@pytest.fixture(scope="session")
def isar_post_renderer_path(request) -> str:
return str(request.config.option.isar_post_renderer_path.absolute())
......@@ -59,7 +59,7 @@ def replace_paths(instr, testv_path, ref_path, cut_path):
test_dict = {}
TEST_DIR = "."
scripts=["Readme_IVAS_enc.txt", "Readme_IVAS_dec.txt", "Readme_IVAS_rend.txt", "Readme_IVAS_JBM_dec.txt"]
scripts=["Readme_IVAS_enc.txt", "Readme_IVAS_dec.txt", "Readme_IVAS_rend.txt", "Readme_IVAS_JBM_dec.txt", "Readme_IVAS_ISAR_dec.txt", "Readme_IVAS_ISAR_post_rend.txt"]
for s in scripts:
with open(os.path.join(TEST_DIR, s), "r", encoding="UTF-8") as fp:
......@@ -68,6 +68,7 @@ for s in scripts:
dec_opts = ""
diff_opts = ""
rend_opts = ""
isar_post_rend_opts = ""
testv_path = ""
ref_path = ""
cut_path = ""
......@@ -87,17 +88,20 @@ for s in scripts:
dec_opts = line
if line.startswith("$CUT_REND_BIN"):
rend_opts = line
if line.startswith("$CUT_ISAR_POST_REND_BIN"):
isar_post_rend_opts = line
if line.startswith("$DIFF_BIN"):
diff_opts = line
tag = s + "--" + diff_opts.split()[2].split('/')[-1]
if tag in test_dict:
print("non-unique tag found - ignoring new entry")
continue
test_dict[tag] = (enc_opts, dec_opts, rend_opts, diff_opts, testv_path, ref_path, cut_path)
test_dict[tag] = (enc_opts, dec_opts, rend_opts, isar_post_rend_opts, diff_opts, testv_path, ref_path, cut_path)
tag = ""
enc_opts = ""
dec_opts = ""
rend_opts = ""
isar_post_rend_opts = ""
diff_opts = ""
for proc in preproc:
proc = replace_paths(proc, testv_path, ref_path, cut_path)
......@@ -106,9 +110,9 @@ for s in scripts:
Path(path_arg).mkdir(parents=True, exist_ok=True)
@pytest.mark.parametrize("test_tag", list(test_dict.keys()))
def test_26252(test_tag, encoder_path, decoder_path, renderer_path):
def test_26252(test_tag, encoder_path, decoder_path, renderer_path, isar_post_renderer_path):
enc_opts, dec_opts, rend_opts, diff_opts, testv_path, ref_path, cut_path = test_dict[test_tag]
enc_opts, dec_opts, rend_opts, isar_post_rend_opts, diff_opts, testv_path, ref_path, cut_path = test_dict[test_tag]
if enc_opts:
enc_opts = replace_paths(enc_opts, testv_path, ref_path, cut_path)
......@@ -119,6 +123,9 @@ def test_26252(test_tag, encoder_path, decoder_path, renderer_path):
if rend_opts:
rend_opts = replace_paths(rend_opts, testv_path, ref_path, cut_path)
subprocess.run([renderer_path] + rend_opts.split()[1:], check = True)
if isar_post_rend_opts:
isar_post_rend_opts = replace_paths(isar_post_rend_opts, testv_path, ref_path, cut_path)
subprocess.run([isar_post_renderer_path] + isar_post_rend_opts.split()[1:], check = True)
diff_opts = replace_paths(diff_opts, testv_path, ref_path, cut_path)
result = True
......
......@@ -62,6 +62,41 @@ def run_cmd(cmd, env=None):
f"Command returned non-zero exit status ({e.returncode}): {' '.join(e.cmd)}\n{e.stderr}\n{e.stdout}"
)
def run_isar_ext_rend_cmd(cmd, env=None):
logging.info(f"\nRunning ISAR EXT REND command\n{' '.join(cmd)}\n")
try:
sp.run(cmd, check=True, capture_output=True, text=True, env=env)
except sp.CalledProcessError as e:
raise SystemError(
f"Command returned non-zero exit status ({e.returncode}): {' '.join(e.cmd)}\n{e.stderr}\n{e.stdout}"
)
def run_ivas_isar_enc_cmd(cmd, env=None):
logging.info(f"\nRunning IVAS ISAR encoder command\n{' '.join(cmd)}\n")
try:
sp.run(cmd, check=True, capture_output=True, text=True, env=env)
except sp.CalledProcessError as e:
raise SystemError(
f"Command returned non-zero exit status ({e.returncode}): {' '.join(e.cmd)}\n{e.stderr}\n{e.stdout}"
)
def run_ivas_isar_dec_cmd(cmd, env=None):
logging.info(f"\nDUT decoder command:\n\t{' '.join(cmd)}\n")
try:
sp.run(cmd, check=True, capture_output=True, text=True, env=env)
except sp.CalledProcessError as e:
raise SystemError(
f"Command returned non-zero exit status ({e.returncode}): {' '.join(e.cmd)}\n{e.stderr}\n{e.stdout}"
)
def run_isar_post_rend_cmd(cmd, env=None):
logging.info(f"\nRunning ISAR post renderer command\n{' '.join(cmd)}\n")
try:
sp.run(cmd, check=True, capture_output=True, text=True, env=env)
except sp.CalledProcessError as e:
raise SystemError(
f"Command returned non-zero exit status ({e.returncode}): {' '.join(e.cmd)}\n{e.stderr}\n{e.stdout}"
)
def check_BE(
test_info,
......
......@@ -31,6 +31,7 @@
"""
from pathlib import Path
import platform
from tests.renderer.constants import (
BIN_SUFFIX_MERGETARGET,
......@@ -41,6 +42,13 @@ from tests.renderer.constants import (
METADATA_SCENES_TO_TEST,
)
if platform.system() == "Windows":
EXE_SUFFIX = ".exe"
elif platform.system() in ["Linux", "Darwin"]:
EXE_SUFFIX = ""
else:
assert False, f"Unsupported platform {platform.system()}"
""" Set up paths """
TESTS_DIR = Path(__file__).parent
RENDER_CFG_DIR = TESTS_DIR.joinpath("renderer_configs").resolve()
......
......@@ -38,6 +38,7 @@ from tests.split_rendering.utils import *
""" Ambisonics """
@pytest.mark.create_ref
@pytest.mark.parametrize("trajectory", SPLIT_REND_HR_TRAJECTORIES_TO_TEST)
@pytest.mark.parametrize("render_config", RENDERER_CONFIGS_TO_TEST_AMBI)
@pytest.mark.parametrize("bitrate", IVAS_BITRATES_AMBI)
......@@ -53,11 +54,13 @@ def test_ambisonics_full_chain_split(
in_fmt=in_fmt,
bitrate=bitrate,
render_config=RENDER_CFG_DIR.joinpath(f"{render_config}.txt"),
binary_suffix=EXE_SUFFIX,
pre_trajectory=pre_trajectory,
post_trajectory=post_trajectory,
)
@pytest.mark.create_ref
@pytest.mark.parametrize("trajectory", SPLIT_REND_HR_TRAJECTORIES_TO_TEST)
@pytest.mark.parametrize("render_config", RENDERER_CONFIGS_TO_TEST_AMBI)
@pytest.mark.parametrize("in_fmt", INPUT_FORMATS_AMBI_SPLIT_REND)
......@@ -77,6 +80,7 @@ def test_ambisonics_external_split(test_info, in_fmt, render_config, trajectory)
""" Multichannel """
@pytest.mark.create_ref
@pytest.mark.parametrize("trajectory", SPLIT_REND_HR_TRAJECTORIES_TO_TEST)
@pytest.mark.parametrize("render_config", RENDERER_CONFIGS_TO_TEST_MC)
@pytest.mark.parametrize("bitrate", IVAS_BITRATES_MC)
......@@ -92,11 +96,13 @@ def test_multichannel_full_chain_split(
in_fmt=in_fmt,
bitrate=bitrate,
render_config=RENDER_CFG_DIR.joinpath(f"{render_config}.txt"),
binary_suffix=EXE_SUFFIX,
pre_trajectory=pre_trajectory,
post_trajectory=post_trajectory,
)
@pytest.mark.create_ref
@pytest.mark.parametrize("trajectory", SPLIT_REND_HR_TRAJECTORIES_TO_TEST)
@pytest.mark.parametrize("render_config", RENDERER_CONFIGS_TO_TEST_MC)
@pytest.mark.parametrize("in_fmt", INPUT_FORMATS_MC_SPLIT_REND)
......@@ -116,6 +122,7 @@ def test_multichannel_external_split(test_info, in_fmt, render_config, trajector
""" ISM """
@pytest.mark.create_ref
@pytest.mark.parametrize("trajectory", SPLIT_REND_HR_TRAJECTORIES_TO_TEST)
@pytest.mark.parametrize("render_config", RENDERER_CONFIGS_TO_TEST_ISM)
@pytest.mark.parametrize("bitrate", IVAS_BITRATES_ISM)
......@@ -129,11 +136,13 @@ def test_ism_full_chain_split(test_info, in_fmt, bitrate, render_config, traject
in_fmt=in_fmt,
bitrate=bitrate,
render_config=RENDER_CFG_DIR.joinpath(f"{render_config}.txt"),
binary_suffix=EXE_SUFFIX,
pre_trajectory=pre_trajectory,
post_trajectory=post_trajectory,
)
@pytest.mark.create_ref
@pytest.mark.parametrize("trajectory", SPLIT_REND_HR_TRAJECTORIES_TO_TEST)
@pytest.mark.parametrize("render_config", RENDERER_CONFIGS_TO_TEST_ISM)
@pytest.mark.parametrize("in_fmt", INPUT_FORMATS_ISM_SPLIT_REND)
......@@ -153,6 +162,7 @@ def test_ism_external_split(test_info, in_fmt, render_config, trajectory):
""" MASA """
@pytest.mark.create_ref
@pytest.mark.parametrize("trajectory", SPLIT_REND_HR_TRAJECTORIES_TO_TEST)
@pytest.mark.parametrize("render_config", RENDERER_CONFIGS_TO_TEST_MASA)
@pytest.mark.parametrize("bitrate", IVAS_BITRATES_MASA)
......@@ -166,11 +176,13 @@ def test_masa_full_chain_split(test_info, in_fmt, bitrate, render_config, trajec
in_fmt=in_fmt,
bitrate=bitrate,
render_config=RENDER_CFG_DIR.joinpath(f"{render_config}.txt"),
binary_suffix=EXE_SUFFIX,
pre_trajectory=pre_trajectory,
post_trajectory=post_trajectory,
)
@pytest.mark.create_ref
@pytest.mark.parametrize("trajectory", SPLIT_REND_HR_TRAJECTORIES_TO_TEST)
@pytest.mark.parametrize("render_config", RENDERER_CONFIGS_TO_TEST_MASA)
@pytest.mark.parametrize("in_fmt", INPUT_FORMATS_MASA_SPLIT_REND)
......@@ -190,6 +202,7 @@ def test_masa_external_split(test_info, in_fmt, render_config, trajectory):
""" OMASA """
@pytest.mark.create_ref
@pytest.mark.parametrize("trajectory", SPLIT_REND_HR_TRAJECTORIES_TO_TEST)
@pytest.mark.parametrize("render_config", RENDERER_CONFIGS_TO_TEST_OMASA)
@pytest.mark.parametrize("bitrate", IVAS_BITRATES_OMASA)
......@@ -203,6 +216,7 @@ def test_omasa_full_chain_split(test_info, in_fmt, bitrate, render_config, traje
in_fmt=in_fmt,
bitrate=bitrate,
render_config=RENDER_CFG_DIR.joinpath(f"{render_config}.txt"),
binary_suffix=EXE_SUFFIX,
pre_trajectory=pre_trajectory,
post_trajectory=post_trajectory,
)
......@@ -211,6 +225,7 @@ def test_omasa_full_chain_split(test_info, in_fmt, bitrate, render_config, traje
""" OSBA """
@pytest.mark.create_ref
@pytest.mark.parametrize("trajectory", SPLIT_REND_HR_TRAJECTORIES_TO_TEST)
@pytest.mark.parametrize("render_config", RENDERER_CONFIGS_TO_TEST_OSBA)
@pytest.mark.parametrize("bitrate", IVAS_BITRATES_OSBA)
......@@ -224,6 +239,7 @@ def test_osba_full_chain_split(test_info, in_fmt, bitrate, render_config, trajec
in_fmt=in_fmt,
bitrate=bitrate,
render_config=RENDER_CFG_DIR.joinpath(f"{render_config}.txt"),
binary_suffix=EXE_SUFFIX,
pre_trajectory=pre_trajectory,
post_trajectory=post_trajectory,
)
......@@ -232,6 +248,7 @@ def test_osba_full_chain_split(test_info, in_fmt, bitrate, render_config, trajec
""" PLC """
@pytest.mark.create_ref
@pytest.mark.parametrize("error_pattern", PLC_ERROR_PATTERNS)
@pytest.mark.parametrize("trajectory", SPLIT_REND_HR_TRAJECTORIES_TO_TEST)
@pytest.mark.parametrize("render_config", RENDERER_CONFIGS_TO_TEST_PLC)
......@@ -262,6 +279,7 @@ full_chain_split_pcm_params = [
]
@pytest.mark.create_ref
@pytest.mark.parametrize("in_fmt,bitrate,render_config", full_chain_split_pcm_params)
def test_full_chain_split_pcm(test_info, in_fmt, bitrate, render_config):
trajectory = SPLIT_REND_HR_TRAJECTORIES_TO_TEST[0]
......@@ -273,6 +291,7 @@ def test_full_chain_split_pcm(test_info, in_fmt, bitrate, render_config):
in_fmt=in_fmt,
bitrate=bitrate,
render_config=RENDER_CFG_DIR.joinpath(f"{render_config}.txt"),
binary_suffix=EXE_SUFFIX,
pre_trajectory=pre_trajectory,
post_trajectory=post_trajectory,
renderer_fmt="BINAURAL_SPLIT_PCM",
......@@ -286,6 +305,7 @@ external_split_pcm_params = [
]
@pytest.mark.create_ref
@pytest.mark.parametrize("in_fmt,render_config", external_split_pcm_params)
def test_external_split_pcm(test_info, in_fmt, render_config):
trajectory = SPLIT_REND_HR_TRAJECTORIES_TO_TEST[0]
......@@ -301,6 +321,7 @@ def test_external_split_pcm(test_info, in_fmt, render_config):
renderer_fmt="BINAURAL_SPLIT_PCM",
)
@pytest.mark.create_ref
@pytest.mark.parametrize("trajectory", SPLIT_REND_HR_TRAJECTORIES_TO_TEST)
@pytest.mark.parametrize("render_config", RENDERER_CONFIGS_FRAMING)
@pytest.mark.parametrize("in_fmt", ["5_1"])
......@@ -319,6 +340,7 @@ def test_framing_combinations_external_split(test_info, in_fmt, render_config, t
post_rend_fr=post_rend_fr,
pre_rend_fr=pre_rend_fr,
)
@pytest.mark.create_ref
@pytest.mark.parametrize("trajectory", SPLIT_REND_HR_TRAJECTORIES_TO_TEST)
@pytest.mark.parametrize("render_config", RENDERER_CONFIGS_FRAMING)
@pytest.mark.parametrize("in_fmt", ["5_1"])
......@@ -337,6 +359,7 @@ def test_framing_combinations_full_chain_split(
pre_trajectory=pre_trajectory,
bitrate="256000",
post_trajectory=post_trajectory,
binary_suffix=EXE_SUFFIX,
post_rend_fr=post_rend_fr,
pre_rend_fr=pre_rend_fr,
)
......@@ -39,7 +39,7 @@ from typing import Tuple
import numpy as np
import pytest
from tests.renderer.utils import check_BE, run_cmd, test_info
from tests.renderer.utils import check_BE, run_cmd, test_info, run_ivas_isar_enc_cmd, run_ivas_isar_dec_cmd, run_isar_post_rend_cmd, run_isar_ext_rend_cmd
from tests.split_rendering.constants import *
sys.path.append(SCRIPTS_DIR)
......@@ -172,18 +172,26 @@ def run_full_chain_split_rendering(
with TemporaryDirectory() as tmp_dir:
tmp_dir = Path(tmp_dir)
cut_in_file = tmp_dir.joinpath("cut_input.wav")
ivas_bitstream = tmp_dir.joinpath("ivas.192")
split_bitstream = tmp_dir.joinpath("split.bit")
#ivas_bitstream = tmp_dir.joinpath("ivas.192")
ivas_bitstream_stem = f"{in_fmt}_{bitrate}bps_{renderer_fmt}_split_full_config_{render_config.stem}_prerfr_{pre_rend_fr}_postrfr_{post_rend_fr}_ivas.192"
#split_bitstream = tmp_dir.joinpath("split.bit")
split_bitstream_stem = f"{in_fmt}_{bitrate}bps_{renderer_fmt}_split_full_config_{render_config.stem}_prerfr_{pre_rend_fr}_postrfr_{post_rend_fr}_split.bit"
if renderer_fmt == "BINAURAL_SPLIT_PCM":
split_md_file = tmp_dir.joinpath("split_md.bin")
out_file_stem = f"{in_fmt}_{bitrate}bps_{renderer_fmt}_{pre_trajectory.stem}_split_full_{post_trajectory.stem}_config_{render_config.stem}_prerfr_{pre_rend_fr}_postrfr_{post_rend_fr}_.wav"
#split_md_file = tmp_dir.joinpath("split_md.bin")
split_md_file_stem = f"{in_fmt}_{bitrate}bps_{renderer_fmt}_split_full_config_{render_config.stem}_prerfr_{pre_rend_fr}_postrfr_{post_rend_fr}_split_md.bit"
out_file_stem = f"{in_fmt}_{bitrate}bps_{renderer_fmt}_split_full_config_{render_config.stem}_prerfr_{pre_rend_fr}_postrfr_{post_rend_fr}_.wav"
if test_info.config.option.create_ref:
output_path_base = OUTPUT_PATH_REF
else:
output_path_base = OUTPUT_PATH_CUT
ivas_bitstream = output_path_base.joinpath(ivas_bitstream_stem)
split_bitstream = output_path_base.joinpath(split_bitstream_stem)
out_file = output_path_base.joinpath(out_file_stem)
if renderer_fmt == "BINAURAL_SPLIT_PCM":
split_md_file = output_path_base.joinpath(split_md_file_stem)
# check for metadata files
if in_fmt.upper().startswith("OSBA"):
......@@ -216,7 +224,7 @@ def run_full_chain_split_rendering(
cmd[1:1] = FORMAT_TO_IVAS_COD_FORMAT[in_fmt]
run_cmd(cmd)
run_ivas_isar_enc_cmd(cmd)
# decode to split-rendering bitstream
cmd = SPLIT_PRE_DEC_CMD[:]
......@@ -234,7 +242,7 @@ def run_full_chain_split_rendering(
if renderer_fmt == "BINAURAL_SPLIT_PCM":
cmd[5:5] = ["-om", str(split_md_file)]
run_cmd(cmd)
run_ivas_isar_dec_cmd(cmd)
# run split renderer
cmd = SPLIT_POST_REND_CMD[:]
......@@ -251,7 +259,7 @@ def run_full_chain_split_rendering(
if renderer_fmt == "BINAURAL_SPLIT_PCM":
cmd[7:7] = ["-im", str(split_md_file)]
run_cmd(cmd)
run_isar_post_rend_cmd(cmd)
if test_info.config.option.create_cut:
# CUT creation mode will run a comparison with REF
......@@ -297,7 +305,7 @@ def run_external_split_rendering(
split_bitstream = tmp_dir.joinpath("split.bit")
if renderer_fmt == "BINAURAL_SPLIT_PCM":
split_md_file = tmp_dir.joinpath("split_md.bin")
out_file_stem = f"{in_fmt}_{renderer_fmt}_{pre_trajectory.stem}_split_ext_{post_trajectory.stem}_config_{render_config.stem}_postrfr_{pre_rend_fr}_prerfr_{post_rend_fr}.wav"
out_file_stem = f"{in_fmt}_{renderer_fmt}_split_ext_config_{render_config.stem}_postrfr_{pre_rend_fr}_prerfr_{post_rend_fr}.wav"
if test_info.config.option.create_ref:
output_path_base = OUTPUT_PATH_REF
......@@ -343,7 +351,7 @@ def run_external_split_rendering(
if in_meta_files:
cmd[9:9] = ["-im", *in_meta_files]
run_cmd(cmd)
run_isar_ext_rend_cmd(cmd)
# run split renderer
cmd = SPLIT_POST_REND_CMD[:]
......@@ -363,7 +371,7 @@ def run_external_split_rendering(
if plc_error_pattern:
cmd[1:1] = ["-prbfi", str(plc_error_pattern)]
run_cmd(cmd)
run_isar_ext_rend_cmd(cmd)
if test_info.config.option.create_cut:
# CUT creation mode will run a comparison with REF
......