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 12 matching lines...) Expand all Loading... |
23 #include "xcorr_coef.h" | 23 #include "xcorr_coef.h" |
24 #include "enhancer.h" | 24 #include "enhancer.h" |
25 #include "hp_output.h" | 25 #include "hp_output.h" |
26 | 26 |
27 | 27 |
28 | 28 |
29 /*----------------------------------------------------------------* | 29 /*----------------------------------------------------------------* |
30 * interface for enhancer | 30 * interface for enhancer |
31 *---------------------------------------------------------------*/ | 31 *---------------------------------------------------------------*/ |
32 | 32 |
33 int WebRtcIlbcfix_EnhancerInterface( /* (o) Estimated lag in end of in[] */ | 33 size_t WebRtcIlbcfix_EnhancerInterface( /* (o) Estimated lag in end of in[] */ |
34 int16_t *out, /* (o) enhanced signal */ | 34 int16_t *out, /* (o) enhanced signal */ |
35 int16_t *in, /* (i) unenhanced signal */ | 35 int16_t *in, /* (i) unenhanced signal */ |
36 IlbcDecoder *iLBCdec_inst /* (i) buffers etc */ | 36 IlbcDecoder *iLBCdec_inst /* (i) buffers etc */ |
37 ){ | 37 ){ |
38 int iblock; | 38 int iblock; |
39 int lag=20, tlag=20; | 39 size_t lag=20, tlag=20; |
40 int inLen=iLBCdec_inst->blockl+120; | 40 size_t inLen=iLBCdec_inst->blockl+120; |
41 int16_t scale, scale1, plc_blockl; | 41 int16_t scale, scale1; |
| 42 size_t plc_blockl; |
42 int16_t *enh_buf, *enh_period; | 43 int16_t *enh_buf, *enh_period; |
43 int32_t tmp1, tmp2, max, new_blocks; | 44 int32_t tmp1, tmp2, max, new_blocks; |
44 int16_t *enh_bufPtr1; | 45 int16_t *enh_bufPtr1; |
45 int i, k; | 46 size_t i; |
| 47 int k; |
46 int16_t EnChange; | 48 int16_t EnChange; |
47 int16_t SqrtEnChange; | 49 int16_t SqrtEnChange; |
48 int16_t inc; | 50 int16_t inc; |
49 int16_t win; | 51 int16_t win; |
50 int16_t *tmpW16ptr; | 52 int16_t *tmpW16ptr; |
51 int16_t startPos; | 53 int16_t startPos; |
52 int16_t *plc_pred; | 54 int16_t *plc_pred; |
53 int16_t *target, *regressor; | 55 int16_t *target, *regressor; |
54 int16_t max16; | 56 int16_t max16; |
55 int shifts; | 57 int shifts; |
56 int32_t ener; | 58 int32_t ener; |
57 int16_t enerSh; | 59 int16_t enerSh; |
58 int16_t corrSh; | 60 int16_t corrSh; |
59 int16_t ind, sh; | 61 size_t ind; |
| 62 int16_t sh; |
60 int16_t start, stop; | 63 int16_t start, stop; |
61 /* Stack based */ | 64 /* Stack based */ |
62 int16_t totsh[3]; | 65 int16_t totsh[3]; |
63 int16_t downsampled[(BLOCKL_MAX+120)>>1]; /* length 180 */ | 66 int16_t downsampled[(BLOCKL_MAX+120)>>1]; /* length 180 */ |
64 int32_t corr32[50]; | 67 int32_t corr32[50]; |
65 int32_t corrmax[3]; | 68 int32_t corrmax[3]; |
66 int16_t corr16[3]; | 69 int16_t corr16[3]; |
67 int16_t en16[3]; | 70 int16_t en16[3]; |
68 int16_t lagmax[3]; | 71 int16_t lagmax[3]; |
69 | 72 |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 ind = i; | 164 ind = i; |
162 } | 165 } |
163 } else { | 166 } else { |
164 sh = WEBRTC_SPL_MIN(31, totsh[i]-totsh[ind]); | 167 sh = WEBRTC_SPL_MIN(31, totsh[i]-totsh[ind]); |
165 if ((corr16[ind] * en16[i]) >> sh < corr16[i] * en16[ind]) { | 168 if ((corr16[ind] * en16[i]) >> sh < corr16[i] * en16[ind]) { |
166 ind = i; | 169 ind = i; |
167 } | 170 } |
168 } | 171 } |
169 } | 172 } |
170 | 173 |
171 lag = lagmax[ind] + 10; | 174 lag = (size_t)(lagmax[ind] + 10); |
172 | 175 |
173 /* Store the estimated lag in the non-downsampled domain */ | 176 /* Store the estimated lag in the non-downsampled domain */ |
174 enh_period[ENH_NBLOCKS_TOT - new_blocks + iblock] = (int16_t)(lag * 8); | 177 enh_period[ENH_NBLOCKS_TOT - new_blocks + iblock] = (int16_t)(lag * 8); |
175 | 178 |
176 /* Store the estimated lag for backward PLC */ | 179 /* Store the estimated lag for backward PLC */ |
177 if (iLBCdec_inst->prev_enh_pl==1) { | 180 if (iLBCdec_inst->prev_enh_pl==1) { |
178 if (!iblock) { | 181 if (!iblock) { |
179 tlag = lag * 2; | 182 tlag = lag * 2; |
180 } | 183 } |
181 } else { | 184 } else { |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 if (iLBCdec_inst->prev_enh_pl==1) { | 220 if (iLBCdec_inst->prev_enh_pl==1) { |
218 if (lag>plc_blockl) { | 221 if (lag>plc_blockl) { |
219 WEBRTC_SPL_MEMCPY_W16(plc_pred, &in[lag-plc_blockl], plc_blockl); | 222 WEBRTC_SPL_MEMCPY_W16(plc_pred, &in[lag-plc_blockl], plc_blockl); |
220 } else { | 223 } else { |
221 WEBRTC_SPL_MEMCPY_W16(&plc_pred[plc_blockl-lag], in, lag); | 224 WEBRTC_SPL_MEMCPY_W16(&plc_pred[plc_blockl-lag], in, lag); |
222 WEBRTC_SPL_MEMCPY_W16( | 225 WEBRTC_SPL_MEMCPY_W16( |
223 plc_pred, &enh_buf[ENH_BUFL-iLBCdec_inst->blockl-plc_blockl+lag], | 226 plc_pred, &enh_buf[ENH_BUFL-iLBCdec_inst->blockl-plc_blockl+lag], |
224 (plc_blockl-lag)); | 227 (plc_blockl-lag)); |
225 } | 228 } |
226 } else { | 229 } else { |
227 int pos; | 230 size_t pos; |
228 | 231 |
229 pos = plc_blockl; | 232 pos = plc_blockl; |
230 | 233 |
231 while (lag<pos) { | 234 while (lag<pos) { |
232 WEBRTC_SPL_MEMCPY_W16(&plc_pred[pos-lag], in, lag); | 235 WEBRTC_SPL_MEMCPY_W16(&plc_pred[pos-lag], in, lag); |
233 pos = pos - lag; | 236 pos = pos - lag; |
234 } | 237 } |
235 WEBRTC_SPL_MEMCPY_W16(plc_pred, &in[lag-pos], pos); | 238 WEBRTC_SPL_MEMCPY_W16(plc_pred, &in[lag-pos], pos); |
236 | 239 |
237 } | 240 } |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 | 276 |
274 tmp2=WEBRTC_SPL_SHIFT_W32(tmp2, (scale1)); | 277 tmp2=WEBRTC_SPL_SHIFT_W32(tmp2, (scale1)); |
275 EnChange = (int16_t)WebRtcSpl_DivW32W16(tmp2, | 278 EnChange = (int16_t)WebRtcSpl_DivW32W16(tmp2, |
276 (int16_t)tmp1); | 279 (int16_t)tmp1); |
277 | 280 |
278 /* Calculate the Sqrt of the energy in Q15 ((14+16)/2) */ | 281 /* Calculate the Sqrt of the energy in Q15 ((14+16)/2) */ |
279 SqrtEnChange = (int16_t)WebRtcSpl_SqrtFloor(EnChange << 14); | 282 SqrtEnChange = (int16_t)WebRtcSpl_SqrtFloor(EnChange << 14); |
280 | 283 |
281 | 284 |
282 /* Multiply first part of vector with 2*SqrtEnChange */ | 285 /* Multiply first part of vector with 2*SqrtEnChange */ |
283 WebRtcSpl_ScaleVector(plc_pred, plc_pred, SqrtEnChange, | 286 WebRtcSpl_ScaleVector(plc_pred, plc_pred, SqrtEnChange, plc_blockl-16, |
284 (int16_t)(plc_blockl-16), 14); | 287 14); |
285 | 288 |
286 /* Calculate increase parameter for window part (16 last samples) */ | 289 /* Calculate increase parameter for window part (16 last samples) */ |
287 /* (1-2*SqrtEnChange)/16 in Q15 */ | 290 /* (1-2*SqrtEnChange)/16 in Q15 */ |
288 inc = 2048 - (SqrtEnChange >> 3); | 291 inc = 2048 - (SqrtEnChange >> 3); |
289 | 292 |
290 win=0; | 293 win=0; |
291 tmpW16ptr=&plc_pred[plc_blockl-16]; | 294 tmpW16ptr=&plc_pred[plc_blockl-16]; |
292 | 295 |
293 for (i=16;i>0;i--) { | 296 for (i=16;i>0;i--) { |
294 *tmpW16ptr = (int16_t)( | 297 *tmpW16ptr = (int16_t)( |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 enh_bufPtr1, | 339 enh_bufPtr1, |
337 synt, | 340 synt, |
338 &iLBCdec_inst->old_syntdenum[ | 341 &iLBCdec_inst->old_syntdenum[ |
339 (iLBCdec_inst->nsub-1)*(LPC_FILTERORDER+1)], | 342 (iLBCdec_inst->nsub-1)*(LPC_FILTERORDER+1)], |
340 LPC_FILTERORDER+1, lag); | 343 LPC_FILTERORDER+1, lag); |
341 | 344 |
342 WEBRTC_SPL_MEMCPY_W16(&synt[-LPC_FILTERORDER], &synt[lag-LPC_FILTERORDER], | 345 WEBRTC_SPL_MEMCPY_W16(&synt[-LPC_FILTERORDER], &synt[lag-LPC_FILTERORDER], |
343 LPC_FILTERORDER); | 346 LPC_FILTERORDER); |
344 WebRtcIlbcfix_HpOutput(synt, (int16_t*)WebRtcIlbcfix_kHpOutCoefs, | 347 WebRtcIlbcfix_HpOutput(synt, (int16_t*)WebRtcIlbcfix_kHpOutCoefs, |
345 iLBCdec_inst->hpimemy, iLBCdec_inst->hpimemx, | 348 iLBCdec_inst->hpimemy, iLBCdec_inst->hpimemx, |
346 (int16_t)lag); | 349 lag); |
347 WebRtcSpl_FilterARFastQ12( | 350 WebRtcSpl_FilterARFastQ12( |
348 enh_bufPtr1, synt, | 351 enh_bufPtr1, synt, |
349 &iLBCdec_inst->old_syntdenum[ | 352 &iLBCdec_inst->old_syntdenum[ |
350 (iLBCdec_inst->nsub-1)*(LPC_FILTERORDER+1)], | 353 (iLBCdec_inst->nsub-1)*(LPC_FILTERORDER+1)], |
351 LPC_FILTERORDER+1, lag); | 354 LPC_FILTERORDER+1, lag); |
352 | 355 |
353 WEBRTC_SPL_MEMCPY_W16(iLBCdec_inst->syntMem, &synt[lag-LPC_FILTERORDER], | 356 WEBRTC_SPL_MEMCPY_W16(iLBCdec_inst->syntMem, &synt[lag-LPC_FILTERORDER], |
354 LPC_FILTERORDER); | 357 LPC_FILTERORDER); |
355 WebRtcIlbcfix_HpOutput(synt, (int16_t*)WebRtcIlbcfix_kHpOutCoefs, | 358 WebRtcIlbcfix_HpOutput(synt, (int16_t*)WebRtcIlbcfix_kHpOutCoefs, |
356 iLBCdec_inst->hpimemy, iLBCdec_inst->hpimemx, | 359 iLBCdec_inst->hpimemy, iLBCdec_inst->hpimemx, |
357 (int16_t)lag); | 360 lag); |
358 } | 361 } |
359 } | 362 } |
360 | 363 |
361 | 364 |
362 /* Perform enhancement block by block */ | 365 /* Perform enhancement block by block */ |
363 | 366 |
364 for (iblock = 0; iblock<new_blocks; iblock++) { | 367 for (iblock = 0; iblock<new_blocks; iblock++) { |
365 WebRtcIlbcfix_Enhancer(out + iblock * ENH_BLOCKL, | 368 WebRtcIlbcfix_Enhancer(out + iblock * ENH_BLOCKL, |
366 enh_buf, | 369 enh_buf, |
367 ENH_BUFL, | 370 ENH_BUFL, |
368 (int16_t)(iblock * ENH_BLOCKL + startPos), | 371 (int16_t)(iblock * ENH_BLOCKL + startPos), |
369 enh_period, | 372 enh_period, |
370 (int16_t*)WebRtcIlbcfix_kEnhPlocs, ENH_NBLOCKS_TOT); | 373 (int16_t*)WebRtcIlbcfix_kEnhPlocs, ENH_NBLOCKS_TOT); |
371 } | 374 } |
372 | 375 |
373 return (lag); | 376 return (lag); |
374 } | 377 } |
OLD | NEW |