Commit 2482c999 authored by Jan Kiene's avatar Jan Kiene
Browse files

add encoder tests for combined formats

parent ff83c8c7
Loading
Loading
Loading
Loading
+73 −8
Original line number Diff line number Diff line
@@ -67,6 +67,34 @@ TESTVECTOR_FOR_INPUT_FORMAT = {
    "MASA_2TC_1DIR": "ltv{fs}_MASA_2TC_1DIR.wav",
    "MASA_1TC_2DIR": "ltv{fs}_MASA_1TC_2DIR.wav",
    "MASA_2TC_2DIR": "ltv{fs}_MASA_2TC_2DIR.wav",
    "OMASA_ISM1_MASA_1TC_1DIR": "ltv{fs}_OMASA_1ISM_MASA_1TC_1DIR.wav",
    "OMASA_ISM1_MASA_1TC_2DIR": "ltv{fs}_OMASA_1ISM_MASA_1TC_2DIR.wav",
    "OMASA_ISM1_MASA_2TC_1DIR": "ltv{fs}_OMASA_1ISM_MASA_2TC_1DIR.wav",
    "OMASA_ISM1_MASA_2TC_2DIR": "ltv{fs}_OMASA_1ISM_MASA_2TC_2DIR.wav",
    "OMASA_ISM2_MASA_1TC_1DIR": "ltv{fs}_OMASA_2ISM_MASA_1TC_1DIR.wav",
    "OMASA_ISM2_MASA_1TC_2DIR": "ltv{fs}_OMASA_2ISM_MASA_1TC_2DIR.wav",
    "OMASA_ISM2_MASA_2TC_1DIR": "ltv{fs}_OMASA_2ISM_MASA_2TC_1DIR.wav",
    "OMASA_ISM2_MASA_2TC_2DIR": "ltv{fs}_OMASA_2ISM_MASA_2TC_2DIR.wav",
    "OMASA_ISM3_MASA_1TC_1DIR": "ltv{fs}_OMASA_3ISM_MASA_1TC_1DIR.wav",
    "OMASA_ISM3_MASA_1TC_2DIR": "ltv{fs}_OMASA_3ISM_MASA_1TC_2DIR.wav",
    "OMASA_ISM3_MASA_2TC_1DIR": "ltv{fs}_OMASA_3ISM_MASA_2TC_1DIR.wav",
    "OMASA_ISM3_MASA_2TC_2DIR": "ltv{fs}_OMASA_3ISM_MASA_2TC_2DIR.wav",
    "OMASA_ISM4_MASA_1TC_1DIR": "ltv{fs}_OMASA_4ISM_MASA_1TC_1DIR.wav",
    "OMASA_ISM4_MASA_1TC_2DIR": "ltv{fs}_OMASA_4ISM_MASA_1TC_2DIR.wav",
    "OMASA_ISM4_MASA_2TC_1DIR": "ltv{fs}_OMASA_4ISM_MASA_2TC_1DIR.wav",
    "OMASA_ISM4_MASA_2TC_2DIR": "ltv{fs}_OMASA_4ISM_MASA_2TC_2DIR.wav",
    "OSBA_ISM1_FOA": "ltv{fs}_OSBA_1ISM_FOA.wav",
    "OSBA_ISM1_HOA2": "ltv{fs}_OSBA_1ISM_HOA2.wav",
    "OSBA_ISM1_HOA3": "ltv{fs}_OSBA_1ISM_HOA3.wav",
    "OSBA_ISM2_FOA": "ltv{fs}_OSBA_2ISM_FOA.wav",
    "OSBA_ISM2_HOA2": "ltv{fs}_OSBA_2ISM_HOA2.wav",
    "OSBA_ISM2_HOA3": "ltv{fs}_OSBA_2ISM_HOA3.wav",
    "OSBA_ISM3_FOA": "ltv{fs}_OSBA_3ISM_FOA.wav",
    "OSBA_ISM3_HOA2": "ltv{fs}_OSBA_3ISM_HOA2.wav",
    "OSBA_ISM3_HOA3": "ltv{fs}_OSBA_3ISM_HOA3.wav",
    "OSBA_ISM4_FOA": "ltv{fs}_OSBA_4ISM_FOA.wav",
    "OSBA_ISM4_HOA2": "ltv{fs}_OSBA_4ISM_HOA2.wav",
    "OSBA_ISM4_HOA3": "ltv{fs}_OSBA_4ISM_HOA3.wav",
}
METADATA_FOR_INPUT_FORMAT = {
    "ISM1": ["ltvISM1.csv"],
@@ -99,6 +127,8 @@ CMDL_OPTIONS_FOR_INPUT_FORMAT = {
    "MASA_2TC_1DIR": ["-masa", "2"],
    "MASA_1TC_2DIR": ["-masa", "1"],
    "MASA_2TC_2DIR": ["-masa", "2"],
    "OMASA": ["-ism_masa"],
    "OSBA": ["-ism_sba"],
}

### Test case parameters
@@ -114,10 +144,6 @@ INPUT_FORMATS_MASA = [
    "MASA_1TC_2DIR",
    "MASA_2TC_2DIR",
]
INPUT_FORMATS_SINGLE = (
    INPUT_FORMATS_CHANNEL_BASED + INPUT_FORMATS_SCENE_BASED + INPUT_FORMATS_OBJECT_BASED
)  # + INPUT_FORMATS_MASA
# TODO: combined formats

BITRATES_ALL = [
    13200,
@@ -299,6 +325,27 @@ STEREO_DMX_EVS_PARAMS = list(
) + list(product(BITRATES_EVS[:1], SAMPLING_RATES_ALL, [DTX_ON]))


OSBA_PARAMS = list(
    product(
        INPUT_FORMATS_OBJECT_BASED,
        INPUT_FORMATS_SCENE_BASED,
        BITRATES_ALL,
        SAMPLING_RATES_ALL,
        [ISM_MD_BASIC],
    )
)
OMASA_PARAMS = list(
    product(
        INPUT_FORMATS_OBJECT_BASED,
        INPUT_FORMATS_MASA,
        BITRATES_ALL,
        SAMPLING_RATES_ALL,
        [ISM_MD_BASIC],
    )
)
COMBINED_FORMATS_PARAMS = OSBA_PARAMS + OMASA_PARAMS


### -------------- decoder parameter lists --------------

FER_0 = "FER_0perc"
@@ -307,7 +354,12 @@ BITSTREAM_PROCESSING_FER = [FER_0, FER_15]

DECODER_CLEAN_CHANNEL_CHANNELBASED_AND_MASA_PARAMS = (
    collapse_into_list_of_pairs(
        product(STEREO_PARAMS, OUTPUT_FORMATS_ALL[:2], SAMPLING_RATES_ALL, BITSTREAM_PROCESSING_FER)
        product(
            STEREO_PARAMS,
            OUTPUT_FORMATS_ALL[:2],
            SAMPLING_RATES_ALL,
            BITSTREAM_PROCESSING_FER,
        )
    )
    + collapse_into_list_of_pairs(
        product(
@@ -318,8 +370,21 @@ DECODER_CLEAN_CHANNEL_CHANNELBASED_AND_MASA_PARAMS = (
        )
    )
    + collapse_into_list_of_pairs(
        product(MASA_PARAMS, OUTPUT_FORMATS_ALL, SAMPLING_RATES_ALL, BITSTREAM_PROCESSING_FER)
        product(
            MASA_PARAMS,
            OUTPUT_FORMATS_ALL,
            SAMPLING_RATES_ALL,
            BITSTREAM_PROCESSING_FER,
        )
    )
)
DECODER_CLEAN_CHANNEL_OBJECTBASED = collapse_into_list_of_pairs(
    product(
        ISM_PARAMS, OUTPUT_FORMATS_ALL, SAMPLING_RATES_ALL, BITSTREAM_PROCESSING_FER
    )
)
DECODER_CLEAN_CHANNEL_SCENEBASED = collapse_into_list_of_pairs(
    product(
        SBA_PARAMS, OUTPUT_FORMATS_ALL, SAMPLING_RATES_ALL, BITSTREAM_PROCESSING_FER
    )
)
DECODER_CLEAN_CHANNEL_OBJECTBASED = collapse_into_list_of_pairs(product(ISM_PARAMS, OUTPUT_FORMATS_ALL, SAMPLING_RATES_ALL, BITSTREAM_PROCESSING_FER))
DECODER_CLEAN_CHANNEL_SCENEBASED = collapse_into_list_of_pairs(product(SBA_PARAMS, OUTPUT_FORMATS_ALL, SAMPLING_RATES_ALL, BITSTREAM_PROCESSING_FER))
 No newline at end of file
+76 −31
Original line number Diff line number Diff line
@@ -29,7 +29,14 @@ the United Nations Convention on Contracts on the International Sales of Goods.
"""

import pytest
from . import is_be_to_ref, get_bitstream_path, get_testv_path, REF_PATH, DUT_PATH, TESTV_PATH
from . import (
    is_be_to_ref,
    get_bitstream_path,
    get_testv_path,
    REF_PATH,
    DUT_PATH,
    TESTV_PATH,
)
from .constants import *
from pathlib import Path
import subprocess
@@ -48,16 +55,29 @@ def get_output_path(bitstream_path, output_format, output_sampling_rate):


@contextmanager
def get_bitstream(testv_name, encoder_format, bitrate, sampling_rate, dtx, suffix="", processing=None):
def get_bitstream(
    testv_name, encoder_format, bitrate, sampling_rate, dtx, suffix="", processing=None
):
    """
    Utility to get either the stored reference bitstream or the processed version as a temporary file
    """
    with TemporaryDirectory() as tmp_dir:
        bitstream = get_bitstream_path(REF_PATH, testv_name, encoder_format, bitrate, sampling_rate, dtx, suffix)
        bitstream = get_bitstream_path(
            REF_PATH, testv_name, encoder_format, bitrate, sampling_rate, dtx, suffix
        )
        if processing == FER_15:
            bitstream_out = Path(tmp_dir).joinpath(bitstream.stem + f".{processing}.192")
            bitstream_out = Path(tmp_dir).joinpath(
                bitstream.stem + f".{processing}.192"
            )
            ep_path = TESTV_PATH.joinpath("ltv_ep_015.192")
            cmd = ["eid-xor", "-fer", "-vbr", str(bitstream), str(ep_path), str(bitstream_out)]
            cmd = [
                "eid-xor",
                "-fer",
                "-vbr",
                str(bitstream),
                str(ep_path),
                str(bitstream_out),
            ]
            subprocess.run(cmd)
            bitstream = bitstream_out

@@ -97,7 +117,14 @@ def test_decoder_clean_channel_channelbased_and_masa(
    update_ref,
):
    testv_name = get_testv_path(input_format, input_sampling_rate).stem
    with get_bitstream(testv_name, input_format, bitrate, input_sampling_rate, dtx, processing=bitstream_processing) as ref_bitstream:
    with get_bitstream(
        testv_name,
        input_format,
        bitrate,
        input_sampling_rate,
        dtx,
        processing=bitstream_processing,
    ) as ref_bitstream:
        dut_output = get_output_path(ref_bitstream, output_format, output_sampling_rate)

        run_check(
@@ -111,7 +138,8 @@ def test_decoder_clean_channel_channelbased_and_masa(


@pytest.mark.parametrize(
    "input_format,bitrate,input_sampling_rate,dtx,md_type,output_format,output_sampling_rate,bitstream_processing", DECODER_CLEAN_CHANNEL_OBJECTBASED
    "input_format,bitrate,input_sampling_rate,dtx,md_type,output_format,output_sampling_rate,bitstream_processing",
    DECODER_CLEAN_CHANNEL_OBJECTBASED,
)
def test_decoder_objectbased(
    input_format,
@@ -123,7 +151,7 @@ def test_decoder_objectbased(
    output_sampling_rate,
    bitstream_processing,
    dut_decoder_frontend,
        update_ref
    update_ref,
):
    testv_name = get_testv_path(input_format, input_sampling_rate).stem
    suffix = "_basic_MD"
@@ -131,7 +159,15 @@ def test_decoder_objectbased(
        suffix = "_ext_MD"
    elif md_type == ISM_MD_NULL:
        suffix = "_null_MD"
    with get_bitstream(testv_name, input_format, bitrate, input_sampling_rate, dtx, suffix=suffix, processing=bitstream_processing) as ref_bitstream:
    with get_bitstream(
        testv_name,
        input_format,
        bitrate,
        input_sampling_rate,
        dtx,
        suffix=suffix,
        processing=bitstream_processing,
    ) as ref_bitstream:
        dut_output = get_output_path(ref_bitstream, output_format, output_sampling_rate)

        run_check(
@@ -145,7 +181,8 @@ def test_decoder_objectbased(


@pytest.mark.parametrize(
    "input_format,bitrate,input_sampling_rate,dtx,pca,output_format,output_sampling_rate,bitstream_processing", DECODER_CLEAN_CHANNEL_SCENEBASED
    "input_format,bitrate,input_sampling_rate,dtx,pca,output_format,output_sampling_rate,bitstream_processing",
    DECODER_CLEAN_CHANNEL_SCENEBASED,
)
def test_decoder_scenebased(
    input_format,
@@ -157,13 +194,21 @@ def test_decoder_scenebased(
    output_sampling_rate,
    bitstream_processing,
    dut_decoder_frontend,
        update_ref
    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(testv_name, input_format, bitrate, input_sampling_rate, dtx, suffix=suffix, processing=bitstream_processing) as ref_bitstream:
    with get_bitstream(
        testv_name,
        input_format,
        bitrate,
        input_sampling_rate,
        dtx,
        suffix=suffix,
        processing=bitstream_processing,
    ) as ref_bitstream:
        dut_output = get_output_path(ref_bitstream, output_format, output_sampling_rate)

        run_check(
+47 −1
Original line number Diff line number Diff line
@@ -37,10 +37,12 @@ from .constants import (
    INPUT_FORMATS_OBJECT_BASED,
    ENCODER_CHANNEL_BASED_AND_MASA_PARAMS,
    DTX_ON,
    DTX_OFF,
    ISM_PARAMS,
    SBA_PARAMS,
    SBA_FOA_PCA_ON,
    STEREO_DMX_EVS_PARAMS,
    COMBINED_FORMATS_PARAMS,
)
from . import TESTV_PATH, DUT_PATH, is_be_to_ref, get_bitstream_path, get_testv_path

@@ -197,3 +199,47 @@ def test_encoder_stereo_dmx_evs(
        update_ref == 1,
        dtx == DTX_ON,
    )


@pytest.mark.parametrize(
    "input_format_ism,input_format_other,bitrate,sampling_rate,md_type",
    COMBINED_FORMATS_PARAMS,
)
def test_encoder_combined_formats(
    input_format_ism,
    input_format_other,
    bitrate,
    sampling_rate,
    md_type,
    dut_encoder_frontend,
    update_ref,
):
    input_format_combined = "OMASA" if "MASA" in input_format_other else "OSBA"
    testv = get_testv_path(
        f"{input_format_combined}_{input_format_ism}_{input_format_other}",
        sampling_rate,
    )
    options_ism = get_options(input_format_ism, md_type)
    options_other = get_options(input_format_other)
    options_combined = get_options(input_format_combined)
    # glue together: combined mode option, ism num, SBA order/MASA TCs, ISM MD files, MASA MD files (slice results in empty list for OSBA)
    options = (
        options_combined
        + options_ism[1:2]
        + options_other[1:2]
        + options_ism[2:]
        + options_other[2:]
    )
    bitstream = get_bitstream_path(
        DUT_PATH, testv.stem, input_format_combined, bitrate, sampling_rate, DTX_OFF
    )
    run_check(
        bitstream,
        bitrate,
        sampling_rate,
        testv,
        options,
        dut_encoder_frontend,
        update_ref == 1,
        False,
    )