Line data Source code
1 : /****************************************************************************************************** 2 : 3 : (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, 4 : Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., 5 : Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, 6 : Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other 7 : contributors to this repository. All Rights Reserved. 8 : 9 : This software is protected by copyright law and by international treaties. 10 : The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, 11 : Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., 12 : Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, 13 : Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other 14 : contributors to this repository retain full ownership rights in their respective contributions in 15 : the software. This notice grants no license of any kind, including but not limited to patent 16 : license, nor is any license granted by implication, estoppel or otherwise. 17 : 18 : Contributors are required to enter into the IVAS codec Public Collaboration agreement before making 19 : contributions. 20 : 21 : This software is provided "AS IS", without any express or implied warranties. The software is in the 22 : development stage. It is intended exclusively for experts who have experience with such software and 23 : solely for the purpose of inspection. All implied warranties of non-infringement, merchantability 24 : and fitness for a particular purpose are hereby disclaimed and excluded. 25 : 26 : Any dispute, controversy or claim arising under or in relation to providing this software shall be 27 : submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in 28 : accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and 29 : the United Nations Convention on Contracts on the International Sales of Goods. 30 : 31 : *******************************************************************************************************/ 32 : #include <stdint.h> 33 : #include "options.h" 34 : #include "ivas_prot.h" 35 : #include "prot.h" 36 : #ifdef DEBUGGING 37 : #include "debug.h" 38 : #endif 39 : #include "wmc_auto.h" 40 : 41 : 42 : /*-----------------------------------------------------------------------* 43 : * ivas_ls_custom_open() 44 : * 45 : * Allocate Custom LS layout handle 46 : *-----------------------------------------------------------------------*/ 47 : 48 9 : ivas_error ivas_ls_custom_open( 49 : LSSETUP_CUSTOM_HANDLE *hLsSetupCustom /* o : Custom loudspeaker setup handle */ 50 : ) 51 : { 52 : /* Allocate handle */ 53 9 : if ( ( *hLsSetupCustom = (LSSETUP_CUSTOM_HANDLE) malloc( sizeof( LSSETUP_CUSTOM_STRUCT ) ) ) == NULL ) 54 : { 55 0 : return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Custom LS layout memory\n" ) ); 56 : } 57 : 58 9 : ( *hLsSetupCustom )->num_spk = -1; 59 9 : ( *hLsSetupCustom )->is_planar_setup = -1; 60 : 61 9 : set_zero( ( *hLsSetupCustom )->ls_azimuth, MAX_OUTPUT_CHANNELS ); 62 9 : set_zero( ( *hLsSetupCustom )->ls_elevation, MAX_OUTPUT_CHANNELS ); 63 : 64 9 : ( *hLsSetupCustom )->num_lfe = -1; 65 9 : set_s( ( *hLsSetupCustom )->lfe_idx, -1, MAX_OUTPUT_CHANNELS ); 66 : 67 9 : ( *hLsSetupCustom )->separate_ch_found = -1; 68 9 : set_f( ( *hLsSetupCustom )->separate_ch_gains, 0.0f, MAX_OUTPUT_CHANNELS ); 69 : 70 9 : return IVAS_ERR_OK; 71 : } 72 : 73 : 74 : /*-------------------------------------------------------------------------* 75 : * ivas_output_init_ls_custom() 76 : * 77 : * Setup an IVAS_OUTPUT_SETUP_HANDLE from a custom loudspeaker setup 78 : *-------------------------------------------------------------------------*/ 79 : 80 36 : void ivas_ls_custom_setup( 81 : IVAS_OUTPUT_SETUP_HANDLE hOutSetup, /* o : IVAS output setup handle */ 82 : const LSSETUP_CUSTOM_STRUCT *hLsSetupCustom /* i : Custom loudspeaker setup handle */ 83 : ) 84 : { 85 36 : hOutSetup->output_config = IVAS_AUDIO_CONFIG_LS_CUSTOM; 86 : 87 36 : hOutSetup->nchan_out_woLFE = hLsSetupCustom->num_spk; 88 36 : hOutSetup->ls_azimuth = hLsSetupCustom->ls_azimuth; 89 36 : hOutSetup->ls_elevation = hLsSetupCustom->ls_elevation; 90 : 91 36 : hOutSetup->num_lfe = hLsSetupCustom->num_lfe; 92 36 : hOutSetup->index_lfe[0] = hLsSetupCustom->lfe_idx[0]; /* IVAS_OUTPUT_SETUP only supports 1 LFE */ 93 : 94 36 : hOutSetup->is_loudspeaker_setup = TRUE; 95 36 : hOutSetup->is_planar_setup = (int8_t) hLsSetupCustom->is_planar_setup; 96 : 97 36 : return; 98 : } 99 : 100 : /*-----------------------------------------------------------------------* 101 : * ivas_ls_custom_output_init() 102 : * 103 : * Initialize decoder output handles 104 : *-----------------------------------------------------------------------*/ 105 : 106 9 : ivas_error ivas_ls_custom_output_init( 107 : Decoder_Struct *st_ivas /* i/o: IVAS decoder handle */ 108 : ) 109 : { 110 9 : if ( st_ivas->hLsSetupCustom == NULL ) 111 : { 112 0 : return IVAS_ERR_WRONG_PARAMS; 113 : } 114 : 115 9 : st_ivas->hDecoderConfig->nchan_out = st_ivas->hLsSetupCustom->num_spk + st_ivas->hLsSetupCustom->num_lfe; 116 : 117 9 : ivas_ls_custom_setup( &( st_ivas->hOutSetup ), st_ivas->hLsSetupCustom ); 118 9 : ivas_ls_custom_setup( &( st_ivas->hIntSetup ), st_ivas->hLsSetupCustom ); 119 : 120 9 : return IVAS_ERR_OK; 121 : }