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 "cnst.h"
36 : #include "prot_fx.h"
37 :
38 : /*===================================================================*/
39 : /* FUNCTION : Interpol_delay_fx () */
40 : /*-------------------------------------------------------------------*/
41 : /* PURPOSE : Interpolate pitch lag for a subframe */
42 : /*-------------------------------------------------------------------*/
43 : /* INPUT ARGUMENTS : */
44 : /* _ (Word16) last_fx: previous frame delay, Q0 */
45 : /* _ (Word16) current_fx: current frame delay, Q0 */
46 : /* _ (Word16) SubNum : subframe number */
47 : /*-------------------------------------------------------------------*/
48 : /* OUTPUT ARGUMENTS : */
49 : /* */
50 : /* _ (Word16 []) out_fx : 3 Intepolated delays, Q4 */
51 : /*-------------------------------------------------------------------*/
52 : /* INPUT/OUTPUT ARGUMENTS : */
53 : /* _ None */
54 : /*-------------------------------------------------------------------*/
55 : /* RETURN ARGUMENTS : _ None. */
56 : /*===================================================================*/
57 : /* NOTE: this function uses a 5 entry table frac_fx (Q4 unsigned) */
58 : /*===================================================================*/
59 :
60 0 : void Interpol_delay_fx(
61 : Word16 *out_fx, /* Q4 */
62 : Word16 last_fx, /* Q0 */
63 : Word16 current_fx, /* Q0 */
64 : Word16 SubNum, /* Q0 */
65 : const Word16 *frac_fx /* Q4 */
66 : )
67 : {
68 : Word16 i, temp;
69 : Word32 L_add1, L_add2;
70 :
71 0 : FOR( i = 0; i < 3; i++ )
72 : {
73 0 : temp = sub( 16, frac_fx[SubNum + i] ); /* Q4 */
74 0 : L_add1 = L_shr( L_mult( last_fx, temp ), 1 ); /* Q4 */
75 0 : L_add2 = L_shr( L_mult( current_fx, frac_fx[SubNum + i] ), 1 ); /* Q4 */
76 0 : out_fx[i] = (Word16) L_add( L_add1, L_add2 );
77 0 : move16(); /* Q4 */
78 : }
79 0 : return;
80 : }
81 :
82 : /*-------------------------------------------------------------------*
83 : * deemph_lpc()
84 : *
85 : * De-emphasis of LP coefficients
86 : * convolve LPC with [1 -PREEMPH_FAC] to de-emphasise LPC
87 : *--------------------------------------------------------------------*/
88 :
89 0 : void deemph_lpc_fx(
90 : const Word16 *p_Aq_curr_fx, /* i : LP coefficients current frame Q12 */
91 : const Word16 *p_Aq_old_fx, /* i : LP coefficients previous frame Q12 */
92 : Word16 *LPC_de_curr_fx, /* o : De-emphasized LP coefficients current frame in Q12 */
93 : Word16 *LPC_de_old_fx, /* o : De-emphasized LP coefficients previous frame in Q12 */
94 : const Word16 deemph_old /* Q0 */
95 : )
96 : {
97 : Word16 k, temp;
98 : Word16 b_fx[M + 2]; /* Q12 */
99 0 : Word16 a_fx[2] = { -22282, 32767 }; /* Q15 {-PREEMPH_FAC,1.0} */
100 : #ifdef BASOP_NOGLOB_DECLARE_LOCAL
101 0 : Flag Overflow = 0;
102 0 : move32();
103 : #endif
104 0 : b_fx[0] = 4096;
105 0 : move16(); /* 1 in Q12 */
106 0 : FOR( k = 0; k < M; k++ )
107 : {
108 0 : b_fx[k + 1] = p_Aq_curr_fx[k];
109 0 : move16(); /* Q12 */
110 : }
111 0 : b_fx[M + 1] = 0;
112 0 : move16();
113 :
114 0 : FOR( k = 0; k <= M; k++ )
115 : {
116 : /* LPC_de_curr[k] = a[0]*b[k] + a[1]*b[k+1]; */
117 0 : temp = mult( a_fx[0], b_fx[k] ); /* Q12 */
118 0 : LPC_de_curr_fx[k] = add_o( temp, b_fx[k + 1], &Overflow );
119 0 : move16(); /* Q12 */
120 : }
121 :
122 0 : IF( EQ_16( deemph_old, 1 ) )
123 : {
124 :
125 : /* ignoring the 1st value which is 1.0 in this case */
126 0 : b_fx[0] = 4096;
127 0 : move16(); /* 1 in Q12 */
128 0 : FOR( k = 0; k < M; k++ )
129 : {
130 0 : b_fx[k + 1] = p_Aq_old_fx[k + 1]; /* Q12 */
131 0 : move16();
132 : }
133 0 : b_fx[M + 1] = 0;
134 0 : move16();
135 :
136 0 : FOR( k = 0; k <= M; k++ )
137 : {
138 : /* LPC_de_old[k] = a[0]*b[k] + a[1]*b[k+1]; */
139 0 : temp = mult( a_fx[0], b_fx[k] ); /* Q12 */
140 0 : LPC_de_old_fx[k] = add_o( temp, b_fx[k + 1], &Overflow );
141 0 : move16(); /* Q12 */
142 : }
143 : }
144 :
145 :
146 0 : return; /* both outputs LPC_de_curr_fx and LPC_de_old_fx are in Q12 */
147 : }
|