Replace Nalu::InitializeFrom* with Initialize.

Replaces the InitializeFromH264 and InitializeFromH265 methods with
a single Initialize method that accepts a CodecType.  Also moves the
CodecType enum from NaluReader to Nalu.

Change-Id: Ie33aa9c0d772a7f3c6a2e9c867e25be3edfe7828
This commit is contained in:
Jacob Trimble 2016-04-21 13:35:49 -07:00
parent 77fc3f6988
commit a789dc6d3c
15 changed files with 67 additions and 63 deletions

View File

@ -54,7 +54,7 @@ bool AVCDecoderConfiguration::ParseInternal() {
RCHECK(reader.SkipBytes(size)); RCHECK(reader.SkipBytes(size));
Nalu nalu; Nalu nalu;
RCHECK(nalu.InitializeFromH264(nalu_data, size)); RCHECK(nalu.Initialize(Nalu::kH264, nalu_data, size));
RCHECK(nalu.type() == Nalu::H264_SPS); RCHECK(nalu.type() == Nalu::H264_SPS);
AddNalu(nalu); AddNalu(nalu);
@ -80,7 +80,7 @@ bool AVCDecoderConfiguration::ParseInternal() {
RCHECK(reader.SkipBytes(size)); RCHECK(reader.SkipBytes(size));
Nalu nalu; Nalu nalu;
RCHECK(nalu.InitializeFromH264(nalu_data, size)); RCHECK(nalu.Initialize(Nalu::kH264, nalu_data, size));
RCHECK(nalu.type() == Nalu::H264_PPS); RCHECK(nalu.type() == Nalu::H264_PPS);
AddNalu(nalu); AddNalu(nalu);
} }

View File

