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 "prot_fx.h" 35 : #include "wmc_auto.h" 36 : #include "ivas_prot_fx.h" 37 : 38 : 39 : /*-----------------------------------------------------------------------* 40 : * ivas_ls_custom_open() 41 : * 42 : * Allocate Custom LS layout handle 43 : *-----------------------------------------------------------------------*/ 44 3 : ivas_error ivas_ls_custom_open_fx( 45 : LSSETUP_CUSTOM_HANDLE *hLsSetupCustom /* o : Custom loudspeaker setup handle */ 46 : ) 47 : { 48 : /* Allocate handle */ 49 3 : IF( ( *hLsSetupCustom = (LSSETUP_CUSTOM_HANDLE) malloc( sizeof( LSSETUP_CUSTOM_STRUCT ) ) ) == NULL ) 50 : { 51 0 : return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Custom LS layout memory\n" ) ); 52 : } 53 : 54 3 : ( *hLsSetupCustom )->num_spk = -1; 55 3 : move16(); 56 3 : ( *hLsSetupCustom )->is_planar_setup = -1; 57 3 : move16(); 58 : 59 3 : set32_fx( ( *hLsSetupCustom )->ls_azimuth_fx, 0, MAX_OUTPUT_CHANNELS ); // Q22 60 3 : set32_fx( ( *hLsSetupCustom )->ls_elevation_fx, 0, MAX_OUTPUT_CHANNELS ); // Q22 61 : 62 3 : ( *hLsSetupCustom )->num_lfe = -1; 63 3 : move16(); 64 3 : set16_fx( ( *hLsSetupCustom )->lfe_idx, -1, MAX_OUTPUT_CHANNELS ); 65 : 66 3 : ( *hLsSetupCustom )->separate_ch_found = -1; 67 3 : move16(); 68 : 69 3 : set16_fx( ( *hLsSetupCustom )->separate_ch_gains_fx, 0, MAX_OUTPUT_CHANNELS ); 70 3 : return IVAS_ERR_OK; 71 : } 72 : 73 : /*-------------------------------------------------------------------------* 74 : * ivas_output_init_ls_custom() 75 : * 76 : * Setup an IVAS_OUTPUT_SETUP_HANDLE from a custom loudspeaker setup 77 : *-------------------------------------------------------------------------*/ 78 : 79 : 80 15 : void ivas_ls_custom_setup_fx( 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 15 : hOutSetup->output_config = IVAS_AUDIO_CONFIG_LS_CUSTOM; 86 15 : move32(); 87 : 88 15 : hOutSetup->nchan_out_woLFE = hLsSetupCustom->num_spk; 89 15 : move16(); 90 : 91 15 : hOutSetup->ls_azimuth_fx = hLsSetupCustom->ls_azimuth_fx; // Q22 92 15 : move32(); 93 15 : hOutSetup->ls_elevation_fx = hLsSetupCustom->ls_elevation_fx; // Q22 94 15 : move32(); 95 : 96 15 : hOutSetup->num_lfe = hLsSetupCustom->num_lfe; 97 15 : move16(); 98 15 : hOutSetup->index_lfe[0] = hLsSetupCustom->lfe_idx[0]; /* IVAS_OUTPUT_SETUP only supports 1 LFE */ 99 15 : move16(); 100 : 101 15 : hOutSetup->is_loudspeaker_setup = TRUE; 102 15 : move16(); 103 15 : hOutSetup->is_planar_setup = (Word8) hLsSetupCustom->is_planar_setup; 104 15 : move16(); 105 : 106 15 : return; 107 : } 108 : 109 : /*-----------------------------------------------------------------------* 110 : * ivas_ls_custom_output_init() 111 : * 112 : * Initialize decoder output handles 113 : *-----------------------------------------------------------------------*/ 114 : 115 : 116 3 : ivas_error ivas_ls_custom_output_init_fx( 117 : Decoder_Struct *st_ivas /* i/o: IVAS decoder handle */ 118 : ) 119 : { 120 3 : IF( st_ivas->hLsSetupCustom == NULL ) 121 : { 122 0 : return IVAS_ERR_WRONG_PARAMS; 123 : } 124 : 125 3 : st_ivas->hDecoderConfig->nchan_out = add( st_ivas->hLsSetupCustom->num_spk, st_ivas->hLsSetupCustom->num_lfe ); 126 3 : move16(); 127 : 128 3 : ivas_ls_custom_setup_fx( &( st_ivas->hOutSetup ), st_ivas->hLsSetupCustom ); 129 3 : ivas_ls_custom_setup_fx( &( st_ivas->hIntSetup ), st_ivas->hLsSetupCustom ); 130 : 131 3 : return IVAS_ERR_OK; 132 : }