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 : #ifdef DEBUGGING
40 : #include "debug.h"
41 : #endif
42 : #include "cnst.h"
43 : #include "prot.h"
44 : #include "wmc_auto.h"
45 :
46 : /*-------------------------------------------------------------------*
47 : * find_targets()
48 : *
49 : * Find the target vectors for excitaiton search:
50 : *-------------------------------------------------------------------*/
51 :
52 644046 : void find_targets(
53 : const float *speech, /* i : pointer to the speech frame */
54 : const float *mem_syn, /* i : memory of the synthesis filter */
55 : const int16_t i_subfr, /* i : subframe index */
56 : float *mem_w0, /* i/o: weighting filter denominator memory */
57 : const float *p_Aq, /* i : interpolated quantized A(z) filter */
58 : const float *res, /* i : residual signal */
59 : const int16_t L_subfr, /* i : length of vectors for gain quantization */
60 : const float *Ap, /* i : unquantized A(z) filter with bandwidth expansion */
61 : const float tilt_fac, /* i : tilt factor */
62 : float *xn, /* o : Close-loop Pitch search target vector */
63 : float *cn, /* o : target vector in residual domain */
64 : float *h1 /* o : impulse response of weighted synthesis filter */
65 : )
66 : {
67 : int16_t i;
68 : float error[M + 6 * L_SUBFR]; /* error of quantization */
69 : float tmp_fl[M + 3 * L_SUBFR], tmp;
70 :
71 : /*------------------------------------------------------------------------*
72 : * Find the target vector for excitation search:
73 : *
74 : * |------| res[n]
75 : * speech[n]---| A(z) |--------
76 : * |------| | |--------| error[n] |------|
77 : * zero -- (-)--| 1/A(z) |-----------| W(z) |-- target
78 : * exc |--------| |------|
79 : *
80 : * Instead of subtracting the zero-input response of filters from
81 : * the weighted input speech, the above configuration is used to
82 : * compute the target vector.
83 : *-----------------------------------------------------------------------*/
84 :
85 10948782 : for ( i = 0; i < M; i++ )
86 : {
87 10304736 : error[i] = speech[i + i_subfr - M] - mem_syn[i];
88 : }
89 :
90 644046 : syn_filt( p_Aq, M, &res[i_subfr], error + M, L_subfr, error, 0 );
91 644046 : residu( Ap, M, error + M, xn, L_subfr );
92 644046 : deemph( xn, tilt_fac, L_subfr, mem_w0 );
93 :
94 : /*-----------------------------------------------------------------*
95 : * Find target in residual domain (cn[]) for innovation search
96 : *--------------------------------------------------------------*/
97 644046 : if ( cn != NULL )
98 : {
99 : /* first half: xn[] --> cn[] */
100 644046 : set_f( tmp_fl, 0, M );
101 644046 : mvr2r( xn, tmp_fl + M, L_subfr / 2 );
102 644046 : tmp = 0.0f;
103 :
104 644046 : preemph( tmp_fl + M, tilt_fac, L_subfr / 2, &tmp );
105 644046 : syn_filt( Ap, M, tmp_fl + M, tmp_fl + M, L_subfr / 2, tmp_fl, 0 );
106 644046 : residu( p_Aq, M, tmp_fl + M, cn, L_subfr / 2 );
107 :
108 : /* second half: res[] --> cn[] (approximated and faster) */
109 644046 : mvr2r( &res[i_subfr + ( L_subfr / 2 )], cn + ( L_subfr / 2 ), L_subfr / 2 );
110 : }
111 :
112 : /*-----------------------------------------------------------------*
113 : * Compute impulse response h1[] of the weighted synthesis filter
114 : *-----------------------------------------------------------------*/
115 :
116 644046 : set_f( h1, 0, L_subfr );
117 644046 : mvr2r( Ap, h1, M + 1 );
118 644046 : syn_filt( p_Aq, M, h1, h1, L_subfr, h1 + ( M + 1 ), 0 );
119 644046 : tmp = 0.0f;
120 644046 : deemph( h1, tilt_fac, L_subfr, &tmp );
121 :
122 644046 : return;
123 : }
|