Chromium Code Reviews| 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 <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 66 // meaningful name and handle it appropriately in all cases. | 66 // meaningful name and handle it appropriately in all cases. |
| 67 STORAGE_DMABUFS = 5, // Each plane is stored into a DmaBuf. | 67 STORAGE_DMABUFS = 5, // Each plane is stored into a DmaBuf. |
| 68 #endif | 68 #endif |
| 69 #if defined(VIDEO_HOLE) | 69 #if defined(VIDEO_HOLE) |
| 70 // Indicates protected media that needs to be directly rendered to hw. It | 70 // Indicates protected media that needs to be directly rendered to hw. It |
| 71 // is, in principle, platform independent, see http://crbug.com/323157 and | 71 // is, in principle, platform independent, see http://crbug.com/323157 and |
| 72 // https://groups.google.com/a/google.com/d/topic/chrome-gpu/eIM1RwarUmk/dis cussion | 72 // https://groups.google.com/a/google.com/d/topic/chrome-gpu/eIM1RwarUmk/dis cussion |
| 73 STORAGE_HOLE = 6, | 73 STORAGE_HOLE = 6, |
| 74 #endif | 74 #endif |
| 75 STORAGE_GPU_MEMORY_BUFFERS = 7, | 75 STORAGE_GPU_MEMORY_BUFFERS = 7, |
| 76 STORAGE_LAST = STORAGE_GPU_MEMORY_BUFFERS, | 76 STORAGE_MOJO_SHARED_MEMORY = 8, |
| 77 STORAGE_LAST = STORAGE_MOJO_SHARED_MEMORY, | |
| 77 }; | 78 }; |
| 78 | 79 |
| 79 // CB to be called on the mailbox backing this frame when the frame is | 80 // CB to be called on the mailbox backing this frame when the frame is |
| 80 // destroyed. | 81 // destroyed. |
| 81 typedef base::Callback<void(const gpu::SyncToken&)> ReleaseMailboxCB; | 82 typedef base::Callback<void(const gpu::SyncToken&)> ReleaseMailboxCB; |
| 82 | 83 |
| 83 // Interface representing client operations on a SyncToken, i.e. insert one in | 84 // Interface representing client operations on a SyncToken, i.e. insert one in |
| 84 // the GPU Command Buffer and wait for it. | 85 // the GPU Command Buffer and wait for it. |
| 85 class SyncTokenClient { | 86 class SyncTokenClient { |
| 86 public: | 87 public: |
| (...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 406 | 407 |
| 407 // It uses |client| to insert a new sync point and potentially waits on a | 408 // It uses |client| to insert a new sync point and potentially waits on a |
| 408 // older sync point. The final sync point will be used to release this | 409 // older sync point. The final sync point will be used to release this |
| 409 // VideoFrame. | 410 // VideoFrame. |
| 410 // This method is thread safe. Both blink and compositor threads can call it. | 411 // This method is thread safe. Both blink and compositor threads can call it. |
| 411 void UpdateReleaseSyncToken(SyncTokenClient* client); | 412 void UpdateReleaseSyncToken(SyncTokenClient* client); |
| 412 | 413 |
| 413 // Returns a human-readable string describing |*this|. | 414 // Returns a human-readable string describing |*this|. |
| 414 std::string AsHumanReadableString(); | 415 std::string AsHumanReadableString(); |
| 415 | 416 |
| 417 protected: | |
| 418 friend class base::RefCountedThreadSafe<VideoFrame>; | |
| 419 virtual ~VideoFrame(); | |
| 420 | |
| 421 // Clients must use the static factory/wrapping methods to create a new frame. | |
|
xhwang
2016/02/23 21:27:36
except for derived classes?
jrummell
2016/02/25 02:18:26
Done.
| |
| 422 VideoFrame(VideoPixelFormat format, | |
| 423 StorageType storage_type, | |
| 424 const gfx::Size& coded_size, | |
| 425 const gfx::Rect& visible_rect, | |
| 426 const gfx::Size& natural_size, | |
| 427 base::TimeDelta timestamp); | |
| 428 | |
| 429 void set_data(size_t plane, uint8_t* ptr); | |
| 430 void set_stride(size_t plane, int stride); | |
| 431 | |
| 432 static std::string ConfigToString(const VideoPixelFormat format, | |
|
xhwang
2016/02/23 21:27:36
what does this function do? Add a comment?
jrummell
2016/02/25 02:18:26
Done.
| |
| 433 const VideoFrame::StorageType storage_type, | |
| 434 const gfx::Size& coded_size, | |
| 435 const gfx::Rect& visible_rect, | |
| 436 const gfx::Size& natural_size); | |
| 437 | |
| 438 // Returns true if |plane| is a valid plane index for the given |format|. | |
| 439 static bool IsValidPlane(size_t plane, VideoPixelFormat format); | |
| 440 | |
| 416 private: | 441 private: |
| 417 friend class base::RefCountedThreadSafe<VideoFrame>; | |
| 418 | |
| 419 static scoped_refptr<VideoFrame> WrapExternalStorage( | 442 static scoped_refptr<VideoFrame> WrapExternalStorage( |
| 420 VideoPixelFormat format, | 443 VideoPixelFormat format, |
| 421 StorageType storage_type, | 444 StorageType storage_type, |
| 422 const gfx::Size& coded_size, | 445 const gfx::Size& coded_size, |
| 423 const gfx::Rect& visible_rect, | 446 const gfx::Rect& visible_rect, |
| 424 const gfx::Size& natural_size, | 447 const gfx::Size& natural_size, |
| 425 uint8_t* data, | 448 uint8_t* data, |
| 426 size_t data_size, | 449 size_t data_size, |
| 427 base::TimeDelta timestamp, | 450 base::TimeDelta timestamp, |
| 428 base::SharedMemoryHandle handle, | 451 base::SharedMemoryHandle handle, |
| 429 size_t data_offset); | 452 size_t data_offset); |
| 430 | 453 |
| 431 // Clients must use the static factory/wrapping methods to create a new frame. | 454 // Clients must use the static factory/wrapping methods to create a new frame. |
| 432 VideoFrame(VideoPixelFormat format, | 455 VideoFrame(VideoPixelFormat format, |
| 433 StorageType storage_type, | 456 StorageType storage_type, |
| 434 const gfx::Size& coded_size, | 457 const gfx::Size& coded_size, |
| 435 const gfx::Rect& visible_rect, | 458 const gfx::Rect& visible_rect, |
| 436 const gfx::Size& natural_size, | 459 const gfx::Size& natural_size, |
| 437 base::TimeDelta timestamp); | |
| 438 VideoFrame(VideoPixelFormat format, | |
| 439 StorageType storage_type, | |
| 440 const gfx::Size& coded_size, | |
| 441 const gfx::Rect& visible_rect, | |
| 442 const gfx::Size& natural_size, | |
| 443 base::TimeDelta timestamp, | 460 base::TimeDelta timestamp, |
| 444 base::SharedMemoryHandle handle, | 461 base::SharedMemoryHandle handle, |
| 445 size_t shared_memory_offset); | 462 size_t shared_memory_offset); |
| 446 VideoFrame(VideoPixelFormat format, | 463 VideoFrame(VideoPixelFormat format, |
| 447 StorageType storage_type, | 464 StorageType storage_type, |
| 448 const gfx::Size& coded_size, | 465 const gfx::Size& coded_size, |
| 449 const gfx::Rect& visible_rect, | 466 const gfx::Rect& visible_rect, |
| 450 const gfx::Size& natural_size, | 467 const gfx::Size& natural_size, |
| 451 const gpu::MailboxHolder(&mailbox_holders)[kMaxPlanes], | 468 const gpu::MailboxHolder(&mailbox_holders)[kMaxPlanes], |
| 452 const ReleaseMailboxCB& mailbox_holder_release_cb, | 469 const ReleaseMailboxCB& mailbox_holder_release_cb, |
| 453 base::TimeDelta timestamp); | 470 base::TimeDelta timestamp); |
| 454 virtual ~VideoFrame(); | |
| 455 | 471 |
| 456 static scoped_refptr<VideoFrame> CreateFrameInternal( | 472 static scoped_refptr<VideoFrame> CreateFrameInternal( |
| 457 VideoPixelFormat format, | 473 VideoPixelFormat format, |
| 458 const gfx::Size& coded_size, | 474 const gfx::Size& coded_size, |
| 459 const gfx::Rect& visible_rect, | 475 const gfx::Rect& visible_rect, |
| 460 const gfx::Size& natural_size, | 476 const gfx::Size& natural_size, |
| 461 base::TimeDelta timestamp, | 477 base::TimeDelta timestamp, |
| 462 bool zero_initialize_memory); | 478 bool zero_initialize_memory); |
| 463 | 479 |
| 464 void AllocateYUV(bool zero_initialize_memory); | 480 void AllocateYUV(bool zero_initialize_memory); |
| 465 | 481 |
| 482 // Returns the pixel size per element for given |plane| and |format|. E.g. 2x2 | |
| 483 // for the U-plane in PIXEL_FORMAT_I420. | |
|
xhwang
2016/02/23 21:27:36
This is copied from existing code, but it would be
jrummell
2016/02/25 02:18:26
Done (I think).
| |
| 484 static gfx::Size SampleSize(VideoPixelFormat format, size_t plane); | |
| 485 | |
| 486 // Returns the number of bytes per element for given |plane| and |format|. | |
| 487 static int BytesPerElement(VideoPixelFormat format, size_t plane); | |
| 488 | |
| 489 // Return the alignment for the whole frame, calculated as the max of the | |
| 490 // alignment for each individual plane. | |
| 491 static gfx::Size CommonAlignment(VideoPixelFormat format); | |
| 492 | |
|
xhwang
2016/02/23 21:27:36
Move these to the top of the "private" section?
jrummell
2016/02/25 02:18:26
Done.
| |
| 466 // Frame format. | 493 // Frame format. |
| 467 const VideoPixelFormat format_; | 494 const VideoPixelFormat format_; |
| 468 | 495 |
| 469 // Storage type for the different planes. | 496 // Storage type for the different planes. |
| 470 StorageType storage_type_; // TODO(mcasas): make const | 497 StorageType storage_type_; // TODO(mcasas): make const |
| 471 | 498 |
| 472 // Width and height of the video frame, in pixels. This must include pixel | 499 // Width and height of the video frame, in pixels. This must include pixel |
| 473 // data for the whole image; i.e. for YUV formats with subsampled chroma | 500 // data for the whole image; i.e. for YUV formats with subsampled chroma |
| 474 // planes, in the case that the visible portion of the image does not line up | 501 // planes, in the case that the visible portion of the image does not line up |
| 475 // on a sample boundary, |coded_size_| must be rounded up appropriately and | 502 // on a sample boundary, |coded_size_| must be rounded up appropriately and |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 525 gpu::SyncToken release_sync_token_; | 552 gpu::SyncToken release_sync_token_; |
| 526 | 553 |
| 527 VideoFrameMetadata metadata_; | 554 VideoFrameMetadata metadata_; |
| 528 | 555 |
| 529 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoFrame); | 556 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoFrame); |
| 530 }; | 557 }; |
| 531 | 558 |
| 532 } // namespace media | 559 } // namespace media |
| 533 | 560 |
| 534 #endif // MEDIA_BASE_VIDEO_FRAME_H_ | 561 #endif // MEDIA_BASE_VIDEO_FRAME_H_ |
| OLD | NEW |