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 25 matching lines...) Expand all Loading... |
36 case VideoFrame::YV16: | 36 case VideoFrame::YV16: |
37 frame->AllocateYUV(); | 37 frame->AllocateYUV(); |
38 break; | 38 break; |
39 default: | 39 default: |
40 LOG(FATAL) << "Unsupported frame format: " << format; | 40 LOG(FATAL) << "Unsupported frame format: " << format; |
41 } | 41 } |
42 return frame; | 42 return frame; |
43 } | 43 } |
44 | 44 |
45 // static | 45 // static |
| 46 std::string VideoFrame::FormatToString(VideoFrame::Format format) { |
| 47 switch (format) { |
| 48 case VideoFrame::INVALID: |
| 49 return "INVALID"; |
| 50 case VideoFrame::RGB32: |
| 51 return "RGB32"; |
| 52 case VideoFrame::YV12: |
| 53 return "YV12"; |
| 54 case VideoFrame::YV16: |
| 55 return "YV16"; |
| 56 case VideoFrame::EMPTY: |
| 57 return "EMPTY"; |
| 58 case VideoFrame::I420: |
| 59 return "I420"; |
| 60 case VideoFrame::NATIVE_TEXTURE: |
| 61 return "NATIVE_TEXTURE"; |
| 62 #if defined(GOOGLE_TV) |
| 63 case VideoFrame::HOLE: |
| 64 return "HOLE"; |
| 65 #endif |
| 66 case VideoFrame::YV12A: |
| 67 return "YV12A"; |
| 68 } |
| 69 NOTREACHED() << "Invalid videoframe format provided: " << format; |
| 70 return ""; |
| 71 } |
| 72 |
| 73 // static |
46 bool VideoFrame::IsValidConfig(VideoFrame::Format format, | 74 bool VideoFrame::IsValidConfig(VideoFrame::Format format, |
47 const gfx::Size& coded_size, | 75 const gfx::Size& coded_size, |
48 const gfx::Rect& visible_rect, | 76 const gfx::Rect& visible_rect, |
49 const gfx::Size& natural_size) { | 77 const gfx::Size& natural_size) { |
50 return (format != VideoFrame::INVALID && | 78 return (format != VideoFrame::INVALID && |
51 !coded_size.IsEmpty() && | 79 !coded_size.IsEmpty() && |
52 coded_size.GetArea() <= limits::kMaxCanvas && | 80 coded_size.GetArea() <= limits::kMaxCanvas && |
53 coded_size.width() <= limits::kMaxDimension && | 81 coded_size.width() <= limits::kMaxDimension && |
54 coded_size.height() <= limits::kMaxDimension && | 82 coded_size.height() <= limits::kMaxDimension && |
55 !visible_rect.IsEmpty() && | 83 !visible_rect.IsEmpty() && |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
381 : mailbox_(mailbox), | 409 : mailbox_(mailbox), |
382 sync_point_(sync_point), | 410 sync_point_(sync_point), |
383 release_callback_(release_callback) {} | 411 release_callback_(release_callback) {} |
384 | 412 |
385 VideoFrame::MailboxHolder::~MailboxHolder() { | 413 VideoFrame::MailboxHolder::~MailboxHolder() { |
386 if (!release_callback_.is_null()) | 414 if (!release_callback_.is_null()) |
387 release_callback_.Run(sync_point_); | 415 release_callback_.Run(sync_point_); |
388 } | 416 } |
389 | 417 |
390 } // namespace media | 418 } // namespace media |
OLD | NEW |