OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | |
mcasas
2015/11/02 18:29:54
No (c) [1]
[1] https://www.chromium.org/developer
ajose
2015/11/02 22:39:51
Done.
| |
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_FILTERS_OPUS_HEADER_CONSTANTS_H_ | |
6 #define MEDIA_FILTERS_OPUS_HEADER_CONSTANTS_H_ | |
7 | |
8 namespace media { | |
9 | |
10 // The Opus specification is part of IETF RFC 6716: | |
11 // http://tools.ietf.org/html/rfc6716 | |
12 | |
13 // Opus Extra Data contents: | |
14 // - "OpusHead" magic signature (64 bits) | |
15 // - version number (8 bits) | |
16 // - Channels C (8 bits) | |
17 // - Pre-skip (16 bits) | |
18 // - Sampling rate (32 bits) | |
19 // - Gain in dB (16 bits, S7.8) | |
20 // - Mapping (8 bits, 0=single stream (mono/stereo) 1=Vorbis mapping, | |
21 // 2..254: reserved, 255: multistream with no mapping) | |
22 // | |
23 // - if (mapping != 0) | |
24 // - N = totel number of streams (8 bits) | |
25 // - M = number of paired streams (8 bits) | |
26 // - C times channel origin | |
27 // - if (C<2*M) | |
28 // - stream = byte/2 | |
29 // - if (byte&0x1 == 0) | |
30 // - left | |
31 // else | |
32 // - right | |
33 // - else | |
34 // - stream = byte-M | |
35 | |
36 // Default audio output channel layout. Used to initialize |stream_map| in | |
37 // OpusExtraData, and passed to opus_multistream_decoder_create() when the | |
38 // extra data does not contain mapping information. The values are valid only | |
39 // for mono and stereo output: Opus streams with more than 2 channels require a | |
40 // stream map. | |
41 static const int kMaxChannelsWithDefaultLayout = 2; | |
mcasas
2015/11/02 18:29:54
Creating all this static variables in media might
| |
42 static const uint8 kDefaultOpusChannelLayout[kMaxChannelsWithDefaultLayout] = { | |
43 0, 1}; | |
44 | |
45 enum { | |
46 // Opus uses Vorbis channel mapping, and Vorbis channel mapping specifies | |
47 // mappings for up to 8 channels. This information is part of the Vorbis I | |
48 // Specification: | |
49 // http://www.xiph.org/vorbis/doc/Vorbis_I_spec.html | |
50 OPUS_MAX_VORBIS_CHANNELS = 8, | |
51 | |
52 // Size of the Opus extra data excluding optional mapping information. | |
53 OPUS_EXTRADATA_SIZE = 19, | |
54 // Offset for magic signature "OpusHead" | |
55 OPUS_EXTRADATA_LABEL_OFFSET = 0, | |
56 // Offset to the Opus version number | |
57 OPUS_EXTRADATA_VERSION_OFFSET = 8, | |
58 // Offset to the channel count byte in the Opus extra data | |
59 OPUS_EXTRADATA_CHANNELS_OFFSET = 9, | |
60 // Offset to the pre-skip value in the Opus extra data | |
61 OPUS_EXTRADATA_SKIP_SAMPLES_OFFSET = 10, | |
62 // Offset to the sampling rate value in the Opus extra data | |
63 OPUS_EXTRADATA_SAMPLE_RATE_OFFSET = 12, | |
64 // Offset to the gain value in the Opus extra data | |
65 OPUS_EXTRADATA_GAIN_OFFSET = 16, | |
66 // Offset to the channel mapping byte in the Opus extra data | |
67 OPUS_EXTRADATA_CHANNEL_MAPPING_OFFSET = 18, | |
68 | |
69 // Extra Data contains a stream map, beyond the always present | |
70 // |OPUS_EXTRADATA_SIZE| bytes of data. The mapping data contains stream | |
71 // count, coupling information, and per channel mapping values: | |
72 // - Byte 0: Number of streams. | |
73 // - Byte 1: Number coupled. | |
74 // - Byte 2: Starting at byte 2 are |extra_data->channels| uint8 mapping | |
75 // values. | |
76 OPUS_EXTRADATA_NUM_STREAMS_OFFSET = OPUS_EXTRADATA_SIZE, | |
77 OPUS_EXTRADATA_NUM_COUPLED_OFFSET = OPUS_EXTRADATA_NUM_STREAMS_OFFSET + 1, | |
78 OPUS_EXTRADATA_STREAM_MAP_OFFSET = OPUS_EXTRADATA_NUM_STREAMS_OFFSET + 2, | |
79 }; | |
80 | |
81 // Vorbis channel ordering for streams with >= 2 channels: | |
82 // 2 Channels | |
83 // L, R | |
84 // 3 Channels | |
85 // L, Center, R | |
86 // 4 Channels | |
87 // Front L, Front R, Back L, Back R | |
88 // 5 Channels | |
89 // Front L, Center, Front R, Back L, Back R | |
90 // 6 Channels (5.1) | |
91 // Front L, Center, Front R, Back L, Back R, LFE | |
92 // 7 channels (6.1) | |
93 // Front L, Front Center, Front R, Side L, Side R, Back Center, LFE | |
94 // 8 Channels (7.1) | |
95 // Front L, Center, Front R, Side L, Side R, Back L, Back R, LFE | |
96 // | |
97 // Channel ordering information is taken from section 4.3.9 of the Vorbis I | |
98 // Specification: | |
99 // http://xiph.org/vorbis/doc/Vorbis_I_spec.html#x1-800004.3.9 | |
100 | |
101 // These are the FFmpeg channel layouts expressed using the position of each | |
102 // channel in the output stream from libopus. | |
103 const uint8 kFFmpegChannelDecodingLayouts [OPUS_MAX_VORBIS_CHANNELS] | |
mcasas
2015/11/02 18:29:54
static?
s/uint8/uint8_t/
ajose
2015/11/02 22:39:51
Done.
| |
104 [OPUS_MAX_VORBIS_CHANNELS] = { | |
105 {0}, | |
106 | |
107 // Stereo: No reorder. | |
108 {0, 1}, | |
109 | |
110 // 3 Channels, from Vorbis order to: | |
111 // L, R, Center | |
112 {0, 2, 1}, | |
113 | |
114 // 4 Channels: No reorder. | |
115 {0, 1, 2, 3}, | |
116 | |
117 // 5 Channels, from Vorbis order to: | |
118 // Front L, Front R, Center, Back L, Back R | |
119 {0, 2, 1, 3, 4}, | |
120 | |
121 // 6 Channels (5.1), from Vorbis order to: | |
122 // Front L, Front R, Center, LFE, Back L, Back R | |
123 {0, 2, 1, 5, 3, 4}, | |
124 | |
125 // 7 Channels (6.1), from Vorbis order to: | |
126 // Front L, Front R, Front Center, LFE, Side L, Side R, Back Center | |
127 {0, 2, 1, 6, 3, 4, 5}, | |
128 | |
129 // 8 Channels (7.1), from Vorbis order to: | |
130 // Front L, Front R, Center, LFE, Back L, Back R, Side L, Side R | |
131 {0, 2, 1, 7, 5, 6, 3, 4}, | |
132 }; | |
133 | |
134 // Opus internal to Vorbis channel order mapping written in the header. | |
135 static const uint8_t kOpusVorbisChannelMap[OPUS_MAX_VORBIS_CHANNELS] | |
136 [OPUS_MAX_VORBIS_CHANNELS] = { | |
137 {0}, | |
138 {0, 1}, | |
139 {0, 2, 1}, | |
140 {0, 1, 2, 3}, | |
141 {0, 4, 1, 2, 3}, | |
142 {0, 4, 1, 2, 3, 5}, | |
143 {0, 4, 1, 2, 3, 5, 6}, | |
144 {0, 6, 1, 2, 3, 4, 5, 7}, | |
145 }; | |
146 | |
147 } // namespace media | |
148 | |
149 #endif // MEDIA_FILTERS_OPUS_HEADER_CONSTANTS_H_ | |
OLD | NEW |