summaryrefslogtreecommitdiffstats
path: root/media/audio/audio_util_unittest.cc
diff options
context:
space:
mode:
authorfbarchard@chromium.org <fbarchard@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-20 19:30:33 +0000
committerfbarchard@chromium.org <fbarchard@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-20 19:30:33 +0000
commit8511b2c7075a3fbc9b27652deaab575f9d5ea49d (patch)
treecc343886f722dd57ca1d060c95f8b0194cad894e /media/audio/audio_util_unittest.cc
parent00e3f152083aea092353b3d284c368b48136f33c (diff)
downloadchromium_src-8511b2c7075a3fbc9b27652deaab575f9d5ea49d.zip
chromium_src-8511b2c7075a3fbc9b27652deaab575f9d5ea49d.tar.gz
chromium_src-8511b2c7075a3fbc9b27652deaab575f9d5ea49d.tar.bz2
Fold first 3 channels of multichannel instead of 5. Use fixed point.
BUG=none TEST=play a multichannel video, such as trek6.ogv. Voices should sound centered and music stereo. Review URL: http://codereview.chromium.org/304006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@29550 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/audio/audio_util_unittest.cc')
-rw-r--r--media/audio/audio_util_unittest.cc24
1 files changed, 15 insertions, 9 deletions
diff --git a/media/audio/audio_util_unittest.cc b/media/audio/audio_util_unittest.cc
index 4554f6e..c0ed0fc 100644
--- a/media/audio/audio_util_unittest.cc
+++ b/media/audio/audio_util_unittest.cc
@@ -14,7 +14,10 @@ namespace media {
TEST(AudioUtilTest, AdjustVolume_u8) {
// Test AdjustVolume() on 8 bit samples.
uint8 samples_u8[kNumberOfSamples] = { 4, 0x40, 0x80, 0xff };
- uint8 expected_u8[kNumberOfSamples] = { 2, 0x20, 0x40, 0x7f };
+ uint8 expected_u8[kNumberOfSamples] = { (4 - 128) / 2 + 128,
+ (0x40 - 128) / 2 + 128,
+ (0x80 - 128) / 2 + 128,
+ (0xff - 128) / 2 + 128 };
bool result_u8 = media::AdjustVolume(samples_u8, sizeof(samples_u8),
1, // channels.
sizeof(samples_u8[0]),
@@ -77,9 +80,12 @@ TEST(AudioUtilTest, AdjustVolume_s32) {
}
TEST(AudioUtilTest, FoldChannels_u8) {
- // Test AdjustVolume() on 16 bit samples.
+ // Test FoldChannels() on 8 bit samples.
uint8 samples_u8[6] = { 130, 100, 150, 70, 130, 170 };
- uint8 expected_u8[2] = { 43, 153 };
+ uint8 expected_u8[2] = { static_cast<uint8>((130 - 128) * 0.707 +
+ (100 - 128) + 128),
+ static_cast<uint8>((130 - 128) * 0.707 +
+ (150 - 128) + 128) };
bool result_u8 = media::FoldChannels(samples_u8, sizeof(samples_u8),
6, // channels.
sizeof(samples_u8[0]),
@@ -90,10 +96,10 @@ TEST(AudioUtilTest, FoldChannels_u8) {
}
TEST(AudioUtilTest, FoldChannels_s16) {
- // Test AdjustVolume() on 16 bit samples.
+ // Test FoldChannels() on 16 bit samples.
int16 samples_s16[6] = { 12, 1, 3, 7, 13, 17 };
- int16 expected_s16[2] = { static_cast<int16>(12 * .707 + 1 + 7),
- static_cast<int16>(12 * .707 + 3 + 13) };
+ int16 expected_s16[2] = { static_cast<int16>(12 * .707 + 1),
+ static_cast<int16>(12 * .707 + 3) };
bool result_s16 = media::FoldChannels(samples_s16, sizeof(samples_s16),
6, // channels.
sizeof(samples_s16[0]),
@@ -104,10 +110,10 @@ TEST(AudioUtilTest, FoldChannels_s16) {
}
TEST(AudioUtilTest, FoldChannels_s32) {
- // Test AdjustVolume() on 16 bit samples.
+ // Test FoldChannels() on 32 bit samples.
int32 samples_s32[6] = { 12, 1, 3, 7, 13, 17 };
- int32 expected_s32[2] = { static_cast<int16>(12 * .707 + 1 + 7),
- static_cast<int16>(12 * .707 + 3 + 13) };
+ int32 expected_s32[2] = { static_cast<int16>(12 * .707 + 1),
+ static_cast<int16>(12 * .707 + 3) };
bool result_s32 = media::FoldChannels(samples_s32, sizeof(samples_s32),
6, // channels.
sizeof(samples_s32[0]),