2013-09-24 01:35:40 +00:00
|
|
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
2017-12-20 00:56:36 +00:00
|
|
|
#ifndef PACKAGER_MEDIA_CODECS_AAC_AUDIO_SPECIFIC_CONFIG_H_
|
|
|
|
#define PACKAGER_MEDIA_CODECS_AAC_AUDIO_SPECIFIC_CONFIG_H_
|
2013-09-24 01:35:40 +00:00
|
|
|
|
2014-09-30 23:52:58 +00:00
|
|
|
#include <stddef.h>
|
|
|
|
#include <stdint.h>
|
2013-09-24 01:35:40 +00:00
|
|
|
|
2014-09-30 23:52:58 +00:00
|
|
|
#include <vector>
|
2013-09-24 01:35:40 +00:00
|
|
|
|
2016-05-20 21:19:33 +00:00
|
|
|
namespace shaka {
|
2013-09-24 01:35:40 +00:00
|
|
|
namespace media {
|
|
|
|
|
|
|
|
class BitReader;
|
|
|
|
|
2016-03-16 19:10:12 +00:00
|
|
|
// Methods are virtual for mocking.
|
2014-01-23 22:34:39 +00:00
|
|
|
/// This class parses the AAC information from decoder specific information
|
|
|
|
/// embedded in the @b esds box in an ISO BMFF file.
|
|
|
|
/// Please refer to ISO 14496 Part 3 Table 1.13 - Syntax of AudioSpecificConfig
|
|
|
|
/// for more details.
|
2014-01-10 00:21:06 +00:00
|
|
|
class AACAudioSpecificConfig {
|
2013-09-24 01:35:40 +00:00
|
|
|
public:
|
2017-04-10 20:20:45 +00:00
|
|
|
// Audio Object Types specified in ISO 14496-3 (2005), Table 1.3
|
|
|
|
enum AudioObjectType {
|
|
|
|
AOT_NULL = 0,
|
|
|
|
AOT_AAC_MAIN = 1, // Main
|
|
|
|
AOT_AAC_LC = 2, // Low Complexity
|
|
|
|
AOT_AAC_SSR = 3, // Scalable Sample Rate
|
|
|
|
AOT_AAC_LTP = 4, // Long Term Prediction
|
|
|
|
AOT_SBR = 5, // Spectral Band Replication
|
|
|
|
AOT_AAC_SCALABLE = 6, // Scalable
|
|
|
|
AOT_TWINVQ = 7, // Twin Vector Quantizer
|
|
|
|
AOT_CELP = 8, // Code Excited Linear Prediction
|
|
|
|
AOT_HVXC = 9, // Harmonic Vector eXcitation Coding
|
|
|
|
AOT_TTSI = 12, // Text-To-Speech Interface
|
|
|
|
AOT_MAINSYNTH = 13, // Main Synthesis
|
|
|
|
AOT_WAVESYNTH = 14, // Wavetable Synthesis
|
|
|
|
AOT_MIDI = 15, // General MIDI
|
|
|
|
AOT_SAFX = 16, // Algorithmic Synthesis and Audio Effects
|
|
|
|
AOT_ER_AAC_LC = 17, // Error Resilient Low Complexity
|
|
|
|
AOT_ER_AAC_LTP = 19, // Error Resilient Long Term Prediction
|
|
|
|
AOT_ER_AAC_SCALABLE = 20, // Error Resilient Scalable
|
|
|
|
AOT_ER_TWINVQ = 21, // Error Resilient Twin Vector Quantizer
|
|
|
|
AOT_ER_BSAC = 22, // Error Resilient Bit-Sliced Arithmetic Coding
|
|
|
|
AOT_ER_AAC_LD = 23, // Error Resilient Low Delay
|
|
|
|
AOT_ER_CELP = 24, // Error Resilient Code Excited Linear
|
|
|
|
// Prediction
|
|
|
|
AOT_ER_HVXC = 25, // Error Resilient Harmonic Vector eXcitation
|
|
|
|
// Coding
|
|
|
|
AOT_ER_HILN = 26, // Error Resilient Harmonic and Individual Lines
|
|
|
|
// plus Noise
|
|
|
|
AOT_ER_PARAM = 27, // Error Resilient Parametric
|
|
|
|
AOT_SSC = 28, // SinuSoidal Coding
|
|
|
|
AOT_PS = 29, // Parametric Stereo
|
|
|
|
AOT_SURROUND = 30, // MPEG Surround
|
|
|
|
AOT_ESCAPE = 31, // Escape Value
|
|
|
|
AOT_L1 = 32, // Layer 1
|
|
|
|
AOT_L2 = 33, // Layer 2
|
|
|
|
AOT_L3 = 34, // Layer 3
|
|
|
|
AOT_DST = 35, // Direct Stream Transfer
|
|
|
|
AOT_ALS = 36, // Audio LosslesS
|
|
|
|
AOT_SLS = 37, // Scalable LosslesS
|
|
|
|
AOT_SLS_NON_CORE = 38, // Scalable LosslesS (non core)
|
|
|
|
AOT_ER_AAC_ELD = 39, // Error Resilient Enhanced Low Delay
|
|
|
|
AOT_SMR_SIMPLE = 40, // Symbolic Music Representation Simple
|
|
|
|
AOT_SMR_MAIN = 41, // Symbolic Music Representation Main
|
|
|
|
AOT_USAC_NOSBR = 42, // Unified Speech and Audio Coding (no SBR)
|
|
|
|
AOT_SAOC = 43, // Spatial Audio Object Coding
|
|
|
|
AOT_LD_SURROUND = 44, // Low Delay MPEG Surround
|
|
|
|
AOT_USAC = 45, // Unified Speech and Audio Coding
|
|
|
|
};
|
|
|
|
|
2014-01-10 00:21:06 +00:00
|
|
|
AACAudioSpecificConfig();
|
2016-03-16 19:10:12 +00:00
|
|
|
virtual ~AACAudioSpecificConfig();
|
2013-09-24 01:35:40 +00:00
|
|
|
|
2014-01-23 22:34:39 +00:00
|
|
|
/// Parse the AAC config from decoder specific information embedded in an @b
|
|
|
|
/// esds box. The function will parse the data and get the
|
|
|
|
/// ElementaryStreamDescriptor, then it will parse the
|
|
|
|
/// ElementaryStreamDescriptor to get audio stream configurations.
|
|
|
|
/// @param data contains decoder specific information from an @b esds box.
|
|
|
|
/// @return true if successful, false otherwise.
|
2016-03-16 19:10:12 +00:00
|
|
|
virtual bool Parse(const std::vector<uint8_t>& data);
|
|
|
|
|
|
|
|
/// Convert a raw AAC frame into an AAC frame with an ADTS header.
|
|
|
|
/// @param[in,out] buffer contains the raw AAC frame on input, and the
|
|
|
|
/// converted frame on output if successful; it is untouched
|
|
|
|
/// on failure.
|
|
|
|
/// @return true on success, false otherwise.
|
|
|
|
virtual bool ConvertToADTS(std::vector<uint8_t>* buffer) const;
|
2013-09-24 01:35:40 +00:00
|
|
|
|
2017-04-10 20:20:45 +00:00
|
|
|
/// @return The audio object type for this AAC config, with possible extension
|
|
|
|
/// considered.
|
|
|
|
AudioObjectType GetAudioObjectType() const;
|
2013-09-24 01:35:40 +00:00
|
|
|
|
2017-04-10 20:20:45 +00:00
|
|
|
/// @return Sample rate for the AAC stream, with possible extensions
|
|
|
|
/// considered.
|
|
|
|
uint32_t GetSamplesPerSecond() const;
|
2013-10-14 20:55:48 +00:00
|
|
|
|
2017-04-10 20:20:45 +00:00
|
|
|
/// @return Number of channels for the AAC stream, with possible extensions
|
|
|
|
/// considered.
|
|
|
|
uint8_t GetNumChannels() const;
|
2013-10-14 20:55:48 +00:00
|
|
|
|
2014-01-23 22:34:39 +00:00
|
|
|
/// Size in bytes of the ADTS header added by ConvertEsdsToADTS().
|
2013-09-24 01:35:40 +00:00
|
|
|
static const size_t kADTSHeaderSize = 7;
|
|
|
|
|
2017-04-10 20:20:45 +00:00
|
|
|
/// @return whether Spectral Band Repliation (SBR) is present in the stream.
|
|
|
|
bool sbr_present() const { return sbr_present_; }
|
|
|
|
/// Indicate whether SBR is present in the stream.
|
|
|
|
void set_sbr_present(bool sbr_present) { sbr_present_ = sbr_present; }
|
|
|
|
|
2013-09-24 01:35:40 +00:00
|
|
|
private:
|
|
|
|
bool SkipDecoderGASpecificConfig(BitReader* bit_reader) const;
|
|
|
|
bool SkipErrorSpecificConfig() const;
|
|
|
|
bool SkipGASpecificConfig(BitReader* bit_reader) const;
|
|
|
|
|
|
|
|
// The following variables store the AAC specific configuration information
|
|
|
|
// that are used to generate the ADTS header.
|
2017-04-10 20:20:45 +00:00
|
|
|
AudioObjectType audio_object_type_ = AOT_NULL;
|
|
|
|
uint8_t frequency_index_ = 0;
|
|
|
|
uint8_t channel_config_ = 0;
|
|
|
|
// Is Spectral Band Replication (SBR) available?
|
|
|
|
bool sbr_present_ = false;
|
|
|
|
// Is Parametric Stereo available?
|
|
|
|
bool ps_present_ = false;
|
2013-09-24 01:35:40 +00:00
|
|
|
|
2013-09-24 04:17:12 +00:00
|
|
|
// The following variables store audio configuration information.
|
|
|
|
// They are based on the AAC specific configuration but can be overridden
|
|
|
|
// by extensions in elementary stream descriptor.
|
2017-04-10 20:20:45 +00:00
|
|
|
uint32_t frequency_ = 0;
|
|
|
|
uint32_t extension_frequency_ = 0;
|
|
|
|
uint8_t num_channels_ = 0;
|
2013-09-24 01:35:40 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace media
|
2016-05-20 21:19:33 +00:00
|
|
|
} // namespace shaka
|
2013-09-24 01:35:40 +00:00
|
|
|
|
2017-12-20 00:56:36 +00:00
|
|
|
#endif // PACKAGER_MEDIA_CODECS_AAC_AUDIO_SPECIFIC_CONFIG_H_
|