Commit 6c41824b authored by Anika Treffehn's avatar Anika Treffehn
Browse files

added post processing of noerror signal

parent 0d40ea5b
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -223,6 +223,7 @@ def get_processing_chain(
    tmp_lp_cutoff = post_cfg.get("lp_cutoff")
    tmp_mnru_q = None
    tmp_esdru_alpha = None
    tx_condition = False

    # override / add values based on specific conditions
    cond_cfg = cfg.conditions_to_generate[condition]
@@ -260,6 +261,9 @@ def get_processing_chain(

        # Frame error pattern bitstream modification
        if "tx" in cond_cfg.keys() or hasattr(cfg, "tx"):
            # postprocess also signal without error if there is loudness scaling
            if post_cfg.get("loudness"):
                tx_condition = True
            # local specification overwrites global one
            if "tx" in cond_cfg.keys():
                tx_cfg_tmp = cond_cfg["tx"]
@@ -314,6 +318,7 @@ def get_processing_chain(
                    "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,
                    "tx_condition": tx_condition,
                }
            )
        )
@@ -350,6 +355,9 @@ def get_processing_chain(

        # Frame error pattern bitstream modification
        if "tx" in cond_cfg.keys() or hasattr(cfg, "tx"):
            # postprocess also signal without error if there is loudness scaling
            if post_cfg.get("loudness"):
                tx_condition = True
            # local specification overwrites global one
            if "tx" in cond_cfg.keys():
                tx_cfg_tmp = cond_cfg["tx"]
@@ -401,6 +409,7 @@ def get_processing_chain(
                    "tx": tx_cfg,
                    "preamble": preamble,
                    "use_windows_codec_binaries": cfg.use_windows_codec_binaries,
                    "tx_condition": tx_condition,
                }
            )
        )
@@ -427,6 +436,7 @@ def get_processing_chain(
                "multiprocessing": cfg.multiprocessing,
                "mnru_q": tmp_mnru_q,
                "esdru_alpha": tmp_esdru_alpha,
                "tx_condition": tx_condition,
            }
        )
    )
+7 −7
Original line number Diff line number Diff line
@@ -205,7 +205,7 @@ class EVS(Processing):
        # run processing
        split_chan_bs = [f.with_suffix(".192") for f in split_chan_files]
        split_chan_out = [f.with_suffix(".pcm") for f in split_chan_files]
        split_chan_out_unprocessed = [f.with_suffix(".unprocessed.pcm") for f in split_chan_files]
        split_chan_out_noerror = [f.with_suffix(".noerror.pcm") for f in split_chan_files]

        # run all encoders
        logger.debug(f"Running EVS encoders for {out_file.stem.split('.')[0]}")
@@ -245,7 +245,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_unprocessed, repeat(logger)),
                zip(split_chan_bs_unprocessed, split_chan_out_noerror, repeat(logger)),
                None,
                "mt" if self.multiprocessing else None,
                show_progress=False,
@@ -254,9 +254,9 @@ class EVS(Processing):
        # combine the decoded channels into the output file
        if out_file.suffix in [".wav", ".pcm"]:
            combine(split_chan_out, out_file, in_fs=self.out_fs, is_planar=is_planar)
            if split_chan_bs_unprocessed != split_chan_bs:
                out_file_unprocessed = f"{Path(out_file.parent).joinpath(Path(out_file.name).with_suffix(''))}.unprocessed{out_file.suffix}"
                combine(split_chan_out_unprocessed, out_file_unprocessed, in_fs=self.out_fs, is_planar=is_planar)
            if split_chan_bs_unprocessed != split_chan_bs and self.tx_condition:
                out_file_unprocessed = f"{Path(out_file.parent).joinpath(Path(out_file.name).with_suffix(''))}.noerror{out_file.suffix}"
                combine(split_chan_out_noerror, out_file_unprocessed, in_fs=self.out_fs, is_planar=is_planar)
            # copy ISM metadata for ISM pass-through
            if in_meta:
                for idx in range(len(in_meta)):
@@ -265,10 +265,10 @@ class EVS(Processing):
                        / f"{out_file.stem.split('.')[0]}.evs{out_file.suffix}.{idx}.csv"
                    )
                    copyfile(in_meta[idx], out_file_meta)
                    if split_chan_bs_unprocessed != split_chan_bs:
                    if split_chan_bs_unprocessed != split_chan_bs and self.tx_condition:
                        out_file_meta_unprocessed = (
                                out_file.parent
                                / f"{out_file.stem.split('.')[0]}.evs.unprocessed{out_file.suffix}.{idx}.csv"
                                / f"{out_file.stem.split('.')[0]}.evs.noerror{out_file.suffix}.{idx}.csv"
                        )
                        copyfile(in_meta[idx], out_file_meta_unprocessed)

+4 −5
Original line number Diff line number Diff line
@@ -126,15 +126,14 @@ class IVAS(Processing):
        self.enc(in_file, bitstream, in_meta, logger)

        # apply bitstream processing and save unprocessed bitstream
        bitstream_unprocessed = bitstream
        bitstream_noerror = bitstream
        bitstream = self.simulate_tx(in_file, bitstream, logger)

        # decode twice with and without bitstream errors
        self.dec(bitstream, out_file, logger)
        if bitstream_unprocessed != bitstream:
            out_file_unprocessed = Path(f"{out_file.parent.joinpath(out_file.stem)}.unprocessed{out_file.suffix}")
            self.dec(bitstream_unprocessed, out_file_unprocessed, logger)

        if bitstream_noerror != bitstream and self.tx_condition:
            out_file_unprocessed = Path(f"{out_file.parent.joinpath(out_file.stem)}.noerror{out_file.suffix}")
            self.dec(bitstream_noerror, out_file_unprocessed, logger)

    def enc(
        self,
+11 −0
Original line number Diff line number Diff line
@@ -52,3 +52,14 @@ class Postprocessing(Processing):
        convert.convert_file(
            in_file, out_file, logger=logger, in_meta=in_meta, **self.__dict__
        )
        # additional postprocessing of signal without error modification
        if self.tx_condition:
            in_file_no_error = Path(f"{in_file.with_suffix('')}.noerror.wav")
            out_file_no_error = Path(f"{out_file.with_suffix('')}.noerror.wav")
            if in_meta:
                in_meta_no_error = None  # TODO
            else:
                in_meta_no_error = None
            convert.convert_file(
                in_file_no_error, out_file_no_error, logger=logger, in_meta=in_meta_no_error, **self.__dict__
            )