| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2014 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 18 matching lines...) Expand all Loading... |
| 29 float delta = fabsf(target - current); | 29 float delta = fabsf(target - current); |
| 30 float sign = copysign(1.0f, target - current); | 30 float sign = copysign(1.0f, target - current); |
| 31 return current + sign * fminf(delta, limit); | 31 return current + sign * fminf(delta, limit); |
| 32 } | 32 } |
| 33 | 33 |
| 34 bool cplxfinite(complex<float> c) { | 34 bool cplxfinite(complex<float> c) { |
| 35 return std::isfinite(c.real()) && std::isfinite(c.imag()); | 35 return std::isfinite(c.real()) && std::isfinite(c.imag()); |
| 36 } | 36 } |
| 37 | 37 |
| 38 bool cplxnormal(complex<float> c) { | 38 bool cplxnormal(complex<float> c) { |
| 39 return std::isnormal(c.real()) && std::isnormal(c.imag()); | 39 return isnormal(c.real()) && isnormal(c.imag()); |
| 40 } | 40 } |
| 41 | 41 |
| 42 complex<float> zerofudge(complex<float> c) { | 42 complex<float> zerofudge(complex<float> c) { |
| 43 const static complex<float> fudge[7] = {{0.001f, 0.002f}, | 43 const static complex<float> fudge[7] = {{0.001f, 0.002f}, |
| 44 {0.008f, 0.001f}, | 44 {0.008f, 0.001f}, |
| 45 {0.003f, 0.008f}, | 45 {0.003f, 0.008f}, |
| 46 {0.0006f, 0.0009f}, | 46 {0.0006f, 0.0009f}, |
| 47 {0.001f, 0.004f}, | 47 {0.001f, 0.004f}, |
| 48 {0.003f, 0.004f}, | 48 {0.003f, 0.004f}, |
| 49 {0.002f, 0.009f}}; | 49 {0.002f, 0.009f}}; |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 for (int i = 0; i < freqs; ++i) { | 314 for (int i = 0; i < freqs; ++i) { |
| 315 target_[i] = 1.0f; | 315 target_[i] = 1.0f; |
| 316 current_[i] = 1.0f; | 316 current_[i] = 1.0f; |
| 317 } | 317 } |
| 318 } | 318 } |
| 319 | 319 |
| 320 void GainApplier::Apply(const complex<float>* in_block, | 320 void GainApplier::Apply(const complex<float>* in_block, |
| 321 complex<float>* out_block) { | 321 complex<float>* out_block) { |
| 322 for (int i = 0; i < freqs_; ++i) { | 322 for (int i = 0; i < freqs_; ++i) { |
| 323 float factor = sqrtf(fabsf(current_[i])); | 323 float factor = sqrtf(fabsf(current_[i])); |
| 324 if (!std::isnormal(factor)) { | 324 if (!isnormal(factor)) { |
| 325 factor = 1.0f; | 325 factor = 1.0f; |
| 326 } | 326 } |
| 327 out_block[i] = factor * in_block[i]; | 327 out_block[i] = factor * in_block[i]; |
| 328 current_[i] = UpdateFactor(target_[i], current_[i], change_limit_); | 328 current_[i] = UpdateFactor(target_[i], current_[i], change_limit_); |
| 329 } | 329 } |
| 330 } | 330 } |
| 331 | 331 |
| 332 } // namespace intelligibility | 332 } // namespace intelligibility |
| 333 | 333 |
| 334 } // namespace webrtc | 334 } // namespace webrtc |
| OLD | NEW |