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

Side by Side Diff: webrtc/modules/audio_processing/high_pass_filter_impl.cc

Issue 1230503003: Update a ton of audio code to use size_t more correctly and in general reduce (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Resync Created 5 years, 4 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
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « webrtc/modules/audio_processing/gain_control_impl.cc ('k') | webrtc/modules/audio_processing/include/audio_processing.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698