OLD | NEW |
---|---|
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 Loading... | |
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|. | |
Ken Russell (switch to Gerrit)
2012/10/01 17:56:16
Document the format of the pixels (i.e., RGBA, in
scherkus (not reviewing)
2012/10/01 18:15:04
+1,000,000
I don't know if our hardware decode pa
Ami GONE FROM CHROMIUM
2012/10/01 18:16:12
Done.
Ami GONE FROM CHROMIUM
2012/10/01 18:40:26
It does not.
scherkus (not reviewing)
2012/10/01 18:52:06
Where "we" == SkCVR?
So the best practice for usi
Ami GONE FROM CHROMIUM
2012/10/01 19:26:39
OIC; done.
| |
80 void ReadPixelsFromNativeTexture(void* pixels); | |
81 | |
71 // Creates a frame with format equals to VideoFrame::EMPTY, width, height, | 82 // Creates a frame with format equals to VideoFrame::EMPTY, width, height, |
72 // and timestamp are all 0. | 83 // and timestamp are all 0. |
73 static scoped_refptr<VideoFrame> CreateEmptyFrame(); | 84 static scoped_refptr<VideoFrame> CreateEmptyFrame(); |
74 | 85 |
75 // Allocates YV12 frame based on |width| and |height|, and sets its data to | 86 // Allocates YV12 frame based on |width| and |height|, and sets its data to |
76 // the YUV equivalent of RGB(0,0,0). | 87 // the YUV equivalent of RGB(0,0,0). |
77 static scoped_refptr<VideoFrame> CreateBlackFrame(const gfx::Size& size); | 88 static scoped_refptr<VideoFrame> CreateBlackFrame(const gfx::Size& size); |
78 | 89 |
79 Format format() const { return format_; } | 90 Format format() const { return format_; } |
80 | 91 |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
145 // of the surface divided by the horizontal sampling period. Note that | 156 // of the surface divided by the horizontal sampling period. Note that |
146 // strides can be negative. | 157 // strides can be negative. |
147 int32 strides_[kMaxPlanes]; | 158 int32 strides_[kMaxPlanes]; |
148 | 159 |
149 // Array of data pointers to each plane. | 160 // Array of data pointers to each plane. |
150 uint8* data_[kMaxPlanes]; | 161 uint8* data_[kMaxPlanes]; |
151 | 162 |
152 // Native texture ID, if this is a NATIVE_TEXTURE frame. | 163 // Native texture ID, if this is a NATIVE_TEXTURE frame. |
153 uint32 texture_id_; | 164 uint32 texture_id_; |
154 uint32 texture_target_; | 165 uint32 texture_target_; |
166 ReadPixelsCB read_pixels_cb_; | |
155 base::Closure texture_no_longer_needed_; | 167 base::Closure texture_no_longer_needed_; |
156 | 168 |
157 base::TimeDelta timestamp_; | 169 base::TimeDelta timestamp_; |
158 | 170 |
159 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoFrame); | 171 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoFrame); |
160 }; | 172 }; |
161 | 173 |
162 } // namespace media | 174 } // namespace media |
163 | 175 |
164 #endif // MEDIA_BASE_VIDEO_FRAME_H_ | 176 #endif // MEDIA_BASE_VIDEO_FRAME_H_ |
OLD | NEW |