OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef MEDIA_BASE_CHANNEL_MIXING_MATRIX_H_ |
| 6 #define MEDIA_BASE_CHANNEL_MIXING_MATRIX_H_ |
| 7 |
| 8 #include <vector> |
| 9 |
| 10 #include "base/macros.h" |
| 11 #include "media/base/channel_layout.h" |
| 12 #include "media/base/media_export.h" |
| 13 |
| 14 namespace media { |
| 15 |
| 16 class MEDIA_EXPORT ChannelMixingMatrix { |
| 17 public: |
| 18 ChannelMixingMatrix(ChannelLayout input_layout, |
| 19 int input_channels, |
| 20 ChannelLayout output_layout, |
| 21 int output_channels); |
| 22 |
| 23 ~ChannelMixingMatrix(); |
| 24 |
| 25 // Create the transformation matrix of input channels to output channels. |
| 26 // Updates the empty matrix with the transformation, and returns true |
| 27 // if the transformation is just a remapping of channels (no mixing). |
| 28 bool CreateTransformationMatrix(std::vector<std::vector<float>>* matrix); |
| 29 |
| 30 private: |
| 31 // Result transformation of input channels to output channels |
| 32 std::vector<std::vector<float>>* matrix_; |
| 33 |
| 34 // Input and output channel layout provided during construction. |
| 35 ChannelLayout input_layout_; |
| 36 int input_channels_; |
| 37 ChannelLayout output_layout_; |
| 38 int output_channels_; |
| 39 |
| 40 // Helper variable for tracking which inputs are currently unaccounted, |
| 41 // should be empty after construction completes. |
| 42 std::vector<Channels> unaccounted_inputs_; |
| 43 |
| 44 // Helper methods for managing unaccounted input channels. |
| 45 void AccountFor(Channels ch); |
| 46 bool IsUnaccounted(Channels ch) const; |
| 47 |
| 48 // Helper methods for checking if |ch| exists in either |input_layout_| or |
| 49 // |output_layout_| respectively. |
| 50 bool HasInputChannel(Channels ch) const; |
| 51 bool HasOutputChannel(Channels ch) const; |
| 52 |
| 53 // Helper methods for updating |matrix_| with the proper value for |
| 54 // mixing |input_ch| into |output_ch|. MixWithoutAccounting() does not |
| 55 // remove the channel from |unaccounted_inputs_|. |
| 56 void Mix(Channels input_ch, Channels output_ch, float scale); |
| 57 void MixWithoutAccounting(Channels input_ch, Channels output_ch, float scale); |
| 58 |
| 59 DISALLOW_COPY_AND_ASSIGN(ChannelMixingMatrix); |
| 60 }; |
| 61 |
| 62 } // namespace media |
| 63 |
| 64 #endif // MEDIA_BASE_CHANNEL_MIXING_MATRIX_H_ |
OLD | NEW |