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

Side by Side Diff: media/base/decoder_buffer.cc

Issue 1534273002: Switch to standard integer types in media/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: more 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/base/decoder_buffer.h" 5 #include "media/base/decoder_buffer.h"
6 6
7
8 namespace media { 7 namespace media {
9 8
10 // Allocates a block of memory which is padded for use with the SIMD 9 // Allocates a block of memory which is padded for use with the SIMD
11 // optimizations used by FFmpeg. 10 // optimizations used by FFmpeg.
12 static uint8* AllocateFFmpegSafeBlock(int size) { 11 static uint8_t* AllocateFFmpegSafeBlock(int size) {
13 uint8* const block = reinterpret_cast<uint8*>(base::AlignedAlloc( 12 uint8_t* const block = reinterpret_cast<uint8_t*>(base::AlignedAlloc(
14 size + DecoderBuffer::kPaddingSize, DecoderBuffer::kAlignmentSize)); 13 size + DecoderBuffer::kPaddingSize, DecoderBuffer::kAlignmentSize));
15 memset(block + size, 0, DecoderBuffer::kPaddingSize); 14 memset(block + size, 0, DecoderBuffer::kPaddingSize);
16 return block; 15 return block;
17 } 16 }
18 17
19 DecoderBuffer::DecoderBuffer(int size) 18 DecoderBuffer::DecoderBuffer(int size)
20 : size_(size), 19 : size_(size),
21 side_data_size_(0), 20 side_data_size_(0),
22 is_key_frame_(false) { 21 is_key_frame_(false) {
23 Initialize(); 22 Initialize();
24 } 23 }
25 24
26 DecoderBuffer::DecoderBuffer(const uint8* data, 25 DecoderBuffer::DecoderBuffer(const uint8_t* data,
27 int size, 26 int size,
28 const uint8* side_data, 27 const uint8_t* side_data,
29 int side_data_size) 28 int side_data_size)
30 : size_(size), 29 : size_(size), side_data_size_(side_data_size), is_key_frame_(false) {
31 side_data_size_(side_data_size),
32 is_key_frame_(false) {
33 if (!data) { 30 if (!data) {
34 CHECK_EQ(size_, 0); 31 CHECK_EQ(size_, 0);
35 CHECK(!side_data); 32 CHECK(!side_data);
36 return; 33 return;
37 } 34 }
38 35
39 Initialize(); 36 Initialize();
40 37
41 DCHECK_GE(size_, 0); 38 DCHECK_GE(size_, 0);
42 memcpy(data_.get(), data, size_); 39 memcpy(data_.get(), data, size_);
(...skipping 11 matching lines...) Expand all
54 51
55 void DecoderBuffer::Initialize() { 52 void DecoderBuffer::Initialize() {
56 CHECK_GE(size_, 0); 53 CHECK_GE(size_, 0);
57 data_.reset(AllocateFFmpegSafeBlock(size_)); 54 data_.reset(AllocateFFmpegSafeBlock(size_));
58 if (side_data_size_ > 0) 55 if (side_data_size_ > 0)
59 side_data_.reset(AllocateFFmpegSafeBlock(side_data_size_)); 56 side_data_.reset(AllocateFFmpegSafeBlock(side_data_size_));
60 splice_timestamp_ = kNoTimestamp(); 57 splice_timestamp_ = kNoTimestamp();
61 } 58 }
62 59
63 // static 60 // static
64 scoped_refptr<DecoderBuffer> DecoderBuffer::CopyFrom(const uint8* data, 61 scoped_refptr<DecoderBuffer> DecoderBuffer::CopyFrom(const uint8_t* data,
65 int data_size) { 62 int data_size) {
66 // If you hit this CHECK you likely have a bug in a demuxer. Go fix it. 63 // If you hit this CHECK you likely have a bug in a demuxer. Go fix it.
67 CHECK(data); 64 CHECK(data);
68 return make_scoped_refptr(new DecoderBuffer(data, data_size, NULL, 0)); 65 return make_scoped_refptr(new DecoderBuffer(data, data_size, NULL, 0));
69 } 66 }
70 67
71 // static 68 // static
72 scoped_refptr<DecoderBuffer> DecoderBuffer::CopyFrom(const uint8* data, 69 scoped_refptr<DecoderBuffer> DecoderBuffer::CopyFrom(const uint8_t* data,
73 int data_size, 70 int data_size,
74 const uint8* side_data, 71 const uint8_t* side_data,
75 int side_data_size) { 72 int side_data_size) {
76 // If you hit this CHECK you likely have a bug in a demuxer. Go fix it. 73 // If you hit this CHECK you likely have a bug in a demuxer. Go fix it.
77 CHECK(data); 74 CHECK(data);
78 CHECK(side_data); 75 CHECK(side_data);
79 return make_scoped_refptr(new DecoderBuffer(data, data_size, 76 return make_scoped_refptr(new DecoderBuffer(data, data_size,
80 side_data, side_data_size)); 77 side_data, side_data_size));
81 } 78 }
82 79
83 // static 80 // static
84 scoped_refptr<DecoderBuffer> DecoderBuffer::CreateEOSBuffer() { 81 scoped_refptr<DecoderBuffer> DecoderBuffer::CreateEOSBuffer() {
(...skipping 19 matching lines...) Expand all
104 s << " decrypt:" << (*decrypt_config_); 101 s << " decrypt:" << (*decrypt_config_);
105 102
106 return s.str(); 103 return s.str();
107 } 104 }
108 105
109 void DecoderBuffer::set_timestamp(base::TimeDelta timestamp) { 106 void DecoderBuffer::set_timestamp(base::TimeDelta timestamp) {
110 DCHECK(!end_of_stream()); 107 DCHECK(!end_of_stream());
111 timestamp_ = timestamp; 108 timestamp_ = timestamp;
112 } 109 }
113 110
114 void DecoderBuffer::CopySideDataFrom(const uint8* side_data, 111 void DecoderBuffer::CopySideDataFrom(const uint8_t* side_data,
115 int side_data_size) { 112 int side_data_size) {
116 if (side_data_size > 0) { 113 if (side_data_size > 0) {
117 side_data_size_ = side_data_size; 114 side_data_size_ = side_data_size;
118 side_data_.reset(AllocateFFmpegSafeBlock(side_data_size_)); 115 side_data_.reset(AllocateFFmpegSafeBlock(side_data_size_));
119 memcpy(side_data_.get(), side_data, side_data_size_); 116 memcpy(side_data_.get(), side_data, side_data_size_);
120 } else { 117 } else {
121 side_data_.reset(); 118 side_data_.reset();
122 side_data_size_ = 0; 119 side_data_size_ = 0;
123 } 120 }
124 } 121 }
125 122
126 } // namespace media 123 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698