From 93fe5457bf183d5e75482b3d6c3b8599d699ee0b Mon Sep 17 00:00:00 2001 From: Haoming Chen Date: Tue, 8 Nov 2016 18:11:13 -0800 Subject: [PATCH] Fix x64 build on Windows. - Fix integer conversion warnings. - Fix #168. Change-Id: Ie9aadea86a293b49e0854d6549800083143c79df --- packager/media/base/bit_reader.cc | 18 +- packager/media/base/bit_reader.h | 29 +- packager/media/base/bit_reader_unittest.cc | 16 +- packager/media/base/container_names.cc | 8 +- .../media/base/container_names_unittest.cc | 5 +- .../base/producer_consumer_queue_unittest.cc | 2 +- packager/media/codecs/h264_parser.h | 4 +- packager/media/codecs/h265_parser.h | 2 +- packager/media/codecs/h265_parser_unittest.cc | 4 +- .../nal_unit_to_byte_stream_converter.cc | 4 +- .../media/codecs/video_slice_header_parser.cc | 5 +- packager/media/formats/mp2t/es_parser_adts.cc | 6 +- .../formats/mp2t/es_parser_h264_unittest.cc | 4 +- .../formats/mp2t/es_parser_h26x_unittest.cc | 8 +- .../mp2t/mp2t_media_parser_unittest.cc | 2 +- .../formats/mp2t/program_map_table_writer.cc | 2 +- packager/media/formats/mp2t/ts_packet.cc | 9 +- .../formats/mp2t/ts_packet_writer_util.cc | 12 +- packager/media/formats/mp2t/ts_section_pes.cc | 12 +- packager/media/formats/mp2t/ts_section_pmt.cc | 5 +- packager/media/formats/mp2t/ts_writer.cc | 5 +- packager/media/formats/mp4/box.cc | 2 +- packager/media/formats/mp4/box.h | 2 +- packager/media/formats/mp4/box_definitions.cc | 254 +++++++++--------- packager/media/formats/mp4/box_definitions.h | 2 +- .../formats/mp4/box_definitions_unittest.cc | 2 +- .../media/formats/mp4/box_reader_unittest.cc | 6 +- .../formats/mp4/encrypting_fragmenter.cc | 9 +- .../media/formats/mp4/encrypting_fragmenter.h | 2 +- packager/media/formats/mp4/fragmenter.cc | 6 +- .../media/formats/mp4/mp4_media_parser.cc | 2 +- .../formats/mp4/mp4_media_parser_unittest.cc | 2 +- packager/media/formats/mp4/mp4_muxer.cc | 2 +- .../formats/mp4/multi_segment_segmenter.cc | 10 +- packager/media/formats/mp4/segmenter.cc | 2 +- .../media/formats/mp4/track_run_iterator.cc | 7 +- .../mp4/track_run_iterator_unittest.cc | 2 +- packager/media/formats/webm/encryptor.cc | 7 +- .../webm/multi_segment_segmenter_unittest.cc | 12 +- .../media/formats/webm/segmenter_test_base.cc | 10 +- .../media/formats/webm/segmenter_test_base.h | 2 +- .../webm/single_segment_segmenter_unittest.cc | 6 +- packager/media/formats/webm/tracks_builder.cc | 7 +- .../webm/webm_cluster_parser_unittest.cc | 6 +- .../media/formats/webm/webm_crypto_helpers.cc | 2 +- .../media/formats/webm/webm_crypto_helpers.h | 2 +- packager/media/formats/webm/webm_parser.cc | 3 +- .../formats/webm/webm_parser_unittest.cc | 4 +- .../webm/webm_tracks_parser_unittest.cc | 18 +- .../media/formats/wvm/wvm_media_parser.cc | 14 +- packager/media/formats/wvm/wvm_media_parser.h | 6 +- .../formats/wvm/wvm_media_parser_unittest.cc | 4 +- packager/media/test/packager_test.cc | 2 +- packager/third_party/curl/curl.gyp | 1 + 54 files changed, 299 insertions(+), 281 deletions(-) diff --git a/packager/media/base/bit_reader.cc b/packager/media/base/bit_reader.cc index 9fa7cb2a67..85b43577e0 100644 --- a/packager/media/base/bit_reader.cc +++ b/packager/media/base/bit_reader.cc @@ -9,7 +9,7 @@ namespace shaka { namespace media { -BitReader::BitReader(const uint8_t* data, off_t size) +BitReader::BitReader(const uint8_t* data, size_t size) : data_(data), initial_size_(size), bytes_left_(size), @@ -21,16 +21,14 @@ BitReader::BitReader(const uint8_t* data, off_t size) BitReader::~BitReader() {} -bool BitReader::SkipBits(int num_bits) { - DCHECK_GE(num_bits, 0); - +bool BitReader::SkipBits(size_t num_bits) { // Skip any bits in the current byte waiting to be processed, then // process full bytes until less than 8 bits remaining. if (num_bits > num_remaining_bits_in_curr_byte_) { num_bits -= num_remaining_bits_in_curr_byte_; num_remaining_bits_in_curr_byte_ = 0; - int num_bytes = num_bits / 8; + size_t num_bytes = num_bits / 8; num_bits %= 8; if (bytes_left_ < num_bytes) { bytes_left_ = 0; @@ -53,7 +51,7 @@ bool BitReader::SkipBits(int num_bits) { 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) return false; if (num_bytes == 0) @@ -68,13 +66,13 @@ bool BitReader::SkipBytes(int num_bytes) { return true; } -bool BitReader::ReadBitsInternal(int num_bits, uint64_t* out) { - DCHECK_LE(num_bits, 64); +bool BitReader::ReadBitsInternal(size_t num_bits, uint64_t* out) { + DCHECK_LE(num_bits, 64u); *out = 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 += 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() { - DCHECK_EQ(num_remaining_bits_in_curr_byte_, 0); + DCHECK_EQ(num_remaining_bits_in_curr_byte_, 0u); if (bytes_left_ == 0) return; diff --git a/packager/media/base/bit_reader.h b/packager/media/base/bit_reader.h index b907c6a0be..d0cc8f90fb 100644 --- a/packager/media/base/bit_reader.h +++ b/packager/media/base/bit_reader.h @@ -19,7 +19,7 @@ class BitReader { /// Initialize the BitReader object to read a data buffer. /// @param data points to the beginning of the buffer. /// @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(); /// Read a number of bits from stream. @@ -32,8 +32,8 @@ class BitReader { /// stream will enter a state where further ReadBits/SkipBits /// operations will always return false unless @a num_bits is 0. template - bool ReadBits(int num_bits, T* out) { - DCHECK_LE(num_bits, static_cast(sizeof(T) * 8)); + bool ReadBits(size_t num_bits, T* out) { + DCHECK_LE(num_bits, sizeof(T) * 8); uint64_t temp; bool ret = ReadBitsInternal(num_bits, &temp); *out = static_cast(temp); @@ -41,8 +41,8 @@ class BitReader { } // Explicit T=bool overload to make MSVC happy. - bool ReadBits(int num_bits, bool* out) { - DCHECK_EQ(num_bits, 1); + bool ReadBits(size_t num_bits, bool* out) { + DCHECK_EQ(num_bits, 1u); uint64_t temp; bool ret = ReadBitsInternal(num_bits, &temp); *out = temp != 0; @@ -55,7 +55,7 @@ class BitReader { /// bits in the stream), true otherwise. When false is returned, the /// stream will enter a state where further ReadXXX/SkipXXX /// 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 /// condition. @@ -66,7 +66,7 @@ class BitReader { /// be skipped (not enough bits in the stream), true otherwise. When /// false is returned, the stream will enter a state where further /// 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; if (!ReadBits(1, &condition_read)) return false; @@ -79,19 +79,19 @@ class BitReader { /// @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 /// stream), true otherwise. - bool SkipBytes(int num_bytes); + bool SkipBytes(size_t num_bytes); /// @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 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: // 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_. // If the num_remaining_bits_in_curr_byte_ is 0 after this function returns, @@ -102,18 +102,17 @@ class BitReader { const uint8_t* data_; // Initial size of the input data. - // TODO(kqyang): Use size_t instead of off_t instead. - off_t initial_size_; + size_t initial_size_; // 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 // 8 - num_remaining_bits_in_curr_byte_ from MSB. uint8_t 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: DISALLOW_COPY_AND_ASSIGN(BitReader); diff --git a/packager/media/base/bit_reader_unittest.cc b/packager/media/base/bit_reader_unittest.cc index 377d7a198e..c8dcf13a25 100644 --- a/packager/media/base/bit_reader_unittest.cc +++ b/packager/media/base/bit_reader_unittest.cc @@ -20,8 +20,8 @@ TEST(BitReaderTest, NormalOperationTest) { EXPECT_EQ(0, value8); EXPECT_TRUE(reader1.ReadBits(8, &value8)); EXPECT_EQ(0xab, value8); // 1010 1011 - EXPECT_EQ(39, reader1.bits_available()); - EXPECT_EQ(9, reader1.bit_position()); + EXPECT_EQ(39u, reader1.bits_available()); + EXPECT_EQ(9u, reader1.bit_position()); EXPECT_TRUE(reader1.ReadBits(7, &value64)); EXPECT_TRUE(reader1.ReadBits(32, &value64)); EXPECT_EQ(0x55995599u, value64); @@ -64,8 +64,8 @@ TEST(BitReaderTest, SkipBitsTest) { EXPECT_TRUE(reader1.SkipBytes(0)); EXPECT_TRUE(reader1.SkipBytes(1)); EXPECT_TRUE(reader1.SkipBits(52)); - EXPECT_EQ(20, reader1.bits_available()); - EXPECT_EQ(100, reader1.bit_position()); + EXPECT_EQ(20u, reader1.bits_available()); + EXPECT_EQ(100u, reader1.bit_position()); EXPECT_TRUE(reader1.ReadBits(4, &value8)); EXPECT_EQ(13, value8); EXPECT_FALSE(reader1.SkipBits(100)); @@ -77,13 +77,13 @@ TEST(BitReaderTest, SkipBitsConditionalTest) { uint8_t buffer[] = {0x8a, 0x12}; BitReader reader(buffer, sizeof(buffer)); 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_EQ(5, reader.bit_position()); // Skipped. + EXPECT_EQ(5u, reader.bit_position()); // Skipped. 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_EQ(12, reader.bit_position()); // Skipped. + EXPECT_EQ(12u, reader.bit_position()); // Skipped. EXPECT_TRUE(reader.SkipBits(4)); EXPECT_FALSE(reader.SkipBits(1)); } diff --git a/packager/media/base/container_names.cc b/packager/media/base/container_names.cc index 4650c12f3f..0add6fe957 100644 --- a/packager/media/base/container_names.cc +++ b/packager/media/base/container_names.cc @@ -74,7 +74,7 @@ static bool StartsWith(const uint8_t* buffer, // Helper function to read up to 64 bits from a bit stream. static uint64_t ReadBits(BitReader* reader, int num_bits) { - DCHECK_GE(reader->bits_available(), num_bits); + DCHECK_GE(static_cast(reader->bits_available()), num_bits); DCHECK((num_bits > 0) && (num_bits <= 64)); uint64_t value; reader->ReadBits(num_bits, &value); @@ -1223,7 +1223,7 @@ static int GetElementId(BitReader* reader) { for (int i = 0; i < 4; ++i) { num_bits_to_read += 7; if (ReadBits(reader, 1) == 1) { - if (reader->bits_available() < num_bits_to_read) + if (static_cast(reader->bits_available()) < num_bits_to_read) break; // prefix[] adds back the bits read individually. 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) { num_bits_to_read += 7; if (ReadBits(reader, 1) == 1) { - if (reader->bits_available() < num_bits_to_read) + if (static_cast(reader->bits_available()) < num_bits_to_read) break; 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. int header_size = GetVint(&reader); - RCHECK(reader.bits_available() / 8 >= header_size); + RCHECK(static_cast(reader.bits_available()) / 8 >= header_size); // Loop through the header. while (reader.bits_available() > 0) { diff --git a/packager/media/base/container_names_unittest.cc b/packager/media/base/container_names_unittest.cc index 7d1a63d939..dc0e2d01e3 100644 --- a/packager/media/base/container_names_unittest.cc +++ b/packager/media/base/container_names_unittest.cc @@ -190,8 +190,9 @@ TEST(ContainerNamesTest, WebVtt) { kWebVtt + arraysize(kWebVtt)); EXPECT_EQ(CONTAINER_WEBVTT, - DetermineContainer(webvtt_with_utf8_byte_order_mark.data(), - webvtt_with_utf8_byte_order_mark.size())); + DetermineContainer( + webvtt_with_utf8_byte_order_mark.data(), + static_cast(webvtt_with_utf8_byte_order_mark.size()))); } TEST(ContainerNamesTest, FileCheckOGG) { diff --git a/packager/media/base/producer_consumer_queue_unittest.cc b/packager/media/base/producer_consumer_queue_unittest.cc index 779f7645f3..3b1b26daa1 100644 --- a/packager/media/base/producer_consumer_queue_unittest.cc +++ b/packager/media/base/producer_consumer_queue_unittest.cc @@ -89,7 +89,7 @@ TEST(ProducerConsumerQueueTest, PeekOnPoppedElement) { TEST(ProducerConsumerQueueTest, PushWithTimeout) { std::unique_ptr timer; - ProducerConsumerQueue queue(kCapacity); + ProducerConsumerQueue queue(kCapacity); for (size_t i = 0; i < kCapacity; ++i) { timer.reset(new base::ElapsedTimer()); diff --git a/packager/media/codecs/h264_parser.h b/packager/media/codecs/h264_parser.h index eb97f94ba8..1ce13b8166 100644 --- a/packager/media/codecs/h264_parser.h +++ b/packager/media/codecs/h264_parser.h @@ -169,13 +169,13 @@ struct H264SliceHeader { const uint8_t* nalu_data; // 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. // Sturcture: |NALU Header| Slice Header | Slice Data | // Size: |<- 8bits ->|<- header_bit_size ->|<- Rest of nalu ->| // 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 slice_type; diff --git a/packager/media/codecs/h265_parser.h b/packager/media/codecs/h265_parser.h index 0c9b696449..7db12d0b8a 100644 --- a/packager/media/codecs/h265_parser.h +++ b/packager/media/codecs/h265_parser.h @@ -222,7 +222,7 @@ struct H265SliceHeader { // Sturcture: |NALU Header | Slice Header | Slice Data | // Size: |<- 16bits ->|<- header_bit_size ->|<- Rest of nalu ->| // 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 no_output_of_prior_pics_flag = false; diff --git a/packager/media/codecs/h265_parser_unittest.cc b/packager/media/codecs/h265_parser_unittest.cc index a9de1d8a05..55ec82f9b8 100644 --- a/packager/media/codecs/h265_parser_unittest.cc +++ b/packager/media/codecs/h265_parser_unittest.cc @@ -55,7 +55,7 @@ TEST(H265ParserTest, ParseSliceHeader) { EXPECT_EQ(8, header.slice_qp_delta); EXPECT_FALSE(header.cu_chroma_qp_offset_enabled_flag); 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) { @@ -81,7 +81,7 @@ TEST(H265ParserTest, ParseSliceHeader_NonIDR) { EXPECT_FALSE(header.dependent_slice_segment_flag); EXPECT_EQ(1, header.slice_type); 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) { diff --git a/packager/media/codecs/nal_unit_to_byte_stream_converter.cc b/packager/media/codecs/nal_unit_to_byte_stream_converter.cc index 612ca1f5dd..349b1ef825 100644 --- a/packager/media/codecs/nal_unit_to_byte_stream_converter.cc +++ b/packager/media/codecs/nal_unit_to_byte_stream_converter.cc @@ -195,7 +195,7 @@ bool NalUnitToByteStreamConverter::ConvertUnitToByteStreamWithSubsamples( if (is_key_frame) buffer_writer.AppendVector(decoder_configuration_in_byte_stream_); - int adjustment = buffer_writer.Size(); + int adjustment = static_cast(buffer_writer.Size()); size_t subsample_id = 0; 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); subsamples->at(subsample_id).clear_bytes -= static_cast(old_nalu_size); - adjustment += old_nalu_size; + adjustment += static_cast(old_nalu_size); } else { // Apply the adjustment on the current subsample, reset the // adjustment and move to the next subsample. diff --git a/packager/media/codecs/video_slice_header_parser.cc b/packager/media/codecs/video_slice_header_parser.cc index cce8b418dc..10cf33a236 100644 --- a/packager/media/codecs/video_slice_header_parser.cc +++ b/packager/media/codecs/video_slice_header_parser.cc @@ -15,10 +15,9 @@ namespace media { namespace { -int NumBitsToNumBytes(int size_in_bits) { +size_t NumBitsToNumBytes(size_t size_in_bits) { // Round-up division. - DCHECK_GE(size_in_bits, 0); - return (size_in_bits - 1) / 8 + 1; + return (size_in_bits + 7) >> 3; } } // namespace diff --git a/packager/media/formats/mp2t/es_parser_adts.cc b/packager/media/formats/mp2t/es_parser_adts.cc index c8808d9a3b..63bca9a5ac 100644 --- a/packager/media/formats/mp2t/es_parser_adts.cc +++ b/packager/media/formats/mp2t/es_parser_adts.cc @@ -63,8 +63,8 @@ static bool LookForSyncWord(const uint8_t* raw_es, // The layer field (2 bits) must be set to 0. continue; - int frame_size = - mp2t::AdtsHeader::GetAdtsFrameSize(cur_buf, kAdtsHeaderMinSize); + int frame_size = static_cast( + mp2t::AdtsHeader::GetAdtsFrameSize(cur_buf, kAdtsHeaderMinSize)); if (frame_size < kAdtsHeaderMinSize) { // Too short to be an ADTS frame. continue; @@ -117,7 +117,7 @@ bool EsParserAdts::Parse(const uint8_t* buf, } // Copy the input data to the ES buffer. - es_byte_queue_.Push(buf, size); + es_byte_queue_.Push(buf, static_cast(size)); es_byte_queue_.Peek(&raw_es, &raw_es_size); // Look for every ADTS frame in the ES buffer starting at offset = 0 diff --git a/packager/media/formats/mp2t/es_parser_h264_unittest.cc b/packager/media/formats/mp2t/es_parser_h264_unittest.cc index f5ef077813..cd5b307de9 100644 --- a/packager/media/formats/mp2t/es_parser_h264_unittest.cc +++ b/packager/media/formats/mp2t/es_parser_h264_unittest.cc @@ -193,8 +193,8 @@ void EsParserH264Test::ProcessPesPackets( pts = au_idx * kMpegTicksPerFrame; } - ASSERT_TRUE( - es_parser.Parse(&stream_[cur_pes_offset], cur_pes_size, pts, dts)); + ASSERT_TRUE(es_parser.Parse(&stream_[cur_pes_offset], + static_cast(cur_pes_size), pts, dts)); } es_parser.Flush(); } diff --git a/packager/media/formats/mp2t/es_parser_h26x_unittest.cc b/packager/media/formats/mp2t/es_parser_h26x_unittest.cc index 761cfd1e81..dc6bc957b9 100644 --- a/packager/media/formats/mp2t/es_parser_h26x_unittest.cc +++ b/packager/media/formats/mp2t/es_parser_h26x_unittest.cc @@ -129,7 +129,7 @@ class TestableEsParser : public EsParserH26x { std::vector CreateNalu(Nalu::CodecType codec_type, H26xNaluType type, - int i) { + uint8_t i) { std::vector ret; if (codec_type == Nalu::kH264) { ret.resize(3); @@ -215,7 +215,8 @@ void EsParserH26xTest::RunTest(Nalu::CodecType codec_type, seen_key_frame = true; } - std::vector es_data = CreateNalu(codec_type, types[k], k); + std::vector es_data = + CreateNalu(codec_type, types[k], static_cast(k)); 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()) { // Insert the data in parts to test partial data searches. 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(size), + pts, dts)); offset += size; } } diff --git a/packager/media/formats/mp2t/mp2t_media_parser_unittest.cc b/packager/media/formats/mp2t/mp2t_media_parser_unittest.cc index 60a028d6fc..0be3a1d742 100644 --- a/packager/media/formats/mp2t/mp2t_media_parser_unittest.cc +++ b/packager/media/formats/mp2t/mp2t_media_parser_unittest.cc @@ -44,7 +44,7 @@ class Mp2tMediaParserTest : public testing::Test { int64_t video_max_dts_; bool AppendData(const uint8_t* data, size_t length) { - return parser_->Parse(data, length); + return parser_->Parse(data, static_cast(length)); } bool AppendDataInPieces(const uint8_t* data, diff --git a/packager/media/formats/mp2t/program_map_table_writer.cc b/packager/media/formats/mp2t/program_map_table_writer.cc index 08649d4aed..491a367b90 100644 --- a/packager/media/formats/mp2t/program_map_table_writer.cc +++ b/packager/media/formats/mp2t/program_map_table_writer.cc @@ -179,7 +179,7 @@ const uint8_t kPrivateDataIndicatorDescriptorEncryptedH264[] = { }; void WritePmtToBuffer(const uint8_t* pmt, - int pmt_size, + size_t pmt_size, ContinuityCounter* continuity_counter, BufferWriter* writer) { const bool kPayloadUnitStartIndicator = true; diff --git a/packager/media/formats/mp2t/ts_packet.cc b/packager/media/formats/mp2t/ts_packet.cc index e1de014279..cc45871f35 100644 --- a/packager/media/formats/mp2t/ts_packet.cc +++ b/packager/media/formats/mp2t/ts_packet.cc @@ -138,7 +138,8 @@ bool TsPacket::ParseHeader(const uint8_t* buf) { bool TsPacket::ParseAdaptationField(BitReader* bit_reader, int adaptation_field_length) { DCHECK_GT(adaptation_field_length, 0); - int adaptation_field_start_marker = bit_reader->bits_available() / 8; + int adaptation_field_start_marker = + static_cast(bit_reader->bits_available()) / 8; int discontinuity_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. - int adaptation_field_remaining_size = adaptation_field_length - - (adaptation_field_start_marker - bit_reader->bits_available() / 8); + int adaptation_field_remaining_size = + adaptation_field_length - + (adaptation_field_start_marker - + static_cast(bit_reader->bits_available()) / 8); RCHECK(adaptation_field_remaining_size >= 0); for (int k = 0; k < adaptation_field_remaining_size; k++) { int stuffing_byte; diff --git a/packager/media/formats/mp2t/ts_packet_writer_util.cc b/packager/media/formats/mp2t/ts_packet_writer_util.cc index f6d7e4347f..8abf156f56 100644 --- a/packager/media/formats/mp2t/ts_packet_writer_util.cc +++ b/packager/media/formats/mp2t/ts_packet_writer_util.cc @@ -74,19 +74,19 @@ void WriteAdaptationField(bool has_pcr, // The size of all leading flags (not including the adaptation_field_length). const int kAdaptationFieldHeaderSize = 1; - int adaptation_field_length = + size_t adaptation_field_length = kAdaptationFieldHeaderSize + (has_pcr ? kPcrFieldsSize : 0); if (remaining_data_size < kTsPacketMaximumPayloadSize) { - const int current_ts_size = kTsPacketHeaderSize + remaining_data_size + - adaptation_field_length + - kAdaptationFieldLengthSize; + const size_t current_ts_size = kTsPacketHeaderSize + remaining_data_size + + adaptation_field_length + + kAdaptationFieldLengthSize; if (current_ts_size < kTsPacketSize) { adaptation_field_length += kTsPacketSize - current_ts_size; } } writer->AppendInt(static_cast(adaptation_field_length)); - int remaining_bytes = adaptation_field_length; + int remaining_bytes = static_cast(adaptation_field_length); writer->AppendInt(static_cast( // All flags except PCR_flag are 0. static_cast(has_pcr) << 4)); @@ -144,7 +144,7 @@ void WritePayloadToBufferWriter(const uint8_t* payload, WriteAdaptationField(has_pcr, pcr_base, bytes_left, writer); const size_t bytes_for_adaptation_field = writer->Size() - before; - const int write_bytes = + const size_t write_bytes = kTsPacketMaximumPayloadSize - bytes_for_adaptation_field; writer->AppendArray(payload + payload_bytes_written, write_bytes); payload_bytes_written += write_bytes; diff --git a/packager/media/formats/mp2t/ts_section_pes.cc b/packager/media/formats/mp2t/ts_section_pes.cc index 1063d42952..d971b2cfbb 100644 --- a/packager/media/formats/mp2t/ts_section_pes.cc +++ b/packager/media/formats/mp2t/ts_section_pes.cc @@ -195,7 +195,7 @@ bool TsSectionPes::ParseInternal(const uint8_t* raw_pes, int raw_pes_size) { RCHECK(packet_start_code_prefix == kPesStartCode); DVLOG(LOG_LEVEL_PES) << "stream_id=" << std::hex << stream_id << std::dec; if (pes_packet_length == 0) - pes_packet_length = bit_reader.bits_available() / 8; + pes_packet_length = static_cast(bit_reader.bits_available()) / 8; // Ignore the PES for unknown stream IDs. // 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_extension_flag)); 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(bit_reader.bits_available()) / 8; // Compute the size and the offset of the ES payload. // "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. - DCHECK_EQ(bit_reader.bits_available() % 8, 0); - int pes_header_remaining_size = pes_header_data_length - - (pes_header_start_size - bit_reader.bits_available() / 8); + DCHECK_EQ(bit_reader.bits_available() % 8, 0u); + int pes_header_remaining_size = + pes_header_data_length - + (pes_header_start_size - + static_cast(bit_reader.bits_available()) / 8); RCHECK(pes_header_remaining_size >= 0); // Read the PES packet. diff --git a/packager/media/formats/mp2t/ts_section_pmt.cc b/packager/media/formats/mp2t/ts_section_pmt.cc index ee145083f6..8ba854cb2e 100644 --- a/packager/media/formats/mp2t/ts_section_pmt.cc +++ b/packager/media/formats/mp2t/ts_section_pmt.cc @@ -38,7 +38,7 @@ bool TsSectionPmt::ParsePsiSection(BitReader* bit_reader) { RCHECK(bit_reader->ReadBits(1, &dummy_zero)); RCHECK(bit_reader->ReadBits(2, &reserved)); RCHECK(bit_reader->ReadBits(12, §ion_length)); - int section_start_marker = bit_reader->bits_available() / 8; + int section_start_marker = static_cast(bit_reader->bits_available()) / 8; RCHECK(bit_reader->ReadBits(16, &program_number)); RCHECK(bit_reader->ReadBits(2, &reserved)); @@ -76,7 +76,8 @@ bool TsSectionPmt::ParsePsiSection(BitReader* bit_reader) { // (4 bytes = size of the CRC). int pid_map_end_marker = section_start_marker - section_length + 4; std::map pid_map; - while (bit_reader->bits_available() > 8 * pid_map_end_marker) { + while (static_cast(bit_reader->bits_available()) > + 8 * pid_map_end_marker) { int stream_type; int reserved; int pid_es; diff --git a/packager/media/formats/mp2t/ts_writer.cc b/packager/media/formats/mp2t/ts_writer.cc index cc631597a6..da45e4f52c 100644 --- a/packager/media/formats/mp2t/ts_writer.cc +++ b/packager/media/formats/mp2t/ts_writer.cc @@ -135,10 +135,9 @@ bool WritePesToFile(const PesPacket& pes, pes_packet_length > kMaxPesPacketLengthValue ? 0 : pes_packet_length)); first_ts_packet_buffer.AppendBuffer(pes_header_writer); - const int available_payload = + const size_t available_payload = kTsPacketMaxPayloadWithPcr - first_ts_packet_buffer.Size(); - const int bytes_consumed = - std::min(static_cast(pes.data().size()), available_payload); + const size_t bytes_consumed = std::min(pes.data().size(), available_payload); first_ts_packet_buffer.AppendArray(pes.data().data(), bytes_consumed); BufferWriter output_writer; diff --git a/packager/media/formats/mp4/box.cc b/packager/media/formats/mp4/box.cc index 6b07389ed7..3553223f57 100644 --- a/packager/media/formats/mp4/box.cc +++ b/packager/media/formats/mp4/box.cc @@ -48,7 +48,7 @@ void Box::WriteHeader(BufferWriter* writer) { } uint32_t Box::ComputeSize() { - box_size_ = ComputeSizeInternal(); + box_size_ = static_cast(ComputeSizeInternal()); return box_size_; } diff --git a/packager/media/formats/mp4/box.h b/packager/media/formats/mp4/box.h index 5a048541f4..de204bae04 100644 --- a/packager/media/formats/mp4/box.h +++ b/packager/media/formats/mp4/box.h @@ -67,7 +67,7 @@ struct Box { virtual bool ReadWriteInternal(BoxBuffer* buffer) = 0; // 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. - 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 // current needs. diff --git a/packager/media/formats/mp4/box_definitions.cc b/packager/media/formats/mp4/box_definitions.cc index 8cc762c40c..99d08c0caa 100644 --- a/packager/media/formats/mp4/box_definitions.cc +++ b/packager/media/formats/mp4/box_definitions.cc @@ -154,7 +154,7 @@ bool FileType::ReadWriteInternal(BoxBuffer* buffer) { return true; } -uint32_t FileType::ComputeSizeInternal() { +size_t FileType::ComputeSizeInternal() { return HeaderSize() + kFourCCSize + sizeof(minor_version) + kFourCCSize * compatible_brands.size(); } @@ -178,7 +178,7 @@ bool ProtectionSystemSpecificHeader::ReadWriteInternal(BoxBuffer* buffer) { return true; } -uint32_t ProtectionSystemSpecificHeader::ComputeSizeInternal() { +size_t ProtectionSystemSpecificHeader::ComputeSizeInternal() { return raw_box.size(); } @@ -191,7 +191,7 @@ bool SampleAuxiliaryInformationOffset::ReadWriteInternal(BoxBuffer* buffer) { if (flags & 1) RCHECK(buffer->IgnoreBytes(8)); // aux_info_type and parameter. - uint32_t count = offsets.size(); + uint32_t count = static_cast(offsets.size()); RCHECK(buffer->ReadWriteUInt32(&count)); offsets.resize(count); @@ -201,7 +201,7 @@ bool SampleAuxiliaryInformationOffset::ReadWriteInternal(BoxBuffer* buffer) { return true; } -uint32_t SampleAuxiliaryInformationOffset::ComputeSizeInternal() { +size_t SampleAuxiliaryInformationOffset::ComputeSizeInternal() { // This box is optional. Skip it if it is empty. if (offsets.size() == 0) return 0; @@ -226,7 +226,7 @@ bool SampleAuxiliaryInformationSize::ReadWriteInternal(BoxBuffer* buffer) { return true; } -uint32_t SampleAuxiliaryInformationSize::ComputeSizeInternal() { +size_t SampleAuxiliaryInformationSize::ComputeSizeInternal() { // This box is optional. Skip it if it is empty. if (sample_count == 0) return 0; @@ -290,10 +290,11 @@ bool SampleEncryptionEntry::ParseFromBuffer(uint8_t iv_size, uint32_t SampleEncryptionEntry::ComputeSize() const { const uint32_t subsample_entry_size = sizeof(uint16_t) + sizeof(uint32_t); const uint16_t subsample_count = static_cast(subsamples.size()); - return initialization_vector.size() + - (subsample_count > 0 ? (sizeof(subsample_count) + - subsample_entry_size * subsample_count) - : 0); + return static_cast( + initialization_vector.size() + + (subsample_count > 0 + ? (sizeof(subsample_count) + subsample_entry_size * subsample_count) + : 0)); } uint32_t SampleEncryptionEntry::GetTotalSizeOfSubsamples() const { @@ -325,7 +326,8 @@ bool SampleEncryption::ReadWriteInternal(BoxBuffer* buffer) { return false; } - uint32_t sample_count = sample_encryption_entries.size(); + uint32_t sample_count = + static_cast(sample_encryption_entries.size()); RCHECK(buffer->ReadWriteUInt32(&sample_count)); sample_encryption_entries.resize(sample_count); @@ -336,15 +338,16 @@ bool SampleEncryption::ReadWriteInternal(BoxBuffer* buffer) { return true; } -uint32_t SampleEncryption::ComputeSizeInternal() { - const uint32_t sample_count = sample_encryption_entries.size(); +size_t SampleEncryption::ComputeSizeInternal() { + const uint32_t sample_count = + static_cast(sample_encryption_entries.size()); if (sample_count == 0) { // Sample encryption box is optional. Skip it if it is empty. return 0; } DCHECK(IsIvSizeValid(iv_size)); - uint32_t box_size = HeaderSize() + sizeof(sample_count); + size_t box_size = HeaderSize() + sizeof(sample_count); if (flags & kUseSubsampleEncryption) { for (const SampleEncryptionEntry& sample_encryption_entry : sample_encryption_entries) { @@ -382,7 +385,7 @@ bool OriginalFormat::ReadWriteInternal(BoxBuffer* buffer) { return ReadWriteHeaderInternal(buffer) && buffer->ReadWriteFourCC(&format); } -uint32_t OriginalFormat::ComputeSizeInternal() { +size_t OriginalFormat::ComputeSizeInternal() { return HeaderSize() + kFourCCSize; } @@ -397,7 +400,7 @@ bool SchemeType::ReadWriteInternal(BoxBuffer* buffer) { return true; } -uint32_t SchemeType::ComputeSizeInternal() { +size_t SchemeType::ComputeSizeInternal() { return HeaderSize() + kFourCCSize + sizeof(version); } @@ -460,7 +463,7 @@ bool TrackEncryption::ReadWriteInternal(BoxBuffer* buffer) { return true; } -uint32_t TrackEncryption::ComputeSizeInternal() { +size_t TrackEncryption::ComputeSizeInternal() { return HeaderSize() + sizeof(uint32_t) + kCencKeyIdSize + (default_constant_iv.empty() ? 0 : (sizeof(uint8_t) + default_constant_iv.size())); @@ -476,7 +479,7 @@ bool SchemeInfo::ReadWriteInternal(BoxBuffer* buffer) { return true; } -uint32_t SchemeInfo::ComputeSizeInternal() { +size_t SchemeInfo::ComputeSizeInternal() { return HeaderSize() + track_encryption.ComputeSize(); } @@ -502,7 +505,7 @@ bool ProtectionSchemeInfo::ReadWriteInternal(BoxBuffer* buffer) { return true; } -uint32_t ProtectionSchemeInfo::ComputeSizeInternal() { +size_t ProtectionSchemeInfo::ComputeSizeInternal() { // Skip sinf box if it is not initialized. if (format.format == FOURCC_NULL) return 0; @@ -541,7 +544,7 @@ bool MovieHeader::ReadWriteInternal(BoxBuffer* buffer) { return true; } -uint32_t MovieHeader::ComputeSizeInternal() { +size_t MovieHeader::ComputeSizeInternal() { version = IsFitIn32Bits(creation_time, modification_time, duration) ? 0 : 1; return HeaderSize() + sizeof(uint32_t) * (1 + version) * 3 + sizeof(timescale) + sizeof(rate) + sizeof(volume) + @@ -592,7 +595,7 @@ bool TrackHeader::ReadWriteInternal(BoxBuffer* buffer) { return true; } -uint32_t TrackHeader::ComputeSizeInternal() { +size_t TrackHeader::ComputeSizeInternal() { version = IsFitIn32Bits(creation_time, modification_time, duration) ? 0 : 1; return HeaderSize() + sizeof(track_id) + sizeof(uint32_t) * (1 + version) * 3 + sizeof(layer) + @@ -608,13 +611,13 @@ bool SampleDescription::ReadWriteInternal(BoxBuffer* buffer) { uint32_t count = 0; switch (type) { case kVideo: - count = video_entries.size(); + count = static_cast(video_entries.size()); break; case kAudio: - count = audio_entries.size(); + count = static_cast(audio_entries.size()); break; case kText: - count = text_entries.size(); + count = static_cast(text_entries.size()); break; default: NOTIMPLEMENTED() << "SampleDecryption type " << type @@ -658,8 +661,8 @@ bool SampleDescription::ReadWriteInternal(BoxBuffer* buffer) { return true; } -uint32_t SampleDescription::ComputeSizeInternal() { - uint32_t box_size = HeaderSize() + sizeof(uint32_t); +size_t SampleDescription::ComputeSizeInternal() { + size_t box_size = HeaderSize() + sizeof(uint32_t); if (type == kVideo) { for (uint32_t i = 0; i < video_entries.size(); ++i) box_size += video_entries[i].ComputeSize(); @@ -678,7 +681,7 @@ DecodingTimeToSample::~DecodingTimeToSample() {} FourCC DecodingTimeToSample::BoxType() const { return FOURCC_stts; } bool DecodingTimeToSample::ReadWriteInternal(BoxBuffer* buffer) { - uint32_t count = decoding_time.size(); + uint32_t count = static_cast(decoding_time.size()); RCHECK(ReadWriteHeaderInternal(buffer) && buffer->ReadWriteUInt32(&count)); @@ -690,7 +693,7 @@ bool DecodingTimeToSample::ReadWriteInternal(BoxBuffer* buffer) { return true; } -uint32_t DecodingTimeToSample::ComputeSizeInternal() { +size_t DecodingTimeToSample::ComputeSizeInternal() { return HeaderSize() + sizeof(uint32_t) + sizeof(DecodingTime) * decoding_time.size(); } @@ -700,7 +703,7 @@ CompositionTimeToSample::~CompositionTimeToSample() {} FourCC CompositionTimeToSample::BoxType() const { return FOURCC_ctts; } bool CompositionTimeToSample::ReadWriteInternal(BoxBuffer* buffer) { - uint32_t count = composition_offset.size(); + uint32_t count = static_cast(composition_offset.size()); if (!buffer->Reading()) { // Determine whether version 0 or version 1 should be used. // Use version 0 if possible, use version 1 if there is a negative @@ -734,14 +737,14 @@ bool CompositionTimeToSample::ReadWriteInternal(BoxBuffer* buffer) { return true; } -uint32_t CompositionTimeToSample::ComputeSizeInternal() { +size_t CompositionTimeToSample::ComputeSizeInternal() { // This box is optional. Skip it if it is empty. if (composition_offset.empty()) return 0; // Structure CompositionOffset contains |sample_offset| (uint32_t) and // |sample_offset| (int64_t). The actual size of |sample_offset| is // 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) + kCompositionOffsetSize * composition_offset.size(); } @@ -751,7 +754,7 @@ SampleToChunk::~SampleToChunk() {} FourCC SampleToChunk::BoxType() const { return FOURCC_stsc; } bool SampleToChunk::ReadWriteInternal(BoxBuffer* buffer) { - uint32_t count = chunk_info.size(); + uint32_t count = static_cast(chunk_info.size()); RCHECK(ReadWriteHeaderInternal(buffer) && buffer->ReadWriteUInt32(&count)); @@ -767,7 +770,7 @@ bool SampleToChunk::ReadWriteInternal(BoxBuffer* buffer) { return true; } -uint32_t SampleToChunk::ComputeSizeInternal() { +size_t SampleToChunk::ComputeSizeInternal() { return HeaderSize() + sizeof(uint32_t) + sizeof(ChunkInfo) * chunk_info.size(); } @@ -792,7 +795,7 @@ bool SampleSize::ReadWriteInternal(BoxBuffer* buffer) { return true; } -uint32_t SampleSize::ComputeSizeInternal() { +size_t SampleSize::ComputeSizeInternal() { return HeaderSize() + sizeof(sample_size) + sizeof(sample_count) + (sample_size == 0 ? sizeof(uint32_t) * sizes.size() : 0); } @@ -802,7 +805,7 @@ CompactSampleSize::~CompactSampleSize() {} FourCC CompactSampleSize::BoxType() const { return FOURCC_stz2; } bool CompactSampleSize::ReadWriteInternal(BoxBuffer* buffer) { - uint32_t sample_count = sizes.size(); + uint32_t sample_count = static_cast(sizes.size()); RCHECK(ReadWriteHeaderInternal(buffer) && buffer->IgnoreBytes(3) && buffer->ReadWriteUInt8(&field_size) && @@ -847,7 +850,7 @@ bool CompactSampleSize::ReadWriteInternal(BoxBuffer* buffer) { return true; } -uint32_t CompactSampleSize::ComputeSizeInternal() { +size_t CompactSampleSize::ComputeSizeInternal() { return HeaderSize() + sizeof(uint32_t) + sizeof(uint32_t) + (field_size * sizes.size() + 7) / 8; } @@ -857,7 +860,7 @@ ChunkOffset::~ChunkOffset() {} FourCC ChunkOffset::BoxType() const { return FOURCC_stco; } bool ChunkOffset::ReadWriteInternal(BoxBuffer* buffer) { - uint32_t count = offsets.size(); + uint32_t count = static_cast(offsets.size()); RCHECK(ReadWriteHeaderInternal(buffer) && buffer->ReadWriteUInt32(&count)); @@ -867,7 +870,7 @@ bool ChunkOffset::ReadWriteInternal(BoxBuffer* buffer) { return true; } -uint32_t ChunkOffset::ComputeSizeInternal() { +size_t ChunkOffset::ComputeSizeInternal() { return HeaderSize() + sizeof(uint32_t) + sizeof(uint32_t) * offsets.size(); } @@ -876,7 +879,7 @@ ChunkLargeOffset::~ChunkLargeOffset() {} FourCC ChunkLargeOffset::BoxType() const { return FOURCC_co64; } bool ChunkLargeOffset::ReadWriteInternal(BoxBuffer* buffer) { - uint32_t count = offsets.size(); + uint32_t count = static_cast(offsets.size()); if (!buffer->Reading()) { // 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; } -uint32_t ChunkLargeOffset::ComputeSizeInternal() { - uint32_t count = offsets.size(); +size_t ChunkLargeOffset::ComputeSizeInternal() { + uint32_t count = static_cast(offsets.size()); int use_large_offset = (count > 0 && !IsFitIn32Bits(offsets[count - 1])) ? 1 : 0; return HeaderSize() + sizeof(count) + @@ -912,7 +915,7 @@ SyncSample::~SyncSample() {} FourCC SyncSample::BoxType() const { return FOURCC_stss; } bool SyncSample::ReadWriteInternal(BoxBuffer* buffer) { - uint32_t count = sample_number.size(); + uint32_t count = static_cast(sample_number.size()); RCHECK(ReadWriteHeaderInternal(buffer) && buffer->ReadWriteUInt32(&count)); @@ -922,7 +925,7 @@ bool SyncSample::ReadWriteInternal(BoxBuffer* buffer) { return true; } -uint32_t SyncSample::ComputeSizeInternal() { +size_t SyncSample::ComputeSizeInternal() { // Sync sample box is optional. Skip it if it is empty. if (sample_number.empty()) return 0; @@ -979,8 +982,9 @@ bool CencSampleEncryptionInfoEntry::ReadWrite(BoxBuffer* buffer) { } uint32_t CencSampleEncryptionInfoEntry::ComputeSize() const { - return sizeof(uint32_t) + kCencKeyIdSize + - (constant_iv.empty() ? 0 : (sizeof(uint8_t) + constant_iv.size())); + return static_cast( + sizeof(uint32_t) + kCencKeyIdSize + + (constant_iv.empty() ? 0 : (sizeof(uint8_t) + constant_iv.size()))); } AudioRollRecoveryEntry::AudioRollRecoveryEntry(): roll_distance(0) {} @@ -1033,7 +1037,7 @@ bool SampleGroupDescription::ReadWriteEntries(BoxBuffer* buffer, return false; } - uint32_t count = entries->size(); + uint32_t count = static_cast(entries->size()); RCHECK(buffer->ReadWriteUInt32(&count)); RCHECK(count != 0); entries->resize(count); @@ -1052,7 +1056,7 @@ bool SampleGroupDescription::ReadWriteEntries(BoxBuffer* buffer, return true; } -uint32_t SampleGroupDescription::ComputeSizeInternal() { +size_t SampleGroupDescription::ComputeSizeInternal() { // Version 0 is obsoleted, so always generate version 1 box. version = 1; size_t entries_size = 0; @@ -1091,7 +1095,7 @@ bool SampleToGroup::ReadWriteInternal(BoxBuffer* buffer) { return true; } - uint32_t count = entries.size(); + uint32_t count = static_cast(entries.size()); RCHECK(buffer->ReadWriteUInt32(&count)); entries.resize(count); for (uint32_t i = 0; i < count; ++i) { @@ -1101,7 +1105,7 @@ bool SampleToGroup::ReadWriteInternal(BoxBuffer* buffer) { return true; } -uint32_t SampleToGroup::ComputeSizeInternal() { +size_t SampleToGroup::ComputeSizeInternal() { // This box is optional. Skip it if it is not used. if (entries.empty()) return 0; @@ -1133,7 +1137,8 @@ bool SampleTable::ReadWriteInternal(BoxBuffer* buffer) { CompactSampleSize compact_sample_size; RCHECK(reader->ReadChild(&compact_sample_size)); sample_size.sample_size = 0; - sample_size.sample_count = compact_sample_size.sizes.size(); + sample_size.sample_count = + static_cast(compact_sample_size.sizes.size()); sample_size.sizes.swap(compact_sample_size.sizes); } @@ -1162,13 +1167,13 @@ bool SampleTable::ReadWriteInternal(BoxBuffer* buffer) { return true; } -uint32_t SampleTable::ComputeSizeInternal() { - uint32_t box_size = - HeaderSize() + description.ComputeSize() + - decoding_time_to_sample.ComputeSize() + - composition_time_to_sample.ComputeSize() + sample_to_chunk.ComputeSize() + - sample_size.ComputeSize() + chunk_large_offset.ComputeSize() + - sync_sample.ComputeSize(); +size_t SampleTable::ComputeSizeInternal() { + size_t box_size = HeaderSize() + description.ComputeSize() + + decoding_time_to_sample.ComputeSize() + + composition_time_to_sample.ComputeSize() + + sample_to_chunk.ComputeSize() + sample_size.ComputeSize() + + chunk_large_offset.ComputeSize() + + sync_sample.ComputeSize(); for (auto& sample_group_description : sample_group_descriptions) box_size += sample_group_description.ComputeSize(); for (auto& sample_to_group : sample_to_groups) @@ -1181,7 +1186,7 @@ EditList::~EditList() {} FourCC EditList::BoxType() const { return FOURCC_elst; } bool EditList::ReadWriteInternal(BoxBuffer* buffer) { - uint32_t count = edits.size(); + uint32_t count = static_cast(edits.size()); RCHECK(ReadWriteHeaderInternal(buffer) && buffer->ReadWriteUInt32(&count)); edits.resize(count); @@ -1196,7 +1201,7 @@ bool EditList::ReadWriteInternal(BoxBuffer* buffer) { return true; } -uint32_t EditList::ComputeSizeInternal() { +size_t EditList::ComputeSizeInternal() { // EditList box is optional. Skip it if it is empty. if (edits.empty()) return 0; @@ -1223,7 +1228,7 @@ bool Edit::ReadWriteInternal(BoxBuffer* buffer) { buffer->ReadWriteChild(&list); } -uint32_t Edit::ComputeSizeInternal() { +size_t Edit::ComputeSizeInternal() { // Edit box is optional. Skip it if it is empty. if (list.edits.empty()) return 0; @@ -1267,8 +1272,8 @@ bool HandlerReference::ReadWriteInternal(BoxBuffer* buffer) { return true; } -uint32_t HandlerReference::ComputeSizeInternal() { - uint32_t box_size = HeaderSize() + kFourCCSize + 16; // 16 bytes Reserved +size_t HandlerReference::ComputeSizeInternal() { + size_t box_size = HeaderSize() + kFourCCSize + 16; // 16 bytes Reserved switch (handler_type) { case FOURCC_vide: box_size += sizeof(kVideoHandlerName); @@ -1332,7 +1337,7 @@ bool PrivFrame::ReadWrite(BoxBuffer* buffer) { return true; } - uint32_t frame_size = owner.size() + 1 + value.size(); + uint32_t frame_size = static_cast(owner.size() + 1 + value.size()); // 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 // 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()) return 0; const uint32_t kFourCCSize = 4; - return kFourCCSize + sizeof(uint32_t) + sizeof(uint16_t) + owner.size() + 1 + - value.size(); + return kFourCCSize + + static_cast(sizeof(uint32_t) + sizeof(uint16_t) + + owner.size() + 1 + value.size()); } ID3v2::ID3v2() {} @@ -1394,7 +1400,7 @@ bool ID3v2::ReadWriteInternal(BoxBuffer* buffer) { return true; } -uint32_t ID3v2::ComputeSizeInternal() { +size_t ID3v2::ComputeSizeInternal() { uint32_t private_frame_size = private_frame.ComputeSize(); // Skip ID3v2 box generation if there is no private frame. return private_frame_size == 0 ? 0 : HeaderSize() + language.ComputeSize() + @@ -1417,8 +1423,8 @@ bool Metadata::ReadWriteInternal(BoxBuffer* buffer) { return true; } -uint32_t Metadata::ComputeSizeInternal() { - uint32_t id3v2_size = id3v2.ComputeSize(); +size_t Metadata::ComputeSizeInternal() { + size_t id3v2_size = id3v2.ComputeSize(); // Skip metadata box generation if there is no metadata box. return id3v2_size == 0 ? 0 : HeaderSize() + handler.ComputeSize() + id3v2_size; @@ -1453,7 +1459,7 @@ bool CodecConfiguration::ReadWriteInternal(BoxBuffer* buffer) { return true; } -uint32_t CodecConfiguration::ComputeSizeInternal() { +size_t CodecConfiguration::ComputeSizeInternal() { if (data.empty()) return 0; DCHECK_NE(box_type, FOURCC_NULL); @@ -1471,7 +1477,7 @@ bool PixelAspectRatio::ReadWriteInternal(BoxBuffer* buffer) { return true; } -uint32_t PixelAspectRatio::ComputeSizeInternal() { +size_t PixelAspectRatio::ComputeSizeInternal() { // This box is optional. Skip it if it is not initialized. if (h_spacing == 0 && v_spacing == 0) return 0; @@ -1572,7 +1578,7 @@ bool VideoSampleEntry::ReadWriteInternal(BoxBuffer* buffer) { return true; } -uint32_t VideoSampleEntry::ComputeSizeInternal() { +size_t VideoSampleEntry::ComputeSizeInternal() { const FourCC actual_format = GetActualFormat(); if (actual_format == FOURCC_NULL) return 0; @@ -1624,7 +1630,7 @@ bool ElementaryStreamDescriptor::ReadWriteInternal(BoxBuffer* buffer) { return true; } -uint32_t ElementaryStreamDescriptor::ComputeSizeInternal() { +size_t ElementaryStreamDescriptor::ComputeSizeInternal() { // This box is optional. Skip it if not initialized. if (es_descriptor.object_type() == kForbidden) return 0; @@ -1658,7 +1664,7 @@ bool DTSSpecific::ReadWriteInternal(BoxBuffer* buffer) { return true; } -uint32_t DTSSpecific::ComputeSizeInternal() { +size_t DTSSpecific::ComputeSizeInternal() { // This box is optional. Skip it if not initialized. if (sampling_frequency == 0) return 0; @@ -1679,7 +1685,7 @@ bool AC3Specific::ReadWriteInternal(BoxBuffer* buffer) { return true; } -uint32_t AC3Specific::ComputeSizeInternal() { +size_t AC3Specific::ComputeSizeInternal() { // This box is optional. Skip it if not initialized. if (data.empty()) return 0; @@ -1693,12 +1699,12 @@ FourCC EC3Specific::BoxType() const { return FOURCC_dec3; } bool EC3Specific::ReadWriteInternal(BoxBuffer* 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)); return true; } -uint32_t EC3Specific::ComputeSizeInternal() { +size_t EC3Specific::ComputeSizeInternal() { // This box is optional. Skip it if not initialized. if (data.empty()) return 0; @@ -1744,7 +1750,7 @@ bool OpusSpecific::ReadWriteInternal(BoxBuffer* buffer) { return true; } -uint32_t OpusSpecific::ComputeSizeInternal() { +size_t OpusSpecific::ComputeSizeInternal() { // This box is optional. Skip it if not initialized. if (opus_identification_header.empty()) return 0; @@ -1814,7 +1820,7 @@ bool AudioSampleEntry::ReadWriteInternal(BoxBuffer* buffer) { return true; } -uint32_t AudioSampleEntry::ComputeSizeInternal() { +size_t AudioSampleEntry::ComputeSizeInternal() { if (GetActualFormat() == FOURCC_NULL) return 0; return HeaderSize() + sizeof(data_reference_index) + sizeof(channelcount) + @@ -1839,7 +1845,7 @@ bool WebVTTConfigurationBox::ReadWriteInternal(BoxBuffer* buffer) { buffer->Reading() ? buffer->BytesLeft() : config.size()); } -uint32_t WebVTTConfigurationBox::ComputeSizeInternal() { +size_t WebVTTConfigurationBox::ComputeSizeInternal() { return HeaderSize() + config.size(); } @@ -1857,7 +1863,7 @@ bool WebVTTSourceLabelBox::ReadWriteInternal(BoxBuffer* buffer) { : source_label.size()); } -uint32_t WebVTTSourceLabelBox::ComputeSizeInternal() { +size_t WebVTTSourceLabelBox::ComputeSizeInternal() { if (source_label.empty()) return 0; return HeaderSize() + source_label.size(); @@ -1893,7 +1899,7 @@ bool TextSampleEntry::ReadWriteInternal(BoxBuffer* buffer) { return true; } -uint32_t TextSampleEntry::ComputeSizeInternal() { +size_t TextSampleEntry::ComputeSizeInternal() { // 6 for the (anonymous) reserved bytes for SampleEntry class. return HeaderSize() + 6 + sizeof(data_reference_index) + config.ComputeSize() + label.ComputeSize(); @@ -1917,7 +1923,7 @@ bool MediaHeader::ReadWriteInternal(BoxBuffer* buffer) { return true; } -uint32_t MediaHeader::ComputeSizeInternal() { +size_t MediaHeader::ComputeSizeInternal() { version = IsFitIn32Bits(creation_time, modification_time, duration) ? 0 : 1; return HeaderSize() + sizeof(timescale) + sizeof(uint32_t) * (1 + version) * 3 + language.ComputeSize() + @@ -1940,7 +1946,7 @@ bool VideoMediaHeader::ReadWriteInternal(BoxBuffer* buffer) { return true; } -uint32_t VideoMediaHeader::ComputeSizeInternal() { +size_t VideoMediaHeader::ComputeSizeInternal() { return HeaderSize() + sizeof(graphicsmode) + sizeof(opcolor_red) + sizeof(opcolor_green) + sizeof(opcolor_blue); } @@ -1955,7 +1961,7 @@ bool SoundMediaHeader::ReadWriteInternal(BoxBuffer* buffer) { return true; } -uint32_t SoundMediaHeader::ComputeSizeInternal() { +size_t SoundMediaHeader::ComputeSizeInternal() { return HeaderSize() + sizeof(balance) + sizeof(uint16_t); } @@ -1968,7 +1974,7 @@ bool SubtitleMediaHeader::ReadWriteInternal(BoxBuffer* buffer) { return ReadWriteHeaderInternal(buffer); } -uint32_t SubtitleMediaHeader::ComputeSizeInternal() { +size_t SubtitleMediaHeader::ComputeSizeInternal() { return HeaderSize(); } @@ -1988,7 +1994,7 @@ bool DataEntryUrl::ReadWriteInternal(BoxBuffer* buffer) { return true; } -uint32_t DataEntryUrl::ComputeSizeInternal() { +size_t DataEntryUrl::ComputeSizeInternal() { return HeaderSize() + location.size(); } @@ -1999,7 +2005,7 @@ DataReference::DataReference() { DataReference::~DataReference() {} FourCC DataReference::BoxType() const { return FOURCC_dref; } bool DataReference::ReadWriteInternal(BoxBuffer* buffer) { - uint32_t entry_count = data_entry.size(); + uint32_t entry_count = static_cast(data_entry.size()); RCHECK(ReadWriteHeaderInternal(buffer) && buffer->ReadWriteUInt32(&entry_count)); data_entry.resize(entry_count); @@ -2009,9 +2015,9 @@ bool DataReference::ReadWriteInternal(BoxBuffer* buffer) { return true; } -uint32_t DataReference::ComputeSizeInternal() { - uint32_t count = data_entry.size(); - uint32_t box_size = HeaderSize() + sizeof(count); +size_t DataReference::ComputeSizeInternal() { + uint32_t count = static_cast(data_entry.size()); + size_t box_size = HeaderSize() + sizeof(count); for (uint32_t i = 0; i < count; ++i) box_size += data_entry[i].ComputeSize(); return box_size; @@ -2027,7 +2033,7 @@ bool DataInformation::ReadWriteInternal(BoxBuffer* buffer) { buffer->ReadWriteChild(&dref); } -uint32_t DataInformation::ComputeSizeInternal() { +size_t DataInformation::ComputeSizeInternal() { return HeaderSize() + dref.ComputeSize(); } @@ -2057,8 +2063,8 @@ bool MediaInformation::ReadWriteInternal(BoxBuffer* buffer) { return true; } -uint32_t MediaInformation::ComputeSizeInternal() { - uint32_t box_size = +size_t MediaInformation::ComputeSizeInternal() { + size_t box_size = HeaderSize() + dinf.ComputeSize() + sample_table.ComputeSize(); switch (sample_table.description.type) { case kVideo: @@ -2104,7 +2110,7 @@ bool Media::ReadWriteInternal(BoxBuffer* buffer) { return true; } -uint32_t Media::ComputeSizeInternal() { +size_t Media::ComputeSizeInternal() { handler.handler_type = TrackTypeToFourCC(information.sample_table.description.type); return HeaderSize() + header.ComputeSize() + handler.ComputeSize() + @@ -2125,7 +2131,7 @@ bool Track::ReadWriteInternal(BoxBuffer* buffer) { return true; } -uint32_t Track::ComputeSizeInternal() { +size_t Track::ComputeSizeInternal() { return HeaderSize() + header.ComputeSize() + media.ComputeSize() + edit.ComputeSize(); } @@ -2141,7 +2147,7 @@ bool MovieExtendsHeader::ReadWriteInternal(BoxBuffer* buffer) { return true; } -uint32_t MovieExtendsHeader::ComputeSizeInternal() { +size_t MovieExtendsHeader::ComputeSizeInternal() { // This box is optional. Skip it if it is not used. if (fragment_duration == 0) return 0; @@ -2168,7 +2174,7 @@ bool TrackExtends::ReadWriteInternal(BoxBuffer* buffer) { return true; } -uint32_t TrackExtends::ComputeSizeInternal() { +size_t TrackExtends::ComputeSizeInternal() { return HeaderSize() + sizeof(track_id) + sizeof(default_sample_description_index) + sizeof(default_sample_duration) + sizeof(default_sample_size) + @@ -2193,11 +2199,11 @@ bool MovieExtends::ReadWriteInternal(BoxBuffer* buffer) { return true; } -uint32_t MovieExtends::ComputeSizeInternal() { +size_t MovieExtends::ComputeSizeInternal() { // This box is optional. Skip it if it does not contain any track. if (tracks.size() == 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) box_size += tracks[i].ComputeSize(); return box_size; @@ -2227,9 +2233,9 @@ bool Movie::ReadWriteInternal(BoxBuffer* buffer) { return true; } -uint32_t Movie::ComputeSizeInternal() { - uint32_t box_size = HeaderSize() + header.ComputeSize() + - metadata.ComputeSize() + extends.ComputeSize(); +size_t Movie::ComputeSizeInternal() { + size_t box_size = HeaderSize() + header.ComputeSize() + + metadata.ComputeSize() + extends.ComputeSize(); for (uint32_t i = 0; i < tracks.size(); ++i) box_size += tracks[i].ComputeSize(); for (uint32_t i = 0; i < pssh.size(); ++i) @@ -2248,7 +2254,7 @@ bool TrackFragmentDecodeTime::ReadWriteInternal(BoxBuffer* buffer) { return true; } -uint32_t TrackFragmentDecodeTime::ComputeSizeInternal() { +size_t TrackFragmentDecodeTime::ComputeSizeInternal() { version = IsFitIn32Bits(decode_time) ? 0 : 1; return HeaderSize() + sizeof(uint32_t) * (1 + version); } @@ -2262,7 +2268,7 @@ bool MovieFragmentHeader::ReadWriteInternal(BoxBuffer* buffer) { buffer->ReadWriteUInt32(&sequence_number); } -uint32_t MovieFragmentHeader::ComputeSizeInternal() { +size_t MovieFragmentHeader::ComputeSizeInternal() { return HeaderSize() + sizeof(sequence_number); } @@ -2314,8 +2320,8 @@ bool TrackFragmentHeader::ReadWriteInternal(BoxBuffer* buffer) { return true; } -uint32_t TrackFragmentHeader::ComputeSizeInternal() { - uint32_t box_size = HeaderSize() + sizeof(track_id); +size_t TrackFragmentHeader::ComputeSizeInternal() { + size_t box_size = HeaderSize() + sizeof(track_id); if (flags & kSampleDescriptionIndexPresentMask) box_size += sizeof(sample_description_index); if (flags & kDefaultSampleDurationPresentMask) @@ -2434,8 +2440,8 @@ bool TrackFragmentRun::ReadWriteInternal(BoxBuffer* buffer) { return true; } -uint32_t TrackFragmentRun::ComputeSizeInternal() { - uint32_t box_size = HeaderSize() + sizeof(sample_count); +size_t TrackFragmentRun::ComputeSizeInternal() { + size_t box_size = HeaderSize() + sizeof(sample_count); if (flags & kDataOffsetPresentMask) box_size += sizeof(data_offset); if (flags & kFirstSampleFlagsPresentMask) @@ -2479,11 +2485,11 @@ bool TrackFragment::ReadWriteInternal(BoxBuffer* buffer) { buffer->TryReadWriteChild(&sample_encryption); } -uint32_t TrackFragment::ComputeSizeInternal() { - uint32_t box_size = - HeaderSize() + header.ComputeSize() + decode_time.ComputeSize() + - auxiliary_size.ComputeSize() + auxiliary_offset.ComputeSize() + - sample_encryption.ComputeSize(); +size_t TrackFragment::ComputeSizeInternal() { + size_t box_size = HeaderSize() + header.ComputeSize() + + decode_time.ComputeSize() + auxiliary_size.ComputeSize() + + auxiliary_offset.ComputeSize() + + sample_encryption.ComputeSize(); for (uint32_t i = 0; i < runs.size(); ++i) box_size += runs[i].ComputeSize(); for (uint32_t i = 0; i < sample_group_descriptions.size(); ++i) @@ -2515,8 +2521,8 @@ bool MovieFragment::ReadWriteInternal(BoxBuffer* buffer) { return true; } -uint32_t MovieFragment::ComputeSizeInternal() { - uint32_t box_size = HeaderSize() + header.ComputeSize(); +size_t MovieFragment::ComputeSizeInternal() { + size_t box_size = HeaderSize() + header.ComputeSize(); for (uint32_t i = 0; i < tracks.size(); ++i) box_size += tracks[i].ComputeSize(); for (uint32_t i = 0; i < pssh.size(); ++i) @@ -2573,7 +2579,7 @@ bool SegmentIndex::ReadWriteInternal(BoxBuffer* buffer) { return true; } -uint32_t SegmentIndex::ComputeSizeInternal() { +size_t SegmentIndex::ComputeSizeInternal() { version = IsFitIn32Bits(earliest_presentation_time, first_offset) ? 0 : 1; return HeaderSize() + sizeof(reference_id) + sizeof(timescale) + sizeof(uint32_t) * (1 + version) * 2 + 2 * sizeof(uint16_t) + @@ -2589,7 +2595,7 @@ bool MediaData::ReadWriteInternal(BoxBuffer* buffer) { return false; } -uint32_t MediaData::ComputeSizeInternal() { +size_t MediaData::ComputeSizeInternal() { return HeaderSize() + data_size; } @@ -2603,7 +2609,7 @@ bool CueSourceIDBox::ReadWriteInternal(BoxBuffer* buffer) { return true; } -uint32_t CueSourceIDBox::ComputeSizeInternal() { +size_t CueSourceIDBox::ComputeSizeInternal() { if (source_id == kCueSourceIdNotSet) return 0; return HeaderSize() + sizeof(source_id); @@ -2623,7 +2629,7 @@ bool CueTimeBox::ReadWriteInternal(BoxBuffer* buffer) { buffer->Reading() ? buffer->BytesLeft() : cue_current_time.size()); } -uint32_t CueTimeBox::ComputeSizeInternal() { +size_t CueTimeBox::ComputeSizeInternal() { if (cue_current_time.empty()) return 0; return HeaderSize() + cue_current_time.size(); @@ -2642,7 +2648,7 @@ bool CueIDBox::ReadWriteInternal(BoxBuffer* buffer) { &cue_id, buffer->Reading() ? buffer->BytesLeft() : cue_id.size()); } -uint32_t CueIDBox::ComputeSizeInternal() { +size_t CueIDBox::ComputeSizeInternal() { if (cue_id.empty()) return 0; return HeaderSize() + cue_id.size(); @@ -2661,7 +2667,7 @@ bool CueSettingsBox::ReadWriteInternal(BoxBuffer* buffer) { &settings, buffer->Reading() ? buffer->BytesLeft() : settings.size()); } -uint32_t CueSettingsBox::ComputeSizeInternal() { +size_t CueSettingsBox::ComputeSizeInternal() { if (settings.empty()) return 0; return HeaderSize() + settings.size(); @@ -2680,7 +2686,7 @@ bool CuePayloadBox::ReadWriteInternal(BoxBuffer* buffer) { &cue_text, buffer->Reading() ? buffer->BytesLeft() : cue_text.size()); } -uint32_t CuePayloadBox::ComputeSizeInternal() { +size_t CuePayloadBox::ComputeSizeInternal() { return HeaderSize() + cue_text.size(); } @@ -2695,7 +2701,7 @@ bool VTTEmptyCueBox::ReadWriteInternal(BoxBuffer* buffer) { return ReadWriteHeaderInternal(buffer); } -uint32_t VTTEmptyCueBox::ComputeSizeInternal() { +size_t VTTEmptyCueBox::ComputeSizeInternal() { return HeaderSize(); } @@ -2713,7 +2719,7 @@ bool VTTAdditionalTextBox::ReadWriteInternal(BoxBuffer* buffer) { buffer->Reading() ? buffer->BytesLeft() : cue_additional_text.size()); } -uint32_t VTTAdditionalTextBox::ComputeSizeInternal() { +size_t VTTAdditionalTextBox::ComputeSizeInternal() { return HeaderSize() + cue_additional_text.size(); } @@ -2735,7 +2741,7 @@ bool VTTCueBox::ReadWriteInternal(BoxBuffer* buffer) { return true; } -uint32_t VTTCueBox::ComputeSizeInternal() { +size_t VTTCueBox::ComputeSizeInternal() { return HeaderSize() + cue_source_id.ComputeSize() + cue_id.ComputeSize() + cue_time.ComputeSize() + cue_settings.ComputeSize() + cue_payload.ComputeSize(); diff --git a/packager/media/formats/mp4/box_definitions.h b/packager/media/formats/mp4/box_definitions.h index 12b1b8f372..96c9cdd45f 100644 --- a/packager/media/formats/mp4/box_definitions.h +++ b/packager/media/formats/mp4/box_definitions.h @@ -38,7 +38,7 @@ class BoxBuffer; \ private: \ bool ReadWriteInternal(BoxBuffer* buffer) override; \ - uint32_t ComputeSizeInternal() override; \ + size_t ComputeSizeInternal() override; \ \ public: diff --git a/packager/media/formats/mp4/box_definitions_unittest.cc b/packager/media/formats/mp4/box_definitions_unittest.cc index 8ee2a9114b..1f1fdcd9d7 100644 --- a/packager/media/formats/mp4/box_definitions_unittest.cc +++ b/packager/media/formats/mp4/box_definitions_unittest.cc @@ -44,7 +44,7 @@ class BoxDefinitionsTestGeneral : public testing::Test { // Create a fake skip box contains the buffer and Write it. BufferWriter buffer; buffer.Swap(buffer_.get()); - uint32_t skip_box_size = buffer.Size() + kBoxSize; + uint32_t skip_box_size = static_cast(buffer.Size() + kBoxSize); buffer_->AppendInt(skip_box_size); buffer_->AppendInt(static_cast(FOURCC_skip)); buffer_->AppendBuffer(buffer); diff --git a/packager/media/formats/mp4/box_reader_unittest.cc b/packager/media/formats/mp4/box_reader_unittest.cc index 5b6121a9e6..d7f90608c4 100644 --- a/packager/media/formats/mp4/box_reader_unittest.cc +++ b/packager/media/formats/mp4/box_reader_unittest.cc @@ -35,7 +35,7 @@ struct FreeBox : Box { bool ReadWriteInternal(BoxBuffer* buffer) override { return true; } - uint32_t ComputeSizeInternal() override { + size_t ComputeSizeInternal() override { NOTIMPLEMENTED(); return 0; } @@ -46,7 +46,7 @@ struct PsshBox : Box { bool ReadWriteInternal(BoxBuffer* buffer) override { return buffer->ReadWriteUInt32(&val); } - uint32_t ComputeSizeInternal() override { + size_t ComputeSizeInternal() override { NOTIMPLEMENTED(); return 0; } @@ -70,7 +70,7 @@ struct SkipBox : FullBox { } return buffer->TryReadWriteChild(&empty); } - uint32_t ComputeSizeInternal() override { + size_t ComputeSizeInternal() override { NOTIMPLEMENTED(); return 0; } diff --git a/packager/media/formats/mp4/encrypting_fragmenter.cc b/packager/media/formats/mp4/encrypting_fragmenter.cc index 53675a9369..859ec8104c 100644 --- a/packager/media/formats/mp4/encrypting_fragmenter.cc +++ b/packager/media/formats/mp4/encrypting_fragmenter.cc @@ -179,7 +179,8 @@ void EncryptingFragmenter::FinalizeFragmentForEncryption() { // Optimize saiz box. SampleAuxiliaryInformationSize& saiz = traf()->auxiliary_size; - saiz.sample_count = traf()->runs[0].sample_sizes.size(); + saiz.sample_count = + static_cast(traf()->runs[0].sample_sizes.size()); if (!saiz.sample_info_sizes.empty()) { if (!OptimizeSampleEntries(&saiz.sample_info_sizes, &saiz.default_sample_info_size)) { @@ -242,7 +243,7 @@ Status EncryptingFragmenter::CreateEncryptor() { return Status::OK; } -void EncryptingFragmenter::EncryptBytes(uint8_t* data, uint32_t size) { +void EncryptingFragmenter::EncryptBytes(uint8_t* data, size_t size) { DCHECK(encryptor_); CHECK(encryptor_->Crypt(data, size, data)); } @@ -268,8 +269,8 @@ Status EncryptingFragmenter::EncryptSample(scoped_refptr sample) { SubsampleEntry subsample; subsample.clear_bytes = static_cast(frame.uncompressed_header_size); - subsample.cipher_bytes = - frame.frame_size - frame.uncompressed_header_size; + subsample.cipher_bytes = static_cast( + frame.frame_size - frame.uncompressed_header_size); // "VP Codec ISO Media File Format Binding" document requires that the // encrypted bytes of each frame within the superframe must be block diff --git a/packager/media/formats/mp4/encrypting_fragmenter.h b/packager/media/formats/mp4/encrypting_fragmenter.h index 84e11bd2db..57c93b45fe 100644 --- a/packager/media/formats/mp4/encrypting_fragmenter.h +++ b/packager/media/formats/mp4/encrypting_fragmenter.h @@ -79,7 +79,7 @@ class EncryptingFragmenter : public Fragmenter { } private: - void EncryptBytes(uint8_t* data, uint32_t size); + void EncryptBytes(uint8_t* data, size_t size); Status EncryptSample(scoped_refptr sample); // Should we enable subsample encryption? diff --git a/packager/media/formats/mp4/fragmenter.cc b/packager/media/formats/mp4/fragmenter.cc index b90a0e879d..016d4f39b1 100644 --- a/packager/media/formats/mp4/fragmenter.cc +++ b/packager/media/formats/mp4/fragmenter.cc @@ -60,7 +60,8 @@ Status Fragmenter::AddSample(scoped_refptr sample) { LOG(WARNING) << "MP4 samples do not support side data. Side data ignored."; // 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(sample->data_size())); traf_->runs[0].sample_durations.push_back(sample->duration()); traf_->runs[0].sample_flags.push_back( sample->is_key_frame() ? 0 : TrackFragmentHeader::kNonKeySampleMask); @@ -109,7 +110,8 @@ Status Fragmenter::InitializeFragment(int64_t first_sample_dts) { void Fragmenter::FinalizeFragment() { // Optimize trun box. - traf_->runs[0].sample_count = traf_->runs[0].sample_sizes.size(); + traf_->runs[0].sample_count = + static_cast(traf_->runs[0].sample_sizes.size()); if (OptimizeSampleEntries(&traf_->runs[0].sample_durations, &traf_->header.default_sample_duration)) { traf_->header.flags |= diff --git a/packager/media/formats/mp4/mp4_media_parser.cc b/packager/media/formats/mp4/mp4_media_parser.cc index 038c909588..6147328404 100644 --- a/packager/media/formats/mp4/mp4_media_parser.cc +++ b/packager/media/formats/mp4/mp4_media_parser.cc @@ -269,7 +269,7 @@ bool MP4MediaParser::ParseBox(bool* err) { VLOG(2) << "Skipping top-level box: " << FourCCToString(reader->type()); } - queue_.Pop(reader->size()); + queue_.Pop(static_cast(reader->size())); return !(*err); } diff --git a/packager/media/formats/mp4/mp4_media_parser_unittest.cc b/packager/media/formats/mp4/mp4_media_parser_unittest.cc index 42896d2bb5..258ca3cc63 100644 --- a/packager/media/formats/mp4/mp4_media_parser_unittest.cc +++ b/packager/media/formats/mp4/mp4_media_parser_unittest.cc @@ -53,7 +53,7 @@ class MP4MediaParserTest : public testing::Test { size_t num_samples_; bool AppendData(const uint8_t* data, size_t length) { - return parser_->Parse(data, length); + return parser_->Parse(data, static_cast(length)); } bool AppendDataInPieces(const uint8_t* data, diff --git a/packager/media/formats/mp4/mp4_muxer.cc b/packager/media/formats/mp4/mp4_muxer.cc index a4753176c4..aac6028c56 100644 --- a/packager/media/formats/mp4/mp4_muxer.cc +++ b/packager/media/formats/mp4/mp4_muxer.cc @@ -101,7 +101,7 @@ Status MP4Muxer::Initialize() { moov->header.creation_time = IsoTimeNow(); moov->header.modification_time = IsoTimeNow(); - moov->header.next_track_id = streams().size() + 1; + moov->header.next_track_id = static_cast(streams().size()) + 1; moov->tracks.resize(streams().size()); moov->extends.tracks.resize(streams().size()); diff --git a/packager/media/formats/mp4/multi_segment_segmenter.cc b/packager/media/formats/mp4/multi_segment_segmenter.cc index f47b3f814c..2319b5e469 100644 --- a/packager/media/formats/mp4/multi_segment_segmenter.cc +++ b/packager/media/formats/mp4/multi_segment_segmenter.cc @@ -85,18 +85,18 @@ Status MultiSegmentSegmenter::DoFinalizeSegment() { // sidx() contains pre-generated segment references with one reference per // fragment. Calculate |num_fragments_per_subsegment| and combine // pre-generated references into final subsegment references. - uint32_t num_fragments = sidx()->references.size(); - uint32_t num_fragments_per_subsegment = + size_t num_fragments = sidx()->references.size(); + size_t num_fragments_per_subsegment = (num_fragments - 1) / options().num_subsegments_per_sidx + 1; if (num_fragments_per_subsegment <= 1) return WriteSegment(); - uint32_t frag_index = 0; - uint32_t subseg_index = 0; + size_t frag_index = 0; + size_t subseg_index = 0; std::vector& refs = sidx()->references; uint64_t first_sap_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].subsegment_duration += refs[i].subsegment_duration; refs[subseg_index].earliest_presentation_time = diff --git a/packager/media/formats/mp4/segmenter.cc b/packager/media/formats/mp4/segmenter.cc index 0bf527f6d8..977a45ffb5 100644 --- a/packager/media/formats/mp4/segmenter.cc +++ b/packager/media/formats/mp4/segmenter.cc @@ -456,7 +456,7 @@ Status Segmenter::FinalizeFragment(bool finalize_segment, sizeof(uint32_t); // for sample count field in 'senc' } traf.runs[0].data_offset = data_offset + mdat.data_size; - mdat.data_size += fragmenters_[i]->data()->Size(); + mdat.data_size += static_cast(fragmenters_[i]->data()->Size()); } // Generate segment reference. diff --git a/packager/media/formats/mp4/track_run_iterator.cc b/packager/media/formats/mp4/track_run_iterator.cc index d6546ab1f3..d05919c045 100644 --- a/packager/media/formats/mp4/track_run_iterator.cc +++ b/packager/media/formats/mp4/track_run_iterator.cc @@ -79,7 +79,7 @@ TrackRunIterator::~TrackRunIterator() {} static void PopulateSampleInfo(const TrackExtends& trex, const TrackFragmentHeader& tfhd, const TrackFragmentRun& trun, - const uint32_t i, + const size_t i, SampleInfo* sample_info) { if (i < trun.sample_sizes.size()) { sample_info->size = trun.sample_sizes[i]; @@ -187,7 +187,7 @@ bool TrackRunIterator::Init() { int64_t run_start_dts = 0; uint32_t num_samples = sample_size.sample_count; - uint32_t num_chunks = chunk_offset_vector.size(); + uint32_t num_chunks = static_cast(chunk_offset_vector.size()); // Check that total number of samples match. DCHECK_EQ(num_samples, decoding_time.NumSamples()); @@ -410,7 +410,8 @@ bool TrackRunIterator::Init(const MovieFragment& moof) { tri.samples.resize(trun.sample_count); 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; } runs_.push_back(tri); diff --git a/packager/media/formats/mp4/track_run_iterator_unittest.cc b/packager/media/formats/mp4/track_run_iterator_unittest.cc index 41168b3f5f..00cb0d8b01 100644 --- a/packager/media/formats/mp4/track_run_iterator_unittest.cc +++ b/packager/media/formats/mp4/track_run_iterator_unittest.cc @@ -277,7 +277,7 @@ class TrackRunIteratorTest : public testing::Test { void SetAscending(std::vector* vec) { vec->resize(10); for (size_t i = 0; i < vec->size(); i++) - (*vec)[i] = i + 1; + (*vec)[i] = static_cast(i + 1); } }; diff --git a/packager/media/formats/webm/encryptor.cc b/packager/media/formats/webm/encryptor.cc index 97fd0b33ac..e090c3602e 100644 --- a/packager/media/formats/webm/encryptor.cc +++ b/packager/media/formats/webm/encryptor.cc @@ -118,10 +118,11 @@ Status Encryptor::EncryptFrame(scoped_refptr sample, uint32_t partition_offset = 0; BufferWriter offsets_buffer(kWebMPartitionOffsetSize * num_partitions); for (const auto& vpx_frame : vpx_frames) { - uint32_t encrypted_size = - vpx_frame.frame_size - vpx_frame.uncompressed_header_size; + uint32_t encrypted_size = static_cast( + vpx_frame.frame_size - vpx_frame.uncompressed_header_size); encrypted_size -= encrypted_size % kAesBlockSize; - uint32_t clear_size = vpx_frame.frame_size - encrypted_size; + uint32_t clear_size = + static_cast(vpx_frame.frame_size - encrypted_size); partition_offset += clear_size; offsets_buffer.AppendInt(partition_offset); if (encrypted_size > 0) { diff --git a/packager/media/formats/webm/multi_segment_segmenter_unittest.cc b/packager/media/formats/webm/multi_segment_segmenter_unittest.cc index ec3ad2fa6e..93faec2c3d 100644 --- a/packager/media/formats/webm/multi_segment_segmenter_unittest.cc +++ b/packager/media/formats/webm/multi_segment_segmenter_unittest.cc @@ -142,11 +142,11 @@ TEST_F(MultiSegmentSegmenterTest, SplitsFilesOnSegmentDuration) { // Verify the resulting data. ClusterParser parser; 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)); 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_FALSE(File::Open(TemplateFileName(2).c_str(), "r")); @@ -170,11 +170,11 @@ TEST_F(MultiSegmentSegmenterTest, RespectsSegmentSAPAlign) { // Verify the resulting data. ClusterParser parser; 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)); 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_FALSE(File::Open(TemplateFileName(2).c_str(), "r")); @@ -196,7 +196,7 @@ TEST_F(MultiSegmentSegmenterTest, SplitsClustersOnFragmentDuration) { // Verify the resulting data. ClusterParser parser; 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(3, parser.GetFrameCountForCluster(1)); @@ -221,7 +221,7 @@ TEST_F(MultiSegmentSegmenterTest, RespectsFragmentSAPAlign) { // Verify the resulting data. ClusterParser parser; 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(4, parser.GetFrameCountForCluster(1)); diff --git a/packager/media/formats/webm/segmenter_test_base.cc b/packager/media/formats/webm/segmenter_test_base.cc index 726f0042de..e994cc66a4 100644 --- a/packager/media/formats/webm/segmenter_test_base.cc +++ b/packager/media/formats/webm/segmenter_test_base.cc @@ -121,7 +121,8 @@ void SegmentTestBase::ClusterParser::PopulateFromCluster( WebMListParser cluster_parser(kWebMIdCluster, this); size_t position = 0; while (position < size) { - int read = cluster_parser.Parse(data + position, size - position); + int read = cluster_parser.Parse(data + position, + static_cast(size - position)); ASSERT_LT(0, read); cluster_parser.Reset(); @@ -138,11 +139,12 @@ void SegmentTestBase::ClusterParser::PopulateFromSegment( const uint8_t* data = reinterpret_cast(file_contents.c_str()); const size_t size = file_contents.size(); WebMListParser header_parser(kWebMIdEBMLHeader, this); - int offset = header_parser.Parse(data, size); + int offset = header_parser.Parse(data, static_cast(size)); ASSERT_LT(0, offset); 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(size) - offset)); } int SegmentTestBase::ClusterParser::GetFrameCountForCluster(size_t i) const { @@ -150,7 +152,7 @@ int SegmentTestBase::ClusterParser::GetFrameCountForCluster(size_t i) const { return cluster_sizes_[i]; } -int SegmentTestBase::ClusterParser::cluster_count() const { +size_t SegmentTestBase::ClusterParser::cluster_count() const { return cluster_sizes_.size(); } diff --git a/packager/media/formats/webm/segmenter_test_base.h b/packager/media/formats/webm/segmenter_test_base.h index 89cc2d7a12..1113f9d253 100644 --- a/packager/media/formats/webm/segmenter_test_base.h +++ b/packager/media/formats/webm/segmenter_test_base.h @@ -89,7 +89,7 @@ class SegmentTestBase : public ::testing::Test { int GetFrameCountForCluster(size_t i) const; - int cluster_count() const; + size_t cluster_count() const; private: // WebMParserClient overrides. diff --git a/packager/media/formats/webm/single_segment_segmenter_unittest.cc b/packager/media/formats/webm/single_segment_segmenter_unittest.cc index 7f6d01a219..5756fada19 100644 --- a/packager/media/formats/webm/single_segment_segmenter_unittest.cc +++ b/packager/media/formats/webm/single_segment_segmenter_unittest.cc @@ -180,7 +180,7 @@ TEST_F(SingleSegmentSegmenterTest, SplitsClustersOnSegmentDuration) { // Verify the resulting data. ClusterParser parser; 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(3, parser.GetFrameCountForCluster(1)); } @@ -201,7 +201,7 @@ TEST_F(SingleSegmentSegmenterTest, IgnoresFragmentDuration) { // Verify the resulting data. ClusterParser parser; 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)); } @@ -226,7 +226,7 @@ TEST_F(SingleSegmentSegmenterTest, RespectsSAPAlign) { // 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 // 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(4, parser.GetFrameCountForCluster(1)); } diff --git a/packager/media/formats/webm/tracks_builder.cc b/packager/media/formats/webm/tracks_builder.cc index 92ed1007e2..3eb19874af 100644 --- a/packager/media/formats/webm/tracks_builder.cc +++ b/packager/media/formats/webm/tracks_builder.cc @@ -61,9 +61,8 @@ static int DoubleElementSize(int element_id) { } static int StringElementSize(int element_id, const std::string& value) { - return GetUIntSize(element_id) + - GetUIntMkvSize(value.length()) + - value.length(); + return GetUIntSize(element_id) + GetUIntMkvSize(value.length()) + + static_cast(value.length()); } static void SerializeInt(uint8_t** buf_ptr, @@ -196,7 +195,7 @@ std::vector TracksBuilder::Finish() { buffer.resize(GetTracksSize()); // Populate the storage with a tracks header - WriteTracks(&buffer[0], buffer.size()); + WriteTracks(&buffer[0], static_cast(buffer.size())); return buffer; } diff --git a/packager/media/formats/webm/webm_cluster_parser_unittest.cc b/packager/media/formats/webm/webm_cluster_parser_unittest.cc index 1920445002..c145dfb5b4 100644 --- a/packager/media/formats/webm/webm_cluster_parser_unittest.cc +++ b/packager/media/formats/webm/webm_cluster_parser_unittest.cc @@ -230,7 +230,7 @@ std::unique_ptr CreateCluster(int timecode, std::unique_ptr CreateCluster(const uint8_t* data, size_t data_size) { ClusterBuilder cb; cb.SetClusterTimecode(0); - cb.AddSimpleBlock(kVideoTrackNum, 0, 0, data, data_size); + cb.AddSimpleBlock(kVideoTrackNum, 0, 0, data, static_cast(data_size)); return cb.Finish(); } @@ -239,8 +239,8 @@ bool VerifyBuffersHelper(const BufferQueue& audio_buffers, const BufferQueue& text_buffers, const BlockInfo* block_info, int block_count) { - int buffer_count = audio_buffers.size() + video_buffers.size() + - text_buffers.size(); + int buffer_count = static_cast( + audio_buffers.size() + video_buffers.size() + text_buffers.size()); if (block_count != buffer_count) { LOG(ERROR) << __FUNCTION__ << " : block_count (" << block_count << ") mismatches buffer_count (" << buffer_count << ")"; diff --git a/packager/media/formats/webm/webm_crypto_helpers.cc b/packager/media/formats/webm/webm_crypto_helpers.cc index 74c16d7e2d..14efd5f1f1 100644 --- a/packager/media/formats/webm/webm_crypto_helpers.cc +++ b/packager/media/formats/webm/webm_crypto_helpers.cc @@ -30,7 +30,7 @@ std::vector GenerateWebMCounterBlock(const uint8_t* iv, int iv_size) { bool WebMCreateDecryptConfig(const uint8_t* data, int data_size, const uint8_t* key_id, - int key_id_size, + size_t key_id_size, std::unique_ptr* decrypt_config, int* data_offset) { int header_size = kWebMSignalByteSize; diff --git a/packager/media/formats/webm/webm_crypto_helpers.h b/packager/media/formats/webm/webm_crypto_helpers.h index e0162db4b3..2a4e10aba6 100644 --- a/packager/media/formats/webm/webm_crypto_helpers.h +++ b/packager/media/formats/webm/webm_crypto_helpers.h @@ -23,7 +23,7 @@ namespace media { bool WebMCreateDecryptConfig(const uint8_t* data, int data_size, const uint8_t* key_id, - int key_id_size, + size_t key_id_size, std::unique_ptr* decrypt_config, int* data_offset); diff --git a/packager/media/formats/webm/webm_parser.cc b/packager/media/formats/webm/webm_parser.cc index 6a279bcbe3..27a8db457a 100644 --- a/packager/media/formats/webm/webm_parser.cc +++ b/packager/media/formats/webm/webm_parser.cc @@ -892,7 +892,8 @@ bool WebMListParser::OnListStart(int id, int64_t size) { if (!element_info) return false; - int current_level = root_level_ + list_state_stack_.size() - 1; + int current_level = + root_level_ + static_cast(list_state_stack_.size()) - 1; if (current_level + 1 != element_info->level_) return false; diff --git a/packager/media/formats/webm/webm_parser_unittest.cc b/packager/media/formats/webm/webm_parser_unittest.cc index a3918493bc..cd88392f91 100644 --- a/packager/media/formats/webm/webm_parser_unittest.cc +++ b/packager/media/formats/webm/webm_parser_unittest.cc @@ -345,7 +345,7 @@ TEST_F(WebMParserTest, ReservedIds) { for (size_t i = 0; i < arraysize(kBuffers); i++) { int id; int64_t element_size; - int buffer_size = 2 + i; + int buffer_size = 2 + static_cast(i); EXPECT_EQ(buffer_size, WebMParseElementHeader(kBuffers[i], buffer_size, &id, &element_size)); EXPECT_EQ(id, kWebMReservedId); @@ -373,7 +373,7 @@ TEST_F(WebMParserTest, ReservedSizes) { for (size_t i = 0; i < arraysize(kBuffers); i++) { int id; int64_t element_size; - int buffer_size = 2 + i; + int buffer_size = 2 + static_cast(i); EXPECT_EQ(buffer_size, WebMParseElementHeader(kBuffers[i], buffer_size, &id, &element_size)); EXPECT_EQ(id, 0xA3); diff --git a/packager/media/formats/webm/webm_tracks_parser_unittest.cc b/packager/media/formats/webm/webm_tracks_parser_unittest.cc index 006b9d55b4..b9b873a9b4 100644 --- a/packager/media/formats/webm/webm_tracks_parser_unittest.cc +++ b/packager/media/formats/webm/webm_tracks_parser_unittest.cc @@ -29,15 +29,15 @@ class WebMTracksParserTest : public testing::Test { protected: void VerifyTextTrackInfo(const uint8_t* buffer, - int buffer_size, + size_t buffer_size, TextKind text_kind, const std::string& name, const std::string& language) { std::unique_ptr parser(new WebMTracksParser(false)); - int result = parser->Parse(buffer, buffer_size); + int result = parser->Parse(buffer, static_cast(buffer_size)); EXPECT_GT(result, 0); - EXPECT_EQ(result, buffer_size); + EXPECT_EQ(result, static_cast(buffer_size)); const WebMTracksParser::TextTracks& text_tracks = parser->text_tracks(); EXPECT_EQ(text_tracks.size(), WebMTracksParser::TextTracks::size_type(1)); @@ -103,7 +103,7 @@ TEST_F(WebMTracksParserTest, IgnoringTextTracks) { const std::vector buf = tb.Finish(); std::unique_ptr parser(new WebMTracksParser(true)); - int result = parser->Parse(&buf[0], buf.size()); + int result = parser->Parse(&buf[0], static_cast(buf.size())); EXPECT_GT(result, 0); EXPECT_EQ(result, static_cast(buf.size())); @@ -116,7 +116,7 @@ TEST_F(WebMTracksParserTest, IgnoringTextTracks) { // Test again w/o ignoring the test tracks. parser.reset(new WebMTracksParser(false)); - result = parser->Parse(&buf[0], buf.size()); + result = parser->Parse(&buf[0], static_cast(buf.size())); EXPECT_GT(result, 0); EXPECT_EQ(parser->ignored_tracks().size(), 0u); @@ -135,7 +135,7 @@ TEST_F(WebMTracksParserTest, AudioVideoDefaultDurationUnset) { const std::vector buf = tb.Finish(); std::unique_ptr parser(new WebMTracksParser(true)); - int result = parser->Parse(&buf[0], buf.size()); + int result = parser->Parse(&buf[0], static_cast(buf.size())); EXPECT_LE(0, result); EXPECT_EQ(static_cast(buf.size()), result); @@ -166,7 +166,7 @@ TEST_F(WebMTracksParserTest, AudioVideoDefaultDurationSet) { const std::vector buf = tb.Finish(); std::unique_ptr parser(new WebMTracksParser(true)); - int result = parser->Parse(&buf[0], buf.size()); + int result = parser->Parse(&buf[0], static_cast(buf.size())); EXPECT_LE(0, result); EXPECT_EQ(static_cast(buf.size()), result); @@ -187,7 +187,7 @@ TEST_F(WebMTracksParserTest, InvalidZeroDefaultDurationSet) { std::unique_ptr parser(new WebMTracksParser(true)); - EXPECT_EQ(-1, parser->Parse(&buf[0], buf.size())); + EXPECT_EQ(-1, parser->Parse(&buf[0], static_cast(buf.size()))); } TEST_F(WebMTracksParserTest, HighTrackUID) { @@ -198,7 +198,7 @@ TEST_F(WebMTracksParserTest, HighTrackUID) { const std::vector buf = tb.Finish(); std::unique_ptr parser(new WebMTracksParser(true)); - EXPECT_GT(parser->Parse(&buf[0], buf.size()),0); + EXPECT_GT(parser->Parse(&buf[0], static_cast(buf.size())), 0); } } // namespace media diff --git a/packager/media/formats/wvm/wvm_media_parser.cc b/packager/media/formats/wvm/wvm_media_parser.cc index 2a38e6790e..654e821f1e 100644 --- a/packager/media/formats/wvm/wvm_media_parser.cc +++ b/packager/media/formats/wvm/wvm_media_parser.cc @@ -48,7 +48,7 @@ const uint32_t kPesStreamIdVideo = 0xE0; const uint32_t kPesStreamIdAudioMask = 0xE0; const uint32_t kPesStreamIdAudio = 0xC0; const uint32_t kVersion4 = 4; -const int kAdtsHeaderMinSize = 7; +const size_t kAdtsHeaderMinSize = 7; const uint8_t kAacSampleSizeBits = 16; // Applies to all video streams. 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) { - uint32_t num_bytes, prev_size; - num_bytes = prev_size = 0; + size_t num_bytes = 0; + size_t prev_size = 0; const uint8_t* read_ptr = buf; const uint8_t* end = read_ptr + size; @@ -208,7 +208,7 @@ bool WvmMediaParser::Parse(const uint8_t* buf, int size) { parse_state_ = SystemHeaderSkip; break; case PackHeaderStuffingSkip: - if ((end - read_ptr) >= (int32_t)skip_bytes_) { + if ((end - read_ptr) >= skip_bytes_) { read_ptr += skip_bytes_; skip_bytes_ = 0; parse_state_ = StartCode1; @@ -218,7 +218,7 @@ bool WvmMediaParser::Parse(const uint8_t* buf, int size) { } continue; case SystemHeaderSkip: - if ((end - read_ptr) >= (int32_t)skip_bytes_) { + if ((end - read_ptr) >= skip_bytes_) { read_ptr += skip_bytes_; skip_bytes_ = 0; parse_state_ = StartCode1; @@ -895,8 +895,8 @@ bool WvmMediaParser::Output(bool output_encrypted_sample) { } else if ((prev_pes_stream_id_ & kPesStreamIdAudioMask) == kPesStreamIdAudio) { // Set data on the audio stream. - int frame_size = mp2t::AdtsHeader::GetAdtsFrameSize(sample_data_.data(), - kAdtsHeaderMinSize); + int frame_size = static_cast(mp2t::AdtsHeader::GetAdtsFrameSize( + sample_data_.data(), kAdtsHeaderMinSize)); mp2t::AdtsHeader adts_header; const uint8_t* frame_ptr = sample_data_.data(); if (!adts_header.Parse(frame_ptr, frame_size)) { diff --git a/packager/media/formats/wvm/wvm_media_parser.h b/packager/media/formats/wvm/wvm_media_parser.h index ac8b927ba5..68d76ff955 100644 --- a/packager/media/formats/wvm/wvm_media_parser.h +++ b/packager/media/formats/wvm/wvm_media_parser.h @@ -228,17 +228,17 @@ class WvmMediaParser : public MediaParser { uint8_t current_program_id_; uint32_t 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_2_; uint8_t prev_pes_flags_1_; - uint8_t pes_header_data_bytes_; + size_t pes_header_data_bytes_; uint64_t timestamp_; uint64_t pts_; uint64_t dts_; uint8_t index_program_id_; scoped_refptr media_sample_; - uint32_t crypto_unit_start_pos_; + size_t crypto_unit_start_pos_; PrevSampleData prev_media_sample_data_; H264ByteToUnitStreamConverter byte_to_unit_stream_converter_; diff --git a/packager/media/formats/wvm/wvm_media_parser_unittest.cc b/packager/media/formats/wvm/wvm_media_parser_unittest.cc index f187449042..57d36c5947 100644 --- a/packager/media/formats/wvm/wvm_media_parser_unittest.cc +++ b/packager/media/formats/wvm/wvm_media_parser_unittest.cc @@ -151,7 +151,7 @@ class WvmMediaParserTest : public testing::Test { InitializeParser(); std::vector buffer = ReadTestDataFile(filename); - EXPECT_TRUE(parser_->Parse(buffer.data(), buffer.size())); + EXPECT_TRUE(parser_->Parse(buffer.data(), static_cast(buffer.size()))); } }; @@ -159,7 +159,7 @@ TEST_F(WvmMediaParserTest, ParseWvmWithoutKeySource) { key_source_.reset(); InitializeParser(); std::vector buffer = ReadTestDataFile(kWvmFile); - EXPECT_TRUE(parser_->Parse(buffer.data(), buffer.size())); + EXPECT_TRUE(parser_->Parse(buffer.data(), static_cast(buffer.size()))); EXPECT_EQ(kExpectedStreams, stream_map_.size()); EXPECT_EQ(kExpectedVideoFrameCount, video_frame_count_); EXPECT_EQ(kExpectedAudioFrameCount, audio_frame_count_); diff --git a/packager/media/test/packager_test.cc b/packager/media/test/packager_test.cc index 81bad2b5b3..0203447b50 100644 --- a/packager/media/test/packager_test.cc +++ b/packager/media/test/packager_test.cc @@ -440,7 +440,7 @@ TEST_P(PackagerTest, MP4MuxerMultiSegmentsUnencryptedVideo) { std::string segment_content; ASSERT_TRUE(base::ReadFileToString(segment_path, &segment_content)); EXPECT_TRUE(base::AppendToFile(output_path, segment_content.data(), - segment_content.size())); + static_cast(segment_content.size()))); ++segment_index; } diff --git a/packager/third_party/curl/curl.gyp b/packager/third_party/curl/curl.gyp index 7282451ff1..915f7e9354 100644 --- a/packager/third_party/curl/curl.gyp +++ b/packager/third_party/curl/curl.gyp @@ -94,6 +94,7 @@ 'defines': [ 'BUILDING_LIBCURL', ], + 'msvs_disabled_warnings': [ 4267, ], }], ], 'variables': {