Chromium Code Reviews| 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_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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 105 // |profile| combines the information about the codec and its profile. | 106 // |profile| combines the information about the codec and its profile. |
| 106 VideoCodecProfile profile = VIDEO_CODEC_PROFILE_UNKNOWN; | 107 VideoCodecProfile profile = VIDEO_CODEC_PROFILE_UNKNOWN; |
| 107 | 108 |
| 108 // The flag indicating whether the stream is encrypted. | 109 // The flag indicating whether the stream is encrypted. |
| 109 bool is_encrypted = false; | 110 bool is_encrypted = false; |
| 110 | 111 |
| 111 // An optional graphics surface that the VDA should render to. For setting | 112 // An optional graphics surface that the VDA should render to. For setting |
| 112 // an output SurfaceView on Android. It's only valid when not equal to | 113 // an output SurfaceView on Android. It's only valid when not equal to |
| 113 // |kNoSurfaceID|. | 114 // |kNoSurfaceID|. |
| 114 int surface_id = kNoSurfaceID; | 115 int surface_id = kNoSurfaceID; |
| 116 | |
| 117 // Specifies the allocation and handling mode for output PictureBuffers. | |
| 118 // When set to ALLOCATE, the VDA is expected to allocate backing memory | |
| 119 // for PictureBuffers at the time of AssignPictureBuffers() call. | |
| 120 // When set to IMPORT, the VDA will not allocate, but after receiving | |
| 121 // AssignPictureBuffers() call, it will expect a call to | |
| 122 // ImportBufferForPicture() for each PictureBuffer before use. | |
| 123 enum class OutputMode { | |
|
kcwu
2016/03/22 05:42:54
Move type definition to head of struct.
Pawel Osciak
2016/03/28 01:31:29
Done.
| |
| 124 ALLOCATE, | |
| 125 IMPORT, | |
| 126 }; | |
| 127 OutputMode output_mode = OutputMode::ALLOCATE; | |
| 115 }; | 128 }; |
| 116 | 129 |
| 117 // Interface for collaborating with picture interface to provide memory for | 130 // Interface for collaborating with picture interface to provide memory for |
| 118 // output picture and blitting them. These callbacks will not be made unless | 131 // output picture and blitting them. These callbacks will not be made unless |
| 119 // Initialize() has returned successfully. | 132 // Initialize() has returned successfully. |
| 120 // This interface is extended by the various layers that relay messages back | 133 // This interface is extended by the various layers that relay messages back |
| 121 // to the plugin, through the PPP_VideoDecoder_Dev interface the plugin | 134 // to the plugin, through the PPP_VideoDecoder_Dev interface the plugin |
| 122 // implements. | 135 // implements. |
| 123 class MEDIA_EXPORT Client { | 136 class MEDIA_EXPORT Client { |
| 124 public: | 137 public: |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 196 // is not allowed to deallocate the buffer before the DismissPictureBuffer | 209 // is not allowed to deallocate the buffer before the DismissPictureBuffer |
| 197 // callback has been initiated for a given buffer. | 210 // callback has been initiated for a given buffer. |
| 198 // | 211 // |
| 199 // Parameters: | 212 // Parameters: |
| 200 // |buffers| contains the allocated picture buffers for the output. Note | 213 // |buffers| contains the allocated picture buffers for the output. Note |
| 201 // that the count of buffers may be larger than the count requested through | 214 // that the count of buffers may be larger than the count requested through |
| 202 // the call to Client::ProvidePictureBuffers(). | 215 // the call to Client::ProvidePictureBuffers(). |
| 203 virtual void AssignPictureBuffers( | 216 virtual void AssignPictureBuffers( |
| 204 const std::vector<PictureBuffer>& buffers) = 0; | 217 const std::vector<PictureBuffer>& buffers) = 0; |
| 205 | 218 |
| 219 // Imports |gpu_memory_buffer_handles| as backing memory for picture buffer | |
| 220 // associated with |picture_buffer_id|. The n-th element in | |
| 221 // |gpu_memory_buffer_handles| should be a handle to a GpuMemoryBuffer backing | |
| 222 // the n-th plane of the PictureBuffer. This can only be be used if the VDA | |
| 223 // has been Initialize()d with config.output_mode = IMPORT, and should be | |
| 224 // preceded by a call to AssignPictureBuffers() to set up the number of | |
| 225 // PictureBuffers and their details. | |
| 226 // After this call, the VDA becomes the owner of the GpuMemoryBufferHandles, | |
| 227 // and is responsible for closing them after use, also on import failure. | |
| 228 virtual void ImportBufferForPicture( | |
| 229 int32_t picture_buffer_id, | |
| 230 const std::vector<gfx::GpuMemoryBufferHandle>& gpu_memory_buffer_handles); | |
| 231 | |
| 206 // Sends picture buffers to be reused by the decoder. This needs to be called | 232 // Sends picture buffers to be reused by the decoder. This needs to be called |
| 207 // for each buffer that has been processed so that decoder may know onto which | 233 // for each buffer that has been processed so that decoder may know onto which |
| 208 // picture buffers it can write the output to. | 234 // picture buffers it can write the output to. |
| 209 // | 235 // |
| 210 // Parameters: | 236 // Parameters: |
| 211 // |picture_buffer_id| id of the picture buffer that is to be reused. | 237 // |picture_buffer_id| id of the picture buffer that is to be reused. |
| 212 virtual void ReusePictureBuffer(int32_t picture_buffer_id) = 0; | 238 virtual void ReusePictureBuffer(int32_t picture_buffer_id) = 0; |
| 213 | 239 |
| 214 // Flushes the decoder: all pending inputs will be decoded and pictures handed | 240 // Flushes the decoder: all pending inputs will be decoded and pictures handed |
| 215 // back to the client, followed by NotifyFlushDone() being called on the | 241 // back to the client, followed by NotifyFlushDone() being called on the |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 260 // to run decode operations without GL context, which helps reduce latency and | 286 // to run decode operations without GL context, which helps reduce latency and |
| 261 // offloads the GPU Child thread. | 287 // offloads the GPU Child thread. |
| 262 virtual bool TryToSetupDecodeOnSeparateThread( | 288 virtual bool TryToSetupDecodeOnSeparateThread( |
| 263 const base::WeakPtr<Client>& decode_client, | 289 const base::WeakPtr<Client>& decode_client, |
| 264 const scoped_refptr<base::SingleThreadTaskRunner>& decode_task_runner); | 290 const scoped_refptr<base::SingleThreadTaskRunner>& decode_task_runner); |
| 265 | 291 |
| 266 // Windows creates a BGRA texture. | 292 // Windows creates a BGRA texture. |
| 267 // TODO(dshwang): after moving to D3D11, remove this. crbug.com/438691 | 293 // TODO(dshwang): after moving to D3D11, remove this. crbug.com/438691 |
| 268 virtual GLenum GetSurfaceInternalFormat() const; | 294 virtual GLenum GetSurfaceInternalFormat() const; |
| 269 | 295 |
| 296 // In IMPORT OutputMode, return the format that the VDA requires for imported | |
| 297 // picture buffers. In ALLOCATE mode, return the format that VDA is currently | |
| 298 // using or will be using for output picture buffers allocated by it. | |
| 299 virtual VideoPixelFormat GetOutputFormat() const; | |
| 300 | |
| 270 protected: | 301 protected: |
| 271 // Do not delete directly; use Destroy() or own it with a scoped_ptr, which | 302 // Do not delete directly; use Destroy() or own it with a scoped_ptr, which |
| 272 // will Destroy() it properly by default. | 303 // will Destroy() it properly by default. |
| 273 virtual ~VideoDecodeAccelerator(); | 304 virtual ~VideoDecodeAccelerator(); |
| 274 }; | 305 }; |
| 275 | 306 |
| 276 } // namespace media | 307 } // namespace media |
| 277 | 308 |
| 278 namespace std { | 309 namespace std { |
| 279 | 310 |
| 280 // Specialize std::default_delete so that scoped_ptr<VideoDecodeAccelerator> | 311 // Specialize std::default_delete so that scoped_ptr<VideoDecodeAccelerator> |
| 281 // uses "Destroy()" instead of trying to use the destructor. | 312 // uses "Destroy()" instead of trying to use the destructor. |
| 282 template <> | 313 template <> |
| 283 struct MEDIA_EXPORT default_delete<media::VideoDecodeAccelerator> { | 314 struct MEDIA_EXPORT default_delete<media::VideoDecodeAccelerator> { |
| 284 void operator()(media::VideoDecodeAccelerator* vda) const; | 315 void operator()(media::VideoDecodeAccelerator* vda) const; |
| 285 }; | 316 }; |
| 286 | 317 |
| 287 } // namespace std | 318 } // namespace std |
| 288 | 319 |
| 289 #endif // MEDIA_VIDEO_VIDEO_DECODE_ACCELERATOR_H_ | 320 #endif // MEDIA_VIDEO_VIDEO_DECODE_ACCELERATOR_H_ |
| OLD | NEW |