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 1218 : Word32 get_delay_fx( /* o : delay value in ms */
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 : #ifdef SPLIT_REND_WITH_HEAD_ROT
56 : ,
57 : const AUDIO_CONFIG output_config /* i : decoder output config */
58 : #endif
59 : )
60 : {
61 : Word32 delay; /*Q0*/
62 1218 : delay = 0;
63 1218 : move32();
64 :
65 1218 : IF( what_delay == ENC )
66 : {
67 624 : IF( EQ_16( ivas_format, MONO_FORMAT ) ) /* EVS mono */
68 : {
69 3 : delay = DELAY_FIR_RESAMPL_NS + ACELP_LOOK_NS; /*Q0*/
70 3 : move32();
71 : }
72 : ELSE
73 : {
74 621 : delay = IVAS_ENC_DELAY_NS; /*Q0*/
75 621 : move32();
76 621 : test();
77 621 : if ( EQ_16( ivas_format, MASA_FORMAT ) || EQ_16( ivas_format, MASA_ISM_FORMAT ) )
78 : {
79 119 : delay = 0; /* All delay is compensated in the decoder with MASA */
80 119 : move32();
81 : }
82 : }
83 624 : test();
84 624 : if ( EQ_16( ivas_format, SBA_FORMAT ) || EQ_16( ivas_format, SBA_ISM_FORMAT ) )
85 : {
86 : /* compensate for DirAC/SPAR filterbank delay */
87 279 : delay = L_add( delay, IVAS_FB_ENC_DELAY_NS ); /*Q0*/
88 : }
89 : }
90 : ELSE
91 : {
92 594 : IF( EQ_16( ivas_format, MONO_FORMAT ) ) /* EVS mono */
93 : {
94 3 : IF( EQ_32( io_fs, 8000 ) )
95 : {
96 0 : delay = DELAY_CLDFB_NS; /*Q0*/
97 0 : move32();
98 : }
99 : ELSE
100 : {
101 3 : delay = DELAY_BWE_TOTAL_NS; /*Q0*/
102 3 : move32();
103 : }
104 : }
105 : ELSE /* IVAS */
106 : {
107 591 : delay = IVAS_DEC_DELAY_NS; /*Q0*/
108 591 : move32();
109 :
110 : #ifdef SPLIT_REND_WITH_HEAD_ROT
111 :
112 : IF( NE_16( output_config, AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) )
113 : {
114 : #endif
115 591 : if ( hCldfb != NULL )
116 : {
117 : /* compensate for filterbank delay */
118 384 : delay = L_add( delay, IVAS_FB_DEC_DELAY_NS ); /*Q0*/
119 : }
120 : #ifdef SPLIT_REND_WITH_HEAD_ROT
121 : }
122 : #endif
123 591 : test();
124 591 : if ( EQ_16( ivas_format, MASA_FORMAT ) || EQ_16( ivas_format, MASA_ISM_FORMAT ) )
125 : {
126 112 : delay = L_add( delay, IVAS_ENC_DELAY_NS ); /* Compensate also the encoder delay in the decoder with MASA */ /*Q0*/
127 : }
128 : }
129 : }
130 :
131 1218 : return delay; /*Q0*/
132 : }
|