Commit d8e3f5b7 authored by Vladimir Malenovsky's avatar Vladimir Malenovsky
Browse files

truncate signals with a separate script

parent 2f653516
Loading
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -1405,6 +1405,7 @@ ivas-conformance-linux:

    # Reference creation
    - python3 scripts/prepare_combined_format_inputs.py
    - python3 scripts/prepare_truncated_inputs.py
    - TEST_SET="tests/codec_be_on_mr_nonselection tests/renderer_short/test_renderer.py tests/split_rendering/test_split_rendering.py"
    - python3 -m pytest -q $TEST_SET -v -n auto --update_ref 1 --create_ref --keep_files --html=report_cmd.html --self-contained-html
    - python3 scripts/parse_commands.py report_cmd.html Readme_IVAS.txt
+0 −64
Original line number Diff line number Diff line
@@ -33,70 +33,6 @@ the United Nations Convention on Contracts on the International Sales of Goods.
import pytest

from tests.split_rendering.utils import *
import pdb


@pytest.fixture(scope="session", autouse=True)
def truncate_input_files(collected_tests, request):
    """
    Truncate the test vectors to maximum INPUT_DURATION_SEC seconds
    """
    
    INPUT_FORMATS_FULL_CHAIN_SPLIT_PCM = [entry[0] for entry in full_chain_split_pcm_params]
    INPUT_FORMATS_EXT_SPLIT_PCM = [entry[0] for entry in external_split_pcm_params] 

    TEST_FUNCTIONS_TO_FORMATS = {
        "test_ambisonics_full_chain_split": INPUT_FORMATS_AMBI_SPLIT_REND,
        "test_ambisonics_external_split": INPUT_FORMATS_AMBI_SPLIT_REND,
        "test_multichannel_full_chain_split": INPUT_FORMATS_MC_SPLIT_REND,
        "test_multichannel_external_split": INPUT_FORMATS_MC_SPLIT_REND,
        "test_ism_full_chain_split": INPUT_FORMATS_ISM_SPLIT_REND,
        "test_ism_external_split": INPUT_FORMATS_ISM_SPLIT_REND,
        "test_masa_full_chain_split": INPUT_FORMATS_MASA_SPLIT_REND,
        "test_masa_external_split": INPUT_FORMATS_MASA_SPLIT_REND,
        "test_omasa_full_chain_split": INPUT_FORMATS_OMASA_SPLIT_REND,
        "test_omasa_external_split": INPUT_FORMATS_OMASA_SPLIT_REND,
        "test_osba_full_chain_split": INPUT_FORMATS_OSBA_SPLIT_REND,
        "test_osba_external_split": INPUT_FORMATS_OSBA_SPLIT_REND,
        "test_post_rend_plc": [INPUT_FORMATS_AMBI_SPLIT_REND[-1]],
        "test_full_chain_split_pcm": INPUT_FORMATS_FULL_CHAIN_SPLIT_PCM,
        "test_external_split_pcm": INPUT_FORMATS_EXT_SPLIT_PCM,
        "test_framing_combinations_full_chain_split": ["5_1", "FOA"],
        "test_framing_combinations_external_split": ["5_1"],
    }
    
    pattern = r'::([^\[]+)\['

    # get the list of test functions to run
    functions_to_run = {re.search(pattern, entry).group(1) for entry in collected_tests if re.search(pattern, entry)}
    functions_to_run = list(functions_to_run)

    # get the list of file formats for test functions
    formats = []
    for name in functions_to_run:
        formats.extend(TEST_FUNCTIONS_TO_FORMATS.get(name, []))
    seen = set()
    formats = [fmt for fmt in formats if not (fmt in seen or seen.add(fmt))]    # remove duplicates
    
    logging.info(f"\nCutting input files for the following formats: {', '.join(formats)}\n")

    # pdb.set_trace()
    for in_fmt in formats:
        in_file = FORMAT_TO_FILE_COMPARETEST[in_fmt]
        cut_in_file = in_file.with_stem(in_file.stem + "_cut")

        if not path.exists(cut_in_file):
            data, fs = readfile(in_file)

            if data.ndim == 1:
                data_out = data[: INPUT_DURATION_SEC * fs]
            elif data.ndim == 2:
                data_out = data[: INPUT_DURATION_SEC * fs, :]
            else:
                raise ValueError(f"Cannot truncate data with dimension of {data.ndim}")

            writefile(cut_in_file, data_out, fs)


""" Ambisonics """