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

Merge branch 'add_ci' into 'main'

Add ci and first tests

See merge request !4
parents e898d309 1e95a4c2
Loading
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -7,6 +7,7 @@ venv/
.idea/
.DS_Store
*.wav
!tests/data/**/*.wav
*.pcm
*.bs
*.192

.gitlab-ci.yml

0 → 100644
+80 −0
Original line number Diff line number Diff line
variables:
  CODEC_DIR: "/codec"


default:
  interruptible: true


stages:
  - test
  - analyze


# script anchor for updating the codec repo
.get-codec-binaries: &get-codec-binaries
  - dir=$(pwd)
  # NOTE: CODEC_DIR has to be in PATH
  - cd $CODEC_DIR
  # make sure that we are at latest main
  - git pull
  # only builds if code has actually changed
  - make -j
  - cd $dir


# ------------------------------------
# functionality tests
# ------------------------------------

# test the format conversion only
test_audiotools_convert:
  stage: test
  tags:
    - linux
  script:
    - python3 -m pytest -n auto tests/test_audiotools_convert.py

# run some test configs for item creation
test_processing:
  stage: test
  tags:
    - linux
  script:
    - *get-codec-binaries
    - python3 -m pytest -n auto tests/test_processing.py

# ------------------------------------
# static analysis/formatting tests
# ------------------------------------

lint:
  stage: analyze
  tags:
    - linux
  allow_failure: true
  script:
    - flake8 --max-line-length 88 --extend-ignore=E203,E501,E741

format:
  stage: analyze
  variables:
    ARTIFACT_BASE_NAME: "mr-$CI_MERGE_REQUEST_IID--sha-$CI_COMMIT_SHORT_SHA--formatting-fix"
    ARTIFACT_FOLDER: "formatting-patch"
  tags:
    - linux
  allow_failure: true
  script:
    - mkdir $ARTIFACT_FOLDER

    - isort --profile black . || ret_val_isort=$?
    - black . || ret_val_black=$?
    - git diff > "${ARTIFACT_FOLDER}/${ARTIFACT_BASE_NAME}.patch"

    - if [[ $ret_val_isort != 0 || $ret_val_black != 0 ]]; then exit 1; fi
  artifacts:
    paths:
      - "$ARTIFACT_FOLDER"
    when: on_failure
    name: "$ARTIFACT_BASE_NAME"
    expose_as: "formatting patch"

tests/README.md

