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

add exhaustive testcases for non-diegetic panning in decoder

parent 4e271728
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -92,6 +92,7 @@ def get_bitstream_and_options(
    processing,
    hrtf=BINAURAL_HRTF_NONE,
    suffix="",
    non_diegetic_pan_value=None,
):
    """
    Utility to get either the stored reference bitstream or the processed version as a temporary file
@@ -141,6 +142,9 @@ def get_bitstream_and_options(
        if hrtf != BINAURAL_HRTF_NONE:
            options.extend(["-hrtf", str(HRTF_PATHS[hrtf]).format(fs=sampling_rate)])

        if non_diegetic_pan_value is not None:
            options.extend(["-non_diegetic_pan", f"{non_diegetic_pan_value}"])

        yield bitstream, options


+148 −0
Original line number Diff line number Diff line
__copyright__ = """
(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 . import get_bitstream_and_options, get_output_path, run_check
from .. import get_testv_path
from ..constants import (
    STEREO_DMX_EVS_PARAMS,
    ISM_MD_EXTENDED,
    ISM_MD_NULL,
    DECODER_CONST_BR_NO_BINAURAL_OBJECTBASED,
    SAMPLING_RATES_ALL,
    BITSTREAM_PROCESSING,
)

# NOTE: this way, all possible inputs for the non-diegetic panning value are used for all input/output configs
# less exhaustive testing is probably enough here, one can e.g. only test one panning value for each i/o config
NON_DIEGETIC_PAN_VALUES = ["c", "center", "middle", "left", "l", "right", "r"] + list(
    range(-90, 91)
)
ISM1_DECODER_PARAMS = [
    p
    for p in DECODER_CONST_BR_NO_BINAURAL_OBJECTBASED
    if p[0].startswith("ISM1") and p[1] == "STEREO"
]


@pytest.mark.parametrize("non_diegetic_panning_value", NON_DIEGETIC_PAN_VALUES)
@pytest.mark.parametrize(
    "input_format,bitrate,input_sampling_rate,dtx,md_type,output_format,output_sampling_rate,bitstream_processing",
    ISM1_DECODER_PARAMS,
)
def test_decoder_non_diegetic_pan_ism(
    input_format,
    bitrate,
    input_sampling_rate,
    dtx,
    md_type,
    output_format,
    output_sampling_rate,
    bitstream_processing,
    non_diegetic_panning_value,
    dut_decoder_frontend,
    update_ref,
):
    testv_name = get_testv_path(input_format, input_sampling_rate).stem
    suffix = "_basic_MD"
    if md_type == ISM_MD_EXTENDED:
        suffix = "_ext_MD"
    elif md_type == ISM_MD_NULL:
        suffix = "_null_MD"
    with get_bitstream_and_options(
        testv_name,
        input_format,
        bitrate,
        input_sampling_rate,
        dtx,
        bitstream_processing,
        suffix=suffix,
    ) as (ref_bitstream, options):
        suffix += f"-non_diegetic_pan_{non_diegetic_panning_value}"
        dut_output = get_output_path(
            ref_bitstream,
            output_format,
            output_sampling_rate,
            bitstream_processing,
            suffix=suffix,
        )
        run_check(
            str(ref_bitstream),
            output_format,
            output_sampling_rate,
            str(dut_output),
            options,
            dut_decoder_frontend,
            update_ref == 1,
        )


# for the mono input, we use the Stereo DMX EVS outputs from the decoder so no explicit mono encoder run is needed
@pytest.mark.parametrize("non_diegetic_panning_value", NON_DIEGETIC_PAN_VALUES)
@pytest.mark.parametrize("bitrate,input_sampling_rate,dtx", STEREO_DMX_EVS_PARAMS)
@pytest.mark.parametrize("output_sampling_rate", SAMPLING_RATES_ALL)
@pytest.mark.parametrize("bitstream_processing", BITSTREAM_PROCESSING)
def test_decoder_non_diegetic_pan_mono(
    bitrate,
    input_sampling_rate,
    dtx,
    output_sampling_rate,
    bitstream_processing,
    non_diegetic_panning_value,
    dut_decoder_frontend,
    update_ref,
):
    testv_name = get_testv_path("STEREO", input_sampling_rate).stem
    with get_bitstream_and_options(
        testv_name,
        "StereoDmxEvs",
        bitrate,
        input_sampling_rate,
        dtx,
        bitstream_processing,
        non_diegetic_pan_value=non_diegetic_panning_value,
    ) as (ref_bitstream, options):
        suffix = f"-non_diegetic_pan_{non_diegetic_panning_value}"
        dut_output = get_output_path(
            ref_bitstream,
            "STEREO",
            output_sampling_rate,
            bitstream_processing,
            suffix=suffix,
        )
        run_check(
            str(ref_bitstream),
            "",
            output_sampling_rate,
            str(dut_output),
            options,
            dut_decoder_frontend,
            update_ref == 1,
        )