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 | 10 |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 void* I420Buffer::native_handle() const { | 193 void* I420Buffer::native_handle() const { |
194 return nullptr; | 194 return nullptr; |
195 } | 195 } |
196 | 196 |
197 rtc::scoped_refptr<VideoFrameBuffer> I420Buffer::NativeToI420Buffer() { | 197 rtc::scoped_refptr<VideoFrameBuffer> I420Buffer::NativeToI420Buffer() { |
198 RTC_NOTREACHED(); | 198 RTC_NOTREACHED(); |
199 return nullptr; | 199 return nullptr; |
200 } | 200 } |
201 | 201 |
202 rtc::scoped_refptr<I420Buffer> I420Buffer::Copy( | 202 rtc::scoped_refptr<I420Buffer> I420Buffer::Copy( |
203 const rtc::scoped_refptr<VideoFrameBuffer>& source) { | 203 const rtc::scoped_const_refptr<VideoFrameBuffer>& source) { |
204 int width = source->width(); | 204 int width = source->width(); |
205 int height = source->height(); | 205 int height = source->height(); |
206 rtc::scoped_refptr<I420Buffer> target = I420Buffer::Create(width, height); | 206 rtc::scoped_refptr<I420Buffer> target = I420Buffer::Create(width, height); |
207 RTC_CHECK(libyuv::I420Copy(source->DataY(), source->StrideY(), | 207 RTC_CHECK(libyuv::I420Copy(source->DataY(), source->StrideY(), |
208 source->DataU(), source->StrideU(), | 208 source->DataU(), source->StrideU(), |
209 source->DataV(), source->StrideV(), | 209 source->DataV(), source->StrideV(), |
210 target->MutableDataY(), target->StrideY(), | 210 target->MutableDataY(), target->StrideY(), |
211 target->MutableDataU(), target->StrideU(), | 211 target->MutableDataU(), target->StrideU(), |
212 target->MutableDataV(), target->StrideV(), | 212 target->MutableDataV(), target->StrideV(), |
213 width, height) == 0); | 213 width, height) == 0); |
214 | 214 |
215 return target; | 215 return target; |
216 } | 216 } |
217 | 217 |
218 void I420Buffer::SetToBlack() { | 218 void I420Buffer::SetToBlack() { |
219 RTC_CHECK(libyuv::I420Rect(MutableDataY(), StrideY(), | 219 RTC_CHECK(libyuv::I420Rect(MutableDataY(), StrideY(), |
220 MutableDataU(), StrideU(), | 220 MutableDataU(), StrideU(), |
221 MutableDataV(), StrideV(), | 221 MutableDataV(), StrideV(), |
222 0, 0, width(), height(), | 222 0, 0, width(), height(), |
223 0, 128, 128) == 0); | 223 0, 128, 128) == 0); |
224 } | 224 } |
225 | 225 |
226 void I420Buffer::CropAndScaleFrom( | 226 void I420Buffer::CropAndScaleFrom( |
227 const rtc::scoped_refptr<VideoFrameBuffer>& src, | 227 const rtc::scoped_const_refptr<VideoFrameBuffer>& src, |
228 int offset_x, | 228 int offset_x, |
229 int offset_y, | 229 int offset_y, |
230 int crop_width, | 230 int crop_width, |
231 int crop_height) { | 231 int crop_height) { |
232 RTC_CHECK_LE(crop_width, src->width()); | 232 RTC_CHECK_LE(crop_width, src->width()); |
233 RTC_CHECK_LE(crop_height, src->height()); | 233 RTC_CHECK_LE(crop_height, src->height()); |
234 RTC_CHECK_LE(crop_width + offset_x, src->width()); | 234 RTC_CHECK_LE(crop_width + offset_x, src->width()); |
235 RTC_CHECK_LE(crop_height + offset_y, src->height()); | 235 RTC_CHECK_LE(crop_height + offset_y, src->height()); |
236 RTC_CHECK_GE(offset_x, 0); | 236 RTC_CHECK_GE(offset_x, 0); |
237 RTC_CHECK_GE(offset_y, 0); | 237 RTC_CHECK_GE(offset_y, 0); |
(...skipping 16 matching lines...) Expand all Loading... |
254 crop_width, crop_height, | 254 crop_width, crop_height, |
255 MutableDataY(), StrideY(), | 255 MutableDataY(), StrideY(), |
256 MutableDataU(), StrideU(), | 256 MutableDataU(), StrideU(), |
257 MutableDataV(), StrideV(), | 257 MutableDataV(), StrideV(), |
258 width(), height(), libyuv::kFilterBox); | 258 width(), height(), libyuv::kFilterBox); |
259 | 259 |
260 RTC_DCHECK_EQ(res, 0); | 260 RTC_DCHECK_EQ(res, 0); |
261 } | 261 } |
262 | 262 |
263 void I420Buffer::CropAndScaleFrom( | 263 void I420Buffer::CropAndScaleFrom( |
264 const rtc::scoped_refptr<VideoFrameBuffer>& src) { | 264 const rtc::scoped_const_refptr<VideoFrameBuffer>& src) { |
265 const int crop_width = | 265 const int crop_width = |
266 std::min(src->width(), width() * src->height() / height()); | 266 std::min(src->width(), width() * src->height() / height()); |
267 const int crop_height = | 267 const int crop_height = |
268 std::min(src->height(), height() * src->width() / width()); | 268 std::min(src->height(), height() * src->width() / width()); |
269 | 269 |
270 CropAndScaleFrom( | 270 CropAndScaleFrom( |
271 src, | 271 src, |
272 (src->width() - crop_width) / 2, (src->height() - crop_height) / 2, | 272 (src->width() - crop_width) / 2, (src->height() - crop_height) / 2, |
273 crop_width, crop_height); | 273 crop_width, crop_height); |
274 } | 274 } |
275 | 275 |
276 void I420Buffer::ScaleFrom(const rtc::scoped_refptr<VideoFrameBuffer>& src) { | 276 void I420Buffer::ScaleFrom( |
| 277 const rtc::scoped_const_refptr<VideoFrameBuffer>& src) { |
277 CropAndScaleFrom(src, 0, 0, src->width(), src->height()); | 278 CropAndScaleFrom(src, 0, 0, src->width(), src->height()); |
278 } | 279 } |
279 | 280 |
280 rtc::scoped_refptr<I420Buffer> I420Buffer::CopyKeepStride( | 281 rtc::scoped_refptr<I420Buffer> I420Buffer::CopyKeepStride( |
281 const rtc::scoped_refptr<VideoFrameBuffer>& source) { | 282 const rtc::scoped_const_refptr<VideoFrameBuffer>& source) { |
282 int width = source->width(); | 283 int width = source->width(); |
283 int height = source->height(); | 284 int height = source->height(); |
284 int stride_y = source->StrideY(); | 285 int stride_y = source->StrideY(); |
285 int stride_u = source->StrideU(); | 286 int stride_u = source->StrideU(); |
286 int stride_v = source->StrideV(); | 287 int stride_v = source->StrideV(); |
287 rtc::scoped_refptr<I420Buffer> target = | 288 rtc::scoped_refptr<I420Buffer> target = |
288 I420Buffer::Create(width, height, stride_y, stride_u, stride_v); | 289 I420Buffer::Create(width, height, stride_y, stride_u, stride_v); |
289 RTC_CHECK(libyuv::I420Copy(source->DataY(), stride_y, | 290 RTC_CHECK(libyuv::I420Copy(source->DataY(), stride_y, |
290 source->DataU(), stride_u, | 291 source->DataU(), stride_u, |
291 source->DataV(), stride_v, | 292 source->DataV(), stride_v, |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 void* WrappedI420Buffer::native_handle() const { | 400 void* WrappedI420Buffer::native_handle() const { |
400 return nullptr; | 401 return nullptr; |
401 } | 402 } |
402 | 403 |
403 rtc::scoped_refptr<VideoFrameBuffer> WrappedI420Buffer::NativeToI420Buffer() { | 404 rtc::scoped_refptr<VideoFrameBuffer> WrappedI420Buffer::NativeToI420Buffer() { |
404 RTC_NOTREACHED(); | 405 RTC_NOTREACHED(); |
405 return nullptr; | 406 return nullptr; |
406 } | 407 } |
407 | 408 |
408 } // namespace webrtc | 409 } // namespace webrtc |
OLD | NEW |