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 29 matching lines...) Expand all Loading... |
40 } else { | 40 } else { |
41 hpf->ba = kFilterCoefficients; | 41 hpf->ba = kFilterCoefficients; |
42 } | 42 } |
43 | 43 |
44 WebRtcSpl_MemSetW16(hpf->x, 0, 2); | 44 WebRtcSpl_MemSetW16(hpf->x, 0, 2); |
45 WebRtcSpl_MemSetW16(hpf->y, 0, 4); | 45 WebRtcSpl_MemSetW16(hpf->y, 0, 4); |
46 | 46 |
47 return AudioProcessing::kNoError; | 47 return AudioProcessing::kNoError; |
48 } | 48 } |
49 | 49 |
50 int Filter(FilterState* hpf, int16_t* data, int length) { | 50 int Filter(FilterState* hpf, int16_t* data, size_t length) { |
51 assert(hpf != NULL); | 51 assert(hpf != NULL); |
52 | 52 |
53 int32_t tmp_int32 = 0; | 53 int32_t tmp_int32 = 0; |
54 int16_t* y = hpf->y; | 54 int16_t* y = hpf->y; |
55 int16_t* x = hpf->x; | 55 int16_t* x = hpf->x; |
56 const int16_t* ba = hpf->ba; | 56 const int16_t* ba = hpf->ba; |
57 | 57 |
58 for (int i = 0; i < length; i++) { | 58 for (size_t i = 0; i < length; i++) { |
59 // y[i] = b[0] * x[i] + b[1] * x[i-1] + b[2] * x[i-2] | 59 // y[i] = b[0] * x[i] + b[1] * x[i-1] + b[2] * x[i-2] |
60 // + -a[1] * y[i-1] + -a[2] * y[i-2]; | 60 // + -a[1] * y[i-1] + -a[2] * y[i-2]; |
61 | 61 |
62 tmp_int32 = y[1] * ba[3]; // -a[1] * y[i-1] (low part) | 62 tmp_int32 = y[1] * ba[3]; // -a[1] * y[i-1] (low part) |
63 tmp_int32 += y[3] * ba[4]; // -a[2] * y[i-2] (low part) | 63 tmp_int32 += y[3] * ba[4]; // -a[2] * y[i-2] (low part) |
64 tmp_int32 = (tmp_int32 >> 15); | 64 tmp_int32 = (tmp_int32 >> 15); |
65 tmp_int32 += y[0] * ba[3]; // -a[1] * y[i-1] (high part) | 65 tmp_int32 += y[0] * ba[3]; // -a[1] * y[i-1] (high part) |
66 tmp_int32 += y[2] * ba[4]; // -a[2] * y[i-2] (high part) | 66 tmp_int32 += y[2] * ba[4]; // -a[2] * y[i-2] (high part) |
67 tmp_int32 = (tmp_int32 << 1); | 67 tmp_int32 = (tmp_int32 << 1); |
68 | 68 |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 int HighPassFilterImpl::num_handles_required() const { | 159 int HighPassFilterImpl::num_handles_required() const { |
160 return apm_->num_output_channels(); | 160 return apm_->num_output_channels(); |
161 } | 161 } |
162 | 162 |
163 int HighPassFilterImpl::GetHandleError(void* handle) const { | 163 int HighPassFilterImpl::GetHandleError(void* handle) const { |
164 // The component has no detailed errors. | 164 // The component has no detailed errors. |
165 assert(handle != NULL); | 165 assert(handle != NULL); |
166 return apm_->kUnspecifiedError; | 166 return apm_->kUnspecifiedError; |
167 } | 167 } |
168 } // namespace webrtc | 168 } // namespace webrtc |
OLD | NEW |