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_1.h> | 8 #include <d3d11.h> |
9 #include <d3d9.h> | 9 #include <d3d9.h> |
10 #include <initguid.h> | 10 #include <initguid.h> |
11 #include <stdint.h> | 11 #include <stdint.h> |
12 | 12 |
13 // Work around bug in this header by disabling the relevant warning for it. | 13 // Work around bug in this header by disabling the relevant warning for it. |
14 // https://connect.microsoft.com/VisualStudio/feedback/details/911260/dxva2api-h
-in-win8-sdk-triggers-c4201-with-w4 | 14 // https://connect.microsoft.com/VisualStudio/feedback/details/911260/dxva2api-h
-in-win8-sdk-triggers-c4201-with-w4 |
15 #pragma warning(push) | 15 #pragma warning(push) |
16 #pragma warning(disable : 4201) | 16 #pragma warning(disable : 4201) |
17 #include <dxva2api.h> | 17 #include <dxva2api.h> |
18 #pragma warning(pop) | 18 #pragma warning(pop) |
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 uint64_t keyed_mutex_value, | 310 uint64_t keyed_mutex_value, |
311 int picture_buffer_id, | 311 int picture_buffer_id, |
312 int input_buffer_id, | 312 int input_buffer_id, |
313 const gfx::ColorSpace& color_space); | 313 const gfx::ColorSpace& color_space); |
314 | 314 |
315 // Copies the |video_frame| to the destination |dest_texture|. | 315 // Copies the |video_frame| to the destination |dest_texture|. |
316 void CopyTextureOnDecoderThread( | 316 void CopyTextureOnDecoderThread( |
317 ID3D11Texture2D* dest_texture, | 317 ID3D11Texture2D* dest_texture, |
318 base::win::ScopedComPtr<IDXGIKeyedMutex> dest_keyed_mutex, | 318 base::win::ScopedComPtr<IDXGIKeyedMutex> dest_keyed_mutex, |
319 uint64_t keyed_mutex_value, | 319 uint64_t keyed_mutex_value, |
320 base::win::ScopedComPtr<IMFSample> input_sample, | 320 base::win::ScopedComPtr<IMFSample> video_frame, |
321 int picture_buffer_id, | 321 int picture_buffer_id, |
322 int input_buffer_id); | 322 int input_buffer_id); |
323 | 323 |
324 // Flushes the decoder device to ensure that the decoded surface is copied | 324 // Flushes the decoder device to ensure that the decoded surface is copied |
325 // to the target surface. |iterations| helps to maintain an upper limit on | 325 // to the target surface. |iterations| helps to maintain an upper limit on |
326 // the number of times we try to complete the flush operation. | 326 // the number of times we try to complete the flush operation. |
327 void FlushDecoder(int iterations, | 327 void FlushDecoder(int iterations, |
328 IDirect3DSurface9* src_surface, | 328 IDirect3DSurface9* src_surface, |
329 IDirect3DSurface9* dest_surface, | 329 IDirect3DSurface9* dest_surface, |
330 int picture_buffer_id, | 330 int picture_buffer_id, |
331 int input_buffer_id); | 331 int input_buffer_id); |
332 | 332 |
333 // Polls to wait for GPU commands to be finished on the picture buffer | 333 // Polls to wait for GPU commands to be finished on the picture buffer |
334 // before reusing it. | 334 // before reusing it. |
335 void WaitForOutputBuffer(int32_t picture_buffer_id, int count); | 335 void WaitForOutputBuffer(int32_t picture_buffer_id, int count); |
336 | 336 |
337 // Initialize the DX11 video processor. | 337 // Initializes the DX11 Video format converter media types. |
338 // Returns true on success. | 338 // Returns true on success. |
339 bool InitializeID3D11VideoProcessor(int width, | 339 bool InitializeDX11VideoFormatConverterMediaType( |
340 int height, | 340 int width, |
341 const gfx::ColorSpace& color_space); | 341 int height, |
| 342 const gfx::ColorSpace& color_space); |
342 | 343 |
343 // Returns the output video frame dimensions (width, height). | 344 // Returns the output video frame dimensions (width, height). |
344 // |sample| :- This is the output sample containing the video frame. | 345 // |sample| :- This is the output sample containing the video frame. |
345 // |width| :- The width is returned here. | 346 // |width| :- The width is returned here. |
346 // |height| :- The height is returned here. | 347 // |height| :- The height is returned here. |
347 // Returns true on success. | 348 // Returns true on success. |
348 bool GetVideoFrameDimensions(IMFSample* sample, int* width, int* height); | 349 bool GetVideoFrameDimensions(IMFSample* sample, int* width, int* height); |
349 | 350 |
350 // Sets the output type on the |transform| to the GUID identified by the | 351 // Sets the output type on the |transform| to the GUID identified by the |
351 // the |output_type| parameter. The GUID can be MFVideoFormat_RGB32, | 352 // the |output_type| parameter. The GUID can be MFVideoFormat_RGB32, |
(...skipping 17 matching lines...) Expand all Loading... |
369 // Called when we detect a stream configuration change. We reinitialize the | 370 // Called when we detect a stream configuration change. We reinitialize the |
370 // decoder here. | 371 // decoder here. |
371 void ConfigChanged(const Config& config); | 372 void ConfigChanged(const Config& config); |
372 | 373 |
373 uint32_t GetTextureTarget() const; | 374 uint32_t GetTextureTarget() const; |
374 | 375 |
375 // To expose client callbacks from VideoDecodeAccelerator. | 376 // To expose client callbacks from VideoDecodeAccelerator. |
376 VideoDecodeAccelerator::Client* client_; | 377 VideoDecodeAccelerator::Client* client_; |
377 | 378 |
378 base::win::ScopedComPtr<IMFTransform> decoder_; | 379 base::win::ScopedComPtr<IMFTransform> decoder_; |
| 380 base::win::ScopedComPtr<IMFTransform> video_format_converter_mft_; |
379 | 381 |
380 base::win::ScopedComPtr<IDirect3D9Ex> d3d9_; | 382 base::win::ScopedComPtr<IDirect3D9Ex> d3d9_; |
381 base::win::ScopedComPtr<IDirect3DDevice9Ex> d3d9_device_ex_; | 383 base::win::ScopedComPtr<IDirect3DDevice9Ex> d3d9_device_ex_; |
382 base::win::ScopedComPtr<IDirect3DDeviceManager9> device_manager_; | 384 base::win::ScopedComPtr<IDirect3DDeviceManager9> device_manager_; |
383 base::win::ScopedComPtr<IDirect3DQuery9> query_; | 385 base::win::ScopedComPtr<IDirect3DQuery9> query_; |
384 | 386 |
385 base::win::ScopedComPtr<ID3D11Device> d3d11_device_; | 387 base::win::ScopedComPtr<ID3D11Device> d3d11_device_; |
386 base::win::ScopedComPtr<ID3D11Device> angle_device_; | 388 base::win::ScopedComPtr<ID3D11Device> angle_device_; |
387 base::win::ScopedComPtr<IMFDXGIDeviceManager> d3d11_device_manager_; | 389 base::win::ScopedComPtr<IMFDXGIDeviceManager> d3d11_device_manager_; |
388 base::win::ScopedComPtr<ID3D10Multithread> multi_threaded_; | 390 base::win::ScopedComPtr<ID3D10Multithread> multi_threaded_; |
389 base::win::ScopedComPtr<ID3D11DeviceContext> d3d11_device_context_; | 391 base::win::ScopedComPtr<ID3D11DeviceContext> d3d11_device_context_; |
390 base::win::ScopedComPtr<ID3D11Query> d3d11_query_; | 392 base::win::ScopedComPtr<ID3D11Query> d3d11_query_; |
391 | 393 |
392 base::win::ScopedComPtr<ID3D11VideoDevice> video_device_; | |
393 base::win::ScopedComPtr<ID3D11VideoContext> video_context_; | |
394 base::win::ScopedComPtr<ID3D11VideoProcessorEnumerator> enumerator_; | |
395 base::win::ScopedComPtr<ID3D11VideoProcessor> d3d11_processor_; | |
396 | |
397 int processor_width_ = 0; | |
398 int processor_height_ = 0; | |
399 | |
400 base::win::ScopedComPtr<IDirectXVideoProcessorService> | 394 base::win::ScopedComPtr<IDirectXVideoProcessorService> |
401 video_processor_service_; | 395 video_processor_service_; |
402 base::win::ScopedComPtr<IDirectXVideoProcessor> processor_; | 396 base::win::ScopedComPtr<IDirectXVideoProcessor> processor_; |
403 DXVA2_ProcAmpValues default_procamp_values_; | 397 DXVA2_ProcAmpValues default_procamp_values_; |
404 | 398 |
405 // Ideally the reset token would be a stack variable which is used while | 399 // Ideally the reset token would be a stack variable which is used while |
406 // creating the device manager. However it seems that the device manager | 400 // creating the device manager. However it seems that the device manager |
407 // holds onto the token and attempts to access it if the underlying device | 401 // holds onto the token and attempts to access it if the underlying device |
408 // changes. | 402 // changes. |
409 // TODO(ananta): This needs to be verified. | 403 // TODO(ananta): This needs to be verified. |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
525 // H/W decoding. | 519 // H/W decoding. |
526 bool use_dx11_; | 520 bool use_dx11_; |
527 | 521 |
528 // True when using Microsoft's VP9 HMFT for decoding. | 522 // True when using Microsoft's VP9 HMFT for decoding. |
529 bool using_ms_vp9_mft_ = false; | 523 bool using_ms_vp9_mft_ = false; |
530 | 524 |
531 // True if we should use DXGI keyed mutexes to synchronize between the two | 525 // True if we should use DXGI keyed mutexes to synchronize between the two |
532 // contexts. | 526 // contexts. |
533 bool use_keyed_mutex_; | 527 bool use_keyed_mutex_; |
534 | 528 |
| 529 // Set to true if the DX11 video format converter input media types need to |
| 530 // be initialized. Defaults to true. |
| 531 bool dx11_video_format_converter_media_type_needs_init_; |
| 532 |
535 // Color spaced used when initializing the dx11 format converter. | 533 // Color spaced used when initializing the dx11 format converter. |
536 gfx::ColorSpace dx11_converter_color_space_; | 534 gfx::ColorSpace dx11_converter_color_space_; |
537 | 535 |
538 // Set to true if we are sharing ANGLE's device. | 536 // Set to true if we are sharing ANGLE's device. |
539 bool using_angle_device_; | 537 bool using_angle_device_; |
540 | 538 |
541 // Enables experimental hardware acceleration for VP8/VP9 video decoding. | 539 // Enables experimental hardware acceleration for VP8/VP9 video decoding. |
542 const gpu::GpuPreferences::VpxDecodeVendors enable_accelerated_vpx_decode_; | 540 const gpu::GpuPreferences::VpxDecodeVendors enable_accelerated_vpx_decode_; |
543 | 541 |
544 // The media foundation H.264 decoder has problems handling changes like | 542 // The media foundation H.264 decoder has problems handling changes like |
(...skipping 14 matching lines...) Expand all Loading... |
559 | 557 |
560 // Function pointer for the MFCreateDXGIDeviceManager API. | 558 // Function pointer for the MFCreateDXGIDeviceManager API. |
561 static CreateDXGIDeviceManager create_dxgi_device_manager_; | 559 static CreateDXGIDeviceManager create_dxgi_device_manager_; |
562 | 560 |
563 DISALLOW_COPY_AND_ASSIGN(DXVAVideoDecodeAccelerator); | 561 DISALLOW_COPY_AND_ASSIGN(DXVAVideoDecodeAccelerator); |
564 }; | 562 }; |
565 | 563 |
566 } // namespace media | 564 } // namespace media |
567 | 565 |
568 #endif // MEDIA_GPU_DXVA_VIDEO_DECODE_ACCELERATOR_WIN_H_ | 566 #endif // MEDIA_GPU_DXVA_VIDEO_DECODE_ACCELERATOR_WIN_H_ |
OLD | NEW |