From 9787fec1d6a14f3ca72288d277d3049c2c65b85e Mon Sep 17 00:00:00 2001 From: "fbarchard@chromium.org" Date: Sat, 25 Jul 2009 03:16:21 +0000 Subject: Surround Sound handling by folding 5 channels down to stereo. BUG=16026 TEST=play a movie trailer with 5.1 audio. It should sound roughly the same as quicktime. Review URL: http://codereview.chromium.org/155894 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@21613 0039d316-1c4b-4281-b951-d872f2087c98 --- media/audio/audio_util.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'media/audio/audio_util.h') diff --git a/media/audio/audio_util.h b/media/audio/audio_util.h index 14fe169..edfe7ab 100644 --- a/media/audio/audio_util.h +++ b/media/audio/audio_util.h @@ -9,6 +9,11 @@ namespace media { +// For all audio functions 3 audio formats are supported: +// 8 bits unsigned 0 to 255. +// 16 bit signed (little endian). +// 32 bit signed (little endian) + // AdjustVolume() does a software volume adjustment of a sample buffer. // The samples are multiplied by the volume, which should range from // 0.0 (mute) to 1.0 (full volume). @@ -25,6 +30,25 @@ bool AdjustVolume(void* buf, int bytes_per_sample, float volume); +// FoldChannels() does a software multichannel folding down to stereo. +// Channel order is assumed to be 5.1 Dolby standard which is +// front left, front right, center, surround left, surround right. +// The subwoofer is ignored. +// 6.1 adds a rear center speaker, and 7.1 has 2 rear speakers. These +// channels are rare and ignored. +// After summing the channels, volume is adjusted and the samples are +// clipped to the maximum value. +// Volume should normally range from 0.0 (mute) to 1.0 (full volume), but +// since clamping is performed a value of more than 1 is allowed to increase +// volume. +// The buffer is modified in-place to avoid memory management, as this +// function may be called in performance critical code. +bool FoldChannels(void* buf, + size_t buflen, + int channels, + int bytes_per_sample, + float volume); + } // namespace media #endif // MEDIA_AUDIO_AUDIO_UTIL_H_ -- cgit v1.1