Commit 11477dfb authored by Jan Kiene's avatar Jan Kiene
Browse files

Merge branch 'main' into...

Merge branch 'main' into 922-use-precomputed-HRTF-average-LR-energies-and-IAC-in-all-renderers-test-cases
parents 72dae489 e8ae579a
Loading
Loading
Loading
Loading
Loading
+31 −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.
"""
+1 −0
Original line number Diff line number Diff line
!.gitignore
+44 −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.
"""


def pytest_addoption(parser):
    parser.addoption(
        "--create_ref",
        action="store_true",
        default=False,
    )
    parser.addoption(
        "--create_cut",
        action="store_true",
        default=False,
    )
+236 −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 re
from pathlib import Path

from tests.renderer.constants import (
    OUTPUT_FORMATS_BINAURAL,
    SCRIPTS_DIR,
    TESTV_DIR,
)

TESTS_DIR = Path(__file__).parent

BITSTREAM_DIR = TESTS_DIR.joinpath("bitstream")
DEC_ROM_DIR = TESTS_DIR.joinpath("dec_out_rom")
HRTF_BINARY_DIR = SCRIPTS_DIR.joinpath(
    "binauralRenderer_interface", "binaural_renderers_hrtf_data"
)
DEC_BINARY_DIR = TESTS_DIR.joinpath("dec_out_bin")

ENCODER_CMD = [str(TESTS_DIR.parent.parent.joinpath("IVAS_cod"))]

DECODER_CMD = [str(TESTS_DIR.parent.parent.joinpath("IVAS_dec"))]

RENDERER_CMD = [str(TESTS_DIR.parent.parent.joinpath("IVAS_rend"))]

HRTF_BINARY_FILE = "ivas_binaural_{}kHz.bin"
SAMPLE_RATE = ["16", "32", "48"]

INPUT_FORMATS_MC = ["5_1", "5_1_2", "5_1_4", "7_1", "7_1_4"]  # "MONO", "STEREO",
INPUT_FORMATS_SBA = ["1", "2", "3"]
INPUT_FORMATS_ISM = ["1", "2", "3", "4"]
INPUT_FORMATS_MASA = {"tc": ["1", "2"], "dir": ["1", "2"]}
INPUT_FORMATS_MASA_RENDERER = ["MASA1", "MASA2"]


FORMAT_TO_FILE_MC_WOEXT = {
    "5_1": "stv51MC{}c",
    "7_1": "stv71MC{}c",
    "5_1_2": "stv512MC{}c",
    "5_1_4": "stv514MC{}c",
    "7_1_4": "stv714MC{}c",
}
FORMAT_TO_FILE_SBA_WOEXT = {
    "1": "stvFOA{}c",
    "2": "stv2OA{}c",
    "3": "stv3OA{}c",
}
FORMAT_TO_FILE_ISM_WOEXT = "stv{}ISM{}s"
FORMAT_TO_FILE_MASA_WOEXT = "stv{}MASA{}TC{}c"

BITRATE_ISM = {
    "1": 96000,
    "2": 160000,
    "3": 384000,
    "4": 512000,
}

FORMAT_TO_METADATA_FILES = {"MASA": "stv{}MASA{}TC{}c.met", "ISM": "stvISM{}.csv"}

FORMAT_TO_METADATA_FILES_RENDERER = {
    "ISM1": [str(TESTV_DIR.joinpath("stvISM1.csv"))],
    "ISM2": [
        str(TESTV_DIR.joinpath("stvISM1.csv")),
        str(TESTV_DIR.joinpath("stvISM2.csv")),
    ],
    "ISM3": [
        str(TESTV_DIR.joinpath("stvISM1.csv")),
        str(TESTV_DIR.joinpath("stvISM2.csv")),
        str(TESTV_DIR.joinpath("stvISM3.csv")),
    ],
    "ISM4": [
        str(TESTV_DIR.joinpath("stvISM1.csv")),
        str(TESTV_DIR.joinpath("stvISM2.csv")),
        str(TESTV_DIR.joinpath("stvISM3.csv")),
        str(TESTV_DIR.joinpath("stvISM4.csv")),
    ],
    "NDP_ISM4": [
        str(TESTV_DIR.joinpath("stvISM1.csv")),
        str(TESTV_DIR.joinpath("stvISM2_non-diegetic-pan.csv")),
        str(TESTV_DIR.joinpath("stvISM3.csv")),
        str(TESTV_DIR.joinpath("stvISM4.csv")),
    ],
    "MASA1": [str(TESTV_DIR.joinpath("stv1MASA1TC48c.met"))],
    "MASA2": [str(TESTV_DIR.joinpath("stv2MASA2TC48c.met"))],
}


HR_TRAJECTORIES_TO_TEST = ["headrot_case00_3000_q", "headrot"]

HR_TRAJECTORIES_TO_TEST_RENDERER = ["full_circle_in_15s"]


