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_GPU_DXVA_VIDEO_DECODE_ACCELERATOR_WIN_H_ | 5 #ifndef MEDIA_GPU_DXVA_VIDEO_DECODE_ACCELERATOR_WIN_H_ |
6 #define MEDIA_GPU_DXVA_VIDEO_DECODE_ACCELERATOR_WIN_H_ | 6 #define MEDIA_GPU_DXVA_VIDEO_DECODE_ACCELERATOR_WIN_H_ |
7 | 7 |
8 #include <d3d11.h> | 8 #include <d3d11.h> |
9 #include <d3d9.h> | 9 #include <d3d9.h> |
10 #include <initguid.h> | 10 #include <initguid.h> |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 // TODO(ananta) | 64 // TODO(ananta) |
65 // Move this to a common place so that all VDA's can use this. | 65 // Move this to a common place so that all VDA's can use this. |
66 class H264ConfigChangeDetector { | 66 class H264ConfigChangeDetector { |
67 public: | 67 public: |
68 H264ConfigChangeDetector(); | 68 H264ConfigChangeDetector(); |
69 ~H264ConfigChangeDetector(); | 69 ~H264ConfigChangeDetector(); |
70 | 70 |
71 // Detects stream configuration changes. | 71 // Detects stream configuration changes. |
72 // Returns false on failure. | 72 // Returns false on failure. |
73 bool DetectConfig(const uint8_t* stream, unsigned int size); | 73 bool DetectConfig(const uint8_t* stream, unsigned int size); |
74 | |
75 bool config_changed() const { return config_changed_; } | 74 bool config_changed() const { return config_changed_; } |
76 | 75 |
77 gfx::ColorSpace current_color_space() const; | 76 gfx::ColorSpace current_color_space() const; |
78 | 77 |
79 private: | 78 private: |
80 // These fields are used to track the SPS/PPS in the H.264 bitstream and | 79 // These fields are used to track the SPS/PPS in the H.264 bitstream and |
81 // are eventually compared against the SPS/PPS in the bitstream to detect | 80 // are eventually compared against the SPS/PPS in the bitstream to detect |
82 // a change. | 81 // a change. |
83 int last_sps_id_; | 82 int last_sps_id_; |
84 std::vector<uint8_t> last_sps_; | 83 std::vector<uint8_t> last_sps_; |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 // some second generation Intel GPU drivers crash if we create a video | 160 // some second generation Intel GPU drivers crash if we create a video |
162 // device with a resolution higher then 1920 x 1088. This function | 161 // device with a resolution higher then 1920 x 1088. This function |
163 // checks if the GPU is in this list and if yes returns true. | 162 // checks if the GPU is in this list and if yes returns true. |
164 static bool IsLegacyGPU(ID3D11Device* device); | 163 static bool IsLegacyGPU(ID3D11Device* device); |
165 | 164 |
166 // Creates and initializes an instance of the D3D device and the | 165 // Creates and initializes an instance of the D3D device and the |
167 // corresponding device manager. The device manager instance is eventually | 166 // corresponding device manager. The device manager instance is eventually |
168 // passed to the IMFTransform interface implemented by the decoder. | 167 // passed to the IMFTransform interface implemented by the decoder. |
169 bool CreateD3DDevManager(); | 168 bool CreateD3DDevManager(); |
170 | 169 |
| 170 // TODO(hubbe): COMMENT |
| 171 bool CreateVideoProcessor(); |
| 172 |
171 // Creates and initializes an instance of the DX11 device and the | 173 // Creates and initializes an instance of the DX11 device and the |
172 // corresponding device manager. The device manager instance is eventually | 174 // corresponding device manager. The device manager instance is eventually |
173 // passed to the IMFTransform interface implemented by the decoder. | 175 // passed to the IMFTransform interface implemented by the decoder. |
174 bool CreateDX11DevManager(); | 176 bool CreateDX11DevManager(); |
175 | 177 |
176 // Creates, initializes and sets the media codec types for the decoder. | 178 // Creates, initializes and sets the media codec types for the decoder. |
177 bool InitDecoder(VideoCodecProfile profile); | 179 bool InitDecoder(VideoCodecProfile profile); |
178 | 180 |
179 // Validates whether the decoder supports hardware video acceleration. | 181 // Validates whether the decoder supports hardware video acceleration. |
180 bool CheckDecoderDxvaSupport(); | 182 bool CheckDecoderDxvaSupport(); |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 // Returns if we have output samples waiting to be processed. We only | 276 // Returns if we have output samples waiting to be processed. We only |
275 // allow one output sample to be present in the output queue at any given | 277 // allow one output sample to be present in the output queue at any given |
276 // time. | 278 // time. |
277 bool OutputSamplesPresent(); | 279 bool OutputSamplesPresent(); |
278 | 280 |
279 // Copies the source surface |src_surface| to the destination |dest_surface|. | 281 // Copies the source surface |src_surface| to the destination |dest_surface|. |
280 // The copying is done on the decoder thread. | 282 // The copying is done on the decoder thread. |
281 void CopySurface(IDirect3DSurface9* src_surface, | 283 void CopySurface(IDirect3DSurface9* src_surface, |
282 IDirect3DSurface9* dest_surface, | 284 IDirect3DSurface9* dest_surface, |
283 int picture_buffer_id, | 285 int picture_buffer_id, |
284 int input_buffer_id); | 286 int input_buffer_id, |
| 287 const gfx::ColorSpace& color_space); |
285 | 288 |
286 // This is a notification that the source surface |src_surface| was copied to | 289 // This is a notification that the source surface |src_surface| was copied to |
287 // the destination |dest_surface|. Received on the main thread. | 290 // the destination |dest_surface|. Received on the main thread. |
288 void CopySurfaceComplete(IDirect3DSurface9* src_surface, | 291 void CopySurfaceComplete(IDirect3DSurface9* src_surface, |
289 IDirect3DSurface9* dest_surface, | 292 IDirect3DSurface9* dest_surface, |
290 int picture_buffer_id, | 293 int picture_buffer_id, |
291 int input_buffer_id); | 294 int input_buffer_id); |
292 | 295 |
293 void BindPictureBufferToSample(base::win::ScopedComPtr<IMFSample> sample, | 296 void BindPictureBufferToSample(base::win::ScopedComPtr<IMFSample> sample, |
294 int picture_buffer_id, | 297 int picture_buffer_id, |
295 int input_buffer_id); | 298 int input_buffer_id); |
296 | 299 |
297 // Copies the source texture |src_texture| to the destination |dest_texture|. | 300 // Copies the source texture |src_texture| to the destination |dest_texture|. |
298 // The copying is done on the decoder thread. | 301 // The copying is done on the decoder thread. |
299 void CopyTexture(ID3D11Texture2D* src_texture, | 302 void CopyTexture(ID3D11Texture2D* src_texture, |
300 ID3D11Texture2D* dest_texture, | 303 ID3D11Texture2D* dest_texture, |
301 base::win::ScopedComPtr<IDXGIKeyedMutex> dest_keyed_mutex, | 304 base::win::ScopedComPtr<IDXGIKeyedMutex> dest_keyed_mutex, |
302 uint64_t keyed_mutex_value, | 305 uint64_t keyed_mutex_value, |
303 int picture_buffer_id, | 306 int picture_buffer_id, |
304 int input_buffer_id); | 307 int input_buffer_id, |
| 308 const gfx::ColorSpace& color_space); |
305 | 309 |
306 // Copies the |video_frame| to the destination |dest_texture|. | 310 // Copies the |video_frame| to the destination |dest_texture|. |
307 void CopyTextureOnDecoderThread( | 311 void CopyTextureOnDecoderThread( |
308 ID3D11Texture2D* dest_texture, | 312 ID3D11Texture2D* dest_texture, |
309 base::win::ScopedComPtr<IDXGIKeyedMutex> dest_keyed_mutex, | 313 base::win::ScopedComPtr<IDXGIKeyedMutex> dest_keyed_mutex, |
310 uint64_t keyed_mutex_value, | 314 uint64_t keyed_mutex_value, |
311 IMFSample* video_frame, | 315 IMFSample* video_frame, |
312 int picture_buffer_id, | 316 int picture_buffer_id, |
313 int input_buffer_id); | 317 int input_buffer_id); |
314 | 318 |
315 // Flushes the decoder device to ensure that the decoded surface is copied | 319 // Flushes the decoder device to ensure that the decoded surface is copied |
316 // to the target surface. |iterations| helps to maintain an upper limit on | 320 // to the target surface. |iterations| helps to maintain an upper limit on |
317 // the number of times we try to complete the flush operation. | 321 // the number of times we try to complete the flush operation. |
318 void FlushDecoder(int iterations, | 322 void FlushDecoder(int iterations, |
319 IDirect3DSurface9* src_surface, | 323 IDirect3DSurface9* src_surface, |
320 IDirect3DSurface9* dest_surface, | 324 IDirect3DSurface9* dest_surface, |
321 int picture_buffer_id, | 325 int picture_buffer_id, |
322 int input_buffer_id); | 326 int input_buffer_id); |
323 | 327 |
324 // Polls to wait for GPU commands to be finished on the picture buffer | 328 // Polls to wait for GPU commands to be finished on the picture buffer |
325 // before reusing it. | 329 // before reusing it. |
326 void WaitForOutputBuffer(int32_t picture_buffer_id, int count); | 330 void WaitForOutputBuffer(int32_t picture_buffer_id, int count); |
327 | 331 |
328 // Initializes the DX11 Video format converter media types. | 332 // Initializes the DX11 Video format converter media types. |
329 // Returns true on success. | 333 // Returns true on success. |
330 bool InitializeDX11VideoFormatConverterMediaType(int width, int height); | 334 bool InitializeDX11VideoFormatConverterMediaType( |
| 335 int width, |
| 336 int height, |
| 337 const gfx::ColorSpace& color_space); |
331 | 338 |
332 // Returns the output video frame dimensions (width, height). | 339 // Returns the output video frame dimensions (width, height). |
333 // |sample| :- This is the output sample containing the video frame. | 340 // |sample| :- This is the output sample containing the video frame. |
334 // |width| :- The width is returned here. | 341 // |width| :- The width is returned here. |
335 // |height| :- The height is returned here. | 342 // |height| :- The height is returned here. |
336 // Returns true on success. | 343 // Returns true on success. |
337 bool GetVideoFrameDimensions(IMFSample* sample, int* width, int* height); | 344 bool GetVideoFrameDimensions(IMFSample* sample, int* width, int* height); |
338 | 345 |
339 // Sets the output type on the |transform| to the GUID identified by the | 346 // Sets the output type on the |transform| to the GUID identified by the |
340 // the |output_type| parameter. The GUID can be MFVideoFormat_RGB32, | 347 // the |output_type| parameter. The GUID can be MFVideoFormat_RGB32, |
(...skipping 29 matching lines...) Expand all Loading... |
370 base::win::ScopedComPtr<IDirect3DDeviceManager9> device_manager_; | 377 base::win::ScopedComPtr<IDirect3DDeviceManager9> device_manager_; |
371 base::win::ScopedComPtr<IDirect3DQuery9> query_; | 378 base::win::ScopedComPtr<IDirect3DQuery9> query_; |
372 | 379 |
373 base::win::ScopedComPtr<ID3D11Device> d3d11_device_; | 380 base::win::ScopedComPtr<ID3D11Device> d3d11_device_; |
374 base::win::ScopedComPtr<ID3D11Device> angle_device_; | 381 base::win::ScopedComPtr<ID3D11Device> angle_device_; |
375 base::win::ScopedComPtr<IMFDXGIDeviceManager> d3d11_device_manager_; | 382 base::win::ScopedComPtr<IMFDXGIDeviceManager> d3d11_device_manager_; |
376 base::win::ScopedComPtr<ID3D10Multithread> multi_threaded_; | 383 base::win::ScopedComPtr<ID3D10Multithread> multi_threaded_; |
377 base::win::ScopedComPtr<ID3D11DeviceContext> d3d11_device_context_; | 384 base::win::ScopedComPtr<ID3D11DeviceContext> d3d11_device_context_; |
378 base::win::ScopedComPtr<ID3D11Query> d3d11_query_; | 385 base::win::ScopedComPtr<ID3D11Query> d3d11_query_; |
379 | 386 |
| 387 base::win::ScopedComPtr<IDirectXVideoProcessorService> |
| 388 video_processor_service_; |
| 389 base::win::ScopedComPtr<IDirectXVideoProcessor> processor_; |
| 390 DXVA2_ProcAmpValues default_procamp_values_; |
| 391 |
380 // Ideally the reset token would be a stack variable which is used while | 392 // Ideally the reset token would be a stack variable which is used while |
381 // creating the device manager. However it seems that the device manager | 393 // creating the device manager. However it seems that the device manager |
382 // holds onto the token and attempts to access it if the underlying device | 394 // holds onto the token and attempts to access it if the underlying device |
383 // changes. | 395 // changes. |
384 // TODO(ananta): This needs to be verified. | 396 // TODO(ananta): This needs to be verified. |
385 uint32_t dev_manager_reset_token_; | 397 uint32_t dev_manager_reset_token_; |
386 | 398 |
387 // Reset token for the DX11 device manager. | 399 // Reset token for the DX11 device manager. |
388 uint32_t dx11_dev_manager_reset_token_; | 400 uint32_t dx11_dev_manager_reset_token_; |
389 | 401 |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
481 bool pending_flush_; | 493 bool pending_flush_; |
482 | 494 |
483 // Use CODECAPI_AVLowLatencyMode. | 495 // Use CODECAPI_AVLowLatencyMode. |
484 bool enable_low_latency_; | 496 bool enable_low_latency_; |
485 | 497 |
486 bool share_nv12_textures_; | 498 bool share_nv12_textures_; |
487 | 499 |
488 // Copy NV12 texture to another NV12 texture. | 500 // Copy NV12 texture to another NV12 texture. |
489 bool copy_nv12_textures_; | 501 bool copy_nv12_textures_; |
490 | 502 |
| 503 // When converting YUV to RGB, make sure we tell the blitter about the input |
| 504 // color space so that it can convert it correctly. |
| 505 bool use_color_info_ = true; |
| 506 |
491 // Defaults to false. Indicates if we should use D3D or DX11 interfaces for | 507 // Defaults to false. Indicates if we should use D3D or DX11 interfaces for |
492 // H/W decoding. | 508 // H/W decoding. |
493 bool use_dx11_; | 509 bool use_dx11_; |
494 | 510 |
495 // True when using Microsoft's VP9 HMFT for decoding. | 511 // True when using Microsoft's VP9 HMFT for decoding. |
496 bool using_ms_vp9_mft_ = false; | 512 bool using_ms_vp9_mft_ = false; |
497 | 513 |
498 // True if we should use DXGI keyed mutexes to synchronize between the two | 514 // True if we should use DXGI keyed mutexes to synchronize between the two |
499 // contexts. | 515 // contexts. |
500 bool use_keyed_mutex_; | 516 bool use_keyed_mutex_; |
(...skipping 26 matching lines...) Expand all Loading... |
527 | 543 |
528 // Function pointer for the MFCreateDXGIDeviceManager API. | 544 // Function pointer for the MFCreateDXGIDeviceManager API. |
529 static CreateDXGIDeviceManager create_dxgi_device_manager_; | 545 static CreateDXGIDeviceManager create_dxgi_device_manager_; |
530 | 546 |
531 DISALLOW_COPY_AND_ASSIGN(DXVAVideoDecodeAccelerator); | 547 DISALLOW_COPY_AND_ASSIGN(DXVAVideoDecodeAccelerator); |
532 }; | 548 }; |
533 | 549 |
534 } // namespace media | 550 } // namespace media |
535 | 551 |
536 #endif // MEDIA_GPU_DXVA_VIDEO_DECODE_ACCELERATOR_WIN_H_ | 552 #endif // MEDIA_GPU_DXVA_VIDEO_DECODE_ACCELERATOR_WIN_H_ |
OLD | NEW |