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 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 void BlockBuffer::ReInit() { | 195 void BlockBuffer::ReInit() { |
196 WebRtc_InitBuffer(buffer_); | 196 WebRtc_InitBuffer(buffer_); |
197 } | 197 } |
198 | 198 |
199 void BlockBuffer::Insert(const float block[PART_LEN]) { | 199 void BlockBuffer::Insert(const float block[PART_LEN]) { |
200 WebRtc_WriteBuffer(buffer_, block, 1); | 200 WebRtc_WriteBuffer(buffer_, block, 1); |
201 } | 201 } |
202 | 202 |
203 void BlockBuffer::ExtractExtendedBlock(float extended_block[PART_LEN2]) { | 203 void BlockBuffer::ExtractExtendedBlock(float extended_block[PART_LEN2]) { |
204 float* block_ptr = NULL; | 204 float* block_ptr = NULL; |
205 RTC_DCHECK_LT(0u, AvaliableSpace()); | 205 RTC_DCHECK_LT(0, AvaliableSpace()); |
206 | 206 |
207 // Extract the previous block. | 207 // Extract the previous block. |
208 WebRtc_MoveReadPtr(buffer_, -1); | 208 WebRtc_MoveReadPtr(buffer_, -1); |
209 WebRtc_ReadBuffer(buffer_, reinterpret_cast<void**>(&block_ptr), | 209 WebRtc_ReadBuffer(buffer_, reinterpret_cast<void**>(&block_ptr), |
210 &extended_block[0], 1); | 210 &extended_block[0], 1); |
211 if (block_ptr != &extended_block[0]) { | 211 if (block_ptr != &extended_block[0]) { |
212 memcpy(&extended_block[0], block_ptr, PART_LEN * sizeof(float)); | 212 memcpy(&extended_block[0], block_ptr, PART_LEN * sizeof(float)); |
213 } | 213 } |
214 | 214 |
215 // Extract the current block. | 215 // Extract the current block. |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
454 if (metric->instant > metric->max) | 454 if (metric->instant > metric->max) |
455 metric->max = metric->instant; | 455 metric->max = metric->instant; |
456 | 456 |
457 // Min. | 457 // Min. |
458 if (metric->instant < metric->min) | 458 if (metric->instant < metric->min) |
459 metric->min = metric->instant; | 459 metric->min = metric->instant; |
460 | 460 |
461 // Average. | 461 // Average. |
462 metric->counter++; | 462 metric->counter++; |
463 // This is to protect overflow, which should almost never happen. | 463 // This is to protect overflow, which should almost never happen. |
464 RTC_CHECK_NE(0u, metric->counter); | 464 RTC_CHECK_NE(0, metric->counter); |
465 metric->sum += metric->instant; | 465 metric->sum += metric->instant; |
466 metric->average = metric->sum / metric->counter; | 466 metric->average = metric->sum / metric->counter; |
467 | 467 |
468 // Upper mean. | 468 // Upper mean. |
469 if (metric->instant > metric->average) { | 469 if (metric->instant > metric->average) { |
470 metric->hicounter++; | 470 metric->hicounter++; |
471 // This is to protect overflow, which should almost never happen. | 471 // This is to protect overflow, which should almost never happen. |
472 RTC_CHECK_NE(0u, metric->hicounter); | 472 RTC_CHECK_NE(0, metric->hicounter); |
473 metric->hisum += metric->instant; | 473 metric->hisum += metric->instant; |
474 metric->himean = metric->hisum / metric->hicounter; | 474 metric->himean = metric->hisum / metric->hicounter; |
475 } | 475 } |
476 } | 476 } |
477 | 477 |
478 // Threshold to protect against the ill-effects of a zero far-end. | 478 // Threshold to protect against the ill-effects of a zero far-end. |
479 const float WebRtcAec_kMinFarendPSD = 15; | 479 const float WebRtcAec_kMinFarendPSD = 15; |
480 | 480 |
481 // Updates the following smoothed Power Spectral Densities (PSD): | 481 // Updates the following smoothed Power Spectral Densities (PSD): |
482 // - sd : near-end | 482 // - sd : near-end |
(...skipping 1566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2049 | 2049 |
2050 int WebRtcAec_system_delay(AecCore* self) { | 2050 int WebRtcAec_system_delay(AecCore* self) { |
2051 return self->system_delay; | 2051 return self->system_delay; |
2052 } | 2052 } |
2053 | 2053 |
2054 void WebRtcAec_SetSystemDelay(AecCore* self, int delay) { | 2054 void WebRtcAec_SetSystemDelay(AecCore* self, int delay) { |
2055 RTC_DCHECK_GE(delay, 0); | 2055 RTC_DCHECK_GE(delay, 0); |
2056 self->system_delay = delay; | 2056 self->system_delay = delay; |
2057 } | 2057 } |
2058 } // namespace webrtc | 2058 } // namespace webrtc |
OLD | NEW |