Shaka Packager SDK
Loading...
Searching...
No Matches
aac_audio_specific_config.h
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
3// found in the LICENSE file.
4
5#ifndef PACKAGER_MEDIA_CODECS_AAC_AUDIO_SPECIFIC_CONFIG_H_
6#define PACKAGER_MEDIA_CODECS_AAC_AUDIO_SPECIFIC_CONFIG_H_
7
8#include <cstddef>
9#include <cstdint>
10#include <vector>
11
12namespace shaka {
13namespace media {
14
15class BitReader;
16
17// Methods are virtual for mocking.
23 public:
24 // Audio Object Types specified in ISO 14496-3 (2005), Table 1.3
25 enum AudioObjectType {
26 AOT_NULL = 0,
27 AOT_AAC_MAIN = 1, // Main
28 AOT_AAC_LC = 2, // Low Complexity
29 AOT_AAC_SSR = 3, // Scalable Sample Rate
30 AOT_AAC_LTP = 4, // Long Term Prediction
31 AOT_SBR = 5, // Spectral Band Replication
32 AOT_AAC_SCALABLE = 6, // Scalable
33 AOT_TWINVQ = 7, // Twin Vector Quantizer
34 AOT_CELP = 8, // Code Excited Linear Prediction
35 AOT_HVXC = 9, // Harmonic Vector eXcitation Coding
36 AOT_TTSI = 12, // Text-To-Speech Interface
37 AOT_MAINSYNTH = 13, // Main Synthesis
38 AOT_WAVESYNTH = 14, // Wavetable Synthesis
39 AOT_MIDI = 15, // General MIDI
40 AOT_SAFX = 16, // Algorithmic Synthesis and Audio Effects
41 AOT_ER_AAC_LC = 17, // Error Resilient Low Complexity
42 AOT_ER_AAC_LTP = 19, // Error Resilient Long Term Prediction
43 AOT_ER_AAC_SCALABLE = 20, // Error Resilient Scalable
44 AOT_ER_TWINVQ = 21, // Error Resilient Twin Vector Quantizer
45 AOT_ER_BSAC = 22, // Error Resilient Bit-Sliced Arithmetic Coding
46 AOT_ER_AAC_LD = 23, // Error Resilient Low Delay
47 AOT_ER_CELP = 24, // Error Resilient Code Excited Linear
48 // Prediction
49 AOT_ER_HVXC = 25, // Error Resilient Harmonic Vector eXcitation
50 // Coding
51 AOT_ER_HILN = 26, // Error Resilient Harmonic and Individual Lines
52 // plus Noise
53 AOT_ER_PARAM = 27, // Error Resilient Parametric
54 AOT_SSC = 28, // SinuSoidal Coding
55 AOT_PS = 29, // Parametric Stereo
56 AOT_SURROUND = 30, // MPEG Surround
57 AOT_ESCAPE = 31, // Escape Value
58 AOT_L1 = 32, // Layer 1
59 AOT_L2 = 33, // Layer 2
60 AOT_L3 = 34, // Layer 3
61 AOT_DST = 35, // Direct Stream Transfer
62 AOT_ALS = 36, // Audio LosslesS
63 AOT_SLS = 37, // Scalable LosslesS
64 AOT_SLS_NON_CORE = 38, // Scalable LosslesS (non core)
65 AOT_ER_AAC_ELD = 39, // Error Resilient Enhanced Low Delay
66 AOT_SMR_SIMPLE = 40, // Symbolic Music Representation Simple
67 AOT_SMR_MAIN = 41, // Symbolic Music Representation Main
68 AOT_USAC = 42, // Unified Speech and Audio Coding
69 AOT_SAOC = 43, // Spatial Audio Object Coding
70 AOT_LD_SURROUND = 44, // Low Delay MPEG Surround
71 SAOC_DE = 45, // Spatial Audio Object Coding Dialogue Enhancement
72 };
73
76
83 virtual bool Parse(const std::vector<uint8_t>& data);
84
91 virtual bool ConvertToADTS(const uint8_t* data,
92 size_t data_size,
93 std::vector<uint8_t>* audio_frame) const;
94
97 AudioObjectType GetAudioObjectType() const;
98
101 uint32_t GetSamplesPerSecond() const;
102
105 uint8_t GetNumChannels() const;
106
108 static const size_t kADTSHeaderSize = 7;
109
111 bool sbr_present() const { return sbr_present_; }
113 void set_sbr_present(bool sbr_present) { sbr_present_ = sbr_present; }
114
115 private:
116 bool ParseAudioObjectType(BitReader* bit_reader);
117 bool ParseDecoderGASpecificConfig(BitReader* bit_reader);
118 bool SkipErrorSpecificConfig() const;
119 // Parse GASpecificConfig. Calls |ParseProgramConfigElement| if
120 // |channel_config_| == 0.
121 bool ParseGASpecificConfig(BitReader* bit_reader);
122 // Parse program_config_element(). |num_channels_| will be updated.
123 bool ParseProgramConfigElement(BitReader* bit_reader);
124
125 // The following variables store the AAC specific configuration information
126 // that are used to generate the ADTS header.
127 AudioObjectType audio_object_type_ = AOT_NULL;
128 uint8_t frequency_index_ = 0;
129 uint8_t channel_config_ = 0;
130 // Is Spectral Band Replication (SBR) available?
131 bool sbr_present_ = false;
132 // Is Parametric Stereo available?
133 bool ps_present_ = false;
134
135 // The following variables store audio configuration information.
136 // They are based on the AAC specific configuration but can be overridden
137 // by extensions in elementary stream descriptor.
138 uint32_t frequency_ = 0;
139 uint32_t extension_frequency_ = 0;
140 uint8_t num_channels_ = 0;
141};
142
143} // namespace media
144} // namespace shaka
145
146#endif // PACKAGER_MEDIA_CODECS_AAC_AUDIO_SPECIFIC_CONFIG_H_
static const size_t kADTSHeaderSize
Size in bytes of the ADTS header added by ConvertEsdsToADTS().
virtual bool ConvertToADTS(const uint8_t *data, size_t data_size, std::vector< uint8_t > *audio_frame) const
virtual bool Parse(const std::vector< uint8_t > &data)
void set_sbr_present(bool sbr_present)
Indicate whether SBR is present in the stream.
A class to read bit streams.
Definition bit_reader.h:20
All the methods that are virtual are virtual for mocking.