Renamed Nalu |data_size| to |payload_size|.
This member refers to the size of the payload (the data after the header). Since the pointer is called |data|, calling this size |data_size| is confusing. Change-Id: I9174cf6c5c402beddaebbce7c16514470ba0c3da
This commit is contained in:
parent
e0e0925b31
commit
53e6d2d149
|
@ -54,8 +54,8 @@ void H264ByteToUnitStreamConverter::ProcessNalu(const Nalu& nalu,
|
|||
DCHECK(output_buffer);
|
||||
|
||||
// Skip the start code, but keep the 1-byte NALU type.
|
||||
const uint8_t* nalu_ptr = nalu.data() + nalu.header_size() - 1;
|
||||
const uint64_t nalu_size = nalu.data_size() + 1;
|
||||
const uint8_t* nalu_ptr = nalu.data();
|
||||
const uint64_t nalu_size = nalu.payload_size() + nalu.header_size();
|
||||
DCHECK_LE(nalu_size, std::numeric_limits<uint32_t>::max());
|
||||
|
||||
switch (nalu.type()) {
|
||||
|
|
|
@ -635,7 +635,7 @@ H264Parser::Result H264Parser::ParseSPS(const Nalu& nalu, int* sps_id) {
|
|||
int data;
|
||||
Result res;
|
||||
H264BitReader reader;
|
||||
reader.Initialize(nalu.data() + nalu.header_size(), nalu.data_size());
|
||||
reader.Initialize(nalu.data() + nalu.header_size(), nalu.payload_size());
|
||||
H264BitReader* br = &reader;
|
||||
|
||||
*sps_id = -1;
|
||||
|
@ -760,7 +760,7 @@ H264Parser::Result H264Parser::ParsePPS(const Nalu& nalu, int* pps_id) {
|
|||
const H264SPS* sps;
|
||||
Result res;
|
||||
H264BitReader reader;
|
||||
reader.Initialize(nalu.data() + nalu.header_size(), nalu.data_size());
|
||||
reader.Initialize(nalu.data() + nalu.header_size(), nalu.payload_size());
|
||||
H264BitReader* br = &reader;
|
||||
|
||||
*pps_id = -1;
|
||||
|
@ -1031,7 +1031,7 @@ H264Parser::Result H264Parser::ParseSliceHeader(const Nalu& nalu,
|
|||
const H264PPS* pps;
|
||||
Result res;
|
||||
H264BitReader reader;
|
||||
reader.Initialize(nalu.data() + nalu.header_size(), nalu.data_size());
|
||||
reader.Initialize(nalu.data() + nalu.header_size(), nalu.payload_size());
|
||||
H264BitReader* br = &reader;
|
||||
|
||||
memset(shdr, 0, sizeof(*shdr));
|
||||
|
@ -1039,7 +1039,7 @@ H264Parser::Result H264Parser::ParseSliceHeader(const Nalu& nalu,
|
|||
shdr->idr_pic_flag = (nalu.type() == 5);
|
||||
shdr->nal_ref_idc = nalu.ref_idc();
|
||||
shdr->nalu_data = nalu.data() + nalu.header_size();
|
||||
shdr->nalu_size = nalu.data_size();
|
||||
shdr->nalu_size = nalu.payload_size();
|
||||
|
||||
READ_UE_OR_RETURN(&shdr->first_mb_in_slice);
|
||||
READ_UE_OR_RETURN(&shdr->slice_type);
|
||||
|
@ -1179,7 +1179,7 @@ H264Parser::Result H264Parser::ParseSEI(const Nalu& nalu,
|
|||
H264SEIMessage* sei_msg) {
|
||||
int byte;
|
||||
H264BitReader reader;
|
||||
reader.Initialize(nalu.data() + nalu.header_size(), nalu.data_size());
|
||||
reader.Initialize(nalu.data() + nalu.header_size(), nalu.payload_size());
|
||||
H264BitReader* br = &reader;
|
||||
|
||||
memset(sei_msg, 0, sizeof(*sei_msg));
|
||||
|
|
|
@ -21,8 +21,8 @@ inline bool IsStartCode(const uint8_t* data) {
|
|||
|
||||
Nalu::Nalu()
|
||||
: data_(nullptr),
|
||||
data_size_(0),
|
||||
header_size_(0),
|
||||
payload_size_(0),
|
||||
ref_idc_(0),
|
||||
type_(0),
|
||||
is_video_slice_(false) {}
|
||||
|
@ -36,7 +36,7 @@ bool Nalu::InitializeFromH264(const uint8_t* data, uint64_t size) {
|
|||
|
||||
data_ = data;
|
||||
header_size_ = 1;
|
||||
data_size_ = size - 1;
|
||||
payload_size_ = size - 1;
|
||||
ref_idc_ = (header >> 5) & 0x3;
|
||||
type_ = header & 0x1F;
|
||||
is_video_slice_ = (type_ >= Nalu::H264_NonIDRSlice &&
|
||||
|
@ -103,7 +103,7 @@ NaluReader::Result NaluReader::Advance(Nalu* nalu) {
|
|||
|
||||
DVLOG(4) << "NALU type: " << static_cast<int>(nalu->type())
|
||||
<< " at: " << reinterpret_cast<const void*>(nalu->data())
|
||||
<< " data size: " << nalu->data_size()
|
||||
<< " data size: " << nalu->payload_size()
|
||||
<< " ref: " << static_cast<int>(nalu->ref_idc());
|
||||
|
||||
return NaluReader::kOk;
|
||||
|
|
|
@ -43,8 +43,8 @@ class Nalu {
|
|||
uint64_t size) WARN_UNUSED_RESULT;
|
||||
|
||||
const uint8_t* data() const { return data_; }
|
||||
uint64_t data_size() const { return data_size_; }
|
||||
uint64_t header_size() const { return header_size_; }
|
||||
uint64_t payload_size() const { return payload_size_; }
|
||||
|
||||
int ref_idc() const { return ref_idc_; }
|
||||
int type() const { return type_; }
|
||||
|
@ -54,8 +54,11 @@ class Nalu {
|
|||
// A pointer to the NALU (i.e. points to the header). This pointer is not
|
||||
// owned by this instance.
|
||||
const uint8_t* data_;
|
||||
uint64_t data_size_;
|
||||
// NALU header size (e.g. 1 byte for H.264). Note that it does not include
|
||||
// header extension data in some NAL units.
|
||||
uint64_t header_size_;
|
||||
// Size of data after the header.
|
||||
uint64_t payload_size_;
|
||||
|
||||
int ref_idc_;
|
||||
int type_;
|
||||
|
|
|
@ -25,14 +25,14 @@ TEST(NaluReaderTest, StartCodeSearch) {
|
|||
Nalu nalu;
|
||||
ASSERT_EQ(NaluReader::kOk, reader.Advance(&nalu));
|
||||
EXPECT_EQ(kNaluData + 9, nalu.data());
|
||||
EXPECT_EQ(3u, nalu.data_size());
|
||||
EXPECT_EQ(3u, nalu.payload_size());
|
||||
EXPECT_EQ(1u, nalu.header_size());
|
||||
EXPECT_EQ(0, nalu.ref_idc());
|
||||
EXPECT_EQ(0x12, nalu.type());
|
||||
|
||||
ASSERT_EQ(NaluReader::kOk, reader.Advance(&nalu));
|
||||
EXPECT_EQ(kNaluData + 17, nalu.data());
|
||||
EXPECT_EQ(3u, nalu.data_size());
|
||||
EXPECT_EQ(3u, nalu.payload_size());
|
||||
EXPECT_EQ(1u, nalu.header_size());
|
||||
EXPECT_EQ(3, nalu.ref_idc());
|
||||
EXPECT_EQ(7, nalu.type());
|
||||
|
@ -53,14 +53,14 @@ TEST(NaluReaderTest, OneByteNaluLength) {
|
|||
Nalu nalu;
|
||||
ASSERT_EQ(NaluReader::kOk, reader.Advance(&nalu));
|
||||
EXPECT_EQ(kNaluData + 1, nalu.data());
|
||||
EXPECT_EQ(4u, nalu.data_size());
|
||||
EXPECT_EQ(4u, nalu.payload_size());
|
||||
EXPECT_EQ(1u, nalu.header_size());
|
||||
EXPECT_EQ(0, nalu.ref_idc());
|
||||
EXPECT_EQ(8, nalu.type());
|
||||
|
||||
ASSERT_EQ(NaluReader::kOk, reader.Advance(&nalu));
|
||||
EXPECT_EQ(kNaluData + 7, nalu.data());
|
||||
EXPECT_EQ(5u, nalu.data_size());
|
||||
EXPECT_EQ(5u, nalu.payload_size());
|
||||
EXPECT_EQ(1u, nalu.header_size());
|
||||
EXPECT_EQ(3, nalu.ref_idc());
|
||||
EXPECT_EQ(7, nalu.type());
|
||||
|
@ -81,14 +81,14 @@ TEST(NaluReaderTest, FourByteNaluLength) {
|
|||
Nalu nalu;
|
||||
ASSERT_EQ(NaluReader::kOk, reader.Advance(&nalu));
|
||||
EXPECT_EQ(kNaluData + 4, nalu.data());
|
||||
EXPECT_EQ(6u, nalu.data_size());
|
||||
EXPECT_EQ(6u, nalu.payload_size());
|
||||
EXPECT_EQ(1u, nalu.header_size());
|
||||
EXPECT_EQ(0, nalu.ref_idc());
|
||||
EXPECT_EQ(8, nalu.type());
|
||||
|
||||
ASSERT_EQ(NaluReader::kOk, reader.Advance(&nalu));
|
||||
EXPECT_EQ(kNaluData + 15, nalu.data());
|
||||
EXPECT_EQ(2u, nalu.data_size());
|
||||
EXPECT_EQ(2u, nalu.payload_size());
|
||||
EXPECT_EQ(1u, nalu.header_size());
|
||||
EXPECT_EQ(3, nalu.ref_idc());
|
||||
EXPECT_EQ(7, nalu.type());
|
||||
|
|
|
@ -244,7 +244,7 @@ Status EncryptingFragmenter::EncryptSample(scoped_refptr<MediaSample> sample) {
|
|||
const uint64_t current_clear_bytes = nalu.header_size() +
|
||||
video_slice_header_size;
|
||||
const uint64_t cipher_bytes =
|
||||
nalu.data_size() - video_slice_header_size;
|
||||
nalu.payload_size() - video_slice_header_size;
|
||||
const uint8_t* nalu_data = nalu.data() + current_clear_bytes;
|
||||
EncryptBytes(const_cast<uint8_t*>(nalu_data), cipher_bytes);
|
||||
|
||||
|
@ -254,7 +254,7 @@ Status EncryptingFragmenter::EncryptSample(scoped_refptr<MediaSample> sample) {
|
|||
accumulated_clear_bytes = 0;
|
||||
} else {
|
||||
// For non-video-slice NAL units, don't encrypt.
|
||||
accumulated_clear_bytes += nalu.header_size() + nalu.data_size();
|
||||
accumulated_clear_bytes += nalu.header_size() + nalu.payload_size();
|
||||
}
|
||||
}
|
||||
if (result != NaluReader::kEOStream)
|
||||
|
|
Loading…
Reference in New Issue