7 #include "packager/media/filters/avc_decoder_configuration.h"
9 #include "packager/base/strings/string_number_conversions.h"
10 #include "packager/base/strings/string_util.h"
11 #include "packager/media/base/buffer_reader.h"
12 #include "packager/media/filters/h264_parser.h"
13 #include "packager/media/formats/mp4/rcheck.h"
15 namespace edash_packager {
18 AVCDecoderConfiguration::AVCDecoderConfiguration()
20 profile_indication_(0),
21 profile_compatibility_(0),
24 AVCDecoderConfiguration::~AVCDecoderConfiguration() {}
26 bool AVCDecoderConfiguration::ParseInternal() {
30 RCHECK(reader.Read1(&version_) && version_ == 1 &&
31 reader.Read1(&profile_indication_) &&
32 reader.Read1(&profile_compatibility_) && reader.Read1(&avc_level_));
34 uint8_t length_size_minus_one;
35 RCHECK(reader.Read1(&length_size_minus_one));
36 if ((length_size_minus_one & 0x3) == 2) {
37 LOG(ERROR) <<
"Invalid NALU length size.";
43 RCHECK(reader.Read1(&num_sps));
46 LOG(ERROR) <<
"No SPS found.";
50 for (uint8_t i = 0; i < num_sps; i++) {
52 RCHECK(reader.Read2(&size));
53 const uint8_t* nalu_data = reader.data() + reader.pos();
54 RCHECK(reader.SkipBytes(size));
57 RCHECK(nalu.InitializeFromH264(nalu_data, size));
58 RCHECK(nalu.type() == Nalu::H264_SPS);
67 RCHECK(parser.ParseSps(nalu, &sps_id) == H264Parser::kOk);
68 RCHECK(ExtractResolutionFromSps(*parser.GetSps(sps_id), &coded_width_,
69 &coded_height_, &pixel_width_,
75 RCHECK(reader.Read1(&pps_count));
76 for (uint8_t i = 0; i < pps_count; i++) {
78 RCHECK(reader.Read2(&size));
79 const uint8_t* nalu_data = reader.data() + reader.pos();
80 RCHECK(reader.SkipBytes(size));
83 RCHECK(nalu.InitializeFromH264(nalu_data, size));
84 RCHECK(nalu.type() == Nalu::H264_PPS);
97 uint8_t profile_indication,
98 uint8_t profile_compatibility,
100 const uint8_t bytes[] = {profile_indication, profile_compatibility,
103 base::StringToLowerASCII(base::HexEncode(bytes, arraysize(bytes)));