| 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 #ifndef MEDIA_BASE_VIDEO_FRAME_H_ | 5 #ifndef MEDIA_BASE_VIDEO_FRAME_H_ |
| 6 #define MEDIA_BASE_VIDEO_FRAME_H_ | 6 #define MEDIA_BASE_VIDEO_FRAME_H_ |
| 7 | 7 |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/md5.h" | 9 #include "base/md5.h" |
| 10 #include "media/base/buffers.h" | 10 #include "media/base/buffers.h" |
| 11 #include "ui/gfx/rect.h" | 11 #include "ui/gfx/rect.h" |
| 12 #include "ui/gfx/size.h" | 12 #include "ui/gfx/size.h" |
| 13 | 13 |
| 14 namespace media { | 14 namespace media { |
| 15 | 15 |
| 16 class MEDIA_EXPORT VideoFrame : public base::RefCountedThreadSafe<VideoFrame> { | 16 class MEDIA_EXPORT VideoFrame : public base::RefCountedThreadSafe<VideoFrame> { |
| 17 public: | 17 public: |
| 18 enum { | 18 enum { |
| 19 kFrameSizeAlignment = 16, | 19 kFrameSizeAlignment = 16, |
| 20 kFrameSizePadding = 16, | 20 kFrameSizePadding = 16, |
| 21 kFrameAddressAlignment = 32 | 21 kFrameAddressAlignment = 32 |
| 22 }; | 22 }; |
| 23 | 23 |
| 24 enum { | 24 enum { |
| 25 kMaxPlanes = 3, | 25 kMaxPlanes = 4, |
| 26 | 26 |
| 27 kRGBPlane = 0, | 27 kRGBPlane = 0, |
| 28 | 28 |
| 29 kYPlane = 0, | 29 kYPlane = 0, |
| 30 kUPlane = 1, | 30 kUPlane = 1, |
| 31 kVPlane = 2, | 31 kVPlane = 2, |
| 32 kAPlane = 3, |
| 32 }; | 33 }; |
| 33 | 34 |
| 34 // Surface formats roughly based on FOURCC labels, see: | 35 // Surface formats roughly based on FOURCC labels, see: |
| 35 // http://www.fourcc.org/rgb.php | 36 // http://www.fourcc.org/rgb.php |
| 36 // http://www.fourcc.org/yuv.php | 37 // http://www.fourcc.org/yuv.php |
| 37 // Keep in sync with WebKit::WebVideoFrame! | 38 // Keep in sync with WebKit::WebVideoFrame! |
| 38 enum Format { | 39 enum Format { |
| 39 INVALID = 0, // Invalid format value. Used for error reporting. | 40 INVALID = 0, // Invalid format value. Used for error reporting. |
| 40 RGB32 = 4, // 32bpp RGB packed with extra byte 8:8:8 | 41 RGB32 = 4, // 32bpp RGB packed with extra byte 8:8:8 |
| 41 YV12 = 6, // 12bpp YVU planar 1x1 Y, 2x2 VU samples | 42 YV12 = 6, // 12bpp YVU planar 1x1 Y, 2x2 VU samples |
| 42 YV16 = 7, // 16bpp YVU planar 1x1 Y, 2x1 VU samples | 43 YV16 = 7, // 16bpp YVU planar 1x1 Y, 2x1 VU samples |
| 43 EMPTY = 9, // An empty frame. | 44 EMPTY = 9, // An empty frame. |
| 44 I420 = 11, // 12bpp YVU planar 1x1 Y, 2x2 UV samples. | 45 I420 = 11, // 12bpp YVU planar 1x1 Y, 2x2 UV samples. |
| 45 NATIVE_TEXTURE = 12, // Native texture. Pixel-format agnostic. | 46 NATIVE_TEXTURE = 12, // Native texture. Pixel-format agnostic. |
| 47 YV12A = 13,// 20bpp YUVA planar 1x1 Y, 2x2 VU, 1x1 A samples |
| 46 }; | 48 }; |
| 47 | 49 |
| 48 // Creates a new frame in system memory with given parameters. Buffers for | 50 // Creates a new frame in system memory with given parameters. Buffers for |
| 49 // the frame are allocated but not initialized. | 51 // the frame are allocated but not initialized. |
| 50 // |coded_size| is the width and height of the frame data in pixels. | 52 // |coded_size| is the width and height of the frame data in pixels. |
| 51 // |visible_rect| is the visible portion of |coded_size|, after cropping (if | 53 // |visible_rect| is the visible portion of |coded_size|, after cropping (if |
| 52 // any) is applied. | 54 // any) is applied. |
| 53 // |natural_size| is the width and height of the frame when the frame's aspect | 55 // |natural_size| is the width and height of the frame when the frame's aspect |
| 54 // ratio is applied to |visible_rect|. | 56 // ratio is applied to |visible_rect|. |
| 55 static scoped_refptr<VideoFrame> CreateFrame( | 57 static scoped_refptr<VideoFrame> CreateFrame( |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 return timestamp_; | 160 return timestamp_; |
| 159 } | 161 } |
| 160 void SetTimestamp(const base::TimeDelta& timestamp) { | 162 void SetTimestamp(const base::TimeDelta& timestamp) { |
| 161 timestamp_ = timestamp; | 163 timestamp_ = timestamp; |
| 162 } | 164 } |
| 163 | 165 |
| 164 // Used to keep a running hash of seen frames. Expects an initialized MD5 | 166 // Used to keep a running hash of seen frames. Expects an initialized MD5 |
| 165 // context. Calls MD5Update with the context and the contents of the frame. | 167 // context. Calls MD5Update with the context and the contents of the frame. |
| 166 void HashFrameForTesting(base::MD5Context* context); | 168 void HashFrameForTesting(base::MD5Context* context); |
| 167 | 169 |
| 170 bool HasAlpha() const { |
| 171 return IsValidPlane(kAPlane); |
| 172 } |
| 173 |
| 168 private: | 174 private: |
| 169 friend class base::RefCountedThreadSafe<VideoFrame>; | 175 friend class base::RefCountedThreadSafe<VideoFrame>; |
| 170 // Clients must use the static CreateFrame() method to create a new frame. | 176 // Clients must use the static CreateFrame() method to create a new frame. |
| 171 VideoFrame(Format format, | 177 VideoFrame(Format format, |
| 172 const gfx::Size& coded_size, | 178 const gfx::Size& coded_size, |
| 173 const gfx::Rect& visible_rect, | 179 const gfx::Rect& visible_rect, |
| 174 const gfx::Size& natural_size, | 180 const gfx::Size& natural_size, |
| 175 base::TimeDelta timestamp); | 181 base::TimeDelta timestamp); |
| 176 virtual ~VideoFrame(); | 182 virtual ~VideoFrame(); |
| 177 | 183 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 base::Closure no_longer_needed_cb_; | 217 base::Closure no_longer_needed_cb_; |
| 212 | 218 |
| 213 base::TimeDelta timestamp_; | 219 base::TimeDelta timestamp_; |
| 214 | 220 |
| 215 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoFrame); | 221 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoFrame); |
| 216 }; | 222 }; |
| 217 | 223 |
| 218 } // namespace media | 224 } // namespace media |
| 219 | 225 |
| 220 #endif // MEDIA_BASE_VIDEO_FRAME_H_ | 226 #endif // MEDIA_BASE_VIDEO_FRAME_H_ |
| OLD | NEW |