Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(12)

Side by Side Diff: webrtc/modules/audio_processing/intelligibility/intelligibility_utils.cc

Issue 2087623003: Fine tune the IntelligibilityEnhancer (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: relax tolerance Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/modules/audio_processing/intelligibility/intelligibility_enhancer_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
11 #include "webrtc/modules/audio_processing/intelligibility/intelligibility_utils. h" 11 #include "webrtc/modules/audio_processing/intelligibility/intelligibility_utils. h"
12 12
13 #include <math.h> 13 #include <math.h>
14 #include <stdlib.h> 14 #include <stdlib.h>
15 #include <string.h> 15 #include <string.h>
16 #include <algorithm> 16 #include <algorithm>
17 #include <limits> 17 #include <limits>
18 18
19 namespace webrtc { 19 namespace webrtc {
20 20
21 namespace intelligibility { 21 namespace intelligibility {
22 22
23 namespace { 23 namespace {
24 24
25 const float kMinFactor = 0.01f; 25 const float kMinFactor = 0.01f;
26 const float kMaxFactor = 1000.f; 26 const float kMaxFactor = 100.f;
27 27
28 // Return |current| changed towards |target|, with the relative change being at 28 // Return |current| changed towards |target|, with the relative change being at
29 // most |limit|. 29 // most |limit|.
30 float UpdateFactor(float target, float current, float limit) { 30 float UpdateFactor(float target, float current, float limit) {
31 float gain = target / (current + std::numeric_limits<float>::epsilon()); 31 float gain = target / (current + std::numeric_limits<float>::epsilon());
32 gain = std::min(std::max(gain, 1.f - limit), 1.f + limit); 32 gain = std::min(std::max(gain, 1.f - limit), 1.f + limit);
33 return std::min(std::max(current * gain, kMinFactor), kMaxFactor);; 33 return std::min(std::max(current * gain, kMinFactor), kMaxFactor);;
34 } 34 }
35 35
36 } // namespace 36 } // namespace
(...skipping 23 matching lines...) Expand all
60 std::complex<float>* out_block) { 60 std::complex<float>* out_block) {
61 for (size_t i = 0; i < num_freqs_; ++i) { 61 for (size_t i = 0; i < num_freqs_; ++i) {
62 current_[i] = UpdateFactor(target_[i], current_[i], relative_change_limit_); 62 current_[i] = UpdateFactor(target_[i], current_[i], relative_change_limit_);
63 out_block[i] = sqrtf(fabsf(current_[i])) * in_block[i]; 63 out_block[i] = sqrtf(fabsf(current_[i])) * in_block[i];
64 } 64 }
65 } 65 }
66 66
67 } // namespace intelligibility 67 } // namespace intelligibility
68 68
69 } // namespace webrtc 69 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/audio_processing/intelligibility/intelligibility_enhancer_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698