Loading ivas_processing_scripts/audiotools/wrappers/eid_xor.py +7 −1 Original line number Diff line number Diff line Loading @@ -91,6 +91,8 @@ def create_and_apply_error_pattern( error_pattern: Optional[Union[Path, str]] = None, error_rate: Optional[float] = None, preamble: Optional[int] = 0, master_seed: Optional[int] = 0, prerun_seed: Optional[int] = 0, ) -> None: """ Function to create (or use existing) frame error pattern for bitstream processing Loading @@ -109,6 +111,10 @@ def create_and_apply_error_pattern( Error rate in percent preamble: Optional[int] Length of preamble in frames master_seed: Optional[int] Master seed for error pattern generation prerun_seed: Optional[int] Number of preruns in seed generation """ if error_pattern is None: Loading @@ -117,7 +123,7 @@ def create_and_apply_error_pattern( error_pattern = in_bitstream.parent.joinpath("error_pattern").with_suffix( ".192" ) create_error_pattern(len_sig, error_pattern, error_rate, preamble) 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" Loading ivas_processing_scripts/audiotools/wrappers/gen_patt.py +11 −4 Original line number Diff line number Diff line Loading @@ -37,10 +37,9 @@ from pathlib import Path from tempfile import TemporaryDirectory from typing import Optional, Union from ivas_processing_scripts.audiotools.constants import IVAS_FRAME_LEN_MS from ivas_processing_scripts.utils import find_binary, run from ivas_processing_scripts.audiotools.wrappers.random_seed import random_seed LIST_FER = [3, 5, 6, 10] ERROR_PATTERNS_DIR = Path(__file__).parent.parent.parent.joinpath("error_patterns") Loading Loading @@ -105,6 +104,8 @@ def create_error_pattern( path_pattern: Union[Path, str], frame_error_rate: float, preamble: Optional[int] = 0, master_seed: Optional[int] = 0, prerun_seed: Optional[int] = 0, ) -> None: """ Creates error pattern with desired frame error rate for bitstream processing Loading @@ -119,6 +120,10 @@ def create_error_pattern( Error rate in percent preamble: Optional[int] Length of preamble in frames master_seed: Optional[int] Master seed for error pattern generation prerun_seed: optional[int] Number of preruns in seed generation """ with TemporaryDirectory() as tmp_dir: Loading @@ -126,8 +131,10 @@ def create_error_pattern( sta_file = ERROR_PATTERNS_DIR.joinpath(f"sta_template") tmp_sta_file = tmp_dir.joinpath("sta") # TODO: compute seed seed = 0 # compute seed seed = random_seed(master_seed, prerun_seed) # open file and modify lines = [] with open(sta_file, "r") as sta_file_txt: Loading ivas_processing_scripts/audiotools/wrappers/random_seed.py 0 → 100644 +83 −0 Original line number Diff line number Diff line #!/usr/bin/env python3 # # (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, # Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., # Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, # Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other # contributors to this repository. All Rights Reserved. # # This software is protected by copyright law and by international treaties. # The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, # Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., # Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, # Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other # contributors to this repository retain full ownership rights in their respective contributions in # the software. This notice grants no license of any kind, including but not limited to patent # license, nor is any license granted by implication, estoppel or otherwise. # # Contributors are required to enter into the IVAS codec Public Collaboration agreement before making # contributions. # # This software is provided "AS IS", without any express or implied warranties. The software is in the # development stage. It is intended exclusively for experts who have experience with such software and # solely for the purpose of inspection. All implied warranties of non-infringement, merchantability # and fitness for a particular purpose are hereby disclaimed and excluded. # # Any dispute, controversy or claim arising under or in relation to providing this software shall be # submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in # accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and # the United Nations Convention on Contracts on the International Sales of Goods. # from typing import Optional from ivas_processing_scripts.utils import find_binary, run def random_seed( master_seed: Optional[int] = 0, prerun_seed: Optional[int] = 0, hexa: Optional[bool] = True, ) -> int: """ Parameters ---------- master_seed: Optional[int] Master seed for error pattern generation prerun_seed: Optional[int] Number of preruns in seed generation hexa: Optonal[bool] Flag if output should be in hexadecimal or decimal format Returns ------- result: int One random value """ # find binary binary = find_binary("random") # set up command line cmd = [ str(binary), "-n", # Number of items str(1), "-s", str(master_seed), "-d", str(prerun_seed), "-r", # value range for results str(0), str(99999999) ] # run command result = run(cmd) result = int(result.stdout[:-1]) if hexa: result = hex(result) return result ivas_processing_scripts/processing/ivas.py +1 −0 Original line number Diff line number Diff line Loading @@ -236,6 +236,7 @@ class IVAS(Processing): signal, _ = read( in_file, fs=self.in_fs ) # TODO: pass down number of frames and preamble from concatenation # TODO: pass seed logger.debug(f"Frame loss simulator {bitstream} -> {bitstream_processed}") create_and_apply_error_pattern( bitstream, Loading Loading
ivas_processing_scripts/audiotools/wrappers/eid_xor.py +7 −1 Original line number Diff line number Diff line Loading @@ -91,6 +91,8 @@ def create_and_apply_error_pattern( error_pattern: Optional[Union[Path, str]] = None, error_rate: Optional[float] = None, preamble: Optional[int] = 0, master_seed: Optional[int] = 0, prerun_seed: Optional[int] = 0, ) -> None: """ Function to create (or use existing) frame error pattern for bitstream processing Loading @@ -109,6 +111,10 @@ def create_and_apply_error_pattern( Error rate in percent preamble: Optional[int] Length of preamble in frames master_seed: Optional[int] Master seed for error pattern generation prerun_seed: Optional[int] Number of preruns in seed generation """ if error_pattern is None: Loading @@ -117,7 +123,7 @@ def create_and_apply_error_pattern( error_pattern = in_bitstream.parent.joinpath("error_pattern").with_suffix( ".192" ) create_error_pattern(len_sig, error_pattern, error_rate, preamble) 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" Loading
ivas_processing_scripts/audiotools/wrappers/gen_patt.py +11 −4 Original line number Diff line number Diff line Loading @@ -37,10 +37,9 @@ from pathlib import Path from tempfile import TemporaryDirectory from typing import Optional, Union from ivas_processing_scripts.audiotools.constants import IVAS_FRAME_LEN_MS from ivas_processing_scripts.utils import find_binary, run from ivas_processing_scripts.audiotools.wrappers.random_seed import random_seed LIST_FER = [3, 5, 6, 10] ERROR_PATTERNS_DIR = Path(__file__).parent.parent.parent.joinpath("error_patterns") Loading Loading @@ -105,6 +104,8 @@ def create_error_pattern( path_pattern: Union[Path, str], frame_error_rate: float, preamble: Optional[int] = 0, master_seed: Optional[int] = 0, prerun_seed: Optional[int] = 0, ) -> None: """ Creates error pattern with desired frame error rate for bitstream processing Loading @@ -119,6 +120,10 @@ def create_error_pattern( Error rate in percent preamble: Optional[int] Length of preamble in frames master_seed: Optional[int] Master seed for error pattern generation prerun_seed: optional[int] Number of preruns in seed generation """ with TemporaryDirectory() as tmp_dir: Loading @@ -126,8 +131,10 @@ def create_error_pattern( sta_file = ERROR_PATTERNS_DIR.joinpath(f"sta_template") tmp_sta_file = tmp_dir.joinpath("sta") # TODO: compute seed seed = 0 # compute seed seed = random_seed(master_seed, prerun_seed) # open file and modify lines = [] with open(sta_file, "r") as sta_file_txt: Loading
ivas_processing_scripts/audiotools/wrappers/random_seed.py 0 → 100644 +83 −0 Original line number Diff line number Diff line #!/usr/bin/env python3 # # (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, # Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., # Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, # Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other # contributors to this repository. All Rights Reserved. # # This software is protected by copyright law and by international treaties. # The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, # Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., # Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, # Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other # contributors to this repository retain full ownership rights in their respective contributions in # the software. This notice grants no license of any kind, including but not limited to patent # license, nor is any license granted by implication, estoppel or otherwise. # # Contributors are required to enter into the IVAS codec Public Collaboration agreement before making # contributions. # # This software is provided "AS IS", without any express or implied warranties. The software is in the # development stage. It is intended exclusively for experts who have experience with such software and # solely for the purpose of inspection. All implied warranties of non-infringement, merchantability # and fitness for a particular purpose are hereby disclaimed and excluded. # # Any dispute, controversy or claim arising under or in relation to providing this software shall be # submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in # accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and # the United Nations Convention on Contracts on the International Sales of Goods. # from typing import Optional from ivas_processing_scripts.utils import find_binary, run def random_seed( master_seed: Optional[int] = 0, prerun_seed: Optional[int] = 0, hexa: Optional[bool] = True, ) -> int: """ Parameters ---------- master_seed: Optional[int] Master seed for error pattern generation prerun_seed: Optional[int] Number of preruns in seed generation hexa: Optonal[bool] Flag if output should be in hexadecimal or decimal format Returns ------- result: int One random value """ # find binary binary = find_binary("random") # set up command line cmd = [ str(binary), "-n", # Number of items str(1), "-s", str(master_seed), "-d", str(prerun_seed), "-r", # value range for results str(0), str(99999999) ] # run command result = run(cmd) result = int(result.stdout[:-1]) if hexa: result = hex(result) return result
ivas_processing_scripts/processing/ivas.py +1 −0 Original line number Diff line number Diff line Loading @@ -236,6 +236,7 @@ class IVAS(Processing): signal, _ = read( in_file, fs=self.in_fs ) # TODO: pass down number of frames and preamble from concatenation # TODO: pass seed logger.debug(f"Frame loss simulator {bitstream} -> {bitstream_processed}") create_and_apply_error_pattern( bitstream, Loading