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

Side by Side Diff: webrtc/tools/agc/activity_metric.cc

Issue 1316523002: Convert channel counts to size_t. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Fix compile Created 4 years, 11 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 namespace webrtc { 49 namespace webrtc {
50 50
51 // TODO(turajs) A new CL will be committed soon where ExtractFeatures will 51 // TODO(turajs) A new CL will be committed soon where ExtractFeatures will
52 // notify the caller of "silence" input, instead of bailing out. We would not 52 // notify the caller of "silence" input, instead of bailing out. We would not
53 // need the following function when such a change is made. 53 // need the following function when such a change is made.
54 54
55 // Add some dither to quiet frames. This avoids the ExtractFeatures skip a 55 // Add some dither to quiet frames. This avoids the ExtractFeatures skip a
56 // silence frame. Otherwise true VAD would drift with respect to the audio. 56 // silence frame. Otherwise true VAD would drift with respect to the audio.
57 // We only consider mono inputs. 57 // We only consider mono inputs.
58 static void DitherSilence(AudioFrame* frame) { 58 static void DitherSilence(AudioFrame* frame) {
59 ASSERT_EQ(1, frame->num_channels_); 59 ASSERT_EQ(1u, frame->num_channels_);
60 const double kRmsSilence = 5; 60 const double kRmsSilence = 5;
61 const double sum_squared_silence = kRmsSilence * kRmsSilence * 61 const double sum_squared_silence = kRmsSilence * kRmsSilence *
62 frame->samples_per_channel_; 62 frame->samples_per_channel_;
63 double sum_squared = 0; 63 double sum_squared = 0;
64 for (size_t n = 0; n < frame->samples_per_channel_; n++) 64 for (size_t n = 0; n < frame->samples_per_channel_; n++)
65 sum_squared += frame->data_[n] * frame->data_[n]; 65 sum_squared += frame->data_[n] * frame->data_[n];
66 if (sum_squared <= sum_squared_silence) { 66 if (sum_squared <= sum_squared_silence) {
67 for (size_t n = 0; n < frame->samples_per_channel_; n++) 67 for (size_t n = 0; n < frame->samples_per_channel_; n++)
68 frame->data_[n] = (rand() & 0xF) - 8; // NOLINT: ignore non-threadsafe. 68 frame->data_[n] = (rand() & 0xF) - 8; // NOLINT: ignore non-threadsafe.
69 } 69 }
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 " one probability per frame.\n" 375 " one probability per frame.\n"
376 "\nUsage:\n\n" 376 "\nUsage:\n\n"
377 "activity_metric input_pcm [options]\n" 377 "activity_metric input_pcm [options]\n"
378 "where 'input_pcm' is the input audio sampled at 16 kHz in 16 bits " 378 "where 'input_pcm' is the input audio sampled at 16 kHz in 16 bits "
379 "format.\n\n"; 379 "format.\n\n";
380 google::SetUsageMessage(kUsage); 380 google::SetUsageMessage(kUsage);
381 google::ParseCommandLineFlags(&argc, &argv, true); 381 google::ParseCommandLineFlags(&argc, &argv, true);
382 webrtc::void_main(argc, argv); 382 webrtc::void_main(argc, argv);
383 return 0; 383 return 0;
384 } 384 }
OLDNEW
« no previous file with comments | « webrtc/system_wrappers/source/aligned_array_unittest.cc ('k') | webrtc/tools/agc/agc_harness.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698