@ -16,7 +16,7 @@ namespace edash_packager {
namespace media { namespace media {
H264ByteToUnitStreamConverter::H264ByteToUnitStreamConverter() H264ByteToUnitStreamConverter::H264ByteToUnitStreamConverter()
: H26xByteToUnitStreamConverter(NaluReader::kH264) {} : H26xByteToUnitStreamConverter(Nalu::kH264) {}
H264ByteToUnitStreamConverter::~H264ByteToUnitStreamConverter() {} H264ByteToUnitStreamConverter::~H264ByteToUnitStreamConverter() {}
bool H264ByteToUnitStreamConverter::GetDecoderConfigurationRecord( bool H264ByteToUnitStreamConverter::GetDecoderConfigurationRecord(

View File

@ -18,7 +18,7 @@ TEST(H264ParserTest, StreamFileParsing) {
int num_nalus = 759; int num_nalus = 759;
H264Parser parser; H264Parser parser;
NaluReader reader(NaluReader::kH264, kIsAnnexbByteStream, buffer.data(), NaluReader reader(Nalu::kH264, kIsAnnexbByteStream, buffer.data(),
buffer.size()); buffer.size());
// Parse until the end of stream/unsupported stream/error in stream is found. // Parse until the end of stream/unsupported stream/error in stream is found.
@ -74,7 +74,7 @@ TEST(H264ParserTest, ExtractResolutionFromSpsData) {
H264Parser parser; H264Parser parser;
int sps_id = 0; int sps_id = 0;
Nalu nalu; Nalu nalu;
ASSERT_TRUE(nalu.InitializeFromH264(kSps, arraysize(kSps))); ASSERT_TRUE(nalu.Initialize(Nalu::kH264, kSps, arraysize(kSps)));
ASSERT_EQ(H264Parser::kOk, parser.ParseSps(nalu, &sps_id)); ASSERT_EQ(H264Parser::kOk, parser.ParseSps(nalu, &sps_id));
uint32_t coded_width = 0; uint32_t coded_width = 0;
@ -99,7 +99,7 @@ TEST(H264ParserTest, ExtractResolutionFromSpsDataWithCropping) {
H264Parser parser; H264Parser parser;
int sps_id = 0; int sps_id = 0;
Nalu nalu; Nalu nalu;
ASSERT_TRUE(nalu.InitializeFromH264(kSps, arraysize(kSps))); ASSERT_TRUE(nalu.Initialize(Nalu::kH264, kSps, arraysize(kSps)));
ASSERT_EQ(H264Parser::kOk, parser.ParseSps(nalu, &sps_id)); ASSERT_EQ(H264Parser::kOk, parser.ParseSps(nalu, &sps_id));
uint32_t coded_width = 0; uint32_t coded_width = 0;

View File

@ -17,7 +17,7 @@ namespace edash_packager {
namespace media { namespace media {
H265ByteToUnitStreamConverter::H265ByteToUnitStreamConverter() H265ByteToUnitStreamConverter::H265ByteToUnitStreamConverter()
: H26xByteToUnitStreamConverter(NaluReader::kH265) {} : H26xByteToUnitStreamConverter(Nalu::kH265) {}
H265ByteToUnitStreamConverter::~H265ByteToUnitStreamConverter() {} H265ByteToUnitStreamConverter::~H265ByteToUnitStreamConverter() {}
bool H265ByteToUnitStreamConverter::GetDecoderConfigurationRecord( bool H265ByteToUnitStreamConverter::GetDecoderConfigurationRecord(
@ -33,7 +33,7 @@ bool H265ByteToUnitStreamConverter::GetDecoderConfigurationRecord(
int id; int id;
Nalu nalu; Nalu nalu;
H265Parser parser; H265Parser parser;
RCHECK(nalu.InitializeFromH265(last_sps_.data(), last_sps_.size())); RCHECK(nalu.Initialize(Nalu::kH265, last_sps_.data(), last_sps_.size()));
RCHECK(parser.ParseSps(nalu, &id) == H265Parser::kOk); RCHECK(parser.ParseSps(nalu, &id) == H265Parser::kOk);
const H265Sps* sps = parser.GetSps(id); const H265Sps* sps = parser.GetSps(id);

View File

@ -36,13 +36,13 @@ TEST(H265ParserTest, ParseSliceHeader) {
int id; int id;
Nalu nalu; Nalu nalu;
H265Parser parser; H265Parser parser;
ASSERT_TRUE(nalu.InitializeFromH265(kSpsData, arraysize(kSpsData))); ASSERT_TRUE(nalu.Initialize(Nalu::kH265, kSpsData, arraysize(kSpsData)));
ASSERT_EQ(H265Parser::kOk, parser.ParseSps(nalu, &id)); ASSERT_EQ(H265Parser::kOk, parser.ParseSps(nalu, &id));
ASSERT_TRUE(nalu.InitializeFromH265(kPpsData, arraysize(kPpsData))); ASSERT_TRUE(nalu.Initialize(Nalu::kH265, kPpsData, arraysize(kPpsData)));
ASSERT_EQ(H265Parser::kOk, parser.ParsePps(nalu, &id)); ASSERT_EQ(H265Parser::kOk, parser.ParsePps(nalu, &id));
// Parse the slice header. // Parse the slice header.
ASSERT_TRUE(nalu.InitializeFromH265(kSliceData, arraysize(kSliceData))); ASSERT_TRUE(nalu.Initialize(Nalu::kH265, kSliceData, arraysize(kSliceData)));
ASSERT_EQ(Nalu::H265_IDR_W_RADL, nalu.type()); ASSERT_EQ(Nalu::H265_IDR_W_RADL, nalu.type());
H265SliceHeader header; H265SliceHeader header;
@ -63,13 +63,14 @@ TEST(H265ParserTest, ParseSliceHeader_NonIDR) {
int id; int id;
Nalu nalu; Nalu nalu;
H265Parser parser; H265Parser parser;
ASSERT_TRUE(nalu.InitializeFromH265(kSpsData, arraysize(kSpsData))); ASSERT_TRUE(nalu.Initialize(Nalu::kH265, kSpsData, arraysize(kSpsData)));
ASSERT_EQ(H265Parser::kOk, parser.ParseSps(nalu, &id)); ASSERT_EQ(H265Parser::kOk, parser.ParseSps(nalu, &id));
ASSERT_TRUE(nalu.InitializeFromH265(kPpsData, arraysize(kPpsData))); ASSERT_TRUE(nalu.Initialize(Nalu::kH265, kPpsData, arraysize(kPpsData)));
ASSERT_EQ(H265Parser::kOk, parser.ParsePps(nalu, &id)); ASSERT_EQ(H265Parser::kOk, parser.ParsePps(nalu, &id));
// Parse the slice header. // Parse the slice header.
ASSERT_TRUE(nalu.InitializeFromH265(kSliceData2, arraysize(kSliceData2))); ASSERT_TRUE(
nalu.Initialize(Nalu::kH265, kSliceData2, arraysize(kSliceData2)));
ASSERT_EQ(1 /* TRAIL_R */, nalu.type()); ASSERT_EQ(1 /* TRAIL_R */, nalu.type());
H265SliceHeader header; H265SliceHeader header;
@ -85,7 +86,7 @@ TEST(H265ParserTest, ParseSliceHeader_NonIDR) {
TEST(H265ParserTest, ParseSps) { TEST(H265ParserTest, ParseSps) {
Nalu nalu; Nalu nalu;
ASSERT_TRUE(nalu.InitializeFromH265(kSpsData, arraysize(kSpsData))); ASSERT_TRUE(nalu.Initialize(Nalu::kH265, kSpsData, arraysize(kSpsData)));
ASSERT_EQ(Nalu::H265_SPS, nalu.type()); ASSERT_EQ(Nalu::H265_SPS, nalu.type());
int id = 12; int id = 12;
@ -108,7 +109,7 @@ TEST(H265ParserTest, ParseSps) {
TEST(H265ParserTest, ParsePps) { TEST(H265ParserTest, ParsePps) {
Nalu nalu; Nalu nalu;
ASSERT_TRUE(nalu.InitializeFromH265(kPpsData, arraysize(kPpsData))); ASSERT_TRUE(nalu.Initialize(Nalu::kH265, kPpsData, arraysize(kPpsData)));
ASSERT_EQ(Nalu::H265_PPS, nalu.type()); ASSERT_EQ(Nalu::H265_PPS, nalu.type());
int id = 12; int id = 12;
@ -129,7 +130,7 @@ TEST(H265ParserTest, ExtractResolutionFromSpsData) {
H265Parser parser; H265Parser parser;
int sps_id = 0; int sps_id = 0;
Nalu nalu; Nalu nalu;
ASSERT_TRUE(nalu.InitializeFromH265(kSpsData, arraysize(kSpsData))); ASSERT_TRUE(nalu.Initialize(Nalu::kH265, kSpsData, arraysize(kSpsData)));
ASSERT_EQ(H265Parser::kOk, parser.ParseSps(nalu, &sps_id)); ASSERT_EQ(H265Parser::kOk, parser.ParseSps(nalu, &sps_id));
uint32_t coded_width = 0; uint32_t coded_width = 0;
@ -155,7 +156,8 @@ TEST(H265ParserTest, ExtractResolutionFromSpsDataWithCrop) {
H265Parser parser; H265Parser parser;
int sps_id = 0; int sps_id = 0;
Nalu nalu; Nalu nalu;
ASSERT_TRUE(nalu.InitializeFromH265(kSpsCropData, arraysize(kSpsCropData))); ASSERT_TRUE(
nalu.Initialize(Nalu::kH265, kSpsCropData, arraysize(kSpsCropData)));
ASSERT_EQ(H265Parser::kOk, parser.ParseSps(nalu, &sps_id)); ASSERT_EQ(H265Parser::kOk, parser.ParseSps(nalu, &sps_id));
uint32_t coded_width = 0; uint32_t coded_width = 0;

View File

@ -21,7 +21,7 @@ const size_t kStreamConversionOverhead = 100;
} }
H26xByteToUnitStreamConverter::H26xByteToUnitStreamConverter( H26xByteToUnitStreamConverter::H26xByteToUnitStreamConverter(
NaluReader::CodecType type) Nalu::CodecType type)
: type_(type) {} : type_(type) {}
H26xByteToUnitStreamConverter::~H26xByteToUnitStreamConverter() {} H26xByteToUnitStreamConverter::~H26xByteToUnitStreamConverter() {}

View File

@ -23,7 +23,7 @@ class H26xByteToUnitStreamConverter {
public: public:
static const size_t kUnitStreamNaluLengthSize = 4; static const size_t kUnitStreamNaluLengthSize = 4;
H26xByteToUnitStreamConverter(NaluReader::CodecType type); H26xByteToUnitStreamConverter(Nalu::CodecType type);
virtual ~H26xByteToUnitStreamConverter(); virtual ~H26xByteToUnitStreamConverter();
/// Converts a whole byte stream encoded video frame to NAL unit stream /// Converts a whole byte stream encoded video frame to NAL unit stream
@ -52,7 +52,7 @@ class H26xByteToUnitStreamConverter {
// not be copied to the buffer. // not be copied to the buffer.
virtual bool ProcessNalu(const Nalu& nalu) = 0; virtual bool ProcessNalu(const Nalu& nalu) = 0;
NaluReader::CodecType type_; Nalu::CodecType type_;
DISALLOW_COPY_AND_ASSIGN(H26xByteToUnitStreamConverter); DISALLOW_COPY_AND_ASSIGN(H26xByteToUnitStreamConverter);
}; };

View File

@ -122,7 +122,7 @@ bool HEVCDecoderConfiguration::ParseInternal() {
RCHECK(reader.SkipBytes(nalu_length)); RCHECK(reader.SkipBytes(nalu_length));
Nalu nalu; Nalu nalu;
RCHECK(nalu.InitializeFromH265(data() + nalu_offset, nalu_length)); RCHECK(nalu.Initialize(Nalu::kH265, data() + nalu_offset, nalu_length));
RCHECK(nalu.type() == nal_unit_type); RCHECK(nalu.type() == nal_unit_type);
AddNalu(nalu); AddNalu(nalu);
} }

View File

@ -155,8 +155,7 @@ bool NalUnitToByteStreamConverter::ConvertUnitToByteStream(
if (is_key_frame) if (is_key_frame)
buffer_writer.AppendVector(decoder_configuration_in_byte_stream_); buffer_writer.AppendVector(decoder_configuration_in_byte_stream_);
NaluReader nalu_reader(NaluReader::kH264, nalu_length_size_, sample, NaluReader nalu_reader(Nalu::kH264, nalu_length_size_, sample, sample_size);
sample_size);
Nalu nalu; Nalu nalu;
NaluReader::Result result = nalu_reader.Advance(&nalu); NaluReader::Result result = nalu_reader.Advance(&nalu);

View File

@ -31,6 +31,17 @@ Nalu::Nalu()
type_(0), type_(0),
is_video_slice_(false) {} is_video_slice_(false) {}
bool Nalu::Initialize(CodecType type,
const uint8_t* data,
uint64_t size) {
if (type == Nalu::kH264) {
return InitializeFromH264(data, size);
} else {
DCHECK_EQ(Nalu::kH265, type);
return InitializeFromH265(data, size);
}
}
// ITU-T H.264 (02/2014) 7.4.1 NAL unit semantics // ITU-T H.264 (02/2014) 7.4.1 NAL unit semantics
bool Nalu::InitializeFromH264(const uint8_t* data, uint64_t size) { bool Nalu::InitializeFromH264(const uint8_t* data, uint64_t size) {
DCHECK(data); DCHECK(data);
@ -142,7 +153,7 @@ bool Nalu::InitializeFromH265(const uint8_t* data, uint64_t size) {
return true; return true;
} }
NaluReader::NaluReader(CodecType type, NaluReader::NaluReader(Nalu::CodecType type,
uint8_t nal_length_size, uint8_t nal_length_size,
const uint8_t* stream, const uint8_t* stream,
uint64_t stream_size) uint64_t stream_size)
@ -193,14 +204,8 @@ NaluReader::Result NaluReader::Advance(Nalu* nalu) {
} }
const uint8_t* nalu_data = stream_ + nalu_length_size_or_start_code_size; const uint8_t* nalu_data = stream_ + nalu_length_size_or_start_code_size;
if (nalu_type_ == kH264) { if (!nalu->Initialize(nalu_type_, nalu_data, nalu_length))
if (!nalu->InitializeFromH264(nalu_data, nalu_length))
return NaluReader::kInvalidStream; return NaluReader::kInvalidStream;
} else {
DCHECK_EQ(kH265, nalu_type_);
if (!nalu->InitializeFromH265(nalu_data, nalu_length))
return NaluReader::kInvalidStream;
}
// Move parser state to after this NALU, so next time Advance // Move parser state to after this NALU, so next time Advance
// is called, we will effectively be skipping it. // is called, we will effectively be skipping it.
@ -302,9 +307,7 @@ bool NaluReader::LocateNaluByStartCode(uint64_t* nalu_size,
// If it is not a valid NAL unit, we will continue searching. This is to // If it is not a valid NAL unit, we will continue searching. This is to
// handle the case where emulation prevention are not applied. // handle the case where emulation prevention are not applied.
Nalu nalu; Nalu nalu;
if (nalu_type_ == kH264 if (nalu.Initialize(nalu_type_, nalu_data, max_nalu_data_size)) {
? nalu.InitializeFromH264(nalu_data, max_nalu_data_size)
: nalu.InitializeFromH265(nalu_data, max_nalu_data_size)) {
nalu_data -= next_start_code_size; nalu_data -= next_start_code_size;
break; break;
} }

View File

@ -72,13 +72,15 @@ class Nalu {
H265_RSV_NVCL41 = 41, H265_RSV_NVCL41 = 41,
}; };
enum CodecType {
kH264,
kH265,
};
Nalu(); Nalu();
bool InitializeFromH264(const uint8_t* data, bool Initialize(CodecType type,
uint64_t size) WARN_UNUSED_RESULT; const uint8_t* data,
bool InitializeFromH265(const uint8_t* data,
uint64_t size) WARN_UNUSED_RESULT; uint64_t size) WARN_UNUSED_RESULT;
const uint8_t* data() const { return data_; } const uint8_t* data() const { return data_; }
@ -96,6 +98,9 @@ class Nalu {
bool is_video_slice() const { return is_video_slice_; } bool is_video_slice() const { return is_video_slice_; }
private: private:
bool InitializeFromH264(const uint8_t* data, uint64_t size);
bool InitializeFromH265(const uint8_t* data, uint64_t size);
// A pointer to the NALU (i.e. points to the header). This pointer is not // A pointer to the NALU (i.e. points to the header). This pointer is not
// owned by this instance. // owned by this instance.
const uint8_t* data_; const uint8_t* data_;
@ -125,15 +130,11 @@ class NaluReader {
kInvalidStream, // error in stream kInvalidStream, // error in stream
kEOStream, // end of stream kEOStream, // end of stream
}; };
enum CodecType {
kH264,
kH265,
};
/// @param nalu_length_size should be set to 0 for AnnexB byte streams; /// @param nalu_length_size should be set to 0 for AnnexB byte streams;
/// otherwise, it indicates the size of NAL unit length for the NAL /// otherwise, it indicates the size of NAL unit length for the NAL
/// unit stream. /// unit stream.
NaluReader(CodecType type, NaluReader(Nalu::CodecType type,
uint8_t nal_length_size, uint8_t nal_length_size,
const uint8_t* stream, const uint8_t* stream,
uint64_t stream_size); uint64_t stream_size);
@ -183,7 +184,7 @@ class NaluReader {
// The remaining size of the stream. // The remaining size of the stream.
uint64_t stream_size_; uint64_t stream_size_;
// The type of NALU being read. // The type of NALU being read.
CodecType nalu_type_; Nalu::CodecType nalu_type_;
// The number of bytes the prefix length is; only valid if format is // The number of bytes the prefix length is; only valid if format is
// kAnnexbByteStreamFormat. // kAnnexbByteStreamFormat.
uint8_t nalu_length_size_; uint8_t nalu_length_size_;

View File

@ -20,7 +20,7 @@ TEST(NaluReaderTest, StartCodeSearch) {
0x00, 0x00, 0x00, 0x01, 0x67, 0xbb, 0xcc, 0xdd, 0x00, 0x00, 0x00, 0x01, 0x67, 0xbb, 0xcc, 0xdd,
}; };
NaluReader reader(NaluReader::kH264, kIsAnnexbByteStream, kNaluData, NaluReader reader(Nalu::kH264, kIsAnnexbByteStream, kNaluData,
arraysize(kNaluData)); arraysize(kNaluData));
Nalu nalu; Nalu nalu;
@ -54,7 +54,7 @@ TEST(NaluReaderTest, StartCodeSearchWithStartCodeInsideNalUnit) {
0x00, 0x00, 0x01, 0x00, 0x00, 0x01,
}; };
NaluReader reader(NaluReader::kH264, kIsAnnexbByteStream, kNaluData, NaluReader reader(Nalu::kH264, kIsAnnexbByteStream, kNaluData,
arraysize(kNaluData)); arraysize(kNaluData));
Nalu nalu; Nalu nalu;
@ -83,7 +83,7 @@ TEST(NaluReaderTest, OneByteNaluLength) {
0x06, 0x67, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x06, 0x67, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
}; };
NaluReader reader(NaluReader::kH264, 1, kNaluData, arraysize(kNaluData)); NaluReader reader(Nalu::kH264, 1, kNaluData, arraysize(kNaluData));
Nalu nalu; Nalu nalu;
ASSERT_EQ(NaluReader::kOk, reader.Advance(&nalu)); ASSERT_EQ(NaluReader::kOk, reader.Advance(&nalu));
@ -111,7 +111,7 @@ TEST(NaluReaderTest, FourByteNaluLength) {
0x00, 0x00, 0x00, 0x03, 0x67, 0x0a, 0x0b, 0x00, 0x00, 0x00, 0x03, 0x67, 0x0a, 0x0b,
}; };
NaluReader reader(NaluReader::kH264, 4, kNaluData, arraysize(kNaluData)); NaluReader reader(Nalu::kH264, 4, kNaluData, arraysize(kNaluData));
Nalu nalu; Nalu nalu;
ASSERT_EQ(NaluReader::kOk, reader.Advance(&nalu)); ASSERT_EQ(NaluReader::kOk, reader.Advance(&nalu));
@ -137,7 +137,7 @@ TEST(NaluReaderTest, ErrorForNotEnoughForNaluLength) {
0x00, 0x00,
}; };
NaluReader reader(NaluReader::kH264, 3, kNaluData, arraysize(kNaluData)); NaluReader reader(Nalu::kH264, 3, kNaluData, arraysize(kNaluData));
Nalu nalu; Nalu nalu;
EXPECT_EQ(NaluReader::kInvalidStream, reader.Advance(&nalu)); EXPECT_EQ(NaluReader::kInvalidStream, reader.Advance(&nalu));
@ -149,7 +149,7 @@ TEST(NaluReaderTest, ErrorForNaluLengthExceedsRemainingData) {
0xFF, 0x08, 0x00, 0xFF, 0x08, 0x00,
}; };
NaluReader reader(NaluReader::kH264, 1, kNaluData, arraysize(kNaluData)); NaluReader reader(Nalu::kH264, 1, kNaluData, arraysize(kNaluData));
Nalu nalu; Nalu nalu;
EXPECT_EQ(NaluReader::kInvalidStream, reader.Advance(&nalu)); EXPECT_EQ(NaluReader::kInvalidStream, reader.Advance(&nalu));
@ -160,7 +160,7 @@ TEST(NaluReaderTest, ErrorForNaluLengthExceedsRemainingData) {
0x04, 0x08, 0x00, 0x00, 0x04, 0x08, 0x00, 0x00,
}; };
NaluReader reader2(NaluReader::kH264, 1, kNaluData2, arraysize(kNaluData2)); NaluReader reader2(Nalu::kH264, 1, kNaluData2, arraysize(kNaluData2));
EXPECT_EQ(NaluReader::kInvalidStream, reader2.Advance(&nalu)); EXPECT_EQ(NaluReader::kInvalidStream, reader2.Advance(&nalu));
} }
@ -170,7 +170,7 @@ TEST(NaluReaderTest, ErrorForForbiddenBitSet) {
0x03, 0x80, 0x00, 0x00, 0x03, 0x80, 0x00, 0x00,
}; };
NaluReader reader(NaluReader::kH264, 1, kNaluData, arraysize(kNaluData)); NaluReader reader(Nalu::kH264, 1, kNaluData, arraysize(kNaluData));
Nalu nalu; Nalu nalu;
EXPECT_EQ(NaluReader::kInvalidStream, reader.Advance(&nalu)); EXPECT_EQ(NaluReader::kInvalidStream, reader.Advance(&nalu));
@ -183,8 +183,8 @@ TEST(NaluReaderTest, ErrorForZeroSize) {
}; };
Nalu nalu; Nalu nalu;
EXPECT_FALSE(nalu.InitializeFromH264(kNaluData, 0)); EXPECT_FALSE(nalu.Initialize(Nalu::kH264, kNaluData, 0));
EXPECT_FALSE(nalu.InitializeFromH265(kNaluData, 0)); EXPECT_FALSE(nalu.Initialize(Nalu::kH265, kNaluData, 0));
} }
} // namespace media } // namespace media

View File

@ -182,8 +182,7 @@ bool EsParserH264::ParseInternal() {
int access_unit_size = base::checked_cast<int, int64_t>( int access_unit_size = base::checked_cast<int, int64_t>(
next_access_unit_pos_ - current_access_unit_pos_); next_access_unit_pos_ - current_access_unit_pos_);
DCHECK_LE(access_unit_size, size); DCHECK_LE(access_unit_size, size);
NaluReader reader(NaluReader::kH264, kIsAnnexbByteStream, es, NaluReader reader(Nalu::kH264, kIsAnnexbByteStream, es, access_unit_size);
access_unit_size);
while (true) { while (true) {
Nalu nalu; Nalu nalu;

View File

@ -271,10 +271,10 @@ Status EncryptingFragmenter::EncryptSample(scoped_refptr<MediaSample> sample) {
data += frame.frame_size; data += frame.frame_size;
} }
} else { } else {
const NaluReader::CodecType nalu_type = const Nalu::CodecType nalu_type =
(video_codec_ == kCodecHVC1 || video_codec_ == kCodecHEV1) (video_codec_ == kCodecHVC1 || video_codec_ == kCodecHEV1)
? NaluReader::kH265 ? Nalu::kH265
: NaluReader::kH264; : Nalu::kH264;
NaluReader reader(nalu_type, nalu_length_size_, data, NaluReader reader(nalu_type, nalu_length_size_, data,
sample->data_size()); sample->data_size());

View File

@ -43,7 +43,7 @@ TEST(H264VideoSliceHeaderParserTest, BasicSupport) {
ASSERT_TRUE(parser.Initialize(extra_data)); ASSERT_TRUE(parser.Initialize(extra_data));
Nalu nalu; Nalu nalu;
ASSERT_TRUE(nalu.InitializeFromH264(kData, arraysize(kData))); ASSERT_TRUE(nalu.Initialize(Nalu::kH264, kData, arraysize(kData)));
// Real header size is 34 bits, but we round up to 5 bytes. // Real header size is 34 bits, but we round up to 5 bytes.
EXPECT_EQ(5, parser.GetHeaderSize(nalu)); EXPECT_EQ(5, parser.GetHeaderSize(nalu));
} }