Rename AAC to AACAudioSpecificConfig.
Change-Id: Idda2db1f2cdde6c2c220830c2681bef209ad4ce2
This commit is contained in:
parent
4c01b89625
commit
e4ebc9763c
|
@ -2,7 +2,7 @@
|
||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
#include "media/mp4/aac.h"
|
#include "media/mp4/aac_audio_specific_config.h"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
|
@ -27,16 +27,18 @@ namespace media {
|
||||||
|
|
||||||
namespace mp4 {
|
namespace mp4 {
|
||||||
|
|
||||||
AAC::AAC()
|
AACAudioSpecificConfig::AACAudioSpecificConfig()
|
||||||
: audio_object_type_(0), frequency_index_(0), channel_config_(0),
|
: audio_object_type_(0),
|
||||||
ps_present_(false), frequency_(0), extension_frequency_(0),
|
frequency_index_(0),
|
||||||
num_channels_(0) {
|
channel_config_(0),
|
||||||
}
|
ps_present_(false),
|
||||||
|
frequency_(0),
|
||||||
|
extension_frequency_(0),
|
||||||
|
num_channels_(0) {}
|
||||||
|
|
||||||
AAC::~AAC() {
|
AACAudioSpecificConfig::~AACAudioSpecificConfig() {}
|
||||||
}
|
|
||||||
|
|
||||||
bool AAC::Parse(const std::vector<uint8>& data) {
|
bool AACAudioSpecificConfig::Parse(const std::vector<uint8>& data) {
|
||||||
if (data.empty())
|
if (data.empty())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -125,7 +127,8 @@ bool AAC::Parse(const std::vector<uint8>& data) {
|
||||||
channel_config_ <= 7;
|
channel_config_ <= 7;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 AAC::GetOutputSamplesPerSecond(bool sbr_in_mimetype) const {
|
uint32 AACAudioSpecificConfig::GetOutputSamplesPerSecond(bool sbr_in_mimetype)
|
||||||
|
const {
|
||||||
if (extension_frequency_ > 0)
|
if (extension_frequency_ > 0)
|
||||||
return extension_frequency_;
|
return extension_frequency_;
|
||||||
|
|
||||||
|
@ -140,7 +143,7 @@ uint32 AAC::GetOutputSamplesPerSecond(bool sbr_in_mimetype) const {
|
||||||
return std::min(2 * frequency_, 48000u);
|
return std::min(2 * frequency_, 48000u);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8 AAC::GetNumChannels(bool sbr_in_mimetype) const {
|
uint8 AACAudioSpecificConfig::GetNumChannels(bool sbr_in_mimetype) const {
|
||||||
// Check for implicit signalling of HE-AAC and indicate stereo output
|
// Check for implicit signalling of HE-AAC and indicate stereo output
|
||||||
// if the mono channel configuration is signalled.
|
// if the mono channel configuration is signalled.
|
||||||
// See ISO-14496-3 Section 1.6.6.1.2 for details about this special casing.
|
// See ISO-14496-3 Section 1.6.6.1.2 for details about this special casing.
|
||||||
|
@ -154,7 +157,7 @@ uint8 AAC::GetNumChannels(bool sbr_in_mimetype) const {
|
||||||
return num_channels_;
|
return num_channels_;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AAC::ConvertToADTS(std::vector<uint8>* buffer) const {
|
bool AACAudioSpecificConfig::ConvertToADTS(std::vector<uint8>* buffer) const {
|
||||||
size_t size = buffer->size() + kADTSHeaderSize;
|
size_t size = buffer->size() + kADTSHeaderSize;
|
||||||
|
|
||||||
DCHECK(audio_object_type_ >= 1 && audio_object_type_ <= 4 &&
|
DCHECK(audio_object_type_ >= 1 && audio_object_type_ <= 4 &&
|
||||||
|
@ -181,7 +184,7 @@ bool AAC::ConvertToADTS(std::vector<uint8>* buffer) const {
|
||||||
|
|
||||||
// Currently this function only support GASpecificConfig defined in
|
// Currently this function only support GASpecificConfig defined in
|
||||||
// ISO 14496 Part 3 Table 4.1 - Syntax of GASpecificConfig()
|
// ISO 14496 Part 3 Table 4.1 - Syntax of GASpecificConfig()
|
||||||
bool AAC::SkipDecoderGASpecificConfig(BitReader* bit_reader) const {
|
bool AACAudioSpecificConfig::SkipDecoderGASpecificConfig(BitReader* bit_reader) const {
|
||||||
switch (audio_object_type_) {
|
switch (audio_object_type_) {
|
||||||
case 1:
|
case 1:
|
||||||
case 2:
|
case 2:
|
||||||
|
@ -203,7 +206,7 @@ bool AAC::SkipDecoderGASpecificConfig(BitReader* bit_reader) const {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AAC::SkipErrorSpecificConfig() const {
|
bool AACAudioSpecificConfig::SkipErrorSpecificConfig() const {
|
||||||
switch (audio_object_type_) {
|
switch (audio_object_type_) {
|
||||||
case 17:
|
case 17:
|
||||||
case 19:
|
case 19:
|
||||||
|
@ -225,7 +228,7 @@ bool AAC::SkipErrorSpecificConfig() const {
|
||||||
|
|
||||||
// The following code is written according to ISO 14496 part 3 Table 4.1 -
|
// The following code is written according to ISO 14496 part 3 Table 4.1 -
|
||||||
// GASpecificConfig.
|
// GASpecificConfig.
|
||||||
bool AAC::SkipGASpecificConfig(BitReader* bit_reader) const {
|
bool AACAudioSpecificConfig::SkipGASpecificConfig(BitReader* bit_reader) const {
|
||||||
uint8 extension_flag = 0;
|
uint8 extension_flag = 0;
|
||||||
uint8 depends_on_core_coder;
|
uint8 depends_on_core_coder;
|
||||||
uint16 dummy;
|
uint16 dummy;
|
|
@ -2,8 +2,8 @@
|
||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
#ifndef MEDIA_MP4_AAC_H_
|
#ifndef MEDIA_MP4_AAC_AUDIO_SPECIFIC_CONFIG_H_
|
||||||
#define MEDIA_MP4_AAC_H_
|
#define MEDIA_MP4_AAC_AUDIO_SPECIFIC_CONFIG_H_
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
@ -19,12 +19,10 @@ namespace mp4 {
|
||||||
// embedded in the esds box in an ISO BMFF file.
|
// embedded in the esds box in an ISO BMFF file.
|
||||||
// Please refer to ISO 14496 Part 3 Table 1.13 - Syntax of AudioSpecificConfig
|
// Please refer to ISO 14496 Part 3 Table 1.13 - Syntax of AudioSpecificConfig
|
||||||
// for more details.
|
// for more details.
|
||||||
// TODO(kqyang): the class name is not appropriate, it should be
|
class AACAudioSpecificConfig {
|
||||||
// AACAudioSpecificConfig instead.
|
|
||||||
class AAC {
|
|
||||||
public:
|
public:
|
||||||
AAC();
|
AACAudioSpecificConfig();
|
||||||
~AAC();
|
~AACAudioSpecificConfig();
|
||||||
|
|
||||||
// Parse the AAC config from the raw binary data embedded in esds box.
|
// Parse the AAC config from the raw binary data embedded in esds box.
|
||||||
// The function will parse the data and get the ElementaryStreamDescriptor,
|
// The function will parse the data and get the ElementaryStreamDescriptor,
|
||||||
|
@ -32,12 +30,12 @@ class AAC {
|
||||||
// configurations.
|
// configurations.
|
||||||
bool Parse(const std::vector<uint8>& data);
|
bool Parse(const std::vector<uint8>& data);
|
||||||
|
|
||||||
// Gets the output sample rate for the AAC stream.
|
// Get the output sample rate for the AAC stream.
|
||||||
// |sbr_in_mimetype| should be set to true if the SBR mode is
|
// |sbr_in_mimetype| should be set to true if the SBR mode is
|
||||||
// signalled in the mimetype. (ie mp4a.40.5 in the codecs parameter).
|
// signalled in the mimetype. (ie mp4a.40.5 in the codecs parameter).
|
||||||
uint32 GetOutputSamplesPerSecond(bool sbr_in_mimetype) const;
|
uint32 GetOutputSamplesPerSecond(bool sbr_in_mimetype) const;
|
||||||
|
|
||||||
// Gets number of channels for the AAC stream.
|
// Get number of channels for the AAC stream.
|
||||||
// |sbr_in_mimetype| should be set to true if the SBR mode is
|
// |sbr_in_mimetype| should be set to true if the SBR mode is
|
||||||
// signalled in the mimetype. (ie mp4a.40.5 in the codecs parameter).
|
// signalled in the mimetype. (ie mp4a.40.5 in the codecs parameter).
|
||||||
uint8 GetNumChannels(bool sbr_in_mimetype) const;
|
uint8 GetNumChannels(bool sbr_in_mimetype) const;
|
||||||
|
@ -85,7 +83,6 @@ class AAC {
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace mp4
|
} // namespace mp4
|
||||||
|
|
||||||
} // namespace media
|
} // namespace media
|
||||||
|
|
||||||
#endif // MEDIA_MP4_AAC_H_
|
#endif // MEDIA_MP4_AAC_AUDIO_SPECIFIC_CONFIG_H_
|
|
@ -0,0 +1,144 @@
|
||||||
|
// 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.
|
||||||
|
|
||||||
|
#include "media/mp4/aac_audio_specific_config.h"
|
||||||
|
|
||||||
|
#include "testing/gtest/include/gtest/gtest.h"
|
||||||
|
|
||||||
|
namespace media {
|
||||||
|
namespace mp4 {
|
||||||
|
|
||||||
|
TEST(AACAudioSpecificConfigTest, BasicProfileTest) {
|
||||||
|
AACAudioSpecificConfig aac_audio_specific_config;
|
||||||
|
uint8 buffer[] = {0x12, 0x10};
|
||||||
|
std::vector<uint8> data;
|
||||||
|
|
||||||
|
data.assign(buffer, buffer + sizeof(buffer));
|
||||||
|
|
||||||
|
EXPECT_TRUE(aac_audio_specific_config.Parse(data));
|
||||||
|
EXPECT_EQ(aac_audio_specific_config.GetOutputSamplesPerSecond(false), 44100);
|
||||||
|
EXPECT_EQ(aac_audio_specific_config.GetNumChannels(false), 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(AACAudioSpecificConfigTest, ExtensionTest) {
|
||||||
|
AACAudioSpecificConfig aac_audio_specific_config;
|
||||||
|
uint8 buffer[] = {0x13, 0x08, 0x56, 0xe5, 0x9d, 0x48, 0x80};
|
||||||
|
std::vector<uint8> data;
|
||||||
|
|
||||||
|
data.assign(buffer, buffer + sizeof(buffer));
|
||||||
|
|
||||||
|
EXPECT_TRUE(aac_audio_specific_config.Parse(data));
|
||||||
|
EXPECT_EQ(aac_audio_specific_config.GetOutputSamplesPerSecond(false), 48000);
|
||||||
|
EXPECT_EQ(aac_audio_specific_config.GetOutputSamplesPerSecond(true), 48000);
|
||||||
|
EXPECT_EQ(aac_audio_specific_config.GetNumChannels(false), 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test implicit SBR with mono channel config.
|
||||||
|
// Mono channel layout should only be reported if SBR is not
|
||||||
|
// specified. Otherwise stereo should be reported.
|
||||||
|
// See ISO-14496-3 Section 1.6.6.1.2 for details about this special casing.
|
||||||
|
TEST(AACAudioSpecificConfigTest, ImplicitSBR_ChannelConfig0) {
|
||||||
|
AACAudioSpecificConfig aac_audio_specific_config;
|
||||||
|
uint8 buffer[] = {0x13, 0x08};
|
||||||
|
std::vector<uint8> data;
|
||||||
|
|
||||||
|
data.assign(buffer, buffer + sizeof(buffer));
|
||||||
|
|
||||||
|
EXPECT_TRUE(aac_audio_specific_config.Parse(data));
|
||||||
|
|
||||||
|
// Test w/o implict SBR.
|
||||||
|
EXPECT_EQ(aac_audio_specific_config.GetOutputSamplesPerSecond(false), 24000);
|
||||||
|
EXPECT_EQ(aac_audio_specific_config.GetNumChannels(false), 1);
|
||||||
|
|
||||||
|
// Test implicit SBR.
|
||||||
|
EXPECT_EQ(aac_audio_specific_config.GetOutputSamplesPerSecond(true), 48000);
|
||||||
|
EXPECT_EQ(aac_audio_specific_config.GetNumChannels(true), 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Tests implicit SBR with a stereo channel config.
|
||||||
|
TEST(AACAudioSpecificConfigTest, ImplicitSBR_ChannelConfig1) {
|
||||||
|
AACAudioSpecificConfig aac_audio_specific_config;
|
||||||
|
uint8 buffer[] = {0x13, 0x10};
|
||||||
|
std::vector<uint8> data;
|
||||||
|
|
||||||
|
data.assign(buffer, buffer + sizeof(buffer));
|
||||||
|
|
||||||
|
EXPECT_TRUE(aac_audio_specific_config.Parse(data));
|
||||||
|
|
||||||
|
// Test w/o implict SBR.
|
||||||
|
EXPECT_EQ(aac_audio_specific_config.GetOutputSamplesPerSecond(false), 24000);
|
||||||
|
EXPECT_EQ(aac_audio_specific_config.GetNumChannels(false), 2);
|
||||||
|
|
||||||
|
// Test implicit SBR.
|
||||||
|
EXPECT_EQ(aac_audio_specific_config.GetOutputSamplesPerSecond(true), 48000);
|
||||||
|
EXPECT_EQ(aac_audio_specific_config.GetNumChannels(true), 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(AACAudioSpecificConfigTest, SixChannelTest) {
|
||||||
|
AACAudioSpecificConfig aac_audio_specific_config;
|
||||||
|
uint8 buffer[] = {0x11, 0xb0};
|
||||||
|
std::vector<uint8> data;
|
||||||
|
|
||||||
|
data.assign(buffer, buffer + sizeof(buffer));
|
||||||
|
|
||||||
|
EXPECT_TRUE(aac_audio_specific_config.Parse(data));
|
||||||
|
EXPECT_EQ(aac_audio_specific_config.GetOutputSamplesPerSecond(false), 48000);
|
||||||
|
EXPECT_EQ(aac_audio_specific_config.GetNumChannels(false), 6);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(AACAudioSpecificConfigTest, DataTooShortTest) {
|
||||||
|
AACAudioSpecificConfig aac_audio_specific_config;
|
||||||
|
std::vector<uint8> data;
|
||||||
|
|
||||||
|
EXPECT_FALSE(aac_audio_specific_config.Parse(data));
|
||||||
|
|
||||||
|
data.push_back(0x12);
|
||||||
|
EXPECT_FALSE(aac_audio_specific_config.Parse(data));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(AACAudioSpecificConfigTest, IncorrectProfileTest) {
|
||||||
|
AACAudioSpecificConfig aac_audio_specific_config;
|
||||||
|
uint8 buffer[] = {0x0, 0x08};
|
||||||
|
std::vector<uint8> data;
|
||||||
|
|
||||||
|
data.assign(buffer, buffer + sizeof(buffer));
|
||||||
|
|
||||||
|
EXPECT_FALSE(aac_audio_specific_config.Parse(data));
|
||||||
|
|
||||||
|
data[0] = 0x08;
|
||||||
|
EXPECT_TRUE(aac_audio_specific_config.Parse(data));
|
||||||
|
|
||||||
|
data[0] = 0x28;
|
||||||
|
EXPECT_FALSE(aac_audio_specific_config.Parse(data));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(AACAudioSpecificConfigTest, IncorrectFrequencyTest) {
|
||||||
|
AACAudioSpecificConfig aac_audio_specific_config;
|
||||||
|
uint8 buffer[] = {0x0f, 0x88};
|
||||||
|
std::vector<uint8> data;
|
||||||
|
|
||||||
|
data.assign(buffer, buffer + sizeof(buffer));
|
||||||
|
|
||||||
|
EXPECT_FALSE(aac_audio_specific_config.Parse(data));
|
||||||
|
|
||||||
|
data[0] = 0x0e;
|
||||||
|
data[1] = 0x08;
|
||||||
|
EXPECT_TRUE(aac_audio_specific_config.Parse(data));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(AACAudioSpecificConfigTest, IncorrectChannelTest) {
|
||||||
|
AACAudioSpecificConfig aac_audio_specific_config;
|
||||||
|
uint8 buffer[] = {0x0e, 0x00};
|
||||||
|
std::vector<uint8> data;
|
||||||
|
|
||||||
|
data.assign(buffer, buffer + sizeof(buffer));
|
||||||
|
|
||||||
|
EXPECT_FALSE(aac_audio_specific_config.Parse(data));
|
||||||
|
|
||||||
|
data[1] = 0x08;
|
||||||
|
EXPECT_TRUE(aac_audio_specific_config.Parse(data));
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace mp4
|
||||||
|
} // namespace media
|
|
@ -1,146 +0,0 @@
|
||||||
// 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.
|
|
||||||
|
|
||||||
#include "media/mp4/aac.h"
|
|
||||||
|
|
||||||
#include "testing/gtest/include/gtest/gtest.h"
|
|
||||||
|
|
||||||
namespace media {
|
|
||||||
|
|
||||||
namespace mp4 {
|
|
||||||
|
|
||||||
TEST(AACTest, BasicProfileTest) {
|
|
||||||
AAC aac;
|
|
||||||
uint8 buffer[] = {0x12, 0x10};
|
|
||||||
std::vector<uint8> data;
|
|
||||||
|
|
||||||
data.assign(buffer, buffer + sizeof(buffer));
|
|
||||||
|
|
||||||
EXPECT_TRUE(aac.Parse(data));
|
|
||||||
EXPECT_EQ(aac.GetOutputSamplesPerSecond(false), 44100);
|
|
||||||
EXPECT_EQ(aac.GetNumChannels(false), 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST(AACTest, ExtensionTest) {
|
|
||||||
AAC aac;
|
|
||||||
uint8 buffer[] = {0x13, 0x08, 0x56, 0xe5, 0x9d, 0x48, 0x80};
|
|
||||||
std::vector<uint8> data;
|
|
||||||
|
|
||||||
data.assign(buffer, buffer + sizeof(buffer));
|
|
||||||
|
|
||||||
EXPECT_TRUE(aac.Parse(data));
|
|
||||||
EXPECT_EQ(aac.GetOutputSamplesPerSecond(false), 48000);
|
|
||||||
EXPECT_EQ(aac.GetOutputSamplesPerSecond(true), 48000);
|
|
||||||
EXPECT_EQ(aac.GetNumChannels(false), 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Test implicit SBR with mono channel config.
|
|
||||||
// Mono channel layout should only be reported if SBR is not
|
|
||||||
// specified. Otherwise stereo should be reported.
|
|
||||||
// See ISO-14496-3 Section 1.6.6.1.2 for details about this special casing.
|
|
||||||
TEST(AACTest, ImplicitSBR_ChannelConfig0) {
|
|
||||||
AAC aac;
|
|
||||||
uint8 buffer[] = {0x13, 0x08};
|
|
||||||
std::vector<uint8> data;
|
|
||||||
|
|
||||||
data.assign(buffer, buffer + sizeof(buffer));
|
|
||||||
|
|
||||||
EXPECT_TRUE(aac.Parse(data));
|
|
||||||
|
|
||||||
// Test w/o implict SBR.
|
|
||||||
EXPECT_EQ(aac.GetOutputSamplesPerSecond(false), 24000);
|
|
||||||
EXPECT_EQ(aac.GetNumChannels(false), 1);
|
|
||||||
|
|
||||||
// Test implicit SBR.
|
|
||||||
EXPECT_EQ(aac.GetOutputSamplesPerSecond(true), 48000);
|
|
||||||
EXPECT_EQ(aac.GetNumChannels(true), 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Tests implicit SBR with a stereo channel config.
|
|
||||||
TEST(AACTest, ImplicitSBR_ChannelConfig1) {
|
|
||||||
AAC aac;
|
|
||||||
uint8 buffer[] = {0x13, 0x10};
|
|
||||||
std::vector<uint8> data;
|
|
||||||
|
|
||||||
data.assign(buffer, buffer + sizeof(buffer));
|
|
||||||
|
|
||||||
EXPECT_TRUE(aac.Parse(data));
|
|
||||||
|
|
||||||
// Test w/o implict SBR.
|
|
||||||
EXPECT_EQ(aac.GetOutputSamplesPerSecond(false), 24000);
|
|
||||||
EXPECT_EQ(aac.GetNumChannels(false), 2);
|
|
||||||
|
|
||||||
// Test implicit SBR.
|
|
||||||
EXPECT_EQ(aac.GetOutputSamplesPerSecond(true), 48000);
|
|
||||||
EXPECT_EQ(aac.GetNumChannels(true), 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST(AACTest, SixChannelTest) {
|
|
||||||
AAC aac;
|
|
||||||
uint8 buffer[] = {0x11, 0xb0};
|
|
||||||
std::vector<uint8> data;
|
|
||||||
|
|
||||||
data.assign(buffer, buffer + sizeof(buffer));
|
|
||||||
|
|
||||||
EXPECT_TRUE(aac.Parse(data));
|
|
||||||
EXPECT_EQ(aac.GetOutputSamplesPerSecond(false), 48000);
|
|
||||||
EXPECT_EQ(aac.GetNumChannels(false), 6);
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST(AACTest, DataTooShortTest) {
|
|
||||||
AAC aac;
|
|
||||||
std::vector<uint8> data;
|
|
||||||
|
|
||||||
EXPECT_FALSE(aac.Parse(data));
|
|
||||||
|
|
||||||
data.push_back(0x12);
|
|
||||||
EXPECT_FALSE(aac.Parse(data));
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST(AACTest, IncorrectProfileTest) {
|
|
||||||
AAC aac;
|
|
||||||
uint8 buffer[] = {0x0, 0x08};
|
|
||||||
std::vector<uint8> data;
|
|
||||||
|
|
||||||
data.assign(buffer, buffer + sizeof(buffer));
|
|
||||||
|
|
||||||
EXPECT_FALSE(aac.Parse(data));
|
|
||||||
|
|
||||||
data[0] = 0x08;
|
|
||||||
EXPECT_TRUE(aac.Parse(data));
|
|
||||||
|
|
||||||
data[0] = 0x28;
|
|
||||||
EXPECT_FALSE(aac.Parse(data));
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST(AACTest, IncorrectFrequencyTest) {
|
|
||||||
AAC aac;
|
|
||||||
uint8 buffer[] = {0x0f, 0x88};
|
|
||||||
std::vector<uint8> data;
|
|
||||||
|
|
||||||
data.assign(buffer, buffer + sizeof(buffer));
|
|
||||||
|
|
||||||
EXPECT_FALSE(aac.Parse(data));
|
|
||||||
|
|
||||||
data[0] = 0x0e;
|
|
||||||
data[1] = 0x08;
|
|
||||||
EXPECT_TRUE(aac.Parse(data));
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST(AACTest, IncorrectChannelTest) {
|
|
||||||
AAC aac;
|
|
||||||
uint8 buffer[] = {0x0e, 0x00};
|
|
||||||
std::vector<uint8> data;
|
|
||||||
|
|
||||||
data.assign(buffer, buffer + sizeof(buffer));
|
|
||||||
|
|
||||||
EXPECT_FALSE(aac.Parse(data));
|
|
||||||
|
|
||||||
data[1] = 0x08;
|
|
||||||
EXPECT_TRUE(aac.Parse(data));
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace mp4
|
|
||||||
|
|
||||||
} // namespace media
|
|
|
@ -983,8 +983,10 @@ bool ElementaryStreamDescriptor::ReadWrite(BoxBuffer* buffer) {
|
||||||
std::vector<uint8> data;
|
std::vector<uint8> data;
|
||||||
RCHECK(buffer->ReadWriteVector(&data, buffer->Size() - buffer->Pos()));
|
RCHECK(buffer->ReadWriteVector(&data, buffer->Size() - buffer->Pos()));
|
||||||
RCHECK(es_descriptor.Parse(data));
|
RCHECK(es_descriptor.Parse(data));
|
||||||
if (es_descriptor.IsAAC())
|
if (es_descriptor.IsAAC()) {
|
||||||
RCHECK(aac.Parse(es_descriptor.decoder_specific_info()));
|
RCHECK(aac_audio_specific_config.Parse(
|
||||||
|
es_descriptor.decoder_specific_info()));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
DCHECK(buffer->writer());
|
DCHECK(buffer->writer());
|
||||||
es_descriptor.Write(buffer->writer());
|
es_descriptor.Write(buffer->writer());
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "media/mp4/aac.h"
|
#include "media/mp4/aac_audio_specific_config.h"
|
||||||
#include "media/mp4/box.h"
|
#include "media/mp4/box.h"
|
||||||
#include "media/mp4/es_descriptor.h"
|
#include "media/mp4/es_descriptor.h"
|
||||||
#include "media/mp4/fourccs.h"
|
#include "media/mp4/fourccs.h"
|
||||||
|
@ -210,7 +210,7 @@ struct VideoSampleEntry : Box {
|
||||||
struct ElementaryStreamDescriptor : FullBox {
|
struct ElementaryStreamDescriptor : FullBox {
|
||||||
DECLARE_BOX_METHODS(ElementaryStreamDescriptor);
|
DECLARE_BOX_METHODS(ElementaryStreamDescriptor);
|
||||||
|
|
||||||
AAC aac;
|
AACAudioSpecificConfig aac_audio_specific_config;
|
||||||
ESDescriptor es_descriptor;
|
ESDescriptor es_descriptor;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -227,10 +227,11 @@ bool MP4MediaParser::ParseMoov(BoxReader* reader) {
|
||||||
// supported MPEG2 AAC variants.
|
// supported MPEG2 AAC variants.
|
||||||
if (entry.esds.es_descriptor.IsAAC()) {
|
if (entry.esds.es_descriptor.IsAAC()) {
|
||||||
codec = kCodecAAC;
|
codec = kCodecAAC;
|
||||||
const AAC& aac = entry.esds.aac;
|
const AACAudioSpecificConfig& aac_audio_specific_config =
|
||||||
num_channels = aac.num_channels();
|
entry.esds.aac_audio_specific_config;
|
||||||
sampling_frequency = aac.frequency();
|
num_channels = aac_audio_specific_config.num_channels();
|
||||||
audio_object_type = aac.audio_object_type();
|
sampling_frequency = aac_audio_specific_config.frequency();
|
||||||
|
audio_object_type = aac_audio_specific_config.audio_object_type();
|
||||||
extra_data = entry.esds.es_descriptor.decoder_specific_info();
|
extra_data = entry.esds.es_descriptor.decoder_specific_info();
|
||||||
} else if (audio_type == kEAC3) {
|
} else if (audio_type == kEAC3) {
|
||||||
codec = kCodecEAC3;
|
codec = kCodecEAC3;
|
||||||
|
|
|
@ -98,8 +98,8 @@
|
||||||
'target_name': 'mp4',
|
'target_name': 'mp4',
|
||||||
'type': 'static_library',
|
'type': 'static_library',
|
||||||
'sources': [
|
'sources': [
|
||||||
'media/mp4/aac.cc',
|
'media/mp4/aac_audio_specific_config.cc',
|
||||||
'media/mp4/aac.h',
|
'media/mp4/aac_audio_specific_config.h',
|
||||||
'media/mp4/box.cc',
|
'media/mp4/box.cc',
|
||||||
'media/mp4/box.h',
|
'media/mp4/box.h',
|
||||||
'media/mp4/box_buffer_interface.h',
|
'media/mp4/box_buffer_interface.h',
|
||||||
|
@ -147,7 +147,7 @@
|
||||||
'target_name': 'mp4_unittest',
|
'target_name': 'mp4_unittest',
|
||||||
'type': 'executable',
|
'type': 'executable',
|
||||||
'sources': [
|
'sources': [
|
||||||
'media/mp4/aac_unittest.cc',
|
'media/mp4/aac_audio_specific_config_unittest.cc',
|
||||||
'media/mp4/box_definitions_unittest.cc',
|
'media/mp4/box_definitions_unittest.cc',
|
||||||
'media/mp4/box_reader_unittest.cc',
|
'media/mp4/box_reader_unittest.cc',
|
||||||
'media/mp4/chunk_info_iterator_unittest.cc',
|
'media/mp4/chunk_info_iterator_unittest.cc',
|
||||||
|
|
Loading…
Reference in New Issue