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

Side by Side Diff: media/base/audio_bus_unittest.cc

Issue 13726011: Add vector_math::FMUL. Replace audio_util::AdjustVolume. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix volume == 1 case. Created 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « media/base/audio_bus.cc ('k') | media/base/audio_converter.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <limits> 5 #include <limits>
6 6
7 #include "base/stringprintf.h" 7 #include "base/stringprintf.h"
8 #include "base/time.h" 8 #include "base/time.h"
9 #include "media/audio/audio_parameters.h" 9 #include "media/audio/audio_parameters.h"
10 #include "media/base/audio_bus.h" 10 #include "media/base/audio_bus.h"
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 } 349 }
350 350
351 int16 test_array[arraysize(kTestVectorInt16)]; 351 int16 test_array[arraysize(kTestVectorInt16)];
352 expected->ToInterleavedPartial( 352 expected->ToInterleavedPartial(
353 kPartialStart, kPartialFrames, sizeof(*kTestVectorInt16), test_array); 353 kPartialStart, kPartialFrames, sizeof(*kTestVectorInt16), test_array);
354 ASSERT_EQ(memcmp( 354 ASSERT_EQ(memcmp(
355 test_array, kTestVectorInt16 + kPartialStart * kTestVectorChannels, 355 test_array, kTestVectorInt16 + kPartialStart * kTestVectorChannels,
356 kPartialFrames * sizeof(*kTestVectorInt16) * kTestVectorChannels), 0); 356 kPartialFrames * sizeof(*kTestVectorInt16) * kTestVectorChannels), 0);
357 } 357 }
358 358
359 TEST_F(AudioBusTest, Scale) {
360 scoped_ptr<AudioBus> bus = AudioBus::Create(kChannels, kFrameCount);
361
362 // Fill the bus with dummy data.
363 static const float kFillValue = 1;
364 for (int i = 0; i < bus->channels(); ++i)
365 std::fill(bus->channel(i), bus->channel(i) + bus->frames(), kFillValue);
366
367 // Adjust by an invalid volume and ensure volume is unchanged.
368 bus->Scale(-1);
369 for (int i = 0; i < bus->channels(); ++i) {
370 SCOPED_TRACE("Invalid Scale");
371 VerifyValue(bus->channel(i), bus->frames(), kFillValue);
372 }
373
374 // Verify correct volume adjustment.
375 static const float kVolume = 0.5;
376 bus->Scale(kVolume);
377 for (int i = 0; i < bus->channels(); ++i) {
378 SCOPED_TRACE("Half Scale");
379 VerifyValue(bus->channel(i), bus->frames(), kFillValue * kVolume);
380 }
381
382 // Verify zero volume case.
383 bus->Scale(0);
384 for (int i = 0; i < bus->channels(); ++i) {
385 SCOPED_TRACE("Zero Scale");
386 VerifyValue(bus->channel(i), bus->frames(), 0);
387 }
388 }
389
359 } // namespace media 390 } // namespace media
OLDNEW
« no previous file with comments | « media/base/audio_bus.cc ('k') | media/base/audio_converter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698