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

add testcases with external hrtf file

parent d23eb6d2
Loading
Loading
Loading
Loading
+1 −8
Original line number Diff line number Diff line
@@ -28,17 +28,10 @@ accordance with the laws of the Federal Republic of Germany excluding its confli
the United Nations Convention on Contracts on the International Sales of Goods.
"""

import os
from pathlib import Path
import filecmp
import subprocess
from ..testconfig import MD5_REF_DICT
from .constants import TESTVECTOR_FOR_INPUT_FORMAT

HERE = Path(__file__).parent
TESTV_PATH = Path(os.environ.get("BE_TESTV_DIR", HERE.joinpath("testv")))
REF_PATH = Path(os.environ.get("BE_REF_DIR", HERE.joinpath("ref")))
DUT_PATH = HERE.joinpath("dut")
from .constants import TESTVECTOR_FOR_INPUT_FORMAT, TESTV_PATH, REF_PATH


def is_be_to_ref(dut_file):
+52 −21
Original line number Diff line number Diff line
@@ -29,6 +29,13 @@ the United Nations Convention on Contracts on the International Sales of Goods.
"""

from itertools import product
from pathlib import Path
import os

HERE = Path(__file__).parent
TESTV_PATH = Path(os.environ.get("BE_TESTV_DIR", HERE.joinpath("testv")))
REF_PATH = Path(os.environ.get("BE_REF_DIR", HERE.joinpath("ref")))
DUT_PATH = HERE.joinpath("dut")


def collapse_into_list_of_pairs(params):
@@ -208,7 +215,9 @@ OUTPUT_FORMATS_ALL = [
    "BINAURAL_ROOM_REVERB",
]
OUTPUT_FORMATS_BINAURAL = OUTPUT_FORMATS_ALL[-3:]
OUTPUT_FORMATS_NON_BINAURAL = [f for f in OUTPUT_FORMATS_ALL if f not in OUTPUT_FORMATS_BINAURAL]
OUTPUT_FORMATS_NON_BINAURAL = [
    f for f in OUTPUT_FORMATS_ALL if f not in OUTPUT_FORMATS_BINAURAL
]


