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.452 Aug 12, 2021. Version 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 6856 : 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 6856 : delay = 0;
60 6856 : move32();
61 :
62 6856 : IF( what_delay == ENC )
63 : {
64 628 : IF( EQ_16( ivas_format, MONO_FORMAT ) ) /* EVS mono */
65 : {
66 3 : delay = DELAY_FIR_RESAMPL_NS + ACELP_LOOK_NS; /*Q0*/
67 3 : move32();
68 : }
69 : ELSE
70 : {
71 625 : delay = IVAS_ENC_DELAY_NS; /*Q0*/
72 625 : move32();
73 625 : test();
74 625 : if ( EQ_16( ivas_format, MASA_FORMAT ) || EQ_16( ivas_format, MASA_ISM_FORMAT ) )
75 : {
76 119 : delay = 0; /* All delay is compensated in the decoder with MASA */
77 119 : move32();
78 : }
79 : }
80 :
81 628 : test();
82 628 : if ( EQ_16( ivas_format, SBA_FORMAT ) || EQ_16( ivas_format, SBA_ISM_FORMAT ) )
83 : {
84 : /* compensate for DirAC/SPAR filterbank delay */
85 282 : delay = L_add( delay, IVAS_FB_ENC_DELAY_NS ); /*Q0*/
86 : }
87 : }
88 : ELSE
89 : {
90 6228 : 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 6225 : delay = IVAS_DEC_DELAY_NS; /*Q0*/
106 6225 : move32();
107 :
108 6225 : IF( !flag_binaural_split_coded )
109 : {
110 6225 : if ( hCldfb != NULL )
111 : {
112 : /* compensate for filterbank delay */
113 441 : delay = L_add( delay, IVAS_FB_DEC_DELAY_NS ); /*Q0*/
114 : }
115 : }
116 :
117 6225 : test();
118 6225 : 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 6856 : return delay; /*Q0*/
126 : }
|