OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 plc_blockl=40; | 89 plc_blockl=40; |
90 new_blocks=2; | 90 new_blocks=2; |
91 startPos=440; /* Start position for enhancement | 91 startPos=440; /* Start position for enhancement |
92 (640-new_blocks*ENH_BLOCKL-40) */ | 92 (640-new_blocks*ENH_BLOCKL-40) */ |
93 } | 93 } |
94 | 94 |
95 /* Update the pitch prediction for each enhancer block, move the old ones */ | 95 /* Update the pitch prediction for each enhancer block, move the old ones */ |
96 memmove(enh_period, &enh_period[new_blocks], | 96 memmove(enh_period, &enh_period[new_blocks], |
97 (ENH_NBLOCKS_TOT - new_blocks) * sizeof(*enh_period)); | 97 (ENH_NBLOCKS_TOT - new_blocks) * sizeof(*enh_period)); |
98 | 98 |
99 k=WebRtcSpl_DownsampleFast( | 99 k = WebRtcSpl_DownsampleFast( |
100 enh_buf+ENH_BUFL-inLen, /* Input samples */ | 100 enh_buf+ENH_BUFL-inLen, /* Input samples */ |
101 (int16_t)(inLen+ENH_BUFL_FILTEROVERHEAD), | 101 inLen + ENH_BUFL_FILTEROVERHEAD, |
102 downsampled, | 102 downsampled, |
103 (int16_t)(inLen / 2), | 103 inLen / 2, |
104 (int16_t*)WebRtcIlbcfix_kLpFiltCoefs, /* Coefficients in Q12 */ | 104 (int16_t*)WebRtcIlbcfix_kLpFiltCoefs, /* Coefficients in Q12 */ |
105 FILTERORDER_DS_PLUS1, /* Length of filter (order-1) */ | 105 FILTERORDER_DS_PLUS1, /* Length of filter (order-1) */ |
106 FACTOR_DS, | 106 FACTOR_DS, |
107 DELAY_DS); | 107 DELAY_DS); |
108 | 108 |
109 /* Estimate the pitch in the down sampled domain. */ | 109 /* Estimate the pitch in the down sampled domain. */ |
110 for(iblock = 0; iblock<new_blocks; iblock++){ | 110 for(iblock = 0; iblock<new_blocks; iblock++){ |
111 | 111 |
112 /* references */ | 112 /* references */ |
113 target = downsampled + 60 + iblock * ENH_BLOCKL_HALF; | 113 target = downsampled + 60 + iblock * ENH_BLOCKL_HALF; |
114 regressor = target - 10; | 114 regressor = target - 10; |
115 | 115 |
116 /* scaling */ | 116 /* scaling */ |
117 max16=WebRtcSpl_MaxAbsValueW16(®ressor[-50], | 117 max16 = WebRtcSpl_MaxAbsValueW16(®ressor[-50], ENH_BLOCKL_HALF + 50 - 1); |
118 (int16_t)(ENH_BLOCKL_HALF+50-1)); | |
119 shifts = WebRtcSpl_GetSizeInBits((uint32_t)(max16 * max16)) - 25; | 118 shifts = WebRtcSpl_GetSizeInBits((uint32_t)(max16 * max16)) - 25; |
120 shifts = WEBRTC_SPL_MAX(0, shifts); | 119 shifts = WEBRTC_SPL_MAX(0, shifts); |
121 | 120 |
122 /* compute cross correlation */ | 121 /* compute cross correlation */ |
123 WebRtcSpl_CrossCorrelation(corr32, target, regressor, | 122 WebRtcSpl_CrossCorrelation(corr32, target, regressor, |
124 ENH_BLOCKL_HALF, 50, (int16_t)shifts, -1); | 123 ENH_BLOCKL_HALF, 50, (int16_t)shifts, -1); |
125 | 124 |
126 /* Find 3 highest correlations that should be compared for the | 125 /* Find 3 highest correlations that should be compared for the |
127 highest (corr*corr)/ener */ | 126 highest (corr*corr)/ener */ |
128 | 127 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 | 191 |
193 /* Calculate the best lag of the new frame | 192 /* Calculate the best lag of the new frame |
194 This is used to interpolate backwards and mix with the PLC'd data | 193 This is used to interpolate backwards and mix with the PLC'd data |
195 */ | 194 */ |
196 | 195 |
197 /* references */ | 196 /* references */ |
198 target=in; | 197 target=in; |
199 regressor=in+tlag-1; | 198 regressor=in+tlag-1; |
200 | 199 |
201 /* scaling */ | 200 /* scaling */ |
202 max16=WebRtcSpl_MaxAbsValueW16(regressor, (int16_t)(plc_blockl+3-1)); | 201 max16 = WebRtcSpl_MaxAbsValueW16(regressor, plc_blockl + 3 - 1); |
203 if (max16>5000) | 202 if (max16>5000) |
204 shifts=2; | 203 shifts=2; |
205 else | 204 else |
206 shifts=0; | 205 shifts=0; |
207 | 206 |
208 /* compute cross correlation */ | 207 /* compute cross correlation */ |
209 WebRtcSpl_CrossCorrelation(corr32, target, regressor, | 208 WebRtcSpl_CrossCorrelation(corr32, target, regressor, |
210 plc_blockl, 3, (int16_t)shifts, 1); | 209 plc_blockl, 3, (int16_t)shifts, 1); |
211 | 210 |
212 /* find lag */ | 211 /* find lag */ |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 WebRtcSpl_MemSetW16(iLBCdec_inst->hpimemx, 0, 2); | 330 WebRtcSpl_MemSetW16(iLBCdec_inst->hpimemx, 0, 2); |
332 | 331 |
333 /* Initialize filter memory by filtering through 2 lags */ | 332 /* Initialize filter memory by filtering through 2 lags */ |
334 WEBRTC_SPL_MEMCPY_W16(&synt[-LPC_FILTERORDER], iLBCdec_inst->syntMem, | 333 WEBRTC_SPL_MEMCPY_W16(&synt[-LPC_FILTERORDER], iLBCdec_inst->syntMem, |
335 LPC_FILTERORDER); | 334 LPC_FILTERORDER); |
336 WebRtcSpl_FilterARFastQ12( | 335 WebRtcSpl_FilterARFastQ12( |
337 enh_bufPtr1, | 336 enh_bufPtr1, |
338 synt, | 337 synt, |
339 &iLBCdec_inst->old_syntdenum[ | 338 &iLBCdec_inst->old_syntdenum[ |
340 (iLBCdec_inst->nsub-1)*(LPC_FILTERORDER+1
)], | 339 (iLBCdec_inst->nsub-1)*(LPC_FILTERORDER+1
)], |
341 LPC_FILTERORDER+1, (int16_t)lag); | 340 LPC_FILTERORDER+1, lag); |
342 | 341 |
343 WEBRTC_SPL_MEMCPY_W16(&synt[-LPC_FILTERORDER], &synt[lag-LPC_FILTERORDER], | 342 WEBRTC_SPL_MEMCPY_W16(&synt[-LPC_FILTERORDER], &synt[lag-LPC_FILTERORDER], |
344 LPC_FILTERORDER); | 343 LPC_FILTERORDER); |
345 WebRtcIlbcfix_HpOutput(synt, (int16_t*)WebRtcIlbcfix_kHpOutCoefs, | 344 WebRtcIlbcfix_HpOutput(synt, (int16_t*)WebRtcIlbcfix_kHpOutCoefs, |
346 iLBCdec_inst->hpimemy, iLBCdec_inst->hpimemx, | 345 iLBCdec_inst->hpimemy, iLBCdec_inst->hpimemx, |
347 (int16_t)lag); | 346 (int16_t)lag); |
348 WebRtcSpl_FilterARFastQ12( | 347 WebRtcSpl_FilterARFastQ12( |
349 enh_bufPtr1, synt, | 348 enh_bufPtr1, synt, |
350 &iLBCdec_inst->old_syntdenum[ | 349 &iLBCdec_inst->old_syntdenum[ |
351 (iLBCdec_inst->nsub-1)*(LPC_FILTERORDER+1
)], | 350 (iLBCdec_inst->nsub-1)*(LPC_FILTERORDER+1
)], |
352 LPC_FILTERORDER+1, (int16_t)lag); | 351 LPC_FILTERORDER+1, lag); |
353 | 352 |
354 WEBRTC_SPL_MEMCPY_W16(iLBCdec_inst->syntMem, &synt[lag-LPC_FILTERORDER], | 353 WEBRTC_SPL_MEMCPY_W16(iLBCdec_inst->syntMem, &synt[lag-LPC_FILTERORDER], |
355 LPC_FILTERORDER); | 354 LPC_FILTERORDER); |
356 WebRtcIlbcfix_HpOutput(synt, (int16_t*)WebRtcIlbcfix_kHpOutCoefs, | 355 WebRtcIlbcfix_HpOutput(synt, (int16_t*)WebRtcIlbcfix_kHpOutCoefs, |
357 iLBCdec_inst->hpimemy, iLBCdec_inst->hpimemx, | 356 iLBCdec_inst->hpimemy, iLBCdec_inst->hpimemx, |
358 (int16_t)lag); | 357 (int16_t)lag); |
359 } | 358 } |
360 } | 359 } |
361 | 360 |
362 | 361 |
363 /* Perform enhancement block by block */ | 362 /* Perform enhancement block by block */ |
364 | 363 |
365 for (iblock = 0; iblock<new_blocks; iblock++) { | 364 for (iblock = 0; iblock<new_blocks; iblock++) { |
366 WebRtcIlbcfix_Enhancer(out + iblock * ENH_BLOCKL, | 365 WebRtcIlbcfix_Enhancer(out + iblock * ENH_BLOCKL, |
367 enh_buf, | 366 enh_buf, |
368 ENH_BUFL, | 367 ENH_BUFL, |
369 (int16_t)(iblock * ENH_BLOCKL + startPos), | 368 (int16_t)(iblock * ENH_BLOCKL + startPos), |
370 enh_period, | 369 enh_period, |
371 (int16_t*)WebRtcIlbcfix_kEnhPlocs, ENH_NBLOCKS_TOT); | 370 (int16_t*)WebRtcIlbcfix_kEnhPlocs, ENH_NBLOCKS_TOT); |
372 } | 371 } |
373 | 372 |
374 return (lag); | 373 return (lag); |
375 } | 374 } |
OLD | NEW |