From 22b08456865daeb72a7dccb48d1c4aed6773694f Mon Sep 17 00:00:00 2001 From: Tom Finegan Date: Thu, 7 Apr 2016 14:58:03 -0700 Subject: [PATCH] webmts: Fix implicit conversion warnings. Fix warnings exposed by addition of -Wshorten-64-32 compiler flag in webmts sources. Change-Id: I3104e7be2bf991d7e108b652857ecca8e82c5ef9 --- m2ts/vpxpes2ts.cc | 2 +- m2ts/vpxpes_parser.cc | 14 +++++++------- m2ts/vpxpes_parser.h | 2 +- m2ts/webm2pes.cc | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/m2ts/vpxpes2ts.cc b/m2ts/vpxpes2ts.cc index f9a886f..7684b56 100644 --- a/m2ts/vpxpes2ts.cc +++ b/m2ts/vpxpes2ts.cc @@ -145,7 +145,7 @@ bool VpxPes2Ts::ReceivePacket(const PacketDataBuffer& packet_data) { const int kTsHeaderSize = 4; const int kTsPayloadSize = 184; const int kTsPacketSize = kTsHeaderSize + kTsPayloadSize; - int bytes_to_packetize = packet_data.size(); + int bytes_to_packetize = static_cast(packet_data.size()); std::uint8_t continuity_counter = 0; std::size_t read_pos = 0; diff --git a/m2ts/vpxpes_parser.cc b/m2ts/vpxpes_parser.cc index 1263dcd..a97a302 100644 --- a/m2ts/vpxpes_parser.cc +++ b/m2ts/vpxpes_parser.cc @@ -47,7 +47,7 @@ bool VpxPesParser::Open(const std::string& pes_file) { pes_file_data_.push_back(static_cast(byte)); if (!feof(file.get()) || ferror(file.get()) || - pes_file_size_ != static_cast(pes_file_data_.size())) { + pes_file_size_ != pes_file_data_.size()) { return false; } @@ -95,7 +95,7 @@ bool VpxPesParser::ParsePesHeader(PesHeader* header) { if (!VerifyPacketStartCode()) return false; - int pos = read_pos_; + std::size_t pos = read_pos_; for (auto& a : header->start_code) { a = pes_file_data_[pos++]; } @@ -121,7 +121,7 @@ bool VpxPesParser::ParsePesOptionalHeader(PesOptionalHeader* header) { if (!header || parse_state_ != kParsePesOptionalHeader) return false; - int offset = read_pos_; + size_t offset = read_pos_; if (offset >= pes_file_size_) return false; @@ -142,7 +142,7 @@ bool VpxPesParser::ParsePesOptionalHeader(PesOptionalHeader* header) { if (header->remaining_size != kWebm2PesOptHeaderRemainingSize) return false; - int bytes_left = header->remaining_size; + size_t bytes_left = header->remaining_size; if (header->has_pts) { // Read PTS markers. Format: @@ -169,7 +169,7 @@ bool VpxPesParser::ParsePesOptionalHeader(PesOptionalHeader* header) { } // Validate stuffing byte(s). - for (int i = 0; i < bytes_left; ++i) { + for (size_t i = 0; i < bytes_left; ++i) { if (pes_file_data_[offset + i] != 0xff) return false; } @@ -210,7 +210,7 @@ bool VpxPesParser::ParseBcmvHeader(BcmvHeader* header) { } int VpxPesParser::BytesAvailable() const { - return pes_file_data_.size() - read_pos_; + return static_cast(pes_file_data_.size() - read_pos_); } bool VpxPesParser::ParseNextPacket(PesHeader* header, VpxFrame* frame) { @@ -236,4 +236,4 @@ bool VpxPesParser::ParseNextPacket(PesHeader* header, VpxFrame* frame) { return true; } -} // namespace libwebm \ No newline at end of file +} // namespace libwebm diff --git a/m2ts/vpxpes_parser.h b/m2ts/vpxpes_parser.h index 03bde03..35bfe38 100644 --- a/m2ts/vpxpes_parser.h +++ b/m2ts/vpxpes_parser.h @@ -137,7 +137,7 @@ class VpxPesParser { // header. bool ParseBcmvHeader(BcmvHeader* header); - std::int64_t pes_file_size_ = 0; + std::size_t pes_file_size_ = 0; PesFileData pes_file_data_; std::size_t read_pos_ = 0; ParseState parse_state_ = kParsePesHeader; diff --git a/m2ts/webm2pes.cc b/m2ts/webm2pes.cc index f6492b1..80f0efd 100644 --- a/m2ts/webm2pes.cc +++ b/m2ts/webm2pes.cc @@ -483,7 +483,7 @@ bool Webm2Pes::WritePesPacket(const mkvparser::Block::Frame& vpx_frame, } write_pts = false; - BCMVHeader bcmv_header(packet_payload_range.length); + BCMVHeader bcmv_header(static_cast(packet_payload_range.length)); if (bcmv_header.Write(&packet_data_) != true) { std::fprintf(stderr, "Webm2Pes: BCMV write failed.\n"); return false;