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

Side by Side Diff: media/filters/opus_header_constants.h

Issue 1414793002: Update WebmMuxer for audio component of MediaStream recording. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments Created 5 years, 1 month 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
« no previous file with comments | « media/filters/opus_audio_decoder.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2015 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_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;
miu 2015/11/03 04:18:29 Per discussion on chromium-dev@ (about a month ago
ajose 2015/11/03 23:06:22 Done.
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 static const uint8_t kFFmpegChannelDecodingLayouts [OPUS_MAX_VORBIS_CHANNELS]
miu 2015/11/03 04:18:28 The lazy class idea is not needed. There should n
ajose 2015/11/03 23:06:22 Done.
104 [OPUS_MAX_VORBIS_CHANNELS] =
105 {
106 {0},
107
108 // Stereo: No reorder.
109 {0, 1},
110
111 // 3 Channels, from Vorbis order to:
112 // L, R, Center
113 {0, 2, 1},
114
115 // 4 Channels: No reorder.
116 {0, 1, 2, 3},
117
118 // 5 Channels, from Vorbis order to:
119 // Front L, Front R, Center, Back L, Back R
120 {0, 2, 1, 3, 4},
121
122 // 6 Channels (5.1), from Vorbis order to:
123 // Front L, Front R, Center, LFE, Back L, Back R
124 {0, 2, 1, 5, 3, 4},
125
126 // 7 Channels (6.1), from Vorbis order to:
127 // Front L, Front R, Front Center, LFE, Side L, Side R, Back Center
128 {0, 2, 1, 6, 3, 4, 5},
129
130 // 8 Channels (7.1), from Vorbis order to:
131 // Front L, Front R, Center, LFE, Back L, Back R, Side L, Side R
132 {0, 2, 1, 7, 5, 6, 3, 4},
133 };
134
135 // Opus internal to Vorbis channel order mapping written in the header.
136 static const uint8_t kOpusVorbisChannelMap[OPUS_MAX_VORBIS_CHANNELS]
137 [OPUS_MAX_VORBIS_CHANNELS] = {
138 {0},
139 {0, 1},
140 {0, 2, 1},
141 {0, 1, 2, 3},
142 {0, 4, 1, 2, 3},
143 {0, 4, 1, 2, 3, 5},
144 {0, 4, 1, 2, 3, 5, 6},
145 {0, 6, 1, 2, 3, 4, 5, 7},
146 };
147
148 } // namespace media
149
150 #endif // MEDIA_FILTERS_OPUS_HEADER_CONSTANTS_H_
OLDNEW
« no previous file with comments | « media/filters/opus_audio_decoder.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698