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

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

Issue 14199002: Send hardware video frames with mailboxes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix linux/windows hardware path Created 7 years, 8 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 | Annotate | Revision Log
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 "base/callback.h" 8 #include "base/callback.h"
9 #include "base/md5.h" 9 #include "base/md5.h"
10 #include "gpu/command_buffer/common/mailbox.h"
10 #include "media/base/buffers.h" 11 #include "media/base/buffers.h"
11 #include "ui/gfx/rect.h" 12 #include "ui/gfx/rect.h"
12 #include "ui/gfx/size.h" 13 #include "ui/gfx/size.h"
13 14
14 class SkBitmap; 15 class SkBitmap;
15 16
16 namespace media { 17 namespace media {
17 18
18 class MEDIA_EXPORT VideoFrame : public base::RefCountedThreadSafe<VideoFrame> { 19 class MEDIA_EXPORT VideoFrame : public base::RefCountedThreadSafe<VideoFrame> {
19 public: 20 public:
(...skipping 22 matching lines...) Expand all
42 YV12 = 6, // 12bpp YVU planar 1x1 Y, 2x2 VU samples 43 YV12 = 6, // 12bpp YVU planar 1x1 Y, 2x2 VU samples
43 YV16 = 7, // 16bpp YVU planar 1x1 Y, 2x1 VU samples 44 YV16 = 7, // 16bpp YVU planar 1x1 Y, 2x1 VU samples
44 EMPTY = 9, // An empty frame. 45 EMPTY = 9, // An empty frame.
45 I420 = 11, // 12bpp YVU planar 1x1 Y, 2x2 UV samples. 46 I420 = 11, // 12bpp YVU planar 1x1 Y, 2x2 UV samples.
46 NATIVE_TEXTURE = 12, // Native texture. Pixel-format agnostic. 47 NATIVE_TEXTURE = 12, // Native texture. Pixel-format agnostic.
47 #if defined(GOOGLE_TV) 48 #if defined(GOOGLE_TV)
48 HOLE = 13, // Hole frame. 49 HOLE = 13, // Hole frame.
49 #endif 50 #endif
50 }; 51 };
51 52
53 typedef base::Callback<void(uint32 sync_point)> TextureNoLongerNeededCallback;
54
52 // Creates a new frame in system memory with given parameters. Buffers for 55 // Creates a new frame in system memory with given parameters. Buffers for
53 // the frame are allocated but not initialized. 56 // the frame are allocated but not initialized.
54 // |coded_size| is the width and height of the frame data in pixels. 57 // |coded_size| is the width and height of the frame data in pixels.
55 // |visible_rect| is the visible portion of |coded_size|, after cropping (if 58 // |visible_rect| is the visible portion of |coded_size|, after cropping (if
56 // any) is applied. 59 // any) is applied.
57 // |natural_size| is the width and height of the frame when the frame's aspect 60 // |natural_size| is the width and height of the frame when the frame's aspect
58 // ratio is applied to |visible_rect|. 61 // ratio is applied to |visible_rect|.
59 static scoped_refptr<VideoFrame> CreateFrame( 62 static scoped_refptr<VideoFrame> CreateFrame(
60 Format format, 63 Format format,
61 const gfx::Size& coded_size, 64 const gfx::Size& coded_size,
(...skipping 16 matching lines...) Expand all
78 // frame is destroyed |no_longer_needed_cb.Run()| will be called. 81 // frame is destroyed |no_longer_needed_cb.Run()| will be called.
79 // |coded_size| is the width and height of the frame data in pixels. 82 // |coded_size| is the width and height of the frame data in pixels.
80 // |visible_rect| is the visible portion of |coded_size|, after cropping (if 83 // |visible_rect| is the visible portion of |coded_size|, after cropping (if
81 // any) is applied. 84 // any) is applied.
82 // |natural_size| is the width and height of the frame when the frame's aspect 85 // |natural_size| is the width and height of the frame when the frame's aspect
83 // ratio is applied to |visible_rect|. 86 // ratio is applied to |visible_rect|.
84 87
85 // |read_pixels_cb| may be used to do (slow!) readbacks from the 88 // |read_pixels_cb| may be used to do (slow!) readbacks from the
86 // texture to main memory. 89 // texture to main memory.
87 static scoped_refptr<VideoFrame> WrapNativeTexture( 90 static scoped_refptr<VideoFrame> WrapNativeTexture(
88 uint32 texture_id, 91 const gpu::Mailbox& texture_mailbox,
92 uint32 texture_mailbox_sync_point,
89 uint32 texture_target, 93 uint32 texture_target,
90 const gfx::Size& coded_size, 94 const gfx::Size& coded_size,
91 const gfx::Rect& visible_rect, 95 const gfx::Rect& visible_rect,
92 const gfx::Size& natural_size, 96 const gfx::Size& natural_size,
93 base::TimeDelta timestamp, 97 base::TimeDelta timestamp,
94 const ReadPixelsCB& read_pixels_cb, 98 const ReadPixelsCB& read_pixels_cb,
99 const TextureNoLongerNeededCallback& texture_no_longer_needed_cb,
95 const base::Closure& no_longer_needed_cb); 100 const base::Closure& no_longer_needed_cb);
96 101
97 // Read pixels from the native texture backing |*this| and write 102 // Read pixels from the native texture backing |*this| and write
98 // them to |pixels| as BGRA. |pixels| must point to a buffer at 103 // them to |pixels| as BGRA. |pixels| must point to a buffer at
99 // least as large as 4*visible_rect().width()*visible_rect().height(). 104 // least as large as 4*visible_rect().width()*visible_rect().height().
100 void ReadPixelsFromNativeTexture(const SkBitmap& pixels); 105 void ReadPixelsFromNativeTexture(const SkBitmap& pixels);
101 106
102 // Wraps external YUV data of the given parameters with a VideoFrame. 107 // Wraps external YUV data of the given parameters with a VideoFrame.
103 // The returned VideoFrame does not own the data passed in. When the frame 108 // The returned VideoFrame does not own the data passed in. When the frame
104 // is destroyed |no_longer_needed_cb.Run()| will be called. 109 // is destroyed |no_longer_needed_cb.Run()| will be called.
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 // 154 //
150 // As opposed to stride(), row_bytes() refers to the bytes representing 155 // As opposed to stride(), row_bytes() refers to the bytes representing
151 // frame data scanlines (coded_size.width() pixels, without stride padding). 156 // frame data scanlines (coded_size.width() pixels, without stride padding).
152 int row_bytes(size_t plane) const; 157 int row_bytes(size_t plane) const;
153 int rows(size_t plane) const; 158 int rows(size_t plane) const;
154 159
155 // Returns pointer to the buffer for a given plane. The memory is owned by 160 // Returns pointer to the buffer for a given plane. The memory is owned by
156 // VideoFrame object and must not be freed by the caller. 161 // VideoFrame object and must not be freed by the caller.
157 uint8* data(size_t plane) const; 162 uint8* data(size_t plane) const;
158 163
159 // Returns the ID of the native texture wrapped by this frame. Only valid to 164 // Returns the mailbox of the native texture wrapped by this frame. Only
160 // call if this is a NATIVE_TEXTURE frame. 165 // valid to call if this is a NATIVE_TEXTURE frame.
161 uint32 texture_id() const; 166 const gpu::Mailbox& texture_mailbox() const;
167
168 // Before using the texture_mailbox, the consumer must wait on this sync
169 // point. Only valid to call if this is a NATIVE_TEXTURE frame.
170 uint32 texture_mailbox_sync_point() const;
171
172 // Reset the sync point to a new value. Only valid to call if this is a
173 // NATIVE_TEXTURE frame.
174 void set_texture_mailbox_sync_point(uint32 sync_point);
162 175
163 // Returns the texture target. Only valid for NATIVE_TEXTURE frames. 176 // Returns the texture target. Only valid for NATIVE_TEXTURE frames.
164 uint32 texture_target() const; 177 uint32 texture_target() const;
165 178
166 // Returns true if this VideoFrame represents the end of the stream. 179 // Returns true if this VideoFrame represents the end of the stream.
167 bool IsEndOfStream() const; 180 bool IsEndOfStream() const;
168 181
169 base::TimeDelta GetTimestamp() const { 182 base::TimeDelta GetTimestamp() const {
170 return timestamp_; 183 return timestamp_;
171 } 184 }
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 gfx::Size natural_size_; 221 gfx::Size natural_size_;
209 222
210 // Array of strides for each plane, typically greater or equal to the width 223 // Array of strides for each plane, typically greater or equal to the width
211 // of the surface divided by the horizontal sampling period. Note that 224 // of the surface divided by the horizontal sampling period. Note that
212 // strides can be negative. 225 // strides can be negative.
213 int32 strides_[kMaxPlanes]; 226 int32 strides_[kMaxPlanes];
214 227
215 // Array of data pointers to each plane. 228 // Array of data pointers to each plane.
216 uint8* data_[kMaxPlanes]; 229 uint8* data_[kMaxPlanes];
217 230
218 // Native texture ID, if this is a NATIVE_TEXTURE frame. 231 // Native texture mailbox, if this is a NATIVE_TEXTURE frame.
219 uint32 texture_id_; 232 gpu::Mailbox texture_mailbox_;
233 uint32 texture_mailbox_sync_point_;
220 uint32 texture_target_; 234 uint32 texture_target_;
221 ReadPixelsCB read_pixels_cb_; 235 ReadPixelsCB read_pixels_cb_;
236 TextureNoLongerNeededCallback texture_no_longer_needed_cb_;
222 237
223 base::Closure no_longer_needed_cb_; 238 base::Closure no_longer_needed_cb_;
224 239
225 base::TimeDelta timestamp_; 240 base::TimeDelta timestamp_;
226 241
227 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoFrame); 242 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoFrame);
228 }; 243 };
229 244
230 } // namespace media 245 } // namespace media
231 246
232 #endif // MEDIA_BASE_VIDEO_FRAME_H_ 247 #endif // MEDIA_BASE_VIDEO_FRAME_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698