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 #include "media/base/channel_layout.h" | 5 #include "media/base/channel_layout.h" |
6 | 6 |
| 7 #include "base/basictypes.h" |
| 8 #include "base/logging.h" |
| 9 |
| 10 namespace media { |
| 11 |
7 static const int kLayoutToChannels[] = { | 12 static const int kLayoutToChannels[] = { |
8 0, // CHANNEL_LAYOUT_NONE | 13 0, // CHANNEL_LAYOUT_NONE |
9 0, // CHANNEL_LAYOUT_UNSUPPORTED | 14 0, // CHANNEL_LAYOUT_UNSUPPORTED |
10 1, // CHANNEL_LAYOUT_MONO | 15 1, // CHANNEL_LAYOUT_MONO |
11 2, // CHANNEL_LAYOUT_STEREO | 16 2, // CHANNEL_LAYOUT_STEREO |
12 3, // CHANNEL_LAYOUT_2_1 | 17 3, // CHANNEL_LAYOUT_2_1 |
13 3, // CHANNEL_LAYOUT_SURROUND | 18 3, // CHANNEL_LAYOUT_SURROUND |
14 4, // CHANNEL_LAYOUT_4POINT0 | 19 4, // CHANNEL_LAYOUT_4POINT0 |
15 4, // CHANNEL_LAYOUT_2_2 | 20 4, // CHANNEL_LAYOUT_2_2 |
16 4, // CHANNEL_LAYOUT_QUAD | 21 4, // CHANNEL_LAYOUT_QUAD |
17 5, // CHANNEL_LAYOUT_5POINT0 | 22 5, // CHANNEL_LAYOUT_5POINT0 |
18 6, // CHANNEL_LAYOUT_5POINT1 | 23 6, // CHANNEL_LAYOUT_5POINT1 |
19 5, // CHANNEL_LAYOUT_5POINT0_BACK | 24 5, // CHANNEL_LAYOUT_5POINT0_BACK |
20 6, // CHANNEL_LAYOUT_5POINT1_BACK | 25 6, // CHANNEL_LAYOUT_5POINT1_BACK |
21 7, // CHANNEL_LAYOUT_7POINT0 | 26 7, // CHANNEL_LAYOUT_7POINT0 |
22 8, // CHANNEL_LAYOUT_7POINT1 | 27 8, // CHANNEL_LAYOUT_7POINT1 |
23 8, // CHANNEL_LAYOUT_7POINT1_WIDE | 28 8, // CHANNEL_LAYOUT_7POINT1_WIDE |
24 2}; // CHANNEL_LAYOUT_STEREO_DOWNMIX | 29 2}; // CHANNEL_LAYOUT_STEREO_DOWNMIX |
25 | 30 |
26 const int kChannelOrderings[CHANNEL_LAYOUT_MAX][CHANNELS_MAX] = { | 31 // The channel orderings for each layout as specified by FFmpeg. Each value |
| 32 // represents the index of each channel in each layout. Values of -1 mean the |
| 33 // channel at that index is not used for that layout.For example, the left side |
| 34 // surround sound channel in FFmpeg's 5.1 layout is in the 5th position (because |
| 35 // the order is L, R, C, LFE, LS, RS), so |
| 36 // kChannelOrderings[CHANNEL_LAYOUT_5POINT1][SIDE_LEFT] = 4; |
| 37 static const int kChannelOrderings[CHANNEL_LAYOUT_MAX][CHANNELS_MAX] = { |
27 // FL | FR | FC | LFE | BL | BR | FLofC | FRofC | BC | SL | SR | StL | StR | 38 // FL | FR | FC | LFE | BL | BR | FLofC | FRofC | BC | SL | SR | StL | StR |
28 | 39 |
29 // CHANNEL_LAYOUT_NONE | 40 // CHANNEL_LAYOUT_NONE |
30 { -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 }, | 41 { -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 }, |
31 | 42 |
32 // CHANNEL_LAYOUT_UNSUPPORTED | 43 // CHANNEL_LAYOUT_UNSUPPORTED |
33 { -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 }, | 44 { -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 }, |
34 | 45 |
35 // CHANNEL_LAYOUT_MONO | 46 // CHANNEL_LAYOUT_MONO |
36 { -1 , -1 , 0 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 }, | 47 { -1 , -1 , 0 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 }, |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 // CHANNEL_LAYOUT_7POINT1_WIDE | 85 // CHANNEL_LAYOUT_7POINT1_WIDE |
75 { 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , -1 , -1 , -1 , -1 , -1 }, | 86 { 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , -1 , -1 , -1 , -1 , -1 }, |
76 | 87 |
77 // CHANNEL_LAYOUT_STEREO_DOWNMIX | 88 // CHANNEL_LAYOUT_STEREO_DOWNMIX |
78 { -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , 0 , 1 }, | 89 { -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , 0 , 1 }, |
79 | 90 |
80 // FL | FR | FC | LFE | BL | BR | FLofC | FRofC | BC | SL | SR | StL | StR | 91 // FL | FR | FC | LFE | BL | BR | FLofC | FRofC | BC | SL | SR | StL | StR |
81 }; | 92 }; |
82 | 93 |
83 int ChannelLayoutToChannelCount(ChannelLayout layout) { | 94 int ChannelLayoutToChannelCount(ChannelLayout layout) { |
| 95 DCHECK_LT(static_cast<size_t>(layout), arraysize(kLayoutToChannels)); |
84 return kLayoutToChannels[layout]; | 96 return kLayoutToChannels[layout]; |
85 } | 97 } |
| 98 |
| 99 int ChannelOrder(ChannelLayout layout, Channels channel) { |
| 100 DCHECK_LT(static_cast<size_t>(layout), arraysize(kChannelOrderings)); |
| 101 DCHECK_LT(static_cast<size_t>(channel), arraysize(kChannelOrderings[0])); |
| 102 return kChannelOrderings[layout][channel]; |
| 103 } |
| 104 |
| 105 } // namespace media |
OLD | NEW |