Commit a61ac998 authored by Anika Treffehn's avatar Anika Treffehn
Browse files

added ivas rend in chains.py

parent 3d27e237
Loading
Loading
Loading
Loading
+18 −1
Original line number Diff line number Diff line
@@ -39,7 +39,7 @@ from ivas_processing_scripts.audiotools.audioarray import trim
from ivas_processing_scripts.audiotools.audiofile import read, write
from ivas_processing_scripts.processing.config import TestConfig
from ivas_processing_scripts.processing.evs import EVS
from ivas_processing_scripts.processing.ivas import IVAS
from ivas_processing_scripts.processing.ivas import IVAS, IVAS_rend
from ivas_processing_scripts.processing.postprocessing import Postprocessing
from ivas_processing_scripts.processing.preprocessing import Preprocessing
from ivas_processing_scripts.processing.preprocessing_2 import Preprocessing2
@@ -450,6 +450,23 @@ def get_processing_chain(
    else:
        raise SystemExit(f"Unknown condition {condition}!")

    # add optional IVAS_rend rendering step after each condition
    if cond_cfg.get("ivas_rend", -1) != -1:
        rend_cfg = cond_cfg["ivas_rend"]
        chain["processes"].append(
            IVAS_rend(
                {
                    "in_fmt": tmp_in_fmt,
                    "in_fs": tmp_in_fs,
                    "out_fmt": rend_cfg.get("fmt", tmp_out_fmt),
                    "bin": get_abs_path(rend_cfg.get("bin", None)),
                    "opts": rend_cfg.get("opts"),
                    "use_windows_codec_binaries": cfg.use_windows_codec_binaries,
                    # TODO: multiprocessing, tx, preamble, tx_condition keys necessary?
                }
            )
        )

    # add postprocessing step based on condition
    post_fmt = post_cfg.get("fmt")
    if isinstance(post_fmt, list):
+17 −0
Original line number Diff line number Diff line
@@ -79,6 +79,17 @@ def get_default_config_for_codecs(codec_name: str, ext_with_dot: str = "") -> di
    return cfg


def get_default_config_for_renderer(codec_name: str, ext_with_dot: str = "") -> dict:
    rend_bin = f"{codec_name}_rend{ext_with_dot}"

    cfg = {
        "ivas_rend": {
            "bin": find_binary(rend_bin, raise_error=False),
        },
    }
    return cfg


class TestConfig:
    # avoid confusion with pytest tests due to naming
    __test__ = False
@@ -244,6 +255,12 @@ class TestConfig:
                        f"The following key must be specified for ESDRU: {REQUIRED_KEYS_ESDRU}"
                    )

            if cond_cfg.get("ivas_rend", -1) != -1:
                merged_cfg = get_default_config_for_renderer("IVAS", codec_bin_extension)
                merge_dicts(merged_cfg, cond_cfg)
                cfg["conditions_to_generate"][cond_name] = merged_cfg


    def _validate_merged_config(self, cfg: dict):
        # if not on windows, but "use_windows_codec_binaries" is given, assure that wine is there
        if (
+16 −3
Original line number Diff line number Diff line
@@ -366,11 +366,24 @@ class IVAS_rend(Processing):
        self.name = "ivas_rend"
        self.in_fmt = audio.fromtype(self.in_fmt)
        self.out_fmt = audio.fromtype(self.out_fmt)
        if not hasattr(self, "opts"):
            self.dec_opts = None
        self._use_wine = (
                platform.system() == "Linux" and self.use_windows_codec_binaries
        )

    def _validate(self):
        need_exe_suffix = (
                platform.system() == "Windows" or self.use_windows_codec_binaries
        )
        if not Path(self.bin).exists():
            if need_exe_suffix and (
                    self.bin and Path(self.bin).with_suffix(".exe").exists()
            ):
                self.bin = Path(self.bin).with_suffix(".exe")
            else:
                raise FileNotFoundError(
                f"The IVAS renderer binary was not found at the given path: {self.cod_bin}"
                    "The IVAS renderer binary was not found! Please check the configuration."
                )

    def process(