Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(295)

Side by Side Diff: media/base/video_frame.h

Issue 1704273002: Add MojoVideoFrame (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: move to media/mojo/common Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | media/base/video_frame.cc » ('j') | media/mojo/common/mojo_video_frame.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 VideoPixelFormat format,
421 StorageType storage_type,
422 const gfx::Size& coded_size,
423 const gfx::Rect& visible_rect,
424 const gfx::Size& natural_size,
425 uint8_t* data,
426 size_t data_size,
427 base::TimeDelta timestamp,
428 base::SharedMemoryHandle handle,
429 size_t data_offset);
430
431 // Clients must use the static factory/wrapping methods to create a new frame. 420 // Clients must use the static factory/wrapping methods to create a new frame.
421 // Derived classes should create their own factory/wrapping methods, and use
422 // this constructor to do basic initialization.
432 VideoFrame(VideoPixelFormat format, 423 VideoFrame(VideoPixelFormat format,
433 StorageType storage_type, 424 StorageType storage_type,
434 const gfx::Size& coded_size, 425 const gfx::Size& coded_size,
435 const gfx::Rect& visible_rect, 426 const gfx::Rect& visible_rect,
436 const gfx::Size& natural_size, 427 const gfx::Size& natural_size,
437 base::TimeDelta timestamp); 428 base::TimeDelta timestamp);
429
430 virtual ~VideoFrame();
431
432 // Creates a summary of the configuration settings provided as parameters.
433 static std::string ConfigToString(const VideoPixelFormat format,
mcasas 2016/02/25 15:12:35 Since is only used in LOG(DFATAL)s I'd sandwich i
jrummell 2016/02/25 21:51:47 Combined (AsHumanReadableString() now calls Config
434 const VideoFrame::StorageType storage_type,
435 const gfx::Size& coded_size,
436 const gfx::Rect& visible_rect,
437 const gfx::Size& natural_size);
438
439 // Returns true if |plane| is a valid plane index for the given |format|.
440 static bool IsValidPlane(size_t plane, VideoPixelFormat format);
441
442 void set_data(size_t plane, uint8_t* ptr);
443 void set_stride(size_t plane, int stride);
444
445 private:
446 // Clients must use the static factory/wrapping methods to create a new frame.
438 VideoFrame(VideoPixelFormat format, 447 VideoFrame(VideoPixelFormat format,
439 StorageType storage_type, 448 StorageType storage_type,
440 const gfx::Size& coded_size, 449 const gfx::Size& coded_size,
441 const gfx::Rect& visible_rect, 450 const gfx::Rect& visible_rect,
442 const gfx::Size& natural_size, 451 const gfx::Size& natural_size,
443 base::TimeDelta timestamp, 452 base::TimeDelta timestamp,
444 base::SharedMemoryHandle handle, 453 base::SharedMemoryHandle handle,
445 size_t shared_memory_offset); 454 size_t shared_memory_offset);
446 VideoFrame(VideoPixelFormat format, 455 VideoFrame(VideoPixelFormat format,
447 StorageType storage_type, 456 StorageType storage_type,
448 const gfx::Size& coded_size, 457 const gfx::Size& coded_size,
449 const gfx::Rect& visible_rect, 458 const gfx::Rect& visible_rect,
450 const gfx::Size& natural_size, 459 const gfx::Size& natural_size,
451 const gpu::MailboxHolder(&mailbox_holders)[kMaxPlanes], 460 const gpu::MailboxHolder(&mailbox_holders)[kMaxPlanes],
452 const ReleaseMailboxCB& mailbox_holder_release_cb, 461 const ReleaseMailboxCB& mailbox_holder_release_cb,
453 base::TimeDelta timestamp); 462 base::TimeDelta timestamp);
454 virtual ~VideoFrame(); 463
464 static scoped_refptr<VideoFrame> WrapExternalStorage(
465 VideoPixelFormat format,
466 StorageType storage_type,
467 const gfx::Size& coded_size,
468 const gfx::Rect& visible_rect,
469 const gfx::Size& natural_size,
470 uint8_t* data,
471 size_t data_size,
472 base::TimeDelta timestamp,
473 base::SharedMemoryHandle handle,
474 size_t data_offset);
455 475
456 static scoped_refptr<VideoFrame> CreateFrameInternal( 476 static scoped_refptr<VideoFrame> CreateFrameInternal(
457 VideoPixelFormat format, 477 VideoPixelFormat format,
458 const gfx::Size& coded_size, 478 const gfx::Size& coded_size,
459 const gfx::Rect& visible_rect, 479 const gfx::Rect& visible_rect,
460 const gfx::Size& natural_size, 480 const gfx::Size& natural_size,
461 base::TimeDelta timestamp, 481 base::TimeDelta timestamp,
462 bool zero_initialize_memory); 482 bool zero_initialize_memory);
463 483
484 // Returns the pixel size of each subsample for a given |plane| and |format|.
485 // E.g. 2x2 for the U-plane in PIXEL_FORMAT_I420.
486 static gfx::Size SampleSize(VideoPixelFormat format, size_t plane);
487
488 // Returns the number of bytes per element for given |plane| and |format|.
489 static int BytesPerElement(VideoPixelFormat format, size_t plane);
490
491 // Return the alignment for the whole frame, calculated as the max of the
492 // alignment for each individual plane.
493 static gfx::Size CommonAlignment(VideoPixelFormat format);
mcasas 2016/02/25 15:12:35 Why did you change this file level static function
jrummell 2016/02/25 21:51:47 CommonAlignment() uses SampleSize(), which is now
494
464 void AllocateYUV(bool zero_initialize_memory); 495 void AllocateYUV(bool zero_initialize_memory);
465 496
466 // Frame format. 497 // Frame format.
467 const VideoPixelFormat format_; 498 const VideoPixelFormat format_;
468 499
469 // Storage type for the different planes. 500 // Storage type for the different planes.
470 StorageType storage_type_; // TODO(mcasas): make const 501 StorageType storage_type_; // TODO(mcasas): make const
471 502
472 // Width and height of the video frame, in pixels. This must include pixel 503 // 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 504 // data for the whole image; i.e. for YUV formats with subsampled chroma
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 gpu::SyncToken release_sync_token_; 556 gpu::SyncToken release_sync_token_;
526 557
527 VideoFrameMetadata metadata_; 558 VideoFrameMetadata metadata_;
528 559
529 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoFrame); 560 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoFrame);
530 }; 561 };
531 562
532 } // namespace media 563 } // namespace media
533 564
534 #endif // MEDIA_BASE_VIDEO_FRAME_H_ 565 #endif // MEDIA_BASE_VIDEO_FRAME_H_
OLDNEW
« no previous file with comments | « no previous file | media/base/video_frame.cc » ('j') | media/mojo/common/mojo_video_frame.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698