Fix parsing of VP9 level.
The VP9 level is contained in the CodecPrivate data. Change-Id: I65475363ee230b422a8cdce8172f6262cb3329e7
This commit is contained in:
parent
836591f4f5
commit
a1dc4f2f22
@ -116,8 +116,8 @@ bool CopyColour(const mkvparser::Colour& parser_colour,
|
||||
//
|
||||
// 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
||||
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
// | ID Byte | Length | |
|
||||
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
|
||||
// | ID Byte | Length | |
|
||||
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
|
||||
// | |
|
||||
// : Bytes 1..Length of Codec Feature :
|
||||
// | |
|
||||
@ -132,7 +132,7 @@ bool CopyColour(const mkvparser::Colour& parser_colour,
|
||||
//
|
||||
// The X bit is reserved.
|
||||
//
|
||||
// Currently only profile level is supported. ID byte must be set to 1, and
|
||||
// Currently only VP9 level is supported. ID byte must be set to 2, and
|
||||
// length must be 1. Supported values are:
|
||||
//
|
||||
// 10: Level 1
|
||||
@ -158,12 +158,13 @@ int ParseVpxCodecPrivate(const uint8_t* private_data, int32_t length) {
|
||||
return 0;
|
||||
|
||||
const uint8_t id_byte = *private_data;
|
||||
if (id_byte != 1)
|
||||
const uint8_t kVp9LevelId = 2;
|
||||
if (id_byte != kVp9LevelId)
|
||||
return 0;
|
||||
|
||||
const int kVpxProfileLength = 1;
|
||||
const int kVpxFeatureLength = 1;
|
||||
const uint8_t length_byte = private_data[1];
|
||||
if (length_byte != kVpxProfileLength)
|
||||
if (length_byte != kVpxFeatureLength)
|
||||
return 0;
|
||||
|
||||
const int level = static_cast<int>(private_data[2]);
|
||||
|
@ -43,7 +43,7 @@ bool ColourValuePresent(long long value);
|
||||
bool CopyColour(const mkvparser::Colour& parser_colour,
|
||||
mkvmuxer::Colour* muxer_colour);
|
||||
|
||||
// Returns VP9 profile upon success or 0 upon failure.
|
||||
// Returns VP9 level upon success or 0 upon failure.
|
||||
int ParseVpxCodecPrivate(const uint8_t* private_data, int32_t length);
|
||||
|
||||
} // namespace libwebm
|
||||
|
@ -672,15 +672,15 @@ TEST_F(ParserTest, Vp9CodecProfileTest) {
|
||||
EXPECT_EQ(0, libwebm::ParseVpxCodecPrivate(&bad_codec_private[0], 0));
|
||||
EXPECT_EQ(0, libwebm::ParseVpxCodecPrivate(&bad_codec_private[0],
|
||||
kCodecPrivateLength));
|
||||
const uint8_t good_codec_private[kCodecPrivateLength] = {1, 1, 11};
|
||||
const uint8_t good_codec_private_level[kCodecPrivateLength] = {2, 1, 11};
|
||||
|
||||
// Test parse of codec private chunks, but lie about length.
|
||||
EXPECT_EQ(0, libwebm::ParseVpxCodecPrivate(&bad_codec_private[0], 0));
|
||||
EXPECT_EQ(0, libwebm::ParseVpxCodecPrivate(&good_codec_private[0], 0));
|
||||
EXPECT_EQ(0, libwebm::ParseVpxCodecPrivate(&good_codec_private_level[0], 0));
|
||||
|
||||
// Test a valid codec private; this should return 11.
|
||||
// ID: 1, Length: 1, Profile: 11
|
||||
EXPECT_EQ(11, libwebm::ParseVpxCodecPrivate(&good_codec_private[0],
|
||||
// ID: 2, Length: 1, Profile: 11
|
||||
EXPECT_EQ(11, libwebm::ParseVpxCodecPrivate(&good_codec_private_level[0],
|
||||
kCodecPrivateLength));
|
||||
}
|
||||
|
||||
|
@ -373,10 +373,10 @@ bool OutputTracks(const mkvparser::Segment& segment, const Options& options,
|
||||
const std::string codec_id = track->GetCodecId();
|
||||
const std::string v_vp9 = "V_VP9";
|
||||
if (codec_id == v_vp9) {
|
||||
const int vp9_profile_level = libwebm::ParseVpxCodecPrivate(
|
||||
const int vp9_level = libwebm::ParseVpxCodecPrivate(
|
||||
private_data, static_cast<int32_t>(private_size));
|
||||
fprintf(o, "%sVP9 profile level: %d\n", indent->indent_str().c_str(),
|
||||
vp9_profile_level);
|
||||
fprintf(o, "%sVP9 level: %d\n", indent->indent_str().c_str(),
|
||||
vp9_level);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user