| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_BASE_CHANNEL_MIXER_H_ | 5 #ifndef MEDIA_BASE_CHANNEL_MIXER_H_ |
| 6 #define MEDIA_BASE_CHANNEL_MIXER_H_ | 6 #define MEDIA_BASE_CHANNEL_MIXER_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "media/base/channel_layout.h" | 11 #include "media/base/channel_layout.h" |
| 12 #include "media/base/media_export.h" | 12 #include "media/base/media_export.h" |
| 13 | 13 |
| 14 namespace media { | 14 namespace media { |
| 15 | 15 |
| 16 class AudioBus; | 16 class AudioBus; |
| 17 class AudioParameters; |
| 17 | 18 |
| 18 // ChannelMixer is for converting audio between channel layouts. The conversion | 19 // ChannelMixer is for converting audio between channel layouts. The conversion |
| 19 // matrix is built upon construction and used during each Transform() call. The | 20 // matrix is built upon construction and used during each Transform() call. The |
| 20 // algorithm works by generating a conversion matrix mapping each output channel | 21 // algorithm works by generating a conversion matrix mapping each output channel |
| 21 // to list of input channels. The transform renders all of the output channels, | 22 // to list of input channels. The transform renders all of the output channels, |
| 22 // with each output channel rendered according to a weighted sum of the relevant | 23 // with each output channel rendered according to a weighted sum of the relevant |
| 23 // input channels as defined in the matrix. | 24 // input channels as defined in the matrix. |
| 24 class MEDIA_EXPORT ChannelMixer { | 25 class MEDIA_EXPORT ChannelMixer { |
| 25 public: | 26 public: |
| 26 ChannelMixer(ChannelLayout input, ChannelLayout output); | 27 ChannelMixer(ChannelLayout input_layout, ChannelLayout output_layout); |
| 28 ChannelMixer(const AudioParameters& input, const AudioParameters& output); |
| 27 ~ChannelMixer(); | 29 ~ChannelMixer(); |
| 28 | 30 |
| 31 void Initialize(const AudioParameters& input, const AudioParameters& output); |
| 32 |
| 29 // Transforms all channels from |input| into |output| channels. | 33 // Transforms all channels from |input| into |output| channels. |
| 30 void Transform(const AudioBus* input, AudioBus* output); | 34 void Transform(const AudioBus* input, AudioBus* output); |
| 31 | 35 |
| 32 private: | 36 private: |
| 33 // Constructor helper methods for managing unaccounted input channels. | 37 // Constructor helper methods for managing unaccounted input channels. |
| 34 void AccountFor(Channels ch); | 38 void AccountFor(Channels ch); |
| 35 bool IsUnaccounted(Channels ch); | 39 bool IsUnaccounted(Channels ch); |
| 36 | 40 |
| 37 // Helper methods for checking if |ch| exists in either |input_layout_| or | 41 // Helper methods for checking if |ch| exists in either |input_layout_| or |
| 38 // |output_layout_| respectively. | 42 // |output_layout_| respectively. |
| (...skipping 20 matching lines...) Expand all Loading... |
| 59 // Optimization case for when we can simply remap the input channels to output | 63 // Optimization case for when we can simply remap the input channels to output |
| 60 // channels and don't need to do a multiply-accumulate loop over |matrix_|. | 64 // channels and don't need to do a multiply-accumulate loop over |matrix_|. |
| 61 bool remapping_; | 65 bool remapping_; |
| 62 | 66 |
| 63 DISALLOW_COPY_AND_ASSIGN(ChannelMixer); | 67 DISALLOW_COPY_AND_ASSIGN(ChannelMixer); |
| 64 }; | 68 }; |
| 65 | 69 |
| 66 } // namespace media | 70 } // namespace media |
| 67 | 71 |
| 68 #endif // MEDIA_BASE_CHANNEL_MIXER_H_ | 72 #endif // MEDIA_BASE_CHANNEL_MIXER_H_ |
| OLD | NEW |