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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 int16_t y_[4]; | 85 int16_t y_[4]; |
86 }; | 86 }; |
87 | 87 |
88 HighPassFilterImpl::HighPassFilterImpl(rtc::CriticalSection* crit) | 88 HighPassFilterImpl::HighPassFilterImpl(rtc::CriticalSection* crit) |
89 : crit_(crit) { | 89 : crit_(crit) { |
90 RTC_DCHECK(crit_); | 90 RTC_DCHECK(crit_); |
91 } | 91 } |
92 | 92 |
93 HighPassFilterImpl::~HighPassFilterImpl() {} | 93 HighPassFilterImpl::~HighPassFilterImpl() {} |
94 | 94 |
95 void HighPassFilterImpl::Initialize(int channels, int sample_rate_hz) { | 95 void HighPassFilterImpl::Initialize(size_t channels, int sample_rate_hz) { |
96 RTC_DCHECK_LE(0, channels); | |
97 std::vector<rtc::scoped_ptr<BiquadFilter>> new_filters(channels); | 96 std::vector<rtc::scoped_ptr<BiquadFilter>> new_filters(channels); |
98 for (int i = 0; i < channels; i++) { | 97 for (size_t i = 0; i < channels; i++) { |
99 new_filters[i].reset(new BiquadFilter(sample_rate_hz)); | 98 new_filters[i].reset(new BiquadFilter(sample_rate_hz)); |
100 } | 99 } |
101 rtc::CritScope cs(crit_); | 100 rtc::CritScope cs(crit_); |
102 filters_.swap(new_filters); | 101 filters_.swap(new_filters); |
103 } | 102 } |
104 | 103 |
105 void HighPassFilterImpl::ProcessCaptureAudio(AudioBuffer* audio) { | 104 void HighPassFilterImpl::ProcessCaptureAudio(AudioBuffer* audio) { |
106 RTC_DCHECK(audio); | 105 RTC_DCHECK(audio); |
107 rtc::CritScope cs(crit_); | 106 rtc::CritScope cs(crit_); |
108 if (!enabled_) { | 107 if (!enabled_) { |
109 return; | 108 return; |
110 } | 109 } |
111 | 110 |
112 RTC_DCHECK_GE(160u, audio->num_frames_per_band()); | 111 RTC_DCHECK_GE(160u, audio->num_frames_per_band()); |
113 RTC_DCHECK_EQ(filters_.size(), static_cast<size_t>(audio->num_channels())); | 112 RTC_DCHECK_EQ(filters_.size(), audio->num_channels()); |
114 for (size_t i = 0; i < filters_.size(); i++) { | 113 for (size_t i = 0; i < filters_.size(); i++) { |
115 filters_[i]->Process(audio->split_bands(i)[kBand0To8kHz], | 114 filters_[i]->Process(audio->split_bands(i)[kBand0To8kHz], |
116 audio->num_frames_per_band()); | 115 audio->num_frames_per_band()); |
117 } | 116 } |
118 } | 117 } |
119 | 118 |
120 int HighPassFilterImpl::Enable(bool enable) { | 119 int HighPassFilterImpl::Enable(bool enable) { |
121 rtc::CritScope cs(crit_); | 120 rtc::CritScope cs(crit_); |
122 if (!enabled_ && enable) { | 121 if (!enabled_ && enable) { |
123 for (auto& filter : filters_) { | 122 for (auto& filter : filters_) { |
124 filter->Reset(); | 123 filter->Reset(); |
125 } | 124 } |
126 } | 125 } |
127 enabled_ = enable; | 126 enabled_ = enable; |
128 return AudioProcessing::kNoError; | 127 return AudioProcessing::kNoError; |
129 } | 128 } |
130 | 129 |
131 bool HighPassFilterImpl::is_enabled() const { | 130 bool HighPassFilterImpl::is_enabled() const { |
132 rtc::CritScope cs(crit_); | 131 rtc::CritScope cs(crit_); |
133 return enabled_; | 132 return enabled_; |
134 } | 133 } |
135 } // namespace webrtc | 134 } // namespace webrtc |
OLD | NEW |