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