diff --git a/examples/TEMPLATE.yml b/examples/TEMPLATE.yml index a5039d4d1f6e327579f3466182c650a113a94dea..083ac4bb0accc9cf7626b8352e4e58effa9a3704 100755 --- a/examples/TEMPLATE.yml +++ b/examples/TEMPLATE.yml @@ -18,6 +18,9 @@ # master_seed: 5 ### Additional seed to specify number of preruns (used for background noise delay and FER bitstream processing); default = 0 # prerun_seed: 2 +### flag for linux to use windows-built binaries with wine: default = false +### this requires the wine binary to be available and will be ignored on windows +# use_windows_codec_binaries: True, ### Any relative paths will be interpreted relative to the working directory the script is called from! ### Usage of absolute paths is recommended. diff --git a/experiments/selection/BS1534-1a/config/BS1534-1a.yml b/experiments/selection/BS1534-1a/config/BS1534-1a.yml index 22bf59ec947f8615495f34cd3414fdad0c3bb269..1c84be9f5f83617eac860069b0659247db8f3cfc 100644 --- a/experiments/selection/BS1534-1a/config/BS1534-1a.yml +++ b/experiments/selection/BS1534-1a/config/BS1534-1a.yml @@ -9,6 +9,7 @@ prerun_seed: 2 input_path: "experiments/selection/BS1534-1a/proc_input" output_path: "experiments/selection/BS1534-1a/proc_output" +use_windows_codec_binaries: True ################################################ ### Input configuration diff --git a/experiments/selection/BS1534-1b/config/BS1534-1b.yml b/experiments/selection/BS1534-1b/config/BS1534-1b.yml index f1806aeadb0e629b025b0eb64bd245a22052d161..8f2f9869ea61ec566d6417e8a03e78b75f9699a4 100644 --- a/experiments/selection/BS1534-1b/config/BS1534-1b.yml +++ b/experiments/selection/BS1534-1b/config/BS1534-1b.yml @@ -9,6 +9,7 @@ prerun_seed: 2 input_path: "experiments/selection/BS1534-1b/proc_input" output_path: "experiments/selection/BS1534-1b/proc_output" +use_windows_codec_binaries: True ################################################ ### Input configuration diff --git a/experiments/selection/BS1534-2a/config/BS1534-2a.yml b/experiments/selection/BS1534-2a/config/BS1534-2a.yml index ad09975a6228261ba53903e1097e77dd3127180d..d10ff8ced10560d283cb2cf5f5278ebb7396b726 100644 --- a/experiments/selection/BS1534-2a/config/BS1534-2a.yml +++ b/experiments/selection/BS1534-2a/config/BS1534-2a.yml @@ -9,6 +9,7 @@ prerun_seed: 2 input_path: "experiments/selection/BS1534-2a/proc_input" output_path: "experiments/selection/BS1534-2a/proc_output" +use_windows_codec_binaries: True ################################################ ### Input configuration diff --git a/experiments/selection/BS1534-2b/config/BS1534-2b.yml b/experiments/selection/BS1534-2b/config/BS1534-2b.yml index 84ad3bc6d5d3e92f5b4317cf21e14422748ed298..7340490f58402b0e878c71e1db6daafa811dbd64 100644 --- a/experiments/selection/BS1534-2b/config/BS1534-2b.yml +++ b/experiments/selection/BS1534-2b/config/BS1534-2b.yml @@ -9,6 +9,7 @@ prerun_seed: 2 input_path: "experiments/selection/BS1534-2b/proc_input" output_path: "experiments/selection/BS1534-2b/proc_output" +use_windows_codec_binaries: True ################################################ ### Input configuration diff --git a/experiments/selection/BS1534-3a/config/BS1534-3a.yml b/experiments/selection/BS1534-3a/config/BS1534-3a.yml index 9285c32814f9192c7e17212b698c81b2a7b80467..dad8771b3f5c96535071368aa435fcb1775ad229 100644 --- a/experiments/selection/BS1534-3a/config/BS1534-3a.yml +++ b/experiments/selection/BS1534-3a/config/BS1534-3a.yml @@ -9,6 +9,7 @@ prerun_seed: 2 input_path: "experiments/selection/BS1534-3a/proc_input" output_path: "experiments/selection/BS1534-3a/proc_output" +use_windows_codec_binaries: True ################################################ ### Input configuration diff --git a/experiments/selection/BS1534-3b/config/BS1534-3b.yml b/experiments/selection/BS1534-3b/config/BS1534-3b.yml index 14f877fca87c5ce7beee633db968939f5d98f592..9bc83f0bde8dd2583aaab1abcc50186f4e6e5fd5 100644 --- a/experiments/selection/BS1534-3b/config/BS1534-3b.yml +++ b/experiments/selection/BS1534-3b/config/BS1534-3b.yml @@ -9,6 +9,7 @@ prerun_seed: 2 input_path: "experiments/selection/BS1534-3b/proc_input" output_path: "experiments/selection/BS1534-3b/proc_output" +use_windows_codec_binaries: True ################################################ ### Input configuration diff --git a/experiments/selection/BS1534-4a/config/BS1534-4a.yml b/experiments/selection/BS1534-4a/config/BS1534-4a.yml index 73b4264f1fba9081bd06cbfb979b0f113a6b9ecd..bbafb275321fcd330eb1f833894963730531994f 100644 --- a/experiments/selection/BS1534-4a/config/BS1534-4a.yml +++ b/experiments/selection/BS1534-4a/config/BS1534-4a.yml @@ -9,6 +9,7 @@ prerun_seed: 2 input_path: "experiments/selection/BS1534-4a/proc_input" output_path: "experiments/selection/BS1534-4a/proc_output" +use_windows_codec_binaries: True ################################################ ### Input configuration diff --git a/experiments/selection/BS1534-4b/config/BS1534-4b.yml b/experiments/selection/BS1534-4b/config/BS1534-4b.yml index c24a219aebff1c4b4e451c657cf7fdc2296b0cc9..27e23869d3a0a17d699fa6dd354020c5bd194e52 100644 --- a/experiments/selection/BS1534-4b/config/BS1534-4b.yml +++ b/experiments/selection/BS1534-4b/config/BS1534-4b.yml @@ -9,6 +9,7 @@ prerun_seed: 2 input_path: "experiments/selection/BS1534-4b/proc_input" output_path: "experiments/selection/BS1534-4b/proc_output" +use_windows_codec_binaries: True ################################################ ### Input configuration diff --git a/experiments/selection/BS1534-5a/config/BS1534-5a.yml b/experiments/selection/BS1534-5a/config/BS1534-5a.yml index e9e48f8b898fdb838167a6b8e062245adf08a995..6e6b313f89f14abbdb797457042b95fa6a5d5f82 100644 --- a/experiments/selection/BS1534-5a/config/BS1534-5a.yml +++ b/experiments/selection/BS1534-5a/config/BS1534-5a.yml @@ -9,6 +9,7 @@ prerun_seed: 2 input_path: "experiments/selection/BS1534-5a/proc_input" output_path: "experiments/selection/BS1534-5a/proc_output" +use_windows_codec_binaries: True ################################################ ### Input configuration diff --git a/experiments/selection/BS1534-5b/config/BS1534-5b.yml b/experiments/selection/BS1534-5b/config/BS1534-5b.yml index eeb4c4dd2da3fb6a90ea491e171ff0c71b4ac568..021418ab8749a53c369410c35ea00c9cfb8ed711 100644 --- a/experiments/selection/BS1534-5b/config/BS1534-5b.yml +++ b/experiments/selection/BS1534-5b/config/BS1534-5b.yml @@ -9,6 +9,7 @@ prerun_seed: 2 input_path: "experiments/selection/BS1534-5b/proc_input" output_path: "experiments/selection/BS1534-5b/proc_output" +use_windows_codec_binaries: True ################################################ ### Input configuration diff --git a/experiments/selection/BS1534-6a/config/BS1534-6a.yml b/experiments/selection/BS1534-6a/config/BS1534-6a.yml index 66d9b043eef9cdfd8eafc41549f99308036c07d4..eb27ea94a9c2a9d1b4b82a31e39145a6f895fd23 100644 --- a/experiments/selection/BS1534-6a/config/BS1534-6a.yml +++ b/experiments/selection/BS1534-6a/config/BS1534-6a.yml @@ -9,6 +9,7 @@ prerun_seed: 2 input_path: "experiments/selection/BS1534-6a/proc_input" output_path: "experiments/selection/BS1534-6a/proc_output" +use_windows_codec_binaries: True ################################################ ### Input configuration diff --git a/experiments/selection/BS1534-6b/config/BS1534-6b.yml b/experiments/selection/BS1534-6b/config/BS1534-6b.yml index 4998c7b24e594840490396aa696412247fea26dc..1f7b5409d72a8462a893e33fd975cf5663265d84 100644 --- a/experiments/selection/BS1534-6b/config/BS1534-6b.yml +++ b/experiments/selection/BS1534-6b/config/BS1534-6b.yml @@ -9,6 +9,7 @@ prerun_seed: 2 input_path: "experiments/selection/BS1534-6b/proc_input" output_path: "experiments/selection/BS1534-6b/proc_output" +use_windows_codec_binaries: True ################################################ ### Input configuration diff --git a/experiments/selection/P800-1/config/P800-1.yml b/experiments/selection/P800-1/config/P800-1.yml index bd78848f6addb87c495b99fdb3e047c1792ee5df..e810f021ea4c6b31ca60a91f60dd43a965243072 100644 --- a/experiments/selection/P800-1/config/P800-1.yml +++ b/experiments/selection/P800-1/config/P800-1.yml @@ -9,6 +9,7 @@ prerun_seed: 2 input_path: "experiments/selection/P800-1/proc_input" output_path: "experiments/selection/P800-1/proc_output" +use_windows_codec_binaries: True ################################################ ### Input configuration diff --git a/experiments/selection/P800-2/config/P800-2.yml b/experiments/selection/P800-2/config/P800-2.yml index af6d38ccf162aa1f0d05f88713ea2fa878de25e6..22d0703776d94a6e12d32d8dc1ed07e93f0cae45 100644 --- a/experiments/selection/P800-2/config/P800-2.yml +++ b/experiments/selection/P800-2/config/P800-2.yml @@ -9,6 +9,7 @@ prerun_seed: 2 input_path: "experiments/selection/P800-2/proc_input" output_path: "experiments/selection/P800-2/proc_output" +use_windows_codec_binaries: True ################################################ ### Input configuration diff --git a/experiments/selection/P800-3/config/P800-3.yml b/experiments/selection/P800-3/config/P800-3.yml index feb754a435a44e5a60065ca326d0977474d70a6a..696d5a9ef28490597bf1b7de9370223b329bb49e 100644 --- a/experiments/selection/P800-3/config/P800-3.yml +++ b/experiments/selection/P800-3/config/P800-3.yml @@ -9,6 +9,7 @@ prerun_seed: 2 input_path: "experiments/selection/P800-3/proc_input" output_path: "experiments/selection/P800-3/proc_output" +use_windows_codec_binaries: True ################################################ ### Input configuration diff --git a/experiments/selection/P800-4/config/P800-4.yml b/experiments/selection/P800-4/config/P800-4.yml index d48a900ec4a73922a4d3f1dbb2f2b0160a74a5d7..9c305937389b525d1720b7ce8be9f8fc0b1a38c4 100644 --- a/experiments/selection/P800-4/config/P800-4.yml +++ b/experiments/selection/P800-4/config/P800-4.yml @@ -9,6 +9,7 @@ prerun_seed: 2 input_path: "experiments/selection/P800-4/proc_input" output_path: "experiments/selection/P800-4/proc_output" +use_windows_codec_binaries: True ################################################ ### Input configuration diff --git a/experiments/selection/P800-5/config/P800-5.yml b/experiments/selection/P800-5/config/P800-5.yml index de93f64d2d9266f936c584076cfe56a930d9a396..2bc3d2b2424e15cbe64f596ec9a642e6b2d292c9 100644 --- a/experiments/selection/P800-5/config/P800-5.yml +++ b/experiments/selection/P800-5/config/P800-5.yml @@ -9,6 +9,7 @@ prerun_seed: 2 input_path: "experiments/selection/P800-5/proc_input" output_path: "experiments/selection/P800-5/proc_output" +use_windows_codec_binaries: True ################################################ ### Input configuration diff --git a/experiments/selection/P800-6/config/P800-6.yml b/experiments/selection/P800-6/config/P800-6.yml index c1dab2ea18a194ac85869002e43fb5b640bf85ec..adabe89c7e379a3501909d761105458dc86cd69b 100644 --- a/experiments/selection/P800-6/config/P800-6.yml +++ b/experiments/selection/P800-6/config/P800-6.yml @@ -9,6 +9,7 @@ prerun_seed: 2 input_path: "experiments/selection/P800-6/proc_input" output_path: "experiments/selection/P800-6/proc_output" +use_windows_codec_binaries: True ################################################ ### Input configuration diff --git a/experiments/selection/P800-7/config/P800-7.yml b/experiments/selection/P800-7/config/P800-7.yml index 03f1a48f666231ce3d74ad368a8dda3bfee03051..4427e46bff5d4b837dbf9db6b4efd55a69a7b1cc 100644 --- a/experiments/selection/P800-7/config/P800-7.yml +++ b/experiments/selection/P800-7/config/P800-7.yml @@ -9,6 +9,7 @@ prerun_seed: 2 input_path: "experiments/selection/P800-7/proc_input" output_path: "experiments/selection/P800-7/proc_output" +use_windows_codec_binaries: True ################################################ ### Input configuration diff --git a/ivas_processing_scripts/constants.py b/ivas_processing_scripts/constants.py index 762c11b31802c1ef52c757e1aa6981fce3bdecc4..5cc4760948bee91dc956d5b99ef03bda7b01d3ef 100755 --- a/ivas_processing_scripts/constants.py +++ b/ivas_processing_scripts/constants.py @@ -33,7 +33,7 @@ from datetime import datetime from pathlib import Path -from ivas_processing_scripts.utils import find_binary, get_binary_paths, get_gitsha +from ivas_processing_scripts.utils import get_binary_paths, get_gitsha LOGGER_SUFFIX = ".log" LOGGER_FORMAT = ( @@ -58,6 +58,7 @@ DEFAULT_CONFIG = { "date": f"{datetime.now().strftime('%Y%m%d_%H.%M.%S')}", "git_sha": f"{get_gitsha()}", "multiprocessing": True, + "use_windows_codec_binaries": False, "delete_tmp": False, "master_seed": 0, "prerun_seed": 0, @@ -69,22 +70,6 @@ DEFAULT_CONFIG = { }, "condition_in_output_filename": False, } -DEFAULT_CONFIG_EVS = { - "cod": { - "bin": find_binary("EVS_cod", raise_error=False), - }, - "dec": { - "bin": find_binary("EVS_dec", raise_error=False), - }, -} -DEFAULT_CONFIG_IVAS = { - "cod": { - "bin": find_binary("IVAS_cod", raise_error=False), - }, - "dec": { - "bin": find_binary("IVAS_dec", raise_error=False), - }, -} DEFAULT_CONFIG_BINARIES = { "binary_paths": get_binary_paths( diff --git a/ivas_processing_scripts/processing/chains.py b/ivas_processing_scripts/processing/chains.py index c11be9a1bc54700ee37cb9d3e6624fefcea19935..24d7e80655ee28d6bc2ce816c1e28f98fc65f460 100755 --- a/ivas_processing_scripts/processing/chains.py +++ b/ivas_processing_scripts/processing/chains.py @@ -323,6 +323,7 @@ def get_processing_chain( "preamble": preamble, "evs_lfe_9k6bps_nb": evs_lfe_9k6bps_nb, "sba_fmt": cond_cfg.get("sba_fmt", tmp_in_fmt), + "use_windows_codec_binaries": cfg.use_windows_codec_binaries, } ) ) @@ -408,6 +409,7 @@ def get_processing_chain( "multiprocessing": cfg.multiprocessing, "tx": tx_cfg, "preamble": preamble, + "use_windows_codec_binaries": cfg.use_windows_codec_binaries, } ) ) diff --git a/ivas_processing_scripts/processing/config.py b/ivas_processing_scripts/processing/config.py index 1fef013bafddc9642d6ce29fca050ca99e52cd4f..09776a791b391b3d997bb2248257291636d99e23 100755 --- a/ivas_processing_scripts/processing/config.py +++ b/ivas_processing_scripts/processing/config.py @@ -30,6 +30,7 @@ # the United Nations Convention on Contracts on the International Sales of Goods. # +import platform from copy import deepcopy from pathlib import Path @@ -37,8 +38,6 @@ import yaml from ivas_processing_scripts.constants import ( DEFAULT_CONFIG, - DEFAULT_CONFIG_EVS, - DEFAULT_CONFIG_IVAS, REQUIRED_KEYS, REQUIRED_KEYS_ESDRU, REQUIRED_KEYS_EVS, @@ -46,7 +45,7 @@ from ivas_processing_scripts.constants import ( REQUIRED_KEYS_MNRU, SUPPORTED_CONDITIONS, ) -from ivas_processing_scripts.utils import get_abs_path +from ivas_processing_scripts.utils import find_binary, get_abs_path def merge_dicts(base: dict, other: dict) -> None: @@ -64,6 +63,21 @@ def merge_dicts(base: dict, other: dict) -> None: base[k] = other[k] +def get_default_config_for_codecs(codec_name: str, ext_with_dot: str = "") -> dict: + cod_bin = f"{codec_name}_cod{ext_with_dot}" + dec_bin = f"{codec_name}_dec{ext_with_dot}" + + cfg = { + "cod": { + "bin": find_binary(cod_bin, raise_error=False), + }, + "dec": { + "bin": find_binary(dec_bin, raise_error=False), + }, + } + return cfg + + class TestConfig: # avoid confusion with pytest tests due to naming __test__ = False @@ -76,16 +90,20 @@ class TestConfig: self.tmp_dirs = [] # get default config - cfg = DEFAULT_CONFIG + cfg = deepcopy(DEFAULT_CONFIG) # parse configuration file file_cfg = self._parse_yaml(filename) # validate configuration from file - self._validate(file_cfg) + use_windows_codec_binaries = file_cfg.get( + "use_windows_codec_binaries", cfg["use_windows_codec_binaries"] + ) + self._validate_file_cfg(file_cfg, use_windows_codec_binaries) # merge dictionaries, overriding from config file merge_dicts(cfg, file_cfg) + self._validate_merged_config(cfg) # set attributes from merged dictionary self.__dict__.update(cfg) @@ -117,7 +135,7 @@ class TestConfig: return cfg - def _validate(self, cfg: dict): + def _validate_file_cfg(self, cfg: dict, use_windows_codec_binaries: bool): """ensure configuration contains required keys""" MISSING_KEYS = [] # check required keys @@ -170,6 +188,11 @@ class TestConfig: "Background noise file has to be placed outside the input folder!" ) + codec_bin_extension = ( + ".exe" + if platform.system() == "Linux" and use_windows_codec_binaries + else "" + ) for cond_name, cond_cfg in cfg.get("conditions_to_generate").items(): type = cond_cfg.get("type") if not type: @@ -181,7 +204,7 @@ class TestConfig: f"Condition type {cond_cfg.get('type')} is unsuported! Must be one of '{SUPPORTED_CONDITIONS}'" ) elif type == "evs": - merged_cfg = deepcopy(DEFAULT_CONFIG_EVS) + merged_cfg = get_default_config_for_codecs("EVS", codec_bin_extension) merge_dicts(merged_cfg, cond_cfg) cfg["conditions_to_generate"][cond_name] = merged_cfg if REQUIRED_KEYS_EVS.difference( @@ -191,7 +214,7 @@ class TestConfig: f"The following key(s) must be specified for EVS: {REQUIRED_KEYS_EVS}" ) elif type == "ivas": - merged_cfg = deepcopy(DEFAULT_CONFIG_IVAS) + merged_cfg = get_default_config_for_codecs("IVAS", codec_bin_extension) merge_dicts(merged_cfg, cond_cfg) cfg["conditions_to_generate"][cond_name] = merged_cfg if REQUIRED_KEYS_IVAS.difference( @@ -214,3 +237,12 @@ class TestConfig: raise KeyError( f"The following key must be specified for ESDRU: {REQUIRED_KEYS_ESDRU}" ) + + def _validate_merged_config(self, cfg: dict): + # if not on windows, but "use_windows_codec_binaries" is given, assure that wine is there + if ( + platform.system() == "Linux" + and cfg["use_windows_codec_binaries"] + and find_binary("wine") is None + ): + raise FileNotFoundError("Using windows binaries on Linux requires wine") diff --git a/ivas_processing_scripts/processing/evs.py b/ivas_processing_scripts/processing/evs.py index 0653327e85ef198d583df84ecded4fe474d8a353..d99a6d66ef99d44592dfbebd51d519c7864405ed 100755 --- a/ivas_processing_scripts/processing/evs.py +++ b/ivas_processing_scripts/processing/evs.py @@ -64,12 +64,18 @@ class EVS(Processing): self.name = "evs" self.in_fmt = audio.fromtype(self.in_fmt) self._validate() + 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 self.cod_bin or not Path(self.cod_bin).exists(): - if platform.system() == "Windows" and ( + if need_exe_suffix and ( self.cod_bin and Path(self.cod_bin).with_suffix(".exe").exists() ): self.cod_bin = Path(self.cod_bin).with_suffix(".exe") @@ -78,7 +84,7 @@ class EVS(Processing): "The EVS encoder binary was not found! Please check the configuration." ) if not self.dec_bin or not Path(self.dec_bin).exists(): - if platform.system() == "Windows" and ( + if need_exe_suffix and ( self.dec_bin and Path(self.dec_bin).with_suffix(".exe").exists() ): self.dec_bin = Path(self.dec_bin).with_suffix(".exe") @@ -286,6 +292,8 @@ class EVS(Processing): logger: Optional[logging.Logger] = None, ) -> None: cmd = [self.cod_bin] + if self._use_wine: + cmd.insert(0, "wine") # in case of LFE 9.6 kbps NB processing strip any "-max_band XX" from cmd.extend and amend by "-max_band NB" if proc_chan_lfe_9k6bps_nb is True: @@ -381,6 +389,8 @@ class EVS(Processing): logger: Optional[logging.Logger] = None, ) -> None: cmd = [self.dec_bin] + if self._use_wine: + cmd.insert(0, "wine") if self.dec_opts: cmd.extend(self.dec_opts) diff --git a/ivas_processing_scripts/processing/ivas.py b/ivas_processing_scripts/processing/ivas.py index b2cae46bf38d6ea0f720a19f3f48cae302ec117f..4f85054eae1a140a3c4fe98625474f1d2c041f63 100755 --- a/ivas_processing_scripts/processing/ivas.py +++ b/ivas_processing_scripts/processing/ivas.py @@ -60,10 +60,16 @@ class IVAS(Processing): self.out_fmt = audio.fromtype(self.out_fmt) if not hasattr(self, "dec_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 self.cod_bin or not Path(self.cod_bin).exists(): - if platform.system() == "Windows" and ( + if need_exe_suffix and ( self.cod_bin and Path(self.cod_bin).with_suffix(".exe").exists() ): self.cod_bin = Path(self.cod_bin).with_suffix(".exe") @@ -72,7 +78,7 @@ class IVAS(Processing): "The IVAS encoder binary was not found! Please check the configuration." ) if not self.dec_bin or not Path(self.dec_bin).exists(): - if platform.system() == "Windows" and ( + if need_exe_suffix and ( self.dec_bin and Path(self.dec_bin).with_suffix(".exe").exists() ): self.dec_bin = Path(self.dec_bin).with_suffix(".exe") @@ -181,6 +187,8 @@ class IVAS(Processing): raise ValueError(f"IVAS: invalid audio input extension: {in_file.suffix}") cmd = [self.cod_bin] + if self._use_wine: + cmd.insert(0, "wine") if self.cod_opts: cmd.extend(self.cod_opts) @@ -272,6 +280,9 @@ class IVAS(Processing): logger.debug(f"IVAS decoder {bitstream} -> {out_file}") cmd = [self.dec_bin] + if self._use_wine: + cmd.insert(0, "wine") + if hasattr(self, "trajectory"): cmd.extend(["-T", self.trajectory])