Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(214)

Unified Diff: media/formats/mp4/box_reader.h

Issue 1499423004: Remove kint32max. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@kint9
Patch Set: rebase Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/capture/video/mac/video_capture_device_mac.mm ('k') | media/formats/mp4/box_reader.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/formats/mp4/box_reader.h
diff --git a/media/formats/mp4/box_reader.h b/media/formats/mp4/box_reader.h
index 957c28715436e42fd506c20004e3464fdcdea9dd..3fff1919f10530eb667b3bdaa5fdc4ac9713568d 100644
--- a/media/formats/mp4/box_reader.h
+++ b/media/formats/mp4/box_reader.h
@@ -5,6 +5,9 @@
#ifndef MEDIA_FORMATS_MP4_BOX_READER_H_
#define MEDIA_FORMATS_MP4_BOX_READER_H_
+#include <stdint.h>
+
+#include <limits>
#include <map>
#include <vector>
@@ -32,53 +35,55 @@ struct MEDIA_EXPORT Box {
class MEDIA_EXPORT BufferReader {
public:
- BufferReader(const uint8* buf, const int size) : buf_(buf), pos_(0) {
+ BufferReader(const uint8_t* buf, const int size) : buf_(buf), pos_(0) {
CHECK(buf);
- size_ = base::checked_cast<uint64>(size);
+ size_ = base::checked_cast<uint64_t>(size);
}
- bool HasBytes(uint64 count) {
+ bool HasBytes(uint64_t count) {
// As the size of a box is implementation limited to 2^31, fail if
// attempting to check for too many bytes.
- return (pos_ <= size_ && count < static_cast<uint64>(kint32max) &&
+ return (pos_ <= size_ &&
+ count <
+ static_cast<uint64_t>(std::numeric_limits<int32_t>::max()) &&
size_ - pos_ >= count);
}
// Read a value from the stream, perfoming endian correction, and advance the
// stream pointer.
- bool Read1(uint8* v) WARN_UNUSED_RESULT;
- bool Read2(uint16* v) WARN_UNUSED_RESULT;
- bool Read2s(int16* v) WARN_UNUSED_RESULT;
- bool Read4(uint32* v) WARN_UNUSED_RESULT;
- bool Read4s(int32* v) WARN_UNUSED_RESULT;
- bool Read8(uint64* v) WARN_UNUSED_RESULT;
- bool Read8s(int64* v) WARN_UNUSED_RESULT;
+ bool Read1(uint8_t* v) WARN_UNUSED_RESULT;
+ bool Read2(uint16_t* v) WARN_UNUSED_RESULT;
+ bool Read2s(int16_t* v) WARN_UNUSED_RESULT;
+ bool Read4(uint32_t* v) WARN_UNUSED_RESULT;
+ bool Read4s(int32_t* v) WARN_UNUSED_RESULT;
+ bool Read8(uint64_t* v) WARN_UNUSED_RESULT;
+ bool Read8s(int64_t* v) WARN_UNUSED_RESULT;
bool ReadFourCC(FourCC* v) WARN_UNUSED_RESULT;
- bool ReadVec(std::vector<uint8>* t, uint64 count) WARN_UNUSED_RESULT;
+ bool ReadVec(std::vector<uint8_t>* t, uint64_t count) WARN_UNUSED_RESULT;
// These variants read a 4-byte integer of the corresponding signedness and
// store it in the 8-byte return type.
- bool Read4Into8(uint64* v) WARN_UNUSED_RESULT;
- bool Read4sInto8s(int64* v) WARN_UNUSED_RESULT;
+ bool Read4Into8(uint64_t* v) WARN_UNUSED_RESULT;
+ bool Read4sInto8s(int64_t* v) WARN_UNUSED_RESULT;
// Advance the stream by this many bytes.
- bool SkipBytes(uint64 nbytes) WARN_UNUSED_RESULT;
+ bool SkipBytes(uint64_t nbytes) WARN_UNUSED_RESULT;
- const uint8* data() const { return buf_; }
+ const uint8_t* data() const { return buf_; }
// This returns the size of the box as specified in the box header. Initially
// it is the buffer size until the header is read. Note that the size
// specified in the box header may be different than the number of bytes
// actually provided.
- uint64 size() const { return size_; }
- uint64 pos() const { return pos_; }
+ uint64_t size() const { return size_; }
+ uint64_t pos() const { return pos_; }
protected:
- const uint8* buf_;
- uint64 size_;
- uint64 pos_;
+ const uint8_t* buf_;
+ uint64_t size_;
+ uint64_t pos_;
template<typename T> bool Read(T* t) WARN_UNUSED_RESULT;
};
@@ -93,7 +98,7 @@ class MEDIA_EXPORT BoxReader : public BufferReader {
// values are only expected when insufficient data is available.
//
// |buf| is retained but not owned, and must outlive the BoxReader instance.
- static BoxReader* ReadTopLevelBox(const uint8* buf,
+ static BoxReader* ReadTopLevelBox(const uint8_t* buf,
const int buf_size,
const scoped_refptr<MediaLog>& media_log,
bool* err);
@@ -104,7 +109,7 @@ class MEDIA_EXPORT BoxReader : public BufferReader {
// true. The semantics of |*err| are the same as above.
//
// |buf| is not retained.
- static bool StartTopLevelBox(const uint8* buf,
+ static bool StartTopLevelBox(const uint8_t* buf,
const int buf_size,
const scoped_refptr<MediaLog>& media_log,
FourCC* type,
@@ -116,7 +121,7 @@ class MEDIA_EXPORT BoxReader : public BufferReader {
// with any type of box -- it does not have to be IsValidTopLevelBox().
//
// |buf| is retained but not owned, and must outlive the BoxReader instance.
- static BoxReader* ReadConcatentatedBoxes(const uint8* buf,
+ static BoxReader* ReadConcatentatedBoxes(const uint8_t* buf,
const int buf_size);
// Returns true if |type| is recognized to be a top-level box, false
@@ -169,15 +174,15 @@ class MEDIA_EXPORT BoxReader : public BufferReader {
bool ReadFullBoxHeader() WARN_UNUSED_RESULT;
FourCC type() const { return type_; }
- uint8 version() const { return version_; }
- uint32 flags() const { return flags_; }
+ uint8_t version() const { return version_; }
+ uint32_t flags() const { return flags_; }
const scoped_refptr<MediaLog>& media_log() const { return media_log_; }
private:
// Create a BoxReader from |buf|. |is_EOS| should be true if |buf| is
// complete stream (i.e. no additional data is expected to be appended).
- BoxReader(const uint8* buf,
+ BoxReader(const uint8_t* buf,
const int size,
const scoped_refptr<MediaLog>& media_log,
bool is_EOS);
@@ -200,8 +205,8 @@ class MEDIA_EXPORT BoxReader : public BufferReader {
scoped_refptr<MediaLog> media_log_;
FourCC type_;
- uint8 version_;
- uint32 flags_;
+ uint8_t version_;
+ uint32_t flags_;
typedef std::multimap<FourCC, BoxReader> ChildMap;
« no previous file with comments | « media/capture/video/mac/video_capture_device_mac.mm ('k') | media/formats/mp4/box_reader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698