Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Side by Side Diff: webrtc/common_video/video_frame_buffer.cc

Issue 1822283002: New method I420Buffer::Copy. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Make Copy method static, and accept VideoFrameBuffer as input. Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/common_video/include/video_frame_buffer.h ('k') | webrtc/test/frame_utils.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/checks.h" 13 #include "webrtc/base/checks.h"
14 #include "webrtc/base/keep_ref_until_done.h" 14 #include "webrtc/base/keep_ref_until_done.h"
15 #include "libyuv/convert.h"
15 16
16 // Aligning pointer to 64 bytes for improved performance, e.g. use SIMD. 17 // Aligning pointer to 64 bytes for improved performance, e.g. use SIMD.
17 static const int kBufferAlignment = 64; 18 static const int kBufferAlignment = 64;
18 19
19 namespace webrtc { 20 namespace webrtc {
20 21
21 namespace { 22 namespace {
22 23
23 int I420DataSize(int height, int stride_y, int stride_u, int stride_v) { 24 int I420DataSize(int height, int stride_y, int stride_u, int stride_v) {
24 return stride_y * height + (stride_u + stride_v) * ((height + 1) / 2); 25 return stride_y * height + (stride_u + stride_v) * ((height + 1) / 2);
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 111
111 void* I420Buffer::native_handle() const { 112 void* I420Buffer::native_handle() const {
112 return nullptr; 113 return nullptr;
113 } 114 }
114 115
115 rtc::scoped_refptr<VideoFrameBuffer> I420Buffer::NativeToI420Buffer() { 116 rtc::scoped_refptr<VideoFrameBuffer> I420Buffer::NativeToI420Buffer() {
116 RTC_NOTREACHED(); 117 RTC_NOTREACHED();
117 return nullptr; 118 return nullptr;
118 } 119 }
119 120
121 rtc::scoped_refptr<I420Buffer> I420Buffer::Copy(
122 const rtc::scoped_refptr<VideoFrameBuffer>& buffer) {
123 int width = buffer->width();
124 int height = buffer->height();
125 rtc::scoped_refptr<I420Buffer> copy =
126 new rtc::RefCountedObject<I420Buffer>(width, height);
127 RTC_CHECK(0 ==
128 libyuv::I420Copy(buffer->data(kYPlane), buffer->stride(kYPlane),
pbos-webrtc 2016/03/29 14:00:37 pref RTC_CHECK_EQ or == 0 after
129 buffer->data(kUPlane), buffer->stride(kUPlane),
130 buffer->data(kVPlane), buffer->stride(kVPlane),
131 copy->MutableData(kYPlane), copy->stride(kYPlane),
132 copy->MutableData(kUPlane), copy->stride(kUPlane),
133 copy->MutableData(kVPlane), copy->stride(kVPlane),
134 width, height));
135
136 return copy;
137 }
138
120 NativeHandleBuffer::NativeHandleBuffer(void* native_handle, 139 NativeHandleBuffer::NativeHandleBuffer(void* native_handle,
121 int width, 140 int width,
122 int height) 141 int height)
123 : native_handle_(native_handle), width_(width), height_(height) { 142 : native_handle_(native_handle), width_(width), height_(height) {
124 RTC_DCHECK(native_handle != nullptr); 143 RTC_DCHECK(native_handle != nullptr);
125 RTC_DCHECK_GT(width, 0); 144 RTC_DCHECK_GT(width, 0);
126 RTC_DCHECK_GT(height, 0); 145 RTC_DCHECK_GT(height, 0);
127 } 146 }
128 147
129 int NativeHandleBuffer::width() const { 148 int NativeHandleBuffer::width() const {
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 buffer->stride(kVPlane) * uv_offset_y + uv_offset_x; 261 buffer->stride(kVPlane) * uv_offset_y + uv_offset_x;
243 return new rtc::RefCountedObject<WrappedI420Buffer>( 262 return new rtc::RefCountedObject<WrappedI420Buffer>(
244 cropped_width, cropped_height, 263 cropped_width, cropped_height,
245 y_plane, buffer->stride(kYPlane), 264 y_plane, buffer->stride(kYPlane),
246 u_plane, buffer->stride(kUPlane), 265 u_plane, buffer->stride(kUPlane),
247 v_plane, buffer->stride(kVPlane), 266 v_plane, buffer->stride(kVPlane),
248 rtc::KeepRefUntilDone(buffer)); 267 rtc::KeepRefUntilDone(buffer));
249 } 268 }
250 269
251 } // namespace webrtc 270 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/common_video/include/video_frame_buffer.h ('k') | webrtc/test/frame_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698