OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 #include "webrtc/api/video/i420_buffer.h" | 10 #include "webrtc/api/video/i420_buffer.h" |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 static_cast<libyuv::RotationMode>(rotation))); | 129 static_cast<libyuv::RotationMode>(rotation))); |
130 | 130 |
131 return buffer; | 131 return buffer; |
132 } | 132 } |
133 | 133 |
134 void I420Buffer::InitializeData() { | 134 void I420Buffer::InitializeData() { |
135 memset(data_.get(), 0, | 135 memset(data_.get(), 0, |
136 I420DataSize(height_, stride_y_, stride_u_, stride_v_)); | 136 I420DataSize(height_, stride_y_, stride_u_, stride_v_)); |
137 } | 137 } |
138 | 138 |
| 139 VideoFrameBuffer::Type I420Buffer::type() const { |
| 140 return Type::kI420; |
| 141 } |
| 142 |
139 int I420Buffer::width() const { | 143 int I420Buffer::width() const { |
140 return width_; | 144 return width_; |
141 } | 145 } |
142 | 146 |
143 int I420Buffer::height() const { | 147 int I420Buffer::height() const { |
144 return height_; | 148 return height_; |
145 } | 149 } |
146 | 150 |
147 const uint8_t* I420Buffer::DataY() const { | 151 const uint8_t* I420Buffer::DataY() const { |
148 return data_.get(); | 152 return data_.get(); |
149 } | 153 } |
150 const uint8_t* I420Buffer::DataU() const { | 154 const uint8_t* I420Buffer::DataU() const { |
151 return data_.get() + stride_y_ * height_; | 155 return data_.get() + stride_y_ * height_; |
152 } | 156 } |
153 const uint8_t* I420Buffer::DataV() const { | 157 const uint8_t* I420Buffer::DataV() const { |
154 return data_.get() + stride_y_ * height_ + stride_u_ * ((height_ + 1) / 2); | 158 return data_.get() + stride_y_ * height_ + stride_u_ * ((height_ + 1) / 2); |
155 } | 159 } |
156 | 160 |
157 int I420Buffer::StrideY() const { | 161 int I420Buffer::StrideY() const { |
158 return stride_y_; | 162 return stride_y_; |
159 } | 163 } |
160 int I420Buffer::StrideU() const { | 164 int I420Buffer::StrideU() const { |
161 return stride_u_; | 165 return stride_u_; |
162 } | 166 } |
163 int I420Buffer::StrideV() const { | 167 int I420Buffer::StrideV() const { |
164 return stride_v_; | 168 return stride_v_; |
165 } | 169 } |
166 | 170 |
167 void* I420Buffer::native_handle() const { | |
168 return nullptr; | |
169 } | |
170 | |
171 rtc::scoped_refptr<VideoFrameBuffer> I420Buffer::NativeToI420Buffer() { | |
172 return this; | |
173 } | |
174 | |
175 uint8_t* I420Buffer::MutableDataY() { | 171 uint8_t* I420Buffer::MutableDataY() { |
176 return const_cast<uint8_t*>(DataY()); | 172 return const_cast<uint8_t*>(DataY()); |
177 } | 173 } |
178 uint8_t* I420Buffer::MutableDataU() { | 174 uint8_t* I420Buffer::MutableDataU() { |
179 return const_cast<uint8_t*>(DataU()); | 175 return const_cast<uint8_t*>(DataU()); |
180 } | 176 } |
181 uint8_t* I420Buffer::MutableDataV() { | 177 uint8_t* I420Buffer::MutableDataV() { |
182 return const_cast<uint8_t*>(DataV()); | 178 return const_cast<uint8_t*>(DataV()); |
183 } | 179 } |
184 | 180 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 src, | 235 src, |
240 (src.width() - crop_width) / 2, (src.height() - crop_height) / 2, | 236 (src.width() - crop_width) / 2, (src.height() - crop_height) / 2, |
241 crop_width, crop_height); | 237 crop_width, crop_height); |
242 } | 238 } |
243 | 239 |
244 void I420Buffer::ScaleFrom(const VideoFrameBuffer& src) { | 240 void I420Buffer::ScaleFrom(const VideoFrameBuffer& src) { |
245 CropAndScaleFrom(src, 0, 0, src.width(), src.height()); | 241 CropAndScaleFrom(src, 0, 0, src.width(), src.height()); |
246 } | 242 } |
247 | 243 |
248 } // namespace webrtc | 244 } // namespace webrtc |
OLD | NEW |