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 : 33 : #include <stdint.h> 34 : #include "options.h" 35 : #include "prot_fx.h" 36 : #include "ivas_prot_rend_fx.h" 37 : #include "ivas_rom_rend.h" 38 : #include "ivas_rom_TdBinauralRenderer.h" 39 : #include "wmc_auto.h" 40 : 41 : /*-----------------------------------------------------------------------* 42 : * Local constants 43 : *-----------------------------------------------------------------------*/ 44 : 45 : #define IVAS_REVERB_DEFAULT_PRE_DELAY_FX 2147484 // 0.016 46 : #define IVAS_REVERB_DEFAULT_INPUT_DELAY_FX 13421773 // 0.1 47 : 48 : #define IVAS_REVERB_DEFAULT_USE_ER 0 49 : 50 : 51 : /*-----------------------------------------------------------------------* 52 : * ivas_render_config_open() 53 : * 54 : * Allocates the renderer configuration structure 55 : *-----------------------------------------------------------------------*/ 56 : 57 400 : ivas_error ivas_render_config_open_fx( 58 : RENDER_CONFIG_HANDLE *hRenderConfig /* i/o: Renderer config handle */ 59 : ) 60 : { 61 : /* Allocate HR filter set for headphones configuration */ 62 400 : IF( ( *hRenderConfig = (RENDER_CONFIG_HANDLE) malloc( sizeof( RENDER_CONFIG_DATA ) ) ) == NULL ) 63 : { 64 0 : return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for renderer configuration!" ); 65 : } 66 : 67 400 : return IVAS_ERR_OK; 68 : } 69 : 70 : 71 : /*-------------------------------------------------------------------* 72 : * ivas_render_config_close() 73 : * 74 : * Deallocates the renderer configuration structure 75 : *-------------------------------------------------------------------*/ 76 : 77 1293 : void ivas_render_config_close_fx( 78 : RENDER_CONFIG_HANDLE *hRenderConfig /* i/o: Renderer config handle */ 79 : ) 80 : { 81 1293 : test(); 82 1293 : IF( hRenderConfig == NULL || *hRenderConfig == NULL ) 83 : { 84 893 : return; 85 : } 86 : 87 400 : free( *hRenderConfig ); 88 400 : *hRenderConfig = NULL; 89 : 90 400 : return; 91 : } 92 : 93 : 94 : /*-------------------------------------------------------------------* 95 : * ivas_render_config_init_from_rom() 96 : * 97 : * Initializes the renderer configuration structure from ROM 98 : *-------------------------------------------------------------------*/ 99 : 100 400 : ivas_error ivas_render_config_init_from_rom_fx( 101 : RENDER_CONFIG_HANDLE *hRenderConfig /* i/o: Renderer config handle */ 102 : ) 103 : { 104 : Word16 i; 105 400 : test(); 106 400 : IF( hRenderConfig == NULL || *hRenderConfig == NULL ) 107 : { 108 0 : return IVAS_ERROR( IVAS_ERR_UNEXPECTED_NULL_POINTER, "Unexpected null pointer while attempting to fill renderer configuration from ROM" ); 109 : } 110 400 : ( *hRenderConfig )->roomAcoustics.nBands = IVAS_REVERB_DEFAULT_N_BANDS; 111 400 : move16(); 112 400 : ( *hRenderConfig )->roomAcoustics.acousticPreDelay_fx = IVAS_REVERB_DEFAULT_PRE_DELAY_FX; 113 400 : move32(); 114 400 : ( *hRenderConfig )->roomAcoustics.inputPreDelay_fx = IVAS_REVERB_DEFAULT_INPUT_DELAY_FX; 115 400 : move32(); 116 400 : ( *hRenderConfig )->roomAcoustics.use_er = IVAS_REVERB_DEFAULT_USE_ER; 117 400 : move16(); 118 400 : set32_fx( &( *hRenderConfig )->roomAcoustics.pFc_input_fx[0], 0, CLDFB_NO_CHANNELS_MAX ); 119 400 : set32_fx( &( *hRenderConfig )->roomAcoustics.pAcoustic_rt60_fx[0], 0, CLDFB_NO_CHANNELS_MAX ); 120 400 : set32_fx( &( *hRenderConfig )->roomAcoustics.pAcoustic_dsr_fx[0], 0, CLDFB_NO_CHANNELS_MAX ); 121 : 122 400 : Copy32( ivas_reverb_default_fc_fx, ( *hRenderConfig )->roomAcoustics.pFc_input_fx, IVAS_REVERB_DEFAULT_N_BANDS ); 123 400 : Copy32( ivas_reverb_default_RT60_fx, ( *hRenderConfig )->roomAcoustics.pAcoustic_rt60_fx, IVAS_REVERB_DEFAULT_N_BANDS ); 124 400 : Copy32( ivas_reverb_default_DSR_fx, ( *hRenderConfig )->roomAcoustics.pAcoustic_dsr_fx, IVAS_REVERB_DEFAULT_N_BANDS ); 125 : 126 2000 : FOR( i = 0; i < MAX_NUM_OBJECTS; i++ ) 127 : { 128 1600 : ( *hRenderConfig )->directivity_fx[i_mult( i, 3 )] = 23040; /* Front cone */ /*Q6*/ 129 1600 : move16(); 130 1600 : ( *hRenderConfig )->directivity_fx[add( i_mult( i, 3 ), 1 )] = 23040; /* Back cone */ /*Q6*/ 131 1600 : move16(); 132 1600 : ( *hRenderConfig )->directivity_fx[add( i_mult( i, 3 ), 2 )] = 32767 /*1.0f in Q15*/; /* Back attenuation */ 133 1600 : move16(); 134 : } 135 400 : ( *hRenderConfig )->distAtt_fx[0] = 2113929216; /* Maximum radius (2^ISM_RADIUS_NBITS-1)*0.25 */ /*15.75 in Q27*/ /* Default max dist */ 136 400 : move32(); 137 400 : ( *hRenderConfig )->distAtt_fx[1] = ONE_IN_Q30; // Q30 /* Default ref dist */ 138 400 : move32(); 139 400 : ( *hRenderConfig )->distAtt_fx[2] = ONE_IN_Q30; // Q30 /* Default rolloff factor */ 140 400 : move32(); 141 400 : ( *hRenderConfig )->split_rend_config.splitRendBitRate = ISAR_MAX_SPLIT_REND_BITRATE; 142 400 : move32(); 143 400 : ( *hRenderConfig )->split_rend_config.dof = 3; 144 400 : move16(); 145 400 : ( *hRenderConfig )->split_rend_config.hq_mode = 0; 146 400 : move16(); 147 400 : ( *hRenderConfig )->split_rend_config.codec_delay_ms = 0; 148 400 : move16(); 149 400 : ( *hRenderConfig )->split_rend_config.isar_frame_size_ms = 20; 150 400 : move16(); 151 400 : ( *hRenderConfig )->split_rend_config.codec_frame_size_ms = 0; /* 0 means "use default for selected codec" */ 152 400 : move16(); 153 400 : ( *hRenderConfig )->split_rend_config.codec = ISAR_SPLIT_REND_CODEC_DEFAULT; 154 400 : move32(); 155 400 : ( *hRenderConfig )->split_rend_config.poseCorrectionMode = ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB; 156 400 : move32(); 157 400 : ( *hRenderConfig )->split_rend_config.rendererSelection = IVAS_BIN_RENDERER_TYPE_DEFAULT; 158 400 : move32(); 159 400 : ( *hRenderConfig )->split_rend_config.lc3plus_highres = 0; 160 400 : move16(); 161 : 162 400 : return IVAS_ERR_OK; 163 : }