OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #ifndef MEDIA_AUDIO_AUDIO_UTIL_H_ | 5 #ifndef MEDIA_AUDIO_AUDIO_UTIL_H_ |
6 #define MEDIA_AUDIO_AUDIO_UTIL_H_ | 6 #define MEDIA_AUDIO_AUDIO_UTIL_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 // InterleaveFloatToInt16 scales, clips, and interleaves the planar | 67 // InterleaveFloatToInt16 scales, clips, and interleaves the planar |
68 // floating-point audio contained in |source| to the int16 |destination|. | 68 // floating-point audio contained in |source| to the int16 |destination|. |
69 // The floating-point data is in a canonical range of -1.0 -> +1.0. | 69 // The floating-point data is in a canonical range of -1.0 -> +1.0. |
70 // The size of the |source| vector determines the number of channels. | 70 // The size of the |source| vector determines the number of channels. |
71 // The |destination| buffer is assumed to be large enough to hold the | 71 // The |destination| buffer is assumed to be large enough to hold the |
72 // result. Thus it must be at least size: number_of_frames * source.size() | 72 // result. Thus it must be at least size: number_of_frames * source.size() |
73 void InterleaveFloatToInt16(const std::vector<float*>& source, | 73 void InterleaveFloatToInt16(const std::vector<float*>& source, |
74 int16* destination, | 74 int16* destination, |
75 size_t number_of_frames); | 75 size_t number_of_frames); |
76 | 76 |
77 // Reorder PCM from AAC layout to Core Audio 5.1 layout. | |
78 // TODO(fbarchard): Switch layout when ffmpeg is updated. | |
79 template<class Format> | |
80 void SwizzleCoreAudioLayout5_1(Format* b, uint32 filled) { | |
81 static const int kNumSurroundChannels = 6; | |
82 Format aac[kNumSurroundChannels]; | |
83 for (uint32 i = 0; i < filled; i += sizeof(aac), b += kNumSurroundChannels) { | |
84 memcpy(aac, b, sizeof(aac)); | |
85 b[0] = aac[1]; // L | |
86 b[1] = aac[2]; // R | |
87 b[2] = aac[0]; // C | |
88 b[3] = aac[5]; // LFE | |
89 b[4] = aac[3]; // Ls | |
90 b[5] = aac[4]; // Rs | |
91 } | |
92 } | |
93 | |
94 // Returns the default audio hardware sample-rate. | 77 // Returns the default audio hardware sample-rate. |
95 double GetAudioHardwareSampleRate(); | 78 double GetAudioHardwareSampleRate(); |
96 | 79 |
97 } // namespace media | 80 } // namespace media |
98 | 81 |
99 #endif // MEDIA_AUDIO_AUDIO_UTIL_H_ | 82 #endif // MEDIA_AUDIO_AUDIO_UTIL_H_ |
OLD | NEW |