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

add xfail cases to test_codec_ROM_vs_file.py

parent c378d4e6
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -52,6 +52,8 @@ RENDERER_CMD = [str(TESTS_DIR.parent.parent.joinpath("IVAS_rend"))]

HRTF_BINARY_FILE_SAME_AS_ROM = "ivas_binaural_{}kHz.bin"
HRTF_BINARY_FILE_DIFF_FROM_ROM = "ivas_binaural_51_brir-lc_{}kHz.bin"
HRTF_FILES= [HRTF_BINARY_FILE_SAME_AS_ROM, HRTF_BINARY_FILE_DIFF_FROM_ROM]

SAMPLE_RATE = ["16", "32", "48"]

INPUT_FORMATS_MC = ["5_1", "5_1_2", "5_1_4", "7_1", "7_1_4"]  # "MONO", "STEREO",
+32 −16
Original line number Diff line number Diff line
@@ -32,13 +32,13 @@
import pytest

from tests.hrtf_binary_loading.utils import *
from .constants import HRTF_BINARY_FILE_SAME_AS_ROM, HRTF_BINARY_FILE_DIFF_FROM_ROM
from .constants import HRTF_FILES

""" Binary file """


@pytest.mark.parametrize("out_fs", SAMPLE_RATE)
@pytest.mark.parametrize("hrtf_file", [HRTF_BINARY_FILE_SAME_AS_ROM, HRTF_BINARY_FILE_DIFF_FROM_ROM])
@pytest.mark.parametrize("hrtf_file", HRTF_FILES)
def test_binary_file(test_info, hrtf_file, out_fs):
    check_binary_file(hrtf_file, out_fs)

@@ -49,7 +49,8 @@ def test_binary_file(test_info, hrtf_file, out_fs):
@pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL[:-1])
@pytest.mark.parametrize("out_fs", SAMPLE_RATE)
@pytest.mark.parametrize("in_fmt", INPUT_FORMATS_MC)
def test_multichannel_binaural_static(test_info, in_fmt, out_fmt, out_fs):
@pytest.mark.parametrize("hrtf_file", HRTF_FILES)
def test_multichannel_binaural_static(test_info, in_fmt, out_fmt, out_fs, hrtf_file):
    # if in_fmt in ["MONO", "STEREO"]:
    #    pytest.skip("MONO or STEREO to Binaural rendering unsupported")

@@ -69,6 +70,7 @@ def test_multichannel_binaural_static(test_info, in_fmt, out_fmt, out_fs):
        in_fs,
        out_fmt,
        out_fs,
        hrtf_file,
    )


@@ -76,8 +78,9 @@ def test_multichannel_binaural_static(test_info, in_fmt, out_fmt, out_fs):
@pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL[:-1])
@pytest.mark.parametrize("out_fs", SAMPLE_RATE)
@pytest.mark.parametrize("in_fmt", INPUT_FORMATS_MC)
@pytest.mark.parametrize("hrtf_file", HRTF_FILES)
def test_multichannel_binaural_headrotation(
    test_info, in_fmt, out_fmt, out_fs, trj_file
    test_info, in_fmt, out_fmt, out_fs, trj_file, hrtf_file
):
    # if in_fmt in ["MONO", "STEREO"]:
    #    pytest.skip("MONO or STEREO to Binaural rendering unsupported")
@@ -98,6 +101,7 @@ def test_multichannel_binaural_headrotation(
        in_fs,
        out_fmt,
        out_fs,
        hrtf_file,
        trj_file=str(TESTV_DIR.joinpath(f"{trj_file}.csv")),
    )

@@ -108,7 +112,8 @@ def test_multichannel_binaural_headrotation(
@pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL[:-1])
@pytest.mark.parametrize("fs", SAMPLE_RATE[1:])
@pytest.mark.parametrize("in_fmt", INPUT_FORMATS_SBA)
def test_sba_binaural_static(test_info, in_fmt, fs, out_fmt):
@pytest.mark.parametrize("hrtf_file", HRTF_FILES)
def test_sba_binaural_static(test_info, in_fmt, fs, out_fmt, hrtf_file):
    # -sba +/-Order : Scene Based Audio input format (Ambisonics ACN/SN3D)
    #                 where Order specifies the Ambisionics order (1-3)

