| Index: media/formats/webm/cluster_builder.cc
|
| diff --git a/media/formats/webm/cluster_builder.cc b/media/formats/webm/cluster_builder.cc
|
| index 1a3b358ef99c64989b658bdd67149710446556f6..b28b03b7ba355ae3818773558dd937f475d2e481 100644
|
| --- a/media/formats/webm/cluster_builder.cc
|
| +++ b/media/formats/webm/cluster_builder.cc
|
| @@ -10,34 +10,34 @@
|
|
|
| namespace media {
|
|
|
| -static const uint8 kClusterHeader[] = {
|
| - 0x1F, 0x43, 0xB6, 0x75, // CLUSTER ID
|
| - 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // cluster(size = 0)
|
| - 0xE7, // Timecode ID
|
| - 0x88, // timecode(size=8)
|
| - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // timecode value
|
| +static const uint8_t kClusterHeader[] = {
|
| + 0x1F, 0x43, 0xB6, 0x75, // CLUSTER ID
|
| + 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // cluster(size = 0)
|
| + 0xE7, // Timecode ID
|
| + 0x88, // timecode(size=8)
|
| + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // timecode value
|
| };
|
|
|
| -static const uint8 kSimpleBlockHeader[] = {
|
| - 0xA3, // SimpleBlock ID
|
| - 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // SimpleBlock(size = 0)
|
| +static const uint8_t kSimpleBlockHeader[] = {
|
| + 0xA3, // SimpleBlock ID
|
| + 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // SimpleBlock(size = 0)
|
| };
|
|
|
| -static const uint8 kBlockGroupHeader[] = {
|
| - 0xA0, // BlockGroup ID
|
| - 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // BlockGroup(size = 0)
|
| - 0x9B, // BlockDuration ID
|
| - 0x88, // BlockDuration(size = 8)
|
| - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // duration
|
| - 0xA1, // Block ID
|
| - 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Block(size = 0)
|
| +static const uint8_t kBlockGroupHeader[] = {
|
| + 0xA0, // BlockGroup ID
|
| + 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // BlockGroup(size = 0)
|
| + 0x9B, // BlockDuration ID
|
| + 0x88, // BlockDuration(size = 8)
|
| + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // duration
|
| + 0xA1, // Block ID
|
| + 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Block(size = 0)
|
| };
|
|
|
| -static const uint8 kBlockGroupHeaderWithoutBlockDuration[] = {
|
| - 0xA0, // BlockGroup ID
|
| - 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // BlockGroup(size = 0)
|
| - 0xA1, // Block ID
|
| - 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Block(size = 0)
|
| +static const uint8_t kBlockGroupHeaderWithoutBlockDuration[] = {
|
| + 0xA0, // BlockGroup ID
|
| + 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // BlockGroup(size = 0)
|
| + 0xA1, // Block ID
|
| + 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Block(size = 0)
|
| };
|
|
|
| enum {
|
| @@ -54,34 +54,37 @@ enum {
|
| kInitialBufferSize = 32768,
|
| };
|
|
|
| -Cluster::Cluster(scoped_ptr<uint8[]> data, int size)
|
| +Cluster::Cluster(scoped_ptr<uint8_t[]> data, int size)
|
| : data_(data.Pass()), size_(size) {}
|
| Cluster::~Cluster() {}
|
|
|
| ClusterBuilder::ClusterBuilder() { Reset(); }
|
| ClusterBuilder::~ClusterBuilder() {}
|
|
|
| -void ClusterBuilder::SetClusterTimecode(int64 cluster_timecode) {
|
| +void ClusterBuilder::SetClusterTimecode(int64_t cluster_timecode) {
|
| DCHECK_EQ(cluster_timecode_, -1);
|
|
|
| cluster_timecode_ = cluster_timecode;
|
|
|
| // Write the timecode into the header.
|
| - uint8* buf = buffer_.get() + kClusterTimecodeOffset;
|
| + uint8_t* buf = buffer_.get() + kClusterTimecodeOffset;
|
| for (int i = 7; i >= 0; --i) {
|
| buf[i] = cluster_timecode & 0xff;
|
| cluster_timecode >>= 8;
|
| }
|
| }
|
|
|
| -void ClusterBuilder::AddSimpleBlock(int track_num, int64 timecode, int flags,
|
| - const uint8* data, int size) {
|
| +void ClusterBuilder::AddSimpleBlock(int track_num,
|
| + int64_t timecode,
|
| + int flags,
|
| + const uint8_t* data,
|
| + int size) {
|
| int block_size = size + 4;
|
| int bytes_needed = sizeof(kSimpleBlockHeader) + block_size;
|
| if (bytes_needed > (buffer_size_ - bytes_used_))
|
| ExtendBuffer(bytes_needed);
|
|
|
| - uint8* buf = buffer_.get() + bytes_used_;
|
| + uint8_t* buf = buffer_.get() + bytes_used_;
|
| int block_offset = bytes_used_;
|
| memcpy(buf, kSimpleBlockHeader, sizeof(kSimpleBlockHeader));
|
| UpdateUInt64(block_offset + kSimpleBlockSizeOffset, block_size);
|
| @@ -92,24 +95,30 @@ void ClusterBuilder::AddSimpleBlock(int track_num, int64 timecode, int flags,
|
| bytes_used_ += bytes_needed;
|
| }
|
|
|
| -void ClusterBuilder::AddBlockGroup(int track_num, int64 timecode, int duration,
|
| - int flags, const uint8* data, int size) {
|
| +void ClusterBuilder::AddBlockGroup(int track_num,
|
| + int64_t timecode,
|
| + int duration,
|
| + int flags,
|
| + const uint8_t* data,
|
| + int size) {
|
| AddBlockGroupInternal(track_num, timecode, true, duration, flags, data, size);
|
| }
|
|
|
| void ClusterBuilder::AddBlockGroupWithoutBlockDuration(int track_num,
|
| - int64 timecode,
|
| + int64_t timecode,
|
| int flags,
|
| - const uint8* data,
|
| + const uint8_t* data,
|
| int size) {
|
| AddBlockGroupInternal(track_num, timecode, false, 0, flags, data, size);
|
| }
|
|
|
| -
|
| -void ClusterBuilder::AddBlockGroupInternal(int track_num, int64 timecode,
|
| +void ClusterBuilder::AddBlockGroupInternal(int track_num,
|
| + int64_t timecode,
|
| bool include_block_duration,
|
| - int duration, int flags,
|
| - const uint8* data, int size) {
|
| + int duration,
|
| + int flags,
|
| + const uint8_t* data,
|
| + int size) {
|
| int block_size = size + 4;
|
| int bytes_needed = block_size;
|
| if (include_block_duration) {
|
| @@ -123,7 +132,7 @@ void ClusterBuilder::AddBlockGroupInternal(int track_num, int64 timecode,
|
| if (bytes_needed > (buffer_size_ - bytes_used_))
|
| ExtendBuffer(bytes_needed);
|
|
|
| - uint8* buf = buffer_.get() + bytes_used_;
|
| + uint8_t* buf = buffer_.get() + bytes_used_;
|
| int block_group_offset = bytes_used_;
|
| if (include_block_duration) {
|
| memcpy(buf, kBlockGroupHeader, sizeof(kBlockGroupHeader));
|
| @@ -150,8 +159,12 @@ void ClusterBuilder::AddBlockGroupInternal(int track_num, int64 timecode,
|
| bytes_used_ += bytes_needed;
|
| }
|
|
|
| -void ClusterBuilder::WriteBlock(uint8* buf, int track_num, int64 timecode,
|
| - int flags, const uint8* data, int size) {
|
| +void ClusterBuilder::WriteBlock(uint8_t* buf,
|
| + int track_num,
|
| + int64_t timecode,
|
| + int flags,
|
| + const uint8_t* data,
|
| + int size) {
|
| DCHECK_GE(track_num, 0);
|
| DCHECK_LE(track_num, 126);
|
| DCHECK_GE(flags, 0);
|
| @@ -160,7 +173,7 @@ void ClusterBuilder::WriteBlock(uint8* buf, int track_num, int64 timecode,
|
| DCHECK_GT(size, 0);
|
| DCHECK_NE(cluster_timecode_, -1);
|
|
|
| - int64 timecode_delta = timecode - cluster_timecode_;
|
| + int64_t timecode_delta = timecode - cluster_timecode_;
|
| DCHECK_GE(timecode_delta, -32768);
|
| DCHECK_LE(timecode_delta, 32767);
|
|
|
| @@ -193,7 +206,7 @@ scoped_ptr<Cluster> ClusterBuilder::FinishWithUnknownSize() {
|
|
|
| void ClusterBuilder::Reset() {
|
| buffer_size_ = kInitialBufferSize;
|
| - buffer_.reset(new uint8[buffer_size_]);
|
| + buffer_.reset(new uint8_t[buffer_size_]);
|
| memcpy(buffer_.get(), kClusterHeader, sizeof(kClusterHeader));
|
| bytes_used_ = sizeof(kClusterHeader);
|
| cluster_timecode_ = -1;
|
| @@ -205,16 +218,16 @@ void ClusterBuilder::ExtendBuffer(int bytes_needed) {
|
| while ((new_buffer_size - bytes_used_) < bytes_needed)
|
| new_buffer_size *= 2;
|
|
|
| - scoped_ptr<uint8[]> new_buffer(new uint8[new_buffer_size]);
|
| + scoped_ptr<uint8_t[]> new_buffer(new uint8_t[new_buffer_size]);
|
|
|
| memcpy(new_buffer.get(), buffer_.get(), bytes_used_);
|
| buffer_.reset(new_buffer.release());
|
| buffer_size_ = new_buffer_size;
|
| }
|
|
|
| -void ClusterBuilder::UpdateUInt64(int offset, int64 value) {
|
| +void ClusterBuilder::UpdateUInt64(int offset, int64_t value) {
|
| DCHECK_LE(offset + 7, buffer_size_);
|
| - uint8* buf = buffer_.get() + offset;
|
| + uint8_t* buf = buffer_.get() + offset;
|
|
|
| // Fill the last 7 bytes of size field in big-endian order.
|
| for (int i = 7; i > 0; i--) {
|
|
|