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

Unified 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, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | media/base/video_frame.cc » ('j') | media/mojo/common/mojo_video_frame.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/base/video_frame.h
diff --git a/media/base/video_frame.h b/media/base/video_frame.h
index ad7f4c01a4268651728ce71acba87c3ec0ac388e..9538d7ad79effce0750ec927124f0959734e2c85 100644
--- a/media/base/video_frame.h
+++ b/media/base/video_frame.h
@@ -73,7 +73,8 @@ class MEDIA_EXPORT VideoFrame : public base::RefCountedThreadSafe<VideoFrame> {
STORAGE_HOLE = 6,
#endif
STORAGE_GPU_MEMORY_BUFFERS = 7,
- STORAGE_LAST = STORAGE_GPU_MEMORY_BUFFERS,
+ STORAGE_MOJO_SHARED_BUFFER = 8,
+ STORAGE_LAST = STORAGE_MOJO_SHARED_BUFFER,
};
// CB to be called on the mailbox backing this frame when the frame is
@@ -413,28 +414,40 @@ class MEDIA_EXPORT VideoFrame : public base::RefCountedThreadSafe<VideoFrame> {
// Returns a human-readable string describing |*this|.
std::string AsHumanReadableString();
- private:
+ protected:
friend class base::RefCountedThreadSafe<VideoFrame>;
- static scoped_refptr<VideoFrame> WrapExternalStorage(
- VideoPixelFormat format,
- StorageType storage_type,
- const gfx::Size& coded_size,
- const gfx::Rect& visible_rect,
- const gfx::Size& natural_size,
- uint8_t* data,
- size_t data_size,
- base::TimeDelta timestamp,
- base::SharedMemoryHandle handle,
- size_t data_offset);
-
// Clients must use the static factory/wrapping methods to create a new frame.
+ // Derived classes should create their own factory/wrapping methods, and use
+ // this constructor to do basic initialization.
VideoFrame(VideoPixelFormat format,
StorageType storage_type,
const gfx::Size& coded_size,
const gfx::Rect& visible_rect,
const gfx::Size& natural_size,
base::TimeDelta timestamp);
+
+ virtual ~VideoFrame();
+
+ // Creates a summary of the configuration settings provided as parameters.
+ static std::string ConfigToString(const VideoPixelFormat format,
+ const VideoFrame::StorageType storage_type,
+ const gfx::Size& coded_size,
+ const gfx::Rect& visible_rect,
+ const gfx::Size& natural_size);
+
+ // Returns true if |plane| is a valid plane index for the given |format|.
+ static bool IsValidPlane(size_t plane, VideoPixelFormat format);
+
+ // Returns |dimensions| adjusted to appropriate boundaries based on |format|.
+ static gfx::Size DetermineAlignedSize(VideoPixelFormat format,
+ const gfx::Size& dimensions);
+
+ void set_data(size_t plane, uint8_t* ptr);
+ void set_stride(size_t plane, int stride);
+
+ private:
+ // Clients must use the static factory/wrapping methods to create a new frame.
VideoFrame(VideoPixelFormat format,
StorageType storage_type,
const gfx::Size& coded_size,
@@ -451,7 +464,18 @@ class MEDIA_EXPORT VideoFrame : public base::RefCountedThreadSafe<VideoFrame> {
const gpu::MailboxHolder(&mailbox_holders)[kMaxPlanes],
const ReleaseMailboxCB& mailbox_holder_release_cb,
base::TimeDelta timestamp);
- virtual ~VideoFrame();
+
+ static scoped_refptr<VideoFrame> WrapExternalStorage(
+ VideoPixelFormat format,
+ StorageType storage_type,
+ const gfx::Size& coded_size,
+ const gfx::Rect& visible_rect,
+ const gfx::Size& natural_size,
+ uint8_t* data,
+ size_t data_size,
+ base::TimeDelta timestamp,
+ base::SharedMemoryHandle handle,
+ size_t data_offset);
static scoped_refptr<VideoFrame> CreateFrameInternal(
VideoPixelFormat format,
@@ -461,6 +485,17 @@ class MEDIA_EXPORT VideoFrame : public base::RefCountedThreadSafe<VideoFrame> {
base::TimeDelta timestamp,
bool zero_initialize_memory);
+ // Returns the pixel size of each subsample for a given |plane| and |format|.
+ // E.g. 2x2 for the U-plane in PIXEL_FORMAT_I420.
+ static gfx::Size SampleSize(VideoPixelFormat format, size_t plane);
+
+ // Returns the number of bytes per element for given |plane| and |format|.
+ static int BytesPerElement(VideoPixelFormat format, size_t plane);
+
+ // Return the alignment for the whole frame, calculated as the max of the
+ // alignment for each individual plane.
+ static gfx::Size CommonAlignment(VideoPixelFormat format);
+
void AllocateYUV(bool zero_initialize_memory);
// Frame format.
« 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