@@ -124,6 +129,7 @@ def test_sba_binaural_static(test_info, in_fmt, fs, out_fmt):
        fs,
        out_fmt,
        fs,
        hrtf_file,
    )


@@ -131,7 +137,8 @@ def test_sba_binaural_static(test_info, in_fmt, fs, out_fmt):
@pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL[:-1])
@pytest.mark.parametrize("fs", SAMPLE_RATE[1:])
@pytest.mark.parametrize("in_fmt", INPUT_FORMATS_SBA)
def test_sba_binaural_headrotation(test_info, in_fmt, fs, out_fmt, trj_file):
@pytest.mark.parametrize("hrtf_file", HRTF_FILES)
def test_sba_binaural_headrotation(test_info, in_fmt, fs, out_fmt, trj_file, hrtf_file):
    # -sba +/-Order : Scene Based Audio input format (Ambisonics ACN/SN3D)
    #                 where Order specifies the Ambisionics order (1-3)

@@ -147,6 +154,7 @@ def test_sba_binaural_headrotation(test_info, in_fmt, fs, out_fmt, trj_file):
        fs,
        out_fmt,
        fs,
        hrtf_file,
        trj_file=str(TESTV_DIR.joinpath(f"{trj_file}.csv")),
    )

@@ -158,7 +166,8 @@ def test_sba_binaural_headrotation(test_info, in_fmt, fs, out_fmt, trj_file):
@pytest.mark.parametrize("fs", SAMPLE_RATE[-1:])
@pytest.mark.parametrize("in_dir", INPUT_FORMATS_MASA["dir"])
@pytest.mark.parametrize("in_tc", INPUT_FORMATS_MASA["tc"])
def test_masa_binaural_static(test_info, in_tc, in_dir, fs, out_fmt):
@pytest.mark.parametrize("hrtf_file", HRTF_FILES)
def test_masa_binaural_static(test_info, in_tc, in_dir, fs, out_fmt, hrtf_file):
    # -masa Ch File : MASA format
    #                 where Ch specifies the number of MASA input/transport channels (1 or 2)
    #                 and File specifies input file containing parametric MASA metadata
@@ -178,6 +187,7 @@ def test_masa_binaural_static(test_info, in_tc, in_dir, fs, out_fmt):
        fs,
        out_fmt,
        fs,
        hrtf_file,
    )


@@ -186,7 +196,8 @@ def test_masa_binaural_static(test_info, in_tc, in_dir, fs, out_fmt):
@pytest.mark.parametrize("fs", SAMPLE_RATE[-1:])
@pytest.mark.parametrize("in_dir", INPUT_FORMATS_MASA["dir"])
@pytest.mark.parametrize("in_tc", INPUT_FORMATS_MASA["tc"])
def test_masa_binaural_headrotation(test_info, in_tc, in_dir, fs, out_fmt, trj_file):
@pytest.mark.parametrize("hrtf_file", HRTF_FILES)
def test_masa_binaural_headrotation(test_info, in_tc, in_dir, fs, out_fmt, trj_file, hrtf_file):
    # -masa Ch File : MASA format
    #                 where Ch specifies the number of MASA input/transport channels (1 or 2)
    #                 and File specifies input file containing parametric MASA metadata
@@ -206,6 +217,7 @@ def test_masa_binaural_headrotation(test_info, in_tc, in_dir, fs, out_fmt, trj_f
        fs,
        out_fmt,
        fs,
        hrtf_file,
        trj_file=str(TESTV_DIR.joinpath(f"{trj_file}.csv")),
    )

