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 12 matching lines...) Expand all Loading... |
54 enum State { | 55 enum State { |
55 kUninitialized, // un-initialized. | 56 kUninitialized, // un-initialized. |
56 kNormal, // normal playing state. | 57 kNormal, // normal playing state. |
57 kResetting, // upon received Reset(), before ResetDone() | 58 kResetting, // upon received Reset(), before ResetDone() |
58 kStopped, // upon output EOS received. | 59 kStopped, // upon output EOS received. |
59 kFlushing, // upon flush request received. | 60 kFlushing, // upon flush request received. |
60 }; | 61 }; |
61 | 62 |
62 // Does not take ownership of |client| which must outlive |*this|. | 63 // Does not take ownership of |client| which must outlive |*this|. |
63 DXVAVideoDecodeAccelerator( | 64 DXVAVideoDecodeAccelerator( |
64 const base::Callback<bool(void)>& make_context_current, | 65 const GetGLContextCallback& get_gl_context_cb, |
65 gfx::GLContext* gl_context, | 66 const MakeGLContextCurrentCallback& make_context_current_cb, |
66 bool enable_accelerated_vpx_decode); | 67 bool enable_accelerated_vpx_decode); |
67 ~DXVAVideoDecodeAccelerator() override; | 68 ~DXVAVideoDecodeAccelerator() override; |
68 | 69 |
69 // media::VideoDecodeAccelerator implementation. | 70 // media::VideoDecodeAccelerator implementation. |
70 bool Initialize(const Config& config, Client* client) override; | 71 bool Initialize(const Config& config, Client* client) override; |
71 void Decode(const media::BitstreamBuffer& bitstream_buffer) override; | 72 void Decode(const media::BitstreamBuffer& bitstream_buffer) override; |
72 void AssignPictureBuffers( | 73 void AssignPictureBuffers( |
73 const std::vector<media::PictureBuffer>& buffers) override; | 74 const std::vector<media::PictureBuffer>& buffers) override; |
74 void ReusePictureBuffer(int32_t picture_buffer_id) override; | 75 void ReusePictureBuffer(int32_t picture_buffer_id) override; |
75 void Flush() override; | 76 void Flush() override; |
76 void Reset() override; | 77 void Reset() override; |
77 void Destroy() override; | 78 void Destroy() override; |
78 bool CanDecodeOnIOThread() override; | 79 bool TryToSetupDecodeOnSeparateThread( |
| 80 const base::WeakPtr<Client>& decode_client, |
| 81 const scoped_refptr<base::SingleThreadTaskRunner>& decode_task_runner) |
| 82 override; |
79 GLenum GetSurfaceInternalFormat() const override; | 83 GLenum GetSurfaceInternalFormat() const override; |
80 | 84 |
81 static media::VideoDecodeAccelerator::SupportedProfiles | 85 static media::VideoDecodeAccelerator::SupportedProfiles |
82 GetSupportedProfiles(); | 86 GetSupportedProfiles(); |
83 | 87 |
84 // Preload dlls required for decoding. | 88 // Preload dlls required for decoding. |
85 static void PreSandboxInitialization(); | 89 static void PreSandboxInitialization(); |
86 | 90 |
87 private: | 91 private: |
88 typedef void* EGLConfig; | 92 typedef void* EGLConfig; |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
340 | 344 |
341 // Set to true when the drain message is sent to the decoder during a flush | 345 // Set to true when the drain message is sent to the decoder during a flush |
342 // operation. Used to ensure the message is only sent once after | 346 // operation. Used to ensure the message is only sent once after |
343 // |pending_input_buffers_| is drained. Protected by |decoder_lock_|. | 347 // |pending_input_buffers_| is drained. Protected by |decoder_lock_|. |
344 bool sent_drain_message_; | 348 bool sent_drain_message_; |
345 | 349 |
346 // List of input samples waiting to be processed. | 350 // List of input samples waiting to be processed. |
347 typedef std::list<base::win::ScopedComPtr<IMFSample>> PendingInputs; | 351 typedef std::list<base::win::ScopedComPtr<IMFSample>> PendingInputs; |
348 PendingInputs pending_input_buffers_; | 352 PendingInputs pending_input_buffers_; |
349 | 353 |
| 354 // Callback to get current GLContext. |
| 355 GetGLContextCallback get_gl_context_cb_; |
350 // Callback to set the correct gl context. | 356 // Callback to set the correct gl context. |
351 base::Callback<bool(void)> make_context_current_; | 357 MakeGLContextCurrentCallback make_context_current_cb_; |
352 | 358 |
353 // Which codec we are decoding with hardware acceleration. | 359 // Which codec we are decoding with hardware acceleration. |
354 media::VideoCodec codec_; | 360 media::VideoCodec codec_; |
355 // Thread on which the decoder operations like passing input frames, | 361 // Thread on which the decoder operations like passing input frames, |
356 // getting output frames are performed. One instance of this thread | 362 // getting output frames are performed. One instance of this thread |
357 // is created per decoder instance. | 363 // is created per decoder instance. |
358 base::Thread decoder_thread_; | 364 base::Thread decoder_thread_; |
359 | 365 |
360 // Task runner to be used for posting tasks to the decoder thread. | 366 // Task runner to be used for posting tasks to the decoder thread. |
361 scoped_refptr<base::SingleThreadTaskRunner> decoder_thread_task_runner_; | 367 scoped_refptr<base::SingleThreadTaskRunner> decoder_thread_task_runner_; |
(...skipping 19 matching lines...) Expand all Loading... |
381 bool use_dx11_; | 387 bool use_dx11_; |
382 | 388 |
383 // True if we should use DXGI keyed mutexes to synchronize between the two | 389 // True if we should use DXGI keyed mutexes to synchronize between the two |
384 // contexts. | 390 // contexts. |
385 bool use_keyed_mutex_; | 391 bool use_keyed_mutex_; |
386 | 392 |
387 // Set to true if the DX11 video format converter input media types need to | 393 // Set to true if the DX11 video format converter input media types need to |
388 // be initialized. Defaults to true. | 394 // be initialized. Defaults to true. |
389 bool dx11_video_format_converter_media_type_needs_init_; | 395 bool dx11_video_format_converter_media_type_needs_init_; |
390 | 396 |
391 // The GLContext to be used by the decoder. | |
392 scoped_refptr<gfx::GLContext> gl_context_; | |
393 | |
394 // Set to true if we are sharing ANGLE's device. | 397 // Set to true if we are sharing ANGLE's device. |
395 bool using_angle_device_; | 398 bool using_angle_device_; |
396 | 399 |
397 // Enables experimental hardware acceleration for VP8/VP9 video decoding. | 400 // Enables experimental hardware acceleration for VP8/VP9 video decoding. |
398 const bool enable_accelerated_vpx_decode_; | 401 const bool enable_accelerated_vpx_decode_; |
399 | 402 |
400 // WeakPtrFactory for posting tasks back to |this|. | 403 // WeakPtrFactory for posting tasks back to |this|. |
401 base::WeakPtrFactory<DXVAVideoDecodeAccelerator> weak_this_factory_; | 404 base::WeakPtrFactory<DXVAVideoDecodeAccelerator> weak_this_factory_; |
402 | 405 |
403 // Function pointer for the MFCreateDXGIDeviceManager API. | 406 // Function pointer for the MFCreateDXGIDeviceManager API. |
404 static CreateDXGIDeviceManager create_dxgi_device_manager_; | 407 static CreateDXGIDeviceManager create_dxgi_device_manager_; |
405 | 408 |
406 DISALLOW_COPY_AND_ASSIGN(DXVAVideoDecodeAccelerator); | 409 DISALLOW_COPY_AND_ASSIGN(DXVAVideoDecodeAccelerator); |
407 }; | 410 }; |
408 | 411 |
409 } // namespace content | 412 } // namespace content |
410 | 413 |
411 #endif // CONTENT_COMMON_GPU_MEDIA_DXVA_VIDEO_DECODE_ACCELERATOR_H_ | 414 #endif // CONTENT_COMMON_GPU_MEDIA_DXVA_VIDEO_DECODE_ACCELERATOR_H_ |
OLD | NEW |