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

Side by Side Diff: media/video/video_decode_accelerator.h

Issue 1822983002: Support external buffer import in VDA interface and add a V4L2SVDA impl. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
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_VIDEO_VIDEO_DECODE_ACCELERATOR_H_ 5 #ifndef MEDIA_VIDEO_VIDEO_DECODE_ACCELERATOR_H_
6 #define MEDIA_VIDEO_VIDEO_DECODE_ACCELERATOR_H_ 6 #define MEDIA_VIDEO_VIDEO_DECODE_ACCELERATOR_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
14 #include "base/memory/weak_ptr.h" 14 #include "base/memory/weak_ptr.h"
15 #include "media/base/bitstream_buffer.h" 15 #include "media/base/bitstream_buffer.h"
16 #include "media/base/surface_manager.h" 16 #include "media/base/surface_manager.h"
17 #include "media/base/video_decoder_config.h" 17 #include "media/base/video_decoder_config.h"
18 #include "media/video/picture.h" 18 #include "media/video/picture.h"
19 #include "ui/gfx/geometry/size.h" 19 #include "ui/gfx/geometry/size.h"
20 #include "ui/gfx/gpu_memory_buffer.h"
20 21
21 typedef unsigned int GLenum; 22 typedef unsigned int GLenum;
22 23
23 namespace base { 24 namespace base {
24 class SingleThreadTaskRunner; 25 class SingleThreadTaskRunner;
25 } 26 }
26 27
27 namespace media { 28 namespace media {
28 29
29 // Video decoder interface. 30 // Video decoder interface.
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 // failures, GPU library failures, browser programming errors, and so on. 91 // failures, GPU library failures, browser programming errors, and so on.
91 PLATFORM_FAILURE, 92 PLATFORM_FAILURE,
92 // Largest used enum. This should be adjusted when new errors are added. 93 // Largest used enum. This should be adjusted when new errors are added.
93 LARGEST_ERROR_ENUM, 94 LARGEST_ERROR_ENUM,
94 }; 95 };
95 96
96 // Config structure contains parameters required for the VDA initialization. 97 // Config structure contains parameters required for the VDA initialization.
97 struct MEDIA_EXPORT Config { 98 struct MEDIA_EXPORT Config {
98 enum { kNoSurfaceID = SurfaceManager::kNoSurfaceID }; 99 enum { kNoSurfaceID = SurfaceManager::kNoSurfaceID };
99 100
101 // Specifies the allocation and handling mode for output PictureBuffers.
102 // When set to ALLOCATE, the VDA is expected to allocate backing memory
103 // for PictureBuffers at the time of AssignPictureBuffers() call.
104 // When set to IMPORT, the VDA will not allocate, but after receiving
105 // AssignPictureBuffers() call, it will expect a call to
106 // ImportBufferForPicture() for each PictureBuffer before use.
107 enum class OutputMode {
108 ALLOCATE,
109 IMPORT,
110 };
111
100 Config() = default; 112 Config() = default;
101 Config(VideoCodecProfile profile); 113 Config(VideoCodecProfile profile);
102 Config(const VideoDecoderConfig& video_decoder_config); 114 Config(const VideoDecoderConfig& video_decoder_config);
103 115
104 std::string AsHumanReadableString() const; 116 std::string AsHumanReadableString() const;
105 117
106 // |profile| combines the information about the codec and its profile. 118 // |profile| combines the information about the codec and its profile.
107 VideoCodecProfile profile = VIDEO_CODEC_PROFILE_UNKNOWN; 119 VideoCodecProfile profile = VIDEO_CODEC_PROFILE_UNKNOWN;
108 120
109 // The flag indicating whether the stream is encrypted. 121 // The flag indicating whether the stream is encrypted.
110 bool is_encrypted = false; 122 bool is_encrypted = false;
111 123
112 // An optional graphics surface that the VDA should render to. For setting 124 // An optional graphics surface that the VDA should render to. For setting
113 // an output SurfaceView on Android. It's only valid when not equal to 125 // an output SurfaceView on Android. It's only valid when not equal to
114 // |kNoSurfaceID|. 126 // |kNoSurfaceID|.
115 int surface_id = kNoSurfaceID; 127 int surface_id = kNoSurfaceID;
128
129 OutputMode output_mode = OutputMode::ALLOCATE;
116 }; 130 };
117 131
118 // Interface for collaborating with picture interface to provide memory for 132 // Interface for collaborating with picture interface to provide memory for
119 // output picture and blitting them. These callbacks will not be made unless 133 // output picture and blitting them. These callbacks will not be made unless
120 // Initialize() has returned successfully. 134 // Initialize() has returned successfully.
121 // This interface is extended by the various layers that relay messages back 135 // This interface is extended by the various layers that relay messages back
122 // to the plugin, through the PPP_VideoDecoder_Dev interface the plugin 136 // to the plugin, through the PPP_VideoDecoder_Dev interface the plugin
123 // implements. 137 // implements.
124 class MEDIA_EXPORT Client { 138 class MEDIA_EXPORT Client {
125 public: 139 public:
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 // is not allowed to deallocate the buffer before the DismissPictureBuffer 211 // is not allowed to deallocate the buffer before the DismissPictureBuffer
198 // callback has been initiated for a given buffer. 212 // callback has been initiated for a given buffer.
199 // 213 //
200 // Parameters: 214 // Parameters:
201 // |buffers| contains the allocated picture buffers for the output. Note 215 // |buffers| contains the allocated picture buffers for the output. Note
202 // that the count of buffers may be larger than the count requested through 216 // that the count of buffers may be larger than the count requested through
203 // the call to Client::ProvidePictureBuffers(). 217 // the call to Client::ProvidePictureBuffers().
204 virtual void AssignPictureBuffers( 218 virtual void AssignPictureBuffers(
205 const std::vector<PictureBuffer>& buffers) = 0; 219 const std::vector<PictureBuffer>& buffers) = 0;
206 220
221 // Imports |gpu_memory_buffer_handles| as backing memory for picture buffer
222 // associated with |picture_buffer_id|. The n-th element in
223 // |gpu_memory_buffer_handles| should be a handle to a GpuMemoryBuffer backing
224 // the n-th plane of the PictureBuffer. This can only be be used if the VDA
225 // has been Initialize()d with config.output_mode = IMPORT, and should be
226 // preceded by a call to AssignPictureBuffers() to set up the number of
227 // PictureBuffers and their details.
228 // After this call, the VDA becomes the owner of the GpuMemoryBufferHandles,
229 // and is responsible for closing them after use, also on import failure.
230 virtual void ImportBufferForPicture(
231 int32_t picture_buffer_id,
232 const std::vector<gfx::GpuMemoryBufferHandle>& gpu_memory_buffer_handles);
233
207 // Sends picture buffers to be reused by the decoder. This needs to be called 234 // Sends picture buffers to be reused by the decoder. This needs to be called
208 // for each buffer that has been processed so that decoder may know onto which 235 // for each buffer that has been processed so that decoder may know onto which
209 // picture buffers it can write the output to. 236 // picture buffers it can write the output to.
210 // 237 //
211 // Parameters: 238 // Parameters:
212 // |picture_buffer_id| id of the picture buffer that is to be reused. 239 // |picture_buffer_id| id of the picture buffer that is to be reused.
213 virtual void ReusePictureBuffer(int32_t picture_buffer_id) = 0; 240 virtual void ReusePictureBuffer(int32_t picture_buffer_id) = 0;
214 241
215 // Flushes the decoder: all pending inputs will be decoded and pictures handed 242 // Flushes the decoder: all pending inputs will be decoded and pictures handed
216 // back to the client, followed by NotifyFlushDone() being called on the 243 // back to the client, followed by NotifyFlushDone() being called on the
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 // to run decode operations without GL context, which helps reduce latency and 288 // to run decode operations without GL context, which helps reduce latency and
262 // offloads the GPU Child thread. 289 // offloads the GPU Child thread.
263 virtual bool TryToSetupDecodeOnSeparateThread( 290 virtual bool TryToSetupDecodeOnSeparateThread(
264 const base::WeakPtr<Client>& decode_client, 291 const base::WeakPtr<Client>& decode_client,
265 const scoped_refptr<base::SingleThreadTaskRunner>& decode_task_runner); 292 const scoped_refptr<base::SingleThreadTaskRunner>& decode_task_runner);
266 293
267 // Windows creates a BGRA texture. 294 // Windows creates a BGRA texture.
268 // TODO(dshwang): after moving to D3D11, remove this. crbug.com/438691 295 // TODO(dshwang): after moving to D3D11, remove this. crbug.com/438691
269 virtual GLenum GetSurfaceInternalFormat() const; 296 virtual GLenum GetSurfaceInternalFormat() const;
270 297
298 // In IMPORT OutputMode, return the format that the VDA requires for imported
299 // picture buffers. In ALLOCATE mode, return the format that VDA is currently
300 // using or will be using for output picture buffers allocated by it.
301 virtual VideoPixelFormat GetOutputFormat() const;
302
271 protected: 303 protected:
272 // Do not delete directly; use Destroy() or own it with a scoped_ptr, which 304 // Do not delete directly; use Destroy() or own it with a scoped_ptr, which
273 // will Destroy() it properly by default. 305 // will Destroy() it properly by default.
274 virtual ~VideoDecodeAccelerator(); 306 virtual ~VideoDecodeAccelerator();
275 }; 307 };
276 308
277 } // namespace media 309 } // namespace media
278 310
279 namespace std { 311 namespace std {
280 312
281 // Specialize std::default_delete so that scoped_ptr<VideoDecodeAccelerator> 313 // Specialize std::default_delete so that scoped_ptr<VideoDecodeAccelerator>
282 // uses "Destroy()" instead of trying to use the destructor. 314 // uses "Destroy()" instead of trying to use the destructor.
283 template <> 315 template <>
284 struct MEDIA_EXPORT default_delete<media::VideoDecodeAccelerator> { 316 struct MEDIA_EXPORT default_delete<media::VideoDecodeAccelerator> {
285 void operator()(media::VideoDecodeAccelerator* vda) const; 317 void operator()(media::VideoDecodeAccelerator* vda) const;
286 }; 318 };
287 319
288 } // namespace std 320 } // namespace std
289 321
290 #endif // MEDIA_VIDEO_VIDEO_DECODE_ACCELERATOR_H_ 322 #endif // MEDIA_VIDEO_VIDEO_DECODE_ACCELERATOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698