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

Side by Side Diff: media/base/channel_layout.cc

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
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" 7 #include "base/basictypes.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 9
10 namespace media { 10 namespace media {
11 11
12 static const int kLayoutToChannels[] = { 12 static const int kLayoutToChannels[] = {
13 0, // CHANNEL_LAYOUT_NONE 13 0, // CHANNEL_LAYOUT_NONE
14 0, // CHANNEL_LAYOUT_UNSUPPORTED 14 0, // CHANNEL_LAYOUT_UNSUPPORTED
15 1, // CHANNEL_LAYOUT_MONO 15 1, // CHANNEL_LAYOUT_MONO
16 2, // CHANNEL_LAYOUT_STEREO 16 2, // CHANNEL_LAYOUT_STEREO
17 3, // CHANNEL_LAYOUT_2_1 17 3, // CHANNEL_LAYOUT_2_1
18 3, // CHANNEL_LAYOUT_SURROUND 18 3, // CHANNEL_LAYOUT_SURROUND
19 4, // CHANNEL_LAYOUT_4POINT0 19 4, // CHANNEL_LAYOUT_4POINT0
20 4, // CHANNEL_LAYOUT_2_2 20 4, // CHANNEL_LAYOUT_2_2
21 4, // CHANNEL_LAYOUT_QUAD 21 4, // CHANNEL_LAYOUT_QUAD
22 5, // CHANNEL_LAYOUT_5POINT0 22 5, // CHANNEL_LAYOUT_5POINT0
23 6, // CHANNEL_LAYOUT_5POINT1 23 6, // CHANNEL_LAYOUT_5POINT1
24 5, // CHANNEL_LAYOUT_5POINT0_BACK 24 5, // CHANNEL_LAYOUT_5POINT0_BACK
25 6, // CHANNEL_LAYOUT_5POINT1_BACK 25 6, // CHANNEL_LAYOUT_5POINT1_BACK
26 7, // CHANNEL_LAYOUT_7POINT0 26 7, // CHANNEL_LAYOUT_7POINT0
27 8, // CHANNEL_LAYOUT_7POINT1 27 8, // CHANNEL_LAYOUT_7POINT1
28 8, // CHANNEL_LAYOUT_7POINT1_WIDE 28 8, // CHANNEL_LAYOUT_7POINT1_WIDE
29 2}; // CHANNEL_LAYOUT_STEREO_DOWNMIX 29 2, // CHANNEL_LAYOUT_STEREO_DOWNMIX
30 };
30 31
31 // The channel orderings for each layout as specified by FFmpeg. Each value 32 // 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 // 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 // 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 // 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 // the order is L, R, C, LFE, LS, RS), so
36 // kChannelOrderings[CHANNEL_LAYOUT_5POINT1][SIDE_LEFT] = 4; 37 // kChannelOrderings[CHANNEL_LAYOUT_5POINT1][SIDE_LEFT] = 4;
37 static const int kChannelOrderings[CHANNEL_LAYOUT_MAX][CHANNELS_MAX] = { 38 static const int kChannelOrderings[CHANNEL_LAYOUT_MAX][CHANNELS_MAX] = {
38 // FL | FR | FC | LFE | BL | BR | FLofC | FRofC | BC | SL | SR | StL | StR 39 // FL | FR | FC | LFE | BL | BR | FLofC | FRofC | BC | SL | SR
39 40
40 // CHANNEL_LAYOUT_NONE 41 // CHANNEL_LAYOUT_NONE
41 { -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 }, 42 { -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 },
42 43
43 // CHANNEL_LAYOUT_UNSUPPORTED 44 // CHANNEL_LAYOUT_UNSUPPORTED
44 { -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 }, 45 { -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 },
45 46
46 // CHANNEL_LAYOUT_MONO 47 // CHANNEL_LAYOUT_MONO
47 { -1 , -1 , 0 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 }, 48 { -1 , -1 , 0 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 },
48 49
49 // CHANNEL_LAYOUT_STEREO 50 // CHANNEL_LAYOUT_STEREO
50 { 0 , 1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 }, 51 { 0 , 1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 },
51 52
52 // CHANNEL_LAYOUT_2_1 53 // CHANNEL_LAYOUT_2_1
53 { 0 , 1 , -1 , -1 , -1 , -1 , -1 , -1 , 2 , -1 , -1 , -1 , -1 }, 54 { 0 , 1 , -1 , -1 , -1 , -1 , -1 , -1 , 2 , -1 , -1 },
54 55
55 // CHANNEL_LAYOUT_SURROUND 56 // CHANNEL_LAYOUT_SURROUND
56 { 0 , 1 , 2 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 }, 57 { 0 , 1 , 2 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 },
57 58
58 // CHANNEL_LAYOUT_4POINT0 59 // CHANNEL_LAYOUT_4POINT0
59 { 0 , 1 , 2 , -1 , -1 , -1 , -1 , -1 , 3 , -1 , -1 , -1 , -1 }, 60 { 0 , 1 , 2 , -1 , -1 , -1 , -1 , -1 , 3 , -1 , -1 },
60 61
61 // CHANNEL_LAYOUT_2_2 62 // CHANNEL_LAYOUT_2_2
62 { 0 , 1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , 2 , 3 , -1 , -1 }, 63 { 0 , 1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , 2 , 3 },
63 64
64 // CHANNEL_LAYOUT_QUAD 65 // CHANNEL_LAYOUT_QUAD
65 { 0 , 1 , -1 , -1 , 2 , 3 , -1 , -1 , -1 , -1 , -1 , -1 , -1 }, 66 { 0 , 1 , -1 , -1 , 2 , 3 , -1 , -1 , -1 , -1 , -1 },
66 67
67 // CHANNEL_LAYOUT_5POINT0 68 // CHANNEL_LAYOUT_5POINT0
68 { 0 , 1 , 2 , -1 , -1 , -1 , -1 , -1 , -1 , 3 , 4 , -1 , -1 }, 69 { 0 , 1 , 2 , -1 , -1 , -1 , -1 , -1 , -1 , 3 , 4 },
69 70
70 // CHANNEL_LAYOUT_5POINT1 71 // CHANNEL_LAYOUT_5POINT1
71 { 0 , 1 , 2 , 3 , -1 , -1 , -1 , -1 , -1 , 4 , 5 , -1 , -1 }, 72 { 0 , 1 , 2 , 3 , -1 , -1 , -1 , -1 , -1 , 4 , 5 },
72 73
73 // CHANNEL_LAYOUT_5POINT0_BACK 74 // CHANNEL_LAYOUT_5POINT0_BACK
74 { 0 , 1 , 2 , -1 , 3 , 4 , -1 , -1 , -1 , -1 , -1 , -1 , -1 }, 75 { 0 , 1 , 2 , -1 , 3 , 4 , -1 , -1 , -1 , -1 , -1 },
75 76
76 // CHANNEL_LAYOUT_5POINT1_BACK 77 // CHANNEL_LAYOUT_5POINT1_BACK
77 { 0 , 1 , 2 , 3 , 4 , 5 , -1 , -1 , -1 , -1 , -1 , -1 , -1 }, 78 { 0 , 1 , 2 , 3 , 4 , 5 , -1 , -1 , -1 , -1 , -1 },
78 79
79 // CHANNEL_LAYOUT_7POINT0 80 // CHANNEL_LAYOUT_7POINT0
80 { 0 , 1 , 2 , -1 , 5 , 6 , -1 , -1 , -1 , 3 , 4 , -1 , -1 }, 81 { 0 , 1 , 2 , -1 , 5 , 6 , -1 , -1 , -1 , 3 , 4 },
81 82
82 // CHANNEL_LAYOUT_7POINT1 83 // CHANNEL_LAYOUT_7POINT1
83 { 0 , 1 , 2 , 3 , 6 , 7 , -1 , -1 , -1 , 4 , 5 , -1 , -1 }, 84 { 0 , 1 , 2 , 3 , 6 , 7 , -1 , -1 , -1 , 4 , 5 },
84 85
85 // CHANNEL_LAYOUT_7POINT1_WIDE 86 // CHANNEL_LAYOUT_7POINT1_WIDE
86 { 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , -1 , -1 , -1 , -1 , -1 }, 87 { 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , -1 , -1 , -1 },
87 88
88 // CHANNEL_LAYOUT_STEREO_DOWNMIX 89 // CHANNEL_LAYOUT_STEREO_DOWNMIX
89 { -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , 0 , 1 }, 90 { 0 , 1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 },
90 91
91 // FL | FR | FC | LFE | BL | BR | FLofC | FRofC | BC | SL | SR | StL | StR 92 // FL | FR | FC | LFE | BL | BR | FLofC | FRofC | BC | SL | SR
92 }; 93 };
93 94
94 int ChannelLayoutToChannelCount(ChannelLayout layout) { 95 int ChannelLayoutToChannelCount(ChannelLayout layout) {
95 DCHECK_LT(static_cast<size_t>(layout), arraysize(kLayoutToChannels)); 96 DCHECK_LT(static_cast<size_t>(layout), arraysize(kLayoutToChannels));
96 return kLayoutToChannels[layout]; 97 return kLayoutToChannels[layout];
97 } 98 }
98 99
99 int ChannelOrder(ChannelLayout layout, Channels channel) { 100 int ChannelOrder(ChannelLayout layout, Channels channel) {
100 DCHECK_LT(static_cast<size_t>(layout), arraysize(kChannelOrderings)); 101 DCHECK_LT(static_cast<size_t>(layout), arraysize(kChannelOrderings));
101 DCHECK_LT(static_cast<size_t>(channel), arraysize(kChannelOrderings[0])); 102 DCHECK_LT(static_cast<size_t>(channel), arraysize(kChannelOrderings[0]));
102 return kChannelOrderings[layout][channel]; 103 return kChannelOrderings[layout][channel];
103 } 104 }
104 105
105 } // namespace media 106 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698