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

Side by Side Diff: media/base/channel_mixer.h

Issue 11150034: Add support for channel transforms. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rename to Transform() Created 8 years, 2 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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_MIXER_H_
6 #define MEDIA_BASE_CHANNEL_MIXER_H_
7
8 #include <vector>
9
10 #include "base/basictypes.h"
11 #include "media/base/channel_layout.h"
12 #include "media/base/media_export.h"
13
14 namespace media {
15
16 class AudioBus;
17
18 // ChannelMixer is for converting audio between channel layouts. The conversion
19 // 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 // to list of input channels. The transform is then done by scaling each input
22 // channel according to the matrix and summing it into a single output channel.
Chris Rogers 2012/10/19 20:48:17 This last sentence is a little confusing. I think
DaleCurtis 2012/10/19 22:33:20 Done.
23 class MEDIA_EXPORT ChannelMixer {
24 public:
25 ChannelMixer(ChannelLayout input, ChannelLayout output);
26 ~ChannelMixer();
27
28 // Transforms all channels from |input| into |output| channels.
29 void Transform(const AudioBus* input, AudioBus* output);
30
31 private:
32 // Constructor helper methods for managing unaccounted input channels.
33 void AccountFor(Channels ch);
34 bool IsUnaccounted(Channels ch);
35
36 // Helper methods for checking if |ch| exists in either |input_layout_| or
37 // |output_layout_| respectively.
38 bool HasInputChannel(Channels ch);
39 bool HasOutputChannel(Channels ch);
40
41 // Constructor helper methods for updating |matrix_| with the proper value for
42 // mixing |input_ch| into |output_ch|. MixWithoutAccounting() does not remove
43 // the channel from |unaccounted_inputs_|.
44 void Mix(Channels input_ch, Channels output_ch, float scale);
45 void MixWithoutAccounting(Channels input_ch, Channels output_ch, float scale);
46
47 // Input and output channel layout provided during construction.
48 ChannelLayout input_layout_;
49 ChannelLayout output_layout_;
50
51 // Helper variable for tracking which inputs are currently unaccounted, should
52 // be empty after construction completes.
53 std::vector<Channels> unaccounted_inputs_;
54
55 // 2D matrix of output channels to input channels.
56 std::vector< std::vector<float> > matrix_;
57
58 // Optimization case for when we can simply remap the input channels to output
59 // channels and don't need to do a multiply-accumulate loop over |matrix_|.
60 bool remapping_;
61
62 DISALLOW_COPY_AND_ASSIGN(ChannelMixer);
63 };
64
65 } // namespace media
66
67 #endif // MEDIA_BASE_CHANNEL_MIXER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698