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

Unified Diff: media/audio/audio_util.cc

Issue 10824304: Upgrade AudioBus to support wrapping, interleaving. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase. Created 8 years, 4 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/audio/audio_util.cc
diff --git a/media/audio/audio_util.cc b/media/audio/audio_util.cc
index d54f2774007ae96ef4d82894a826b3a6b3bcc596..56bc14d3219e51f49a8bf20554946ff2464aa642 100644
--- a/media/audio/audio_util.cc
+++ b/media/audio/audio_util.cc
@@ -182,6 +182,8 @@ bool FoldChannels(void* buf,
return false;
}
+// TODO(dalecurtis): Delete once everywhere is using the AudioBus version:
+// http://crbug.com/120319.
bool DeinterleaveAudioChannel(void* source,
float* destination,
int channels,
@@ -228,54 +230,6 @@ bool DeinterleaveAudioChannel(void* source,
return false;
}
-// |Format| is the destination type, |Fixed| is a type larger than |Format|
-// such that operations can be made without overflowing.
-template<class Format, class Fixed>
-static void InterleaveFloatToInt(const AudioBus* source,
- void* dst_bytes, size_t number_of_frames) {
- Format* destination = reinterpret_cast<Format*>(dst_bytes);
- Fixed max_value = std::numeric_limits<Format>::max();
- Fixed min_value = std::numeric_limits<Format>::min();
-
- Format bias = 0;
- if (!std::numeric_limits<Format>::is_signed) {
- bias = max_value / 2;
- max_value = bias;
- min_value = -(bias - 1);
- }
-
- int channels = source->channels();
- for (int i = 0; i < channels; ++i) {
- const float* channel_data = source->channel(i);
- for (size_t j = 0; j < number_of_frames; ++j) {
- Fixed sample = max_value * channel_data[j];
- if (sample > max_value)
- sample = max_value;
- else if (sample < min_value)
- sample = min_value;
-
- destination[j * channels + i] = static_cast<Format>(sample) + bias;
- }
- }
-}
-
-void InterleaveFloatToInt(const AudioBus* source, void* dst,
- size_t number_of_frames, int bytes_per_sample) {
- switch (bytes_per_sample) {
- case 1:
- InterleaveFloatToInt<uint8, int32>(source, dst, number_of_frames);
- break;
- case 2:
- InterleaveFloatToInt<int16, int32>(source, dst, number_of_frames);
- break;
- case 4:
- InterleaveFloatToInt<int32, int64>(source, dst, number_of_frames);
- break;
- default:
- break;
- }
-}
-
// TODO(enal): use template specialization and size-specific intrinsics.
// Call is on the time-critical path, and by using SSE/AVX
// instructions we can speed things up by ~4-8x, more for the case
« no previous file with comments | « media/audio/audio_util.h ('k') | media/base/audio_bus.h » ('j') | media/base/audio_bus.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698