OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "media/base/video_frame.h" | 5 #include "media/base/video_frame.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
118 | 118 |
119 // static | 119 // static |
120 scoped_refptr<VideoFrame> VideoFrame::WrapExternalYuvData( | 120 scoped_refptr<VideoFrame> VideoFrame::WrapExternalYuvData( |
121 Format format, | 121 Format format, |
122 const gfx::Size& coded_size, | 122 const gfx::Size& coded_size, |
123 const gfx::Rect& visible_rect, | 123 const gfx::Rect& visible_rect, |
124 const gfx::Size& natural_size, | 124 const gfx::Size& natural_size, |
125 int32 y_stride, int32 u_stride, int32 v_stride, | 125 int32 y_stride, int32 u_stride, int32 v_stride, |
126 uint8* y_data, uint8* u_data, uint8* v_data, | 126 uint8* y_data, uint8* u_data, uint8* v_data, |
127 base::TimeDelta timestamp, | 127 base::TimeDelta timestamp, |
128 base::SharedMemoryHandle shm_handle, | 128 base::SharedMemoryHandle shm_handle, |
hshi1
2013/08/09 18:12:33
Need to rebase once more... |shm_handle| is gone
| |
129 const base::Closure& no_longer_needed_cb) { | 129 const base::Closure& no_longer_needed_cb) { |
130 DCHECK(format == YV12 || format == YV16 || format == I420) << format; | 130 DCHECK(format == YV12 || format == YV16 || format == I420) << format; |
131 scoped_refptr<VideoFrame> frame(new VideoFrame( | 131 scoped_refptr<VideoFrame> frame(new VideoFrame( |
132 format, coded_size, visible_rect, natural_size, timestamp)); | 132 format, coded_size, visible_rect, natural_size, timestamp)); |
133 frame->shared_memory_handle_ = shm_handle; | 133 frame->shared_memory_handle_ = shm_handle; |
134 frame->strides_[kYPlane] = y_stride; | 134 frame->strides_[kYPlane] = y_stride; |
135 frame->strides_[kUPlane] = u_stride; | 135 frame->strides_[kUPlane] = u_stride; |
136 frame->strides_[kVPlane] = v_stride; | 136 frame->strides_[kVPlane] = v_stride; |
137 frame->data_[kYPlane] = y_data; | 137 frame->data_[kYPlane] = y_data; |
138 frame->data_[kUPlane] = u_data; | 138 frame->data_[kUPlane] = u_data; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
191 switch (format) { | 191 switch (format) { |
192 case VideoFrame::NATIVE_TEXTURE: | 192 case VideoFrame::NATIVE_TEXTURE: |
193 #if defined(GOOGLE_TV) | 193 #if defined(GOOGLE_TV) |
194 case VideoFrame::HOLE: | 194 case VideoFrame::HOLE: |
195 #endif | 195 #endif |
196 return 0; | 196 return 0; |
197 case VideoFrame::RGB32: | 197 case VideoFrame::RGB32: |
198 return 1; | 198 return 1; |
199 case VideoFrame::YV12: | 199 case VideoFrame::YV12: |
200 case VideoFrame::YV16: | 200 case VideoFrame::YV16: |
201 case VideoFrame::I420: | |
201 return 3; | 202 return 3; |
202 case VideoFrame::YV12A: | 203 case VideoFrame::YV12A: |
203 return 4; | 204 return 4; |
204 case VideoFrame::EMPTY: | 205 case VideoFrame::EMPTY: |
205 case VideoFrame::I420: | |
206 case VideoFrame::INVALID: | 206 case VideoFrame::INVALID: |
207 break; | 207 break; |
208 } | 208 } |
209 NOTREACHED() << "Unsupported video frame format: " << format; | 209 NOTREACHED() << "Unsupported video frame format: " << format; |
210 return 0; | 210 return 0; |
211 } | 211 } |
212 | 212 |
213 static inline size_t RoundUp(size_t value, size_t alignment) { | 213 static inline size_t RoundUp(size_t value, size_t alignment) { |
214 // Check that |alignment| is a power of 2. | 214 // Check that |alignment| is a power of 2. |
215 DCHECK((alignment + (alignment - 1)) == (alignment | (alignment - 1))); | 215 DCHECK((alignment + (alignment - 1)) == (alignment | (alignment - 1))); |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
344 } | 344 } |
345 | 345 |
346 int VideoFrame::rows(size_t plane) const { | 346 int VideoFrame::rows(size_t plane) const { |
347 DCHECK(IsValidPlane(plane)); | 347 DCHECK(IsValidPlane(plane)); |
348 int height = coded_size_.height(); | 348 int height = coded_size_.height(); |
349 switch (format_) { | 349 switch (format_) { |
350 case RGB32: | 350 case RGB32: |
351 case YV16: | 351 case YV16: |
352 return height; | 352 return height; |
353 | 353 |
354 case YV12A: | |
355 if (plane == kAPlane) | |
356 return height; | |
357 // fallthrough. | |
354 case YV12: | 358 case YV12: |
355 case YV12A: | 359 case I420: |
356 if (plane == kYPlane || plane == kAPlane) | 360 if (plane == kYPlane) |
357 return height; | 361 return height; |
358 return RoundUp(height, 2) / 2; | 362 return RoundUp(height, 2) / 2; |
359 | 363 |
360 default: | 364 default: |
361 break; | 365 break; |
362 } | 366 } |
363 | 367 |
364 // Intentionally leave out non-production formats. | 368 // Intentionally leave out non-production formats. |
365 NOTREACHED() << "Unsupported video frame format: " << format_; | 369 NOTREACHED() << "Unsupported video frame format: " << format_; |
366 return 0; | 370 return 0; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
409 : mailbox_(mailbox), | 413 : mailbox_(mailbox), |
410 sync_point_(sync_point), | 414 sync_point_(sync_point), |
411 release_callback_(release_callback) {} | 415 release_callback_(release_callback) {} |
412 | 416 |
413 VideoFrame::MailboxHolder::~MailboxHolder() { | 417 VideoFrame::MailboxHolder::~MailboxHolder() { |
414 if (!release_callback_.is_null()) | 418 if (!release_callback_.is_null()) |
415 release_callback_.Run(sync_point_); | 419 release_callback_.Run(sync_point_); |
416 } | 420 } |
417 | 421 |
418 } // namespace media | 422 } // namespace media |
OLD | NEW |