@@ -216,7 +228,8 @@ def test_masa_binaural_headrotation(test_info, in_tc, in_dir, fs, out_fmt, trj_f
@pytest.mark.parametrize("out_fmt", [OUTPUT_FORMATS_BINAURAL[0]])
@pytest.mark.parametrize("out_fs", SAMPLE_RATE)
@pytest.mark.parametrize("in_fmt", INPUT_FORMATS_ISM)
def test_ism_binaural_static(test_info, in_fmt, out_fs, out_fmt):
@pytest.mark.parametrize("hrtf_file", HRTF_FILES)
def test_ism_binaural_static(test_info, in_fmt, out_fs, out_fmt, hrtf_file):
    # -ism [+]Ch Files : ISM format
    #                    where Ch specifies the number of ISMs (1-4)
    #                    and Files specify input files containing metadata, one file per object
@@ -241,6 +254,7 @@ def test_ism_binaural_static(test_info, in_fmt, out_fs, out_fmt):
        in_fs,
        out_fmt,
        out_fs,
        hrtf_file,
    )


@@ -248,7 +262,8 @@ def test_ism_binaural_static(test_info, in_fmt, out_fs, out_fmt):
@pytest.mark.parametrize("out_fmt", [OUTPUT_FORMATS_BINAURAL[0]])
@pytest.mark.parametrize("out_fs", SAMPLE_RATE)
@pytest.mark.parametrize("in_fmt", INPUT_FORMATS_ISM)
def test_ism_binaural_headrotation(test_info, in_fmt, out_fs, out_fmt, trj_file):
@pytest.mark.parametrize("hrtf_file", HRTF_FILES)
def test_ism_binaural_headrotation(test_info, in_fmt, out_fs, out_fmt, trj_file, hrtf_file):
    # -ism [+]Ch Files : ISM format
    #                    where Ch specifies the number of ISMs (1-4)
    #                    and Files specify input files containing metadata, one file per object
@@ -273,6 +288,7 @@ def test_ism_binaural_headrotation(test_info, in_fmt, out_fs, out_fmt, trj_file)
        in_fs,
        out_fmt,
        out_fs,
        hrtf_file,
        trj_file=str(TESTV_DIR.joinpath(f"{trj_file}.csv")),
    )

@@ -283,7 +299,8 @@ def test_ism_binaural_headrotation(test_info, in_fmt, out_fs, out_fmt, trj_file)
@pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL[-1:])
@pytest.mark.parametrize("out_fs", SAMPLE_RATE)
@pytest.mark.parametrize("in_fmt", INPUT_FORMATS_ISM)
def test_ism_binaural_roomreverb_static(test_info, in_fmt, out_fs, out_fmt):
@pytest.mark.parametrize("hrtf_file", HRTF_FILES)
def test_ism_binaural_roomreverb_static(test_info, in_fmt, out_fs, out_fmt, hrtf_file):
    # -ism [+]Ch Files : ISM format
    #                    where Ch specifies the number of ISMs (1-4)
    #                    and Files specify input files containing metadata, one file per object
@@ -308,6 +325,7 @@ def test_ism_binaural_roomreverb_static(test_info, in_fmt, out_fs, out_fmt):
        in_fs,
        out_fmt,
        out_fs,
        hrtf_file,
    )


@@ -315,13 +333,10 @@ def test_ism_binaural_roomreverb_static(test_info, in_fmt, out_fs, out_fmt):
@pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL[-1:])
@pytest.mark.parametrize("out_fs", SAMPLE_RATE)
@pytest.mark.parametrize("in_fmt", INPUT_FORMATS_ISM)
@pytest.mark.parametrize("hrtf_file", HRTF_FILES)
def test_ism_binaural_roomreverb_headrotation(
    test_info, in_fmt, out_fs, out_fmt, trj_file
    test_info, in_fmt, out_fs, out_fmt, trj_file, hrtf_file
):
    # -ism [+]Ch Files : ISM format
    #                    where Ch specifies the number of ISMs (1-4)
    #                    and Files specify input files containing metadata, one file per object

    in_fs = 48
    bitrate = BITRATE_ISM[in_fmt]
    option_list = ["-ism", in_fmt]
@@ -342,5 +357,6 @@ def test_ism_binaural_roomreverb_headrotation(
        in_fs,
        out_fmt,
        out_fs,
        hrtf_file,
        trj_file=str(TESTV_DIR.joinpath(f"{trj_file}.csv")),
    )
