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

Side by Side Diff: webrtc/common_audio/vad/vad_sp.c

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, 3 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/common_audio/vad/vad_sp.h ('k') | webrtc/common_audio/vad/vad_sp_unittest.cc » ('j') | 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) 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
11 #include "webrtc/common_audio/vad/vad_sp.h" 11 #include "webrtc/common_audio/vad/vad_sp.h"
12 12
13 #include <assert.h> 13 #include <assert.h>
14 14
15 #include "webrtc/common_audio/signal_processing/include/signal_processing_librar y.h" 15 #include "webrtc/common_audio/signal_processing/include/signal_processing_librar y.h"
16 #include "webrtc/common_audio/vad/vad_core.h" 16 #include "webrtc/common_audio/vad/vad_core.h"
17 #include "webrtc/typedefs.h" 17 #include "webrtc/typedefs.h"
18 18
19 // Allpass filter coefficients, upper and lower, in Q13. 19 // Allpass filter coefficients, upper and lower, in Q13.
20 // Upper: 0.64, Lower: 0.17. 20 // Upper: 0.64, Lower: 0.17.
21 static const int16_t kAllPassCoefsQ13[2] = { 5243, 1392 }; // Q13. 21 static const int16_t kAllPassCoefsQ13[2] = { 5243, 1392 }; // Q13.
22 static const int16_t kSmoothingDown = 6553; // 0.2 in Q15. 22 static const int16_t kSmoothingDown = 6553; // 0.2 in Q15.
23 static const int16_t kSmoothingUp = 32439; // 0.99 in Q15. 23 static const int16_t kSmoothingUp = 32439; // 0.99 in Q15.
24 24
25 // TODO(bjornv): Move this function to vad_filterbank.c. 25 // TODO(bjornv): Move this function to vad_filterbank.c.
26 // Downsampling filter based on splitting filter and allpass functions. 26 // Downsampling filter based on splitting filter and allpass functions.
27 void WebRtcVad_Downsampling(const int16_t* signal_in, 27 void WebRtcVad_Downsampling(const int16_t* signal_in,
28 int16_t* signal_out, 28 int16_t* signal_out,
29 int32_t* filter_state, 29 int32_t* filter_state,
30 int in_length) { 30 size_t in_length) {
31 int16_t tmp16_1 = 0, tmp16_2 = 0; 31 int16_t tmp16_1 = 0, tmp16_2 = 0;
32 int32_t tmp32_1 = filter_state[0]; 32 int32_t tmp32_1 = filter_state[0];
33 int32_t tmp32_2 = filter_state[1]; 33 int32_t tmp32_2 = filter_state[1];
34 int n = 0; 34 size_t n = 0;
35 int half_length = (in_length >> 1); // Downsampling by 2 gives half length. 35 // Downsampling by 2 gives half length.
36 size_t half_length = (in_length >> 1);
36 37
37 // Filter coefficients in Q13, filter state in Q0. 38 // Filter coefficients in Q13, filter state in Q0.
38 for (n = 0; n < half_length; n++) { 39 for (n = 0; n < half_length; n++) {
39 // All-pass filtering upper branch. 40 // All-pass filtering upper branch.
40 tmp16_1 = (int16_t) ((tmp32_1 >> 1) + 41 tmp16_1 = (int16_t) ((tmp32_1 >> 1) +
41 ((kAllPassCoefsQ13[0] * *signal_in) >> 14)); 42 ((kAllPassCoefsQ13[0] * *signal_in) >> 14));
42 *signal_out = tmp16_1; 43 *signal_out = tmp16_1;
43 tmp32_1 = (int32_t)(*signal_in++) - ((kAllPassCoefsQ13[0] * tmp16_1) >> 12); 44 tmp32_1 = (int32_t)(*signal_in++) - ((kAllPassCoefsQ13[0] * tmp16_1) >> 12);
44 45
45 // All-pass filtering lower branch. 46 // All-pass filtering lower branch.
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 alpha = kSmoothingUp; // 0.99 in Q15. 169 alpha = kSmoothingUp; // 0.99 in Q15.
169 } 170 }
170 } 171 }
171 tmp32 = (alpha + 1) * self->mean_value[channel]; 172 tmp32 = (alpha + 1) * self->mean_value[channel];
172 tmp32 += (WEBRTC_SPL_WORD16_MAX - alpha) * current_median; 173 tmp32 += (WEBRTC_SPL_WORD16_MAX - alpha) * current_median;
173 tmp32 += 16384; 174 tmp32 += 16384;
174 self->mean_value[channel] = (int16_t) (tmp32 >> 15); 175 self->mean_value[channel] = (int16_t) (tmp32 >> 15);
175 176
176 return self->mean_value[channel]; 177 return self->mean_value[channel];
177 } 178 }
OLDNEW
« no previous file with comments | « webrtc/common_audio/vad/vad_sp.h ('k') | webrtc/common_audio/vad/vad_sp_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698