Rename XxxConfiguration to XxxConfigurationRecord

These are really configuration records.

Change-Id: I0d081c2e14f19bcdf8eb52dc094a1e7c096b5f98
This commit is contained in:
Kongqun Yang 2016-05-25 10:33:53 -07:00
parent 68aa1397b0
commit 6d281c6676
24 changed files with 177 additions and 181 deletions

View File

@ -4,7 +4,7 @@
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd
#include "packager/media/filters/avc_decoder_configuration.h"
#include "packager/media/filters/avc_decoder_configuration_record.h"
#include "packager/base/strings/string_number_conversions.h"
#include "packager/base/strings/string_util.h"
@ -15,15 +15,15 @@
namespace shaka {
namespace media {
AVCDecoderConfiguration::AVCDecoderConfiguration()
AVCDecoderConfigurationRecord::AVCDecoderConfigurationRecord()
: version_(0),
profile_indication_(0),
profile_compatibility_(0),
avc_level_(0) {}
AVCDecoderConfiguration::~AVCDecoderConfiguration() {}
AVCDecoderConfigurationRecord::~AVCDecoderConfigurationRecord() {}
bool AVCDecoderConfiguration::ParseInternal() {
bool AVCDecoderConfigurationRecord::ParseInternal() {
// See ISO 14496-15 sec 5.3.3.1.2
BufferReader reader(data(), data_size());
@ -88,12 +88,12 @@ bool AVCDecoderConfiguration::ParseInternal() {
return true;
}
std::string AVCDecoderConfiguration::GetCodecString() const {
std::string AVCDecoderConfigurationRecord::GetCodecString() const {
return GetCodecString(profile_indication_, profile_compatibility_,
avc_level_);
}
std::string AVCDecoderConfiguration::GetCodecString(
std::string AVCDecoderConfigurationRecord::GetCodecString(
uint8_t profile_indication,
uint8_t profile_compatibility,
uint8_t avc_level) {

View File

@ -4,24 +4,24 @@
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd
#ifndef MEDIA_FILTERS_AVC_DECODER_CONFIGURATION_H_
#define MEDIA_FILTERS_AVC_DECODER_CONFIGURATION_H_
#ifndef MEDIA_FILTERS_AVC_DECODER_CONFIGURATION_RECORD_H_
#define MEDIA_FILTERS_AVC_DECODER_CONFIGURATION_RECORD_H_
#include <stdint.h>
#include <string>
#include <vector>
#include "packager/base/macros.h"
#include "packager/media/filters/decoder_configuration.h"
#include "packager/media/filters/decoder_configuration_record.h"
namespace shaka {
namespace media {
/// Class for parsing AVC decoder configuration.
class AVCDecoderConfiguration : public DecoderConfiguration {
/// Class for parsing AVC decoder configuration record.
class AVCDecoderConfigurationRecord : public DecoderConfigurationRecord {
public:
AVCDecoderConfiguration();
~AVCDecoderConfiguration() override;
AVCDecoderConfigurationRecord();
~AVCDecoderConfigurationRecord() override;
/// @return The codec string.
std::string GetCodecString() const;
@ -55,10 +55,10 @@ class AVCDecoderConfiguration : public DecoderConfiguration {
uint32_t pixel_width_;
uint32_t pixel_height_;
DISALLOW_COPY_AND_ASSIGN(AVCDecoderConfiguration);
DISALLOW_COPY_AND_ASSIGN(AVCDecoderConfigurationRecord);
};
} // namespace media
} // namespace shaka
#endif // MEDIA_FILTERS_AVC_DECODER_CONFIGURATION_H_
#endif // MEDIA_FILTERS_AVC_DECODER_CONFIGURATION_RECORD_H_

View File

@ -4,21 +4,21 @@
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd
#include "packager/media/filters/avc_decoder_configuration.h"
#include "packager/media/filters/avc_decoder_configuration_record.h"
#include <gtest/gtest.h>
namespace shaka {
namespace media {
TEST(AVCDecoderConfigurationTest, Success) {
TEST(AVCDecoderConfigurationRecordTest, Success) {
const uint8_t kAvcDecoderConfigurationData[] = {
0x01, 0x64, 0x00, 0x1E, 0xFF, 0xE1, 0x00, 0x1D, 0x67, 0x64, 0x00, 0x1E,
0xAC, 0xD9, 0x40, 0xB4, 0x2F, 0xF9, 0x7F, 0xF0, 0x00, 0x80, 0x00, 0x91,
0x00, 0x00, 0x03, 0x03, 0xE9, 0x00, 0x00, 0xEA, 0x60, 0x0F, 0x16, 0x2D,
0x96, 0x01, 0x00, 0x06, 0x68, 0xEB, 0xE3, 0xCB, 0x22, 0xC0};
AVCDecoderConfiguration avc_config;
AVCDecoderConfigurationRecord avc_config;
ASSERT_TRUE(avc_config.Parse(kAvcDecoderConfigurationData,
arraysize(kAvcDecoderConfigurationData)));
@ -35,29 +35,29 @@ TEST(AVCDecoderConfigurationTest, Success) {
EXPECT_EQ("avc1.64001e", avc_config.GetCodecString());
}
TEST(AVCDecoderConfigurationTest, FailsOnInvalidNaluLengthSize) {
TEST(AVCDecoderConfigurationRecordTest, FailsOnInvalidNaluLengthSize) {
const uint8_t kAvcDecoderConfigurationData[] = {
0x01, 0x64, 0x00, 0x1E, 0xFE, 0xE1, 0x00, 0x1D, 0x67, 0x64, 0x00, 0x1E,
0xAC, 0xD9, 0x40, 0xB4, 0x2F, 0xF9, 0x7F, 0xF0, 0x00, 0x80, 0x00, 0x91,
0x00, 0x00, 0x03, 0x03, 0xE9, 0x00, 0x00, 0xEA, 0x60, 0x0F, 0x16, 0x2D,
0x96, 0x01, 0x00, 0x06, 0x68, 0xEB, 0xE3, 0xCB, 0x22, 0xC0};
AVCDecoderConfiguration avc_config;
AVCDecoderConfigurationRecord avc_config;
ASSERT_FALSE(avc_config.Parse(kAvcDecoderConfigurationData,
arraysize(kAvcDecoderConfigurationData)));
}
TEST(AVCDecoderConfigurationTest, FailOnInsufficientData) {
TEST(AVCDecoderConfigurationRecordTest, FailOnInsufficientData) {
const uint8_t kAvcDecoderConfigurationData[] = {0x01, 0x64, 0x00, 0x1E};
AVCDecoderConfiguration avc_config;
AVCDecoderConfigurationRecord avc_config;
ASSERT_FALSE(avc_config.Parse(kAvcDecoderConfigurationData,
arraysize(kAvcDecoderConfigurationData)));
}
TEST(AVCDecoderConfigurationTest, GetCodecString) {
TEST(AVCDecoderConfigurationRecordTest, GetCodecString) {
EXPECT_EQ("avc1.123456",
AVCDecoderConfiguration::GetCodecString(0x12, 0x34, 0x56));
AVCDecoderConfigurationRecord::GetCodecString(0x12, 0x34, 0x56));
}
} // namespace media

View File

@ -4,21 +4,22 @@
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd
#include "packager/media/filters/decoder_configuration.h"
#include "packager/media/filters/decoder_configuration_record.h"
namespace shaka {
namespace media {
DecoderConfiguration::DecoderConfiguration() : nalu_length_size_(0) {}
DecoderConfiguration::~DecoderConfiguration() {}
DecoderConfigurationRecord::DecoderConfigurationRecord()
: nalu_length_size_(0) {}
DecoderConfigurationRecord::~DecoderConfigurationRecord() {}
bool DecoderConfiguration::Parse(const uint8_t* data, size_t data_size) {
bool DecoderConfigurationRecord::Parse(const uint8_t* data, size_t data_size) {
data_.assign(data, data + data_size);
nalu_.clear();
return ParseInternal();
}
void DecoderConfiguration::AddNalu(const Nalu& nalu) {
void DecoderConfigurationRecord::AddNalu(const Nalu& nalu) {
nalu_.push_back(nalu);
}

View File

@ -4,8 +4,8 @@
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd
#ifndef MEDIA_FILTERS_DECODER_CONFIGURATION_H_
#define MEDIA_FILTERS_DECODER_CONFIGURATION_H_
#ifndef MEDIA_FILTERS_DECODER_CONFIGURATION_RECORD_H_
#define MEDIA_FILTERS_DECODER_CONFIGURATION_RECORD_H_
#include <vector>
@ -16,19 +16,19 @@
namespace shaka {
namespace media {
// Defines a base class for decoder configurations.
class DecoderConfiguration {
// Defines a base class for decoder configuration record.
class DecoderConfigurationRecord {
public:
virtual ~DecoderConfiguration();
virtual ~DecoderConfigurationRecord();
/// Parses input to extract decoder configuration data. This will make and
/// Parses input to extract decoder configuration record. This will make and
/// store a copy of the data for Nalu access.
/// @return false if there are parsing errors.
bool Parse(const std::vector<uint8_t>& data) {
return Parse(data.data(), data.size());
}
/// Parses input to extract decoder configuration data. This will make and
/// Parses input to extract decoder configuration record. This will make and
/// store a copy of the data for Nalu access.
/// @return false if there are parsing errors.
bool Parse(const uint8_t* data, size_t data_size);
@ -44,7 +44,7 @@ class DecoderConfiguration {
const Nalu& nalu(size_t i) const { return nalu_[i]; }
protected:
DecoderConfiguration();
DecoderConfigurationRecord();
/// Adds the given Nalu to the configuration.
void AddNalu(const Nalu& nalu);
@ -71,10 +71,10 @@ class DecoderConfiguration {
std::vector<Nalu> nalu_;
uint8_t nalu_length_size_;
DISALLOW_COPY_AND_ASSIGN(DecoderConfiguration);
DISALLOW_COPY_AND_ASSIGN(DecoderConfigurationRecord);
};
} // namespace media
} // namespace shaka
#endif // MEDIA_FILTERS_DECODER_CONFIGURATION_H_
#endif // MEDIA_FILTERS_DECODER_CONFIGURATION_RECORD_H_

View File

@ -13,10 +13,10 @@
'target_name': 'filters',
'type': '<(component)',
'sources': [
'avc_decoder_configuration.cc',
'avc_decoder_configuration.h',
'decoder_configuration.cc',
'decoder_configuration.h',
'avc_decoder_configuration_record.cc',
'avc_decoder_configuration_record.h',
'decoder_configuration_record.cc',
'decoder_configuration_record.h',
'ec3_audio_util.cc',
'ec3_audio_util.h',
'h264_byte_to_unit_stream_converter.cc',
@ -31,14 +31,14 @@
'h26x_bit_reader.h',
'h26x_byte_to_unit_stream_converter.cc',
'h26x_byte_to_unit_stream_converter.h',
'hevc_decoder_configuration.cc',
'hevc_decoder_configuration.h',
'hevc_decoder_configuration_record.cc',
'hevc_decoder_configuration_record.h',
'nal_unit_to_byte_stream_converter.cc',
'nal_unit_to_byte_stream_converter.h',
'nalu_reader.cc',
'nalu_reader.h',
'vp_codec_configuration.cc',
'vp_codec_configuration.h',
'vp_codec_configuration_record.cc',
'vp_codec_configuration_record.h',
'vp8_parser.cc',
'vp8_parser.h',
'vp9_parser.cc',
@ -53,17 +53,17 @@
'target_name': 'filters_unittest',
'type': '<(gtest_target_type)',
'sources': [
'avc_decoder_configuration_unittest.cc',
'avc_decoder_configuration_record_unittest.cc',
'ec3_audio_util_unittest.cc',
'h264_byte_to_unit_stream_converter_unittest.cc',
'h264_parser_unittest.cc',
'h265_byte_to_unit_stream_converter_unittest.cc',
'h265_parser_unittest.cc',
'h26x_bit_reader_unittest.cc',
'hevc_decoder_configuration_unittest.cc',
'hevc_decoder_configuration_record_unittest.cc',
'nal_unit_to_byte_stream_converter_unittest.cc',
'nalu_reader_unittest.cc',
'vp_codec_configuration_unittest.cc',
'vp_codec_configuration_record_unittest.cc',
'vp8_parser_unittest.cc',
'vp9_parser_unittest.cc',
],

View File

@ -9,7 +9,7 @@
#include "packager/base/strings/string_number_conversions.h"
#include "packager/media/filters/h265_byte_to_unit_stream_converter.h"
#include "packager/media/filters/hevc_decoder_configuration.h"
#include "packager/media/filters/hevc_decoder_configuration_record.h"
#include "packager/media/test/test_data_util.h"
namespace {
@ -47,13 +47,13 @@ TEST(H265ByteToUnitStreamConverter, ConversionSuccess) {
EXPECT_EQ(expected_decoder_config, decoder_config);
// Double-check that it can be parsed.
HEVCDecoderConfiguration conf;
ASSERT_TRUE(conf.Parse(decoder_config));
HEVCDecoderConfigurationRecord config;
ASSERT_TRUE(config.Parse(decoder_config));
// The order is SPS, PPS, VPS.
ASSERT_EQ(3u, conf.nalu_count());
EXPECT_EQ(Nalu::H265_SPS, conf.nalu(0).type());
EXPECT_EQ(Nalu::H265_PPS, conf.nalu(1).type());
EXPECT_EQ(Nalu::H265_VPS, conf.nalu(2).type());
ASSERT_EQ(3u, config.nalu_count());
EXPECT_EQ(Nalu::H265_SPS, config.nalu(0).type());
EXPECT_EQ(Nalu::H265_PPS, config.nalu(1).type());
EXPECT_EQ(Nalu::H265_VPS, config.nalu(2).type());
}
TEST(H265ByteToUnitStreamConverter, ConversionFailure) {

View File

@ -4,7 +4,7 @@
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd
#include "packager/media/filters/hevc_decoder_configuration.h"
#include "packager/media/filters/hevc_decoder_configuration_record.h"
#include "packager/base/strings/string_number_conversions.h"
#include "packager/base/strings/string_util.h"
@ -73,7 +73,7 @@ std::string CodecAsString(VideoCodec codec) {
} // namespace
HEVCDecoderConfiguration::HEVCDecoderConfiguration()
HEVCDecoderConfigurationRecord::HEVCDecoderConfigurationRecord()
: version_(0),
general_profile_space_(0),
general_tier_flag_(false),
@ -81,9 +81,9 @@ HEVCDecoderConfiguration::HEVCDecoderConfiguration()
general_profile_compatibility_flags_(0),
general_level_idc_(0) {}
HEVCDecoderConfiguration::~HEVCDecoderConfiguration() {}
HEVCDecoderConfigurationRecord::~HEVCDecoderConfigurationRecord() {}
bool HEVCDecoderConfiguration::ParseInternal() {
bool HEVCDecoderConfigurationRecord::ParseInternal() {
BufferReader reader(data(), data_size());
uint8_t profile_indication = 0;
@ -132,7 +132,8 @@ bool HEVCDecoderConfiguration::ParseInternal() {
return true;
}
std::string HEVCDecoderConfiguration::GetCodecString(VideoCodec codec) const {
std::string HEVCDecoderConfigurationRecord::GetCodecString(
VideoCodec codec) const {
// ISO/IEC 14496-15:2014 Annex E.
std::vector<std::string> fields;
fields.push_back(CodecAsString(codec));

View File

@ -4,8 +4,8 @@
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd
#ifndef MEDIA_FILTERS_HEVC_DECODER_CONFIGURATION_H_
#define MEDIA_FILTERS_HEVC_DECODER_CONFIGURATION_H_
#ifndef MEDIA_FILTERS_HEVC_DECODER_CONFIGURATION_RECORD_H_
#define MEDIA_FILTERS_HEVC_DECODER_CONFIGURATION_RECORD_H_
#include <stdint.h>
#include <string>
@ -13,16 +13,16 @@
#include "packager/base/macros.h"
#include "packager/media/base/video_stream_info.h"
#include "packager/media/filters/decoder_configuration.h"
#include "packager/media/filters/decoder_configuration_record.h"
namespace shaka {
namespace media {
/// Class for parsing HEVC decoder configuration.
class HEVCDecoderConfiguration : public DecoderConfiguration {
/// Class for parsing HEVC decoder configuration record.
class HEVCDecoderConfigurationRecord : public DecoderConfigurationRecord {
public:
HEVCDecoderConfiguration();
~HEVCDecoderConfiguration() override;
HEVCDecoderConfigurationRecord();
~HEVCDecoderConfigurationRecord() override;
/// @return The codec string.
std::string GetCodecString(VideoCodec codec) const;
@ -38,10 +38,10 @@ class HEVCDecoderConfiguration : public DecoderConfiguration {
std::vector<uint8_t> general_constraint_indicator_flags_;
uint8_t general_level_idc_;
DISALLOW_COPY_AND_ASSIGN(HEVCDecoderConfiguration);
DISALLOW_COPY_AND_ASSIGN(HEVCDecoderConfigurationRecord);
};
} // namespace media
} // namespace shaka
#endif // MEDIA_FILTERS_HEVC_DECODER_CONFIGURATION_H_
#endif // MEDIA_FILTERS_HEVC_DECODER_CONFIGURATION_RECORD_H_

View File

@ -4,14 +4,14 @@
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd
#include "packager/media/filters/hevc_decoder_configuration.h"
#include "packager/media/filters/hevc_decoder_configuration_record.h"
#include <gtest/gtest.h>
namespace shaka {
namespace media {
TEST(HEVCDecoderConfigurationTest, Success) {
TEST(HEVCDecoderConfigurationRecordTest, Success) {
const uint8_t kHevcDecoderConfigurationData[] = {
0x01, // Version
0x02, // profile_indication
@ -39,7 +39,7 @@ TEST(HEVCDecoderConfigurationTest, Success) {
0x00, 0x00, 0x03, 0x00, 0x00,
};
HEVCDecoderConfiguration hevc_config;
HEVCDecoderConfigurationRecord hevc_config;
ASSERT_TRUE(hevc_config.Parse(kHevcDecoderConfigurationData,
arraysize(kHevcDecoderConfigurationData)));
@ -53,10 +53,10 @@ TEST(HEVCDecoderConfigurationTest, Success) {
EXPECT_EQ(0x40, hevc_config.nalu(0).data()[0]);
}
TEST(HEVCDecoderConfigurationTest, FailOnInsufficientData) {
TEST(HEVCDecoderConfigurationRecordTest, FailOnInsufficientData) {
const uint8_t kHevcDecoderConfigurationData[] = {0x01, 0x02, 0x20, 0x00};
HEVCDecoderConfiguration hevc_config;
HEVCDecoderConfigurationRecord hevc_config;
ASSERT_FALSE(hevc_config.Parse(kHevcDecoderConfigurationData,
arraysize(kHevcDecoderConfigurationData)));
}

View File

@ -13,7 +13,7 @@
#include "packager/media/base/buffer_reader.h"
#include "packager/media/base/buffer_writer.h"
#include "packager/media/base/macros.h"
#include "packager/media/filters/avc_decoder_configuration.h"
#include "packager/media/filters/avc_decoder_configuration_record.h"
#include "packager/media/filters/nalu_reader.h"
namespace shaka {
@ -99,7 +99,7 @@ bool NalUnitToByteStreamConverter::Initialize(
return false;
}
AVCDecoderConfiguration decoder_config;
AVCDecoderConfigurationRecord decoder_config;
if (!decoder_config.Parse(std::vector<uint8_t>(
decoder_configuration_data,
decoder_configuration_data + decoder_configuration_data_size))) {

View File

@ -153,11 +153,11 @@ bool VP8Parser::Parse(const uint8_t* data,
// http://tools.ietf.org/html/rfc6386 Section 2.
writable_codec_config()->set_bit_depth(8);
writable_codec_config()->set_chroma_subsampling(
VPCodecConfiguration::CHROMA_420_COLLOCATED_WITH_LUMA);
VPCodecConfigurationRecord::CHROMA_420_COLLOCATED_WITH_LUMA);
// VP8 uses YCrCb color space defined in ITU-R_BT.601.
// http://tools.ietf.org/html/rfc6386 Section 9.2.
writable_codec_config()->set_color_space(
VPCodecConfiguration::COLOR_SPACE_BT_601);
VPCodecConfigurationRecord::COLOR_SPACE_BT_601);
VPxFrameInfo vpx_frame;
vpx_frame.frame_size = data_size;

View File

@ -140,7 +140,7 @@ bool ParseIfSuperframeIndex(const uint8_t* data,
return true;
}
bool ReadProfile(BitReader* reader, VPCodecConfiguration* codec_config) {
bool ReadProfile(BitReader* reader, VPCodecConfigurationRecord* codec_config) {
uint8_t bit[2];
RCHECK(reader->ReadBits(1, &bit[0]));
RCHECK(reader->ReadBits(1, &bit[1]));
@ -160,54 +160,55 @@ bool ReadSyncCode(BitReader* reader) {
return sync_code == VP9_SYNC_CODE;
}
VPCodecConfiguration::ColorSpace GetColorSpace(uint8_t color_space) {
VPCodecConfigurationRecord::ColorSpace GetColorSpace(uint8_t color_space) {
switch (color_space) {
case VPX_COLOR_SPACE_UNKNOWN:
return VPCodecConfiguration::COLOR_SPACE_UNSPECIFIED;
return VPCodecConfigurationRecord::COLOR_SPACE_UNSPECIFIED;
case VPX_COLOR_SPACE_BT_601:
return VPCodecConfiguration::COLOR_SPACE_BT_601;
return VPCodecConfigurationRecord::COLOR_SPACE_BT_601;
case VPX_COLOR_SPACE_BT_709:
return VPCodecConfiguration::COLOR_SPACE_BT_709;
return VPCodecConfigurationRecord::COLOR_SPACE_BT_709;
case VPX_COLOR_SPACE_SMPTE_170:
return VPCodecConfiguration::COLOR_SPACE_SMPTE_170;
return VPCodecConfigurationRecord::COLOR_SPACE_SMPTE_170;
case VPX_COLOR_SPACE_SMPTE_240:
return VPCodecConfiguration::COLOR_SPACE_SMPTE_240;
return VPCodecConfigurationRecord::COLOR_SPACE_SMPTE_240;
case VPX_COLOR_SPACE_BT_2020:
// VP9 does not specify if it is in the form of “constant luminance” or
// “non-constant luminance”. As such, application should rely on the
// signaling outside of VP9 bitstream. If there is no such signaling,
// application may assume non-constant luminance for BT.2020.
return VPCodecConfiguration::COLOR_SPACE_BT_2020_NON_CONSTANT_LUMINANCE;
return VPCodecConfigurationRecord::
COLOR_SPACE_BT_2020_NON_CONSTANT_LUMINANCE;
case VPX_COLOR_SPACE_SRGB:
return VPCodecConfiguration::COLOR_SPACE_SRGB;
return VPCodecConfigurationRecord::COLOR_SPACE_SRGB;
default:
LOG(WARNING) << "Unknown color space: " << static_cast<int>(color_space);
return VPCodecConfiguration::COLOR_SPACE_UNSPECIFIED;
return VPCodecConfigurationRecord::COLOR_SPACE_UNSPECIFIED;
}
}
VPCodecConfiguration::ChromaSubsampling GetChromaSubsampling(
VPCodecConfigurationRecord::ChromaSubsampling GetChromaSubsampling(
uint8_t subsampling) {
switch (subsampling) {
case 0:
return VPCodecConfiguration::CHROMA_444;
return VPCodecConfigurationRecord::CHROMA_444;
case 1:
return VPCodecConfiguration::CHROMA_440;
return VPCodecConfigurationRecord::CHROMA_440;
case 2:
return VPCodecConfiguration::CHROMA_422;
return VPCodecConfigurationRecord::CHROMA_422;
case 3:
// VP9 assumes that chrome samples are collocated with luma samples if
// there is no explicit signaling outside of VP9 bitstream.
return VPCodecConfiguration::CHROMA_420_COLLOCATED_WITH_LUMA;
return VPCodecConfigurationRecord::CHROMA_420_COLLOCATED_WITH_LUMA;
default:
LOG(WARNING) << "Unexpected chroma subsampling value: "
<< static_cast<int>(subsampling);
return VPCodecConfiguration::CHROMA_420_COLLOCATED_WITH_LUMA;
return VPCodecConfigurationRecord::CHROMA_420_COLLOCATED_WITH_LUMA;
}
}
bool ReadBitDepthAndColorSpace(BitReader* reader,
VPCodecConfiguration* codec_config) {
VPCodecConfigurationRecord* codec_config) {
uint8_t bit_depth = 8;
if (codec_config->profile() >= 2) {
bool use_vpx_bits_12;
@ -221,7 +222,7 @@ bool ReadBitDepthAndColorSpace(BitReader* reader,
codec_config->set_color_space(GetColorSpace(color_space));
bool yuv_full_range = false;
auto chroma_subsampling = VPCodecConfiguration::CHROMA_444;
auto chroma_subsampling = VPCodecConfigurationRecord::CHROMA_444;
if (color_space != VPX_COLOR_SPACE_SRGB) {
RCHECK(reader->ReadBits(1, &yuv_full_range));
@ -230,7 +231,7 @@ bool ReadBitDepthAndColorSpace(BitReader* reader,
RCHECK(reader->ReadBits(2, &subsampling));
chroma_subsampling = GetChromaSubsampling(subsampling);
if (chroma_subsampling ==
VPCodecConfiguration::CHROMA_420_COLLOCATED_WITH_LUMA) {
VPCodecConfigurationRecord::CHROMA_420_COLLOCATED_WITH_LUMA) {
LOG(ERROR) << "4:2:0 color not supported in profile "
<< codec_config->profile();
return false;
@ -241,11 +242,11 @@ bool ReadBitDepthAndColorSpace(BitReader* reader,
RCHECK(!reserved);
} else {
chroma_subsampling =
VPCodecConfiguration::CHROMA_420_COLLOCATED_WITH_LUMA;
VPCodecConfigurationRecord::CHROMA_420_COLLOCATED_WITH_LUMA;
}
} else {
// Assume 4:4:4 for colorspace SRGB.
chroma_subsampling = VPCodecConfiguration::CHROMA_444;
chroma_subsampling = VPCodecConfigurationRecord::CHROMA_444;
if (codec_config->profile() & 1) {
bool reserved;
RCHECK(reader->ReadBits(1, &reserved));
@ -474,7 +475,7 @@ bool VP9Parser::Parse(const uint8_t* data,
// profile 0. VP9 specifies that the default color format should be
// YUV 4:2:0 in this case (normative).
writable_codec_config()->set_chroma_subsampling(
VPCodecConfiguration::CHROMA_420_COLLOCATED_WITH_LUMA);
VPCodecConfigurationRecord::CHROMA_420_COLLOCATED_WITH_LUMA);
writable_codec_config()->set_bit_depth(8);
}
@ -537,7 +538,7 @@ bool VP9Parser::IsKeyframe(const uint8_t* data, size_t data_size) {
RCHECK(reader.ReadBits(2, &frame_marker));
RCHECK(frame_marker == VP9_FRAME_MARKER);
VPCodecConfiguration codec_config;
VPCodecConfigurationRecord codec_config;
RCHECK(ReadProfile(&reader, &codec_config));
bool show_existing_frame;

View File

@ -4,7 +4,7 @@
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd
#include "packager/media/filters/vp_codec_configuration.h"
#include "packager/media/filters/vp_codec_configuration_record.h"
#include "packager/base/strings/string_number_conversions.h"
#include "packager/base/strings/string_util.h"
@ -33,7 +33,7 @@ std::string VPCodecAsString(VideoCodec codec) {
} // namespace
VPCodecConfiguration::VPCodecConfiguration()
VPCodecConfigurationRecord::VPCodecConfigurationRecord()
: profile_(0),
level_(0),
bit_depth_(0),
@ -42,7 +42,7 @@ VPCodecConfiguration::VPCodecConfiguration()
transfer_function_(0),
video_full_range_flag_(false) {}
VPCodecConfiguration::VPCodecConfiguration(
VPCodecConfigurationRecord::VPCodecConfigurationRecord(
uint8_t profile,
uint8_t level,
uint8_t bit_depth,
@ -60,9 +60,9 @@ VPCodecConfiguration::VPCodecConfiguration(
video_full_range_flag_(video_full_range_flag),
codec_initialization_data_(codec_initialization_data) {}
VPCodecConfiguration::~VPCodecConfiguration(){};
VPCodecConfigurationRecord::~VPCodecConfigurationRecord(){};
bool VPCodecConfiguration::Parse(const std::vector<uint8_t>& data) {
bool VPCodecConfigurationRecord::Parse(const std::vector<uint8_t>& data) {
BitReader reader(data.data(), data.size());
RCHECK(reader.ReadBits(8, &profile_));
RCHECK(reader.ReadBits(8, &level_));
@ -81,7 +81,7 @@ bool VPCodecConfiguration::Parse(const std::vector<uint8_t>& data) {
return true;
}
void VPCodecConfiguration::Write(std::vector<uint8_t>* data) const {
void VPCodecConfigurationRecord::Write(std::vector<uint8_t>* data) const {
BufferWriter writer;
writer.AppendInt(profile_);
writer.AppendInt(level_);
@ -96,7 +96,7 @@ void VPCodecConfiguration::Write(std::vector<uint8_t>* data) const {
writer.SwapBuffer(data);
}
std::string VPCodecConfiguration::GetCodecString(VideoCodec codec) const {
std::string VPCodecConfigurationRecord::GetCodecString(VideoCodec codec) const {
const std::string fields[] = {
base::IntToString(profile_),
base::IntToString(level_),

View File

@ -4,8 +4,8 @@
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd
#ifndef MEDIA_FILTERS_VP_CODEC_CONFIGURATION_H_
#define MEDIA_FILTERS_VP_CODEC_CONFIGURATION_H_
#ifndef MEDIA_FILTERS_VP_CODEC_CONFIGURATION_RECORD_H_
#define MEDIA_FILTERS_VP_CODEC_CONFIGURATION_RECORD_H_
#include <stdint.h>
#include <string>
@ -17,8 +17,8 @@
namespace shaka {
namespace media {
/// Class for parsing or writing VP codec configuration data.
class VPCodecConfiguration {
/// Class for parsing or writing VP codec configuration record.
class VPCodecConfigurationRecord {
public:
enum ColorSpace {
COLOR_SPACE_UNSPECIFIED = 0,
@ -39,8 +39,9 @@ class VPCodecConfiguration {
CHROMA_440 = 4,
};
VPCodecConfiguration();
VPCodecConfiguration(uint8_t profile,
VPCodecConfigurationRecord();
VPCodecConfigurationRecord(
uint8_t profile,
uint8_t level,
uint8_t bit_depth,
uint8_t color_space,
@ -48,14 +49,14 @@ class VPCodecConfiguration {
uint8_t transfer_function,
bool video_full_range_flag,
const std::vector<uint8_t>& codec_initialization_data);
~VPCodecConfiguration();
~VPCodecConfigurationRecord();
/// Parses input to extract VP codec configuration data.
/// Parses input to extract VP codec configuration record.
/// @return false if there is parsing errors.
bool Parse(const std::vector<uint8_t>& data);
/// @param data should not be null.
/// Writes VP codec configuration data to buffer.
/// Writes VP codec configuration record to buffer.
void Write(std::vector<uint8_t>* data) const;
/// @return The codec string.
@ -101,4 +102,4 @@ class VPCodecConfiguration {
} // namespace media
} // namespace shaka
#endif // MEDIA_FILTERS_VP_CODEC_CONFIGURATION_H_
#endif // MEDIA_FILTERS_VP_CODEC_CONFIGURATION_RECORD_H_

View File

@ -4,19 +4,19 @@
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd
#include "packager/media/filters/vp_codec_configuration.h"
#include "packager/media/filters/vp_codec_configuration_record.h"
#include <gtest/gtest.h>
namespace shaka {
namespace media {
TEST(VPCodecConfigurationTest, Parse) {
TEST(VPCodecConfigurationRecordTest, Parse) {
const uint8_t kVpCodecConfigurationData[] = {
0x01, 0x00, 0xA2, 0x14, 0x00, 0x01, 0x00,
};
VPCodecConfiguration vp_config;
VPCodecConfigurationRecord vp_config;
ASSERT_TRUE(vp_config.Parse(std::vector<uint8_t>(
kVpCodecConfigurationData,
kVpCodecConfigurationData + arraysize(kVpCodecConfigurationData))));
@ -32,22 +32,22 @@ TEST(VPCodecConfigurationTest, Parse) {
EXPECT_EQ("vp09.01.00.10.02.01.02.00", vp_config.GetCodecString(kCodecVP9));
}
TEST(VPCodecConfigurationTest, ParseWithInsufficientData) {
TEST(VPCodecConfigurationRecordTest, ParseWithInsufficientData) {
const uint8_t kVpCodecConfigurationData[] = {
0x01, 0x00, 0xA2, 0x14,
};
VPCodecConfiguration vp_config;
VPCodecConfigurationRecord vp_config;
ASSERT_FALSE(vp_config.Parse(std::vector<uint8_t>(
kVpCodecConfigurationData,
kVpCodecConfigurationData + arraysize(kVpCodecConfigurationData))));
}
TEST(VPCodecConfigurationTest, Write) {
TEST(VPCodecConfigurationRecordTest, Write) {
const uint8_t kExpectedVpCodecConfigurationData[] = {
0x02, 0x01, 0x80, 0x21, 0x00, 0x00,
};
VPCodecConfiguration vp_config(0x02, 0x01, 0x08, 0x00, 0x02, 0x00, true,
VPCodecConfigurationRecord vp_config(0x02, 0x01, 0x08, 0x00, 0x02, 0x00, true,
std::vector<uint8_t>());
std::vector<uint8_t> data;
vp_config.Write(&data);

View File

@ -11,7 +11,7 @@
#include <stdlib.h>
#include "packager/base/macros.h"
#include "packager/media/filters/vp_codec_configuration.h"
#include "packager/media/filters/vp_codec_configuration_record.h"
namespace shaka {
namespace media {
@ -41,13 +41,15 @@ class VPxParser {
/// @return VPx codec configuration extracted. Note that it is only valid
/// after parsing a keyframe or intra frame successfully.
const VPCodecConfiguration& codec_config() const { return codec_config_; }
const VPCodecConfigurationRecord& codec_config() const {
return codec_config_;
}
protected:
VPCodecConfiguration* writable_codec_config() { return &codec_config_; }
VPCodecConfigurationRecord* writable_codec_config() { return &codec_config_; }
private:
VPCodecConfiguration codec_config_;
VPCodecConfigurationRecord codec_config_;
DISALLOW_COPY_AND_ASSIGN(VPxParser);
};

View File

@ -10,7 +10,7 @@
#include "packager/media/base/media_sample.h"
#include "packager/media/base/timestamp.h"
#include "packager/media/base/video_stream_info.h"
#include "packager/media/filters/avc_decoder_configuration.h"
#include "packager/media/filters/avc_decoder_configuration_record.h"
#include "packager/media/filters/h264_byte_to_unit_stream_converter.h"
#include "packager/media/filters/h264_parser.h"
#include "packager/media/formats/mp2t/mp2t_common.h"
@ -143,25 +143,14 @@ bool EsParserH264::UpdateVideoDecoderConfig(int pps_id) {
return false;
}
last_video_decoder_config_ = scoped_refptr<StreamInfo>(
new VideoStreamInfo(
pid(),
kMpeg2Timescale,
kInfiniteDuration,
kCodecH264,
AVCDecoderConfiguration::GetCodecString(decoder_config_record[1],
last_video_decoder_config_ = scoped_refptr<StreamInfo>(new VideoStreamInfo(
pid(), kMpeg2Timescale, kInfiniteDuration, kCodecH264,
AVCDecoderConfigurationRecord::GetCodecString(decoder_config_record[1],
decoder_config_record[2],
decoder_config_record[3]),
std::string(),
coded_width,
coded_height,
pixel_width,
pixel_height,
0,
std::string(), coded_width, coded_height, pixel_width, pixel_height, 0,
H264ByteToUnitStreamConverter::kUnitStreamNaluLengthSize,
decoder_config_record.data(),
decoder_config_record.size(),
false));
decoder_config_record.data(), decoder_config_record.size(), false));
DVLOG(1) << "Profile IDC: " << sps->profile_idc;
DVLOG(1) << "Level IDC: " << sps->level_idc;
DVLOG(1) << "log2_max_frame_num_minus4: " << sps->log2_max_frame_num_minus4;

View File

@ -13,7 +13,7 @@
#include "packager/media/base/offset_byte_queue.h"
#include "packager/media/base/timestamp.h"
#include "packager/media/base/video_stream_info.h"
#include "packager/media/filters/hevc_decoder_configuration.h"
#include "packager/media/filters/hevc_decoder_configuration_record.h"
#include "packager/media/filters/h265_byte_to_unit_stream_converter.h"
#include "packager/media/filters/h265_parser.h"
#include "packager/media/formats/mp2t/mp2t_common.h"
@ -117,7 +117,7 @@ bool EsParserH265::UpdateVideoDecoderConfig(int pps_id) {
}
std::vector<uint8_t> decoder_config_record;
HEVCDecoderConfiguration decoder_config;
HEVCDecoderConfigurationRecord decoder_config;
if (!stream_converter()->GetDecoderConfigurationRecord(
&decoder_config_record) ||
!decoder_config.Parse(decoder_config_record)) {

View File

@ -21,9 +21,9 @@
#include "packager/media/base/video_stream_info.h"
#include "packager/media/file/file.h"
#include "packager/media/file/file_closer.h"
#include "packager/media/filters/avc_decoder_configuration.h"
#include "packager/media/filters/hevc_decoder_configuration.h"
#include "packager/media/filters/vp_codec_configuration.h"
#include "packager/media/filters/avc_decoder_configuration_record.h"
#include "packager/media/filters/hevc_decoder_configuration_record.h"
#include "packager/media/filters/vp_codec_configuration_record.h"
#include "packager/media/formats/mp4/box_definitions.h"
#include "packager/media/formats/mp4/box_reader.h"
#include "packager/media/formats/mp4/es_descriptor.h"
@ -511,7 +511,7 @@ bool MP4MediaParser::ParseMoov(BoxReader* reader) {
const VideoCodec video_codec = FourCCToVideoCodec(actual_format);
switch (actual_format) {
case FOURCC_avc1: {
AVCDecoderConfiguration avc_config;
AVCDecoderConfigurationRecord avc_config;
if (!avc_config.Parse(entry.codec_configuration.data)) {
LOG(ERROR) << "Failed to parse avcc.";
return false;
@ -548,7 +548,7 @@ bool MP4MediaParser::ParseMoov(BoxReader* reader) {
}
case FOURCC_hev1:
case FOURCC_hvc1: {
HEVCDecoderConfiguration hevc_config;
HEVCDecoderConfigurationRecord hevc_config;
if (!hevc_config.Parse(entry.codec_configuration.data)) {
LOG(ERROR) << "Failed to parse hevc.";
return false;
@ -560,7 +560,7 @@ bool MP4MediaParser::ParseMoov(BoxReader* reader) {
case FOURCC_vp08:
case FOURCC_vp09:
case FOURCC_vp10: {
VPCodecConfiguration vp_config;
VPCodecConfigurationRecord vp_config;
if (!vp_config.Parse(entry.codec_configuration.data)) {
LOG(ERROR) << "Failed to parse vpcc.";
return false;

View File

@ -7,8 +7,8 @@
#include "packager/media/formats/mp4/video_slice_header_parser.h"
#include "packager/media/base/rcheck.h"
#include "packager/media/filters/avc_decoder_configuration.h"
#include "packager/media/filters/hevc_decoder_configuration.h"
#include "packager/media/filters/avc_decoder_configuration_record.h"
#include "packager/media/filters/hevc_decoder_configuration_record.h"
namespace shaka {
namespace media {
@ -29,7 +29,7 @@ H264VideoSliceHeaderParser::~H264VideoSliceHeaderParser() {}
bool H264VideoSliceHeaderParser::Initialize(
const std::vector<uint8_t>& decoder_configuration) {
AVCDecoderConfiguration config;
AVCDecoderConfigurationRecord config;
RCHECK(config.Parse(decoder_configuration));
for (size_t i = 0; i < config.nalu_count(); i++) {
@ -61,7 +61,7 @@ H265VideoSliceHeaderParser::~H265VideoSliceHeaderParser() {}
bool H265VideoSliceHeaderParser::Initialize(
const std::vector<uint8_t>& decoder_configuration) {
int id;
HEVCDecoderConfiguration hevc_config;
HEVCDecoderConfigurationRecord hevc_config;
RCHECK(hevc_config.Parse(decoder_configuration));
for (size_t i = 0; i < hevc_config.nalu_count(); i++) {

View File

@ -456,7 +456,8 @@ bool WebMClusterParser::OnBlock(bool is_simple_block,
return false;
}
const VPCodecConfiguration* codec_config = &vpx_parser->codec_config();
const VPCodecConfigurationRecord* codec_config =
&vpx_parser->codec_config();
video_stream_info_->set_codec_string(
codec_config->GetCodecString(video_stream_info_->codec()));
std::vector<uint8_t> extra_data;

View File

@ -15,7 +15,7 @@
#include "packager/media/base/media_sample.h"
#include "packager/media/base/status.h"
#include "packager/media/base/video_stream_info.h"
#include "packager/media/filters/avc_decoder_configuration.h"
#include "packager/media/filters/avc_decoder_configuration_record.h"
#include "packager/media/formats/mp2t/adts_header.h"
#include "packager/media/formats/mp4/aac_audio_specific_config.h"
#include "packager/media/formats/mp4/es_descriptor.h"
@ -725,7 +725,7 @@ bool WvmMediaParser::ParseIndexEntry() {
case Audio_AC3SpecificData:
LOG(ERROR) << "Audio type not supported.";
return false;
case AVCDecoderConfigurationRecord:
case Video_AVCDecoderConfigurationRecord:
video_codec_config = binary_data;
break;
default:
@ -831,7 +831,7 @@ bool WvmMediaParser::Output(bool output_encrypted_sample) {
byte_to_unit_stream_converter_.GetDecoderConfigurationRecord(
&decoder_config_record);
for (uint32_t i = 0; i < stream_infos_.size(); i++) {
if (stream_infos_[i]->stream_type() == media::kStreamVideo &&
if (stream_infos_[i]->stream_type() == kStreamVideo &&
stream_infos_[i]->codec_string().empty()) {
const std::vector<uint8_t>* stream_config;
if (stream_infos_[i]->extra_data().empty()) {
@ -847,7 +847,7 @@ bool WvmMediaParser::Output(bool output_encrypted_sample) {
VideoStreamInfo* video_stream_info =
reinterpret_cast<VideoStreamInfo*>(stream_infos_[i].get());
AVCDecoderConfiguration avc_config;
AVCDecoderConfigurationRecord avc_config;
if (!avc_config.Parse(*stream_config)) {
LOG(WARNING) << "Failed to parse AVCDecoderConfigurationRecord. "
"Using computed configuration record instead.";
@ -894,9 +894,9 @@ bool WvmMediaParser::Output(bool output_encrypted_sample) {
} else if ((prev_pes_stream_id_ & kPesStreamIdAudioMask) ==
kPesStreamIdAudio) {
// Set data on the audio stream.
int frame_size = media::mp2t::AdtsHeader::GetAdtsFrameSize(
sample_data_.data(), kAdtsHeaderMinSize);
media::mp2t::AdtsHeader adts_header;
int frame_size = mp2t::AdtsHeader::GetAdtsFrameSize(sample_data_.data(),
kAdtsHeaderMinSize);
mp2t::AdtsHeader adts_header;
const uint8_t* frame_ptr = sample_data_.data();
if (!adts_header.Parse(frame_ptr, frame_size)) {
LOG(ERROR) << "Could not parse ADTS header";
@ -908,7 +908,7 @@ bool WvmMediaParser::Output(bool output_encrypted_sample) {
frame_size - header_size);
if (!is_initialized_) {
for (uint32_t i = 0; i < stream_infos_.size(); i++) {
if (stream_infos_[i]->stream_type() == media::kStreamAudio &&
if (stream_infos_[i]->stream_type() == kStreamAudio &&
stream_infos_[i]->codec_string().empty()) {
AudioStreamInfo* audio_stream_info =
reinterpret_cast<AudioStreamInfo*>(stream_infos_[i].get());

View File

@ -103,7 +103,7 @@ class WvmMediaParser : public MediaParser {
SparseDownloadMap = 36,
AudioSampleSize = 37,
Audio_EsDescriptor = 38,
AVCDecoderConfigurationRecord = 39,
Video_AVCDecoderConfigurationRecord = 39,
Audio_EC3SpecificData = 40,
AudioIdentifier = 41,
VideoStreamId = 42,