• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *  Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
3  *
4  *  Use of this source code is governed by a BSD-style license
5  *  that can be found in the LICENSE file in the root of the source
6  *  tree. An additional intellectual property rights grant can be found
7  *  in the file PATENTS.  All contributing project authors may
8  *  be found in the AUTHORS file in the root of the source tree.
9  */
10 
11 /*
12  * initialize.c
13  *
14  * Internal initfunctions
15  *
16  */
17 
18 #include "codec.h"
19 #include "structs.h"
20 #include "pitch_estimator.h"
21 
22 
WebRtcIsacfix_InitMaskingEnc(MaskFiltstr_enc * maskdata)23 void WebRtcIsacfix_InitMaskingEnc(MaskFiltstr_enc *maskdata) {
24 
25   int k;
26 
27   for (k = 0; k < WINLEN; k++) {
28     maskdata->DataBufferLoQ0[k] = (int16_t) 0;
29     maskdata->DataBufferHiQ0[k] = (int16_t) 0;
30   }
31   for (k = 0; k < ORDERLO+1; k++) {
32     maskdata->CorrBufLoQQ[k] = (int32_t) 0;
33     maskdata->CorrBufLoQdom[k] = 0;
34 
35     maskdata->PreStateLoGQ15[k] = 0;
36 
37   }
38   for (k = 0; k < ORDERHI+1; k++) {
39     maskdata->CorrBufHiQQ[k] = (int32_t) 0;
40     maskdata->CorrBufHiQdom[k] = 0;
41     maskdata->PreStateHiGQ15[k] = 0;
42   }
43 
44   maskdata->OldEnergy = 10;
45 
46   return;
47 }
48 
WebRtcIsacfix_InitMaskingDec(MaskFiltstr_dec * maskdata)49 void WebRtcIsacfix_InitMaskingDec(MaskFiltstr_dec *maskdata) {
50 
51   int k;
52 
53   for (k = 0; k < ORDERLO+1; k++)
54   {
55     maskdata->PostStateLoGQ0[k] = 0;
56   }
57   for (k = 0; k < ORDERHI+1; k++)
58   {
59     maskdata->PostStateHiGQ0[k] = 0;
60   }
61 
62   maskdata->OldEnergy = 10;
63 
64   return;
65 }
66 
67 
68 
69 
70 
71 
72 
WebRtcIsacfix_InitPreFilterbank(PreFiltBankstr * prefiltdata)73 void WebRtcIsacfix_InitPreFilterbank(PreFiltBankstr *prefiltdata)
74 {
75   int k;
76 
77   for (k = 0; k < QLOOKAHEAD; k++) {
78     prefiltdata->INLABUF1_fix[k] = 0;
79     prefiltdata->INLABUF2_fix[k] = 0;
80   }
81   for (k = 0; k < 2 * (QORDER - 1); k++) {
82     prefiltdata->INSTAT1_fix[k] = 0;
83     prefiltdata->INSTAT2_fix[k] = 0;
84   }
85 
86   /* High pass filter states */
87   prefiltdata->HPstates_fix[0] = 0;
88   prefiltdata->HPstates_fix[1] = 0;
89 
90   return;
91 }
92 
WebRtcIsacfix_InitPostFilterbank(PostFiltBankstr * postfiltdata)93 void WebRtcIsacfix_InitPostFilterbank(PostFiltBankstr *postfiltdata)
94 {
95   int k;
96 
97   for (k = 0; k < 2 * POSTQORDER; k++) {
98     postfiltdata->STATE_0_LOWER_fix[k] = 0;
99     postfiltdata->STATE_0_UPPER_fix[k] = 0;
100   }
101 
102   /* High pass filter states */
103 
104   postfiltdata->HPstates1_fix[0] = 0;
105   postfiltdata->HPstates1_fix[1] = 0;
106 
107   postfiltdata->HPstates2_fix[0] = 0;
108   postfiltdata->HPstates2_fix[1] = 0;
109 
110   return;
111 }
112 
113 
WebRtcIsacfix_InitPitchFilter(PitchFiltstr * pitchfiltdata)114 void WebRtcIsacfix_InitPitchFilter(PitchFiltstr *pitchfiltdata)
115 {
116   int k;
117 
118   for (k = 0; k < PITCH_BUFFSIZE; k++)
119     pitchfiltdata->ubufQQ[k] = 0;
120   for (k = 0; k < (PITCH_DAMPORDER); k++)
121     pitchfiltdata->ystateQQ[k] = 0;
122 
123   pitchfiltdata->oldlagQ7 = 6400; /* 50.0 in Q7 */
124   pitchfiltdata->oldgainQ12 = 0;
125 }
126 
WebRtcIsacfix_InitPitchAnalysis(PitchAnalysisStruct * State)127 void WebRtcIsacfix_InitPitchAnalysis(PitchAnalysisStruct *State)
128 {
129   int k;
130 
131   for (k = 0; k < PITCH_CORR_LEN2+PITCH_CORR_STEP2+PITCH_MAX_LAG/2-PITCH_FRAME_LEN/2+2; k++) {
132     State->dec_buffer16[k] = 0;
133   }
134   for (k = 0; k < 2 * ALLPASSSECTIONS + 1; k++) {
135     State->decimator_state32[k] = 0;
136   }
137 
138   for (k = 0; k < QLOOKAHEAD; k++)
139     State->inbuf[k] = 0;
140 
141   WebRtcIsacfix_InitPitchFilter(&(State->PFstr_wght));
142 
143   WebRtcIsacfix_InitPitchFilter(&(State->PFstr));
144 }
145 
146 
WebRtcIsacfix_InitPlc(PLCstr * State)147 void WebRtcIsacfix_InitPlc( PLCstr *State )
148 {
149   State->decayCoeffPriodic = WEBRTC_SPL_WORD16_MAX;
150   State->decayCoeffNoise = WEBRTC_SPL_WORD16_MAX;
151 
152   State->used = PLC_WAS_USED;
153 
154   WebRtcSpl_ZerosArrayW16(State->overlapLP, RECOVERY_OVERLAP);
155   WebRtcSpl_ZerosArrayW16(State->lofilt_coefQ15, ORDERLO);
156   WebRtcSpl_ZerosArrayW16(State->hifilt_coefQ15, ORDERHI );
157 
158   State->AvgPitchGain_Q12 = 0;
159   State->lastPitchGain_Q12 = 0;
160   State->lastPitchLag_Q7 = 0;
161   State->gain_lo_hiQ17[0]=State->gain_lo_hiQ17[1] = 0;
162   WebRtcSpl_ZerosArrayW16(State->prevPitchInvIn, FRAMESAMPLES/2);
163   WebRtcSpl_ZerosArrayW16(State->prevPitchInvOut, PITCH_MAX_LAG + 10 );
164   WebRtcSpl_ZerosArrayW32(State->prevHP, PITCH_MAX_LAG + 10 );
165   State->pitchCycles = 0;
166   State->A = 0;
167   State->B = 0;
168   State->pitchIndex = 0;
169   State->stretchLag = 240;
170   State->seed = 4447;
171 
172 
173 }
174