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 : /*==================================================================================== 34 : EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 35 : ====================================================================================*/ 36 : 37 : #include <stdint.h> 38 : #include "options.h" 39 : #include "prot_fx.h" 40 : #include "ivas_cnst.h" 41 : #include "wmc_auto.h" 42 : 43 : /*-------------------------------------------------------------------------- 44 : * get_delay() 45 : * 46 : * Function returns various types of delays in the codec in ns. 47 : *--------------------------------------------------------------------------*/ 48 : 49 : /*! r: delay value in ns */ 50 6227 : Word32 get_delay_fx( 51 : const Word16 what_delay, /* i : what delay? (ENC or DEC) Q0*/ 52 : const Word32 io_fs, /* i : input/output sampling frequency Q0*/ 53 : const IVAS_FORMAT ivas_format, /* i : IVAS format */ 54 : HANDLE_CLDFB_FILTER_BANK hCldfb, /* i : Handle of Cldfb analysis */ 55 : const Word16 flag_binaural_split_coded /* i : split rendering on/off flag */ 56 : ) 57 : { 58 : Word32 delay; /*Q0*/ 59 6227 : delay = 0; 60 6227 : move32(); 61 : 62 6227 : IF( what_delay == ENC ) 63 : { 64 0 : IF( EQ_16( ivas_format, MONO_FORMAT ) ) /* EVS mono */ 65 : { 66 0 : delay = DELAY_FIR_RESAMPL_NS + ACELP_LOOK_NS; /*Q0*/ 67 0 : move32(); 68 : } 69 : ELSE 70 : { 71 0 : delay = IVAS_ENC_DELAY_NS; /*Q0*/ 72 0 : move32(); 73 0 : test(); 74 0 : if ( EQ_16( ivas_format, MASA_FORMAT ) || EQ_16( ivas_format, MASA_ISM_FORMAT ) ) 75 : { 76 0 : delay = 0; /* All delay is compensated in the decoder with MASA */ 77 0 : move32(); 78 : } 79 : } 80 : 81 0 : test(); 82 0 : if ( EQ_16( ivas_format, SBA_FORMAT ) || EQ_16( ivas_format, SBA_ISM_FORMAT ) ) 83 : { 84 : /* compensate for DirAC/SPAR filterbank delay */ 85 0 : delay = L_add( delay, IVAS_FB_ENC_DELAY_NS ); /*Q0*/ 86 : } 87 : } 88 : ELSE 89 : { 90 6227 : IF( EQ_16( ivas_format, MONO_FORMAT ) ) /* EVS mono */ 91 : { 92 3 : IF( EQ_32( io_fs, 8000 ) ) 93 : { 94 0 : delay = DELAY_CLDFB_NS; /*Q0*/ 95 0 : move32(); 96 : } 97 : ELSE 98 : { 99 3 : delay = DELAY_BWE_TOTAL_NS; /*Q0*/ 100 3 : move32(); 101 : } 102 : } 103 : ELSE /* IVAS */ 104 : { 105 6224 : delay = IVAS_DEC_DELAY_NS; /*Q0*/ 106 6224 : move32(); 107 : 108 6224 : IF( !flag_binaural_split_coded ) 109 : { 110 6224 : if ( hCldfb != NULL ) 111 : { 112 : /* compensate for filterbank delay */ 113 440 : delay = L_add( delay, IVAS_FB_DEC_DELAY_NS ); /*Q0*/ 114 : } 115 : } 116 : 117 6224 : test(); 118 6224 : if ( EQ_16( ivas_format, MASA_FORMAT ) || EQ_16( ivas_format, MASA_ISM_FORMAT ) ) 119 : { 120 5729 : delay = L_add( delay, IVAS_ENC_DELAY_NS ); /* Compensate also the encoder delay in the decoder with MASA */ /*Q0*/ 121 : } 122 : } 123 : } 124 : 125 6227 : return delay; /*Q0*/ 126 : }