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 |
11 #include "webrtc/common_video/include/video_frame_buffer.h" | 11 #include "webrtc/common_video/include/video_frame_buffer.h" |
12 | 12 |
13 #include "webrtc/base/bind.h" | |
14 #include "webrtc/base/checks.h" | 13 #include "webrtc/base/checks.h" |
| 14 #include "webrtc/base/keep_ref_until_done.h" |
15 | 15 |
16 // Aligning pointer to 64 bytes for improved performance, e.g. use SIMD. | 16 // Aligning pointer to 64 bytes for improved performance, e.g. use SIMD. |
17 static const int kBufferAlignment = 64; | 17 static const int kBufferAlignment = 64; |
18 | 18 |
19 namespace webrtc { | 19 namespace webrtc { |
20 namespace { | |
21 | |
22 // Used in rtc::Bind to keep a buffer alive until destructor is called. | |
23 static void NoLongerUsedCallback(rtc::scoped_refptr<VideoFrameBuffer> dummy) {} | |
24 | |
25 } // anonymous namespace | |
26 | 20 |
27 uint8_t* VideoFrameBuffer::MutableData(PlaneType type) { | 21 uint8_t* VideoFrameBuffer::MutableData(PlaneType type) { |
28 RTC_NOTREACHED(); | 22 RTC_NOTREACHED(); |
29 return nullptr; | 23 return nullptr; |
30 } | 24 } |
31 | 25 |
32 VideoFrameBuffer::~VideoFrameBuffer() {} | 26 VideoFrameBuffer::~VideoFrameBuffer() {} |
33 | 27 |
34 I420Buffer::I420Buffer(int width, int height) | 28 I420Buffer::I420Buffer(int width, int height) |
35 : I420Buffer(width, height, width, (width + 1) / 2, (width + 1) / 2) { | 29 : I420Buffer(width, height, width, (width + 1) / 2, (width + 1) / 2) { |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 buffer->stride(kYPlane) * offset_y + offset_x; | 225 buffer->stride(kYPlane) * offset_y + offset_x; |
232 const uint8_t* u_plane = buffer->data(kUPlane) + | 226 const uint8_t* u_plane = buffer->data(kUPlane) + |
233 buffer->stride(kUPlane) * uv_offset_y + uv_offset_x; | 227 buffer->stride(kUPlane) * uv_offset_y + uv_offset_x; |
234 const uint8_t* v_plane = buffer->data(kVPlane) + | 228 const uint8_t* v_plane = buffer->data(kVPlane) + |
235 buffer->stride(kVPlane) * uv_offset_y + uv_offset_x; | 229 buffer->stride(kVPlane) * uv_offset_y + uv_offset_x; |
236 return new rtc::RefCountedObject<WrappedI420Buffer>( | 230 return new rtc::RefCountedObject<WrappedI420Buffer>( |
237 cropped_width, cropped_height, | 231 cropped_width, cropped_height, |
238 y_plane, buffer->stride(kYPlane), | 232 y_plane, buffer->stride(kYPlane), |
239 u_plane, buffer->stride(kUPlane), | 233 u_plane, buffer->stride(kUPlane), |
240 v_plane, buffer->stride(kVPlane), | 234 v_plane, buffer->stride(kVPlane), |
241 rtc::Bind(&NoLongerUsedCallback, buffer)); | 235 rtc::KeepRefUntilDone(buffer)); |
242 } | 236 } |
243 | 237 |
244 } // namespace webrtc | 238 } // namespace webrtc |
OLD | NEW |