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 136 matching lines...) Loading... |
147 const uint8_t* I420Buffer::DataY() const { | 147 const uint8_t* I420Buffer::DataY() const { |
148 return data_.get(); | 148 return data_.get(); |
149 } | 149 } |
150 const uint8_t* I420Buffer::DataU() const { | 150 const uint8_t* I420Buffer::DataU() const { |
151 return data_.get() + stride_y_ * height_; | 151 return data_.get() + stride_y_ * height_; |
152 } | 152 } |
153 const uint8_t* I420Buffer::DataV() const { | 153 const uint8_t* I420Buffer::DataV() const { |
154 return data_.get() + stride_y_ * height_ + stride_u_ * ((height_ + 1) / 2); | 154 return data_.get() + stride_y_ * height_ + stride_u_ * ((height_ + 1) / 2); |
155 } | 155 } |
156 | 156 |
157 bool I420Buffer::IsMutable() { | |
158 return HasOneRef(); | |
159 } | |
160 | |
161 uint8_t* I420Buffer::MutableDataY() { | 157 uint8_t* I420Buffer::MutableDataY() { |
162 RTC_DCHECK(IsMutable()); | |
163 return const_cast<uint8_t*>(DataY()); | 158 return const_cast<uint8_t*>(DataY()); |
164 } | 159 } |
165 uint8_t* I420Buffer::MutableDataU() { | 160 uint8_t* I420Buffer::MutableDataU() { |
166 RTC_DCHECK(IsMutable()); | |
167 return const_cast<uint8_t*>(DataU()); | 161 return const_cast<uint8_t*>(DataU()); |
168 } | 162 } |
169 uint8_t* I420Buffer::MutableDataV() { | 163 uint8_t* I420Buffer::MutableDataV() { |
170 RTC_DCHECK(IsMutable()); | |
171 return const_cast<uint8_t*>(DataV()); | 164 return const_cast<uint8_t*>(DataV()); |
172 } | 165 } |
173 | 166 |
174 int I420Buffer::StrideY() const { | 167 int I420Buffer::StrideY() const { |
175 return stride_y_; | 168 return stride_y_; |
176 } | 169 } |
177 int I420Buffer::StrideU() const { | 170 int I420Buffer::StrideU() const { |
178 return stride_u_; | 171 return stride_u_; |
179 } | 172 } |
180 int I420Buffer::StrideV() const { | 173 int I420Buffer::StrideV() const { |
(...skipping 28 matching lines...) Loading... |
209 | 202 |
210 NativeHandleBuffer::NativeHandleBuffer(void* native_handle, | 203 NativeHandleBuffer::NativeHandleBuffer(void* native_handle, |
211 int width, | 204 int width, |
212 int height) | 205 int height) |
213 : native_handle_(native_handle), width_(width), height_(height) { | 206 : native_handle_(native_handle), width_(width), height_(height) { |
214 RTC_DCHECK(native_handle != nullptr); | 207 RTC_DCHECK(native_handle != nullptr); |
215 RTC_DCHECK_GT(width, 0); | 208 RTC_DCHECK_GT(width, 0); |
216 RTC_DCHECK_GT(height, 0); | 209 RTC_DCHECK_GT(height, 0); |
217 } | 210 } |
218 | 211 |
219 bool NativeHandleBuffer::IsMutable() { | |
220 return false; | |
221 } | |
222 | |
223 int NativeHandleBuffer::width() const { | 212 int NativeHandleBuffer::width() const { |
224 return width_; | 213 return width_; |
225 } | 214 } |
226 | 215 |
227 int NativeHandleBuffer::height() const { | 216 int NativeHandleBuffer::height() const { |
228 return height_; | 217 return height_; |
229 } | 218 } |
230 | 219 |
231 const uint8_t* NativeHandleBuffer::DataY() const { | 220 const uint8_t* NativeHandleBuffer::DataY() const { |
232 RTC_NOTREACHED(); // Should not be called. | 221 RTC_NOTREACHED(); // Should not be called. |
(...skipping 42 matching lines...) Loading... |
275 y_stride_(y_stride), | 264 y_stride_(y_stride), |
276 u_stride_(u_stride), | 265 u_stride_(u_stride), |
277 v_stride_(v_stride), | 266 v_stride_(v_stride), |
278 no_longer_used_cb_(no_longer_used) { | 267 no_longer_used_cb_(no_longer_used) { |
279 } | 268 } |
280 | 269 |
281 WrappedI420Buffer::~WrappedI420Buffer() { | 270 WrappedI420Buffer::~WrappedI420Buffer() { |
282 no_longer_used_cb_(); | 271 no_longer_used_cb_(); |
283 } | 272 } |
284 | 273 |
285 // Data owned by creator; never mutable. | |
286 bool WrappedI420Buffer::IsMutable() { | |
287 return false; | |
288 } | |
289 | |
290 int WrappedI420Buffer::width() const { | 274 int WrappedI420Buffer::width() const { |
291 return width_; | 275 return width_; |
292 } | 276 } |
293 | 277 |
294 int WrappedI420Buffer::height() const { | 278 int WrappedI420Buffer::height() const { |
295 return height_; | 279 return height_; |
296 } | 280 } |
297 | 281 |
298 const uint8_t* WrappedI420Buffer::DataY() const { | 282 const uint8_t* WrappedI420Buffer::DataY() const { |
299 return y_plane_; | 283 return y_plane_; |
(...skipping 49 matching lines...) Loading... |
349 buffer->StrideV() * uv_offset_y + uv_offset_x; | 333 buffer->StrideV() * uv_offset_y + uv_offset_x; |
350 return new rtc::RefCountedObject<WrappedI420Buffer>( | 334 return new rtc::RefCountedObject<WrappedI420Buffer>( |
351 cropped_width, cropped_height, | 335 cropped_width, cropped_height, |
352 y_plane, buffer->StrideY(), | 336 y_plane, buffer->StrideY(), |
353 u_plane, buffer->StrideU(), | 337 u_plane, buffer->StrideU(), |
354 v_plane, buffer->StrideV(), | 338 v_plane, buffer->StrideV(), |
355 rtc::KeepRefUntilDone(buffer)); | 339 rtc::KeepRefUntilDone(buffer)); |
356 } | 340 } |
357 | 341 |
358 } // namespace webrtc | 342 } // namespace webrtc |
OLD | NEW |