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

factor out binaural testcases for faster test collection

parent 54159e54
Loading
Loading
Loading
Loading
+46 −9
Original line number Diff line number Diff line
@@ -208,6 +208,7 @@ 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]


### -------------- encoder parameter lists --------------
@@ -379,7 +380,8 @@ BS_PROC_FER_15 = "FER_15perc"
BS_PROC_JBM_DLY_PROF_5 = "JBM_dlyprofile5"
BITSTREAM_PROCESSING = [BS_PROC_NONE, BS_PROC_FER_15, BS_PROC_JBM_DLY_PROF_5]

DECODER_CHANNELBASED_AND_MASA_PARAMS = (
# parameters for const bitrate test with non-binaural output
DECODER_CONST_BR_NO_BINAURAL_CHANNELBASED_AND_MASA = (
    collapse_into_list_of_pairs(
        product(
            STEREO_PARAMS,
@@ -391,7 +393,7 @@ DECODER_CHANNELBASED_AND_MASA_PARAMS = (
    + collapse_into_list_of_pairs(
        product(
            MC_PARAMS,
            OUTPUT_FORMATS_ALL[:10] + OUTPUT_FORMATS_BINAURAL,
            OUTPUT_FORMATS_ALL[:10],
            SAMPLING_RATES_ALL,
            BITSTREAM_PROCESSING,
        )
@@ -399,22 +401,57 @@ DECODER_CHANNELBASED_AND_MASA_PARAMS = (
    + collapse_into_list_of_pairs(
        product(
            MASA_PARAMS,
            OUTPUT_FORMATS_ALL,
            OUTPUT_FORMATS_NON_BINAURAL,
            SAMPLING_RATES_ALL,
            BITSTREAM_PROCESSING,
        )
    )
)
DECODER_OBJECTBASED = collapse_into_list_of_pairs(
    product(ISM_PARAMS, OUTPUT_FORMATS_ALL, SAMPLING_RATES_ALL, BITSTREAM_PROCESSING)
DECODER_CONST_BR_NO_BINAURAL_OBJECTBASED = collapse_into_list_of_pairs(
    product(ISM_PARAMS, OUTPUT_FORMATS_NON_BINAURAL, SAMPLING_RATES_ALL, BITSTREAM_PROCESSING)
)
DECODER_SCENEBASED = collapse_into_list_of_pairs(
    product(SBA_PARAMS, OUTPUT_FORMATS_ALL, 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)
)
DECODER_COMBINED_PARAMS = collapse_into_list_of_pairs(
DECODER_CONST_BR_NO_BINAURAL_COMBINED_PARAMS = collapse_into_list_of_pairs(
    product(
        COMBINED_FORMATS_PARAMS,
        OUTPUT_FORMATS_ALL,
        OUTPUT_FORMATS_NON_BINAURAL,
        SAMPLING_RATES_ALL,
        BITSTREAM_PROCESSING,
    )
)

# 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(
        product(
            MC_PARAMS,
            OUTPUT_FORMATS_BINAURAL,
            SAMPLING_RATES_ALL,
            BITSTREAM_PROCESSING,
        )
    )
    + collapse_into_list_of_pairs(
        product(
            MASA_PARAMS,
            OUTPUT_FORMATS_BINAURAL,
            SAMPLING_RATES_ALL,
            BITSTREAM_PROCESSING,
        )
    )
)
DECODER_CONST_BR_BINAURAL_OBJECTBASED = collapse_into_list_of_pairs(
    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)
)
DECODER_CONST_BR_BINAURAL_COMBINED_PARAMS = collapse_into_list_of_pairs(
    product(
        COMBINED_FORMATS_PARAMS,
        OUTPUT_FORMATS_BINAURAL,
        SAMPLING_RATES_ALL,
        BITSTREAM_PROCESSING,
    )
+4 −7
Original line number Diff line number Diff line
@@ -34,12 +34,9 @@ from .. import get_testv_path
from ..constants import *


### --------------- Actual testcase definitions ---------------


@pytest.mark.parametrize(
    "input_format,bitrate,input_sampling_rate,dtx,output_format,output_sampling_rate,bitstream_processing",
    DECODER_CHANNELBASED_AND_MASA_PARAMS,
    DECODER_CONST_BR_BINAURAL_CHANNELBASED_AND_MASA,
)
def test_decoder_channelbased_and_masa(
    input_format,
@@ -76,7 +73,7 @@ def test_decoder_channelbased_and_masa(

@pytest.mark.parametrize(
    "input_format,bitrate,input_sampling_rate,dtx,md_type,output_format,output_sampling_rate,bitstream_processing",
    DECODER_OBJECTBASED,
    DECODER_CONST_BR_BINAURAL_OBJECTBASED,
)
def test_decoder_objectbased(
    input_format,
@@ -120,7 +117,7 @@ def test_decoder_objectbased(

@pytest.mark.parametrize(
    "input_format,bitrate,input_sampling_rate,dtx,pca,output_format,output_sampling_rate,bitstream_processing",
    DECODER_SCENEBASED,
    DECODER_CONST_BR_BINAURAL_SCENEBASED,
)
def test_decoder_scenebased(
    input_format,
@@ -162,7 +159,7 @@ def test_decoder_scenebased(

@pytest.mark.parametrize(
    "input_format_ism,input_format_other,bitrate,input_sampling_rate,md_type,output_format,output_sampling_rate,bitstream_processing",
    DECODER_COMBINED_PARAMS,
    DECODER_CONST_BR_BINAURAL_COMBINED_PARAMS,
)
def test_decoder_combined_formats(
    input_format_ism,
+205 −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 *


@pytest.mark.parametrize(
    "input_format,bitrate,input_sampling_rate,dtx,output_format,output_sampling_rate,bitstream_processing",
    DECODER_CONST_BR_NO_BINAURAL_CHANNELBASED_AND_MASA,
)
def test_decoder_channelbased_and_masa(
    input_format,
    bitrate,
    input_sampling_rate,
    dtx,
    output_format,
    output_sampling_rate,
    bitstream_processing,
    dut_decoder_frontend,
    update_ref,
):
    testv_name = get_testv_path(input_format, input_sampling_rate).stem
    with get_bitstream_and_options(
        testv_name,
        input_format,
        bitrate,
        input_sampling_rate,
        dtx,
        processing=bitstream_processing,
    ) as (ref_bitstream, options):
        dut_output = get_output_path(ref_bitstream, output_format, output_sampling_rate)

        run_check(
            str(ref_bitstream),
            output_format,
            output_sampling_rate,
            str(dut_output),
            options,
            dut_decoder_frontend,
            update_ref == 1,
        )


@pytest.mark.parametrize(
    "input_format,bitrate,input_sampling_rate,dtx,md_type,output_format,output_sampling_rate,bitstream_processing",
    DECODER_CONST_BR_NO_BINAURAL_OBJECTBASED,
)
def test_decoder_objectbased(
    input_format,
    bitrate,
    input_sampling_rate,
    dtx,
    md_type,
    output_format,
    output_sampling_rate,
    bitstream_processing,
    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,
        suffix=suffix,
        processing=bitstream_processing,
    ) as (ref_bitstream, options):
        dut_output = get_output_path(ref_bitstream, output_format, output_sampling_rate)

        run_check(
            str(ref_bitstream),
            output_format,
            output_sampling_rate,
            str(dut_output),
            dut_decoder_frontend,
            update_ref == 1,
            add_option_list=options,
        )


@pytest.mark.parametrize(
    "input_format,bitrate,input_sampling_rate,dtx,pca,output_format,output_sampling_rate,bitstream_processing",
    DECODER_CONST_BR_NO_BINAURAL_SCENEBASED,
)
def test_decoder_scenebased(
    input_format,
    bitrate,
    input_sampling_rate,
    dtx,
    pca,
    output_format,
    output_sampling_rate,
    bitstream_processing,
    dut_decoder_frontend,
    update_ref,
):
    testv_name = get_testv_path(input_format, input_sampling_rate).stem
    suffix = ""
    if pca == SBA_FOA_PCA_ON:
        suffix += "-pca"
    with get_bitstream_and_options(
        testv_name,
        input_format,
        bitrate,
        input_sampling_rate,
        dtx,
        suffix=suffix,
        processing=bitstream_processing,
    ) as (ref_bitstream, options):
        dut_output = get_output_path(ref_bitstream, output_format, output_sampling_rate)

        run_check(
            str(ref_bitstream),
            output_format,
            output_sampling_rate,
            str(dut_output),
            dut_decoder_frontend,
            update_ref == 1,
            add_option_list=options,
        )


@pytest.mark.parametrize(
    "input_format_ism,input_format_other,bitrate,input_sampling_rate,md_type,output_format,output_sampling_rate,bitstream_processing",
    DECODER_CONST_BR_NO_BINAURAL_COMBINED_PARAMS,
)
def test_decoder_combined_formats(
    input_format_ism,
    input_format_other,
    bitrate,
    input_sampling_rate,
    md_type,
    output_format,
    output_sampling_rate,
    bitstream_processing,
    dut_decoder_frontend,
    update_ref,
):
    input_format_combined = "OMASA" if "MASA" in input_format_other else "OSBA"
    testv_name = get_testv_path(
        f"{input_format_combined}_{input_format_ism}_{input_format_other}",
        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_combined,
        bitrate,
        input_sampling_rate,
        DTX_OFF,
        suffix=suffix,
        processing=bitstream_processing,
    ) as (ref_bitstream, options):
        dut_output = get_output_path(ref_bitstream, output_format, output_sampling_rate)

        run_check(
            str(ref_bitstream),
            output_format,
            output_sampling_rate,
            str(dut_output),
            dut_decoder_frontend,
            update_ref == 1,
            add_option_list=options,
        )