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