tools/gn: fix rebase_path example
[chromium-blink-merge.git] / media / base / channel_mixing_matrix.h
blob64fcdb90228e4872f644a09df53bfecfbbf59add
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.
5 #ifndef MEDIA_BASE_CHANNEL_MIXING_MATRIX_H_
6 #define MEDIA_BASE_CHANNEL_MIXING_MATRIX_H_
8 #include <vector>
10 #include "base/macros.h"
11 #include "media/base/channel_layout.h"
12 #include "media/base/media_export.h"
14 namespace media {
16 class MEDIA_EXPORT ChannelMixingMatrix {
17 public:
18 ChannelMixingMatrix(ChannelLayout input_layout,
19 int input_channels,
20 ChannelLayout output_layout,
21 int output_channels);
23 ~ChannelMixingMatrix();
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);
30 private:
31 // Result transformation of input channels to output channels
32 std::vector<std::vector<float>>* matrix_;
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_;
40 // Helper variable for tracking which inputs are currently unaccounted,
41 // should be empty after construction completes.
42 std::vector<Channels> unaccounted_inputs_;
44 // Helper methods for managing unaccounted input channels.
45 void AccountFor(Channels ch);
46 bool IsUnaccounted(Channels ch) const;
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;
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);
59 DISALLOW_COPY_AND_ASSIGN(ChannelMixingMatrix);
62 } // namespace media
64 #endif // MEDIA_BASE_CHANNEL_MIXING_MATRIX_H_