+17 −12
Original line number Diff line number Diff line
@@ -141,9 +141,7 @@ def get_option_list_str(option_list):


def check_binary_file(hrtf_file, out_fs):
    with open(
        str(HRTF_BINARY_DIR.joinpath(hrtf_file.format(out_fs))), "rb"
    ) as file:
    with open(str(HRTF_BINARY_DIR.joinpath(hrtf_file.format(out_fs))), "rb") as file:
        binary_data = file.read()

        # [Declaration of the binary file]
@@ -286,13 +284,14 @@ def compare_rom_vs_binary(
    in_fs,
    out_fmt,
    out_fs,
    hrtf_file: str,
    keep_file: Optional[bool] = False,
    trj_file: Optional[str] = None,
):
    option_str = "_".join(get_option_list_str(option_list_enc))
    file_ext = f"_{option_str or ''}_{bitrate or ''}_{in_fs or ''}-{out_fs or ''}_{out_fmt or ''}-{uuid.uuid1()} "

    # check_binary_file(out_fs)
    xfail = hrtf_file == HRTF_BINARY_FILE_DIFF_FROM_ROM

    input_path = TESTV_DIR.joinpath(in_file).with_suffix(".wav")
    bitstream_path = BITSTREAM_DIR.joinpath(in_file + file_ext)
@@ -311,19 +310,26 @@ def compare_rom_vs_binary(
    )
    out_rom, out_rom_fs = pyaudio3dtools.audiofile.readfile(out_rom_path)

    hrtf_file = HRTF_BINARY_FILE.format(out_fs)
    if hrtf_file  is not None:
    hrtf_file = hrtf_file.format(out_fs)
    if trj_file is not None:
        option_list_dec.extend(["-hrtf", str(HRTF_BINARY_DIR.joinpath(hrtf_file))])
    else:
        option_list_dec = ["-hrtf", str(HRTF_BINARY_DIR.joinpath(hrtf_file))]

    out_bin_path = DEC_BINARY_DIR.joinpath(in_file + file_ext).with_suffix(".wav")
    run_decoder(
        out_fmt, out_fs, bitstream_path, out_bin_path, add_option_list=option_list_dec
    )
    out_bin, out_bin_fs = pyaudio3dtools.audiofile.readfile(out_bin_path)

    check_BE(test_info, out_rom, out_rom_fs, out_bin, out_bin_fs)
    check_BE(
        test_info,
        out_rom,
        out_rom_fs,
        out_bin,
        out_bin_fs,
        xfail=xfail,
    )
    if keep_file == False:
        os.remove(bitstream_path)
        os.remove(out_rom_path)
@@ -345,7 +351,6 @@ def compare_renderer_vs_renderer_with_binary_hrir(
    config_file: Optional[str] = None,
    frame_size: Optional[str] = "20ms",
    hrir_name="ivas_binaural_48kHz.bin",
    # hrir_name="ivas_binaural_51_brir-lc_48kHz.bin",
    keep_file=False,
):
    hrtf_file_dir = SCRIPTS_DIR.joinpath(
+9 −4
Original line number Diff line number Diff line
@@ -70,6 +70,7 @@ def check_BE(
    ref_fs: int,
    cut: np.ndarray,
    cut_fs: int,
    xfail: bool = False,
):
    if ref is None or np.array_equal(ref, np.zeros_like(ref)):
        pytest.fail("REF signal does not exist or is zero!")
@@ -88,7 +89,11 @@ def check_BE(
        cut = np.pad(cut, [(0, ref.shape[0] - cut.shape[0]), (0, 0)])

    # check max_diff as well, since compare_audio_arrays will try to adjust for small delay differences
    if not np.allclose(ref, cut, rtol=0, atol=2) and max_diff > 2:
    diff_found = not np.allclose(ref, cut, rtol=0, atol=2) and max_diff > 2
    if diff_found:
        if xfail:
            pytest.xfail(f"Expected diff between CuT and REF!")
        else:
            pytest.fail(
                f"CuT not BE to REF! SNR : {snr:3.2f} dB, Gain CuT: {gain_b:1.3f}, Max Diff = {int(max_diff)}"
            )