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

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

Issue 11016006: Support reading pixels from HW-decoded video textures into canvas/webgl. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 2 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 "media/base/buffers.h" 10 #include "media/base/buffers.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 const gfx::Size& data_size, 48 const gfx::Size& data_size,
49 const gfx::Size& natural_size, 49 const gfx::Size& natural_size,
50 base::TimeDelta timestamp); 50 base::TimeDelta timestamp);
51 51
52 // Call prior to CreateFrame to ensure validity of frame configuration. Called 52 // Call prior to CreateFrame to ensure validity of frame configuration. Called
53 // automatically by VideoDecoderConfig::IsValidConfig(). 53 // automatically by VideoDecoderConfig::IsValidConfig().
54 // TODO(scherkus): VideoDecoderConfig shouldn't call this method 54 // TODO(scherkus): VideoDecoderConfig shouldn't call this method
55 static bool IsValidConfig(Format format, const gfx::Size& data_size, 55 static bool IsValidConfig(Format format, const gfx::Size& data_size,
56 const gfx::Size& natural_size); 56 const gfx::Size& natural_size);
57 57
58 // CB to write pixels from the texture backing this frame into the
59 // |void*| parameter.
60 typedef base::Callback<void(void*)> ReadPixelsCB;
61
58 // Wraps a native texture of the given parameters with a VideoFrame. When the 62 // Wraps a native texture of the given parameters with a VideoFrame. When the
59 // frame is destroyed |no_longer_needed.Run()| will be called. 63 // frame is destroyed |no_longer_needed.Run()| will be called.
60 // |data_size| is the width and height of the frame data in pixels. 64 // |data_size| is the width and height of the frame data in pixels.
61 // |natural_size| is the width and height of the frame when the frame's aspect 65 // |natural_size| is the width and height of the frame when the frame's aspect
62 // ratio is applied to |size|. 66 // ratio is applied to |size|.
67 // |read_pixels_cb| may be used to do (slow!) readbacks from the
68 // texture to main memory.
63 static scoped_refptr<VideoFrame> WrapNativeTexture( 69 static scoped_refptr<VideoFrame> WrapNativeTexture(
64 uint32 texture_id, 70 uint32 texture_id,
65 uint32 texture_target, 71 uint32 texture_target,
66 const gfx::Size& data_size, 72 const gfx::Size& data_size,
67 const gfx::Size& natural_size, 73 const gfx::Size& natural_size,
68 base::TimeDelta timestamp, 74 base::TimeDelta timestamp,
75 const ReadPixelsCB& read_pixels_cb,
69 const base::Closure& no_longer_needed); 76 const base::Closure& no_longer_needed);
70 77
78 // Read pixels from the native texture backing |*this| and write
79 // them to |*pixels| as RGBA. |pixels| must point to a buffer at
80 // least as large as 4*data_size().width()*data_size().height().
81 void ReadPixelsFromNativeTexture(void* pixels);
82
71 // Creates a frame with format equals to VideoFrame::EMPTY, width, height, 83 // Creates a frame with format equals to VideoFrame::EMPTY, width, height,
72 // and timestamp are all 0. 84 // and timestamp are all 0.
73 static scoped_refptr<VideoFrame> CreateEmptyFrame(); 85 static scoped_refptr<VideoFrame> CreateEmptyFrame();
74 86
75 // Allocates YV12 frame based on |width| and |height|, and sets its data to 87 // Allocates YV12 frame based on |width| and |height|, and sets its data to
76 // the YUV equivalent of RGB(0,0,0). 88 // the YUV equivalent of RGB(0,0,0).
77 static scoped_refptr<VideoFrame> CreateBlackFrame(const gfx::Size& size); 89 static scoped_refptr<VideoFrame> CreateBlackFrame(const gfx::Size& size);
78 90
79 Format format() const { return format_; } 91 Format format() const { return format_; }
80 92
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 // of the surface divided by the horizontal sampling period. Note that 157 // of the surface divided by the horizontal sampling period. Note that
146 // strides can be negative. 158 // strides can be negative.
147 int32 strides_[kMaxPlanes]; 159 int32 strides_[kMaxPlanes];
148 160
149 // Array of data pointers to each plane. 161 // Array of data pointers to each plane.
150 uint8* data_[kMaxPlanes]; 162 uint8* data_[kMaxPlanes];
151 163
152 // Native texture ID, if this is a NATIVE_TEXTURE frame. 164 // Native texture ID, if this is a NATIVE_TEXTURE frame.
153 uint32 texture_id_; 165 uint32 texture_id_;
154 uint32 texture_target_; 166 uint32 texture_target_;
167 ReadPixelsCB read_pixels_cb_;
155 base::Closure texture_no_longer_needed_; 168 base::Closure texture_no_longer_needed_;
156 169
157 base::TimeDelta timestamp_; 170 base::TimeDelta timestamp_;
158 171
159 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoFrame); 172 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoFrame);
160 }; 173 };
161 174
162 } // namespace media 175 } // namespace media
163 176
164 #endif // MEDIA_BASE_VIDEO_FRAME_H_ 177 #endif // MEDIA_BASE_VIDEO_FRAME_H_
OLDNEW
« no previous file with comments | « content/renderer/media/renderer_gpu_video_decoder_factories.cc ('k') | media/base/video_frame.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698