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

Side by Side Diff: media/cast/test/utility/audio_utility.cc

Issue 2962373002: [Opus] Update to v1.2.1 (Closed)
Patch Set: Include minor updates including fix for win_clang Created 3 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 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <cmath> 5 #include <cmath>
6 #include <vector> 6 #include <vector>
7 7
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/time/time.h" 9 #include "base/time/time.h"
10 #include "media/base/audio_bus.h" 10 #include "media/base/audio_bus.h"
(...skipping 26 matching lines...) Expand all
37 base::TimeDelta::FromSeconds(1)); 37 base::TimeDelta::FromSeconds(1));
38 std::unique_ptr<AudioBus> bus(AudioBus::Create(num_channels_, num_samples)); 38 std::unique_ptr<AudioBus> bus(AudioBus::Create(num_channels_, num_samples));
39 source_.OnMoreData(base::TimeDelta(), base::TimeTicks::Now(), 0, bus.get()); 39 source_.OnMoreData(base::TimeDelta(), base::TimeTicks::Now(), 0, bus.get());
40 bus->Scale(volume_); 40 bus->Scale(volume_);
41 return bus; 41 return bus;
42 } 42 }
43 43
44 int CountZeroCrossings(const float* samples, int length) { 44 int CountZeroCrossings(const float* samples, int length) {
45 // The sample values must pass beyond |kAmplitudeThreshold| on the opposite 45 // The sample values must pass beyond |kAmplitudeThreshold| on the opposite
46 // side of zero before a crossing will be counted. 46 // side of zero before a crossing will be counted.
47 const float kAmplitudeThreshold = 0.03f; // 3% of max amplitude. 47 const float kAmplitudeThreshold = 0.02f; // 2% of max amplitude.
48 48
49 int count = 0; 49 int count = 0;
50 int i = 0; 50 int i = 0;
51 float last = 0.0f; 51 float last = 0.0f;
52 for (; i < length && fabsf(last) < kAmplitudeThreshold; ++i) 52 for (; i < length && fabsf(last) < kAmplitudeThreshold; ++i)
53 last = samples[i]; 53 last = samples[i];
54 for (; i < length; ++i) { 54 for (; i < length; ++i) {
55 if (fabsf(samples[i]) >= kAmplitudeThreshold && 55 if (fabsf(samples[i]) >= kAmplitudeThreshold &&
56 (last < 0) != (samples[i] < 0)) { 56 (last < 0) != (samples[i] < 0)) {
57 ++count; 57 ++count;
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 } 180 }
181 *timestamp = gray_coded; 181 *timestamp = gray_coded;
182 return true; 182 return true;
183 } 183 }
184 } 184 }
185 return false; 185 return false;
186 } 186 }
187 187
188 } // namespace cast 188 } // namespace cast
189 } // namespace media 189 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698