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" |
(...skipping 20 matching lines...) Expand all Loading... | |
31 INVALID = 0, // Invalid format value. Used for error reporting. | 31 INVALID = 0, // Invalid format value. Used for error reporting. |
32 RGB32 = 4, // 32bpp RGB packed with extra byte 8:8:8 | 32 RGB32 = 4, // 32bpp RGB packed with extra byte 8:8:8 |
33 YV12 = 6, // 12bpp YVU planar 1x1 Y, 2x2 VU samples | 33 YV12 = 6, // 12bpp YVU planar 1x1 Y, 2x2 VU samples |
34 YV16 = 7, // 16bpp YVU planar 1x1 Y, 2x1 VU samples | 34 YV16 = 7, // 16bpp YVU planar 1x1 Y, 2x1 VU samples |
35 EMPTY = 9, // An empty frame. | 35 EMPTY = 9, // An empty frame. |
36 I420 = 11, // 12bpp YVU planar 1x1 Y, 2x2 UV samples. | 36 I420 = 11, // 12bpp YVU planar 1x1 Y, 2x2 UV samples. |
37 NATIVE_TEXTURE = 12, // Native texture. Pixel-format agnostic. | 37 NATIVE_TEXTURE = 12, // Native texture. Pixel-format agnostic. |
38 }; | 38 }; |
39 | 39 |
40 // Creates a new frame in system memory with given parameters. Buffers for | 40 // Creates a new frame in system memory with given parameters. Buffers for |
41 // the frame are allocated but not initialized. | 41 // the frame are allocated but not initialized. If bytes_per_row and |
42 // bytes_per_row_uv are zero, they are initialized to a default value | |
43 // suitable for the given format. | |
44 static scoped_refptr<VideoFrame> CreateFrame( | |
45 Format format, | |
46 size_t width, | |
47 size_t height, | |
48 size_t bytes_per_row, | |
49 size_t bytes_per_uv_row, | |
Ami GONE FROM CHROMIUM
2012/06/08 19:11:04
These two args don't make sense to me, because the
| |
50 size_t aligned_height, | |
51 base::TimeDelta timestamp, | |
52 base::TimeDelta duration); | |
42 static scoped_refptr<VideoFrame> CreateFrame( | 53 static scoped_refptr<VideoFrame> CreateFrame( |
43 Format format, | 54 Format format, |
44 size_t width, | 55 size_t width, |
45 size_t height, | 56 size_t height, |
46 base::TimeDelta timestamp, | 57 base::TimeDelta timestamp, |
47 base::TimeDelta duration); | 58 base::TimeDelta duration) { |
59 return CreateFrame(format, width, height, 0, 0, 0, | |
60 timestamp, duration); | |
61 } | |
48 | 62 |
49 // Call prior to CreateFrame to ensure validity of frame configuration. Called | 63 // Call prior to CreateFrame to ensure validity of frame configuration. Called |
50 // automatically by VideoDecoderConfig::IsValidConfig(). | 64 // automatically by VideoDecoderConfig::IsValidConfig(). If bytes_per_row and |
65 // bytes_per_uv_row are non-zero, they are also checked to be valid strides | |
66 // for the given buffer size and format. | |
51 static bool IsValidConfig( | 67 static bool IsValidConfig( |
52 Format format, | 68 Format format, |
53 size_t width, | 69 size_t width, |
54 size_t height); | 70 size_t height, |
71 size_t bytes_per_row, | |
72 size_t bytes_per_uv_row, | |
73 size_t aligned_height); | |
74 static bool IsValidConfig( | |
75 Format format, | |
76 size_t width, | |
77 size_t height) { | |
78 return IsValidConfig(format, width, height, 0, 0, 0); | |
79 } | |
55 | 80 |
56 // Wraps a native texture of the given parameters with a VideoFrame. When the | 81 // Wraps a native texture of the given parameters with a VideoFrame. When the |
57 // frame is destroyed |no_longer_needed.Run()| will be called. | 82 // frame is destroyed |no_longer_needed.Run()| will be called. |
58 static scoped_refptr<VideoFrame> WrapNativeTexture( | 83 static scoped_refptr<VideoFrame> WrapNativeTexture( |
59 uint32 texture_id, | 84 uint32 texture_id, |
60 uint32 texture_target, | 85 uint32 texture_target, |
61 size_t width, | 86 size_t width, |
62 size_t height, | 87 size_t height, |
63 base::TimeDelta timestamp, | 88 base::TimeDelta timestamp, |
64 base::TimeDelta duration, | 89 base::TimeDelta duration, |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
123 friend class base::RefCountedThreadSafe<VideoFrame>; | 148 friend class base::RefCountedThreadSafe<VideoFrame>; |
124 // Clients must use the static CreateFrame() method to create a new frame. | 149 // Clients must use the static CreateFrame() method to create a new frame. |
125 VideoFrame(Format format, | 150 VideoFrame(Format format, |
126 size_t video_width, | 151 size_t video_width, |
127 size_t video_height, | 152 size_t video_height, |
128 base::TimeDelta timestamp, | 153 base::TimeDelta timestamp, |
129 base::TimeDelta duration); | 154 base::TimeDelta duration); |
130 virtual ~VideoFrame(); | 155 virtual ~VideoFrame(); |
131 | 156 |
132 // Used internally by CreateFrame(). | 157 // Used internally by CreateFrame(). |
133 void AllocateRGB(size_t bytes_per_pixel); | 158 void AllocateRGB(size_t bytes_per_row, size_t aligned_height); |
134 void AllocateYUV(); | 159 void AllocateYUV(size_t bytes_per_y_row, size_t bytes_per_uv_row, |
160 size_t aligned_height); | |
135 | 161 |
136 // Used to DCHECK() plane parameters. | 162 // Used to DCHECK() plane parameters. |
137 bool IsValidPlane(size_t plane) const; | 163 bool IsValidPlane(size_t plane) const; |
138 | 164 |
139 // Frame format. | 165 // Frame format. |
140 Format format_; | 166 Format format_; |
141 | 167 |
142 // Width and height of surface. | 168 // Width and height of surface. |
143 size_t width_; | 169 size_t width_; |
144 size_t height_; | 170 size_t height_; |
(...skipping 13 matching lines...) Expand all Loading... | |
158 | 184 |
159 base::TimeDelta timestamp_; | 185 base::TimeDelta timestamp_; |
160 base::TimeDelta duration_; | 186 base::TimeDelta duration_; |
161 | 187 |
162 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoFrame); | 188 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoFrame); |
163 }; | 189 }; |
164 | 190 |
165 } // namespace media | 191 } // namespace media |
166 | 192 |
167 #endif // MEDIA_BASE_VIDEO_FRAME_H_ | 193 #endif // MEDIA_BASE_VIDEO_FRAME_H_ |
OLD | NEW |