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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 RTC_DCHECK_GT(width, 0); | 127 RTC_DCHECK_GT(width, 0); |
128 RTC_DCHECK_GT(height, 0); | 128 RTC_DCHECK_GT(height, 0); |
129 RTC_DCHECK_GE(stride_y, width); | 129 RTC_DCHECK_GE(stride_y, width); |
130 RTC_DCHECK_GE(stride_u, (width + 1) / 2); | 130 RTC_DCHECK_GE(stride_u, (width + 1) / 2); |
131 RTC_DCHECK_GE(stride_v, (width + 1) / 2); | 131 RTC_DCHECK_GE(stride_v, (width + 1) / 2); |
132 } | 132 } |
133 | 133 |
134 I420Buffer::~I420Buffer() { | 134 I420Buffer::~I420Buffer() { |
135 } | 135 } |
136 | 136 |
| 137 rtc::scoped_refptr<I420Buffer> I420Buffer::Create(int width, int height) { |
| 138 return new rtc::RefCountedObject<I420Buffer>(width, height); |
| 139 } |
| 140 |
| 141 rtc::scoped_refptr<I420Buffer> I420Buffer::Create(int width, |
| 142 int height, |
| 143 int stride_y, |
| 144 int stride_u, |
| 145 int stride_v) { |
| 146 return new rtc::RefCountedObject<I420Buffer>( |
| 147 width, height, stride_y, stride_u, stride_v); |
| 148 } |
| 149 |
137 void I420Buffer::InitializeData() { | 150 void I420Buffer::InitializeData() { |
138 memset(data_.get(), 0, | 151 memset(data_.get(), 0, |
139 I420DataSize(height_, stride_y_, stride_u_, stride_v_)); | 152 I420DataSize(height_, stride_y_, stride_u_, stride_v_)); |
140 } | 153 } |
141 | 154 |
142 int I420Buffer::width() const { | 155 int I420Buffer::width() const { |
143 return width_; | 156 return width_; |
144 } | 157 } |
145 | 158 |
146 int I420Buffer::height() const { | 159 int I420Buffer::height() const { |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 | 196 |
184 rtc::scoped_refptr<VideoFrameBuffer> I420Buffer::NativeToI420Buffer() { | 197 rtc::scoped_refptr<VideoFrameBuffer> I420Buffer::NativeToI420Buffer() { |
185 RTC_NOTREACHED(); | 198 RTC_NOTREACHED(); |
186 return nullptr; | 199 return nullptr; |
187 } | 200 } |
188 | 201 |
189 rtc::scoped_refptr<I420Buffer> I420Buffer::Copy( | 202 rtc::scoped_refptr<I420Buffer> I420Buffer::Copy( |
190 const rtc::scoped_refptr<VideoFrameBuffer>& source) { | 203 const rtc::scoped_refptr<VideoFrameBuffer>& source) { |
191 int width = source->width(); | 204 int width = source->width(); |
192 int height = source->height(); | 205 int height = source->height(); |
193 rtc::scoped_refptr<I420Buffer> target = | 206 rtc::scoped_refptr<I420Buffer> target = I420Buffer::Create(width, height); |
194 new rtc::RefCountedObject<I420Buffer>(width, height); | |
195 RTC_CHECK(libyuv::I420Copy(source->DataY(), source->StrideY(), | 207 RTC_CHECK(libyuv::I420Copy(source->DataY(), source->StrideY(), |
196 source->DataU(), source->StrideU(), | 208 source->DataU(), source->StrideU(), |
197 source->DataV(), source->StrideV(), | 209 source->DataV(), source->StrideV(), |
198 target->MutableDataY(), target->StrideY(), | 210 target->MutableDataY(), target->StrideY(), |
199 target->MutableDataU(), target->StrideU(), | 211 target->MutableDataU(), target->StrideU(), |
200 target->MutableDataV(), target->StrideV(), | 212 target->MutableDataV(), target->StrideV(), |
201 width, height) == 0); | 213 width, height) == 0); |
202 | 214 |
203 return target; | 215 return target; |
204 } | 216 } |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 } | 278 } |
267 | 279 |
268 rtc::scoped_refptr<I420Buffer> I420Buffer::CopyKeepStride( | 280 rtc::scoped_refptr<I420Buffer> I420Buffer::CopyKeepStride( |
269 const rtc::scoped_refptr<VideoFrameBuffer>& source) { | 281 const rtc::scoped_refptr<VideoFrameBuffer>& source) { |
270 int width = source->width(); | 282 int width = source->width(); |
271 int height = source->height(); | 283 int height = source->height(); |
272 int stride_y = source->StrideY(); | 284 int stride_y = source->StrideY(); |
273 int stride_u = source->StrideU(); | 285 int stride_u = source->StrideU(); |
274 int stride_v = source->StrideV(); | 286 int stride_v = source->StrideV(); |
275 rtc::scoped_refptr<I420Buffer> target = | 287 rtc::scoped_refptr<I420Buffer> target = |
276 new rtc::RefCountedObject<I420Buffer>( | 288 I420Buffer::Create(width, height, stride_y, stride_u, stride_v); |
277 width, height, stride_y, stride_u, stride_v); | |
278 RTC_CHECK(libyuv::I420Copy(source->DataY(), stride_y, | 289 RTC_CHECK(libyuv::I420Copy(source->DataY(), stride_y, |
279 source->DataU(), stride_u, | 290 source->DataU(), stride_u, |
280 source->DataV(), stride_v, | 291 source->DataV(), stride_v, |
281 target->MutableDataY(), stride_y, | 292 target->MutableDataY(), stride_y, |
282 target->MutableDataU(), stride_u, | 293 target->MutableDataU(), stride_u, |
283 target->MutableDataV(), stride_v, | 294 target->MutableDataV(), stride_v, |
284 width, height) == 0); | 295 width, height) == 0); |
285 | 296 |
286 return target; | 297 return target; |
287 } | 298 } |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
388 void* WrappedI420Buffer::native_handle() const { | 399 void* WrappedI420Buffer::native_handle() const { |
389 return nullptr; | 400 return nullptr; |
390 } | 401 } |
391 | 402 |
392 rtc::scoped_refptr<VideoFrameBuffer> WrappedI420Buffer::NativeToI420Buffer() { | 403 rtc::scoped_refptr<VideoFrameBuffer> WrappedI420Buffer::NativeToI420Buffer() { |
393 RTC_NOTREACHED(); | 404 RTC_NOTREACHED(); |
394 return nullptr; | 405 return nullptr; |
395 } | 406 } |
396 | 407 |
397 } // namespace webrtc | 408 } // namespace webrtc |
OLD | NEW |