| 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 CONTENT_COMMON_GPU_MEDIA_DXVA_VIDEO_DECODE_ACCELERATOR_H_ | 5 #ifndef CONTENT_COMMON_GPU_MEDIA_DXVA_VIDEO_DECODE_ACCELERATOR_H_ |
| 6 #define CONTENT_COMMON_GPU_MEDIA_DXVA_VIDEO_DECODE_ACCELERATOR_H_ | 6 #define CONTENT_COMMON_GPU_MEDIA_DXVA_VIDEO_DECODE_ACCELERATOR_H_ |
| 7 | 7 |
| 8 #include <d3d11.h> | 8 #include <d3d11.h> |
| 9 #include <d3d9.h> | 9 #include <d3d9.h> |
| 10 #include <stdint.h> | 10 #include <stdint.h> |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 | 22 |
| 23 #include "base/compiler_specific.h" | 23 #include "base/compiler_specific.h" |
| 24 #include "base/macros.h" | 24 #include "base/macros.h" |
| 25 #include "base/memory/linked_ptr.h" | 25 #include "base/memory/linked_ptr.h" |
| 26 #include "base/memory/weak_ptr.h" | 26 #include "base/memory/weak_ptr.h" |
| 27 #include "base/synchronization/lock.h" | 27 #include "base/synchronization/lock.h" |
| 28 #include "base/threading/non_thread_safe.h" | 28 #include "base/threading/non_thread_safe.h" |
| 29 #include "base/threading/thread.h" | 29 #include "base/threading/thread.h" |
| 30 #include "base/win/scoped_comptr.h" | 30 #include "base/win/scoped_comptr.h" |
| 31 #include "content/common/content_export.h" | 31 #include "content/common/content_export.h" |
| 32 #include "content/common/gpu/media/gpu_video_decode_accelerator_helpers.h" | |
| 33 #include "media/video/video_decode_accelerator.h" | 32 #include "media/video/video_decode_accelerator.h" |
| 34 | 33 |
| 35 interface IMFSample; | 34 interface IMFSample; |
| 36 interface IDirect3DSurface9; | 35 interface IDirect3DSurface9; |
| 37 | 36 |
| 38 namespace gfx { | 37 namespace gfx { |
| 39 class GLContext; | 38 class GLContext; |
| 40 } | 39 } |
| 41 | 40 |
| 42 typedef HRESULT (WINAPI* CreateDXGIDeviceManager)( | 41 typedef HRESULT (WINAPI* CreateDXGIDeviceManager)( |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 kUninitialized, // un-initialized. | 90 kUninitialized, // un-initialized. |
| 92 kNormal, // normal playing state. | 91 kNormal, // normal playing state. |
| 93 kResetting, // upon received Reset(), before ResetDone() | 92 kResetting, // upon received Reset(), before ResetDone() |
| 94 kStopped, // upon output EOS received. | 93 kStopped, // upon output EOS received. |
| 95 kFlushing, // upon flush request received. | 94 kFlushing, // upon flush request received. |
| 96 kConfigChange, // stream configuration change detected. | 95 kConfigChange, // stream configuration change detected. |
| 97 }; | 96 }; |
| 98 | 97 |
| 99 // Does not take ownership of |client| which must outlive |*this|. | 98 // Does not take ownership of |client| which must outlive |*this|. |
| 100 DXVAVideoDecodeAccelerator( | 99 DXVAVideoDecodeAccelerator( |
| 101 const GetGLContextCallback& get_gl_context_cb, | 100 const base::Callback<bool(void)>& make_context_current, |
| 102 const MakeGLContextCurrentCallback& make_context_current_cb, | 101 gfx::GLContext* gl_context, |
| 103 bool enable_accelerated_vpx_decode); | 102 bool enable_accelerated_vpx_decode); |
| 104 ~DXVAVideoDecodeAccelerator() override; | 103 ~DXVAVideoDecodeAccelerator() override; |
| 105 | 104 |
| 106 // media::VideoDecodeAccelerator implementation. | 105 // media::VideoDecodeAccelerator implementation. |
| 107 bool Initialize(const Config& config, Client* client) override; | 106 bool Initialize(const Config& config, Client* client) override; |
| 108 void Decode(const media::BitstreamBuffer& bitstream_buffer) override; | 107 void Decode(const media::BitstreamBuffer& bitstream_buffer) override; |
| 109 void AssignPictureBuffers( | 108 void AssignPictureBuffers( |
| 110 const std::vector<media::PictureBuffer>& buffers) override; | 109 const std::vector<media::PictureBuffer>& buffers) override; |
| 111 void ReusePictureBuffer(int32_t picture_buffer_id) override; | 110 void ReusePictureBuffer(int32_t picture_buffer_id) override; |
| 112 void Flush() override; | 111 void Flush() override; |
| 113 void Reset() override; | 112 void Reset() override; |
| 114 void Destroy() override; | 113 void Destroy() override; |
| 115 bool TryToSetupDecodeOnSeparateThread( | 114 bool CanDecodeOnIOThread() override; |
| 116 const base::WeakPtr<Client>& decode_client, | |
| 117 const scoped_refptr<base::SingleThreadTaskRunner>& decode_task_runner) | |
| 118 override; | |
| 119 GLenum GetSurfaceInternalFormat() const override; | 115 GLenum GetSurfaceInternalFormat() const override; |
| 120 | 116 |
| 121 static media::VideoDecodeAccelerator::SupportedProfiles | 117 static media::VideoDecodeAccelerator::SupportedProfiles |
| 122 GetSupportedProfiles(); | 118 GetSupportedProfiles(); |
| 123 | 119 |
| 124 // Preload dlls required for decoding. | 120 // Preload dlls required for decoding. |
| 125 static void PreSandboxInitialization(); | 121 static void PreSandboxInitialization(); |
| 126 | 122 |
| 127 private: | 123 private: |
| 128 typedef void* EGLConfig; | 124 typedef void* EGLConfig; |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 | 384 |
| 389 // Set to true when the drain message is sent to the decoder during a flush | 385 // Set to true when the drain message is sent to the decoder during a flush |
| 390 // operation. Used to ensure the message is only sent once after | 386 // operation. Used to ensure the message is only sent once after |
| 391 // |pending_input_buffers_| is drained. Protected by |decoder_lock_|. | 387 // |pending_input_buffers_| is drained. Protected by |decoder_lock_|. |
| 392 bool sent_drain_message_; | 388 bool sent_drain_message_; |
| 393 | 389 |
| 394 // List of input samples waiting to be processed. | 390 // List of input samples waiting to be processed. |
| 395 typedef std::list<base::win::ScopedComPtr<IMFSample>> PendingInputs; | 391 typedef std::list<base::win::ScopedComPtr<IMFSample>> PendingInputs; |
| 396 PendingInputs pending_input_buffers_; | 392 PendingInputs pending_input_buffers_; |
| 397 | 393 |
| 398 // Callback to get current GLContext. | |
| 399 GetGLContextCallback get_gl_context_cb_; | |
| 400 // Callback to set the correct gl context. | 394 // Callback to set the correct gl context. |
| 401 MakeGLContextCurrentCallback make_context_current_cb_; | 395 base::Callback<bool(void)> make_context_current_; |
| 402 | 396 |
| 403 // Which codec we are decoding with hardware acceleration. | 397 // Which codec we are decoding with hardware acceleration. |
| 404 media::VideoCodec codec_; | 398 media::VideoCodec codec_; |
| 405 // Thread on which the decoder operations like passing input frames, | 399 // Thread on which the decoder operations like passing input frames, |
| 406 // getting output frames are performed. One instance of this thread | 400 // getting output frames are performed. One instance of this thread |
| 407 // is created per decoder instance. | 401 // is created per decoder instance. |
| 408 base::Thread decoder_thread_; | 402 base::Thread decoder_thread_; |
| 409 | 403 |
| 410 // Task runner to be used for posting tasks to the decoder thread. | 404 // Task runner to be used for posting tasks to the decoder thread. |
| 411 scoped_refptr<base::SingleThreadTaskRunner> decoder_thread_task_runner_; | 405 scoped_refptr<base::SingleThreadTaskRunner> decoder_thread_task_runner_; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 431 bool use_dx11_; | 425 bool use_dx11_; |
| 432 | 426 |
| 433 // True if we should use DXGI keyed mutexes to synchronize between the two | 427 // True if we should use DXGI keyed mutexes to synchronize between the two |
| 434 // contexts. | 428 // contexts. |
| 435 bool use_keyed_mutex_; | 429 bool use_keyed_mutex_; |
| 436 | 430 |
| 437 // Set to true if the DX11 video format converter input media types need to | 431 // Set to true if the DX11 video format converter input media types need to |
| 438 // be initialized. Defaults to true. | 432 // be initialized. Defaults to true. |
| 439 bool dx11_video_format_converter_media_type_needs_init_; | 433 bool dx11_video_format_converter_media_type_needs_init_; |
| 440 | 434 |
| 435 // The GLContext to be used by the decoder. |
| 436 scoped_refptr<gfx::GLContext> gl_context_; |
| 437 |
| 441 // Set to true if we are sharing ANGLE's device. | 438 // Set to true if we are sharing ANGLE's device. |
| 442 bool using_angle_device_; | 439 bool using_angle_device_; |
| 443 | 440 |
| 444 // Enables experimental hardware acceleration for VP8/VP9 video decoding. | 441 // Enables experimental hardware acceleration for VP8/VP9 video decoding. |
| 445 const bool enable_accelerated_vpx_decode_; | 442 const bool enable_accelerated_vpx_decode_; |
| 446 | 443 |
| 447 // The media foundation H.264 decoder has problems handling changes like | 444 // The media foundation H.264 decoder has problems handling changes like |
| 448 // resolution change, bitrate change etc. If we reinitialize the decoder | 445 // resolution change, bitrate change etc. If we reinitialize the decoder |
| 449 // when these changes occur then, the decoder works fine. The | 446 // when these changes occur then, the decoder works fine. The |
| 450 // H264ConfigChangeDetector class provides functionality to check if the | 447 // H264ConfigChangeDetector class provides functionality to check if the |
| 451 // stream configuration changed. | 448 // stream configuration changed. |
| 452 H264ConfigChangeDetector config_change_detector_; | 449 H264ConfigChangeDetector config_change_detector_; |
| 453 | 450 |
| 454 // Contains the initialization parameters for the video. | 451 // Contains the initialization parameters for the video. |
| 455 Config config_; | 452 Config config_; |
| 456 | 453 |
| 457 // WeakPtrFactory for posting tasks back to |this|. | 454 // WeakPtrFactory for posting tasks back to |this|. |
| 458 base::WeakPtrFactory<DXVAVideoDecodeAccelerator> weak_this_factory_; | 455 base::WeakPtrFactory<DXVAVideoDecodeAccelerator> weak_this_factory_; |
| 459 | 456 |
| 460 // Function pointer for the MFCreateDXGIDeviceManager API. | 457 // Function pointer for the MFCreateDXGIDeviceManager API. |
| 461 static CreateDXGIDeviceManager create_dxgi_device_manager_; | 458 static CreateDXGIDeviceManager create_dxgi_device_manager_; |
| 462 | 459 |
| 463 DISALLOW_COPY_AND_ASSIGN(DXVAVideoDecodeAccelerator); | 460 DISALLOW_COPY_AND_ASSIGN(DXVAVideoDecodeAccelerator); |
| 464 }; | 461 }; |
| 465 | 462 |
| 466 } // namespace content | 463 } // namespace content |
| 467 | 464 |
| 468 #endif // CONTENT_COMMON_GPU_MEDIA_DXVA_VIDEO_DECODE_ACCELERATOR_H_ | 465 #endif // CONTENT_COMMON_GPU_MEDIA_DXVA_VIDEO_DECODE_ACCELERATOR_H_ |
| OLD | NEW |