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.h" 36 : #include "ivas_prot_rend.h" 37 : #include "ivas_rom_rend.h" 38 : #ifdef DEBUGGING 39 : #include "debug.h" 40 : #endif 41 : #include "wmc_auto.h" 42 : 43 : 44 : /*-----------------------------------------------------------------------* 45 : * Local constants 46 : *-----------------------------------------------------------------------*/ 47 : 48 : #define IVAS_REVERB_DEFAULT_PRE_DELAY 0.016f 49 : #define IVAS_REVERB_DEFAULT_INPUT_DELAY 0.1f 50 : 51 : #define IVAS_REVERB_DEFAULT_USE_ER 0 52 : 53 : 54 : /*-----------------------------------------------------------------------* 55 : * ivas_render_config_open() 56 : * 57 : * Allocates the renderer configuration structure 58 : *-----------------------------------------------------------------------*/ 59 : 60 1015 : ivas_error ivas_render_config_open( 61 : RENDER_CONFIG_HANDLE *hRenderConfig /* i/o: Renderer config handle */ 62 : ) 63 : { 64 : /* Allocate HR filter set for headphones configuration */ 65 1015 : if ( ( *hRenderConfig = (RENDER_CONFIG_HANDLE) malloc( sizeof( RENDER_CONFIG_DATA ) ) ) == NULL ) 66 : { 67 0 : return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for renderer configuration!" ); 68 : } 69 : 70 1015 : return IVAS_ERR_OK; 71 : } 72 : 73 : 74 : /*-------------------------------------------------------------------* 75 : * ivas_render_config_close() 76 : * 77 : * Deallocates the renderer configuration structure 78 : *-------------------------------------------------------------------*/ 79 : 80 3197 : void ivas_render_config_close( 81 : RENDER_CONFIG_HANDLE *hRenderConfig /* i/o: Renderer config handle */ 82 : ) 83 : { 84 3197 : if ( hRenderConfig == NULL || *hRenderConfig == NULL ) 85 : { 86 2182 : return; 87 : } 88 : 89 1015 : free( *hRenderConfig ); 90 1015 : *hRenderConfig = NULL; 91 : 92 1015 : return; 93 : } 94 : 95 : 96 : /*-------------------------------------------------------------------* 97 : * ivas_render_config_init_from_rom() 98 : * 99 : * Initializes the renderer configuration structure from ROM 100 : *-------------------------------------------------------------------*/ 101 : 102 1015 : ivas_error ivas_render_config_init_from_rom( 103 : RENDER_CONFIG_HANDLE *hRenderConfig /* i/o: Renderer config handle */ 104 : ) 105 : { 106 : int16_t i; 107 : 108 1015 : 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 : 113 : #ifdef DEBUGGING 114 : ( *hRenderConfig )->renderer_type_override = IVAS_RENDER_TYPE_OVERRIDE_NONE; 115 : #endif 116 1015 : ( *hRenderConfig )->roomAcoustics.nBands = IVAS_REVERB_DEFAULT_N_BANDS; 117 1015 : ( *hRenderConfig )->roomAcoustics.acousticPreDelay = IVAS_REVERB_DEFAULT_PRE_DELAY; 118 1015 : ( *hRenderConfig )->roomAcoustics.inputPreDelay = IVAS_REVERB_DEFAULT_INPUT_DELAY; 119 1015 : ( *hRenderConfig )->roomAcoustics.use_er = IVAS_REVERB_DEFAULT_USE_ER; 120 1015 : set_zero( &( *hRenderConfig )->roomAcoustics.pFc_input[0], CLDFB_NO_CHANNELS_MAX ); 121 1015 : set_zero( &( *hRenderConfig )->roomAcoustics.pAcoustic_rt60[0], CLDFB_NO_CHANNELS_MAX ); 122 1015 : set_zero( &( *hRenderConfig )->roomAcoustics.pAcoustic_dsr[0], CLDFB_NO_CHANNELS_MAX ); 123 : 124 1015 : mvr2r( ivas_reverb_default_fc, ( *hRenderConfig )->roomAcoustics.pFc_input, IVAS_REVERB_DEFAULT_N_BANDS ); 125 1015 : mvr2r( ivas_reverb_default_RT60, ( *hRenderConfig )->roomAcoustics.pAcoustic_rt60, IVAS_REVERB_DEFAULT_N_BANDS ); 126 1015 : mvr2r( ivas_reverb_default_DSR, ( *hRenderConfig )->roomAcoustics.pAcoustic_dsr, IVAS_REVERB_DEFAULT_N_BANDS ); 127 : 128 5075 : for ( i = 0; i < MAX_NUM_OBJECTS; i++ ) 129 : { 130 4060 : ( *hRenderConfig )->directivity[i * 3] = 360.0f; /* Front cone */ 131 4060 : ( *hRenderConfig )->directivity[i * 3 + 1] = 360.0f; /* Back cone */ 132 4060 : ( *hRenderConfig )->directivity[i * 3 + 2] = 1.0f; /* Back attenuation */ 133 : } 134 : 135 1015 : ( *hRenderConfig )->distAtt[0] = 15.75f; /* Default max dist */ 136 1015 : ( *hRenderConfig )->distAtt[1] = 1.0f; /* Default ref dist */ 137 1015 : ( *hRenderConfig )->distAtt[2] = 1.0f; /* Default rolloff factor */ 138 : 139 : /* ISAR-related parameters */ 140 1015 : ( *hRenderConfig )->split_rend_config.splitRendBitRate = ISAR_MAX_SPLIT_REND_BITRATE; 141 1015 : ( *hRenderConfig )->split_rend_config.dof = 3; 142 1015 : ( *hRenderConfig )->split_rend_config.hq_mode = 0; 143 1015 : ( *hRenderConfig )->split_rend_config.codec_delay_ms = 0; 144 1015 : ( *hRenderConfig )->split_rend_config.isar_frame_size_ms = 20; 145 1015 : ( *hRenderConfig )->split_rend_config.codec_frame_size_ms = 0; /* 0 means "use default for selected codec" */ 146 1015 : ( *hRenderConfig )->split_rend_config.codec = ISAR_SPLIT_REND_CODEC_DEFAULT; 147 1015 : ( *hRenderConfig )->split_rend_config.poseCorrectionMode = ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB; 148 1015 : ( *hRenderConfig )->split_rend_config.rendererSelection = IVAS_BIN_RENDERER_TYPE_DEFAULT; 149 1015 : ( *hRenderConfig )->split_rend_config.lc3plus_highres = 0; 150 : 151 1015 : return IVAS_ERR_OK; 152 : }