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 0.016f 46 : #define IVAS_REVERB_DEFAULT_PRE_DELAY_FX 2147484 47 : #define IVAS_REVERB_DEFAULT_INPUT_DELAY 0.1f 48 : #define IVAS_REVERB_DEFAULT_INPUT_DELAY_FX 13421773 49 : 50 : #define IVAS_REVERB_DEFAULT_USE_ER 0 51 : 52 : 53 : /*-----------------------------------------------------------------------* 54 : * ivas_render_config_open() 55 : * 56 : * Allocates the renderer configuration structure 57 : *-----------------------------------------------------------------------*/ 58 : 59 381 : ivas_error ivas_render_config_open( 60 : RENDER_CONFIG_HANDLE *hRenderConfig /* i/o: Renderer config handle */ 61 : ) 62 : { 63 : /* Allocate HR filter set for headphones configuration */ 64 381 : IF( ( *hRenderConfig = (RENDER_CONFIG_HANDLE) malloc( sizeof( RENDER_CONFIG_DATA ) ) ) == NULL ) 65 : { 66 0 : return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for renderer configuration!" ); 67 : } 68 : 69 381 : return IVAS_ERR_OK; 70 : } 71 : 72 : 73 : /*-------------------------------------------------------------------* 74 : * ivas_render_config_close() 75 : * 76 : * Deallocates the renderer configuration structure 77 : *-------------------------------------------------------------------*/ 78 : 79 1262 : void ivas_render_config_close( 80 : RENDER_CONFIG_HANDLE *hRenderConfig /* i/o: Renderer config handle */ 81 : ) 82 : { 83 1262 : test(); 84 1262 : IF( hRenderConfig == NULL || *hRenderConfig == NULL ) 85 : { 86 881 : return; 87 : } 88 : 89 381 : free( *hRenderConfig ); 90 381 : *hRenderConfig = NULL; 91 : 92 381 : return; 93 : } 94 : 95 : 96 : /*-------------------------------------------------------------------* 97 : * ivas_render_config_init_from_rom() 98 : * 99 : * Initializes the renderer configuration structure from ROM 100 : *-------------------------------------------------------------------*/ 101 : 102 381 : ivas_error ivas_render_config_init_from_rom_fx( 103 : RENDER_CONFIG_HANDLE *hRenderConfig /* i/o: Renderer config handle */ 104 : ) 105 : { 106 : Word16 i; 107 381 : test(); 108 381 : IF( hRenderConfig == NULL || *hRenderConfig == NULL ) 109 : { 110 0 : return IVAS_ERROR( IVAS_ERR_UNEXPECTED_NULL_POINTER, "Unexpected null pointer while attempting to fill renderer configuration from ROM" ); 111 : } 112 381 : ( *hRenderConfig )->roomAcoustics.override = FALSE; 113 381 : move16(); 114 381 : ( *hRenderConfig )->roomAcoustics.nBands = IVAS_REVERB_DEFAULT_N_BANDS; 115 381 : move16(); 116 381 : ( *hRenderConfig )->roomAcoustics.acousticPreDelay_fx = IVAS_REVERB_DEFAULT_PRE_DELAY_FX; 117 381 : move32(); 118 381 : ( *hRenderConfig )->roomAcoustics.inputPreDelay_fx = IVAS_REVERB_DEFAULT_INPUT_DELAY_FX; 119 381 : move32(); 120 381 : ( *hRenderConfig )->roomAcoustics.use_er = IVAS_REVERB_DEFAULT_USE_ER; 121 381 : move16(); 122 381 : set32_fx( &( *hRenderConfig )->roomAcoustics.pFc_input_fx[0], 0, CLDFB_NO_CHANNELS_MAX ); 123 381 : set32_fx( &( *hRenderConfig )->roomAcoustics.pAcoustic_rt60_fx[0], 0, CLDFB_NO_CHANNELS_MAX ); 124 381 : set32_fx( &( *hRenderConfig )->roomAcoustics.pAcoustic_dsr_fx[0], 0, CLDFB_NO_CHANNELS_MAX ); 125 : 126 381 : Copy32( ivas_reverb_default_fc_fx, ( *hRenderConfig )->roomAcoustics.pFc_input_fx, IVAS_REVERB_DEFAULT_N_BANDS ); 127 381 : Copy32( ivas_reverb_default_RT60_fx, ( *hRenderConfig )->roomAcoustics.pAcoustic_rt60_fx, IVAS_REVERB_DEFAULT_N_BANDS ); 128 381 : Copy32( ivas_reverb_default_DSR_fx, ( *hRenderConfig )->roomAcoustics.pAcoustic_dsr_fx, IVAS_REVERB_DEFAULT_N_BANDS ); 129 : 130 1905 : FOR( i = 0; i < MAX_NUM_OBJECTS; i++ ) 131 : { 132 1524 : ( *hRenderConfig )->directivity_fx[i_mult( i, 3 )] = 23040; /* Front cone */ /*Q6*/ 133 1524 : move16(); 134 1524 : ( *hRenderConfig )->directivity_fx[add( i_mult( i, 3 ), 1 )] = 23040; /* Back cone */ /*Q6*/ 135 1524 : move16(); 136 1524 : ( *hRenderConfig )->directivity_fx[add( i_mult( i, 3 ), 2 )] = 32767 /*1.0f in Q15*/; /* Back attenuation */ 137 1524 : move16(); 138 : } 139 : 140 381 : return IVAS_ERR_OK; 141 : }