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

added decoding of unprocessed bitstream

parent 164c3799
Loading
Loading
Loading
Loading
+22 −1
Original line number Diff line number Diff line
@@ -199,6 +199,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]

        # run all encoders
        logger.debug(f"Running EVS encoders for {out_file.stem.split('.')[0]}")
@@ -216,6 +217,8 @@ class EVS(Processing):
            show_progress=False,
        )

        # apply bitstream processing and save unprocessed bitstream
        split_chan_bs_unprocessed = split_chan_bs
        split_chan_bs = apply_func_parallel(
            self.simulate_tx,
            zip(split_chan_files, split_chan_bs, repeat(logger)),
@@ -224,7 +227,7 @@ class EVS(Processing):
            show_progress=False,
        )

        # run all decoders
        # run all decoders twice with and without bitstream errors
        logger.debug(f"Running EVS decoders for {out_file.stem.split('.')[0]}")
        apply_func_parallel(
            self.dec,
@@ -233,10 +236,21 @@ class EVS(Processing):
            "mt" if self.multiprocessing else None,
            show_progress=False,
        )
        if split_chan_bs_unprocessed != split_chan_bs:
            apply_func_parallel(
                self.dec,
                zip(split_chan_bs_unprocessed, split_chan_out_unprocessed, repeat(logger)),
                None,
                "mt" if self.multiprocessing else None,
                show_progress=False,
            )

        # 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)
            # copy ISM metadata for ISM pass-through
            if in_meta:
                for idx in range(len(in_meta)):
@@ -245,6 +259,13 @@ 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:
                        out_file_meta_unprocessed = (
                                out_file.parent
                                / f"{out_file.stem.split('.')[0]}.evs.unprocessed{out_file.suffix}.{idx}.csv"
                        )
                        copyfile(in_meta[idx], out_file_meta_unprocessed)

        elif out_file.suffix == ".txt":
            raise NotImplementedError(".txt file support is WIP")
            # output_wav = out_file.replace(output_ext, ".wav")
+7 −5
Original line number Diff line number Diff line
@@ -116,17 +116,19 @@ class IVAS(Processing):

        bitstream = out_file.with_suffix(".192")

        # encode signal
        self.enc(in_file, bitstream, in_meta, logger)

        # apply bitstream processing and save unprocessed bitstream
        bitstream_unprocessed = 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 self.out_fmt == "EXT":
            for i in range(self.in_fmt.num_channels):  # TODO treffehn: check
                # we need to read out_file.0.csv, out_file.1.csv ...
                # self.out.object_pos = np.genfromtxt(out_file.with_suffix(f"{i}.0.csv"), delimiter=",")
                ...

    def enc(
        self,