Commit 457b7281 authored by multrus's avatar multrus
Browse files

initial version

parent d936bbd3
Loading
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -247,11 +247,15 @@ conditions_to_generate:
      bitrates:
          # - 9600
          - [13200, 13200, 8000, 13200, 9600]
      ### for multi-channel configs, code LFE with 9.6 kbps NB (as mandated by IVAS-3)
      evs_lfe_9k6bps_nb: true
      ### Encoder options
      cod:
          ### Path to encoder binary; default search for IVAS_cod in bin folder (primary) and PATH (secondary)
          bin: ~/git/ivas-codec/IVAS_cod
          ### Encoder input sampling rate in Hz (resampling performed in case of mismatch); default = null (no resampling)
          # fs: 32000
      ### Decoder options
      dec:
          ### Path to encoder binary; default search for IVAS_dec in bin folder (primary) and PATH (secondary)
          bin: ~/git/ivas-codec/IVAS_dec
+13 −0
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@

from pathlib import Path
from typing import Optional
from warnings import warn

from ivas_processing_scripts.processing.config import TestConfig
from ivas_processing_scripts.processing.evs import EVS
@@ -242,6 +243,9 @@ def get_processing_chain(
        cod_cfg = cond_cfg["cod"]
        dec_cfg = cond_cfg["dec"]

        # 9.6 kbit/s NB for EVS LFE coding
        evs_lfe_9k6bps_nb = cond_cfg.get("evs_lfe_9k6bps_nb", None)

        # Frame error pattern bitstream modification
        if "tx" in cond_cfg.keys() or hasattr(cfg, "tx"):
            # local specification overwrites global one
@@ -295,6 +299,7 @@ def get_processing_chain(
                    "multiprocessing": cfg.multiprocessing,
                    "tx": tx_cfg,
                    "preamble": preamble,
                    "evs_lfe_9k6bps_nb": evs_lfe_9k6bps_nb,
                }
            )
        )
@@ -305,6 +310,14 @@ def get_processing_chain(
        cod_cfg = cond_cfg["cod"]
        dec_cfg = cond_cfg["dec"]

        # 9.6 kbit/s NB for EVS LFE coding only applies to EVS conditions
        evs_lfe_9k6bps_nb = cond_cfg.get("evs_lfe_9k6bps_nb", None)

        if evs_lfe_9k6bps_nb is not None:
            warn(
                f"Option evs_lfe_9k6bps_nb only applicable to evs conditions - ignoring for ivas."
                )

        # Frame error pattern bitstream modification
        if "tx" in cond_cfg.keys() or hasattr(cfg, "tx"):
            # local specification overwrites global one
+22 −2
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@
import logging
import os.path
import platform
import re
from itertools import repeat
from pathlib import Path
from shutil import copyfile
@@ -100,6 +101,15 @@ class EVS(Processing):
                self.bitrate.extend(
                    [self.bitrate[-1]] * (self.in_fmt.num_channels - len(self.bitrate))
                )

        # special handling for LFE: check, whether evs_lfe_9k6bps_nb is true in multi-channel configs
        self.proc_chan_lfe_9k6bps_nb = [False] * self.in_fmt.num_channels
        if self.in_fmt.lfe_index is not None and self.evs_lfe_9k6bps_nb is True:
            lfe_index = self.in_fmt.lfe_index
            for i in lfe_index:
                self.bitrate[i] = 9600
                self.proc_chan_lfe_9k6bps_nb[i] = True

        # existence of error pattern files (if given) already here
        if self.tx is not None:
            if self.tx.get("type", None) == "JBM":
@@ -176,7 +186,7 @@ class EVS(Processing):
        logger.debug(f"Running EVS encoders for {out_file.stem.split('.')[0]}")
        apply_func_parallel(
            self.enc,
            zip(split_chan_files, split_chan_bs, self.bitrate, repeat(logger)),
            zip(split_chan_files, split_chan_bs, self.bitrate,  self.proc_chan_lfe_9k6bps_nb, repeat(logger)),
            None,
            "mt" if self.multiprocessing else None,
            show_progress=False,
@@ -248,12 +258,22 @@ class EVS(Processing):
        in_pcm_file: Path,
        bitstream: Path,
        bitrate: int,
        proc_chan_lfe_9k6bps_nb: bool,
        logger: Optional[logging.Logger] = None,
    ) -> None:
        cmd = [self.cod_bin]

        # 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:
            cod_opts = []
            regex = re.compile(r'-max_band.*')
            cod_opts = [i for i in self.cod_opts if not regex.match(i)]
            cod_opts.append('-max_band NB')
        else:
            cod_opts = self.cod_opts

        if self.cod_opts:
            cmd.extend(self.cod_opts)
            cmd.extend(cod_opts)

        cmd.extend(
            [