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

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, 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
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..516957518ad42c57184fd56300e5fee9a55a15bb 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, 1.0, -1.0, 0.5,
+ -0.5, 0, 1.0, 0, 0};
mcasas 2016/03/09 00:24:18 This needs formatting, use git cl format before up
eklavyamirani 2016/03/15 03:48:13 Done.
+
// Expected results.
static const int kTestVectorFrames = kTestVectorSize / 2;
static const float kTestVectorResult[][kTestVectorFrames] = {
@@ -375,6 +378,21 @@ TEST_F(AudioBusTest, ToInterleaved) {
}
}
+TEST_F(AudioBusTest, ToInterleavedFloat) {
mcasas 2016/03/09 00:24:18 Add a comment like in l.341
eklavyamirani 2016/03/15 03:48:13 Done.
+ 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)];
mcasas 2016/03/09 00:24:18 You might want to add a SCOPED_TRACE("float"); fo
eklavyamirani 2016/03/15 03:48:13 Done. Is this to output information when the test
mcasas 2016/04/11 23:47:07 Yes.
+ bus->ToInterleavedFloat(0, 0, bus->frames(), bus->channels(), test_array);
+ ASSERT_EQ(memcmp(test_array, kTestVectorFloat,
+ 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