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 "cnst.h"
40 : #include "prot_fx.h"
41 : #include "wmc_auto.h"
42 :
43 :
44 336768 : Word16 Enr_1_Az_fx_o( /* o : impulse response energy Q3 */
45 : const Word16 Aq[], /* i : LP filter coefs Qx based on the fact that Aq[0] == 1.0 */
46 : const Word16 len, /* i : impulse response length Q0 */
47 : Flag *Overflow_out /* o : propagating the Overflow flag to upper level */
48 : )
49 : {
50 : Word16 h1[2 * L_SUBFR];
51 : Word16 *y;
52 : Word16 i, j, a0, q;
53 : Word32 L_tmp, L_tmp2;
54 : #ifdef BASOP_NOGLOB_DECLARE_LOCAL
55 336768 : Flag Overflow = 0;
56 336768 : move32();
57 : #endif
58 : /* Find the impulse response */
59 :
60 336768 : q = sub( 3, norm_s( Aq[0] ) );
61 336768 : a0 = shr( Aq[0], q ); /* Q11 */
62 336768 : q = sub( 4, q );
63 :
64 : /*-----------------------------------------------------------------------*
65 : * Do the filtering (first two iters unrolled to avoid multiplies with 0)
66 : *-----------------------------------------------------------------------*/
67 :
68 336768 : y = h1;
69 : /* h1_in Q11, h1_out Q10 */
70 336768 : L_tmp = L_mult( a0, 1 << 13 ); /* Q25 = L_mult(Q11,Q13) */
71 336768 : *y = round_fx( L_tmp ); /* Q25 to Q9 */
72 336768 : move16();
73 336768 : L_tmp2 = L_mult( *y, *y ); /* Q19 = L_mult(Q9,Q9) */
74 336768 : y++;
75 :
76 336768 : L_tmp = L_msu( 0, Aq[1], y[-1] ); /* Q23 = L_mult(Q14,Q9) */
77 336768 : L_tmp = L_shl( L_tmp, q );
78 336768 : *y = round_fx( L_tmp ); /* Q25 to Q9 */
79 336768 : move16();
80 336768 : L_tmp2 = L_mac( L_tmp2, *y, *y ); /* Q19 = L_mult(Q9,Q9) */
81 336768 : y++;
82 :
83 : /* Skip Zeros */
84 5051520 : FOR( i = 2; i < M; i++ )
85 : {
86 4714752 : L_tmp = L_msu( 0, Aq[1], y[-1] );
87 40075392 : FOR( j = 2; j <= i; j++ )
88 : {
89 35360640 : L_tmp = L_msu_o( L_tmp, Aq[j], y[-j], &Overflow );
90 : }
91 :
92 4714752 : L_tmp = L_shl_o( L_tmp, q, &Overflow );
93 4714752 : *y = round_fx_o( L_tmp, &Overflow );
94 4714752 : move16();
95 4714752 : L_tmp2 = L_mac_o( L_tmp2, *y, *y, &Overflow );
96 4714752 : y++;
97 : }
98 : /* Normal Filtering */
99 24184448 : FOR( ; i < len; i++ )
100 : {
101 23847680 : L_tmp = L_msu( 0, Aq[1], y[-1] );
102 381562880 : FOR( j = 2; j <= M; j++ )
103 : {
104 357715200 : L_tmp = L_msu_o( L_tmp, Aq[j], y[-j], &Overflow );
105 : }
106 :
107 23847680 : L_tmp = L_shl_o( L_tmp, q, &Overflow );
108 23847680 : *y = round_fx_o( L_tmp, &Overflow );
109 23847680 : move16();
110 23847680 : L_tmp2 = L_mac_o( L_tmp2, *y, *y, &Overflow );
111 23847680 : y++;
112 : }
113 336768 : *Overflow_out = Overflow;
114 336768 : move32();
115 336768 : return round_fx_o( L_tmp2, Overflow_out ); /* Q19 to Q3 */
116 : }
117 336768 : Word16 Enr_1_Az_fx( /* o : impulse response energy Q3 */
118 : const Word16 Aq[], /* i : LP filter coefs Qx based on the fact that Aq[0] == 1.0 */
119 : const Word16 len /* i : impulse response length Q0 */
120 : )
121 : {
122 336768 : Flag Overflow = 0;
123 336768 : move32();
124 336768 : return Enr_1_Az_fx_o( Aq, len, &Overflow );
125 : }
|