Fix order of VPS, SPS, PPS in hvcC box of HEVC/MP4 (#300)

Fix order of VPS, SPS, PPS in hvcC box of HEVC/MP4

Fixes #297
This commit is contained in:
l-law 2017-12-01 06:34:42 +08:00 committed by Kongqun Yang
parent cc778f60ab
commit 22c758ed06
4 changed files with 17 additions and 15 deletions

View File

@ -17,6 +17,7 @@ Anders Hasselqvist <anders.hasselqvist@gmail.com>
Chun-da Chen <capitalm.c@gmail.com> Chun-da Chen <capitalm.c@gmail.com>
Google Inc. <*@google.com> Google Inc. <*@google.com>
Leandro Moreira <leandro.ribeiro.moreira@gmail.com> Leandro Moreira <leandro.ribeiro.moreira@gmail.com>
Leo Law <leoltlaw.gh@gmail.com>
More Screens Ltd. <*@morescreens.net> More Screens Ltd. <*@morescreens.net>
Philo Inc. <*@philo.com> Philo Inc. <*@philo.com>
Richard Eklycke <richard@eklycke.se> Richard Eklycke <richard@eklycke.se>

View File

@ -32,6 +32,7 @@ Jacob Trimble <modmaker@google.com>
Joey Parrish <joeyparrish@google.com> Joey Parrish <joeyparrish@google.com>
Kongqun Yang <kqyang@google.com> Kongqun Yang <kqyang@google.com>
Leandro Moreira <leandro.ribeiro.moreira@gmail.com> Leandro Moreira <leandro.ribeiro.moreira@gmail.com>
Leo Law <leoltlaw.gh@gmail.com>
Richard Eklycke <richard@eklycke.se> Richard Eklycke <richard@eklycke.se>
Rintaro Kuroiwa <rkuroiwa@google.com> Rintaro Kuroiwa <rkuroiwa@google.com>
Sergio Ammirata <sergio@ammirata.net> Sergio Ammirata <sergio@ammirata.net>

View File

@ -73,8 +73,14 @@ bool H265ByteToUnitStreamConverter::GetDecoderConfigurationRecord(
buffer.AppendInt(static_cast<uint8_t>(kUnitStreamNaluLengthSize - 1)); buffer.AppendInt(static_cast<uint8_t>(kUnitStreamNaluLengthSize - 1));
buffer.AppendInt(static_cast<uint8_t>(3) /* numOfArrays */); buffer.AppendInt(static_cast<uint8_t>(3) /* numOfArrays */);
// SPS // VPS
const uint8_t kArrayCompleteness = 0x80; const uint8_t kArrayCompleteness = 0x80;
buffer.AppendInt(static_cast<uint8_t>(kArrayCompleteness | Nalu::H265_VPS));
buffer.AppendInt(static_cast<uint16_t>(1) /* numNalus */);
buffer.AppendInt(static_cast<uint16_t>(last_vps_.size()));
buffer.AppendVector(last_vps_);
// SPS
buffer.AppendInt(static_cast<uint8_t>(kArrayCompleteness | Nalu::H265_SPS)); buffer.AppendInt(static_cast<uint8_t>(kArrayCompleteness | Nalu::H265_SPS));
buffer.AppendInt(static_cast<uint16_t>(1) /* numNalus */); buffer.AppendInt(static_cast<uint16_t>(1) /* numNalus */);
buffer.AppendInt(static_cast<uint16_t>(last_sps_.size())); buffer.AppendInt(static_cast<uint16_t>(last_sps_.size()));
@ -86,12 +92,6 @@ bool H265ByteToUnitStreamConverter::GetDecoderConfigurationRecord(
buffer.AppendInt(static_cast<uint16_t>(last_pps_.size())); buffer.AppendInt(static_cast<uint16_t>(last_pps_.size()));
buffer.AppendVector(last_pps_); buffer.AppendVector(last_pps_);
// VPS
buffer.AppendInt(static_cast<uint8_t>(kArrayCompleteness | Nalu::H265_VPS));
buffer.AppendInt(static_cast<uint16_t>(1) /* numNalus */);
buffer.AppendInt(static_cast<uint16_t>(last_vps_.size()));
buffer.AppendVector(last_vps_);
buffer.SwapBuffer(decoder_config); buffer.SwapBuffer(decoder_config);
return true; return true;
} }

View File

@ -14,10 +14,10 @@
namespace { namespace {
const char kExpectedConfigRecord[] = const char kExpectedConfigRecord[] =
"01016000000300900000030000f000fcfdf8f800000303a10001002e42010101600000" "01016000000300900000030000f000fcfdf8f800000303a00001001840010c01ffff01"
"030090000003000003005da0028080241f265999a4932bffc0d5c0d640400000030040" "600000030090000003000003005d999809a10001002e42010101600000030090000003"
"00000602a2000100074401c172b46240a00001001840010c01ffff0160000003009000" "000003005da0028080241f265999a4932bffc0d5c0d64040000003004000000602a200"
"0003000003005d999809"; "0100074401c172b46240";
} }
namespace shaka { namespace shaka {
@ -50,11 +50,11 @@ TEST(H265ByteToUnitStreamConverter, StripParameterSetsNalu) {
// Double-check that it can be parsed. // Double-check that it can be parsed.
HEVCDecoderConfigurationRecord config; HEVCDecoderConfigurationRecord config;
ASSERT_TRUE(config.Parse(decoder_config)); ASSERT_TRUE(config.Parse(decoder_config));
// The order is SPS, PPS, VPS. // The order is VPS, SPS, PPS.
ASSERT_EQ(3u, config.nalu_count()); ASSERT_EQ(3u, config.nalu_count());
EXPECT_EQ(Nalu::H265_SPS, config.nalu(0).type()); EXPECT_EQ(Nalu::H265_VPS, config.nalu(0).type());
EXPECT_EQ(Nalu::H265_PPS, config.nalu(1).type()); EXPECT_EQ(Nalu::H265_SPS, config.nalu(1).type());
EXPECT_EQ(Nalu::H265_VPS, config.nalu(2).type()); EXPECT_EQ(Nalu::H265_PPS, config.nalu(2).type());
} }
TEST(H265ByteToUnitStreamConverter, KeepParameterSetsNalu) { TEST(H265ByteToUnitStreamConverter, KeepParameterSetsNalu) {