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

Side by Side Diff: webrtc/modules/audio_processing/vad/vad_audio_proc_unittest.cc

Issue 1228803003: Update audio code to use size_t more correctly, (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Review comments Created 5 years, 5 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 int16_t data[kDataLength] = {0}; 44 int16_t data[kDataLength] = {0};
45 AudioFeatures features; 45 AudioFeatures features;
46 double sp[kMaxNumFrames]; 46 double sp[kMaxNumFrames];
47 while (fread(data, sizeof(int16_t), kDataLength, pcm_file) == kDataLength) { 47 while (fread(data, sizeof(int16_t), kDataLength, pcm_file) == kDataLength) {
48 audioproc.ExtractFeatures(data, kDataLength, &features); 48 audioproc.ExtractFeatures(data, kDataLength, &features);
49 if (features.num_frames > 0) { 49 if (features.num_frames > 0) {
50 ASSERT_LT(features.num_frames, kMaxNumFrames); 50 ASSERT_LT(features.num_frames, kMaxNumFrames);
51 // Read reference values. 51 // Read reference values.
52 const size_t num_frames = features.num_frames; 52 const size_t num_frames = features.num_frames;
53 ASSERT_EQ(num_frames, fread(sp, sizeof(sp[0]), num_frames, peak_file)); 53 ASSERT_EQ(num_frames, fread(sp, sizeof(sp[0]), num_frames, peak_file));
54 for (int n = 0; n < features.num_frames; n++) 54 for (size_t n = 0; n < features.num_frames; n++)
55 EXPECT_NEAR(features.spectral_peak[n], sp[n], 3); 55 EXPECT_NEAR(features.spectral_peak[n], sp[n], 3);
56 } 56 }
57 } 57 }
58 58
59 fclose(peak_file); 59 fclose(peak_file);
60 fclose(pcm_file); 60 fclose(pcm_file);
61 } 61 }
62 62
63 } // namespace webrtc 63 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698