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

Unified Diff: media/base/audio_bus_unittest.cc

Issue 1769373003: AudioBus: Add a ToInterleavedFloat() method to AudioBus (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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
Index: media/base/audio_bus_unittest.cc
diff --git a/media/base/audio_bus_unittest.cc b/media/base/audio_bus_unittest.cc
index dadb8e986e7ce9eaf8692aba263d19b25e7d2105..c3c60350822f12a4a53d0e7c36b08699361b2111 100644
--- a/media/base/audio_bus_unittest.cc
+++ b/media/base/audio_bus_unittest.cc
@@ -265,6 +265,9 @@ static const int32_t kTestVectorInt32[kTestVectorSize] = {
INT32_MIN, 0, INT32_MAX, INT32_MIN, INT32_MAX / 2,
INT32_MIN / 2, 0, INT32_MAX, 0, 0};
+static const float kTestVectorFloat[kTestVectorSize] = {
+ -1.0, 0.0, 1.0, -1.0, 0.5, -0.5, 0.0, 1.0, 0.0, 0.0};
+
// Expected results.
static const int kTestVectorFrames = kTestVectorSize / 2;
static const float kTestVectorResult[][kTestVectorFrames] = {
@@ -375,6 +378,24 @@ TEST_F(AudioBusTest, ToInterleaved) {
}
}
+// Verify ToInterleavedFloat interleaves |AudioBus| channels of float
+// into a single linear output buffer correctly
mcasas 2016/04/11 23:47:08 s/ToInterleavedFloat/ToInterleavedFloat()/ Classe
+TEST_F(AudioBusTest, ToInterleavedFloat) {
+ SCOPED_TRACE("float");
+ scoped_ptr<AudioBus> bus =
+ AudioBus::Create(kTestVectorChannels, kTestVectorFrames);
+ for (int ch = 0; ch < bus->channels(); ++ch) {
+ memcpy(bus->channel(ch), kTestVectorResult[ch],
+ kTestVectorFrames * sizeof(*bus->channel(ch)));
+ }
+
+ float test_array[arraysize(kTestVectorFloat)];
+ bus->ToInterleavedFloat(0, 0, bus->frames(), test_array);
+ ASSERT_EQ(memcmp(test_array, kTestVectorFloat,
eklavyamirani 2016/04/04 08:11:58 Fixed the formatting on this in my local commit. A
mcasas 2016/04/11 23:47:08 Sorry, yes, when you have addressed the reviewers'
+ kTestVectorFrames * sizeof(*kTestVectorFloat)),
+ 0);
+}
+
// Verify ToInterleavedPartial() interleaves audio correctly.
TEST_F(AudioBusTest, ToInterleavedPartial) {
// Only interleave the middle two frames in each channel.

Powered by Google App Engine
This is Rietveld 408576698