Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 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 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 243 { | 243 { |
| 244 stt->inQueue = 2; | 244 stt->inQueue = 2; |
| 245 } | 245 } |
| 246 | 246 |
| 247 /* call VAD (use low band only) */ | 247 /* call VAD (use low band only) */ |
| 248 WebRtcAgc_ProcessVad(&stt->vadMic, in_mic[0], samples); | 248 WebRtcAgc_ProcessVad(&stt->vadMic, in_mic[0], samples); |
| 249 | 249 |
| 250 return 0; | 250 return 0; |
| 251 } | 251 } |
| 252 | 252 |
| 253 int WebRtcAgc_AddFarend(void *state, const int16_t *in_far, size_t samples) | 253 int WebRtcAgc_AddFarend(void *state, const int16_t *in_far, size_t samples) { |
| 254 { | 254 LegacyAgc* stt = (LegacyAgc*)state; |
| 255 LegacyAgc* stt; | |
| 256 stt = (LegacyAgc*)state; | |
| 257 | 255 |
| 258 if (stt == NULL) | 256 int err = WebRtcAgc_GetAddFarendError(state, samples); |
| 259 { | |
| 260 return -1; | |
| 261 } | |
| 262 | 257 |
| 263 if (stt->fs == 8000) | 258 if (err != 0) |
| 264 { | 259 return err; |
| 265 if (samples != 80) | |
| 266 { | |
| 267 return -1; | |
| 268 } | |
| 269 } else if (stt->fs == 16000 || stt->fs == 32000 || stt->fs == 48000) | |
| 270 { | |
| 271 if (samples != 160) | |
| 272 { | |
| 273 return -1; | |
| 274 } | |
| 275 } else | |
| 276 { | |
| 277 return -1; | |
| 278 } | |
| 279 | 260 |
| 280 return WebRtcAgc_AddFarendToDigital(&stt->digitalAgc, in_far, samples); | 261 return WebRtcAgc_AddFarendToDigital(&stt->digitalAgc, in_far, samples); |
| 281 } | 262 } |
| 282 | 263 |
| 264 int WebRtcAgc_GetAddFarendError(void *state, size_t samples) { | |
|
hlundin-webrtc
2015/11/05 13:01:09
Take a LegacyAgc* as input argument instead, and s
peah-webrtc
2015/11/06 07:10:58
That would be better, but since LegacyAgc is not a
hlundin-webrtc
2015/11/06 07:52:33
Acknowledged.
peah-webrtc
2015/11/06 08:10:03
Acknowledged.
| |
| 265 LegacyAgc* stt; | |
| 266 stt = (LegacyAgc*)state; | |
| 267 | |
| 268 if (stt == NULL) | |
| 269 return -1; | |
| 270 | |
| 271 if (stt->fs == 8000) { | |
| 272 if (samples != 80) | |
| 273 return -1; | |
| 274 } else if (stt->fs == 16000 || stt->fs == 32000 || stt->fs == 48000) { | |
| 275 if (samples != 160) | |
| 276 return -1; | |
| 277 } else { | |
| 278 return -1; | |
| 279 } | |
| 280 | |
| 281 return 0; | |
| 282 } | |
| 283 | |
| 283 int WebRtcAgc_VirtualMic(void *agcInst, int16_t* const* in_near, | 284 int WebRtcAgc_VirtualMic(void *agcInst, int16_t* const* in_near, |
| 284 size_t num_bands, size_t samples, int32_t micLevelIn, | 285 size_t num_bands, size_t samples, int32_t micLevelIn, |
| 285 int32_t *micLevelOut) | 286 int32_t *micLevelOut) |
| 286 { | 287 { |
| 287 int32_t tmpFlt, micLevelTmp, gainIdx; | 288 int32_t tmpFlt, micLevelTmp, gainIdx; |
| 288 uint16_t gain; | 289 uint16_t gain; |
| 289 size_t ii, j; | 290 size_t ii, j; |
| 290 LegacyAgc* stt; | 291 LegacyAgc* stt; |
| 291 | 292 |
| 292 uint32_t nrg; | 293 uint32_t nrg; |
| (...skipping 1217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1510 #endif | 1511 #endif |
| 1511 return -1; | 1512 return -1; |
| 1512 } else | 1513 } else |
| 1513 { | 1514 { |
| 1514 #ifdef WEBRTC_AGC_DEBUG_DUMP | 1515 #ifdef WEBRTC_AGC_DEBUG_DUMP |
| 1515 fprintf(stt->fpt, "\n"); | 1516 fprintf(stt->fpt, "\n"); |
| 1516 #endif | 1517 #endif |
| 1517 return 0; | 1518 return 0; |
| 1518 } | 1519 } |
| 1519 } | 1520 } |
| OLD | NEW |