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 28 matching lines...) Expand all Loading... | |
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. |
42 static scoped_refptr<VideoFrame> CreateFrame( | 42 static scoped_refptr<VideoFrame> CreateFrame( |
43 Format format, | 43 Format format, |
44 size_t width, | 44 size_t width, |
45 size_t height, | 45 size_t height, |
46 base::TimeDelta timestamp, | 46 base::TimeDelta timestamp, |
47 base::TimeDelta duration); | 47 base::TimeDelta duration); |
48 | 48 |
49 static scoped_refptr<VideoFrame> CreateFrame( | |
50 Format format, | |
51 size_t width, | |
52 size_t height, | |
53 size_t natural_width, | |
Ami GONE FROM CHROMIUM
2012/07/13 00:59:05
You need serious commentary about how the "natural
| |
54 size_t natural_height, | |
55 base::TimeDelta timestamp, | |
56 base::TimeDelta duration); | |
57 | |
49 // Call prior to CreateFrame to ensure validity of frame configuration. Called | 58 // Call prior to CreateFrame to ensure validity of frame configuration. Called |
50 // automatically by VideoDecoderConfig::IsValidConfig(). | 59 // automatically by VideoDecoderConfig::IsValidConfig(). |
51 // TODO(scherkus): VideoDecoderConfig shouldn't call this method | 60 // TODO(scherkus): VideoDecoderConfig shouldn't call this method |
52 static bool IsValidConfig( | 61 static bool IsValidConfig( |
53 Format format, | 62 Format format, |
54 size_t width, | 63 size_t width, |
55 size_t height); | 64 size_t height); |
56 | 65 |
57 // Wraps a native texture of the given parameters with a VideoFrame. When the | 66 // Wraps a native texture of the given parameters with a VideoFrame. When the |
58 // frame is destroyed |no_longer_needed.Run()| will be called. | 67 // frame is destroyed |no_longer_needed.Run()| will be called. |
59 static scoped_refptr<VideoFrame> WrapNativeTexture( | 68 static scoped_refptr<VideoFrame> WrapNativeTexture( |
60 uint32 texture_id, | 69 uint32 texture_id, |
61 uint32 texture_target, | 70 uint32 texture_target, |
62 size_t width, | 71 size_t width, |
63 size_t height, | 72 size_t height, |
73 size_t natural_width, | |
74 size_t natural_height, | |
64 base::TimeDelta timestamp, | 75 base::TimeDelta timestamp, |
65 base::TimeDelta duration, | 76 base::TimeDelta duration, |
66 const base::Closure& no_longer_needed); | 77 const base::Closure& no_longer_needed); |
67 | 78 |
68 // Creates a frame with format equals to VideoFrame::EMPTY, width, height | 79 // Creates a frame with format equals to VideoFrame::EMPTY, width, height |
69 // timestamp and duration are all 0. | 80 // timestamp and duration are all 0. |
70 static scoped_refptr<VideoFrame> CreateEmptyFrame(); | 81 static scoped_refptr<VideoFrame> CreateEmptyFrame(); |
71 | 82 |
72 // Allocates YV12 frame based on |width| and |height|, and sets its data to | 83 // Allocates YV12 frame based on |width| and |height|, and sets its data to |
73 // the YUV equivalent of RGB(0,0,0). | 84 // the YUV equivalent of RGB(0,0,0). |
74 static scoped_refptr<VideoFrame> CreateBlackFrame(int width, int height); | 85 static scoped_refptr<VideoFrame> CreateBlackFrame(int width, int height); |
75 | 86 |
76 Format format() const { return format_; } | 87 Format format() const { return format_; } |
77 | 88 |
78 size_t width() const { return width_; } | 89 size_t width() const { return width_; } |
79 | 90 |
80 size_t height() const { return height_; } | 91 size_t height() const { return height_; } |
81 | 92 |
93 size_t natural_width() const { return natural_width_; } | |
94 | |
95 size_t natural_height() const { return natural_height_; } | |
96 | |
82 int stride(size_t plane) const; | 97 int stride(size_t plane) const; |
83 | 98 |
84 // Returns the number of bytes per row and number of rows for a given plane. | 99 // Returns the number of bytes per row and number of rows for a given plane. |
85 // | 100 // |
86 // As opposed to stride(), row_bytes() refers to the bytes representing | 101 // As opposed to stride(), row_bytes() refers to the bytes representing |
87 // visible pixels. | 102 // visible pixels. |
88 int row_bytes(size_t plane) const; | 103 int row_bytes(size_t plane) const; |
89 int rows(size_t plane) const; | 104 int rows(size_t plane) const; |
90 | 105 |
91 // Returns pointer to the buffer for a given plane. The memory is owned by | 106 // Returns pointer to the buffer for a given plane. The memory is owned by |
(...skipping 27 matching lines...) Expand all Loading... | |
119 // Used to keep a running hash of seen frames. Expects an initialized MD5 | 134 // Used to keep a running hash of seen frames. Expects an initialized MD5 |
120 // context. Calls MD5Update with the context and the contents of the frame. | 135 // context. Calls MD5Update with the context and the contents of the frame. |
121 void HashFrameForTesting(base::MD5Context* context); | 136 void HashFrameForTesting(base::MD5Context* context); |
122 | 137 |
123 private: | 138 private: |
124 friend class base::RefCountedThreadSafe<VideoFrame>; | 139 friend class base::RefCountedThreadSafe<VideoFrame>; |
125 // Clients must use the static CreateFrame() method to create a new frame. | 140 // Clients must use the static CreateFrame() method to create a new frame. |
126 VideoFrame(Format format, | 141 VideoFrame(Format format, |
127 size_t video_width, | 142 size_t video_width, |
128 size_t video_height, | 143 size_t video_height, |
144 size_t natural_width, | |
145 size_t natural_height, | |
129 base::TimeDelta timestamp, | 146 base::TimeDelta timestamp, |
130 base::TimeDelta duration); | 147 base::TimeDelta duration); |
131 virtual ~VideoFrame(); | 148 virtual ~VideoFrame(); |
132 | 149 |
133 // Used internally by CreateFrame(). | 150 // Used internally by CreateFrame(). |
134 void AllocateRGB(size_t bytes_per_pixel); | 151 void AllocateRGB(size_t bytes_per_pixel); |
135 void AllocateYUV(); | 152 void AllocateYUV(); |
136 | 153 |
137 // Used to DCHECK() plane parameters. | 154 // Used to DCHECK() plane parameters. |
138 bool IsValidPlane(size_t plane) const; | 155 bool IsValidPlane(size_t plane) const; |
139 | 156 |
140 // Frame format. | 157 // Frame format. |
141 Format format_; | 158 Format format_; |
142 | 159 |
143 // Width and height of surface. | 160 // Width and height of surface. |
144 size_t width_; | 161 size_t width_; |
145 size_t height_; | 162 size_t height_; |
146 | 163 |
164 // Aspect corrected width and height. | |
165 size_t natural_width_; | |
166 size_t natural_height_; | |
167 | |
147 // Array of strides for each plane, typically greater or equal to the width | 168 // Array of strides for each plane, typically greater or equal to the width |
148 // of the surface divided by the horizontal sampling period. Note that | 169 // of the surface divided by the horizontal sampling period. Note that |
149 // strides can be negative. | 170 // strides can be negative. |
150 int32 strides_[kMaxPlanes]; | 171 int32 strides_[kMaxPlanes]; |
151 | 172 |
152 // Array of data pointers to each plane. | 173 // Array of data pointers to each plane. |
153 uint8* data_[kMaxPlanes]; | 174 uint8* data_[kMaxPlanes]; |
154 | 175 |
155 // Native texture ID, if this is a NATIVE_TEXTURE frame. | 176 // Native texture ID, if this is a NATIVE_TEXTURE frame. |
156 uint32 texture_id_; | 177 uint32 texture_id_; |
157 uint32 texture_target_; | 178 uint32 texture_target_; |
158 base::Closure texture_no_longer_needed_; | 179 base::Closure texture_no_longer_needed_; |
159 | 180 |
160 base::TimeDelta timestamp_; | 181 base::TimeDelta timestamp_; |
161 base::TimeDelta duration_; | 182 base::TimeDelta duration_; |
162 | 183 |
163 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoFrame); | 184 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoFrame); |
164 }; | 185 }; |
165 | 186 |
166 } // namespace media | 187 } // namespace media |
167 | 188 |
168 #endif // MEDIA_BASE_VIDEO_FRAME_H_ | 189 #endif // MEDIA_BASE_VIDEO_FRAME_H_ |
OLD | NEW |