0 → 100644
+38 −0
Original line number Diff line number Diff line
<!---

   (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.

-->

# Ivas processing scripts - Tests

The files contained in this folder are not part of the processing scripts themselves.
They are used only for testing the scripts during development and are not required to use or run the processing scripts for generating listening tests.
Additional dependencies for the files in this folder are not required for running the scripts and are thus no dependencies of the processing scripts themselves.

tests/__init__.py

0 → 100644
+38 −0
Original line number Diff line number Diff line
#  (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 pytest
from pathlib import Path
from .constants import OUTPUT_PATH_REF, OUTPUT_PATH_CUT


@pytest.fixture(scope="session", autouse=True)
def setup_test_environment():
    Path(OUTPUT_PATH_REF).mkdir(exist_ok=True)
    Path(OUTPUT_PATH_CUT).mkdir(exist_ok=True)

tests/constants.py

0 → 100644
+202 −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.
#

from pathlib import PurePath

""" Set up paths """
TESTS_DIR = PurePath(__file__).parent
TEST_VECTOR_DIR = TESTS_DIR.joinpath("data")

ISM_METADATA_DIR = TEST_VECTOR_DIR.joinpath("ism_metadata")
MASA_METADATA_DIR = TEST_VECTOR_DIR.joinpath("masa")
SCENE_DESC_DIR = TEST_VECTOR_DIR.joinpath("scene_description")

OUTPUT_PATH_REF = TESTS_DIR.joinpath("ref")
OUTPUT_PATH_CUT = TESTS_DIR.joinpath("cut")

CUSTOM_LAYOUT_DIR = TEST_VECTOR_DIR.joinpath("ls_layouts")
HR_TRAJECTORY_DIR = TEST_VECTOR_DIR.joinpath("trajectories")

""" Renderer commandline template """
RENDERER_CMD = [
    str(TESTS_DIR.parent.parent.joinpath("IVAS_rend")),
    "-i",
    "",  # 2 -> input file
    "-if",
    "",  # 4 -> input format
    "-o",
    "/dev/null",  # 6 -> output file
    "-of",
    "",  # 8 -> output format
    "-fs",
    "48",  # 10 -> input fs
    # "--no_delay_cmp",
    # "-ndl",
    "-q",
]

""" Format to file mappings """
NCHAN_TO_FILE = {
    1: TEST_VECTOR_DIR.joinpath("spectral").joinpath("spectral_test_1ch_48kHz.wav"),
    2: TEST_VECTOR_DIR.joinpath("spectral").joinpath("spectral_test_2ch_48kHz.wav"),
    3: TEST_VECTOR_DIR.joinpath("spectral").joinpath("spectral_test_3ch_48kHz.wav"),
    4: TEST_VECTOR_DIR.joinpath("spectral").joinpath("spectral_test_4ch_48kHz.wav"),
    5: TEST_VECTOR_DIR.joinpath("spectral").joinpath("spectral_test_5ch_48kHz.wav"),
    6: TEST_VECTOR_DIR.joinpath("spectral").joinpath("spectral_test_6ch_48kHz.wav"),
    8: TEST_VECTOR_DIR.joinpath("spectral").joinpath("spectral_test_8ch_48kHz.wav"),
    9: TEST_VECTOR_DIR.joinpath("spectral").joinpath("spectral_test_9ch_48kHz.wav"),
    10: TEST_VECTOR_DIR.joinpath("spectral").joinpath("spectral_test_10ch_48kHz.wav"),
    11: TEST_VECTOR_DIR.joinpath("spectral").joinpath("spectral_test_11ch_48kHz.wav"),
    12: TEST_VECTOR_DIR.joinpath("spectral").joinpath("spectral_test_12ch_48kHz.wav"),
    15: TEST_VECTOR_DIR.joinpath("spectral").joinpath("spectral_test_15ch_48kHz.wav"),
    16: TEST_VECTOR_DIR.joinpath("spectral").joinpath("spectral_test_16ch_48kHz.wav"),
}

FORMAT_TO_FILE = {
    "MONO": NCHAN_TO_FILE[1],
    "STEREO": NCHAN_TO_FILE[2],
    "5_1": NCHAN_TO_FILE[6],
    "7_1": NCHAN_TO_FILE[8],
    "5_1_2": NCHAN_TO_FILE[8],
    "5_1_4": NCHAN_TO_FILE[10],
    "7_1_4": NCHAN_TO_FILE[12],
    "FOA": NCHAN_TO_FILE[4],
    "HOA2": NCHAN_TO_FILE[9],
    "HOA3": NCHAN_TO_FILE[16],
    "ISM1": NCHAN_TO_FILE[1],
    "ISM2": NCHAN_TO_FILE[2],
    "ISM3": NCHAN_TO_FILE[3],
    "ISM4": NCHAN_TO_FILE[4],
    "MASA1": NCHAN_TO_FILE[1],
    "MASA2": NCHAN_TO_FILE[2],
    # "MASA1": TEST_VECTOR_DIR.joinpath("stv_IVASMASA_1dir1TC.pcm"),
    # "MASA2": TEST_VECTOR_DIR.joinpath("stv_IVASMASA_2dir2TC.pcm"),
    "META": TEST_VECTOR_DIR.joinpath("mixed_scene.txt"),
    "16ch_8+4+4": NCHAN_TO_FILE[16],
    "4d0": NCHAN_TO_FILE[4],
    "4d4": NCHAN_TO_FILE[8],
    "cicp1": NCHAN_TO_FILE[1],
    "cicp20": NCHAN_TO_FILE[15],
    "cicp2": NCHAN_TO_FILE[2],
    "custom1": NCHAN_TO_FILE[11],
    "itu_4+5+1": NCHAN_TO_FILE[11],
    "t_design_4": NCHAN_TO_FILE[12],
}

FORMAT_TO_METADATA_FILES = {
    "ISM1": [str(ISM_METADATA_DIR.joinpath("stvISM1.csv"))],
    "ISM2": [
        str(ISM_METADATA_DIR.joinpath("stvISM1.csv")),
        str(ISM_METADATA_DIR.joinpath("stvISM2.csv")),
    ],
    "ISM3": [
        str(ISM_METADATA_DIR.joinpath("stvISM1.csv")),
        str(ISM_METADATA_DIR.joinpath("stvISM2.csv")),
        str(ISM_METADATA_DIR.joinpath("stvISM3.csv")),
    ],
    "ISM4": [
        str(ISM_METADATA_DIR.joinpath("stvISM1.csv")),
        str(ISM_METADATA_DIR.joinpath("stvISM2.csv")),
        str(ISM_METADATA_DIR.joinpath("stvISM3.csv")),
        str(ISM_METADATA_DIR.joinpath("stvISM4.csv")),
    ],
    "MASA1": [str(MASA_METADATA_DIR.joinpath("stv_IVASMASA_1dir1TC.met"))],
    "MASA2": [str(MASA_METADATA_DIR.joinpath("stv_IVASMASA_2dir2TC.met"))],
}

""" Input formats """
INPUT_FORMATS_AMBI = ["FOA", "HOA2", "HOA3"]
INPUT_FORMATS_MC = ["MONO", "STEREO", "5_1", "5_1_2", "5_1_4", "7_1", "7_1_4"]
INPUT_FORMATS_ISM = ["ISM1", "ISM2", "ISM3", "ISM4"]
INPUT_FORMATS_MASA = ["MASA1", "MASA2"]

""" Non binaural / parametric output formats """
OUTPUT_FORMATS = [
    "MONO",
    "STEREO",
    "5_1",
    "5_1_2",
    "5_1_4",
    "7_1",
    "7_1_4",
    "FOA",
    "HOA2",
    "HOA3",
]

""" Custom loudspeaker input/output """
CUSTOM_LS_TO_TEST = [
    # "cicp1",
    # "cicp2",
    "t_design_4",
    # "4d0",
    "4d4",
    "itu_4+5+1",
    "custom1",
    # "cicp20",
    "16ch_8+4+4",
]

""" Mixed scene ( metadata ) rendering """
METADATA_SCENES_TO_TEST = [
    SCENE_DESC_DIR.joinpath(s) for s in ["mixed_scene", "mixed_scene_simple"]
]
METADATA_SCENES_TO_TEST_NO_BE = [SCENE_DESC_DIR.joinpath(s) for s in ["masa_scene"]]

""" Binaural rendering """
INPUT_FORMATS_BINAURAL = OUTPUT_FORMATS[2:]
INPUT_FORMATS_BINAURAL.extend(
    [
        "ISM1",
        "ISM2",
        "ISM3",
        "ISM4",
        "MASA1",
        "MASA2",
    ]
)
OUTPUT_FORMATS_BINAURAL = ["BINAURAL", "BINAURAL_ROOM"]
HR_TRAJECTORIES_TO_TEST = [
    # "const000",
    # "full_circle_in_15s",
    "full_circle_in_15s-Euler",
    "rotate_yaw_pitch_roll1",
]

""" Generate Test Items Configs """
# TODO reorganize later
INPUT_CONFIG_FILES = [
    str(TEST_VECTOR_DIR.joinpath("test_ISM.yml")),
    # str(TEST_VECTOR_DIR.joinpath("test_MASA.yml")), # TODO
    str(TEST_VECTOR_DIR.joinpath("test_MC.yml")),
    str(TEST_VECTOR_DIR.joinpath("test_SBA.yml")),
]
Loading