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

Unified Diff: media/audio/audio_util.cc

Issue 5550006: Implement WebKitClientImpl::loadAudioResource() to decode in-memory audio fil... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 10 years 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
« no previous file with comments | « media/audio/audio_util.h ('k') | media/filters/audio_file_reader.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/audio/audio_util.cc
===================================================================
--- media/audio/audio_util.cc (revision 69343)
+++ media/audio/audio_util.cc (working copy)
@@ -158,4 +158,50 @@
return false;
}
+bool DeinterleaveAudioChannel(void* source,
+ float* destination,
+ int channels,
+ int channel_index,
+ int bytes_per_sample,
+ size_t number_of_frames) {
+ switch (bytes_per_sample) {
+ case 1:
+ {
+ uint8* source8 = static_cast<uint8*>(source) + channel_index;
+ const float kScale = 1.0f / 128.0f;
+ for (unsigned i = 0; i < number_of_frames; ++i) {
+ destination[i] = kScale * static_cast<int>(*source8 + 128);
+ source8 += channels;
+ }
+ return true;
+ }
+
+ case 2:
+ {
+ int16* source16 = static_cast<int16*>(source) + channel_index;
+ const float kScale = 1.0f / 32768.0f;
+ for (unsigned i = 0; i < number_of_frames; ++i) {
+ destination[i] = kScale * *source16;
+ source16 += channels;
+ }
+ return true;
+ }
+
+ case 4:
+ {
+ int32* source32 = static_cast<int32*>(source) + channel_index;
+ const float kScale = 1.0f / (1L << 31);
+ for (unsigned i = 0; i < number_of_frames; ++i) {
+ destination[i] = kScale * *source32;
+ source32 += channels;
+ }
+ return true;
+ }
+
+ default:
+ break;
+ }
+ return false;
+}
+
} // namespace media
« no previous file with comments | « media/audio/audio_util.h ('k') | media/filters/audio_file_reader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698