### -------------- encoder parameter lists --------------
@@ -408,10 +417,20 @@ DECODER_CONST_BR_NO_BINAURAL_CHANNELBASED_AND_MASA = (
    )
)
DECODER_CONST_BR_NO_BINAURAL_OBJECTBASED = collapse_into_list_of_pairs(
    product(ISM_PARAMS, OUTPUT_FORMATS_NON_BINAURAL, SAMPLING_RATES_ALL, BITSTREAM_PROCESSING)
    product(
        ISM_PARAMS,
        OUTPUT_FORMATS_NON_BINAURAL,
        SAMPLING_RATES_ALL,
        BITSTREAM_PROCESSING,
    )
)
DECODER_CONST_BR_NO_BINAURAL_SCENEBASED = collapse_into_list_of_pairs(
    product(SBA_PARAMS, OUTPUT_FORMATS_NON_BINAURAL, SAMPLING_RATES_ALL, BITSTREAM_PROCESSING)
    product(
        SBA_PARAMS,
        OUTPUT_FORMATS_NON_BINAURAL,
        SAMPLING_RATES_ALL,
        BITSTREAM_PROCESSING,
    )
)
DECODER_CONST_BR_NO_BINAURAL_COMBINED_PARAMS = collapse_into_list_of_pairs(
    product(
@@ -424,16 +443,25 @@ DECODER_CONST_BR_NO_BINAURAL_COMBINED_PARAMS = collapse_into_list_of_pairs(

# parameters for const bitrate testcases with binaural output
# TODO: add parameters for all the binaural output options
DECODER_CONST_BR_BINAURAL_CHANNELBASED_AND_MASA = (
    collapse_into_list_of_pairs(

BINAURAL_HRTF_NONE = "HRTFdefault"
BINAURAL_HRTF_EXT_REPO = "HRFText_repo"
HRTF_PATHS = {
    BINAURAL_HRTF_EXT_REPO: HERE.joinpath(
        "../../scripts/binauralRenderer_interface/binaural_renderers_hrtf_data/ivas_binaural_{fs}kHz.bin"
    )
    .resolve()
    .absolute()
}

DECODER_CONST_BR_BINAURAL_MC_AND_MASA = collapse_into_list_of_pairs(
    product(
        MC_PARAMS,
        OUTPUT_FORMATS_BINAURAL,
        SAMPLING_RATES_ALL,
        BITSTREAM_PROCESSING,
    )
    )
    + collapse_into_list_of_pairs(
) + collapse_into_list_of_pairs(
    product(
        MASA_PARAMS,
        OUTPUT_FORMATS_BINAURAL,
@@ -441,12 +469,15 @@ DECODER_CONST_BR_BINAURAL_CHANNELBASED_AND_MASA = (
        BITSTREAM_PROCESSING,
    )
)
)
DECODER_CONST_BR_BINAURAL_OBJECTBASED = collapse_into_list_of_pairs(
    product(ISM_PARAMS, OUTPUT_FORMATS_BINAURAL, SAMPLING_RATES_ALL, BITSTREAM_PROCESSING)
    product(
        ISM_PARAMS, OUTPUT_FORMATS_BINAURAL, SAMPLING_RATES_ALL, BITSTREAM_PROCESSING
    )
)
DECODER_CONST_BR_BINAURAL_SCENEBASED = collapse_into_list_of_pairs(
    product(SBA_PARAMS, OUTPUT_FORMATS_BINAURAL, SAMPLING_RATES_ALL, BITSTREAM_PROCESSING)
    product(
        SBA_PARAMS, OUTPUT_FORMATS_BINAURAL, SAMPLING_RATES_ALL, BITSTREAM_PROCESSING
    )
)
DECODER_CONST_BR_BINAURAL_COMBINED_PARAMS = collapse_into_list_of_pairs(
    product(
+28 −7
Original line number Diff line number Diff line
@@ -34,8 +34,17 @@ from contextlib import contextmanager
from pathlib import Path
from tempfile import TemporaryDirectory
import subprocess
from .. import DUT_PATH, REF_PATH, TESTV_PATH, HERE, is_be_to_ref, get_bitstream_path
from ..constants import BS_PROC_FER_15, BS_PROC_JBM_DLY_PROF_5
from .. import is_be_to_ref, get_bitstream_path
from ..constants import (
    DUT_PATH,
    REF_PATH,
    TESTV_PATH,
    HERE,
    BS_PROC_FER_15,
    BS_PROC_JBM_DLY_PROF_5,
    BINAURAL_HRTF_NONE,
    HRTF_PATHS,
)


def create_head_rotation_file(
@@ -64,16 +73,25 @@ def create_head_rotation_file(
    return out_path


def get_output_path(bitstream_path, output_format, output_sampling_rate):
    output_name = (
        f"{bitstream_path.stem}.dec-{output_format}-{output_sampling_rate}kHz.wav"
    )
def get_output_path(
    bitstream_path, output_format, output_sampling_rate, bitstream_processing, suffix=""
):
    if suffix != "":
        suffix = f"-{suffix}"
    output_name = f"{bitstream_path.stem}.dec-{output_format}-{output_sampling_rate}kHz-{bitstream_processing}{suffix}.wav"
    return DUT_PATH.joinpath(output_name)


@contextmanager
def get_bitstream_and_options(
    testv_name, encoder_format, bitrate, sampling_rate, dtx, processing, suffix=""
    testv_name,
    encoder_format,
    bitrate,
    sampling_rate,
    dtx,
    processing,
    hrtf=BINAURAL_HRTF_NONE,
    suffix="",
):
    """
    Utility to get either the stored reference bitstream or the processed version as a temporary file
@@ -120,6 +138,9 @@ def get_bitstream_and_options(
            bitstream = bitstream_out
            options.append("-VOIP")

        if hrtf != BINAURAL_HRTF_NONE:
            options.extend(["-hrtf", str(HRTF_PATHS[hrtf]).format(fs=sampling_rate)])

        yield bitstream, options


+21 −6
Original line number Diff line number Diff line
@@ -34,11 +34,12 @@ from .. import get_testv_path
from ..constants import *


@pytest.mark.parametrize("hrtf", [BINAURAL_HRTF_NONE, BINAURAL_HRTF_EXT_REPO])
@pytest.mark.parametrize(
    "input_format,bitrate,input_sampling_rate,dtx,output_format,output_sampling_rate,bitstream_processing",
    DECODER_CONST_BR_BINAURAL_CHANNELBASED_AND_MASA,
    DECODER_CONST_BR_BINAURAL_MC_AND_MASA,
)
def test_decoder_channelbased_and_masa(
def test_decoder_mc_and_masa(
    input_format,
    bitrate,
    input_sampling_rate,
@@ -46,6 +47,7 @@ def test_decoder_channelbased_and_masa(
    output_format,
    output_sampling_rate,
    bitstream_processing,
    hrtf,
    dut_decoder_frontend,
    update_ref,
):
@@ -56,9 +58,16 @@ def test_decoder_channelbased_and_masa(
        bitrate,
        input_sampling_rate,
        dtx,
        hrtf=hrtf,
        processing=bitstream_processing,
    ) as (ref_bitstream, options):
        dut_output = get_output_path(ref_bitstream, output_format, output_sampling_rate)
        dut_output = get_output_path(
            ref_bitstream,
            output_format,
            output_sampling_rate,
            bitstream_processing,
            suffix=hrtf,
        )

        run_check(
            str(ref_bitstream),
@@ -102,7 +111,9 @@ def test_decoder_objectbased(
        suffix=suffix,
        processing=bitstream_processing,
    ) as (ref_bitstream, options):
        dut_output = get_output_path(ref_bitstream, output_format, output_sampling_rate)
        dut_output = get_output_path(
            ref_bitstream, output_format, output_sampling_rate, bitstream_processing
        )

        run_check(
            str(ref_bitstream),
@@ -144,7 +155,9 @@ def test_decoder_scenebased(
        suffix=suffix,
        processing=bitstream_processing,
    ) as (ref_bitstream, options):
        dut_output = get_output_path(ref_bitstream, output_format, output_sampling_rate)
        dut_output = get_output_path(
            ref_bitstream, output_format, output_sampling_rate, bitstream_processing
        )

        run_check(
            str(ref_bitstream),
@@ -192,7 +205,9 @@ def test_decoder_combined_formats(
        suffix=suffix,
        processing=bitstream_processing,
    ) as (ref_bitstream, options):
        dut_output = get_output_path(ref_bitstream, output_format, output_sampling_rate)
        dut_output = get_output_path(
            ref_bitstream, output_format, output_sampling_rate, bitstream_processing
        )

        run_check(
            str(ref_bitstream),
+12 −4
Original line number Diff line number Diff line
@@ -58,7 +58,9 @@ def test_decoder_channelbased_and_masa(
        dtx,
        processing=bitstream_processing,
    ) as (ref_bitstream, options):
        dut_output = get_output_path(ref_bitstream, output_format, output_sampling_rate)
        dut_output = get_output_path(
            ref_bitstream, output_format, output_sampling_rate, bitstream_processing
        )

        run_check(
            str(ref_bitstream),
@@ -102,7 +104,9 @@ def test_decoder_objectbased(
        suffix=suffix,
        processing=bitstream_processing,
    ) as (ref_bitstream, options):
        dut_output = get_output_path(ref_bitstream, output_format, output_sampling_rate)
        dut_output = get_output_path(
            ref_bitstream, output_format, output_sampling_rate, bitstream_processing
        )

        run_check(
            str(ref_bitstream),
@@ -144,7 +148,9 @@ def test_decoder_scenebased(
        suffix=suffix,
        processing=bitstream_processing,
    ) as (ref_bitstream, options):
        dut_output = get_output_path(ref_bitstream, output_format, output_sampling_rate)
        dut_output = get_output_path(
            ref_bitstream, output_format, output_sampling_rate, bitstream_processing
        )

        run_check(
            str(ref_bitstream),
@@ -192,7 +198,9 @@ def test_decoder_combined_formats(
        suffix=suffix,
        processing=bitstream_processing,
    ) as (ref_bitstream, options):
        dut_output = get_output_path(ref_bitstream, output_format, output_sampling_rate)
        dut_output = get_output_path(
            ref_bitstream, output_format, output_sampling_rate, bitstream_processing
        )

        run_check(
            str(ref_bitstream),
Loading