Commit 08607070 authored by Archit Tamarapu's avatar Archit Tamarapu
Browse files

Merge branch 'enable-ivasrend-prerendering' into 'main'

[characterization] enable using IVAS_rend also for pre-rendering

See merge request !195
parents de39f219 7a2bd4a1
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -240,6 +240,10 @@ conditions_to_generate:
          # fs: 32000
          ### Additional commandline options; default = null
          # opts: ["-q", "-dtx", 4]
          ### Input format conversion, if encoding a different format
          # fmt: "FOA"
          ### Optional use of IVAS_rend for prerendering; can be True (default search) or a path to the binary
          # ivas_prerend: false
      ### Decoder options
      dec:
          ### Path to decoder binary; default search for IVAS_dec in bin folder (primary) and PATH (secondary)
+45 −7
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@
#

from pathlib import Path
from platform import system
from shutil import copyfile, rmtree
from typing import Optional
from warnings import warn
@@ -50,7 +51,12 @@ from ivas_processing_scripts.processing.processing_splitting_scaling import (
    Processing_splitting_scaling,
)
from ivas_processing_scripts.processing.tx import get_tx_cfg
from ivas_processing_scripts.utils import get_abs_path, list_audio, parse_gain
from ivas_processing_scripts.utils import (
    find_binary,
    get_abs_path,
    list_audio,
    parse_gain,
)


def init_processing_chains(cfg: TestConfig) -> None:
@@ -219,6 +225,34 @@ def get_preprocessing_2(cfg: TestConfig) -> dict:
    return chain


def get_prerend(
    rend_cfg: dict = None,
    name="prerend",
    use_windows_codec_binaries: bool = False,
    attrs: dict = None,
):
    if rend_cfg:
        # set to dict; if the user didn't configure anything and wants defaults
        # Workaround since processing:TestConfig:_validate_file_cfg() removes keys with None values
        if isinstance(rend_cfg, bool):
            rend_cfg = {
                "bin": find_binary(
                    f"IVAS_rend{ '.exe' if system() == 'Linux' and use_windows_codec_binaries else '' }"
                )
            }
        attrs.setdefault("bin", get_abs_path(rend_cfg.get("bin")))
        attrs.setdefault("opts", rend_cfg.get("opts"))
        attrs.setdefault("use_windows_codec_binaries", use_windows_codec_binaries)
        return IVAS_rend(
            attrs,
        )
    else:
        return Postprocessing(
            attrs,
            name=name,
        )


def get_processing_chain(
    condition: str,
    cfg: TestConfig,
@@ -335,8 +369,11 @@ def get_processing_chain(
        # if the encoding format differs from the format after the preprocessing, add format conversion stuff
        if (cod_fmt := cod_cfg.get("fmt", tmp_in_fmt)) != tmp_in_fmt:
            chain["processes"].append(
                Postprocessing(
                    {
                get_prerend(
                    cod_cfg.get("ivas_prerend"),
                    name="cod_fmt",
                    use_windows_codec_binaries=cfg.use_windows_codec_binaries,
                    attrs={
                        "in_fs": tmp_in_fs,
                        "in_fmt": tmp_in_fmt,
                        "out_fs": tmp_in_fs,
@@ -344,7 +381,6 @@ def get_processing_chain(
                        "multiprocessing": cfg.multiprocessing,
                        "tx_condition": False,
                    },
                    name="cod_fmt",
                )
            )
            tmp_in_fmt = cod_fmt
@@ -412,8 +448,11 @@ def get_processing_chain(
        # if the encoding format differs from the format after the preprocessing, add format conversion
        if (cod_fmt := cod_cfg.get("fmt", tmp_in_fmt)) != tmp_in_fmt:
            chain["processes"].append(
                Postprocessing(
                    {
                get_prerend(
                    cod_cfg.get("ivas_prerend"),
                    name="cod_fmt",
                    use_windows_codec_binaries=cfg.use_windows_codec_binaries,
                    attrs={
                        "in_fs": tmp_in_fs,
                        "in_fmt": tmp_in_fmt,
                        "out_fs": tmp_in_fs,
@@ -421,7 +460,6 @@ def get_processing_chain(
                        "multiprocessing": cfg.multiprocessing,
                        "tx_condition": False,
                    },
                    name="cod_fmt",
                )
            )
            tmp_in_fmt = cod_fmt