Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(136)

Side by Side Diff: content/common/gpu/media/dxva_video_decode_accelerator_win.h

Issue 1839193003: Reland: Introduce GpuVideoDecodeAcceleratorFactory. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <initguid.h> 10 #include <initguid.h>
(...skipping 12 matching lines...) Expand all
23 23
24 #include "base/compiler_specific.h" 24 #include "base/compiler_specific.h"
25 #include "base/macros.h" 25 #include "base/macros.h"
26 #include "base/memory/linked_ptr.h" 26 #include "base/memory/linked_ptr.h"
27 #include "base/memory/weak_ptr.h" 27 #include "base/memory/weak_ptr.h"
28 #include "base/synchronization/lock.h" 28 #include "base/synchronization/lock.h"
29 #include "base/threading/non_thread_safe.h" 29 #include "base/threading/non_thread_safe.h"
30 #include "base/threading/thread.h" 30 #include "base/threading/thread.h"
31 #include "base/win/scoped_comptr.h" 31 #include "base/win/scoped_comptr.h"
32 #include "content/common/content_export.h" 32 #include "content/common/content_export.h"
33 #include "content/common/gpu/media/gpu_video_decode_accelerator_helpers.h"
33 #include "media/filters/h264_parser.h" 34 #include "media/filters/h264_parser.h"
34 #include "media/video/video_decode_accelerator.h" 35 #include "media/video/video_decode_accelerator.h"
35 36
36 interface IMFSample; 37 interface IMFSample;
37 interface IDirect3DSurface9; 38 interface IDirect3DSurface9;
38 39
39 namespace gfx { 40 namespace gfx {
40 class GLContext; 41 class GLContext;
41 } 42 }
42 43
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 kUninitialized, // un-initialized. 95 kUninitialized, // un-initialized.
95 kNormal, // normal playing state. 96 kNormal, // normal playing state.
96 kResetting, // upon received Reset(), before ResetDone() 97 kResetting, // upon received Reset(), before ResetDone()
97 kStopped, // upon output EOS received. 98 kStopped, // upon output EOS received.
98 kFlushing, // upon flush request received. 99 kFlushing, // upon flush request received.
99 kConfigChange, // stream configuration change detected. 100 kConfigChange, // stream configuration change detected.
100 }; 101 };
101 102
102 // Does not take ownership of |client| which must outlive |*this|. 103 // Does not take ownership of |client| which must outlive |*this|.
103 DXVAVideoDecodeAccelerator( 104 DXVAVideoDecodeAccelerator(
104 const base::Callback<bool(void)>& make_context_current, 105 const GetGLContextCallback& get_gl_context_cb,
105 gfx::GLContext* gl_context, 106 const MakeGLContextCurrentCallback& make_context_current_cb,
106 bool enable_accelerated_vpx_decode); 107 bool enable_accelerated_vpx_decode);
107 ~DXVAVideoDecodeAccelerator() override; 108 ~DXVAVideoDecodeAccelerator() override;
108 109
109 // media::VideoDecodeAccelerator implementation. 110 // media::VideoDecodeAccelerator implementation.
110 bool Initialize(const Config& config, Client* client) override; 111 bool Initialize(const Config& config, Client* client) override;
111 void Decode(const media::BitstreamBuffer& bitstream_buffer) override; 112 void Decode(const media::BitstreamBuffer& bitstream_buffer) override;
112 void AssignPictureBuffers( 113 void AssignPictureBuffers(
113 const std::vector<media::PictureBuffer>& buffers) override; 114 const std::vector<media::PictureBuffer>& buffers) override;
114 void ReusePictureBuffer(int32_t picture_buffer_id) override; 115 void ReusePictureBuffer(int32_t picture_buffer_id) override;
115 void Flush() override; 116 void Flush() override;
116 void Reset() override; 117 void Reset() override;
117 void Destroy() override; 118 void Destroy() override;
118 bool CanDecodeOnIOThread() override; 119 bool TryToSetupDecodeOnSeparateThread(
120 const base::WeakPtr<Client>& decode_client,
121 const scoped_refptr<base::SingleThreadTaskRunner>& decode_task_runner)
122 override;
119 GLenum GetSurfaceInternalFormat() const override; 123 GLenum GetSurfaceInternalFormat() const override;
120 124
121 static media::VideoDecodeAccelerator::SupportedProfiles 125 static media::VideoDecodeAccelerator::SupportedProfiles
122 GetSupportedProfiles(); 126 GetSupportedProfiles();
123 127
124 // Preload dlls required for decoding. 128 // Preload dlls required for decoding.
125 static void PreSandboxInitialization(); 129 static void PreSandboxInitialization();
126 130
127 private: 131 private:
128 typedef void* EGLConfig; 132 typedef void* EGLConfig;
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 403
400 // Set to true when the drain message is sent to the decoder during a flush 404 // Set to true when the drain message is sent to the decoder during a flush
401 // operation. Used to ensure the message is only sent once after 405 // operation. Used to ensure the message is only sent once after
402 // |pending_input_buffers_| is drained. Protected by |decoder_lock_|. 406 // |pending_input_buffers_| is drained. Protected by |decoder_lock_|.
403 bool sent_drain_message_; 407 bool sent_drain_message_;
404 408
405 // List of input samples waiting to be processed. 409 // List of input samples waiting to be processed.
406 typedef std::list<base::win::ScopedComPtr<IMFSample>> PendingInputs; 410 typedef std::list<base::win::ScopedComPtr<IMFSample>> PendingInputs;
407 PendingInputs pending_input_buffers_; 411 PendingInputs pending_input_buffers_;
408 412
413 // Callback to get current GLContext.
414 GetGLContextCallback get_gl_context_cb_;
409 // Callback to set the correct gl context. 415 // Callback to set the correct gl context.
410 base::Callback<bool(void)> make_context_current_; 416 MakeGLContextCurrentCallback make_context_current_cb_;
411 417
412 // Which codec we are decoding with hardware acceleration. 418 // Which codec we are decoding with hardware acceleration.
413 media::VideoCodec codec_; 419 media::VideoCodec codec_;
414 // Thread on which the decoder operations like passing input frames, 420 // Thread on which the decoder operations like passing input frames,
415 // getting output frames are performed. One instance of this thread 421 // getting output frames are performed. One instance of this thread
416 // is created per decoder instance. 422 // is created per decoder instance.
417 base::Thread decoder_thread_; 423 base::Thread decoder_thread_;
418 424
419 // Task runner to be used for posting tasks to the decoder thread. 425 // Task runner to be used for posting tasks to the decoder thread.
420 scoped_refptr<base::SingleThreadTaskRunner> decoder_thread_task_runner_; 426 scoped_refptr<base::SingleThreadTaskRunner> decoder_thread_task_runner_;
(...skipping 19 matching lines...) Expand all
440 bool use_dx11_; 446 bool use_dx11_;
441 447
442 // True if we should use DXGI keyed mutexes to synchronize between the two 448 // True if we should use DXGI keyed mutexes to synchronize between the two
443 // contexts. 449 // contexts.
444 bool use_keyed_mutex_; 450 bool use_keyed_mutex_;
445 451
446 // Set to true if the DX11 video format converter input media types need to 452 // Set to true if the DX11 video format converter input media types need to
447 // be initialized. Defaults to true. 453 // be initialized. Defaults to true.
448 bool dx11_video_format_converter_media_type_needs_init_; 454 bool dx11_video_format_converter_media_type_needs_init_;
449 455
450 // The GLContext to be used by the decoder.
451 scoped_refptr<gfx::GLContext> gl_context_;
452
453 // Set to true if we are sharing ANGLE's device. 456 // Set to true if we are sharing ANGLE's device.
454 bool using_angle_device_; 457 bool using_angle_device_;
455 458
456 // Enables experimental hardware acceleration for VP8/VP9 video decoding. 459 // Enables experimental hardware acceleration for VP8/VP9 video decoding.
457 const bool enable_accelerated_vpx_decode_; 460 const bool enable_accelerated_vpx_decode_;
458 461
459 // The media foundation H.264 decoder has problems handling changes like 462 // The media foundation H.264 decoder has problems handling changes like
460 // resolution change, bitrate change etc. If we reinitialize the decoder 463 // resolution change, bitrate change etc. If we reinitialize the decoder
461 // when these changes occur then, the decoder works fine. The 464 // when these changes occur then, the decoder works fine. The
462 // H264ConfigChangeDetector class provides functionality to check if the 465 // H264ConfigChangeDetector class provides functionality to check if the
463 // stream configuration changed. 466 // stream configuration changed.
464 scoped_ptr<H264ConfigChangeDetector> config_change_detector_; 467 scoped_ptr<H264ConfigChangeDetector> config_change_detector_;
465 468
466 // Contains the initialization parameters for the video. 469 // Contains the initialization parameters for the video.
467 Config config_; 470 Config config_;
468 471
469 // WeakPtrFactory for posting tasks back to |this|. 472 // WeakPtrFactory for posting tasks back to |this|.
470 base::WeakPtrFactory<DXVAVideoDecodeAccelerator> weak_this_factory_; 473 base::WeakPtrFactory<DXVAVideoDecodeAccelerator> weak_this_factory_;
471 474
472 // Function pointer for the MFCreateDXGIDeviceManager API. 475 // Function pointer for the MFCreateDXGIDeviceManager API.
473 static CreateDXGIDeviceManager create_dxgi_device_manager_; 476 static CreateDXGIDeviceManager create_dxgi_device_manager_;
474 477
475 DISALLOW_COPY_AND_ASSIGN(DXVAVideoDecodeAccelerator); 478 DISALLOW_COPY_AND_ASSIGN(DXVAVideoDecodeAccelerator);
476 }; 479 };
477 480
478 } // namespace content 481 } // namespace content
479 482
480 #endif // CONTENT_COMMON_GPU_MEDIA_DXVA_VIDEO_DECODE_ACCELERATOR_H_ 483 #endif // CONTENT_COMMON_GPU_MEDIA_DXVA_VIDEO_DECODE_ACCELERATOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698