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 <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
212 | 212 |
213 // Returns the required allocation size for a (tightly packed) plane of the | 213 // Returns the required allocation size for a (tightly packed) plane of the |
214 // given coded size and format. | 214 // given coded size and format. |
215 static size_t PlaneAllocationSize(Format format, | 215 static size_t PlaneAllocationSize(Format format, |
216 size_t plane, | 216 size_t plane, |
217 const gfx::Size& coded_size); | 217 const gfx::Size& coded_size); |
218 | 218 |
219 // Returns horizontal bits per pixel for given |plane| and |format|. | 219 // Returns horizontal bits per pixel for given |plane| and |format|. |
220 static int PlaneHorizontalBitsPerPixel(Format format, size_t plane); | 220 static int PlaneHorizontalBitsPerPixel(Format format, size_t plane); |
221 | 221 |
222 // Returns the number of bytes per row for the given plane, format, and width. | |
223 // This refers to the bytes representing frame data scanlines without stride | |
224 // padding. | |
225 static int RowBytes(size_t plane, Format format, int width); | |
226 | |
222 Format format() const { return format_; } | 227 Format format() const { return format_; } |
223 | 228 |
224 const gfx::Size& coded_size() const { return coded_size_; } | 229 const gfx::Size& coded_size() const { return coded_size_; } |
225 const gfx::Rect& visible_rect() const { return visible_rect_; } | 230 const gfx::Rect& visible_rect() const { return visible_rect_; } |
226 const gfx::Size& natural_size() const { return natural_size_; } | 231 const gfx::Size& natural_size() const { return natural_size_; } |
227 | 232 |
228 int stride(size_t plane) const; | 233 int stride(size_t plane) const; |
229 | 234 |
230 // Returns the number of bytes per row and number of rows for a given plane. | 235 // Returns the number of bytes per row and number of rows for a given plane. |
231 // | 236 // |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
277 // VideoFrame. | 282 // VideoFrame. |
278 // This method is thread safe. Both blink and compositor threads can call it. | 283 // This method is thread safe. Both blink and compositor threads can call it. |
279 void UpdateReleaseSyncPoint(SyncPointClient* client); | 284 void UpdateReleaseSyncPoint(SyncPointClient* client); |
280 | 285 |
281 // Used to keep a running hash of seen frames. Expects an initialized MD5 | 286 // Used to keep a running hash of seen frames. Expects an initialized MD5 |
282 // context. Calls MD5Update with the context and the contents of the frame. | 287 // context. Calls MD5Update with the context and the contents of the frame. |
283 void HashFrameForTesting(base::MD5Context* context); | 288 void HashFrameForTesting(base::MD5Context* context); |
284 | 289 |
285 private: | 290 private: |
286 friend class base::RefCountedThreadSafe<VideoFrame>; | 291 friend class base::RefCountedThreadSafe<VideoFrame>; |
292 | |
293 // Used to DCHECK() plane parameters. | |
294 static bool IsValidPlane(size_t plane, VideoFrame::Format format); | |
kcwu
2014/08/15 10:19:17
It is not always used to DCHECK(), for instance, H
wuchengli
2014/08/18 07:08:13
Updated the comments.
| |
295 | |
287 // Clients must use the static CreateFrame() method to create a new frame. | 296 // Clients must use the static CreateFrame() method to create a new frame. |
288 VideoFrame(Format format, | 297 VideoFrame(Format format, |
289 const gfx::Size& coded_size, | 298 const gfx::Size& coded_size, |
290 const gfx::Rect& visible_rect, | 299 const gfx::Rect& visible_rect, |
291 const gfx::Size& natural_size, | 300 const gfx::Size& natural_size, |
292 scoped_ptr<gpu::MailboxHolder> mailbox_holder, | 301 scoped_ptr<gpu::MailboxHolder> mailbox_holder, |
293 base::TimeDelta timestamp, | 302 base::TimeDelta timestamp, |
294 bool end_of_stream); | 303 bool end_of_stream); |
295 virtual ~VideoFrame(); | 304 virtual ~VideoFrame(); |
296 | 305 |
297 void AllocateYUV(); | 306 void AllocateYUV(); |
298 | 307 |
299 // Used to DCHECK() plane parameters. | |
300 bool IsValidPlane(size_t plane) const; | |
301 | |
302 // Frame format. | 308 // Frame format. |
303 const Format format_; | 309 const Format format_; |
304 | 310 |
305 // Width and height of the video frame, in pixels. This must include pixel | 311 // Width and height of the video frame, in pixels. This must include pixel |
306 // data for the whole image; i.e. for YUV formats with subsampled chroma | 312 // data for the whole image; i.e. for YUV formats with subsampled chroma |
307 // planes, in the case that the visible portion of the image does not line up | 313 // planes, in the case that the visible portion of the image does not line up |
308 // on a sample boundary, |coded_size_| must be rounded up appropriately and | 314 // on a sample boundary, |coded_size_| must be rounded up appropriately and |
309 // the pixel data provided for the odd pixels. | 315 // the pixel data provided for the odd pixels. |
310 const gfx::Size coded_size_; | 316 const gfx::Size coded_size_; |
311 | 317 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
348 uint32 release_sync_point_; | 354 uint32 release_sync_point_; |
349 | 355 |
350 const bool end_of_stream_; | 356 const bool end_of_stream_; |
351 | 357 |
352 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoFrame); | 358 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoFrame); |
353 }; | 359 }; |
354 | 360 |
355 } // namespace media | 361 } // namespace media |
356 | 362 |
357 #endif // MEDIA_BASE_VIDEO_FRAME_H_ | 363 #endif // MEDIA_BASE_VIDEO_FRAME_H_ |
OLD | NEW |