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, | |
|
mcasas
2016/02/18 04:32:50
I do something similar in
media/capture/service/m
jrummell
2016/02/23 02:01:21
I've added most of the code from the other CL into
| |
| 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 |
| 416 private: | 417 protected: |
| 417 friend class base::RefCountedThreadSafe<VideoFrame>; | 418 friend class base::RefCountedThreadSafe<VideoFrame>; |
| 418 | 419 |
| 419 static scoped_refptr<VideoFrame> WrapExternalStorage( | 420 static scoped_refptr<VideoFrame> WrapExternalStorage( |
| 420 VideoPixelFormat format, | 421 VideoPixelFormat format, |
| 421 StorageType storage_type, | 422 StorageType storage_type, |
| 422 const gfx::Size& coded_size, | 423 const gfx::Size& coded_size, |
| 423 const gfx::Rect& visible_rect, | 424 const gfx::Rect& visible_rect, |
| 424 const gfx::Size& natural_size, | 425 const gfx::Size& natural_size, |
| 425 uint8_t* data, | 426 uint8_t* data, |
| 426 size_t data_size, | 427 size_t data_size, |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 456 static scoped_refptr<VideoFrame> CreateFrameInternal( | 457 static scoped_refptr<VideoFrame> CreateFrameInternal( |
| 457 VideoPixelFormat format, | 458 VideoPixelFormat format, |
| 458 const gfx::Size& coded_size, | 459 const gfx::Size& coded_size, |
| 459 const gfx::Rect& visible_rect, | 460 const gfx::Rect& visible_rect, |
| 460 const gfx::Size& natural_size, | 461 const gfx::Size& natural_size, |
| 461 base::TimeDelta timestamp, | 462 base::TimeDelta timestamp, |
| 462 bool zero_initialize_memory); | 463 bool zero_initialize_memory); |
| 463 | 464 |
| 464 void AllocateYUV(bool zero_initialize_memory); | 465 void AllocateYUV(bool zero_initialize_memory); |
| 465 | 466 |
| 467 static std::string ConfigToString(const VideoPixelFormat format, | |
| 468 const VideoFrame::StorageType storage_type, | |
| 469 const gfx::Size& coded_size, | |
| 470 const gfx::Rect& visible_rect, | |
| 471 const gfx::Size& natural_size); | |
| 472 | |
| 473 // Returns true if |plane| is a valid plane index for the given |format|. | |
| 474 static bool IsValidPlane(size_t plane, VideoPixelFormat format); | |
| 475 | |
| 476 // Returns the pixel size per element for given |plane| and |format|. E.g. 2x2 | |
| 477 // for the U-plane in PIXEL_FORMAT_I420. | |
| 478 static gfx::Size SampleSize(VideoPixelFormat format, size_t plane); | |
| 479 | |
| 480 // Returns the number of bytes per element for given |plane| and |format|. | |
| 481 static int BytesPerElement(VideoPixelFormat format, size_t plane); | |
| 482 | |
| 483 // Return the alignment for the whole frame, calculated as the max of the | |
| 484 // alignment for each individual plane. | |
| 485 static gfx::Size CommonAlignment(VideoPixelFormat format); | |
| 486 | |
| 466 // Frame format. | 487 // Frame format. |
| 467 const VideoPixelFormat format_; | 488 const VideoPixelFormat format_; |
| 468 | 489 |
| 469 // Storage type for the different planes. | 490 // Storage type for the different planes. |
| 470 StorageType storage_type_; // TODO(mcasas): make const | 491 StorageType storage_type_; // TODO(mcasas): make const |
| 471 | 492 |
| 472 // Width and height of the video frame, in pixels. This must include pixel | 493 // 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 | 494 // 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 | 495 // 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 | 496 // 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_; | 546 gpu::SyncToken release_sync_token_; |
| 526 | 547 |
| 527 VideoFrameMetadata metadata_; | 548 VideoFrameMetadata metadata_; |
| 528 | 549 |
| 529 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoFrame); | 550 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoFrame); |
| 530 }; | 551 }; |
| 531 | 552 |
| 532 } // namespace media | 553 } // namespace media |
| 533 | 554 |
| 534 #endif // MEDIA_BASE_VIDEO_FRAME_H_ | 555 #endif // MEDIA_BASE_VIDEO_FRAME_H_ |
| OLD | NEW |