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

JBM EVS special loudness scaling implemented

parent 5ae85e52
Loading
Loading
Loading
Loading
Loading
+19 −15
Original line number Diff line number Diff line
@@ -234,13 +234,14 @@ class EVS(Processing):
            "mt" if self.multiprocessing else None,
            show_progress=False,
        )
        voip = [scb[1] for scb in split_chan_bs]
        split_chan_bs = [scb[0] for scb in split_chan_bs]

        # run all decoders twice with and without bitstream errors
        # TODO: voip mode only for processed bitstreams for jbm
        logger.debug(f"Running EVS decoders for {out_file.stem.split('.')[0]}")
        apply_func_parallel(
            self.dec,
            zip(split_chan_bs, split_chan_out, repeat(logger)),
            zip(split_chan_bs, split_chan_out, voip, repeat(logger)),
            None,
            "mt" if self.multiprocessing else None,
            show_progress=False,
@@ -248,7 +249,7 @@ class EVS(Processing):
        if split_chan_bs_unprocessed != split_chan_bs:
            apply_func_parallel(
                self.dec,
                zip(split_chan_bs_unprocessed, split_chan_out_noerror, repeat(logger)),
                zip(split_chan_bs_unprocessed, split_chan_out_noerror, repeat(False), repeat(logger)),
                None,
                "mt" if self.multiprocessing else None,
                show_progress=False,
@@ -362,7 +363,7 @@ class EVS(Processing):
        in_file: Union[Path, str],
        bitstream: Path,
        logger: Optional[logging.Logger] = None,
    ) -> Union[Path, str]:
    ) -> Tuple[Union[Path, str], bool]:
        if self.tx is not None:
            if self.tx["type"] == "JBM":
                bs, ext = os.path.splitext(bitstream)
@@ -375,14 +376,8 @@ class EVS(Processing):
                    self.tx["error_profile"],
                    self.tx["n_frames_per_packet"],
                )
                # add -voip cmdline option to the decoder
                # TODO: tracefile also?
                if self.dec_opts:
                    if "-voip" not in self.dec_opts:
                        self.dec_opts.extend(["-voip"])
                else:
                    self.dec_opts = ["-voip"]
                return bitstream_processed
                voip = True
                return bitstream_processed, voip

            elif self.tx["type"] == "FER":
                bs, ext = os.path.splitext(bitstream)
@@ -406,21 +401,30 @@ class EVS(Processing):
                    master_seed=self.tx["master_seed"],
                    prerun_seed=self.tx["prerun_seed"],
                )

                return bitstream_processed
                voip = False
                return bitstream_processed, voip
        else:
            return bitstream
            voip = False
            return bitstream, voip

    def dec(
        self,
        bitstream: Path,
        out_pcm_file: Path,
        voip: bool = False,
        logger: Optional[logging.Logger] = None,
    ) -> None:
        cmd = [self.dec_bin]
        if self._use_wine:
            cmd.insert(0, "wine")

        # add -voip cmdline option to the decoder
        if voip:
            cmd.extend(["-voip"])

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

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

+1 −1
Original line number Diff line number Diff line
@@ -274,7 +274,7 @@ class IVAS(Processing):
        self,
        bitstream: Path,
        out_file: Path,
        voip=False,
        voip: bool = False,
        logger: Optional[logging.Logger] = None,
    ) -> None:
        logger.debug(f"IVAS decoder {bitstream} -> {out_file}")
+2 −0
Original line number Diff line number Diff line
@@ -275,6 +275,8 @@ def read_splits_file(splits_file):
def adjust_loudness(
    file_splits, out_fmt, fs, loudness, loudness_fmt, meta, logger=None
):
    if logger:
        logger.debug("Apply normal loudness scaling. The following loudness values are in the concatenation order.")
    scaled_signals = []
    for f, m in zip(file_splits, meta):
        audio_object = audio.fromarray(fmt=out_fmt, x=f, fs=fs)