Chromium Code Reviews| OLD | NEW |
|---|---|
| (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_CONSTANTS_H_ | |
| 6 #define MEDIA_FILTERS_OPUS_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) | |
|
mcasas
2015/11/05 02:08:20
s/totel/total/
ajose
2015/11/05 19:02:58
Done.
| |
| 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 enum { | |
| 37 // Default audio output channel layout. Used to initialize |stream_map| in | |
| 38 // OpusExtraData, and passed to opus_multistream_decoder_create() when the | |
| 39 // extra data does not contain mapping information. The values are valid only | |
| 40 // for mono and stereo output: Opus streams with more than 2 channels require | |
| 41 // a stream map. | |
| 42 OPUS_MAX_CHANNELS_WITH_DEFAULT_LAYOUT = 2, | |
| 43 | |
| 44 // Opus uses Vorbis channel mapping, and Vorbis channel mapping specifies | |
| 45 // mappings for up to 8 channels. This information is part of the Vorbis I | |
| 46 // Specification: | |
| 47 // http://www.xiph.org/vorbis/doc/Vorbis_I_spec.html | |
| 48 OPUS_MAX_VORBIS_CHANNELS = 8, | |
| 49 | |
| 50 // Size of the Opus extra data excluding optional mapping information. | |
| 51 OPUS_EXTRADATA_SIZE = 19, | |
| 52 // Offset for magic signature "OpusHead" | |
| 53 OPUS_EXTRADATA_LABEL_OFFSET = 0, | |
| 54 // Offset to the Opus version number | |
| 55 OPUS_EXTRADATA_VERSION_OFFSET = 8, | |
| 56 // Offset to the channel count byte in the Opus extra data | |
| 57 OPUS_EXTRADATA_CHANNELS_OFFSET = 9, | |
| 58 // Offset to the pre-skip value in the Opus extra data | |
| 59 OPUS_EXTRADATA_SKIP_SAMPLES_OFFSET = 10, | |
| 60 // Offset to the sampling rate value in the Opus extra data | |
| 61 OPUS_EXTRADATA_SAMPLE_RATE_OFFSET = 12, | |
| 62 // Offset to the gain value in the Opus extra data | |
| 63 OPUS_EXTRADATA_GAIN_OFFSET = 16, | |
| 64 // Offset to the channel mapping byte in the Opus extra data | |
| 65 OPUS_EXTRADATA_CHANNEL_MAPPING_OFFSET = 18, | |
| 66 | |
| 67 // Extra Data contains a stream map, beyond the always present | |
| 68 // |OPUS_EXTRADATA_SIZE| bytes of data. The mapping data contains stream | |
| 69 // count, coupling information, and per channel mapping values: | |
| 70 // - Byte 0: Number of streams. | |
| 71 // - Byte 1: Number coupled. | |
| 72 // - Byte 2: Starting at byte 2 are |extra_data->channels| uint8 mapping | |
| 73 // values. | |
| 74 OPUS_EXTRADATA_NUM_STREAMS_OFFSET = OPUS_EXTRADATA_SIZE, | |
| 75 OPUS_EXTRADATA_NUM_COUPLED_OFFSET = OPUS_EXTRADATA_NUM_STREAMS_OFFSET + 1, | |
| 76 OPUS_EXTRADATA_STREAM_MAP_OFFSET = OPUS_EXTRADATA_NUM_STREAMS_OFFSET + 2, | |
| 77 }; | |
| 78 | |
| 79 // Vorbis channel ordering for streams with >= 2 channels: | |
| 80 // 2 Channels | |
| 81 // L, R | |
| 82 // 3 Channels | |
| 83 // L, Center, R | |
| 84 // 4 Channels | |
| 85 // Front L, Front R, Back L, Back R | |
| 86 // 5 Channels | |
| 87 // Front L, Center, Front R, Back L, Back R | |
| 88 // 6 Channels (5.1) | |
| 89 // Front L, Center, Front R, Back L, Back R, LFE | |
| 90 // 7 channels (6.1) | |
| 91 // Front L, Front Center, Front R, Side L, Side R, Back Center, LFE | |
| 92 // 8 Channels (7.1) | |
| 93 // Front L, Center, Front R, Side L, Side R, Back L, Back R, LFE | |
| 94 // | |
| 95 // Channel ordering information is taken from section 4.3.9 of the Vorbis I | |
| 96 // Specification: | |
| 97 // http://xiph.org/vorbis/doc/Vorbis_I_spec.html#x1-800004.3.9 | |
| 98 extern const uint8_t | |
| 99 kDefaultOpusChannelLayout[OPUS_MAX_CHANNELS_WITH_DEFAULT_LAYOUT]; | |
| 100 | |
| 101 // These are the FFmpeg channel layouts expressed using the position of each | |
| 102 // channel in the output stream from libopus. | |
| 103 extern const uint8_t kFFmpegChannelDecodingLayouts[OPUS_MAX_VORBIS_CHANNELS] | |
| 104 [OPUS_MAX_VORBIS_CHANNELS]; | |
| 105 | |
| 106 // Opus internal to Vorbis channel order mapping written in the header. | |
| 107 extern const uint8_t kOpusVorbisChannelMap[OPUS_MAX_VORBIS_CHANNELS] | |
| 108 [OPUS_MAX_VORBIS_CHANNELS]; | |
| 109 | |
| 110 } // namespace media | |
| 111 | |
| 112 #endif // MEDIA_FILTERS_OPUS_CONSTANTS_H_ | |
| OLD | NEW |