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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 CVPixelBufferRef pixel_buffer) { | 49 CVPixelBufferRef pixel_buffer) { |
50 RTC_DCHECK(pixel_buffer); | 50 RTC_DCHECK(pixel_buffer); |
51 RTC_DCHECK(CVPixelBufferGetPixelFormatType(pixel_buffer) == | 51 RTC_DCHECK(CVPixelBufferGetPixelFormatType(pixel_buffer) == |
52 kCVPixelFormatType_420YpCbCr8BiPlanarFullRange); | 52 kCVPixelFormatType_420YpCbCr8BiPlanarFullRange); |
53 size_t width = CVPixelBufferGetWidthOfPlane(pixel_buffer, 0); | 53 size_t width = CVPixelBufferGetWidthOfPlane(pixel_buffer, 0); |
54 size_t height = CVPixelBufferGetHeightOfPlane(pixel_buffer, 0); | 54 size_t height = CVPixelBufferGetHeightOfPlane(pixel_buffer, 0); |
55 // TODO(tkchin): Use a frame buffer pool. | 55 // TODO(tkchin): Use a frame buffer pool. |
56 rtc::scoped_refptr<webrtc::VideoFrameBuffer> buffer = | 56 rtc::scoped_refptr<webrtc::VideoFrameBuffer> buffer = |
57 new rtc::RefCountedObject<webrtc::I420Buffer>(width, height); | 57 new rtc::RefCountedObject<webrtc::I420Buffer>(width, height); |
58 CVPixelBufferLockBaseAddress(pixel_buffer, kCVPixelBufferLock_ReadOnly); | 58 CVPixelBufferLockBaseAddress(pixel_buffer, kCVPixelBufferLock_ReadOnly); |
59 const uint8* src_y = reinterpret_cast<const uint8*>( | 59 const uint8_t* src_y = reinterpret_cast<const uint8_t*>( |
60 CVPixelBufferGetBaseAddressOfPlane(pixel_buffer, 0)); | 60 CVPixelBufferGetBaseAddressOfPlane(pixel_buffer, 0)); |
61 int src_y_stride = CVPixelBufferGetBytesPerRowOfPlane(pixel_buffer, 0); | 61 int src_y_stride = CVPixelBufferGetBytesPerRowOfPlane(pixel_buffer, 0); |
62 const uint8* src_uv = reinterpret_cast<const uint8*>( | 62 const uint8_t* src_uv = reinterpret_cast<const uint8_t*>( |
63 CVPixelBufferGetBaseAddressOfPlane(pixel_buffer, 1)); | 63 CVPixelBufferGetBaseAddressOfPlane(pixel_buffer, 1)); |
64 int src_uv_stride = CVPixelBufferGetBytesPerRowOfPlane(pixel_buffer, 1); | 64 int src_uv_stride = CVPixelBufferGetBytesPerRowOfPlane(pixel_buffer, 1); |
65 int ret = libyuv::NV12ToI420( | 65 int ret = libyuv::NV12ToI420( |
66 src_y, src_y_stride, src_uv, src_uv_stride, | 66 src_y, src_y_stride, src_uv, src_uv_stride, |
67 buffer->MutableData(webrtc::kYPlane), buffer->stride(webrtc::kYPlane), | 67 buffer->MutableData(webrtc::kYPlane), buffer->stride(webrtc::kYPlane), |
68 buffer->MutableData(webrtc::kUPlane), buffer->stride(webrtc::kUPlane), | 68 buffer->MutableData(webrtc::kUPlane), buffer->stride(webrtc::kUPlane), |
69 buffer->MutableData(webrtc::kVPlane), buffer->stride(webrtc::kVPlane), | 69 buffer->MutableData(webrtc::kVPlane), buffer->stride(webrtc::kVPlane), |
70 width, height); | 70 width, height); |
71 CVPixelBufferUnlockBaseAddress(pixel_buffer, kCVPixelBufferLock_ReadOnly); | 71 CVPixelBufferUnlockBaseAddress(pixel_buffer, kCVPixelBufferLock_ReadOnly); |
72 if (ret) { | 72 if (ret) { |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 } | 262 } |
263 video_format_ = video_format; | 263 video_format_ = video_format; |
264 if (video_format_) { | 264 if (video_format_) { |
265 CFRetain(video_format_); | 265 CFRetain(video_format_); |
266 } | 266 } |
267 } | 267 } |
268 | 268 |
269 } // namespace webrtc | 269 } // namespace webrtc |
270 | 270 |
271 #endif // defined(WEBRTC_VIDEO_TOOLBOX_SUPPORTED) | 271 #endif // defined(WEBRTC_VIDEO_TOOLBOX_SUPPORTED) |
OLD | NEW |