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 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 } | 238 } |
239 | 239 |
240 // static | 240 // static |
241 scoped_refptr<VideoFrame> VideoFrame::WrapNativeTexture( | 241 scoped_refptr<VideoFrame> VideoFrame::WrapNativeTexture( |
242 const gpu::MailboxHolder& mailbox_holder, | 242 const gpu::MailboxHolder& mailbox_holder, |
243 const ReleaseMailboxCB& mailbox_holder_release_cb, | 243 const ReleaseMailboxCB& mailbox_holder_release_cb, |
244 const gfx::Size& coded_size, | 244 const gfx::Size& coded_size, |
245 const gfx::Rect& visible_rect, | 245 const gfx::Rect& visible_rect, |
246 const gfx::Size& natural_size, | 246 const gfx::Size& natural_size, |
247 base::TimeDelta timestamp, | 247 base::TimeDelta timestamp, |
248 bool allow_overlay) { | 248 bool allow_overlay, |
| 249 bool has_alpha) { |
249 gpu::MailboxHolder mailbox_holders[kMaxPlanes]; | 250 gpu::MailboxHolder mailbox_holders[kMaxPlanes]; |
250 mailbox_holders[kARGBPlane] = mailbox_holder; | 251 mailbox_holders[kARGBPlane] = mailbox_holder; |
| 252 TextureFormat texture_format = has_alpha ? TEXTURE_RGBA : TEXTURE_RGB; |
251 scoped_refptr<VideoFrame> frame( | 253 scoped_refptr<VideoFrame> frame( |
252 new VideoFrame(NATIVE_TEXTURE, coded_size, visible_rect, natural_size, | 254 new VideoFrame(NATIVE_TEXTURE, coded_size, visible_rect, natural_size, |
253 mailbox_holders, TEXTURE_RGBA, timestamp, false)); | 255 mailbox_holders, texture_format, timestamp, false)); |
254 frame->mailbox_holders_release_cb_ = mailbox_holder_release_cb; | 256 frame->mailbox_holders_release_cb_ = mailbox_holder_release_cb; |
255 frame->allow_overlay_ = allow_overlay; | 257 frame->allow_overlay_ = allow_overlay; |
256 return frame; | 258 return frame; |
257 } | 259 } |
258 | 260 |
259 // static | 261 // static |
260 scoped_refptr<VideoFrame> VideoFrame::WrapYUV420NativeTextures( | 262 scoped_refptr<VideoFrame> VideoFrame::WrapYUV420NativeTextures( |
261 const gpu::MailboxHolder& y_mailbox_holder, | 263 const gpu::MailboxHolder& y_mailbox_holder, |
262 const gpu::MailboxHolder& u_mailbox_holder, | 264 const gpu::MailboxHolder& u_mailbox_holder, |
263 const gpu::MailboxHolder& v_mailbox_holder, | 265 const gpu::MailboxHolder& v_mailbox_holder, |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
549 break; | 551 break; |
550 } | 552 } |
551 NOTREACHED() << "Unsupported video frame format: " << format; | 553 NOTREACHED() << "Unsupported video frame format: " << format; |
552 return 0; | 554 return 0; |
553 } | 555 } |
554 | 556 |
555 // static | 557 // static |
556 size_t VideoFrame::NumTextures(TextureFormat texture_format) { | 558 size_t VideoFrame::NumTextures(TextureFormat texture_format) { |
557 switch (texture_format) { | 559 switch (texture_format) { |
558 case TEXTURE_RGBA: | 560 case TEXTURE_RGBA: |
| 561 case TEXTURE_RGB: |
559 return 1; | 562 return 1; |
560 case TEXTURE_YUV_420: | 563 case TEXTURE_YUV_420: |
561 return 3; | 564 return 3; |
562 } | 565 } |
563 | 566 |
564 NOTREACHED(); | 567 NOTREACHED(); |
565 return 0; | 568 return 0; |
566 } | 569 } |
567 | 570 |
568 // static | 571 // static |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
815 for (size_t plane = 0; plane < NumPlanes(format_); ++plane) { | 818 for (size_t plane = 0; plane < NumPlanes(format_); ++plane) { |
816 for (int row = 0; row < rows(plane); ++row) { | 819 for (int row = 0; row < rows(plane); ++row) { |
817 base::MD5Update(context, base::StringPiece( | 820 base::MD5Update(context, base::StringPiece( |
818 reinterpret_cast<char*>(data(plane) + stride(plane) * row), | 821 reinterpret_cast<char*>(data(plane) + stride(plane) * row), |
819 row_bytes(plane))); | 822 row_bytes(plane))); |
820 } | 823 } |
821 } | 824 } |
822 } | 825 } |
823 | 826 |
824 } // namespace media | 827 } // namespace media |
OLD | NEW |