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

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: Changes 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_BUFFER = 8,
77 STORAGE_LAST = STORAGE_MOJO_SHARED_BUFFER,
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,
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 // Returns |dimensions| adjusted to appropriate boundaries based on |format|.
443 static gfx::Size DetermineAlignedSize(VideoPixelFormat format,
444 const gfx::Size& dimensions);
445
446 void set_data(size_t plane, uint8_t* ptr);
447 void set_stride(size_t plane, int stride);
448
449 private:
450 // Clients must use the static factory/wrapping methods to create a new frame.
438 VideoFrame(VideoPixelFormat format, 451 VideoFrame(VideoPixelFormat format,
439 StorageType storage_type, 452 StorageType storage_type,
440 const gfx::Size& coded_size, 453 const gfx::Size& coded_size,
441 const gfx::Rect& visible_rect, 454 const gfx::Rect& visible_rect,
442 const gfx::Size& natural_size, 455 const gfx::Size& natural_size,
443 base::TimeDelta timestamp, 456 base::TimeDelta timestamp,
444 base::SharedMemoryHandle handle, 457 base::SharedMemoryHandle handle,
445 size_t shared_memory_offset); 458 size_t shared_memory_offset);
446 VideoFrame(VideoPixelFormat format, 459 VideoFrame(VideoPixelFormat format,
447 StorageType storage_type, 460 StorageType storage_type,
448 const gfx::Size& coded_size, 461 const gfx::Size& coded_size,
449 const gfx::Rect& visible_rect, 462 const gfx::Rect& visible_rect,
450 const gfx::Size& natural_size, 463 const gfx::Size& natural_size,
451 const gpu::MailboxHolder(&mailbox_holders)[kMaxPlanes], 464 const gpu::MailboxHolder(&mailbox_holders)[kMaxPlanes],
452 const ReleaseMailboxCB& mailbox_holder_release_cb, 465 const ReleaseMailboxCB& mailbox_holder_release_cb,
453 base::TimeDelta timestamp); 466 base::TimeDelta timestamp);
454 virtual ~VideoFrame(); 467
468 static scoped_refptr<VideoFrame> WrapExternalStorage(
469 VideoPixelFormat format,
470 StorageType storage_type,
471 const gfx::Size& coded_size,
472 const gfx::Rect& visible_rect,
473 const gfx::Size& natural_size,
474 uint8_t* data,
475 size_t data_size,
476 base::TimeDelta timestamp,
477 base::SharedMemoryHandle handle,
478 size_t data_offset);
455 479
456 static scoped_refptr<VideoFrame> CreateFrameInternal( 480 static scoped_refptr<VideoFrame> CreateFrameInternal(
457 VideoPixelFormat format, 481 VideoPixelFormat format,
458 const gfx::Size& coded_size, 482 const gfx::Size& coded_size,
459 const gfx::Rect& visible_rect, 483 const gfx::Rect& visible_rect,
460 const gfx::Size& natural_size, 484 const gfx::Size& natural_size,
461 base::TimeDelta timestamp, 485 base::TimeDelta timestamp,
462 bool zero_initialize_memory); 486 bool zero_initialize_memory);
463 487
488 // Returns the pixel size of each subsample for a given |plane| and |format|.
489 // E.g. 2x2 for the U-plane in PIXEL_FORMAT_I420.
490 static gfx::Size SampleSize(VideoPixelFormat format, size_t plane);
491
492 // Returns the number of bytes per element for given |plane| and |format|.
493 static int BytesPerElement(VideoPixelFormat format, size_t plane);
494
495 // Return the alignment for the whole frame, calculated as the max of the
496 // alignment for each individual plane.
497 static gfx::Size CommonAlignment(VideoPixelFormat format);
498
464 void AllocateYUV(bool zero_initialize_memory); 499 void AllocateYUV(bool zero_initialize_memory);
465 500
466 // Frame format. 501 // Frame format.
467 const VideoPixelFormat format_; 502 const VideoPixelFormat format_;
468 503
469 // Storage type for the different planes. 504 // Storage type for the different planes.
470 StorageType storage_type_; // TODO(mcasas): make const 505 StorageType storage_type_; // TODO(mcasas): make const
471 506
472 // Width and height of the video frame, in pixels. This must include pixel 507 // 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 508 // 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_; 560 gpu::SyncToken release_sync_token_;
526 561
527 VideoFrameMetadata metadata_; 562 VideoFrameMetadata metadata_;
528 563
529 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoFrame); 564 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoFrame);
530 }; 565 };
531 566
532 } // namespace media 567 } // namespace media
533 568
534 #endif // MEDIA_BASE_VIDEO_FRAME_H_ 569 #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