Fix x64 build on Windows.
- Fix integer conversion warnings. - Fix #168. Change-Id: Ie9aadea86a293b49e0854d6549800083143c79df
This commit is contained in:
parent
655fe7b699
commit
93fe5457bf
|
@ -9,7 +9,7 @@
|
||||||
namespace shaka {
|
namespace shaka {
|
||||||
namespace media {
|
namespace media {
|
||||||
|
|
||||||
BitReader::BitReader(const uint8_t* data, off_t size)
|
BitReader::BitReader(const uint8_t* data, size_t size)
|
||||||
: data_(data),
|
: data_(data),
|
||||||
initial_size_(size),
|
initial_size_(size),
|
||||||
bytes_left_(size),
|
bytes_left_(size),
|
||||||
|
@ -21,16 +21,14 @@ BitReader::BitReader(const uint8_t* data, off_t size)
|
||||||
|
|
||||||
BitReader::~BitReader() {}
|
BitReader::~BitReader() {}
|
||||||
|
|
||||||
bool BitReader::SkipBits(int num_bits) {
|
bool BitReader::SkipBits(size_t num_bits) {
|
||||||
DCHECK_GE(num_bits, 0);
|
|
||||||
|
|
||||||
// Skip any bits in the current byte waiting to be processed, then
|
// Skip any bits in the current byte waiting to be processed, then
|
||||||
// process full bytes until less than 8 bits remaining.
|
// process full bytes until less than 8 bits remaining.
|
||||||
if (num_bits > num_remaining_bits_in_curr_byte_) {
|
if (num_bits > num_remaining_bits_in_curr_byte_) {
|
||||||
num_bits -= num_remaining_bits_in_curr_byte_;
|
num_bits -= num_remaining_bits_in_curr_byte_;
|
||||||
num_remaining_bits_in_curr_byte_ = 0;
|
num_remaining_bits_in_curr_byte_ = 0;
|
||||||
|
|
||||||
int num_bytes = num_bits / 8;
|
size_t num_bytes = num_bits / 8;
|
||||||
num_bits %= 8;
|
num_bits %= 8;
|
||||||
if (bytes_left_ < num_bytes) {
|
if (bytes_left_ < num_bytes) {
|
||||||
bytes_left_ = 0;
|
bytes_left_ = 0;
|
||||||
|
@ -53,7 +51,7 @@ bool BitReader::SkipBits(int num_bits) {
|
||||||
return ReadBitsInternal(num_bits, ¬_needed);
|
return ReadBitsInternal(num_bits, ¬_needed);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BitReader::SkipBytes(int num_bytes) {
|
bool BitReader::SkipBytes(size_t num_bytes) {
|
||||||
if (num_remaining_bits_in_curr_byte_ != 8)
|
if (num_remaining_bits_in_curr_byte_ != 8)
|
||||||
return false;
|
return false;
|
||||||
if (num_bytes == 0)
|
if (num_bytes == 0)
|
||||||
|
@ -68,13 +66,13 @@ bool BitReader::SkipBytes(int num_bytes) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BitReader::ReadBitsInternal(int num_bits, uint64_t* out) {
|
bool BitReader::ReadBitsInternal(size_t num_bits, uint64_t* out) {
|
||||||
DCHECK_LE(num_bits, 64);
|
DCHECK_LE(num_bits, 64u);
|
||||||
|
|
||||||
*out = 0;
|
*out = 0;
|
||||||
|
|
||||||
while (num_remaining_bits_in_curr_byte_ != 0 && num_bits != 0) {
|
while (num_remaining_bits_in_curr_byte_ != 0 && num_bits != 0) {
|
||||||
int bits_to_take = std::min(num_remaining_bits_in_curr_byte_, num_bits);
|
size_t bits_to_take = std::min(num_remaining_bits_in_curr_byte_, num_bits);
|
||||||
|
|
||||||
*out <<= bits_to_take;
|
*out <<= bits_to_take;
|
||||||
*out += curr_byte_ >> (num_remaining_bits_in_curr_byte_ - bits_to_take);
|
*out += curr_byte_ >> (num_remaining_bits_in_curr_byte_ - bits_to_take);
|
||||||
|
@ -90,7 +88,7 @@ bool BitReader::ReadBitsInternal(int num_bits, uint64_t* out) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void BitReader::UpdateCurrByte() {
|
void BitReader::UpdateCurrByte() {
|
||||||
DCHECK_EQ(num_remaining_bits_in_curr_byte_, 0);
|
DCHECK_EQ(num_remaining_bits_in_curr_byte_, 0u);
|
||||||
|
|
||||||
if (bytes_left_ == 0)
|
if (bytes_left_ == 0)
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -19,7 +19,7 @@ class BitReader {
|
||||||
/// Initialize the BitReader object to read a data buffer.
|
/// Initialize the BitReader object to read a data buffer.
|
||||||
/// @param data points to the beginning of the buffer.
|
/// @param data points to the beginning of the buffer.
|
||||||
/// @param size is the buffer size in bytes.
|
/// @param size is the buffer size in bytes.
|
||||||
BitReader(const uint8_t* data, off_t size);
|
BitReader(const uint8_t* data, size_t size);
|
||||||
~BitReader();
|
~BitReader();
|
||||||
|
|
||||||
/// Read a number of bits from stream.
|
/// Read a number of bits from stream.
|
||||||
|
@ -32,8 +32,8 @@ class BitReader {
|
||||||
/// stream will enter a state where further ReadBits/SkipBits
|
/// stream will enter a state where further ReadBits/SkipBits
|
||||||
/// operations will always return false unless @a num_bits is 0.
|
/// operations will always return false unless @a num_bits is 0.
|
||||||
template <typename T>
|
template <typename T>
|
||||||
bool ReadBits(int num_bits, T* out) {
|
bool ReadBits(size_t num_bits, T* out) {
|
||||||
DCHECK_LE(num_bits, static_cast<int>(sizeof(T) * 8));
|
DCHECK_LE(num_bits, sizeof(T) * 8);
|
||||||
uint64_t temp;
|
uint64_t temp;
|
||||||
bool ret = ReadBitsInternal(num_bits, &temp);
|
bool ret = ReadBitsInternal(num_bits, &temp);
|
||||||
*out = static_cast<T>(temp);
|
*out = static_cast<T>(temp);
|
||||||
|
@ -41,8 +41,8 @@ class BitReader {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Explicit T=bool overload to make MSVC happy.
|
// Explicit T=bool overload to make MSVC happy.
|
||||||
bool ReadBits(int num_bits, bool* out) {
|
bool ReadBits(size_t num_bits, bool* out) {
|
||||||
DCHECK_EQ(num_bits, 1);
|
DCHECK_EQ(num_bits, 1u);
|
||||||
uint64_t temp;
|
uint64_t temp;
|
||||||
bool ret = ReadBitsInternal(num_bits, &temp);
|
bool ret = ReadBitsInternal(num_bits, &temp);
|
||||||
*out = temp != 0;
|
*out = temp != 0;
|
||||||
|
@ -55,7 +55,7 @@ class BitReader {
|
||||||
/// bits in the stream), true otherwise. When false is returned, the
|
/// bits in the stream), true otherwise. When false is returned, the
|
||||||
/// stream will enter a state where further ReadXXX/SkipXXX
|
/// stream will enter a state where further ReadXXX/SkipXXX
|
||||||
/// operations will always return false unless |num_bits/bytes| is 0.
|
/// operations will always return false unless |num_bits/bytes| is 0.
|
||||||
bool SkipBits(int num_bits);
|
bool SkipBits(size_t num_bits);
|
||||||
|
|
||||||
/// Read one bit then skip the number of bits specified if that bit matches @a
|
/// Read one bit then skip the number of bits specified if that bit matches @a
|
||||||
/// condition.
|
/// condition.
|
||||||
|
@ -66,7 +66,7 @@ class BitReader {
|
||||||
/// be skipped (not enough bits in the stream), true otherwise. When
|
/// be skipped (not enough bits in the stream), true otherwise. When
|
||||||
/// false is returned, the stream will enter a state where further
|
/// false is returned, the stream will enter a state where further
|
||||||
/// ReadXXX/SkipXXX operations will always return false.
|
/// ReadXXX/SkipXXX operations will always return false.
|
||||||
bool SkipBitsConditional(bool condition, int num_bits) {
|
bool SkipBitsConditional(bool condition, size_t num_bits) {
|
||||||
bool condition_read = true;
|
bool condition_read = true;
|
||||||
if (!ReadBits(1, &condition_read))
|
if (!ReadBits(1, &condition_read))
|
||||||
return false;
|
return false;
|
||||||
|
@ -79,19 +79,19 @@ class BitReader {
|
||||||
/// @return false if the current position is not byte aligned or if the given
|
/// @return false if the current position is not byte aligned or if the given
|
||||||
/// number of bytes cannot be skipped (not enough bytes in the
|
/// number of bytes cannot be skipped (not enough bytes in the
|
||||||
/// stream), true otherwise.
|
/// stream), true otherwise.
|
||||||
bool SkipBytes(int num_bytes);
|
bool SkipBytes(size_t num_bytes);
|
||||||
|
|
||||||
/// @return The number of bits available for reading.
|
/// @return The number of bits available for reading.
|
||||||
int bits_available() const {
|
size_t bits_available() const {
|
||||||
return 8 * bytes_left_ + num_remaining_bits_in_curr_byte_;
|
return 8 * bytes_left_ + num_remaining_bits_in_curr_byte_;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @return The current bit position.
|
/// @return The current bit position.
|
||||||
int bit_position() const { return 8 * initial_size_ - bits_available(); }
|
size_t bit_position() const { return 8 * initial_size_ - bits_available(); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Help function used by ReadBits to avoid inlining the bit reading logic.
|
// Help function used by ReadBits to avoid inlining the bit reading logic.
|
||||||
bool ReadBitsInternal(int num_bits, uint64_t* out);
|
bool ReadBitsInternal(size_t num_bits, uint64_t* out);
|
||||||
|
|
||||||
// Advance to the next byte, loading it into curr_byte_.
|
// Advance to the next byte, loading it into curr_byte_.
|
||||||
// If the num_remaining_bits_in_curr_byte_ is 0 after this function returns,
|
// If the num_remaining_bits_in_curr_byte_ is 0 after this function returns,
|
||||||
|
@ -102,18 +102,17 @@ class BitReader {
|
||||||
const uint8_t* data_;
|
const uint8_t* data_;
|
||||||
|
|
||||||
// Initial size of the input data.
|
// Initial size of the input data.
|
||||||
// TODO(kqyang): Use size_t instead of off_t instead.
|
size_t initial_size_;
|
||||||
off_t initial_size_;
|
|
||||||
|
|
||||||
// Bytes left in the stream (without the curr_byte_).
|
// Bytes left in the stream (without the curr_byte_).
|
||||||
off_t bytes_left_;
|
size_t bytes_left_;
|
||||||
|
|
||||||
// Contents of the current byte; first unread bit starting at position
|
// Contents of the current byte; first unread bit starting at position
|
||||||
// 8 - num_remaining_bits_in_curr_byte_ from MSB.
|
// 8 - num_remaining_bits_in_curr_byte_ from MSB.
|
||||||
uint8_t curr_byte_;
|
uint8_t curr_byte_;
|
||||||
|
|
||||||
// Number of bits remaining in curr_byte_
|
// Number of bits remaining in curr_byte_
|
||||||
int num_remaining_bits_in_curr_byte_;
|
size_t num_remaining_bits_in_curr_byte_;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DISALLOW_COPY_AND_ASSIGN(BitReader);
|
DISALLOW_COPY_AND_ASSIGN(BitReader);
|
||||||
|
|
|
@ -20,8 +20,8 @@ TEST(BitReaderTest, NormalOperationTest) {
|
||||||
EXPECT_EQ(0, value8);
|
EXPECT_EQ(0, value8);
|
||||||
EXPECT_TRUE(reader1.ReadBits(8, &value8));
|
EXPECT_TRUE(reader1.ReadBits(8, &value8));
|
||||||
EXPECT_EQ(0xab, value8); // 1010 1011
|
EXPECT_EQ(0xab, value8); // 1010 1011
|
||||||
EXPECT_EQ(39, reader1.bits_available());
|
EXPECT_EQ(39u, reader1.bits_available());
|
||||||
EXPECT_EQ(9, reader1.bit_position());
|
EXPECT_EQ(9u, reader1.bit_position());
|
||||||
EXPECT_TRUE(reader1.ReadBits(7, &value64));
|
EXPECT_TRUE(reader1.ReadBits(7, &value64));
|
||||||
EXPECT_TRUE(reader1.ReadBits(32, &value64));
|
EXPECT_TRUE(reader1.ReadBits(32, &value64));
|
||||||
EXPECT_EQ(0x55995599u, value64);
|
EXPECT_EQ(0x55995599u, value64);
|
||||||
|
@ -64,8 +64,8 @@ TEST(BitReaderTest, SkipBitsTest) {
|
||||||
EXPECT_TRUE(reader1.SkipBytes(0));
|
EXPECT_TRUE(reader1.SkipBytes(0));
|
||||||
EXPECT_TRUE(reader1.SkipBytes(1));
|
EXPECT_TRUE(reader1.SkipBytes(1));
|
||||||
EXPECT_TRUE(reader1.SkipBits(52));
|
EXPECT_TRUE(reader1.SkipBits(52));
|
||||||
EXPECT_EQ(20, reader1.bits_available());
|
EXPECT_EQ(20u, reader1.bits_available());
|
||||||
EXPECT_EQ(100, reader1.bit_position());
|
EXPECT_EQ(100u, reader1.bit_position());
|
||||||
EXPECT_TRUE(reader1.ReadBits(4, &value8));
|
EXPECT_TRUE(reader1.ReadBits(4, &value8));
|
||||||
EXPECT_EQ(13, value8);
|
EXPECT_EQ(13, value8);
|
||||||
EXPECT_FALSE(reader1.SkipBits(100));
|
EXPECT_FALSE(reader1.SkipBits(100));
|
||||||
|
@ -77,13 +77,13 @@ TEST(BitReaderTest, SkipBitsConditionalTest) {
|
||||||
uint8_t buffer[] = {0x8a, 0x12};
|
uint8_t buffer[] = {0x8a, 0x12};
|
||||||
BitReader reader(buffer, sizeof(buffer));
|
BitReader reader(buffer, sizeof(buffer));
|
||||||
EXPECT_TRUE(reader.SkipBitsConditional(false, 2));
|
EXPECT_TRUE(reader.SkipBitsConditional(false, 2));
|
||||||
EXPECT_EQ(1, reader.bit_position()); // Not skipped.
|
EXPECT_EQ(1u, reader.bit_position()); // Not skipped.
|
||||||
EXPECT_TRUE(reader.SkipBitsConditional(false, 3));
|
EXPECT_TRUE(reader.SkipBitsConditional(false, 3));
|
||||||
EXPECT_EQ(5, reader.bit_position()); // Skipped.
|
EXPECT_EQ(5u, reader.bit_position()); // Skipped.
|
||||||
EXPECT_TRUE(reader.SkipBitsConditional(true, 2));
|
EXPECT_TRUE(reader.SkipBitsConditional(true, 2));
|
||||||
EXPECT_EQ(6, reader.bit_position()); // Not skipped.
|
EXPECT_EQ(6u, reader.bit_position()); // Not skipped.
|
||||||
EXPECT_TRUE(reader.SkipBitsConditional(true, 5));
|
EXPECT_TRUE(reader.SkipBitsConditional(true, 5));
|
||||||
EXPECT_EQ(12, reader.bit_position()); // Skipped.
|
EXPECT_EQ(12u, reader.bit_position()); // Skipped.
|
||||||
EXPECT_TRUE(reader.SkipBits(4));
|
EXPECT_TRUE(reader.SkipBits(4));
|
||||||
EXPECT_FALSE(reader.SkipBits(1));
|
EXPECT_FALSE(reader.SkipBits(1));
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,7 +74,7 @@ static bool StartsWith(const uint8_t* buffer,
|
||||||
|
|
||||||
// Helper function to read up to 64 bits from a bit stream.
|
// Helper function to read up to 64 bits from a bit stream.
|
||||||
static uint64_t ReadBits(BitReader* reader, int num_bits) {
|
static uint64_t ReadBits(BitReader* reader, int num_bits) {
|
||||||
DCHECK_GE(reader->bits_available(), num_bits);
|
DCHECK_GE(static_cast<int>(reader->bits_available()), num_bits);
|
||||||
DCHECK((num_bits > 0) && (num_bits <= 64));
|
DCHECK((num_bits > 0) && (num_bits <= 64));
|
||||||
uint64_t value;
|
uint64_t value;
|
||||||
reader->ReadBits(num_bits, &value);
|
reader->ReadBits(num_bits, &value);
|
||||||
|
@ -1223,7 +1223,7 @@ static int GetElementId(BitReader* reader) {
|
||||||
for (int i = 0; i < 4; ++i) {
|
for (int i = 0; i < 4; ++i) {
|
||||||
num_bits_to_read += 7;
|
num_bits_to_read += 7;
|
||||||
if (ReadBits(reader, 1) == 1) {
|
if (ReadBits(reader, 1) == 1) {
|
||||||
if (reader->bits_available() < num_bits_to_read)
|
if (static_cast<int>(reader->bits_available()) < num_bits_to_read)
|
||||||
break;
|
break;
|
||||||
// prefix[] adds back the bits read individually.
|
// prefix[] adds back the bits read individually.
|
||||||
return ReadBits(reader, num_bits_to_read) | prefix[i];
|
return ReadBits(reader, num_bits_to_read) | prefix[i];
|
||||||
|
@ -1244,7 +1244,7 @@ static uint64_t GetVint(BitReader* reader) {
|
||||||
for (int i = 0; i < 8; ++i) {
|
for (int i = 0; i < 8; ++i) {
|
||||||
num_bits_to_read += 7;
|
num_bits_to_read += 7;
|
||||||
if (ReadBits(reader, 1) == 1) {
|
if (ReadBits(reader, 1) == 1) {
|
||||||
if (reader->bits_available() < num_bits_to_read)
|
if (static_cast<int>(reader->bits_available()) < num_bits_to_read)
|
||||||
break;
|
break;
|
||||||
return ReadBits(reader, num_bits_to_read);
|
return ReadBits(reader, num_bits_to_read);
|
||||||
}
|
}
|
||||||
|
@ -1268,7 +1268,7 @@ static bool CheckWebm(const uint8_t* buffer, int buffer_size) {
|
||||||
|
|
||||||
// Get the header size, and ensure there are enough bits to check.
|
// Get the header size, and ensure there are enough bits to check.
|
||||||
int header_size = GetVint(&reader);
|
int header_size = GetVint(&reader);
|
||||||
RCHECK(reader.bits_available() / 8 >= header_size);
|
RCHECK(static_cast<int>(reader.bits_available()) / 8 >= header_size);
|
||||||
|
|
||||||
// Loop through the header.
|
// Loop through the header.
|
||||||
while (reader.bits_available() > 0) {
|
while (reader.bits_available() > 0) {
|
||||||
|
|
|
@ -190,8 +190,9 @@ TEST(ContainerNamesTest, WebVtt) {
|
||||||
kWebVtt + arraysize(kWebVtt));
|
kWebVtt + arraysize(kWebVtt));
|
||||||
|
|
||||||
EXPECT_EQ(CONTAINER_WEBVTT,
|
EXPECT_EQ(CONTAINER_WEBVTT,
|
||||||
DetermineContainer(webvtt_with_utf8_byte_order_mark.data(),
|
DetermineContainer(
|
||||||
webvtt_with_utf8_byte_order_mark.size()));
|
webvtt_with_utf8_byte_order_mark.data(),
|
||||||
|
static_cast<int>(webvtt_with_utf8_byte_order_mark.size())));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(ContainerNamesTest, FileCheckOGG) {
|
TEST(ContainerNamesTest, FileCheckOGG) {
|
||||||
|
|
|
@ -89,7 +89,7 @@ TEST(ProducerConsumerQueueTest, PeekOnPoppedElement) {
|
||||||
|
|
||||||
TEST(ProducerConsumerQueueTest, PushWithTimeout) {
|
TEST(ProducerConsumerQueueTest, PushWithTimeout) {
|
||||||
std::unique_ptr<base::ElapsedTimer> timer;
|
std::unique_ptr<base::ElapsedTimer> timer;
|
||||||
ProducerConsumerQueue<int> queue(kCapacity);
|
ProducerConsumerQueue<size_t> queue(kCapacity);
|
||||||
|
|
||||||
for (size_t i = 0; i < kCapacity; ++i) {
|
for (size_t i = 0; i < kCapacity; ++i) {
|
||||||
timer.reset(new base::ElapsedTimer());
|
timer.reset(new base::ElapsedTimer());
|
||||||
|
|
|
@ -169,13 +169,13 @@ struct H264SliceHeader {
|
||||||
const uint8_t* nalu_data;
|
const uint8_t* nalu_data;
|
||||||
|
|
||||||
// Size of whole nalu unit.
|
// Size of whole nalu unit.
|
||||||
off_t nalu_size;
|
size_t nalu_size;
|
||||||
|
|
||||||
// This is the size of the slice header not including the nalu header byte.
|
// This is the size of the slice header not including the nalu header byte.
|
||||||
// Sturcture: |NALU Header| Slice Header | Slice Data |
|
// Sturcture: |NALU Header| Slice Header | Slice Data |
|
||||||
// Size: |<- 8bits ->|<- header_bit_size ->|<- Rest of nalu ->|
|
// Size: |<- 8bits ->|<- header_bit_size ->|<- Rest of nalu ->|
|
||||||
// Note that this is not a field in the H.264 spec.
|
// Note that this is not a field in the H.264 spec.
|
||||||
off_t header_bit_size;
|
size_t header_bit_size;
|
||||||
|
|
||||||
int first_mb_in_slice;
|
int first_mb_in_slice;
|
||||||
int slice_type;
|
int slice_type;
|
||||||
|
|
|
@ -222,7 +222,7 @@ struct H265SliceHeader {
|
||||||
// Sturcture: |NALU Header | Slice Header | Slice Data |
|
// Sturcture: |NALU Header | Slice Header | Slice Data |
|
||||||
// Size: |<- 16bits ->|<- header_bit_size ->|<- Rest of nalu ->|
|
// Size: |<- 16bits ->|<- header_bit_size ->|<- Rest of nalu ->|
|
||||||
// Note that this is not a field in the H.265 spec.
|
// Note that this is not a field in the H.265 spec.
|
||||||
int header_bit_size = 0;
|
size_t header_bit_size = 0;
|
||||||
|
|
||||||
bool first_slice_segment_in_pic_flag = false;
|
bool first_slice_segment_in_pic_flag = false;
|
||||||
bool no_output_of_prior_pics_flag = false;
|
bool no_output_of_prior_pics_flag = false;
|
||||||
|
|
|
@ -55,7 +55,7 @@ TEST(H265ParserTest, ParseSliceHeader) {
|
||||||
EXPECT_EQ(8, header.slice_qp_delta);
|
EXPECT_EQ(8, header.slice_qp_delta);
|
||||||
EXPECT_FALSE(header.cu_chroma_qp_offset_enabled_flag);
|
EXPECT_FALSE(header.cu_chroma_qp_offset_enabled_flag);
|
||||||
EXPECT_EQ(5, header.num_entry_point_offsets);
|
EXPECT_EQ(5, header.num_entry_point_offsets);
|
||||||
EXPECT_EQ(85, header.header_bit_size);
|
EXPECT_EQ(85u, header.header_bit_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(H265ParserTest, ParseSliceHeader_NonIDR) {
|
TEST(H265ParserTest, ParseSliceHeader_NonIDR) {
|
||||||
|
@ -81,7 +81,7 @@ TEST(H265ParserTest, ParseSliceHeader_NonIDR) {
|
||||||
EXPECT_FALSE(header.dependent_slice_segment_flag);
|
EXPECT_FALSE(header.dependent_slice_segment_flag);
|
||||||
EXPECT_EQ(1, header.slice_type);
|
EXPECT_EQ(1, header.slice_type);
|
||||||
EXPECT_EQ(5, header.num_entry_point_offsets);
|
EXPECT_EQ(5, header.num_entry_point_offsets);
|
||||||
EXPECT_EQ(124, header.header_bit_size);
|
EXPECT_EQ(124u, header.header_bit_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(H265ParserTest, ParseSps) {
|
TEST(H265ParserTest, ParseSps) {
|
||||||
|
|
|
@ -195,7 +195,7 @@ bool NalUnitToByteStreamConverter::ConvertUnitToByteStreamWithSubsamples(
|
||||||
if (is_key_frame)
|
if (is_key_frame)
|
||||||
buffer_writer.AppendVector(decoder_configuration_in_byte_stream_);
|
buffer_writer.AppendVector(decoder_configuration_in_byte_stream_);
|
||||||
|
|
||||||
int adjustment = buffer_writer.Size();
|
int adjustment = static_cast<int>(buffer_writer.Size());
|
||||||
size_t subsample_id = 0;
|
size_t subsample_id = 0;
|
||||||
|
|
||||||
NaluReader nalu_reader(Nalu::kH264, nalu_length_size_, sample, sample_size);
|
NaluReader nalu_reader(Nalu::kH264, nalu_length_size_, sample, sample_size);
|
||||||
|
@ -245,7 +245,7 @@ bool NalUnitToByteStreamConverter::ConvertUnitToByteStreamWithSubsamples(
|
||||||
DCHECK_LT(old_nalu_size, subsamples->at(subsample_id).clear_bytes);
|
DCHECK_LT(old_nalu_size, subsamples->at(subsample_id).clear_bytes);
|
||||||
subsamples->at(subsample_id).clear_bytes -=
|
subsamples->at(subsample_id).clear_bytes -=
|
||||||
static_cast<uint16_t>(old_nalu_size);
|
static_cast<uint16_t>(old_nalu_size);
|
||||||
adjustment += old_nalu_size;
|
adjustment += static_cast<int>(old_nalu_size);
|
||||||
} else {
|
} else {
|
||||||
// Apply the adjustment on the current subsample, reset the
|
// Apply the adjustment on the current subsample, reset the
|
||||||
// adjustment and move to the next subsample.
|
// adjustment and move to the next subsample.
|
||||||
|
|
|
@ -15,10 +15,9 @@ namespace media {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
int NumBitsToNumBytes(int size_in_bits) {
|
size_t NumBitsToNumBytes(size_t size_in_bits) {
|
||||||
// Round-up division.
|
// Round-up division.
|
||||||
DCHECK_GE(size_in_bits, 0);
|
return (size_in_bits + 7) >> 3;
|
||||||
return (size_in_bits - 1) / 8 + 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
|
@ -63,8 +63,8 @@ static bool LookForSyncWord(const uint8_t* raw_es,
|
||||||
// The layer field (2 bits) must be set to 0.
|
// The layer field (2 bits) must be set to 0.
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
int frame_size =
|
int frame_size = static_cast<int>(
|
||||||
mp2t::AdtsHeader::GetAdtsFrameSize(cur_buf, kAdtsHeaderMinSize);
|
mp2t::AdtsHeader::GetAdtsFrameSize(cur_buf, kAdtsHeaderMinSize));
|
||||||
if (frame_size < kAdtsHeaderMinSize) {
|
if (frame_size < kAdtsHeaderMinSize) {
|
||||||
// Too short to be an ADTS frame.
|
// Too short to be an ADTS frame.
|
||||||
continue;
|
continue;
|
||||||
|
@ -117,7 +117,7 @@ bool EsParserAdts::Parse(const uint8_t* buf,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copy the input data to the ES buffer.
|
// Copy the input data to the ES buffer.
|
||||||
es_byte_queue_.Push(buf, size);
|
es_byte_queue_.Push(buf, static_cast<int>(size));
|
||||||
es_byte_queue_.Peek(&raw_es, &raw_es_size);
|
es_byte_queue_.Peek(&raw_es, &raw_es_size);
|
||||||
|
|
||||||
// Look for every ADTS frame in the ES buffer starting at offset = 0
|
// Look for every ADTS frame in the ES buffer starting at offset = 0
|
||||||
|
|
|
@ -193,8 +193,8 @@ void EsParserH264Test::ProcessPesPackets(
|
||||||
pts = au_idx * kMpegTicksPerFrame;
|
pts = au_idx * kMpegTicksPerFrame;
|
||||||
}
|
}
|
||||||
|
|
||||||
ASSERT_TRUE(
|
ASSERT_TRUE(es_parser.Parse(&stream_[cur_pes_offset],
|
||||||
es_parser.Parse(&stream_[cur_pes_offset], cur_pes_size, pts, dts));
|
static_cast<int>(cur_pes_size), pts, dts));
|
||||||
}
|
}
|
||||||
es_parser.Flush();
|
es_parser.Flush();
|
||||||
}
|
}
|
||||||
|
|
|
@ -129,7 +129,7 @@ class TestableEsParser : public EsParserH26x {
|
||||||
|
|
||||||
std::vector<uint8_t> CreateNalu(Nalu::CodecType codec_type,
|
std::vector<uint8_t> CreateNalu(Nalu::CodecType codec_type,
|
||||||
H26xNaluType type,
|
H26xNaluType type,
|
||||||
int i) {
|
uint8_t i) {
|
||||||
std::vector<uint8_t> ret;
|
std::vector<uint8_t> ret;
|
||||||
if (codec_type == Nalu::kH264) {
|
if (codec_type == Nalu::kH264) {
|
||||||
ret.resize(3);
|
ret.resize(3);
|
||||||
|
@ -215,7 +215,8 @@ void EsParserH26xTest::RunTest(Nalu::CodecType codec_type,
|
||||||
seen_key_frame = true;
|
seen_key_frame = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<uint8_t> es_data = CreateNalu(codec_type, types[k], k);
|
std::vector<uint8_t> es_data =
|
||||||
|
CreateNalu(codec_type, types[k], static_cast<uint8_t>(k));
|
||||||
cur_sample_data.push_back(0);
|
cur_sample_data.push_back(0);
|
||||||
cur_sample_data.push_back(0);
|
cur_sample_data.push_back(0);
|
||||||
cur_sample_data.push_back(0);
|
cur_sample_data.push_back(0);
|
||||||
|
@ -235,7 +236,8 @@ void EsParserH26xTest::RunTest(Nalu::CodecType codec_type,
|
||||||
while (offset < es_data.size()) {
|
while (offset < es_data.size()) {
|
||||||
// Insert the data in parts to test partial data searches.
|
// Insert the data in parts to test partial data searches.
|
||||||
size = std::min(size + 1, es_data.size() - offset);
|
size = std::min(size + 1, es_data.size() - offset);
|
||||||
ASSERT_TRUE(es_parser.Parse(&es_data[offset], size, pts, dts));
|
ASSERT_TRUE(es_parser.Parse(&es_data[offset], static_cast<int>(size),
|
||||||
|
pts, dts));
|
||||||
offset += size;
|
offset += size;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@ class Mp2tMediaParserTest : public testing::Test {
|
||||||
int64_t video_max_dts_;
|
int64_t video_max_dts_;
|
||||||
|
|
||||||
bool AppendData(const uint8_t* data, size_t length) {
|
bool AppendData(const uint8_t* data, size_t length) {
|
||||||
return parser_->Parse(data, length);
|
return parser_->Parse(data, static_cast<int>(length));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AppendDataInPieces(const uint8_t* data,
|
bool AppendDataInPieces(const uint8_t* data,
|
||||||
|
|
|
@ -179,7 +179,7 @@ const uint8_t kPrivateDataIndicatorDescriptorEncryptedH264[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
void WritePmtToBuffer(const uint8_t* pmt,
|
void WritePmtToBuffer(const uint8_t* pmt,
|
||||||
int pmt_size,
|
size_t pmt_size,
|
||||||
ContinuityCounter* continuity_counter,
|
ContinuityCounter* continuity_counter,
|
||||||
BufferWriter* writer) {
|
BufferWriter* writer) {
|
||||||
const bool kPayloadUnitStartIndicator = true;
|
const bool kPayloadUnitStartIndicator = true;
|
||||||
|
|
|
@ -138,7 +138,8 @@ bool TsPacket::ParseHeader(const uint8_t* buf) {
|
||||||
bool TsPacket::ParseAdaptationField(BitReader* bit_reader,
|
bool TsPacket::ParseAdaptationField(BitReader* bit_reader,
|
||||||
int adaptation_field_length) {
|
int adaptation_field_length) {
|
||||||
DCHECK_GT(adaptation_field_length, 0);
|
DCHECK_GT(adaptation_field_length, 0);
|
||||||
int adaptation_field_start_marker = bit_reader->bits_available() / 8;
|
int adaptation_field_start_marker =
|
||||||
|
static_cast<int>(bit_reader->bits_available()) / 8;
|
||||||
|
|
||||||
int discontinuity_indicator;
|
int discontinuity_indicator;
|
||||||
int random_access_indicator;
|
int random_access_indicator;
|
||||||
|
@ -196,8 +197,10 @@ bool TsPacket::ParseAdaptationField(BitReader* bit_reader,
|
||||||
}
|
}
|
||||||
|
|
||||||
// The rest of the adaptation field should be stuffing bytes.
|
// The rest of the adaptation field should be stuffing bytes.
|
||||||
int adaptation_field_remaining_size = adaptation_field_length -
|
int adaptation_field_remaining_size =
|
||||||
(adaptation_field_start_marker - bit_reader->bits_available() / 8);
|
adaptation_field_length -
|
||||||
|
(adaptation_field_start_marker -
|
||||||
|
static_cast<int>(bit_reader->bits_available()) / 8);
|
||||||
RCHECK(adaptation_field_remaining_size >= 0);
|
RCHECK(adaptation_field_remaining_size >= 0);
|
||||||
for (int k = 0; k < adaptation_field_remaining_size; k++) {
|
for (int k = 0; k < adaptation_field_remaining_size; k++) {
|
||||||
int stuffing_byte;
|
int stuffing_byte;
|
||||||
|
|
|
@ -74,10 +74,10 @@ void WriteAdaptationField(bool has_pcr,
|
||||||
|
|
||||||
// The size of all leading flags (not including the adaptation_field_length).
|
// The size of all leading flags (not including the adaptation_field_length).
|
||||||
const int kAdaptationFieldHeaderSize = 1;
|
const int kAdaptationFieldHeaderSize = 1;
|
||||||
int adaptation_field_length =
|
size_t adaptation_field_length =
|
||||||
kAdaptationFieldHeaderSize + (has_pcr ? kPcrFieldsSize : 0);
|
kAdaptationFieldHeaderSize + (has_pcr ? kPcrFieldsSize : 0);
|
||||||
if (remaining_data_size < kTsPacketMaximumPayloadSize) {
|
if (remaining_data_size < kTsPacketMaximumPayloadSize) {
|
||||||
const int current_ts_size = kTsPacketHeaderSize + remaining_data_size +
|
const size_t current_ts_size = kTsPacketHeaderSize + remaining_data_size +
|
||||||
adaptation_field_length +
|
adaptation_field_length +
|
||||||
kAdaptationFieldLengthSize;
|
kAdaptationFieldLengthSize;
|
||||||
if (current_ts_size < kTsPacketSize) {
|
if (current_ts_size < kTsPacketSize) {
|
||||||
|
@ -86,7 +86,7 @@ void WriteAdaptationField(bool has_pcr,
|
||||||
}
|
}
|
||||||
|
|
||||||
writer->AppendInt(static_cast<uint8_t>(adaptation_field_length));
|
writer->AppendInt(static_cast<uint8_t>(adaptation_field_length));
|
||||||
int remaining_bytes = adaptation_field_length;
|
int remaining_bytes = static_cast<int>(adaptation_field_length);
|
||||||
writer->AppendInt(static_cast<uint8_t>(
|
writer->AppendInt(static_cast<uint8_t>(
|
||||||
// All flags except PCR_flag are 0.
|
// All flags except PCR_flag are 0.
|
||||||
static_cast<uint8_t>(has_pcr) << 4));
|
static_cast<uint8_t>(has_pcr) << 4));
|
||||||
|
@ -144,7 +144,7 @@ void WritePayloadToBufferWriter(const uint8_t* payload,
|
||||||
WriteAdaptationField(has_pcr, pcr_base, bytes_left, writer);
|
WriteAdaptationField(has_pcr, pcr_base, bytes_left, writer);
|
||||||
const size_t bytes_for_adaptation_field = writer->Size() - before;
|
const size_t bytes_for_adaptation_field = writer->Size() - before;
|
||||||
|
|
||||||
const int write_bytes =
|
const size_t write_bytes =
|
||||||
kTsPacketMaximumPayloadSize - bytes_for_adaptation_field;
|
kTsPacketMaximumPayloadSize - bytes_for_adaptation_field;
|
||||||
writer->AppendArray(payload + payload_bytes_written, write_bytes);
|
writer->AppendArray(payload + payload_bytes_written, write_bytes);
|
||||||
payload_bytes_written += write_bytes;
|
payload_bytes_written += write_bytes;
|
||||||
|
|
|
@ -195,7 +195,7 @@ bool TsSectionPes::ParseInternal(const uint8_t* raw_pes, int raw_pes_size) {
|
||||||
RCHECK(packet_start_code_prefix == kPesStartCode);
|
RCHECK(packet_start_code_prefix == kPesStartCode);
|
||||||
DVLOG(LOG_LEVEL_PES) << "stream_id=" << std::hex << stream_id << std::dec;
|
DVLOG(LOG_LEVEL_PES) << "stream_id=" << std::hex << stream_id << std::dec;
|
||||||
if (pes_packet_length == 0)
|
if (pes_packet_length == 0)
|
||||||
pes_packet_length = bit_reader.bits_available() / 8;
|
pes_packet_length = static_cast<int>(bit_reader.bits_available()) / 8;
|
||||||
|
|
||||||
// Ignore the PES for unknown stream IDs.
|
// Ignore the PES for unknown stream IDs.
|
||||||
// See ITU H.222 Table 2-22 "Stream_id assignments"
|
// See ITU H.222 Table 2-22 "Stream_id assignments"
|
||||||
|
@ -234,7 +234,7 @@ bool TsSectionPes::ParseInternal(const uint8_t* raw_pes, int raw_pes_size) {
|
||||||
RCHECK(bit_reader.ReadBits(1, &pes_crc_flag));
|
RCHECK(bit_reader.ReadBits(1, &pes_crc_flag));
|
||||||
RCHECK(bit_reader.ReadBits(1, &pes_extension_flag));
|
RCHECK(bit_reader.ReadBits(1, &pes_extension_flag));
|
||||||
RCHECK(bit_reader.ReadBits(8, &pes_header_data_length));
|
RCHECK(bit_reader.ReadBits(8, &pes_header_data_length));
|
||||||
int pes_header_start_size = bit_reader.bits_available() / 8;
|
int pes_header_start_size = static_cast<int>(bit_reader.bits_available()) / 8;
|
||||||
|
|
||||||
// Compute the size and the offset of the ES payload.
|
// Compute the size and the offset of the ES payload.
|
||||||
// "6" for the 6 bytes read before and including |pes_packet_length|.
|
// "6" for the 6 bytes read before and including |pes_packet_length|.
|
||||||
|
@ -287,9 +287,11 @@ bool TsSectionPes::ParseInternal(const uint8_t* raw_pes, int raw_pes_size) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Discard the rest of the PES packet header.
|
// Discard the rest of the PES packet header.
|
||||||
DCHECK_EQ(bit_reader.bits_available() % 8, 0);
|
DCHECK_EQ(bit_reader.bits_available() % 8, 0u);
|
||||||
int pes_header_remaining_size = pes_header_data_length -
|
int pes_header_remaining_size =
|
||||||
(pes_header_start_size - bit_reader.bits_available() / 8);
|
pes_header_data_length -
|
||||||
|
(pes_header_start_size -
|
||||||
|
static_cast<int>(bit_reader.bits_available()) / 8);
|
||||||
RCHECK(pes_header_remaining_size >= 0);
|
RCHECK(pes_header_remaining_size >= 0);
|
||||||
|
|
||||||
// Read the PES packet.
|
// Read the PES packet.
|
||||||
|
|
|
@ -38,7 +38,7 @@ bool TsSectionPmt::ParsePsiSection(BitReader* bit_reader) {
|
||||||
RCHECK(bit_reader->ReadBits(1, &dummy_zero));
|
RCHECK(bit_reader->ReadBits(1, &dummy_zero));
|
||||||
RCHECK(bit_reader->ReadBits(2, &reserved));
|
RCHECK(bit_reader->ReadBits(2, &reserved));
|
||||||
RCHECK(bit_reader->ReadBits(12, §ion_length));
|
RCHECK(bit_reader->ReadBits(12, §ion_length));
|
||||||
int section_start_marker = bit_reader->bits_available() / 8;
|
int section_start_marker = static_cast<int>(bit_reader->bits_available()) / 8;
|
||||||
|
|
||||||
RCHECK(bit_reader->ReadBits(16, &program_number));
|
RCHECK(bit_reader->ReadBits(16, &program_number));
|
||||||
RCHECK(bit_reader->ReadBits(2, &reserved));
|
RCHECK(bit_reader->ReadBits(2, &reserved));
|
||||||
|
@ -76,7 +76,8 @@ bool TsSectionPmt::ParsePsiSection(BitReader* bit_reader) {
|
||||||
// (4 bytes = size of the CRC).
|
// (4 bytes = size of the CRC).
|
||||||
int pid_map_end_marker = section_start_marker - section_length + 4;
|
int pid_map_end_marker = section_start_marker - section_length + 4;
|
||||||
std::map<int, int> pid_map;
|
std::map<int, int> pid_map;
|
||||||
while (bit_reader->bits_available() > 8 * pid_map_end_marker) {
|
while (static_cast<int>(bit_reader->bits_available()) >
|
||||||
|
8 * pid_map_end_marker) {
|
||||||
int stream_type;
|
int stream_type;
|
||||||
int reserved;
|
int reserved;
|
||||||
int pid_es;
|
int pid_es;
|
||||||
|
|
|
@ -135,10 +135,9 @@ bool WritePesToFile(const PesPacket& pes,
|
||||||
pes_packet_length > kMaxPesPacketLengthValue ? 0 : pes_packet_length));
|
pes_packet_length > kMaxPesPacketLengthValue ? 0 : pes_packet_length));
|
||||||
first_ts_packet_buffer.AppendBuffer(pes_header_writer);
|
first_ts_packet_buffer.AppendBuffer(pes_header_writer);
|
||||||
|
|
||||||
const int available_payload =
|
const size_t available_payload =
|
||||||
kTsPacketMaxPayloadWithPcr - first_ts_packet_buffer.Size();
|
kTsPacketMaxPayloadWithPcr - first_ts_packet_buffer.Size();
|
||||||
const int bytes_consumed =
|
const size_t bytes_consumed = std::min(pes.data().size(), available_payload);
|
||||||
std::min(static_cast<int>(pes.data().size()), available_payload);
|
|
||||||
first_ts_packet_buffer.AppendArray(pes.data().data(), bytes_consumed);
|
first_ts_packet_buffer.AppendArray(pes.data().data(), bytes_consumed);
|
||||||
|
|
||||||
BufferWriter output_writer;
|
BufferWriter output_writer;
|
||||||
|
|
|
@ -48,7 +48,7 @@ void Box::WriteHeader(BufferWriter* writer) {
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t Box::ComputeSize() {
|
uint32_t Box::ComputeSize() {
|
||||||
box_size_ = ComputeSizeInternal();
|
box_size_ = static_cast<uint32_t>(ComputeSizeInternal());
|
||||||
return box_size_;
|
return box_size_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -67,7 +67,7 @@ struct Box {
|
||||||
virtual bool ReadWriteInternal(BoxBuffer* buffer) = 0;
|
virtual bool ReadWriteInternal(BoxBuffer* buffer) = 0;
|
||||||
// Compute the size of this box. A value of 0 should be returned if the box
|
// Compute the size of this box. A value of 0 should be returned if the box
|
||||||
// should not be written. Note that this function won't update box size.
|
// should not be written. Note that this function won't update box size.
|
||||||
virtual uint32_t ComputeSizeInternal() = 0;
|
virtual size_t ComputeSizeInternal() = 0;
|
||||||
|
|
||||||
// We don't support 64-bit box sizes. 32-bit should be large enough for our
|
// We don't support 64-bit box sizes. 32-bit should be large enough for our
|
||||||
// current needs.
|
// current needs.
|
||||||
|
|
|
@ -154,7 +154,7 @@ bool FileType::ReadWriteInternal(BoxBuffer* buffer) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t FileType::ComputeSizeInternal() {
|
size_t FileType::ComputeSizeInternal() {
|
||||||
return HeaderSize() + kFourCCSize + sizeof(minor_version) +
|
return HeaderSize() + kFourCCSize + sizeof(minor_version) +
|
||||||
kFourCCSize * compatible_brands.size();
|
kFourCCSize * compatible_brands.size();
|
||||||
}
|
}
|
||||||
|
@ -178,7 +178,7 @@ bool ProtectionSystemSpecificHeader::ReadWriteInternal(BoxBuffer* buffer) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t ProtectionSystemSpecificHeader::ComputeSizeInternal() {
|
size_t ProtectionSystemSpecificHeader::ComputeSizeInternal() {
|
||||||
return raw_box.size();
|
return raw_box.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -191,7 +191,7 @@ bool SampleAuxiliaryInformationOffset::ReadWriteInternal(BoxBuffer* buffer) {
|
||||||
if (flags & 1)
|
if (flags & 1)
|
||||||
RCHECK(buffer->IgnoreBytes(8)); // aux_info_type and parameter.
|
RCHECK(buffer->IgnoreBytes(8)); // aux_info_type and parameter.
|
||||||
|
|
||||||
uint32_t count = offsets.size();
|
uint32_t count = static_cast<uint32_t>(offsets.size());
|
||||||
RCHECK(buffer->ReadWriteUInt32(&count));
|
RCHECK(buffer->ReadWriteUInt32(&count));
|
||||||
offsets.resize(count);
|
offsets.resize(count);
|
||||||
|
|
||||||
|
@ -201,7 +201,7 @@ bool SampleAuxiliaryInformationOffset::ReadWriteInternal(BoxBuffer* buffer) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t SampleAuxiliaryInformationOffset::ComputeSizeInternal() {
|
size_t SampleAuxiliaryInformationOffset::ComputeSizeInternal() {
|
||||||
// This box is optional. Skip it if it is empty.
|
// This box is optional. Skip it if it is empty.
|
||||||
if (offsets.size() == 0)
|
if (offsets.size() == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -226,7 +226,7 @@ bool SampleAuxiliaryInformationSize::ReadWriteInternal(BoxBuffer* buffer) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t SampleAuxiliaryInformationSize::ComputeSizeInternal() {
|
size_t SampleAuxiliaryInformationSize::ComputeSizeInternal() {
|
||||||
// This box is optional. Skip it if it is empty.
|
// This box is optional. Skip it if it is empty.
|
||||||
if (sample_count == 0)
|
if (sample_count == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -290,10 +290,11 @@ bool SampleEncryptionEntry::ParseFromBuffer(uint8_t iv_size,
|
||||||
uint32_t SampleEncryptionEntry::ComputeSize() const {
|
uint32_t SampleEncryptionEntry::ComputeSize() const {
|
||||||
const uint32_t subsample_entry_size = sizeof(uint16_t) + sizeof(uint32_t);
|
const uint32_t subsample_entry_size = sizeof(uint16_t) + sizeof(uint32_t);
|
||||||
const uint16_t subsample_count = static_cast<uint16_t>(subsamples.size());
|
const uint16_t subsample_count = static_cast<uint16_t>(subsamples.size());
|
||||||
return initialization_vector.size() +
|
return static_cast<uint32_t>(
|
||||||
(subsample_count > 0 ? (sizeof(subsample_count) +
|
initialization_vector.size() +
|
||||||
subsample_entry_size * subsample_count)
|
(subsample_count > 0
|
||||||
: 0);
|
? (sizeof(subsample_count) + subsample_entry_size * subsample_count)
|
||||||
|
: 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t SampleEncryptionEntry::GetTotalSizeOfSubsamples() const {
|
uint32_t SampleEncryptionEntry::GetTotalSizeOfSubsamples() const {
|
||||||
|
@ -325,7 +326,8 @@ bool SampleEncryption::ReadWriteInternal(BoxBuffer* buffer) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t sample_count = sample_encryption_entries.size();
|
uint32_t sample_count =
|
||||||
|
static_cast<uint32_t>(sample_encryption_entries.size());
|
||||||
RCHECK(buffer->ReadWriteUInt32(&sample_count));
|
RCHECK(buffer->ReadWriteUInt32(&sample_count));
|
||||||
|
|
||||||
sample_encryption_entries.resize(sample_count);
|
sample_encryption_entries.resize(sample_count);
|
||||||
|
@ -336,15 +338,16 @@ bool SampleEncryption::ReadWriteInternal(BoxBuffer* buffer) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t SampleEncryption::ComputeSizeInternal() {
|
size_t SampleEncryption::ComputeSizeInternal() {
|
||||||
const uint32_t sample_count = sample_encryption_entries.size();
|
const uint32_t sample_count =
|
||||||
|
static_cast<uint32_t>(sample_encryption_entries.size());
|
||||||
if (sample_count == 0) {
|
if (sample_count == 0) {
|
||||||
// Sample encryption box is optional. Skip it if it is empty.
|
// Sample encryption box is optional. Skip it if it is empty.
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
DCHECK(IsIvSizeValid(iv_size));
|
DCHECK(IsIvSizeValid(iv_size));
|
||||||
uint32_t box_size = HeaderSize() + sizeof(sample_count);
|
size_t box_size = HeaderSize() + sizeof(sample_count);
|
||||||
if (flags & kUseSubsampleEncryption) {
|
if (flags & kUseSubsampleEncryption) {
|
||||||
for (const SampleEncryptionEntry& sample_encryption_entry :
|
for (const SampleEncryptionEntry& sample_encryption_entry :
|
||||||
sample_encryption_entries) {
|
sample_encryption_entries) {
|
||||||
|
@ -382,7 +385,7 @@ bool OriginalFormat::ReadWriteInternal(BoxBuffer* buffer) {
|
||||||
return ReadWriteHeaderInternal(buffer) && buffer->ReadWriteFourCC(&format);
|
return ReadWriteHeaderInternal(buffer) && buffer->ReadWriteFourCC(&format);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t OriginalFormat::ComputeSizeInternal() {
|
size_t OriginalFormat::ComputeSizeInternal() {
|
||||||
return HeaderSize() + kFourCCSize;
|
return HeaderSize() + kFourCCSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -397,7 +400,7 @@ bool SchemeType::ReadWriteInternal(BoxBuffer* buffer) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t SchemeType::ComputeSizeInternal() {
|
size_t SchemeType::ComputeSizeInternal() {
|
||||||
return HeaderSize() + kFourCCSize + sizeof(version);
|
return HeaderSize() + kFourCCSize + sizeof(version);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -460,7 +463,7 @@ bool TrackEncryption::ReadWriteInternal(BoxBuffer* buffer) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t TrackEncryption::ComputeSizeInternal() {
|
size_t TrackEncryption::ComputeSizeInternal() {
|
||||||
return HeaderSize() + sizeof(uint32_t) + kCencKeyIdSize +
|
return HeaderSize() + sizeof(uint32_t) + kCencKeyIdSize +
|
||||||
(default_constant_iv.empty() ? 0 : (sizeof(uint8_t) +
|
(default_constant_iv.empty() ? 0 : (sizeof(uint8_t) +
|
||||||
default_constant_iv.size()));
|
default_constant_iv.size()));
|
||||||
|
@ -476,7 +479,7 @@ bool SchemeInfo::ReadWriteInternal(BoxBuffer* buffer) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t SchemeInfo::ComputeSizeInternal() {
|
size_t SchemeInfo::ComputeSizeInternal() {
|
||||||
return HeaderSize() + track_encryption.ComputeSize();
|
return HeaderSize() + track_encryption.ComputeSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -502,7 +505,7 @@ bool ProtectionSchemeInfo::ReadWriteInternal(BoxBuffer* buffer) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t ProtectionSchemeInfo::ComputeSizeInternal() {
|
size_t ProtectionSchemeInfo::ComputeSizeInternal() {
|
||||||
// Skip sinf box if it is not initialized.
|
// Skip sinf box if it is not initialized.
|
||||||
if (format.format == FOURCC_NULL)
|
if (format.format == FOURCC_NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -541,7 +544,7 @@ bool MovieHeader::ReadWriteInternal(BoxBuffer* buffer) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t MovieHeader::ComputeSizeInternal() {
|
size_t MovieHeader::ComputeSizeInternal() {
|
||||||
version = IsFitIn32Bits(creation_time, modification_time, duration) ? 0 : 1;
|
version = IsFitIn32Bits(creation_time, modification_time, duration) ? 0 : 1;
|
||||||
return HeaderSize() + sizeof(uint32_t) * (1 + version) * 3 +
|
return HeaderSize() + sizeof(uint32_t) * (1 + version) * 3 +
|
||||||
sizeof(timescale) + sizeof(rate) + sizeof(volume) +
|
sizeof(timescale) + sizeof(rate) + sizeof(volume) +
|
||||||
|
@ -592,7 +595,7 @@ bool TrackHeader::ReadWriteInternal(BoxBuffer* buffer) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t TrackHeader::ComputeSizeInternal() {
|
size_t TrackHeader::ComputeSizeInternal() {
|
||||||
version = IsFitIn32Bits(creation_time, modification_time, duration) ? 0 : 1;
|
version = IsFitIn32Bits(creation_time, modification_time, duration) ? 0 : 1;
|
||||||
return HeaderSize() + sizeof(track_id) +
|
return HeaderSize() + sizeof(track_id) +
|
||||||
sizeof(uint32_t) * (1 + version) * 3 + sizeof(layer) +
|
sizeof(uint32_t) * (1 + version) * 3 + sizeof(layer) +
|
||||||
|
@ -608,13 +611,13 @@ bool SampleDescription::ReadWriteInternal(BoxBuffer* buffer) {
|
||||||
uint32_t count = 0;
|
uint32_t count = 0;
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case kVideo:
|
case kVideo:
|
||||||
count = video_entries.size();
|
count = static_cast<uint32_t>(video_entries.size());
|
||||||
break;
|
break;
|
||||||
case kAudio:
|
case kAudio:
|
||||||
count = audio_entries.size();
|
count = static_cast<uint32_t>(audio_entries.size());
|
||||||
break;
|
break;
|
||||||
case kText:
|
case kText:
|
||||||
count = text_entries.size();
|
count = static_cast<uint32_t>(text_entries.size());
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
NOTIMPLEMENTED() << "SampleDecryption type " << type
|
NOTIMPLEMENTED() << "SampleDecryption type " << type
|
||||||
|
@ -658,8 +661,8 @@ bool SampleDescription::ReadWriteInternal(BoxBuffer* buffer) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t SampleDescription::ComputeSizeInternal() {
|
size_t SampleDescription::ComputeSizeInternal() {
|
||||||
uint32_t box_size = HeaderSize() + sizeof(uint32_t);
|
size_t box_size = HeaderSize() + sizeof(uint32_t);
|
||||||
if (type == kVideo) {
|
if (type == kVideo) {
|
||||||
for (uint32_t i = 0; i < video_entries.size(); ++i)
|
for (uint32_t i = 0; i < video_entries.size(); ++i)
|
||||||
box_size += video_entries[i].ComputeSize();
|
box_size += video_entries[i].ComputeSize();
|
||||||
|
@ -678,7 +681,7 @@ DecodingTimeToSample::~DecodingTimeToSample() {}
|
||||||
FourCC DecodingTimeToSample::BoxType() const { return FOURCC_stts; }
|
FourCC DecodingTimeToSample::BoxType() const { return FOURCC_stts; }
|
||||||
|
|
||||||
bool DecodingTimeToSample::ReadWriteInternal(BoxBuffer* buffer) {
|
bool DecodingTimeToSample::ReadWriteInternal(BoxBuffer* buffer) {
|
||||||
uint32_t count = decoding_time.size();
|
uint32_t count = static_cast<uint32_t>(decoding_time.size());
|
||||||
RCHECK(ReadWriteHeaderInternal(buffer) &&
|
RCHECK(ReadWriteHeaderInternal(buffer) &&
|
||||||
buffer->ReadWriteUInt32(&count));
|
buffer->ReadWriteUInt32(&count));
|
||||||
|
|
||||||
|
@ -690,7 +693,7 @@ bool DecodingTimeToSample::ReadWriteInternal(BoxBuffer* buffer) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t DecodingTimeToSample::ComputeSizeInternal() {
|
size_t DecodingTimeToSample::ComputeSizeInternal() {
|
||||||
return HeaderSize() + sizeof(uint32_t) +
|
return HeaderSize() + sizeof(uint32_t) +
|
||||||
sizeof(DecodingTime) * decoding_time.size();
|
sizeof(DecodingTime) * decoding_time.size();
|
||||||
}
|
}
|
||||||
|
@ -700,7 +703,7 @@ CompositionTimeToSample::~CompositionTimeToSample() {}
|
||||||
FourCC CompositionTimeToSample::BoxType() const { return FOURCC_ctts; }
|
FourCC CompositionTimeToSample::BoxType() const { return FOURCC_ctts; }
|
||||||
|
|
||||||
bool CompositionTimeToSample::ReadWriteInternal(BoxBuffer* buffer) {
|
bool CompositionTimeToSample::ReadWriteInternal(BoxBuffer* buffer) {
|
||||||
uint32_t count = composition_offset.size();
|
uint32_t count = static_cast<uint32_t>(composition_offset.size());
|
||||||
if (!buffer->Reading()) {
|
if (!buffer->Reading()) {
|
||||||
// Determine whether version 0 or version 1 should be used.
|
// Determine whether version 0 or version 1 should be used.
|
||||||
// Use version 0 if possible, use version 1 if there is a negative
|
// Use version 0 if possible, use version 1 if there is a negative
|
||||||
|
@ -734,14 +737,14 @@ bool CompositionTimeToSample::ReadWriteInternal(BoxBuffer* buffer) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t CompositionTimeToSample::ComputeSizeInternal() {
|
size_t CompositionTimeToSample::ComputeSizeInternal() {
|
||||||
// This box is optional. Skip it if it is empty.
|
// This box is optional. Skip it if it is empty.
|
||||||
if (composition_offset.empty())
|
if (composition_offset.empty())
|
||||||
return 0;
|
return 0;
|
||||||
// Structure CompositionOffset contains |sample_offset| (uint32_t) and
|
// Structure CompositionOffset contains |sample_offset| (uint32_t) and
|
||||||
// |sample_offset| (int64_t). The actual size of |sample_offset| is
|
// |sample_offset| (int64_t). The actual size of |sample_offset| is
|
||||||
// 4 bytes (uint32_t for version 0 and int32_t for version 1).
|
// 4 bytes (uint32_t for version 0 and int32_t for version 1).
|
||||||
const uint32_t kCompositionOffsetSize = sizeof(uint32_t) * 2;
|
const size_t kCompositionOffsetSize = sizeof(uint32_t) * 2;
|
||||||
return HeaderSize() + sizeof(uint32_t) +
|
return HeaderSize() + sizeof(uint32_t) +
|
||||||
kCompositionOffsetSize * composition_offset.size();
|
kCompositionOffsetSize * composition_offset.size();
|
||||||
}
|
}
|
||||||
|
@ -751,7 +754,7 @@ SampleToChunk::~SampleToChunk() {}
|
||||||
FourCC SampleToChunk::BoxType() const { return FOURCC_stsc; }
|
FourCC SampleToChunk::BoxType() const { return FOURCC_stsc; }
|
||||||
|
|
||||||
bool SampleToChunk::ReadWriteInternal(BoxBuffer* buffer) {
|
bool SampleToChunk::ReadWriteInternal(BoxBuffer* buffer) {
|
||||||
uint32_t count = chunk_info.size();
|
uint32_t count = static_cast<uint32_t>(chunk_info.size());
|
||||||
RCHECK(ReadWriteHeaderInternal(buffer) &&
|
RCHECK(ReadWriteHeaderInternal(buffer) &&
|
||||||
buffer->ReadWriteUInt32(&count));
|
buffer->ReadWriteUInt32(&count));
|
||||||
|
|
||||||
|
@ -767,7 +770,7 @@ bool SampleToChunk::ReadWriteInternal(BoxBuffer* buffer) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t SampleToChunk::ComputeSizeInternal() {
|
size_t SampleToChunk::ComputeSizeInternal() {
|
||||||
return HeaderSize() + sizeof(uint32_t) +
|
return HeaderSize() + sizeof(uint32_t) +
|
||||||
sizeof(ChunkInfo) * chunk_info.size();
|
sizeof(ChunkInfo) * chunk_info.size();
|
||||||
}
|
}
|
||||||
|
@ -792,7 +795,7 @@ bool SampleSize::ReadWriteInternal(BoxBuffer* buffer) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t SampleSize::ComputeSizeInternal() {
|
size_t SampleSize::ComputeSizeInternal() {
|
||||||
return HeaderSize() + sizeof(sample_size) + sizeof(sample_count) +
|
return HeaderSize() + sizeof(sample_size) + sizeof(sample_count) +
|
||||||
(sample_size == 0 ? sizeof(uint32_t) * sizes.size() : 0);
|
(sample_size == 0 ? sizeof(uint32_t) * sizes.size() : 0);
|
||||||
}
|
}
|
||||||
|
@ -802,7 +805,7 @@ CompactSampleSize::~CompactSampleSize() {}
|
||||||
FourCC CompactSampleSize::BoxType() const { return FOURCC_stz2; }
|
FourCC CompactSampleSize::BoxType() const { return FOURCC_stz2; }
|
||||||
|
|
||||||
bool CompactSampleSize::ReadWriteInternal(BoxBuffer* buffer) {
|
bool CompactSampleSize::ReadWriteInternal(BoxBuffer* buffer) {
|
||||||
uint32_t sample_count = sizes.size();
|
uint32_t sample_count = static_cast<uint32_t>(sizes.size());
|
||||||
RCHECK(ReadWriteHeaderInternal(buffer) &&
|
RCHECK(ReadWriteHeaderInternal(buffer) &&
|
||||||
buffer->IgnoreBytes(3) &&
|
buffer->IgnoreBytes(3) &&
|
||||||
buffer->ReadWriteUInt8(&field_size) &&
|
buffer->ReadWriteUInt8(&field_size) &&
|
||||||
|
@ -847,7 +850,7 @@ bool CompactSampleSize::ReadWriteInternal(BoxBuffer* buffer) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t CompactSampleSize::ComputeSizeInternal() {
|
size_t CompactSampleSize::ComputeSizeInternal() {
|
||||||
return HeaderSize() + sizeof(uint32_t) + sizeof(uint32_t) +
|
return HeaderSize() + sizeof(uint32_t) + sizeof(uint32_t) +
|
||||||
(field_size * sizes.size() + 7) / 8;
|
(field_size * sizes.size() + 7) / 8;
|
||||||
}
|
}
|
||||||
|
@ -857,7 +860,7 @@ ChunkOffset::~ChunkOffset() {}
|
||||||
FourCC ChunkOffset::BoxType() const { return FOURCC_stco; }
|
FourCC ChunkOffset::BoxType() const { return FOURCC_stco; }
|
||||||
|
|
||||||
bool ChunkOffset::ReadWriteInternal(BoxBuffer* buffer) {
|
bool ChunkOffset::ReadWriteInternal(BoxBuffer* buffer) {
|
||||||
uint32_t count = offsets.size();
|
uint32_t count = static_cast<uint32_t>(offsets.size());
|
||||||
RCHECK(ReadWriteHeaderInternal(buffer) &&
|
RCHECK(ReadWriteHeaderInternal(buffer) &&
|
||||||
buffer->ReadWriteUInt32(&count));
|
buffer->ReadWriteUInt32(&count));
|
||||||
|
|
||||||
|
@ -867,7 +870,7 @@ bool ChunkOffset::ReadWriteInternal(BoxBuffer* buffer) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t ChunkOffset::ComputeSizeInternal() {
|
size_t ChunkOffset::ComputeSizeInternal() {
|
||||||
return HeaderSize() + sizeof(uint32_t) + sizeof(uint32_t) * offsets.size();
|
return HeaderSize() + sizeof(uint32_t) + sizeof(uint32_t) * offsets.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -876,7 +879,7 @@ ChunkLargeOffset::~ChunkLargeOffset() {}
|
||||||
FourCC ChunkLargeOffset::BoxType() const { return FOURCC_co64; }
|
FourCC ChunkLargeOffset::BoxType() const { return FOURCC_co64; }
|
||||||
|
|
||||||
bool ChunkLargeOffset::ReadWriteInternal(BoxBuffer* buffer) {
|
bool ChunkLargeOffset::ReadWriteInternal(BoxBuffer* buffer) {
|
||||||
uint32_t count = offsets.size();
|
uint32_t count = static_cast<uint32_t>(offsets.size());
|
||||||
|
|
||||||
if (!buffer->Reading()) {
|
if (!buffer->Reading()) {
|
||||||
// Switch to ChunkOffset box if it is able to fit in 32 bits offset.
|
// Switch to ChunkOffset box if it is able to fit in 32 bits offset.
|
||||||
|
@ -899,8 +902,8 @@ bool ChunkLargeOffset::ReadWriteInternal(BoxBuffer* buffer) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t ChunkLargeOffset::ComputeSizeInternal() {
|
size_t ChunkLargeOffset::ComputeSizeInternal() {
|
||||||
uint32_t count = offsets.size();
|
uint32_t count = static_cast<uint32_t>(offsets.size());
|
||||||
int use_large_offset =
|
int use_large_offset =
|
||||||
(count > 0 && !IsFitIn32Bits(offsets[count - 1])) ? 1 : 0;
|
(count > 0 && !IsFitIn32Bits(offsets[count - 1])) ? 1 : 0;
|
||||||
return HeaderSize() + sizeof(count) +
|
return HeaderSize() + sizeof(count) +
|
||||||
|
@ -912,7 +915,7 @@ SyncSample::~SyncSample() {}
|
||||||
FourCC SyncSample::BoxType() const { return FOURCC_stss; }
|
FourCC SyncSample::BoxType() const { return FOURCC_stss; }
|
||||||
|
|
||||||
bool SyncSample::ReadWriteInternal(BoxBuffer* buffer) {
|
bool SyncSample::ReadWriteInternal(BoxBuffer* buffer) {
|
||||||
uint32_t count = sample_number.size();
|
uint32_t count = static_cast<uint32_t>(sample_number.size());
|
||||||
RCHECK(ReadWriteHeaderInternal(buffer) &&
|
RCHECK(ReadWriteHeaderInternal(buffer) &&
|
||||||
buffer->ReadWriteUInt32(&count));
|
buffer->ReadWriteUInt32(&count));
|
||||||
|
|
||||||
|
@ -922,7 +925,7 @@ bool SyncSample::ReadWriteInternal(BoxBuffer* buffer) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t SyncSample::ComputeSizeInternal() {
|
size_t SyncSample::ComputeSizeInternal() {
|
||||||
// Sync sample box is optional. Skip it if it is empty.
|
// Sync sample box is optional. Skip it if it is empty.
|
||||||
if (sample_number.empty())
|
if (sample_number.empty())
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -979,8 +982,9 @@ bool CencSampleEncryptionInfoEntry::ReadWrite(BoxBuffer* buffer) {
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t CencSampleEncryptionInfoEntry::ComputeSize() const {
|
uint32_t CencSampleEncryptionInfoEntry::ComputeSize() const {
|
||||||
return sizeof(uint32_t) + kCencKeyIdSize +
|
return static_cast<uint32_t>(
|
||||||
(constant_iv.empty() ? 0 : (sizeof(uint8_t) + constant_iv.size()));
|
sizeof(uint32_t) + kCencKeyIdSize +
|
||||||
|
(constant_iv.empty() ? 0 : (sizeof(uint8_t) + constant_iv.size())));
|
||||||
}
|
}
|
||||||
|
|
||||||
AudioRollRecoveryEntry::AudioRollRecoveryEntry(): roll_distance(0) {}
|
AudioRollRecoveryEntry::AudioRollRecoveryEntry(): roll_distance(0) {}
|
||||||
|
@ -1033,7 +1037,7 @@ bool SampleGroupDescription::ReadWriteEntries(BoxBuffer* buffer,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t count = entries->size();
|
uint32_t count = static_cast<uint32_t>(entries->size());
|
||||||
RCHECK(buffer->ReadWriteUInt32(&count));
|
RCHECK(buffer->ReadWriteUInt32(&count));
|
||||||
RCHECK(count != 0);
|
RCHECK(count != 0);
|
||||||
entries->resize(count);
|
entries->resize(count);
|
||||||
|
@ -1052,7 +1056,7 @@ bool SampleGroupDescription::ReadWriteEntries(BoxBuffer* buffer,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t SampleGroupDescription::ComputeSizeInternal() {
|
size_t SampleGroupDescription::ComputeSizeInternal() {
|
||||||
// Version 0 is obsoleted, so always generate version 1 box.
|
// Version 0 is obsoleted, so always generate version 1 box.
|
||||||
version = 1;
|
version = 1;
|
||||||
size_t entries_size = 0;
|
size_t entries_size = 0;
|
||||||
|
@ -1091,7 +1095,7 @@ bool SampleToGroup::ReadWriteInternal(BoxBuffer* buffer) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t count = entries.size();
|
uint32_t count = static_cast<uint32_t>(entries.size());
|
||||||
RCHECK(buffer->ReadWriteUInt32(&count));
|
RCHECK(buffer->ReadWriteUInt32(&count));
|
||||||
entries.resize(count);
|
entries.resize(count);
|
||||||
for (uint32_t i = 0; i < count; ++i) {
|
for (uint32_t i = 0; i < count; ++i) {
|
||||||
|
@ -1101,7 +1105,7 @@ bool SampleToGroup::ReadWriteInternal(BoxBuffer* buffer) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t SampleToGroup::ComputeSizeInternal() {
|
size_t SampleToGroup::ComputeSizeInternal() {
|
||||||
// This box is optional. Skip it if it is not used.
|
// This box is optional. Skip it if it is not used.
|
||||||
if (entries.empty())
|
if (entries.empty())
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1133,7 +1137,8 @@ bool SampleTable::ReadWriteInternal(BoxBuffer* buffer) {
|
||||||
CompactSampleSize compact_sample_size;
|
CompactSampleSize compact_sample_size;
|
||||||
RCHECK(reader->ReadChild(&compact_sample_size));
|
RCHECK(reader->ReadChild(&compact_sample_size));
|
||||||
sample_size.sample_size = 0;
|
sample_size.sample_size = 0;
|
||||||
sample_size.sample_count = compact_sample_size.sizes.size();
|
sample_size.sample_count =
|
||||||
|
static_cast<uint32_t>(compact_sample_size.sizes.size());
|
||||||
sample_size.sizes.swap(compact_sample_size.sizes);
|
sample_size.sizes.swap(compact_sample_size.sizes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1162,12 +1167,12 @@ bool SampleTable::ReadWriteInternal(BoxBuffer* buffer) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t SampleTable::ComputeSizeInternal() {
|
size_t SampleTable::ComputeSizeInternal() {
|
||||||
uint32_t box_size =
|
size_t box_size = HeaderSize() + description.ComputeSize() +
|
||||||
HeaderSize() + description.ComputeSize() +
|
|
||||||
decoding_time_to_sample.ComputeSize() +
|
decoding_time_to_sample.ComputeSize() +
|
||||||
composition_time_to_sample.ComputeSize() + sample_to_chunk.ComputeSize() +
|
composition_time_to_sample.ComputeSize() +
|
||||||
sample_size.ComputeSize() + chunk_large_offset.ComputeSize() +
|
sample_to_chunk.ComputeSize() + sample_size.ComputeSize() +
|
||||||
|
chunk_large_offset.ComputeSize() +
|
||||||
sync_sample.ComputeSize();
|
sync_sample.ComputeSize();
|
||||||
for (auto& sample_group_description : sample_group_descriptions)
|
for (auto& sample_group_description : sample_group_descriptions)
|
||||||
box_size += sample_group_description.ComputeSize();
|
box_size += sample_group_description.ComputeSize();
|
||||||
|
@ -1181,7 +1186,7 @@ EditList::~EditList() {}
|
||||||
FourCC EditList::BoxType() const { return FOURCC_elst; }
|
FourCC EditList::BoxType() const { return FOURCC_elst; }
|
||||||
|
|
||||||
bool EditList::ReadWriteInternal(BoxBuffer* buffer) {
|
bool EditList::ReadWriteInternal(BoxBuffer* buffer) {
|
||||||
uint32_t count = edits.size();
|
uint32_t count = static_cast<uint32_t>(edits.size());
|
||||||
RCHECK(ReadWriteHeaderInternal(buffer) && buffer->ReadWriteUInt32(&count));
|
RCHECK(ReadWriteHeaderInternal(buffer) && buffer->ReadWriteUInt32(&count));
|
||||||
edits.resize(count);
|
edits.resize(count);
|
||||||
|
|
||||||
|
@ -1196,7 +1201,7 @@ bool EditList::ReadWriteInternal(BoxBuffer* buffer) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t EditList::ComputeSizeInternal() {
|
size_t EditList::ComputeSizeInternal() {
|
||||||
// EditList box is optional. Skip it if it is empty.
|
// EditList box is optional. Skip it if it is empty.
|
||||||
if (edits.empty())
|
if (edits.empty())
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1223,7 +1228,7 @@ bool Edit::ReadWriteInternal(BoxBuffer* buffer) {
|
||||||
buffer->ReadWriteChild(&list);
|
buffer->ReadWriteChild(&list);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t Edit::ComputeSizeInternal() {
|
size_t Edit::ComputeSizeInternal() {
|
||||||
// Edit box is optional. Skip it if it is empty.
|
// Edit box is optional. Skip it if it is empty.
|
||||||
if (list.edits.empty())
|
if (list.edits.empty())
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1267,8 +1272,8 @@ bool HandlerReference::ReadWriteInternal(BoxBuffer* buffer) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t HandlerReference::ComputeSizeInternal() {
|
size_t HandlerReference::ComputeSizeInternal() {
|
||||||
uint32_t box_size = HeaderSize() + kFourCCSize + 16; // 16 bytes Reserved
|
size_t box_size = HeaderSize() + kFourCCSize + 16; // 16 bytes Reserved
|
||||||
switch (handler_type) {
|
switch (handler_type) {
|
||||||
case FOURCC_vide:
|
case FOURCC_vide:
|
||||||
box_size += sizeof(kVideoHandlerName);
|
box_size += sizeof(kVideoHandlerName);
|
||||||
|
@ -1332,7 +1337,7 @@ bool PrivFrame::ReadWrite(BoxBuffer* buffer) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t frame_size = owner.size() + 1 + value.size();
|
uint32_t frame_size = static_cast<uint32_t>(owner.size() + 1 + value.size());
|
||||||
// size should be encoded as synchsafe integer, which is not support here.
|
// size should be encoded as synchsafe integer, which is not support here.
|
||||||
// We don't expect frame_size to be larger than 0x7F. Synchsafe integers less
|
// We don't expect frame_size to be larger than 0x7F. Synchsafe integers less
|
||||||
// than 0x7F is encoded in the same way as normal integer.
|
// than 0x7F is encoded in the same way as normal integer.
|
||||||
|
@ -1362,8 +1367,9 @@ uint32_t PrivFrame::ComputeSize() const {
|
||||||
if (owner.empty() && value.empty())
|
if (owner.empty() && value.empty())
|
||||||
return 0;
|
return 0;
|
||||||
const uint32_t kFourCCSize = 4;
|
const uint32_t kFourCCSize = 4;
|
||||||
return kFourCCSize + sizeof(uint32_t) + sizeof(uint16_t) + owner.size() + 1 +
|
return kFourCCSize +
|
||||||
value.size();
|
static_cast<uint32_t>(sizeof(uint32_t) + sizeof(uint16_t) +
|
||||||
|
owner.size() + 1 + value.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
ID3v2::ID3v2() {}
|
ID3v2::ID3v2() {}
|
||||||
|
@ -1394,7 +1400,7 @@ bool ID3v2::ReadWriteInternal(BoxBuffer* buffer) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t ID3v2::ComputeSizeInternal() {
|
size_t ID3v2::ComputeSizeInternal() {
|
||||||
uint32_t private_frame_size = private_frame.ComputeSize();
|
uint32_t private_frame_size = private_frame.ComputeSize();
|
||||||
// Skip ID3v2 box generation if there is no private frame.
|
// Skip ID3v2 box generation if there is no private frame.
|
||||||
return private_frame_size == 0 ? 0 : HeaderSize() + language.ComputeSize() +
|
return private_frame_size == 0 ? 0 : HeaderSize() + language.ComputeSize() +
|
||||||
|
@ -1417,8 +1423,8 @@ bool Metadata::ReadWriteInternal(BoxBuffer* buffer) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t Metadata::ComputeSizeInternal() {
|
size_t Metadata::ComputeSizeInternal() {
|
||||||
uint32_t id3v2_size = id3v2.ComputeSize();
|
size_t id3v2_size = id3v2.ComputeSize();
|
||||||
// Skip metadata box generation if there is no metadata box.
|
// Skip metadata box generation if there is no metadata box.
|
||||||
return id3v2_size == 0 ? 0
|
return id3v2_size == 0 ? 0
|
||||||
: HeaderSize() + handler.ComputeSize() + id3v2_size;
|
: HeaderSize() + handler.ComputeSize() + id3v2_size;
|
||||||
|
@ -1453,7 +1459,7 @@ bool CodecConfiguration::ReadWriteInternal(BoxBuffer* buffer) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t CodecConfiguration::ComputeSizeInternal() {
|
size_t CodecConfiguration::ComputeSizeInternal() {
|
||||||
if (data.empty())
|
if (data.empty())
|
||||||
return 0;
|
return 0;
|
||||||
DCHECK_NE(box_type, FOURCC_NULL);
|
DCHECK_NE(box_type, FOURCC_NULL);
|
||||||
|
@ -1471,7 +1477,7 @@ bool PixelAspectRatio::ReadWriteInternal(BoxBuffer* buffer) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t PixelAspectRatio::ComputeSizeInternal() {
|
size_t PixelAspectRatio::ComputeSizeInternal() {
|
||||||
// This box is optional. Skip it if it is not initialized.
|
// This box is optional. Skip it if it is not initialized.
|
||||||
if (h_spacing == 0 && v_spacing == 0)
|
if (h_spacing == 0 && v_spacing == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1572,7 +1578,7 @@ bool VideoSampleEntry::ReadWriteInternal(BoxBuffer* buffer) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t VideoSampleEntry::ComputeSizeInternal() {
|
size_t VideoSampleEntry::ComputeSizeInternal() {
|
||||||
const FourCC actual_format = GetActualFormat();
|
const FourCC actual_format = GetActualFormat();
|
||||||
if (actual_format == FOURCC_NULL)
|
if (actual_format == FOURCC_NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1624,7 +1630,7 @@ bool ElementaryStreamDescriptor::ReadWriteInternal(BoxBuffer* buffer) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t ElementaryStreamDescriptor::ComputeSizeInternal() {
|
size_t ElementaryStreamDescriptor::ComputeSizeInternal() {
|
||||||
// This box is optional. Skip it if not initialized.
|
// This box is optional. Skip it if not initialized.
|
||||||
if (es_descriptor.object_type() == kForbidden)
|
if (es_descriptor.object_type() == kForbidden)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1658,7 +1664,7 @@ bool DTSSpecific::ReadWriteInternal(BoxBuffer* buffer) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t DTSSpecific::ComputeSizeInternal() {
|
size_t DTSSpecific::ComputeSizeInternal() {
|
||||||
// This box is optional. Skip it if not initialized.
|
// This box is optional. Skip it if not initialized.
|
||||||
if (sampling_frequency == 0)
|
if (sampling_frequency == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1679,7 +1685,7 @@ bool AC3Specific::ReadWriteInternal(BoxBuffer* buffer) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t AC3Specific::ComputeSizeInternal() {
|
size_t AC3Specific::ComputeSizeInternal() {
|
||||||
// This box is optional. Skip it if not initialized.
|
// This box is optional. Skip it if not initialized.
|
||||||
if (data.empty())
|
if (data.empty())
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1693,12 +1699,12 @@ FourCC EC3Specific::BoxType() const { return FOURCC_dec3; }
|
||||||
|
|
||||||
bool EC3Specific::ReadWriteInternal(BoxBuffer* buffer) {
|
bool EC3Specific::ReadWriteInternal(BoxBuffer* buffer) {
|
||||||
RCHECK(ReadWriteHeaderInternal(buffer));
|
RCHECK(ReadWriteHeaderInternal(buffer));
|
||||||
uint32_t size = buffer->Reading() ? buffer->BytesLeft() : data.size();
|
size_t size = buffer->Reading() ? buffer->BytesLeft() : data.size();
|
||||||
RCHECK(buffer->ReadWriteVector(&data, size));
|
RCHECK(buffer->ReadWriteVector(&data, size));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t EC3Specific::ComputeSizeInternal() {
|
size_t EC3Specific::ComputeSizeInternal() {
|
||||||
// This box is optional. Skip it if not initialized.
|
// This box is optional. Skip it if not initialized.
|
||||||
if (data.empty())
|
if (data.empty())
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1744,7 +1750,7 @@ bool OpusSpecific::ReadWriteInternal(BoxBuffer* buffer) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t OpusSpecific::ComputeSizeInternal() {
|
size_t OpusSpecific::ComputeSizeInternal() {
|
||||||
// This box is optional. Skip it if not initialized.
|
// This box is optional. Skip it if not initialized.
|
||||||
if (opus_identification_header.empty())
|
if (opus_identification_header.empty())
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1814,7 +1820,7 @@ bool AudioSampleEntry::ReadWriteInternal(BoxBuffer* buffer) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t AudioSampleEntry::ComputeSizeInternal() {
|
size_t AudioSampleEntry::ComputeSizeInternal() {
|
||||||
if (GetActualFormat() == FOURCC_NULL)
|
if (GetActualFormat() == FOURCC_NULL)
|
||||||
return 0;
|
return 0;
|
||||||
return HeaderSize() + sizeof(data_reference_index) + sizeof(channelcount) +
|
return HeaderSize() + sizeof(data_reference_index) + sizeof(channelcount) +
|
||||||
|
@ -1839,7 +1845,7 @@ bool WebVTTConfigurationBox::ReadWriteInternal(BoxBuffer* buffer) {
|
||||||
buffer->Reading() ? buffer->BytesLeft() : config.size());
|
buffer->Reading() ? buffer->BytesLeft() : config.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t WebVTTConfigurationBox::ComputeSizeInternal() {
|
size_t WebVTTConfigurationBox::ComputeSizeInternal() {
|
||||||
return HeaderSize() + config.size();
|
return HeaderSize() + config.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1857,7 +1863,7 @@ bool WebVTTSourceLabelBox::ReadWriteInternal(BoxBuffer* buffer) {
|
||||||
: source_label.size());
|
: source_label.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t WebVTTSourceLabelBox::ComputeSizeInternal() {
|
size_t WebVTTSourceLabelBox::ComputeSizeInternal() {
|
||||||
if (source_label.empty())
|
if (source_label.empty())
|
||||||
return 0;
|
return 0;
|
||||||
return HeaderSize() + source_label.size();
|
return HeaderSize() + source_label.size();
|
||||||
|
@ -1893,7 +1899,7 @@ bool TextSampleEntry::ReadWriteInternal(BoxBuffer* buffer) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t TextSampleEntry::ComputeSizeInternal() {
|
size_t TextSampleEntry::ComputeSizeInternal() {
|
||||||
// 6 for the (anonymous) reserved bytes for SampleEntry class.
|
// 6 for the (anonymous) reserved bytes for SampleEntry class.
|
||||||
return HeaderSize() + 6 + sizeof(data_reference_index) +
|
return HeaderSize() + 6 + sizeof(data_reference_index) +
|
||||||
config.ComputeSize() + label.ComputeSize();
|
config.ComputeSize() + label.ComputeSize();
|
||||||
|
@ -1917,7 +1923,7 @@ bool MediaHeader::ReadWriteInternal(BoxBuffer* buffer) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t MediaHeader::ComputeSizeInternal() {
|
size_t MediaHeader::ComputeSizeInternal() {
|
||||||
version = IsFitIn32Bits(creation_time, modification_time, duration) ? 0 : 1;
|
version = IsFitIn32Bits(creation_time, modification_time, duration) ? 0 : 1;
|
||||||
return HeaderSize() + sizeof(timescale) +
|
return HeaderSize() + sizeof(timescale) +
|
||||||
sizeof(uint32_t) * (1 + version) * 3 + language.ComputeSize() +
|
sizeof(uint32_t) * (1 + version) * 3 + language.ComputeSize() +
|
||||||
|
@ -1940,7 +1946,7 @@ bool VideoMediaHeader::ReadWriteInternal(BoxBuffer* buffer) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t VideoMediaHeader::ComputeSizeInternal() {
|
size_t VideoMediaHeader::ComputeSizeInternal() {
|
||||||
return HeaderSize() + sizeof(graphicsmode) + sizeof(opcolor_red) +
|
return HeaderSize() + sizeof(graphicsmode) + sizeof(opcolor_red) +
|
||||||
sizeof(opcolor_green) + sizeof(opcolor_blue);
|
sizeof(opcolor_green) + sizeof(opcolor_blue);
|
||||||
}
|
}
|
||||||
|
@ -1955,7 +1961,7 @@ bool SoundMediaHeader::ReadWriteInternal(BoxBuffer* buffer) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t SoundMediaHeader::ComputeSizeInternal() {
|
size_t SoundMediaHeader::ComputeSizeInternal() {
|
||||||
return HeaderSize() + sizeof(balance) + sizeof(uint16_t);
|
return HeaderSize() + sizeof(balance) + sizeof(uint16_t);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1968,7 +1974,7 @@ bool SubtitleMediaHeader::ReadWriteInternal(BoxBuffer* buffer) {
|
||||||
return ReadWriteHeaderInternal(buffer);
|
return ReadWriteHeaderInternal(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t SubtitleMediaHeader::ComputeSizeInternal() {
|
size_t SubtitleMediaHeader::ComputeSizeInternal() {
|
||||||
return HeaderSize();
|
return HeaderSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1988,7 +1994,7 @@ bool DataEntryUrl::ReadWriteInternal(BoxBuffer* buffer) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t DataEntryUrl::ComputeSizeInternal() {
|
size_t DataEntryUrl::ComputeSizeInternal() {
|
||||||
return HeaderSize() + location.size();
|
return HeaderSize() + location.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1999,7 +2005,7 @@ DataReference::DataReference() {
|
||||||
DataReference::~DataReference() {}
|
DataReference::~DataReference() {}
|
||||||
FourCC DataReference::BoxType() const { return FOURCC_dref; }
|
FourCC DataReference::BoxType() const { return FOURCC_dref; }
|
||||||
bool DataReference::ReadWriteInternal(BoxBuffer* buffer) {
|
bool DataReference::ReadWriteInternal(BoxBuffer* buffer) {
|
||||||
uint32_t entry_count = data_entry.size();
|
uint32_t entry_count = static_cast<uint32_t>(data_entry.size());
|
||||||
RCHECK(ReadWriteHeaderInternal(buffer) &&
|
RCHECK(ReadWriteHeaderInternal(buffer) &&
|
||||||
buffer->ReadWriteUInt32(&entry_count));
|
buffer->ReadWriteUInt32(&entry_count));
|
||||||
data_entry.resize(entry_count);
|
data_entry.resize(entry_count);
|
||||||
|
@ -2009,9 +2015,9 @@ bool DataReference::ReadWriteInternal(BoxBuffer* buffer) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t DataReference::ComputeSizeInternal() {
|
size_t DataReference::ComputeSizeInternal() {
|
||||||
uint32_t count = data_entry.size();
|
uint32_t count = static_cast<uint32_t>(data_entry.size());
|
||||||
uint32_t box_size = HeaderSize() + sizeof(count);
|
size_t box_size = HeaderSize() + sizeof(count);
|
||||||
for (uint32_t i = 0; i < count; ++i)
|
for (uint32_t i = 0; i < count; ++i)
|
||||||
box_size += data_entry[i].ComputeSize();
|
box_size += data_entry[i].ComputeSize();
|
||||||
return box_size;
|
return box_size;
|
||||||
|
@ -2027,7 +2033,7 @@ bool DataInformation::ReadWriteInternal(BoxBuffer* buffer) {
|
||||||
buffer->ReadWriteChild(&dref);
|
buffer->ReadWriteChild(&dref);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t DataInformation::ComputeSizeInternal() {
|
size_t DataInformation::ComputeSizeInternal() {
|
||||||
return HeaderSize() + dref.ComputeSize();
|
return HeaderSize() + dref.ComputeSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2057,8 +2063,8 @@ bool MediaInformation::ReadWriteInternal(BoxBuffer* buffer) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t MediaInformation::ComputeSizeInternal() {
|
size_t MediaInformation::ComputeSizeInternal() {
|
||||||
uint32_t box_size =
|
size_t box_size =
|
||||||
HeaderSize() + dinf.ComputeSize() + sample_table.ComputeSize();
|
HeaderSize() + dinf.ComputeSize() + sample_table.ComputeSize();
|
||||||
switch (sample_table.description.type) {
|
switch (sample_table.description.type) {
|
||||||
case kVideo:
|
case kVideo:
|
||||||
|
@ -2104,7 +2110,7 @@ bool Media::ReadWriteInternal(BoxBuffer* buffer) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t Media::ComputeSizeInternal() {
|
size_t Media::ComputeSizeInternal() {
|
||||||
handler.handler_type =
|
handler.handler_type =
|
||||||
TrackTypeToFourCC(information.sample_table.description.type);
|
TrackTypeToFourCC(information.sample_table.description.type);
|
||||||
return HeaderSize() + header.ComputeSize() + handler.ComputeSize() +
|
return HeaderSize() + header.ComputeSize() + handler.ComputeSize() +
|
||||||
|
@ -2125,7 +2131,7 @@ bool Track::ReadWriteInternal(BoxBuffer* buffer) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t Track::ComputeSizeInternal() {
|
size_t Track::ComputeSizeInternal() {
|
||||||
return HeaderSize() + header.ComputeSize() + media.ComputeSize() +
|
return HeaderSize() + header.ComputeSize() + media.ComputeSize() +
|
||||||
edit.ComputeSize();
|
edit.ComputeSize();
|
||||||
}
|
}
|
||||||
|
@ -2141,7 +2147,7 @@ bool MovieExtendsHeader::ReadWriteInternal(BoxBuffer* buffer) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t MovieExtendsHeader::ComputeSizeInternal() {
|
size_t MovieExtendsHeader::ComputeSizeInternal() {
|
||||||
// This box is optional. Skip it if it is not used.
|
// This box is optional. Skip it if it is not used.
|
||||||
if (fragment_duration == 0)
|
if (fragment_duration == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -2168,7 +2174,7 @@ bool TrackExtends::ReadWriteInternal(BoxBuffer* buffer) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t TrackExtends::ComputeSizeInternal() {
|
size_t TrackExtends::ComputeSizeInternal() {
|
||||||
return HeaderSize() + sizeof(track_id) +
|
return HeaderSize() + sizeof(track_id) +
|
||||||
sizeof(default_sample_description_index) +
|
sizeof(default_sample_description_index) +
|
||||||
sizeof(default_sample_duration) + sizeof(default_sample_size) +
|
sizeof(default_sample_duration) + sizeof(default_sample_size) +
|
||||||
|
@ -2193,11 +2199,11 @@ bool MovieExtends::ReadWriteInternal(BoxBuffer* buffer) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t MovieExtends::ComputeSizeInternal() {
|
size_t MovieExtends::ComputeSizeInternal() {
|
||||||
// This box is optional. Skip it if it does not contain any track.
|
// This box is optional. Skip it if it does not contain any track.
|
||||||
if (tracks.size() == 0)
|
if (tracks.size() == 0)
|
||||||
return 0;
|
return 0;
|
||||||
uint32_t box_size = HeaderSize() + header.ComputeSize();
|
size_t box_size = HeaderSize() + header.ComputeSize();
|
||||||
for (uint32_t i = 0; i < tracks.size(); ++i)
|
for (uint32_t i = 0; i < tracks.size(); ++i)
|
||||||
box_size += tracks[i].ComputeSize();
|
box_size += tracks[i].ComputeSize();
|
||||||
return box_size;
|
return box_size;
|
||||||
|
@ -2227,8 +2233,8 @@ bool Movie::ReadWriteInternal(BoxBuffer* buffer) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t Movie::ComputeSizeInternal() {
|
size_t Movie::ComputeSizeInternal() {
|
||||||
uint32_t box_size = HeaderSize() + header.ComputeSize() +
|
size_t box_size = HeaderSize() + header.ComputeSize() +
|
||||||
metadata.ComputeSize() + extends.ComputeSize();
|
metadata.ComputeSize() + extends.ComputeSize();
|
||||||
for (uint32_t i = 0; i < tracks.size(); ++i)
|
for (uint32_t i = 0; i < tracks.size(); ++i)
|
||||||
box_size += tracks[i].ComputeSize();
|
box_size += tracks[i].ComputeSize();
|
||||||
|
@ -2248,7 +2254,7 @@ bool TrackFragmentDecodeTime::ReadWriteInternal(BoxBuffer* buffer) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t TrackFragmentDecodeTime::ComputeSizeInternal() {
|
size_t TrackFragmentDecodeTime::ComputeSizeInternal() {
|
||||||
version = IsFitIn32Bits(decode_time) ? 0 : 1;
|
version = IsFitIn32Bits(decode_time) ? 0 : 1;
|
||||||
return HeaderSize() + sizeof(uint32_t) * (1 + version);
|
return HeaderSize() + sizeof(uint32_t) * (1 + version);
|
||||||
}
|
}
|
||||||
|
@ -2262,7 +2268,7 @@ bool MovieFragmentHeader::ReadWriteInternal(BoxBuffer* buffer) {
|
||||||
buffer->ReadWriteUInt32(&sequence_number);
|
buffer->ReadWriteUInt32(&sequence_number);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t MovieFragmentHeader::ComputeSizeInternal() {
|
size_t MovieFragmentHeader::ComputeSizeInternal() {
|
||||||
return HeaderSize() + sizeof(sequence_number);
|
return HeaderSize() + sizeof(sequence_number);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2314,8 +2320,8 @@ bool TrackFragmentHeader::ReadWriteInternal(BoxBuffer* buffer) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t TrackFragmentHeader::ComputeSizeInternal() {
|
size_t TrackFragmentHeader::ComputeSizeInternal() {
|
||||||
uint32_t box_size = HeaderSize() + sizeof(track_id);
|
size_t box_size = HeaderSize() + sizeof(track_id);
|
||||||
if (flags & kSampleDescriptionIndexPresentMask)
|
if (flags & kSampleDescriptionIndexPresentMask)
|
||||||
box_size += sizeof(sample_description_index);
|
box_size += sizeof(sample_description_index);
|
||||||
if (flags & kDefaultSampleDurationPresentMask)
|
if (flags & kDefaultSampleDurationPresentMask)
|
||||||
|
@ -2434,8 +2440,8 @@ bool TrackFragmentRun::ReadWriteInternal(BoxBuffer* buffer) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t TrackFragmentRun::ComputeSizeInternal() {
|
size_t TrackFragmentRun::ComputeSizeInternal() {
|
||||||
uint32_t box_size = HeaderSize() + sizeof(sample_count);
|
size_t box_size = HeaderSize() + sizeof(sample_count);
|
||||||
if (flags & kDataOffsetPresentMask)
|
if (flags & kDataOffsetPresentMask)
|
||||||
box_size += sizeof(data_offset);
|
box_size += sizeof(data_offset);
|
||||||
if (flags & kFirstSampleFlagsPresentMask)
|
if (flags & kFirstSampleFlagsPresentMask)
|
||||||
|
@ -2479,10 +2485,10 @@ bool TrackFragment::ReadWriteInternal(BoxBuffer* buffer) {
|
||||||
buffer->TryReadWriteChild(&sample_encryption);
|
buffer->TryReadWriteChild(&sample_encryption);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t TrackFragment::ComputeSizeInternal() {
|
size_t TrackFragment::ComputeSizeInternal() {
|
||||||
uint32_t box_size =
|
size_t box_size = HeaderSize() + header.ComputeSize() +
|
||||||
HeaderSize() + header.ComputeSize() + decode_time.ComputeSize() +
|
decode_time.ComputeSize() + auxiliary_size.ComputeSize() +
|
||||||
auxiliary_size.ComputeSize() + auxiliary_offset.ComputeSize() +
|
auxiliary_offset.ComputeSize() +
|
||||||
sample_encryption.ComputeSize();
|
sample_encryption.ComputeSize();
|
||||||
for (uint32_t i = 0; i < runs.size(); ++i)
|
for (uint32_t i = 0; i < runs.size(); ++i)
|
||||||
box_size += runs[i].ComputeSize();
|
box_size += runs[i].ComputeSize();
|
||||||
|
@ -2515,8 +2521,8 @@ bool MovieFragment::ReadWriteInternal(BoxBuffer* buffer) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t MovieFragment::ComputeSizeInternal() {
|
size_t MovieFragment::ComputeSizeInternal() {
|
||||||
uint32_t box_size = HeaderSize() + header.ComputeSize();
|
size_t box_size = HeaderSize() + header.ComputeSize();
|
||||||
for (uint32_t i = 0; i < tracks.size(); ++i)
|
for (uint32_t i = 0; i < tracks.size(); ++i)
|
||||||
box_size += tracks[i].ComputeSize();
|
box_size += tracks[i].ComputeSize();
|
||||||
for (uint32_t i = 0; i < pssh.size(); ++i)
|
for (uint32_t i = 0; i < pssh.size(); ++i)
|
||||||
|
@ -2573,7 +2579,7 @@ bool SegmentIndex::ReadWriteInternal(BoxBuffer* buffer) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t SegmentIndex::ComputeSizeInternal() {
|
size_t SegmentIndex::ComputeSizeInternal() {
|
||||||
version = IsFitIn32Bits(earliest_presentation_time, first_offset) ? 0 : 1;
|
version = IsFitIn32Bits(earliest_presentation_time, first_offset) ? 0 : 1;
|
||||||
return HeaderSize() + sizeof(reference_id) + sizeof(timescale) +
|
return HeaderSize() + sizeof(reference_id) + sizeof(timescale) +
|
||||||
sizeof(uint32_t) * (1 + version) * 2 + 2 * sizeof(uint16_t) +
|
sizeof(uint32_t) * (1 + version) * 2 + 2 * sizeof(uint16_t) +
|
||||||
|
@ -2589,7 +2595,7 @@ bool MediaData::ReadWriteInternal(BoxBuffer* buffer) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t MediaData::ComputeSizeInternal() {
|
size_t MediaData::ComputeSizeInternal() {
|
||||||
return HeaderSize() + data_size;
|
return HeaderSize() + data_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2603,7 +2609,7 @@ bool CueSourceIDBox::ReadWriteInternal(BoxBuffer* buffer) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t CueSourceIDBox::ComputeSizeInternal() {
|
size_t CueSourceIDBox::ComputeSizeInternal() {
|
||||||
if (source_id == kCueSourceIdNotSet)
|
if (source_id == kCueSourceIdNotSet)
|
||||||
return 0;
|
return 0;
|
||||||
return HeaderSize() + sizeof(source_id);
|
return HeaderSize() + sizeof(source_id);
|
||||||
|
@ -2623,7 +2629,7 @@ bool CueTimeBox::ReadWriteInternal(BoxBuffer* buffer) {
|
||||||
buffer->Reading() ? buffer->BytesLeft() : cue_current_time.size());
|
buffer->Reading() ? buffer->BytesLeft() : cue_current_time.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t CueTimeBox::ComputeSizeInternal() {
|
size_t CueTimeBox::ComputeSizeInternal() {
|
||||||
if (cue_current_time.empty())
|
if (cue_current_time.empty())
|
||||||
return 0;
|
return 0;
|
||||||
return HeaderSize() + cue_current_time.size();
|
return HeaderSize() + cue_current_time.size();
|
||||||
|
@ -2642,7 +2648,7 @@ bool CueIDBox::ReadWriteInternal(BoxBuffer* buffer) {
|
||||||
&cue_id, buffer->Reading() ? buffer->BytesLeft() : cue_id.size());
|
&cue_id, buffer->Reading() ? buffer->BytesLeft() : cue_id.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t CueIDBox::ComputeSizeInternal() {
|
size_t CueIDBox::ComputeSizeInternal() {
|
||||||
if (cue_id.empty())
|
if (cue_id.empty())
|
||||||
return 0;
|
return 0;
|
||||||
return HeaderSize() + cue_id.size();
|
return HeaderSize() + cue_id.size();
|
||||||
|
@ -2661,7 +2667,7 @@ bool CueSettingsBox::ReadWriteInternal(BoxBuffer* buffer) {
|
||||||
&settings, buffer->Reading() ? buffer->BytesLeft() : settings.size());
|
&settings, buffer->Reading() ? buffer->BytesLeft() : settings.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t CueSettingsBox::ComputeSizeInternal() {
|
size_t CueSettingsBox::ComputeSizeInternal() {
|
||||||
if (settings.empty())
|
if (settings.empty())
|
||||||
return 0;
|
return 0;
|
||||||
return HeaderSize() + settings.size();
|
return HeaderSize() + settings.size();
|
||||||
|
@ -2680,7 +2686,7 @@ bool CuePayloadBox::ReadWriteInternal(BoxBuffer* buffer) {
|
||||||
&cue_text, buffer->Reading() ? buffer->BytesLeft() : cue_text.size());
|
&cue_text, buffer->Reading() ? buffer->BytesLeft() : cue_text.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t CuePayloadBox::ComputeSizeInternal() {
|
size_t CuePayloadBox::ComputeSizeInternal() {
|
||||||
return HeaderSize() + cue_text.size();
|
return HeaderSize() + cue_text.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2695,7 +2701,7 @@ bool VTTEmptyCueBox::ReadWriteInternal(BoxBuffer* buffer) {
|
||||||
return ReadWriteHeaderInternal(buffer);
|
return ReadWriteHeaderInternal(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t VTTEmptyCueBox::ComputeSizeInternal() {
|
size_t VTTEmptyCueBox::ComputeSizeInternal() {
|
||||||
return HeaderSize();
|
return HeaderSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2713,7 +2719,7 @@ bool VTTAdditionalTextBox::ReadWriteInternal(BoxBuffer* buffer) {
|
||||||
buffer->Reading() ? buffer->BytesLeft() : cue_additional_text.size());
|
buffer->Reading() ? buffer->BytesLeft() : cue_additional_text.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t VTTAdditionalTextBox::ComputeSizeInternal() {
|
size_t VTTAdditionalTextBox::ComputeSizeInternal() {
|
||||||
return HeaderSize() + cue_additional_text.size();
|
return HeaderSize() + cue_additional_text.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2735,7 +2741,7 @@ bool VTTCueBox::ReadWriteInternal(BoxBuffer* buffer) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t VTTCueBox::ComputeSizeInternal() {
|
size_t VTTCueBox::ComputeSizeInternal() {
|
||||||
return HeaderSize() + cue_source_id.ComputeSize() + cue_id.ComputeSize() +
|
return HeaderSize() + cue_source_id.ComputeSize() + cue_id.ComputeSize() +
|
||||||
cue_time.ComputeSize() + cue_settings.ComputeSize() +
|
cue_time.ComputeSize() + cue_settings.ComputeSize() +
|
||||||
cue_payload.ComputeSize();
|
cue_payload.ComputeSize();
|
||||||
|
|
|
@ -38,7 +38,7 @@ class BoxBuffer;
|
||||||
\
|
\
|
||||||
private: \
|
private: \
|
||||||
bool ReadWriteInternal(BoxBuffer* buffer) override; \
|
bool ReadWriteInternal(BoxBuffer* buffer) override; \
|
||||||
uint32_t ComputeSizeInternal() override; \
|
size_t ComputeSizeInternal() override; \
|
||||||
\
|
\
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@ class BoxDefinitionsTestGeneral : public testing::Test {
|
||||||
// Create a fake skip box contains the buffer and Write it.
|
// Create a fake skip box contains the buffer and Write it.
|
||||||
BufferWriter buffer;
|
BufferWriter buffer;
|
||||||
buffer.Swap(buffer_.get());
|
buffer.Swap(buffer_.get());
|
||||||
uint32_t skip_box_size = buffer.Size() + kBoxSize;
|
uint32_t skip_box_size = static_cast<uint32_t>(buffer.Size() + kBoxSize);
|
||||||
buffer_->AppendInt(skip_box_size);
|
buffer_->AppendInt(skip_box_size);
|
||||||
buffer_->AppendInt(static_cast<uint32_t>(FOURCC_skip));
|
buffer_->AppendInt(static_cast<uint32_t>(FOURCC_skip));
|
||||||
buffer_->AppendBuffer(buffer);
|
buffer_->AppendBuffer(buffer);
|
||||||
|
|
|
@ -35,7 +35,7 @@ struct FreeBox : Box {
|
||||||
bool ReadWriteInternal(BoxBuffer* buffer) override {
|
bool ReadWriteInternal(BoxBuffer* buffer) override {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
uint32_t ComputeSizeInternal() override {
|
size_t ComputeSizeInternal() override {
|
||||||
NOTIMPLEMENTED();
|
NOTIMPLEMENTED();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ struct PsshBox : Box {
|
||||||
bool ReadWriteInternal(BoxBuffer* buffer) override {
|
bool ReadWriteInternal(BoxBuffer* buffer) override {
|
||||||
return buffer->ReadWriteUInt32(&val);
|
return buffer->ReadWriteUInt32(&val);
|
||||||
}
|
}
|
||||||
uint32_t ComputeSizeInternal() override {
|
size_t ComputeSizeInternal() override {
|
||||||
NOTIMPLEMENTED();
|
NOTIMPLEMENTED();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -70,7 +70,7 @@ struct SkipBox : FullBox {
|
||||||
}
|
}
|
||||||
return buffer->TryReadWriteChild(&empty);
|
return buffer->TryReadWriteChild(&empty);
|
||||||
}
|
}
|
||||||
uint32_t ComputeSizeInternal() override {
|
size_t ComputeSizeInternal() override {
|
||||||
NOTIMPLEMENTED();
|
NOTIMPLEMENTED();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -179,7 +179,8 @@ void EncryptingFragmenter::FinalizeFragmentForEncryption() {
|
||||||
|
|
||||||
// Optimize saiz box.
|
// Optimize saiz box.
|
||||||
SampleAuxiliaryInformationSize& saiz = traf()->auxiliary_size;
|
SampleAuxiliaryInformationSize& saiz = traf()->auxiliary_size;
|
||||||
saiz.sample_count = traf()->runs[0].sample_sizes.size();
|
saiz.sample_count =
|
||||||
|
static_cast<uint32_t>(traf()->runs[0].sample_sizes.size());
|
||||||
if (!saiz.sample_info_sizes.empty()) {
|
if (!saiz.sample_info_sizes.empty()) {
|
||||||
if (!OptimizeSampleEntries(&saiz.sample_info_sizes,
|
if (!OptimizeSampleEntries(&saiz.sample_info_sizes,
|
||||||
&saiz.default_sample_info_size)) {
|
&saiz.default_sample_info_size)) {
|
||||||
|
@ -242,7 +243,7 @@ Status EncryptingFragmenter::CreateEncryptor() {
|
||||||
return Status::OK;
|
return Status::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EncryptingFragmenter::EncryptBytes(uint8_t* data, uint32_t size) {
|
void EncryptingFragmenter::EncryptBytes(uint8_t* data, size_t size) {
|
||||||
DCHECK(encryptor_);
|
DCHECK(encryptor_);
|
||||||
CHECK(encryptor_->Crypt(data, size, data));
|
CHECK(encryptor_->Crypt(data, size, data));
|
||||||
}
|
}
|
||||||
|
@ -268,8 +269,8 @@ Status EncryptingFragmenter::EncryptSample(scoped_refptr<MediaSample> sample) {
|
||||||
SubsampleEntry subsample;
|
SubsampleEntry subsample;
|
||||||
subsample.clear_bytes =
|
subsample.clear_bytes =
|
||||||
static_cast<uint16_t>(frame.uncompressed_header_size);
|
static_cast<uint16_t>(frame.uncompressed_header_size);
|
||||||
subsample.cipher_bytes =
|
subsample.cipher_bytes = static_cast<uint32_t>(
|
||||||
frame.frame_size - frame.uncompressed_header_size;
|
frame.frame_size - frame.uncompressed_header_size);
|
||||||
|
|
||||||
// "VP Codec ISO Media File Format Binding" document requires that the
|
// "VP Codec ISO Media File Format Binding" document requires that the
|
||||||
// encrypted bytes of each frame within the superframe must be block
|
// encrypted bytes of each frame within the superframe must be block
|
||||||
|
|
|
@ -79,7 +79,7 @@ class EncryptingFragmenter : public Fragmenter {
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void EncryptBytes(uint8_t* data, uint32_t size);
|
void EncryptBytes(uint8_t* data, size_t size);
|
||||||
Status EncryptSample(scoped_refptr<MediaSample> sample);
|
Status EncryptSample(scoped_refptr<MediaSample> sample);
|
||||||
|
|
||||||
// Should we enable subsample encryption?
|
// Should we enable subsample encryption?
|
||||||
|
|
|
@ -60,7 +60,8 @@ Status Fragmenter::AddSample(scoped_refptr<MediaSample> sample) {
|
||||||
LOG(WARNING) << "MP4 samples do not support side data. Side data ignored.";
|
LOG(WARNING) << "MP4 samples do not support side data. Side data ignored.";
|
||||||
|
|
||||||
// Fill in sample parameters. It will be optimized later.
|
// Fill in sample parameters. It will be optimized later.
|
||||||
traf_->runs[0].sample_sizes.push_back(sample->data_size());
|
traf_->runs[0].sample_sizes.push_back(
|
||||||
|
static_cast<uint32_t>(sample->data_size()));
|
||||||
traf_->runs[0].sample_durations.push_back(sample->duration());
|
traf_->runs[0].sample_durations.push_back(sample->duration());
|
||||||
traf_->runs[0].sample_flags.push_back(
|
traf_->runs[0].sample_flags.push_back(
|
||||||
sample->is_key_frame() ? 0 : TrackFragmentHeader::kNonKeySampleMask);
|
sample->is_key_frame() ? 0 : TrackFragmentHeader::kNonKeySampleMask);
|
||||||
|
@ -109,7 +110,8 @@ Status Fragmenter::InitializeFragment(int64_t first_sample_dts) {
|
||||||
|
|
||||||
void Fragmenter::FinalizeFragment() {
|
void Fragmenter::FinalizeFragment() {
|
||||||
// Optimize trun box.
|
// Optimize trun box.
|
||||||
traf_->runs[0].sample_count = traf_->runs[0].sample_sizes.size();
|
traf_->runs[0].sample_count =
|
||||||
|
static_cast<uint32_t>(traf_->runs[0].sample_sizes.size());
|
||||||
if (OptimizeSampleEntries(&traf_->runs[0].sample_durations,
|
if (OptimizeSampleEntries(&traf_->runs[0].sample_durations,
|
||||||
&traf_->header.default_sample_duration)) {
|
&traf_->header.default_sample_duration)) {
|
||||||
traf_->header.flags |=
|
traf_->header.flags |=
|
||||||
|
|
|
@ -269,7 +269,7 @@ bool MP4MediaParser::ParseBox(bool* err) {
|
||||||
VLOG(2) << "Skipping top-level box: " << FourCCToString(reader->type());
|
VLOG(2) << "Skipping top-level box: " << FourCCToString(reader->type());
|
||||||
}
|
}
|
||||||
|
|
||||||
queue_.Pop(reader->size());
|
queue_.Pop(static_cast<int>(reader->size()));
|
||||||
return !(*err);
|
return !(*err);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,7 @@ class MP4MediaParserTest : public testing::Test {
|
||||||
size_t num_samples_;
|
size_t num_samples_;
|
||||||
|
|
||||||
bool AppendData(const uint8_t* data, size_t length) {
|
bool AppendData(const uint8_t* data, size_t length) {
|
||||||
return parser_->Parse(data, length);
|
return parser_->Parse(data, static_cast<int>(length));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AppendDataInPieces(const uint8_t* data,
|
bool AppendDataInPieces(const uint8_t* data,
|
||||||
|
|
|
@ -101,7 +101,7 @@ Status MP4Muxer::Initialize() {
|
||||||
|
|
||||||
moov->header.creation_time = IsoTimeNow();
|
moov->header.creation_time = IsoTimeNow();
|
||||||
moov->header.modification_time = IsoTimeNow();
|
moov->header.modification_time = IsoTimeNow();
|
||||||
moov->header.next_track_id = streams().size() + 1;
|
moov->header.next_track_id = static_cast<uint32_t>(streams().size()) + 1;
|
||||||
|
|
||||||
moov->tracks.resize(streams().size());
|
moov->tracks.resize(streams().size());
|
||||||
moov->extends.tracks.resize(streams().size());
|
moov->extends.tracks.resize(streams().size());
|
||||||
|
|
|
@ -85,18 +85,18 @@ Status MultiSegmentSegmenter::DoFinalizeSegment() {
|
||||||
// sidx() contains pre-generated segment references with one reference per
|
// sidx() contains pre-generated segment references with one reference per
|
||||||
// fragment. Calculate |num_fragments_per_subsegment| and combine
|
// fragment. Calculate |num_fragments_per_subsegment| and combine
|
||||||
// pre-generated references into final subsegment references.
|
// pre-generated references into final subsegment references.
|
||||||
uint32_t num_fragments = sidx()->references.size();
|
size_t num_fragments = sidx()->references.size();
|
||||||
uint32_t num_fragments_per_subsegment =
|
size_t num_fragments_per_subsegment =
|
||||||
(num_fragments - 1) / options().num_subsegments_per_sidx + 1;
|
(num_fragments - 1) / options().num_subsegments_per_sidx + 1;
|
||||||
if (num_fragments_per_subsegment <= 1)
|
if (num_fragments_per_subsegment <= 1)
|
||||||
return WriteSegment();
|
return WriteSegment();
|
||||||
|
|
||||||
uint32_t frag_index = 0;
|
size_t frag_index = 0;
|
||||||
uint32_t subseg_index = 0;
|
size_t subseg_index = 0;
|
||||||
std::vector<SegmentReference>& refs = sidx()->references;
|
std::vector<SegmentReference>& refs = sidx()->references;
|
||||||
uint64_t first_sap_time =
|
uint64_t first_sap_time =
|
||||||
refs[0].sap_delta_time + refs[0].earliest_presentation_time;
|
refs[0].sap_delta_time + refs[0].earliest_presentation_time;
|
||||||
for (uint32_t i = 1; i < num_fragments; ++i) {
|
for (size_t i = 1; i < num_fragments; ++i) {
|
||||||
refs[subseg_index].referenced_size += refs[i].referenced_size;
|
refs[subseg_index].referenced_size += refs[i].referenced_size;
|
||||||
refs[subseg_index].subsegment_duration += refs[i].subsegment_duration;
|
refs[subseg_index].subsegment_duration += refs[i].subsegment_duration;
|
||||||
refs[subseg_index].earliest_presentation_time =
|
refs[subseg_index].earliest_presentation_time =
|
||||||
|
|
|
@ -456,7 +456,7 @@ Status Segmenter::FinalizeFragment(bool finalize_segment,
|
||||||
sizeof(uint32_t); // for sample count field in 'senc'
|
sizeof(uint32_t); // for sample count field in 'senc'
|
||||||
}
|
}
|
||||||
traf.runs[0].data_offset = data_offset + mdat.data_size;
|
traf.runs[0].data_offset = data_offset + mdat.data_size;
|
||||||
mdat.data_size += fragmenters_[i]->data()->Size();
|
mdat.data_size += static_cast<uint32_t>(fragmenters_[i]->data()->Size());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate segment reference.
|
// Generate segment reference.
|
||||||
|
|
|
@ -79,7 +79,7 @@ TrackRunIterator::~TrackRunIterator() {}
|
||||||
static void PopulateSampleInfo(const TrackExtends& trex,
|
static void PopulateSampleInfo(const TrackExtends& trex,
|
||||||
const TrackFragmentHeader& tfhd,
|
const TrackFragmentHeader& tfhd,
|
||||||
const TrackFragmentRun& trun,
|
const TrackFragmentRun& trun,
|
||||||
const uint32_t i,
|
const size_t i,
|
||||||
SampleInfo* sample_info) {
|
SampleInfo* sample_info) {
|
||||||
if (i < trun.sample_sizes.size()) {
|
if (i < trun.sample_sizes.size()) {
|
||||||
sample_info->size = trun.sample_sizes[i];
|
sample_info->size = trun.sample_sizes[i];
|
||||||
|
@ -187,7 +187,7 @@ bool TrackRunIterator::Init() {
|
||||||
int64_t run_start_dts = 0;
|
int64_t run_start_dts = 0;
|
||||||
|
|
||||||
uint32_t num_samples = sample_size.sample_count;
|
uint32_t num_samples = sample_size.sample_count;
|
||||||
uint32_t num_chunks = chunk_offset_vector.size();
|
uint32_t num_chunks = static_cast<uint32_t>(chunk_offset_vector.size());
|
||||||
|
|
||||||
// Check that total number of samples match.
|
// Check that total number of samples match.
|
||||||
DCHECK_EQ(num_samples, decoding_time.NumSamples());
|
DCHECK_EQ(num_samples, decoding_time.NumSamples());
|
||||||
|
@ -410,7 +410,8 @@ bool TrackRunIterator::Init(const MovieFragment& moof) {
|
||||||
|
|
||||||
tri.samples.resize(trun.sample_count);
|
tri.samples.resize(trun.sample_count);
|
||||||
for (size_t k = 0; k < trun.sample_count; k++) {
|
for (size_t k = 0; k < trun.sample_count; k++) {
|
||||||
PopulateSampleInfo(*trex, traf.header, trun, k, &tri.samples[k]);
|
PopulateSampleInfo(*trex, traf.header, trun, k,
|
||||||
|
&tri.samples[k]);
|
||||||
run_start_dts += tri.samples[k].duration;
|
run_start_dts += tri.samples[k].duration;
|
||||||
}
|
}
|
||||||
runs_.push_back(tri);
|
runs_.push_back(tri);
|
||||||
|
|
|
@ -277,7 +277,7 @@ class TrackRunIteratorTest : public testing::Test {
|
||||||
void SetAscending(std::vector<uint32_t>* vec) {
|
void SetAscending(std::vector<uint32_t>* vec) {
|
||||||
vec->resize(10);
|
vec->resize(10);
|
||||||
for (size_t i = 0; i < vec->size(); i++)
|
for (size_t i = 0; i < vec->size(); i++)
|
||||||
(*vec)[i] = i + 1;
|
(*vec)[i] = static_cast<uint32_t>(i + 1);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -118,10 +118,11 @@ Status Encryptor::EncryptFrame(scoped_refptr<MediaSample> sample,
|
||||||
uint32_t partition_offset = 0;
|
uint32_t partition_offset = 0;
|
||||||
BufferWriter offsets_buffer(kWebMPartitionOffsetSize * num_partitions);
|
BufferWriter offsets_buffer(kWebMPartitionOffsetSize * num_partitions);
|
||||||
for (const auto& vpx_frame : vpx_frames) {
|
for (const auto& vpx_frame : vpx_frames) {
|
||||||
uint32_t encrypted_size =
|
uint32_t encrypted_size = static_cast<uint32_t>(
|
||||||
vpx_frame.frame_size - vpx_frame.uncompressed_header_size;
|
vpx_frame.frame_size - vpx_frame.uncompressed_header_size);
|
||||||
encrypted_size -= encrypted_size % kAesBlockSize;
|
encrypted_size -= encrypted_size % kAesBlockSize;
|
||||||
uint32_t clear_size = vpx_frame.frame_size - encrypted_size;
|
uint32_t clear_size =
|
||||||
|
static_cast<uint32_t>(vpx_frame.frame_size - encrypted_size);
|
||||||
partition_offset += clear_size;
|
partition_offset += clear_size;
|
||||||
offsets_buffer.AppendInt(partition_offset);
|
offsets_buffer.AppendInt(partition_offset);
|
||||||
if (encrypted_size > 0) {
|
if (encrypted_size > 0) {
|
||||||
|
|
|
@ -142,11 +142,11 @@ TEST_F(MultiSegmentSegmenterTest, SplitsFilesOnSegmentDuration) {
|
||||||
// Verify the resulting data.
|
// Verify the resulting data.
|
||||||
ClusterParser parser;
|
ClusterParser parser;
|
||||||
ASSERT_NO_FATAL_FAILURE(parser.PopulateFromCluster(TemplateFileName(0)));
|
ASSERT_NO_FATAL_FAILURE(parser.PopulateFromCluster(TemplateFileName(0)));
|
||||||
ASSERT_EQ(1, parser.cluster_count());
|
ASSERT_EQ(1u, parser.cluster_count());
|
||||||
EXPECT_EQ(5, parser.GetFrameCountForCluster(0));
|
EXPECT_EQ(5, parser.GetFrameCountForCluster(0));
|
||||||
|
|
||||||
ASSERT_NO_FATAL_FAILURE(parser.PopulateFromCluster(TemplateFileName(1)));
|
ASSERT_NO_FATAL_FAILURE(parser.PopulateFromCluster(TemplateFileName(1)));
|
||||||
ASSERT_EQ(1, parser.cluster_count());
|
ASSERT_EQ(1u, parser.cluster_count());
|
||||||
EXPECT_EQ(3, parser.GetFrameCountForCluster(0));
|
EXPECT_EQ(3, parser.GetFrameCountForCluster(0));
|
||||||
|
|
||||||
EXPECT_FALSE(File::Open(TemplateFileName(2).c_str(), "r"));
|
EXPECT_FALSE(File::Open(TemplateFileName(2).c_str(), "r"));
|
||||||
|
@ -170,11 +170,11 @@ TEST_F(MultiSegmentSegmenterTest, RespectsSegmentSAPAlign) {
|
||||||
// Verify the resulting data.
|
// Verify the resulting data.
|
||||||
ClusterParser parser;
|
ClusterParser parser;
|
||||||
ASSERT_NO_FATAL_FAILURE(parser.PopulateFromCluster(TemplateFileName(0)));
|
ASSERT_NO_FATAL_FAILURE(parser.PopulateFromCluster(TemplateFileName(0)));
|
||||||
ASSERT_EQ(1, parser.cluster_count());
|
ASSERT_EQ(1u, parser.cluster_count());
|
||||||
EXPECT_EQ(6, parser.GetFrameCountForCluster(0));
|
EXPECT_EQ(6, parser.GetFrameCountForCluster(0));
|
||||||
|
|
||||||
ASSERT_NO_FATAL_FAILURE(parser.PopulateFromCluster(TemplateFileName(1)));
|
ASSERT_NO_FATAL_FAILURE(parser.PopulateFromCluster(TemplateFileName(1)));
|
||||||
ASSERT_EQ(1, parser.cluster_count());
|
ASSERT_EQ(1u, parser.cluster_count());
|
||||||
EXPECT_EQ(4, parser.GetFrameCountForCluster(0));
|
EXPECT_EQ(4, parser.GetFrameCountForCluster(0));
|
||||||
|
|
||||||
EXPECT_FALSE(File::Open(TemplateFileName(2).c_str(), "r"));
|
EXPECT_FALSE(File::Open(TemplateFileName(2).c_str(), "r"));
|
||||||
|
@ -196,7 +196,7 @@ TEST_F(MultiSegmentSegmenterTest, SplitsClustersOnFragmentDuration) {
|
||||||
// Verify the resulting data.
|
// Verify the resulting data.
|
||||||
ClusterParser parser;
|
ClusterParser parser;
|
||||||
ASSERT_NO_FATAL_FAILURE(parser.PopulateFromCluster(TemplateFileName(0)));
|
ASSERT_NO_FATAL_FAILURE(parser.PopulateFromCluster(TemplateFileName(0)));
|
||||||
ASSERT_EQ(2, parser.cluster_count());
|
ASSERT_EQ(2u, parser.cluster_count());
|
||||||
EXPECT_EQ(5, parser.GetFrameCountForCluster(0));
|
EXPECT_EQ(5, parser.GetFrameCountForCluster(0));
|
||||||
EXPECT_EQ(3, parser.GetFrameCountForCluster(1));
|
EXPECT_EQ(3, parser.GetFrameCountForCluster(1));
|
||||||
|
|
||||||
|
@ -221,7 +221,7 @@ TEST_F(MultiSegmentSegmenterTest, RespectsFragmentSAPAlign) {
|
||||||
// Verify the resulting data.
|
// Verify the resulting data.
|
||||||
ClusterParser parser;
|
ClusterParser parser;
|
||||||
ASSERT_NO_FATAL_FAILURE(parser.PopulateFromCluster(TemplateFileName(0)));
|
ASSERT_NO_FATAL_FAILURE(parser.PopulateFromCluster(TemplateFileName(0)));
|
||||||
ASSERT_EQ(2, parser.cluster_count());
|
ASSERT_EQ(2u, parser.cluster_count());
|
||||||
EXPECT_EQ(6, parser.GetFrameCountForCluster(0));
|
EXPECT_EQ(6, parser.GetFrameCountForCluster(0));
|
||||||
EXPECT_EQ(4, parser.GetFrameCountForCluster(1));
|
EXPECT_EQ(4, parser.GetFrameCountForCluster(1));
|
||||||
|
|
||||||
|
|
|
@ -121,7 +121,8 @@ void SegmentTestBase::ClusterParser::PopulateFromCluster(
|
||||||
WebMListParser cluster_parser(kWebMIdCluster, this);
|
WebMListParser cluster_parser(kWebMIdCluster, this);
|
||||||
size_t position = 0;
|
size_t position = 0;
|
||||||
while (position < size) {
|
while (position < size) {
|
||||||
int read = cluster_parser.Parse(data + position, size - position);
|
int read = cluster_parser.Parse(data + position,
|
||||||
|
static_cast<int>(size - position));
|
||||||
ASSERT_LT(0, read);
|
ASSERT_LT(0, read);
|
||||||
|
|
||||||
cluster_parser.Reset();
|
cluster_parser.Reset();
|
||||||
|
@ -138,11 +139,12 @@ void SegmentTestBase::ClusterParser::PopulateFromSegment(
|
||||||
const uint8_t* data = reinterpret_cast<const uint8_t*>(file_contents.c_str());
|
const uint8_t* data = reinterpret_cast<const uint8_t*>(file_contents.c_str());
|
||||||
const size_t size = file_contents.size();
|
const size_t size = file_contents.size();
|
||||||
WebMListParser header_parser(kWebMIdEBMLHeader, this);
|
WebMListParser header_parser(kWebMIdEBMLHeader, this);
|
||||||
int offset = header_parser.Parse(data, size);
|
int offset = header_parser.Parse(data, static_cast<int>(size));
|
||||||
ASSERT_LT(0, offset);
|
ASSERT_LT(0, offset);
|
||||||
|
|
||||||
WebMListParser segment_parser(kWebMIdSegment, this);
|
WebMListParser segment_parser(kWebMIdSegment, this);
|
||||||
ASSERT_LT(0, segment_parser.Parse(data + offset, size - offset));
|
ASSERT_LT(
|
||||||
|
0, segment_parser.Parse(data + offset, static_cast<int>(size) - offset));
|
||||||
}
|
}
|
||||||
|
|
||||||
int SegmentTestBase::ClusterParser::GetFrameCountForCluster(size_t i) const {
|
int SegmentTestBase::ClusterParser::GetFrameCountForCluster(size_t i) const {
|
||||||
|
@ -150,7 +152,7 @@ int SegmentTestBase::ClusterParser::GetFrameCountForCluster(size_t i) const {
|
||||||
return cluster_sizes_[i];
|
return cluster_sizes_[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
int SegmentTestBase::ClusterParser::cluster_count() const {
|
size_t SegmentTestBase::ClusterParser::cluster_count() const {
|
||||||
return cluster_sizes_.size();
|
return cluster_sizes_.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -89,7 +89,7 @@ class SegmentTestBase : public ::testing::Test {
|
||||||
|
|
||||||
int GetFrameCountForCluster(size_t i) const;
|
int GetFrameCountForCluster(size_t i) const;
|
||||||
|
|
||||||
int cluster_count() const;
|
size_t cluster_count() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// WebMParserClient overrides.
|
// WebMParserClient overrides.
|
||||||
|
|
|
@ -180,7 +180,7 @@ TEST_F(SingleSegmentSegmenterTest, SplitsClustersOnSegmentDuration) {
|
||||||
// Verify the resulting data.
|
// Verify the resulting data.
|
||||||
ClusterParser parser;
|
ClusterParser parser;
|
||||||
ASSERT_NO_FATAL_FAILURE(parser.PopulateFromSegment(OutputFileName()));
|
ASSERT_NO_FATAL_FAILURE(parser.PopulateFromSegment(OutputFileName()));
|
||||||
ASSERT_EQ(2, parser.cluster_count());
|
ASSERT_EQ(2u, parser.cluster_count());
|
||||||
EXPECT_EQ(5, parser.GetFrameCountForCluster(0));
|
EXPECT_EQ(5, parser.GetFrameCountForCluster(0));
|
||||||
EXPECT_EQ(3, parser.GetFrameCountForCluster(1));
|
EXPECT_EQ(3, parser.GetFrameCountForCluster(1));
|
||||||
}
|
}
|
||||||
|
@ -201,7 +201,7 @@ TEST_F(SingleSegmentSegmenterTest, IgnoresFragmentDuration) {
|
||||||
// Verify the resulting data.
|
// Verify the resulting data.
|
||||||
ClusterParser parser;
|
ClusterParser parser;
|
||||||
ASSERT_NO_FATAL_FAILURE(parser.PopulateFromSegment(OutputFileName()));
|
ASSERT_NO_FATAL_FAILURE(parser.PopulateFromSegment(OutputFileName()));
|
||||||
ASSERT_EQ(1, parser.cluster_count());
|
ASSERT_EQ(1u, parser.cluster_count());
|
||||||
EXPECT_EQ(8, parser.GetFrameCountForCluster(0));
|
EXPECT_EQ(8, parser.GetFrameCountForCluster(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -226,7 +226,7 @@ TEST_F(SingleSegmentSegmenterTest, RespectsSAPAlign) {
|
||||||
// Segments are 1 second, so there would normally be 3 frames per cluster,
|
// Segments are 1 second, so there would normally be 3 frames per cluster,
|
||||||
// but since it's SAP aligned and only frame 7 is a key-frame, there are
|
// but since it's SAP aligned and only frame 7 is a key-frame, there are
|
||||||
// two clusters with 6 and 4 frames respectively.
|
// two clusters with 6 and 4 frames respectively.
|
||||||
ASSERT_EQ(2, parser.cluster_count());
|
ASSERT_EQ(2u, parser.cluster_count());
|
||||||
EXPECT_EQ(6, parser.GetFrameCountForCluster(0));
|
EXPECT_EQ(6, parser.GetFrameCountForCluster(0));
|
||||||
EXPECT_EQ(4, parser.GetFrameCountForCluster(1));
|
EXPECT_EQ(4, parser.GetFrameCountForCluster(1));
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,9 +61,8 @@ static int DoubleElementSize(int element_id) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int StringElementSize(int element_id, const std::string& value) {
|
static int StringElementSize(int element_id, const std::string& value) {
|
||||||
return GetUIntSize(element_id) +
|
return GetUIntSize(element_id) + GetUIntMkvSize(value.length()) +
|
||||||
GetUIntMkvSize(value.length()) +
|
static_cast<int>(value.length());
|
||||||
value.length();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SerializeInt(uint8_t** buf_ptr,
|
static void SerializeInt(uint8_t** buf_ptr,
|
||||||
|
@ -196,7 +195,7 @@ std::vector<uint8_t> TracksBuilder::Finish() {
|
||||||
buffer.resize(GetTracksSize());
|
buffer.resize(GetTracksSize());
|
||||||
|
|
||||||
// Populate the storage with a tracks header
|
// Populate the storage with a tracks header
|
||||||
WriteTracks(&buffer[0], buffer.size());
|
WriteTracks(&buffer[0], static_cast<int>(buffer.size()));
|
||||||
|
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
|
@ -230,7 +230,7 @@ std::unique_ptr<Cluster> CreateCluster(int timecode,
|
||||||
std::unique_ptr<Cluster> CreateCluster(const uint8_t* data, size_t data_size) {
|
std::unique_ptr<Cluster> CreateCluster(const uint8_t* data, size_t data_size) {
|
||||||
ClusterBuilder cb;
|
ClusterBuilder cb;
|
||||||
cb.SetClusterTimecode(0);
|
cb.SetClusterTimecode(0);
|
||||||
cb.AddSimpleBlock(kVideoTrackNum, 0, 0, data, data_size);
|
cb.AddSimpleBlock(kVideoTrackNum, 0, 0, data, static_cast<int>(data_size));
|
||||||
return cb.Finish();
|
return cb.Finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -239,8 +239,8 @@ bool VerifyBuffersHelper(const BufferQueue& audio_buffers,
|
||||||
const BufferQueue& text_buffers,
|
const BufferQueue& text_buffers,
|
||||||
const BlockInfo* block_info,
|
const BlockInfo* block_info,
|
||||||
int block_count) {
|
int block_count) {
|
||||||
int buffer_count = audio_buffers.size() + video_buffers.size() +
|
int buffer_count = static_cast<int>(
|
||||||
text_buffers.size();
|
audio_buffers.size() + video_buffers.size() + text_buffers.size());
|
||||||
if (block_count != buffer_count) {
|
if (block_count != buffer_count) {
|
||||||
LOG(ERROR) << __FUNCTION__ << " : block_count (" << block_count
|
LOG(ERROR) << __FUNCTION__ << " : block_count (" << block_count
|
||||||
<< ") mismatches buffer_count (" << buffer_count << ")";
|
<< ") mismatches buffer_count (" << buffer_count << ")";
|
||||||
|
|
|
@ -30,7 +30,7 @@ std::vector<uint8_t> GenerateWebMCounterBlock(const uint8_t* iv, int iv_size) {
|
||||||
bool WebMCreateDecryptConfig(const uint8_t* data,
|
bool WebMCreateDecryptConfig(const uint8_t* data,
|
||||||
int data_size,
|
int data_size,
|
||||||
const uint8_t* key_id,
|
const uint8_t* key_id,
|
||||||
int key_id_size,
|
size_t key_id_size,
|
||||||
std::unique_ptr<DecryptConfig>* decrypt_config,
|
std::unique_ptr<DecryptConfig>* decrypt_config,
|
||||||
int* data_offset) {
|
int* data_offset) {
|
||||||
int header_size = kWebMSignalByteSize;
|
int header_size = kWebMSignalByteSize;
|
||||||
|
|
|
@ -23,7 +23,7 @@ namespace media {
|
||||||
bool WebMCreateDecryptConfig(const uint8_t* data,
|
bool WebMCreateDecryptConfig(const uint8_t* data,
|
||||||
int data_size,
|
int data_size,
|
||||||
const uint8_t* key_id,
|
const uint8_t* key_id,
|
||||||
int key_id_size,
|
size_t key_id_size,
|
||||||
std::unique_ptr<DecryptConfig>* decrypt_config,
|
std::unique_ptr<DecryptConfig>* decrypt_config,
|
||||||
int* data_offset);
|
int* data_offset);
|
||||||
|
|
||||||
|
|
|
@ -892,7 +892,8 @@ bool WebMListParser::OnListStart(int id, int64_t size) {
|
||||||
if (!element_info)
|
if (!element_info)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
int current_level = root_level_ + list_state_stack_.size() - 1;
|
int current_level =
|
||||||
|
root_level_ + static_cast<int>(list_state_stack_.size()) - 1;
|
||||||
if (current_level + 1 != element_info->level_)
|
if (current_level + 1 != element_info->level_)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
|
@ -345,7 +345,7 @@ TEST_F(WebMParserTest, ReservedIds) {
|
||||||
for (size_t i = 0; i < arraysize(kBuffers); i++) {
|
for (size_t i = 0; i < arraysize(kBuffers); i++) {
|
||||||
int id;
|
int id;
|
||||||
int64_t element_size;
|
int64_t element_size;
|
||||||
int buffer_size = 2 + i;
|
int buffer_size = 2 + static_cast<int>(i);
|
||||||
EXPECT_EQ(buffer_size, WebMParseElementHeader(kBuffers[i], buffer_size,
|
EXPECT_EQ(buffer_size, WebMParseElementHeader(kBuffers[i], buffer_size,
|
||||||
&id, &element_size));
|
&id, &element_size));
|
||||||
EXPECT_EQ(id, kWebMReservedId);
|
EXPECT_EQ(id, kWebMReservedId);
|
||||||
|
@ -373,7 +373,7 @@ TEST_F(WebMParserTest, ReservedSizes) {
|
||||||
for (size_t i = 0; i < arraysize(kBuffers); i++) {
|
for (size_t i = 0; i < arraysize(kBuffers); i++) {
|
||||||
int id;
|
int id;
|
||||||
int64_t element_size;
|
int64_t element_size;
|
||||||
int buffer_size = 2 + i;
|
int buffer_size = 2 + static_cast<int>(i);
|
||||||
EXPECT_EQ(buffer_size, WebMParseElementHeader(kBuffers[i], buffer_size,
|
EXPECT_EQ(buffer_size, WebMParseElementHeader(kBuffers[i], buffer_size,
|
||||||
&id, &element_size));
|
&id, &element_size));
|
||||||
EXPECT_EQ(id, 0xA3);
|
EXPECT_EQ(id, 0xA3);
|
||||||
|
|
|
@ -29,15 +29,15 @@ class WebMTracksParserTest : public testing::Test {
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void VerifyTextTrackInfo(const uint8_t* buffer,
|
void VerifyTextTrackInfo(const uint8_t* buffer,
|
||||||
int buffer_size,
|
size_t buffer_size,
|
||||||
TextKind text_kind,
|
TextKind text_kind,
|
||||||
const std::string& name,
|
const std::string& name,
|
||||||
const std::string& language) {
|
const std::string& language) {
|
||||||
std::unique_ptr<WebMTracksParser> parser(new WebMTracksParser(false));
|
std::unique_ptr<WebMTracksParser> parser(new WebMTracksParser(false));
|
||||||
|
|
||||||
int result = parser->Parse(buffer, buffer_size);
|
int result = parser->Parse(buffer, static_cast<int>(buffer_size));
|
||||||
EXPECT_GT(result, 0);
|
EXPECT_GT(result, 0);
|
||||||
EXPECT_EQ(result, buffer_size);
|
EXPECT_EQ(result, static_cast<int>(buffer_size));
|
||||||
|
|
||||||
const WebMTracksParser::TextTracks& text_tracks = parser->text_tracks();
|
const WebMTracksParser::TextTracks& text_tracks = parser->text_tracks();
|
||||||
EXPECT_EQ(text_tracks.size(), WebMTracksParser::TextTracks::size_type(1));
|
EXPECT_EQ(text_tracks.size(), WebMTracksParser::TextTracks::size_type(1));
|
||||||
|
@ -103,7 +103,7 @@ TEST_F(WebMTracksParserTest, IgnoringTextTracks) {
|
||||||
const std::vector<uint8_t> buf = tb.Finish();
|
const std::vector<uint8_t> buf = tb.Finish();
|
||||||
std::unique_ptr<WebMTracksParser> parser(new WebMTracksParser(true));
|
std::unique_ptr<WebMTracksParser> parser(new WebMTracksParser(true));
|
||||||
|
|
||||||
int result = parser->Parse(&buf[0], buf.size());
|
int result = parser->Parse(&buf[0], static_cast<int>(buf.size()));
|
||||||
EXPECT_GT(result, 0);
|
EXPECT_GT(result, 0);
|
||||||
EXPECT_EQ(result, static_cast<int>(buf.size()));
|
EXPECT_EQ(result, static_cast<int>(buf.size()));
|
||||||
|
|
||||||
|
@ -116,7 +116,7 @@ TEST_F(WebMTracksParserTest, IgnoringTextTracks) {
|
||||||
// Test again w/o ignoring the test tracks.
|
// Test again w/o ignoring the test tracks.
|
||||||
parser.reset(new WebMTracksParser(false));
|
parser.reset(new WebMTracksParser(false));
|
||||||
|
|
||||||
result = parser->Parse(&buf[0], buf.size());
|
result = parser->Parse(&buf[0], static_cast<int>(buf.size()));
|
||||||
EXPECT_GT(result, 0);
|
EXPECT_GT(result, 0);
|
||||||
|
|
||||||
EXPECT_EQ(parser->ignored_tracks().size(), 0u);
|
EXPECT_EQ(parser->ignored_tracks().size(), 0u);
|
||||||
|
@ -135,7 +135,7 @@ TEST_F(WebMTracksParserTest, AudioVideoDefaultDurationUnset) {
|
||||||
const std::vector<uint8_t> buf = tb.Finish();
|
const std::vector<uint8_t> buf = tb.Finish();
|
||||||
|
|
||||||
std::unique_ptr<WebMTracksParser> parser(new WebMTracksParser(true));
|
std::unique_ptr<WebMTracksParser> parser(new WebMTracksParser(true));
|
||||||
int result = parser->Parse(&buf[0], buf.size());
|
int result = parser->Parse(&buf[0], static_cast<int>(buf.size()));
|
||||||
EXPECT_LE(0, result);
|
EXPECT_LE(0, result);
|
||||||
EXPECT_EQ(static_cast<int>(buf.size()), result);
|
EXPECT_EQ(static_cast<int>(buf.size()), result);
|
||||||
|
|
||||||
|
@ -166,7 +166,7 @@ TEST_F(WebMTracksParserTest, AudioVideoDefaultDurationSet) {
|
||||||
const std::vector<uint8_t> buf = tb.Finish();
|
const std::vector<uint8_t> buf = tb.Finish();
|
||||||
|
|
||||||
std::unique_ptr<WebMTracksParser> parser(new WebMTracksParser(true));
|
std::unique_ptr<WebMTracksParser> parser(new WebMTracksParser(true));
|
||||||
int result = parser->Parse(&buf[0], buf.size());
|
int result = parser->Parse(&buf[0], static_cast<int>(buf.size()));
|
||||||
EXPECT_LE(0, result);
|
EXPECT_LE(0, result);
|
||||||
EXPECT_EQ(static_cast<int>(buf.size()), result);
|
EXPECT_EQ(static_cast<int>(buf.size()), result);
|
||||||
|
|
||||||
|
@ -187,7 +187,7 @@ TEST_F(WebMTracksParserTest, InvalidZeroDefaultDurationSet) {
|
||||||
|
|
||||||
std::unique_ptr<WebMTracksParser> parser(new WebMTracksParser(true));
|
std::unique_ptr<WebMTracksParser> parser(new WebMTracksParser(true));
|
||||||
|
|
||||||
EXPECT_EQ(-1, parser->Parse(&buf[0], buf.size()));
|
EXPECT_EQ(-1, parser->Parse(&buf[0], static_cast<int>(buf.size())));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(WebMTracksParserTest, HighTrackUID) {
|
TEST_F(WebMTracksParserTest, HighTrackUID) {
|
||||||
|
@ -198,7 +198,7 @@ TEST_F(WebMTracksParserTest, HighTrackUID) {
|
||||||
const std::vector<uint8_t> buf = tb.Finish();
|
const std::vector<uint8_t> buf = tb.Finish();
|
||||||
|
|
||||||
std::unique_ptr<WebMTracksParser> parser(new WebMTracksParser(true));
|
std::unique_ptr<WebMTracksParser> parser(new WebMTracksParser(true));
|
||||||
EXPECT_GT(parser->Parse(&buf[0], buf.size()),0);
|
EXPECT_GT(parser->Parse(&buf[0], static_cast<int>(buf.size())), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace media
|
} // namespace media
|
||||||
|
|
|
@ -48,7 +48,7 @@ const uint32_t kPesStreamIdVideo = 0xE0;
|
||||||
const uint32_t kPesStreamIdAudioMask = 0xE0;
|
const uint32_t kPesStreamIdAudioMask = 0xE0;
|
||||||
const uint32_t kPesStreamIdAudio = 0xC0;
|
const uint32_t kPesStreamIdAudio = 0xC0;
|
||||||
const uint32_t kVersion4 = 4;
|
const uint32_t kVersion4 = 4;
|
||||||
const int kAdtsHeaderMinSize = 7;
|
const size_t kAdtsHeaderMinSize = 7;
|
||||||
const uint8_t kAacSampleSizeBits = 16;
|
const uint8_t kAacSampleSizeBits = 16;
|
||||||
// Applies to all video streams.
|
// Applies to all video streams.
|
||||||
const uint8_t kNaluLengthSize = 4; // unit is bytes.
|
const uint8_t kNaluLengthSize = 4; // unit is bytes.
|
||||||
|
@ -125,8 +125,8 @@ void WvmMediaParser::Init(const InitCB& init_cb,
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WvmMediaParser::Parse(const uint8_t* buf, int size) {
|
bool WvmMediaParser::Parse(const uint8_t* buf, int size) {
|
||||||
uint32_t num_bytes, prev_size;
|
size_t num_bytes = 0;
|
||||||
num_bytes = prev_size = 0;
|
size_t prev_size = 0;
|
||||||
const uint8_t* read_ptr = buf;
|
const uint8_t* read_ptr = buf;
|
||||||
const uint8_t* end = read_ptr + size;
|
const uint8_t* end = read_ptr + size;
|
||||||
|
|
||||||
|
@ -208,7 +208,7 @@ bool WvmMediaParser::Parse(const uint8_t* buf, int size) {
|
||||||
parse_state_ = SystemHeaderSkip;
|
parse_state_ = SystemHeaderSkip;
|
||||||
break;
|
break;
|
||||||
case PackHeaderStuffingSkip:
|
case PackHeaderStuffingSkip:
|
||||||
if ((end - read_ptr) >= (int32_t)skip_bytes_) {
|
if ((end - read_ptr) >= skip_bytes_) {
|
||||||
read_ptr += skip_bytes_;
|
read_ptr += skip_bytes_;
|
||||||
skip_bytes_ = 0;
|
skip_bytes_ = 0;
|
||||||
parse_state_ = StartCode1;
|
parse_state_ = StartCode1;
|
||||||
|
@ -218,7 +218,7 @@ bool WvmMediaParser::Parse(const uint8_t* buf, int size) {
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
case SystemHeaderSkip:
|
case SystemHeaderSkip:
|
||||||
if ((end - read_ptr) >= (int32_t)skip_bytes_) {
|
if ((end - read_ptr) >= skip_bytes_) {
|
||||||
read_ptr += skip_bytes_;
|
read_ptr += skip_bytes_;
|
||||||
skip_bytes_ = 0;
|
skip_bytes_ = 0;
|
||||||
parse_state_ = StartCode1;
|
parse_state_ = StartCode1;
|
||||||
|
@ -895,8 +895,8 @@ bool WvmMediaParser::Output(bool output_encrypted_sample) {
|
||||||
} else if ((prev_pes_stream_id_ & kPesStreamIdAudioMask) ==
|
} else if ((prev_pes_stream_id_ & kPesStreamIdAudioMask) ==
|
||||||
kPesStreamIdAudio) {
|
kPesStreamIdAudio) {
|
||||||
// Set data on the audio stream.
|
// Set data on the audio stream.
|
||||||
int frame_size = mp2t::AdtsHeader::GetAdtsFrameSize(sample_data_.data(),
|
int frame_size = static_cast<int>(mp2t::AdtsHeader::GetAdtsFrameSize(
|
||||||
kAdtsHeaderMinSize);
|
sample_data_.data(), kAdtsHeaderMinSize));
|
||||||
mp2t::AdtsHeader adts_header;
|
mp2t::AdtsHeader adts_header;
|
||||||
const uint8_t* frame_ptr = sample_data_.data();
|
const uint8_t* frame_ptr = sample_data_.data();
|
||||||
if (!adts_header.Parse(frame_ptr, frame_size)) {
|
if (!adts_header.Parse(frame_ptr, frame_size)) {
|
||||||
|
|
|
@ -228,17 +228,17 @@ class WvmMediaParser : public MediaParser {
|
||||||
uint8_t current_program_id_;
|
uint8_t current_program_id_;
|
||||||
uint32_t pes_stream_id_;
|
uint32_t pes_stream_id_;
|
||||||
uint32_t prev_pes_stream_id_;
|
uint32_t prev_pes_stream_id_;
|
||||||
uint16_t pes_packet_bytes_;
|
size_t pes_packet_bytes_;
|
||||||
uint8_t pes_flags_1_;
|
uint8_t pes_flags_1_;
|
||||||
uint8_t pes_flags_2_;
|
uint8_t pes_flags_2_;
|
||||||
uint8_t prev_pes_flags_1_;
|
uint8_t prev_pes_flags_1_;
|
||||||
uint8_t pes_header_data_bytes_;
|
size_t pes_header_data_bytes_;
|
||||||
uint64_t timestamp_;
|
uint64_t timestamp_;
|
||||||
uint64_t pts_;
|
uint64_t pts_;
|
||||||
uint64_t dts_;
|
uint64_t dts_;
|
||||||
uint8_t index_program_id_;
|
uint8_t index_program_id_;
|
||||||
scoped_refptr<MediaSample> media_sample_;
|
scoped_refptr<MediaSample> media_sample_;
|
||||||
uint32_t crypto_unit_start_pos_;
|
size_t crypto_unit_start_pos_;
|
||||||
PrevSampleData prev_media_sample_data_;
|
PrevSampleData prev_media_sample_data_;
|
||||||
H264ByteToUnitStreamConverter byte_to_unit_stream_converter_;
|
H264ByteToUnitStreamConverter byte_to_unit_stream_converter_;
|
||||||
|
|
||||||
|
|
|
@ -151,7 +151,7 @@ class WvmMediaParserTest : public testing::Test {
|
||||||
InitializeParser();
|
InitializeParser();
|
||||||
|
|
||||||
std::vector<uint8_t> buffer = ReadTestDataFile(filename);
|
std::vector<uint8_t> buffer = ReadTestDataFile(filename);
|
||||||
EXPECT_TRUE(parser_->Parse(buffer.data(), buffer.size()));
|
EXPECT_TRUE(parser_->Parse(buffer.data(), static_cast<int>(buffer.size())));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -159,7 +159,7 @@ TEST_F(WvmMediaParserTest, ParseWvmWithoutKeySource) {
|
||||||
key_source_.reset();
|
key_source_.reset();
|
||||||
InitializeParser();
|
InitializeParser();
|
||||||
std::vector<uint8_t> buffer = ReadTestDataFile(kWvmFile);
|
std::vector<uint8_t> buffer = ReadTestDataFile(kWvmFile);
|
||||||
EXPECT_TRUE(parser_->Parse(buffer.data(), buffer.size()));
|
EXPECT_TRUE(parser_->Parse(buffer.data(), static_cast<int>(buffer.size())));
|
||||||
EXPECT_EQ(kExpectedStreams, stream_map_.size());
|
EXPECT_EQ(kExpectedStreams, stream_map_.size());
|
||||||
EXPECT_EQ(kExpectedVideoFrameCount, video_frame_count_);
|
EXPECT_EQ(kExpectedVideoFrameCount, video_frame_count_);
|
||||||
EXPECT_EQ(kExpectedAudioFrameCount, audio_frame_count_);
|
EXPECT_EQ(kExpectedAudioFrameCount, audio_frame_count_);
|
||||||
|
|
|
@ -440,7 +440,7 @@ TEST_P(PackagerTest, MP4MuxerMultiSegmentsUnencryptedVideo) {
|
||||||
std::string segment_content;
|
std::string segment_content;
|
||||||
ASSERT_TRUE(base::ReadFileToString(segment_path, &segment_content));
|
ASSERT_TRUE(base::ReadFileToString(segment_path, &segment_content));
|
||||||
EXPECT_TRUE(base::AppendToFile(output_path, segment_content.data(),
|
EXPECT_TRUE(base::AppendToFile(output_path, segment_content.data(),
|
||||||
segment_content.size()));
|
static_cast<int>(segment_content.size())));
|
||||||
|
|
||||||
++segment_index;
|
++segment_index;
|
||||||
}
|
}
|
||||||
|
|
|
@ -94,6 +94,7 @@
|
||||||
'defines': [
|
'defines': [
|
||||||
'BUILDING_LIBCURL',
|
'BUILDING_LIBCURL',
|
||||||
],
|
],
|
||||||
|
'msvs_disabled_warnings': [ 4267, ],
|
||||||
}],
|
}],
|
||||||
],
|
],
|
||||||
'variables': {
|
'variables': {
|
||||||
|
|
Loading…
Reference in New Issue