with open(
    str(TESTS_DIR.parent.parent.joinpath("lib_com")) + "/ivas_cnst.h", "r"
) as ivas_cnst_file:
    ivas_cnst = ivas_cnst_file.read()

    # Declare renderer_types
    rtid = ivas_cnst.find("RENDERER_TYPE;")
    rte_c = ivas_cnst[ivas_cnst[:rtid].rfind("{") : ivas_cnst[:rtid].rfind("}")]
    enumid = 0
    for rtid1 in [m.start() for m in re.finditer("RENDERER_", rte_c)]:
        rtid2 = rte_c[rtid1:].find(",")
        if rtid2 == -1:
            rtid2 = rte_c[rtid1:].find(" ")
        globals()[rte_c[rtid1 : rtid1 + rtid2]] = enumid
        enumid += 1

    # Declare binaural_input_audio_config
    biacid = ivas_cnst.find("BINAURAL_INPUT_AUDIO_CONFIG;")
    biace_c = ivas_cnst[ivas_cnst[:biacid].rfind("{") : ivas_cnst[:biacid].rfind("}")]
    enumid = 0
    for biacid1 in [
        m.start() for m in re.finditer("BINAURAL_INPUT_AUDIO_CONFIG_", biace_c)
    ]:
        biacid2 = biace_c[biacid1:].find(",")
        if biacid2 == -1:
            biacid2 = biace_c[biacid1:].find(" ")
        globals()[biace_c[biacid1 : biacid1 + biacid2]] = enumid
        enumid += 1

HRTF_READER_RENDERER_BINAURAL_INVALID = 0
HRTF_READER_RENDERER_BINAURAL_FASTCONV = 1
HRTF_READER_RENDERER_BINAURAL_FASTCONV_ROOM = 2
HRTF_READER_RENDERER_BINAURAL_PARAMETRIC = 3
HRTF_READER_RENDERER_BINAURAL_PARAMETRIC_ROOM = 4
HRTF_READER_RENDERER_BINAURAL_OBJECTS_TD = 5
HRTF_READER_RENDERER_BINAURAL_MIXER_CONV = 6
HRTF_READER_RENDERER_BINAURAL_MIXER_CONV_ROOM = 7
HRTF_READER_RENDERER_BINAURAL_REVERB_ALL = 8

BINAURAL_INPUT_AUDIO_CONFIG_INVALID = 0
BINAURAL_INPUT_AUDIO_CONFIG_COMBINED = 1
BINAURAL_INPUT_AUDIO_CONFIG_HOA3 = 2
BINAURAL_INPUT_AUDIO_CONFIG_HOA2 = 3
BINAURAL_INPUT_AUDIO_CONFIG_FOA = 4
BINAURAL_INPUT_AUDIO_CONFIG_UNDEFINED = 5

REQ_HRTF_CONFIG = [
    {
        "renderer_type": HRTF_READER_RENDERER_BINAURAL_FASTCONV,
        "input_configuration": BINAURAL_INPUT_AUDIO_CONFIG_COMBINED,
        "sampling_frequency": 48000,
    },
    {
        "renderer_type": HRTF_READER_RENDERER_BINAURAL_FASTCONV,
        "input_configuration": BINAURAL_INPUT_AUDIO_CONFIG_HOA3,
        "sampling_frequency": 48000,
    },
    {
        "renderer_type": HRTF_READER_RENDERER_BINAURAL_FASTCONV,
        "input_configuration": BINAURAL_INPUT_AUDIO_CONFIG_HOA2,
        "sampling_frequency": 48000,
    },
    {
        "renderer_type": HRTF_READER_RENDERER_BINAURAL_FASTCONV,
        "input_configuration": BINAURAL_INPUT_AUDIO_CONFIG_FOA,
        "sampling_frequency": 48000,
    },
    {
        "renderer_type": HRTF_READER_RENDERER_BINAURAL_FASTCONV_ROOM,
        "input_configuration": BINAURAL_INPUT_AUDIO_CONFIG_COMBINED,
        "sampling_frequency": 48000,
    },
    {
        "renderer_type": HRTF_READER_RENDERER_BINAURAL_PARAMETRIC_ROOM,
        "input_configuration": BINAURAL_INPUT_AUDIO_CONFIG_UNDEFINED,
        "sampling_frequency": 48000,
    },
    {
        "renderer_type": HRTF_READER_RENDERER_BINAURAL_OBJECTS_TD,
        "input_configuration": BINAURAL_INPUT_AUDIO_CONFIG_UNDEFINED,
        "sampling_frequency": -1,
    },
    {
        "renderer_type": HRTF_READER_RENDERER_BINAURAL_MIXER_CONV,
        "input_configuration": BINAURAL_INPUT_AUDIO_CONFIG_COMBINED,
        "sampling_frequency": -1,
    },
    {
        "renderer_type": HRTF_READER_RENDERER_BINAURAL_MIXER_CONV,
        "input_configuration": BINAURAL_INPUT_AUDIO_CONFIG_HOA3,
        "sampling_frequency": -1,
    },
    {
        "renderer_type": HRTF_READER_RENDERER_BINAURAL_MIXER_CONV,
        "input_configuration": BINAURAL_INPUT_AUDIO_CONFIG_HOA2,
        "sampling_frequency": -1,
    },
    {
        "renderer_type": HRTF_READER_RENDERER_BINAURAL_MIXER_CONV,
        "input_configuration": BINAURAL_INPUT_AUDIO_CONFIG_FOA,
        "sampling_frequency": -1,
    },
    {
        "renderer_type": HRTF_READER_RENDERER_BINAURAL_MIXER_CONV_ROOM,
        "input_configuration": BINAURAL_INPUT_AUDIO_CONFIG_COMBINED,
        "sampling_frequency": -1,
    },
    {
        "renderer_type": HRTF_READER_RENDERER_BINAURAL_REVERB_ALL,
        "input_configuration": BINAURAL_INPUT_AUDIO_CONFIG_UNDEFINED,
        "sampling_frequency": -1,
    },
]
+1 −0
Original line number Diff line number Diff line
!.gitignore
Loading