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

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

Issue 1227203003: Update audio code to use size_t more correctly, webrtc/common_audio/ portion. (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
« no previous file with comments | « webrtc/common_audio/vad/vad_unittest.cc ('k') | webrtc/common_audio/window_generator.h » ('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
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 return -1; 49 return -1;
50 } 50 }
51 if (self->init_flag != kInitCheck) { 51 if (self->init_flag != kInitCheck) {
52 return -1; 52 return -1;
53 } 53 }
54 54
55 return WebRtcVad_set_mode_core(self, mode); 55 return WebRtcVad_set_mode_core(self, mode);
56 } 56 }
57 57
58 int WebRtcVad_Process(VadInst* handle, int fs, const int16_t* audio_frame, 58 int WebRtcVad_Process(VadInst* handle, int fs, const int16_t* audio_frame,
59 int frame_length) { 59 size_t frame_length) {
60 int vad = -1; 60 int vad = -1;
61 VadInstT* self = (VadInstT*) handle; 61 VadInstT* self = (VadInstT*) handle;
62 62
63 if (handle == NULL) { 63 if (handle == NULL) {
64 return -1; 64 return -1;
65 } 65 }
66 66
67 if (self->init_flag != kInitCheck) { 67 if (self->init_flag != kInitCheck) {
68 return -1; 68 return -1;
69 } 69 }
(...skipping 13 matching lines...) Expand all
83 } else if (fs == 8000) { 83 } else if (fs == 8000) {
84 vad = WebRtcVad_CalcVad8khz(self, audio_frame, frame_length); 84 vad = WebRtcVad_CalcVad8khz(self, audio_frame, frame_length);
85 } 85 }
86 86
87 if (vad > 0) { 87 if (vad > 0) {
88 vad = 1; 88 vad = 1;
89 } 89 }
90 return vad; 90 return vad;
91 } 91 }
92 92
93 int WebRtcVad_ValidRateAndFrameLength(int rate, int frame_length) { 93 int WebRtcVad_ValidRateAndFrameLength(int rate, size_t frame_length) {
94 int return_value = -1; 94 int return_value = -1;
95 size_t i; 95 size_t i;
96 int valid_length_ms; 96 int valid_length_ms;
97 int valid_length; 97 size_t valid_length;
98 98
99 // We only allow 10, 20 or 30 ms frames. Loop through valid frame rates and 99 // We only allow 10, 20 or 30 ms frames. Loop through valid frame rates and
100 // see if we have a matching pair. 100 // see if we have a matching pair.
101 for (i = 0; i < kRatesSize; i++) { 101 for (i = 0; i < kRatesSize; i++) {
102 if (kValidRates[i] == rate) { 102 if (kValidRates[i] == rate) {
103 for (valid_length_ms = 10; valid_length_ms <= kMaxFrameLengthMs; 103 for (valid_length_ms = 10; valid_length_ms <= kMaxFrameLengthMs;
104 valid_length_ms += 10) { 104 valid_length_ms += 10) {
105 valid_length = (kValidRates[i] / 1000 * valid_length_ms); 105 valid_length = (size_t)(kValidRates[i] / 1000 * valid_length_ms);
106 if (frame_length == valid_length) { 106 if (frame_length == valid_length) {
107 return_value = 0; 107 return_value = 0;
108 break; 108 break;
109 } 109 }
110 } 110 }
111 break; 111 break;
112 } 112 }
113 } 113 }
114 114
115 return return_value; 115 return return_value;
116 } 116 }
OLDNEW
« no previous file with comments | « webrtc/common_audio/vad/vad_unittest.cc ('k') | webrtc/common_audio/window_generator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698