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 #include "webrtc/common_video/include/video_frame_buffer.h" | 10 #include "webrtc/common_video/include/video_frame_buffer.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
54 RTC_DCHECK_GT(width, 0); | 54 RTC_DCHECK_GT(width, 0); |
55 RTC_DCHECK_GT(height, 0); | 55 RTC_DCHECK_GT(height, 0); |
56 RTC_DCHECK_GE(stride_y, width); | 56 RTC_DCHECK_GE(stride_y, width); |
57 RTC_DCHECK_GE(stride_u, (width + 1) / 2); | 57 RTC_DCHECK_GE(stride_u, (width + 1) / 2); |
58 RTC_DCHECK_GE(stride_v, (width + 1) / 2); | 58 RTC_DCHECK_GE(stride_v, (width + 1) / 2); |
59 } | 59 } |
60 | 60 |
61 I420Buffer::~I420Buffer() { | 61 I420Buffer::~I420Buffer() { |
62 } | 62 } |
63 | 63 |
64 // static | |
64 rtc::scoped_refptr<I420Buffer> I420Buffer::Create(int width, int height) { | 65 rtc::scoped_refptr<I420Buffer> I420Buffer::Create(int width, int height) { |
65 return new rtc::RefCountedObject<I420Buffer>(width, height); | 66 return new rtc::RefCountedObject<I420Buffer>(width, height); |
66 } | 67 } |
67 | 68 |
69 // static | |
68 rtc::scoped_refptr<I420Buffer> I420Buffer::Create(int width, | 70 rtc::scoped_refptr<I420Buffer> I420Buffer::Create(int width, |
69 int height, | 71 int height, |
70 int stride_y, | 72 int stride_y, |
71 int stride_u, | 73 int stride_u, |
72 int stride_v) { | 74 int stride_v) { |
73 return new rtc::RefCountedObject<I420Buffer>( | 75 return new rtc::RefCountedObject<I420Buffer>( |
74 width, height, stride_y, stride_u, stride_v); | 76 width, height, stride_y, stride_u, stride_v); |
75 } | 77 } |
76 | 78 |
77 void I420Buffer::InitializeData() { | 79 void I420Buffer::InitializeData() { |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
121 return nullptr; | 123 return nullptr; |
122 } | 124 } |
123 | 125 |
124 rtc::scoped_refptr<VideoFrameBuffer> I420Buffer::NativeToI420Buffer() { | 126 rtc::scoped_refptr<VideoFrameBuffer> I420Buffer::NativeToI420Buffer() { |
125 RTC_NOTREACHED(); | 127 RTC_NOTREACHED(); |
126 return nullptr; | 128 return nullptr; |
127 } | 129 } |
128 | 130 |
129 // static | 131 // static |
130 rtc::scoped_refptr<I420Buffer> I420Buffer::Copy( | 132 rtc::scoped_refptr<I420Buffer> I420Buffer::Copy( |
133 int width, int height, | |
134 const uint8_t* data_y, int stride_y, | |
135 const uint8_t* data_u, int stride_u, | |
136 const uint8_t* data_v, int stride_v) { | |
137 // Note: May use different strides than the input data. | |
138 rtc::scoped_refptr<I420Buffer> buffer = Create(width, height); | |
139 RTC_CHECK(libyuv::I420Copy(data_y, stride_y, | |
magjed_webrtc
2016/11/28 08:39:56
RTC_CHECK_EQ(0, ...)
nisse-webrtc
2016/11/28 09:44:54
Done.
| |
140 data_u, stride_u, | |
141 data_v, stride_v, | |
142 buffer->MutableDataY(), buffer->StrideY(), | |
143 buffer->MutableDataU(), buffer->StrideU(), | |
144 buffer->MutableDataV(), buffer->StrideV(), | |
145 width, height) | |
146 == 0); | |
147 return buffer; | |
148 } | |
149 | |
150 // static | |
151 rtc::scoped_refptr<I420Buffer> I420Buffer::Copy( | |
131 const VideoFrameBuffer& source) { | 152 const VideoFrameBuffer& source) { |
132 int width = source.width(); | 153 return Copy(source.width(), source.height(), |
133 int height = source.height(); | 154 source.DataY(), source.StrideY(), |
134 rtc::scoped_refptr<I420Buffer> target = I420Buffer::Create(width, height); | 155 source.DataU(), source.StrideU(), |
135 RTC_CHECK(libyuv::I420Copy(source.DataY(), source.StrideY(), | 156 source.DataV(), source.StrideV()); |
136 source.DataU(), source.StrideU(), | |
137 source.DataV(), source.StrideV(), | |
138 target->MutableDataY(), target->StrideY(), | |
139 target->MutableDataU(), target->StrideU(), | |
140 target->MutableDataV(), target->StrideV(), | |
141 width, height) == 0); | |
142 | |
143 return target; | |
144 } | 157 } |
145 | 158 |
146 void I420Buffer::SetToBlack() { | 159 void I420Buffer::SetToBlack() { |
147 RTC_CHECK(libyuv::I420Rect(MutableDataY(), StrideY(), | 160 RTC_CHECK(libyuv::I420Rect(MutableDataY(), StrideY(), |
148 MutableDataU(), StrideU(), | 161 MutableDataU(), StrideU(), |
149 MutableDataV(), StrideV(), | 162 MutableDataV(), StrideV(), |
150 0, 0, width(), height(), | 163 0, 0, width(), height(), |
151 0, 128, 128) == 0); | 164 0, 128, 128) == 0); |
152 } | 165 } |
153 | 166 |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
342 void* WrappedI420Buffer::native_handle() const { | 355 void* WrappedI420Buffer::native_handle() const { |
343 return nullptr; | 356 return nullptr; |
344 } | 357 } |
345 | 358 |
346 rtc::scoped_refptr<VideoFrameBuffer> WrappedI420Buffer::NativeToI420Buffer() { | 359 rtc::scoped_refptr<VideoFrameBuffer> WrappedI420Buffer::NativeToI420Buffer() { |
347 RTC_NOTREACHED(); | 360 RTC_NOTREACHED(); |
348 return nullptr; | 361 return nullptr; |
349 } | 362 } |
350 | 363 |
351 } // namespace webrtc | 364 } // namespace webrtc |
OLD | NEW |