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

Unified Diff: media/cast/test/utility/audio_utility.cc

Issue 214273003: [Cast] Remove AudioDecoder's dependency on WebRTC, and refactor/clean-up AudioReceiver. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: One moar Windows compile fix. Created 6 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/cast/test/utility/audio_utility.h ('k') | media/cast/test/utility/in_process_receiver.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/cast/test/utility/audio_utility.cc
diff --git a/media/cast/test/utility/audio_utility.cc b/media/cast/test/utility/audio_utility.cc
index f8e4957b7c35f585ef6ec4bf6a4b6850d903df93..b1c01909bbc7baa24d77f23da628a4bd5e40cfa0 100644
--- a/media/cast/test/utility/audio_utility.cc
+++ b/media/cast/test/utility/audio_utility.cc
@@ -53,6 +53,26 @@ scoped_ptr<PcmAudioFrame> ToPcmAudioFrame(const AudioBus& audio_bus,
return audio_frame.Pass();
}
+int CountZeroCrossings(const float* samples, int len) {
+ // The sample values must pass beyond |kAmplitudeThreshold| on the opposite
+ // side of zero before a crossing will be counted.
+ const float kAmplitudeThreshold = 0.03f; // 3% of max amplitude.
+
+ int count = 0;
+ int i = 0;
+ float last = 0.0f;
+ for (; i < len && fabsf(last) < kAmplitudeThreshold; ++i)
+ last = samples[i];
+ for (; i < len; ++i) {
+ if (fabsf(samples[i]) >= kAmplitudeThreshold &&
+ (last < 0) != (samples[i] < 0)) {
+ ++count;
+ last = samples[i];
+ }
+ }
+ return count;
+}
+
int CountZeroCrossings(const std::vector<int16>& samples) {
// The sample values must pass beyond |kAmplitudeThreshold| on the opposite
// side of zero before a crossing will be counted.
« no previous file with comments | « media/cast/test/utility/audio_utility.h ('k') | media/cast/test/utility/in_process_receiver.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698