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

added bitstream modification for EVS

parent 78510d93
Loading
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -135,7 +135,6 @@ def main(args):
            #     a = {"number_frames": cfg.num_frames, "number_frames_preamble": cfg.num_frames_preamble}
            #     condition["processes"][0].tx.update(a)


            apply_func_parallel(
                process_item,
                zip(
+2 −1
Original line number Diff line number Diff line
@@ -38,9 +38,10 @@ from typing import Optional, Tuple, Union
import numpy as np
import scipy.io.wavfile as wav

from .audioarray import trim, window
from ivas_processing_scripts.audiotools.constants import IVAS_FRAME_LEN_MS

from .audioarray import trim, window

logger = logging.getLogger("__main__")
logger.setLevel(logging.DEBUG)

+6 −2
Original line number Diff line number Diff line
@@ -120,8 +120,12 @@ def create_and_apply_error_pattern(
    if error_pattern is None:
        # create error pattern
        if error_rate is not None:
            error_pattern = in_bitstream.parent.joinpath("error_pattern").with_suffix(".192")
            create_error_pattern(len_sig, error_pattern, error_rate, preamble, master_seed, prerun_seed)
            error_pattern = in_bitstream.parent.joinpath("error_pattern").with_suffix(
                ".192"
            )
            create_error_pattern(
                len_sig, error_pattern, error_rate, preamble, master_seed, prerun_seed
            )
        else:
            raise ValueError(
                "Either error pattern or error rate has to be specified for bitstream processing"
+7 −3
Original line number Diff line number Diff line
@@ -37,8 +37,8 @@ from pathlib import Path
from tempfile import TemporaryDirectory
from typing import Optional, Union

from ivas_processing_scripts.utils import find_binary, run
from ivas_processing_scripts.audiotools.wrappers.random_seed import random_seed
from ivas_processing_scripts.utils import find_binary, run

ERROR_PATTERNS_DIR = Path(__file__).parent.parent.parent.joinpath("error_patterns")

@@ -143,9 +143,13 @@ def create_error_pattern(
            lines.append(sta_file_txt.readline())  # not changed
            lines.append(f"{sta_file_txt.readline()[:-2]}{seed}\n")
            lines.append(sta_file_txt.readline())  # not changed
            lines.append(f"{sta_file_txt.readline()[:-2]}{1-(frame_error_rate/100*2)}\n")
            lines.append(
                f"{sta_file_txt.readline()[:-2]}{1-(frame_error_rate/100*2)}\n"
            )
            lines.append(sta_file_txt.readline())  # not changed
            lines.append(f"{sta_file_txt.readline()[:-2]}{1-(frame_error_rate/100*2)}\n")
            lines.append(
                f"{sta_file_txt.readline()[:-2]}{1-(frame_error_rate/100*2)}\n"
            )
            lines.append(sta_file_txt.readline())  # not changed

        with open(tmp_sta_file, "w") as tmp_sta_file_txt:
+9 −5
Original line number Diff line number Diff line
@@ -30,9 +30,9 @@
#  the United Nations Convention on Contracts on the International Sales of Goods.
#

import os.path
from pathlib import Path
from typing import Optional, Union
import os.path

from ivas_processing_scripts.audiotools.wrappers.gen_patt import create_error_pattern
from ivas_processing_scripts.utils import find_binary, run
@@ -90,7 +90,7 @@ def network_simulator(
    in_bitstream: Union[str, Path],
    out_bitstream: Union[str, Path],
    n_frames_per_packet: int,
    offset: int
    offset: int,
) -> None:
    """
    Wrapper for networkSimulator_g192 binary to apply error patterns for the bitstream processing
@@ -130,7 +130,7 @@ def network_simulator(
        out_bitstream,
        f"{out_bitstream}_tracefile_sim",
        str(n_frames_per_packet),
        str(offset)
        str(offset),
    ]

    # run command
@@ -170,7 +170,9 @@ def apply_network_simulator(
        # create error pattern
        if error_profile is not None:
            if error_profile in LIST_JBM_PROFILES:
                error_pattern = ERROR_PATTERNS_DIR.joinpath(f"dly_error_profile_{error_profile}.dat")
                error_pattern = ERROR_PATTERNS_DIR.joinpath(
                    f"dly_error_profile_{error_profile}.dat"
                )
            else:
                raise ValueError(
                    f"JBM profile number {error_profile} does not exist, should be between {LIST_JBM_PROFILES[0]} and {LIST_JBM_PROFILES[-1]}"
@@ -190,6 +192,8 @@ def apply_network_simulator(
            n_frames_per_packet = 2

    # apply error pattern
    network_simulator(error_pattern, in_bitstream, out_bitstream, n_frames_per_packet, offset)
    network_simulator(
        error_pattern, in_bitstream, out_bitstream, n_frames_per_packet, offset
    )

    return
Loading