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

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

Issue 2943833002: Use constexpr to avoid a static initializer (Closed)
Patch Set: Remove unneeded static Created 3 years, 6 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 | « no previous file | no next file » | 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 15 matching lines...) Expand all
26 } 26 }
27 #include "webrtc/modules/include/module_common_types.h" 27 #include "webrtc/modules/include/module_common_types.h"
28 28
29 namespace webrtc { 29 namespace webrtc {
30 30
31 // The following structures are declared anonymous in iSAC's structs.h. To 31 // The following structures are declared anonymous in iSAC's structs.h. To
32 // forward declare them, we use this derived class trick. 32 // forward declare them, we use this derived class trick.
33 struct VadAudioProc::PitchAnalysisStruct : public ::PitchAnalysisStruct {}; 33 struct VadAudioProc::PitchAnalysisStruct : public ::PitchAnalysisStruct {};
34 struct VadAudioProc::PreFiltBankstr : public ::PreFiltBankstr {}; 34 struct VadAudioProc::PreFiltBankstr : public ::PreFiltBankstr {};
35 35
36 static const float kFrequencyResolution = 36 constexpr float kFrequencyResolution =
kwiberg-webrtc 2017/06/17 22:54:30 That constexpr (and const) imply internal linkage
hlundin-webrtc 2017/06/19 07:45:23 What kwiberg@ says.
brucedawson 2017/06/19 18:45:56 I added constexpr to kSilenceRms, to make it appea
37 kSampleRateHz / static_cast<float>(VadAudioProc::kDftSize); 37 kSampleRateHz / static_cast<float>(VadAudioProc::kDftSize);
38 static const int kSilenceRms = 5; 38 static const int kSilenceRms = 5;
39 39
40 // TODO(turajs): Make a Create or Init for VadAudioProc. 40 // TODO(turajs): Make a Create or Init for VadAudioProc.
41 VadAudioProc::VadAudioProc() 41 VadAudioProc::VadAudioProc()
42 : audio_buffer_(), 42 : audio_buffer_(),
43 num_buffer_samples_(kNumPastSignalSamples), 43 num_buffer_samples_(kNumPastSignalSamples),
44 log_old_gain_(-2), 44 log_old_gain_(-2),
45 old_lag_(50), // Arbitrary but valid as pitch-lag (in samples). 45 old_lag_(50), // Arbitrary but valid as pitch-lag (in samples).
46 pitch_analysis_handle_(new PitchAnalysisStruct), 46 pitch_analysis_handle_(new PitchAnalysisStruct),
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 size_t offset = kNumPastSignalSamples; 267 size_t offset = kNumPastSignalSamples;
268 for (size_t i = 0; i < kNum10msSubframes; i++) { 268 for (size_t i = 0; i < kNum10msSubframes; i++) {
269 rms[i] = 0; 269 rms[i] = 0;
270 for (size_t n = 0; n < kNumSubframeSamples; n++, offset++) 270 for (size_t n = 0; n < kNumSubframeSamples; n++, offset++)
271 rms[i] += audio_buffer_[offset] * audio_buffer_[offset]; 271 rms[i] += audio_buffer_[offset] * audio_buffer_[offset];
272 rms[i] = sqrt(rms[i] / kNumSubframeSamples); 272 rms[i] = sqrt(rms[i] / kNumSubframeSamples);
273 } 273 }
274 } 274 }
275 275
276 } // namespace webrtc 276 } // namespace webrtc
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698