| 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 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 void* I420Buffer::native_handle() const { | 180 void* I420Buffer::native_handle() const { |
| 181 return nullptr; | 181 return nullptr; |
| 182 } | 182 } |
| 183 | 183 |
| 184 rtc::scoped_refptr<VideoFrameBuffer> I420Buffer::NativeToI420Buffer() { | 184 rtc::scoped_refptr<VideoFrameBuffer> I420Buffer::NativeToI420Buffer() { |
| 185 RTC_NOTREACHED(); | 185 RTC_NOTREACHED(); |
| 186 return nullptr; | 186 return nullptr; |
| 187 } | 187 } |
| 188 | 188 |
| 189 rtc::scoped_refptr<I420Buffer> I420Buffer::Copy( | 189 rtc::scoped_refptr<I420Buffer> I420Buffer::Copy( |
| 190 const rtc::scoped_refptr<VideoFrameBuffer>& buffer) { | 190 const rtc::scoped_refptr<VideoFrameBuffer>& source) { |
| 191 int width = buffer->width(); | 191 int width = source->width(); |
| 192 int height = buffer->height(); | 192 int height = source->height(); |
| 193 rtc::scoped_refptr<I420Buffer> copy = | 193 rtc::scoped_refptr<I420Buffer> target = |
| 194 new rtc::RefCountedObject<I420Buffer>(width, height); | 194 new rtc::RefCountedObject<I420Buffer>(width, height); |
| 195 RTC_CHECK(libyuv::I420Copy(buffer->DataY(), buffer->StrideY(), | 195 RTC_CHECK(libyuv::I420Copy(source->DataY(), source->StrideY(), |
| 196 buffer->DataU(), buffer->StrideU(), | 196 source->DataU(), source->StrideU(), |
| 197 buffer->DataV(), buffer->StrideV(), | 197 source->DataV(), source->StrideV(), |
| 198 copy->MutableDataY(), copy->StrideY(), | 198 target->MutableDataY(), target->StrideY(), |
| 199 copy->MutableDataU(), copy->StrideU(), | 199 target->MutableDataU(), target->StrideU(), |
| 200 copy->MutableDataV(), copy->StrideV(), | 200 target->MutableDataV(), target->StrideV(), |
| 201 width, height) == 0); | 201 width, height) == 0); |
| 202 | 202 |
| 203 return copy; | 203 return target; |
| 204 } | 204 } |
| 205 | 205 |
| 206 void I420Buffer::SetToBlack() { | 206 void I420Buffer::SetToBlack() { |
| 207 RTC_CHECK(libyuv::I420Rect(MutableDataY(), StrideY(), | 207 RTC_CHECK(libyuv::I420Rect(MutableDataY(), StrideY(), |
| 208 MutableDataU(), StrideU(), | 208 MutableDataU(), StrideU(), |
| 209 MutableDataV(), StrideV(), | 209 MutableDataV(), StrideV(), |
| 210 0, 0, width(), height(), | 210 0, 0, width(), height(), |
| 211 0, 128, 128) == 0); | 211 0, 128, 128) == 0); |
| 212 } | 212 } |
| 213 | 213 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 CropAndScaleFrom( | 258 CropAndScaleFrom( |
| 259 src, | 259 src, |
| 260 (src->width() - crop_width) / 2, (src->height() - crop_height) / 2, | 260 (src->width() - crop_width) / 2, (src->height() - crop_height) / 2, |
| 261 crop_width, crop_height); | 261 crop_width, crop_height); |
| 262 } | 262 } |
| 263 | 263 |
| 264 void I420Buffer::ScaleFrom(const rtc::scoped_refptr<VideoFrameBuffer>& src) { | 264 void I420Buffer::ScaleFrom(const rtc::scoped_refptr<VideoFrameBuffer>& src) { |
| 265 CropAndScaleFrom(src, 0, 0, src->width(), src->height()); | 265 CropAndScaleFrom(src, 0, 0, src->width(), src->height()); |
| 266 } | 266 } |
| 267 | 267 |
| 268 rtc::scoped_refptr<I420Buffer> I420Buffer::CopyKeepStride( |
| 269 const rtc::scoped_refptr<VideoFrameBuffer>& source) { |
| 270 int width = source->width(); |
| 271 int height = source->height(); |
| 272 int stride_y = source->StrideY(); |
| 273 int stride_u = source->StrideU(); |
| 274 int stride_v = source->StrideV(); |
| 275 rtc::scoped_refptr<I420Buffer> target = |
| 276 new rtc::RefCountedObject<I420Buffer>( |
| 277 width, height, stride_y, stride_u, stride_v); |
| 278 RTC_CHECK(libyuv::I420Copy(source->DataY(), stride_y, |
| 279 source->DataU(), stride_u, |
| 280 source->DataV(), stride_v, |
| 281 target->MutableDataY(), stride_y, |
| 282 target->MutableDataU(), stride_u, |
| 283 target->MutableDataV(), stride_v, |
| 284 width, height) == 0); |
| 285 |
| 286 return target; |
| 287 } |
| 288 |
| 268 NativeHandleBuffer::NativeHandleBuffer(void* native_handle, | 289 NativeHandleBuffer::NativeHandleBuffer(void* native_handle, |
| 269 int width, | 290 int width, |
| 270 int height) | 291 int height) |
| 271 : native_handle_(native_handle), width_(width), height_(height) { | 292 : native_handle_(native_handle), width_(width), height_(height) { |
| 272 RTC_DCHECK(native_handle != nullptr); | 293 RTC_DCHECK(native_handle != nullptr); |
| 273 RTC_DCHECK_GT(width, 0); | 294 RTC_DCHECK_GT(width, 0); |
| 274 RTC_DCHECK_GT(height, 0); | 295 RTC_DCHECK_GT(height, 0); |
| 275 } | 296 } |
| 276 | 297 |
| 277 int NativeHandleBuffer::width() const { | 298 int NativeHandleBuffer::width() const { |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 367 void* WrappedI420Buffer::native_handle() const { | 388 void* WrappedI420Buffer::native_handle() const { |
| 368 return nullptr; | 389 return nullptr; |
| 369 } | 390 } |
| 370 | 391 |
| 371 rtc::scoped_refptr<VideoFrameBuffer> WrappedI420Buffer::NativeToI420Buffer() { | 392 rtc::scoped_refptr<VideoFrameBuffer> WrappedI420Buffer::NativeToI420Buffer() { |
| 372 RTC_NOTREACHED(); | 393 RTC_NOTREACHED(); |
| 373 return nullptr; | 394 return nullptr; |
| 374 } | 395 } |
| 375 | 396 |
| 376 } // namespace webrtc | 397 } // namespace webrtc |
| OLD | NEW |