Loading lib_dec/ivas_init_dec.c +14 −0 Original line number Diff line number Diff line Loading @@ -235,11 +235,25 @@ ivas_error ivas_dec_get_format( /* read number of MASA transport channels */ if ( st_ivas->bit_stream[( ivas_total_brate / FRAMES_PER_SEC ) - 1] ) { #ifdef DECODER_FORMAT_SWITCHING if ( st_ivas->nchan_transport == 1 ) { st_ivas->restartNeeded = 1; return IVAS_ERR_OK; } #endif st_ivas->nchan_transport = 2; element_mode_flag = 1; } else { #ifdef DECODER_FORMAT_SWITCHING if ( st_ivas->nchan_transport == 2 ) { st_ivas->restartNeeded = 1; return IVAS_ERR_OK; } #endif st_ivas->nchan_transport = 1; } Loading tests/test_format_switching.py 0 → 100644 +175 −0 Original line number Diff line number Diff line #!/usr/bin/env python3 __copyright__ = """ (C) 2022-2025 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. """ __doc__ = """ To configure test modules. """ import pytest import csv import os import sys import random from tempfile import TemporaryDirectory from pathlib import Path import soundfile as sf import numpy as np ROOT_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), "../..")) sys.path.append(ROOT_DIR) from tests.conftest import EncoderFrontend, DecoderFrontend from tests.create_short_testvectors import create_short_testvectors from tests.renderer.constants import ( FORMAT_TO_FILE_COMPARETEST, FORMAT_TO_METADATA_FILES, ) FORMAT_ARGUMENT_MAPPING = { "MONO": [], "STEREO": ["-stereo"], "5_1": ["-mc", "5_1"], "7_1": ["-mc", "7_1"], "5_1_2": ["-mc", "5_1_2"], "5_1_4": ["-mc", "5_1_4"], "7_1_4": ["-mc", "7_1_4"], "FOA": ["-sba", "+1"], "HOA2": ["-sba", "+2"], "HOA3": ["-sba", "+3"], "ISM1": ["-ism", "1"], "ISM2": ["-ism", "2"], "ISM3": ["-ism", "3"], "ISM4": ["-ism", "4"], "MASA1": ["-masa", "1"], "MASA2": ["-masa", "2"], "ISM1MASA1": ["-ism_masa", "1", "1"], "ISM2MASA1": ["-ism_masa", "2", "1"], "ISM3MASA1": ["-ism_masa", "3", "1"], "ISM4MASA1": ["-ism_masa", "4", "1"], "ISM1MASA2": ["-ism_masa", "1", "2"], "ISM2MASA2": ["-ism_masa", "2", "2"], "ISM3MASA2": ["-ism_masa", "3", "2"], "ISM4MASA2": ["-ism_masa", "4", "2"], "ISM1SBA1": ["-ism_sba", "1", "+1"], "ISM1SBA2": ["-ism_sba", "1", "+2"], "ISM1SBA3": ["-ism_sba", "1", "+3"], "ISM2SBA1": ["-ism_sba", "2", "+1"], "ISM2SBA2": ["-ism_sba", "2", "+2"], "ISM2SBA3": ["-ism_sba", "2", "+3"], "ISM3SBA1": ["-ism_sba", "3", "+1"], "ISM3SBA2": ["-ism_sba", "3", "+2"], "ISM3SBA3": ["-ism_sba", "3", "+3"], "ISM4SBA1": ["-ism_sba", "4", "+1"], "ISM4SBA2": ["-ism_sba", "4", "+2"], "ISM4SBA3": ["-ism_sba", "4", "+3"], } def test_format_switching ( dut_encoder_frontend: EncoderFrontend, dut_decoder_frontend: DecoderFrontend ): bitrate = 48000 bandwidth = "FB" outMode = "MONO" # Create 1s test files cut_suffix = "_cut.wav" test_file = Path( str(FORMAT_TO_FILE_COMPARETEST["MONO"]).replace(".wav", cut_suffix) ) if not test_file.exists(): create_short_testvectors(1.0, False, None) with TemporaryDirectory() as tmp_dir: bitstreams = [] # Encode subformats for key, audioFile in FORMAT_TO_FILE_COMPARETEST.items(): if key in ["META", "16ch_8+4+4", "4d4", "t_design_4"]: break encoder_args = [] cutFile = Path( str(audioFile).replace(".wav", cut_suffix) ) encoder_args += FORMAT_ARGUMENT_MAPPING[key] if key in FORMAT_TO_METADATA_FILES: encoder_args += FORMAT_TO_METADATA_FILES[key] elif "SBA" in key: # ISM metadata files for OSBA encoder_args += FORMAT_TO_METADATA_FILES[key[:4]] temp_bitstream = Path(tmp_dir).joinpath(f"output-{bitrate}-{bandwidth}-{key}.bts").absolute() dut_encoder_frontend.run( bitrate=bitrate, input_sampling_rate=48, input_path=cutFile, output_bitstream_path=temp_bitstream, sba_order=None, dtx_mode=False, max_band=bandwidth, add_option_list=encoder_args ) bitstreams.append(temp_bitstream) # Combine bitstreams cat_bitstream_full = Path(tmp_dir).joinpath(f"output-{bitrate}-{bandwidth}-FULL-CAT.bts").absolute() cat_bitstream_no_evs = Path(tmp_dir).joinpath(f"output-{bitrate}-{bandwidth}-NO-EVS-CAT.bts").absolute() catBsFull = bytes() catBsNoEVS = bytes() for bsFile in bitstreams: with open (bsFile, mode="rb") as fd: tempRead = fd.read() catBsFull += tempRead if "MONO" not in str(bsFile): catBsNoEVS += tempRead with open (cat_bitstream_full, mode="wb") as outFile: outFile.write(catBsFull) with open (cat_bitstream_no_evs, mode="wb") as outFile: outFile.write(catBsNoEVS) # Decode the combined bitstreams cat_output_full = Path(tmp_dir).joinpath(f"output-{bitrate}-{bandwidth}-FULL-CAT.wav").absolute() cat_output_no_evs = Path(tmp_dir).joinpath(f"output-{bitrate}-{bandwidth}-NO-EVS-CAT.wav").absolute() dut_decoder_frontend.run( output_config=outMode, output_sampling_rate=48, input_bitstream_path=cat_bitstream_no_evs, output_path=cat_output_no_evs, add_option_list= [] ) dut_decoder_frontend.run( output_config=outMode, output_sampling_rate=48, input_bitstream_path=cat_bitstream_full, output_path=cat_output_full, add_option_list= [] ) Loading
lib_dec/ivas_init_dec.c +14 −0 Original line number Diff line number Diff line Loading @@ -235,11 +235,25 @@ ivas_error ivas_dec_get_format( /* read number of MASA transport channels */ if ( st_ivas->bit_stream[( ivas_total_brate / FRAMES_PER_SEC ) - 1] ) { #ifdef DECODER_FORMAT_SWITCHING if ( st_ivas->nchan_transport == 1 ) { st_ivas->restartNeeded = 1; return IVAS_ERR_OK; } #endif st_ivas->nchan_transport = 2; element_mode_flag = 1; } else { #ifdef DECODER_FORMAT_SWITCHING if ( st_ivas->nchan_transport == 2 ) { st_ivas->restartNeeded = 1; return IVAS_ERR_OK; } #endif st_ivas->nchan_transport = 1; } Loading
tests/test_format_switching.py 0 → 100644 +175 −0 Original line number Diff line number Diff line #!/usr/bin/env python3 __copyright__ = """ (C) 2022-2025 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. """ __doc__ = """ To configure test modules. """ import pytest import csv import os import sys import random from tempfile import TemporaryDirectory from pathlib import Path import soundfile as sf import numpy as np ROOT_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), "../..")) sys.path.append(ROOT_DIR) from tests.conftest import EncoderFrontend, DecoderFrontend from tests.create_short_testvectors import create_short_testvectors from tests.renderer.constants import ( FORMAT_TO_FILE_COMPARETEST, FORMAT_TO_METADATA_FILES, ) FORMAT_ARGUMENT_MAPPING = { "MONO": [], "STEREO": ["-stereo"], "5_1": ["-mc", "5_1"], "7_1": ["-mc", "7_1"], "5_1_2": ["-mc", "5_1_2"], "5_1_4": ["-mc", "5_1_4"], "7_1_4": ["-mc", "7_1_4"], "FOA": ["-sba", "+1"], "HOA2": ["-sba", "+2"], "HOA3": ["-sba", "+3"], "ISM1": ["-ism", "1"], "ISM2": ["-ism", "2"], "ISM3": ["-ism", "3"], "ISM4": ["-ism", "4"], "MASA1": ["-masa", "1"], "MASA2": ["-masa", "2"], "ISM1MASA1": ["-ism_masa", "1", "1"], "ISM2MASA1": ["-ism_masa", "2", "1"], "ISM3MASA1": ["-ism_masa", "3", "1"], "ISM4MASA1": ["-ism_masa", "4", "1"], "ISM1MASA2": ["-ism_masa", "1", "2"], "ISM2MASA2": ["-ism_masa", "2", "2"], "ISM3MASA2": ["-ism_masa", "3", "2"], "ISM4MASA2": ["-ism_masa", "4", "2"], "ISM1SBA1": ["-ism_sba", "1", "+1"], "ISM1SBA2": ["-ism_sba", "1", "+2"], "ISM1SBA3": ["-ism_sba", "1", "+3"], "ISM2SBA1": ["-ism_sba", "2", "+1"], "ISM2SBA2": ["-ism_sba", "2", "+2"], "ISM2SBA3": ["-ism_sba", "2", "+3"], "ISM3SBA1": ["-ism_sba", "3", "+1"], "ISM3SBA2": ["-ism_sba", "3", "+2"], "ISM3SBA3": ["-ism_sba", "3", "+3"], "ISM4SBA1": ["-ism_sba", "4", "+1"], "ISM4SBA2": ["-ism_sba", "4", "+2"], "ISM4SBA3": ["-ism_sba", "4", "+3"], } def test_format_switching ( dut_encoder_frontend: EncoderFrontend, dut_decoder_frontend: DecoderFrontend ): bitrate = 48000 bandwidth = "FB" outMode = "MONO" # Create 1s test files cut_suffix = "_cut.wav" test_file = Path( str(FORMAT_TO_FILE_COMPARETEST["MONO"]).replace(".wav", cut_suffix) ) if not test_file.exists(): create_short_testvectors(1.0, False, None) with TemporaryDirectory() as tmp_dir: bitstreams = [] # Encode subformats for key, audioFile in FORMAT_TO_FILE_COMPARETEST.items(): if key in ["META", "16ch_8+4+4", "4d4", "t_design_4"]: break encoder_args = [] cutFile = Path( str(audioFile).replace(".wav", cut_suffix) ) encoder_args += FORMAT_ARGUMENT_MAPPING[key] if key in FORMAT_TO_METADATA_FILES: encoder_args += FORMAT_TO_METADATA_FILES[key] elif "SBA" in key: # ISM metadata files for OSBA encoder_args += FORMAT_TO_METADATA_FILES[key[:4]] temp_bitstream = Path(tmp_dir).joinpath(f"output-{bitrate}-{bandwidth}-{key}.bts").absolute() dut_encoder_frontend.run( bitrate=bitrate, input_sampling_rate=48, input_path=cutFile, output_bitstream_path=temp_bitstream, sba_order=None, dtx_mode=False, max_band=bandwidth, add_option_list=encoder_args ) bitstreams.append(temp_bitstream) # Combine bitstreams cat_bitstream_full = Path(tmp_dir).joinpath(f"output-{bitrate}-{bandwidth}-FULL-CAT.bts").absolute() cat_bitstream_no_evs = Path(tmp_dir).joinpath(f"output-{bitrate}-{bandwidth}-NO-EVS-CAT.bts").absolute() catBsFull = bytes() catBsNoEVS = bytes() for bsFile in bitstreams: with open (bsFile, mode="rb") as fd: tempRead = fd.read() catBsFull += tempRead if "MONO" not in str(bsFile): catBsNoEVS += tempRead with open (cat_bitstream_full, mode="wb") as outFile: outFile.write(catBsFull) with open (cat_bitstream_no_evs, mode="wb") as outFile: outFile.write(catBsNoEVS) # Decode the combined bitstreams cat_output_full = Path(tmp_dir).joinpath(f"output-{bitrate}-{bandwidth}-FULL-CAT.wav").absolute() cat_output_no_evs = Path(tmp_dir).joinpath(f"output-{bitrate}-{bandwidth}-NO-EVS-CAT.wav").absolute() dut_decoder_frontend.run( output_config=outMode, output_sampling_rate=48, input_bitstream_path=cat_bitstream_no_evs, output_path=cat_output_no_evs, add_option_list= [] ) dut_decoder_frontend.run( output_config=outMode, output_sampling_rate=48, input_bitstream_path=cat_bitstream_full, output_path=cat_output_full, add_option_list= [] )