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

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

Issue 1939683002: Test X11 header pollution (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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
« no previous file with comments | « media/gpu/avda_surface_tracker.cc ('k') | media/gpu/dxva_video_decode_accelerator_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 MEDIA_GPU_DXVA_VIDEO_DECODE_ACCELERATOR_H_
6 #define CONTENT_COMMON_GPU_MEDIA_DXVA_VIDEO_DECODE_ACCELERATOR_H_ 6 #define MEDIA_GPU_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>
11 #include <stdint.h> 11 #include <stdint.h>
12 12
13 // Work around bug in this header by disabling the relevant warning for it. 13 // Work around bug in this header by disabling the relevant warning for it.
14 // https://connect.microsoft.com/VisualStudio/feedback/details/911260/dxva2api-h -in-win8-sdk-triggers-c4201-with-w4 14 // https://connect.microsoft.com/VisualStudio/feedback/details/911260/dxva2api-h -in-win8-sdk-triggers-c4201-with-w4
15 #pragma warning(push) 15 #pragma warning(push)
16 #pragma warning(disable:4201) 16 #pragma warning(disable : 4201)
17 #include <dxva2api.h> 17 #include <dxva2api.h>
18 #pragma warning(pop) 18 #pragma warning(pop)
19 #include <mfidl.h> 19 #include <mfidl.h>
20 20
21 #include <list> 21 #include <list>
22 #include <map> 22 #include <map>
23 #include <memory> 23 #include <memory>
24 #include <vector> 24 #include <vector>
25 25
26 #include "base/compiler_specific.h" 26 #include "base/compiler_specific.h"
27 #include "base/macros.h" 27 #include "base/macros.h"
28 #include "base/memory/linked_ptr.h" 28 #include "base/memory/linked_ptr.h"
29 #include "base/memory/weak_ptr.h" 29 #include "base/memory/weak_ptr.h"
30 #include "base/synchronization/lock.h" 30 #include "base/synchronization/lock.h"
31 #include "base/threading/non_thread_safe.h" 31 #include "base/threading/non_thread_safe.h"
32 #include "base/threading/thread.h" 32 #include "base/threading/thread.h"
33 #include "base/win/scoped_comptr.h" 33 #include "base/win/scoped_comptr.h"
34 #include "content/common/content_export.h"
35 #include "content/common/gpu/media/gpu_video_decode_accelerator_helpers.h"
36 #include "media/filters/h264_parser.h" 34 #include "media/filters/h264_parser.h"
35 #include "media/gpu/gpu_video_decode_accelerator_helpers.h"
36 #include "media/gpu/media_gpu_export.h"
37 #include "media/video/video_decode_accelerator.h" 37 #include "media/video/video_decode_accelerator.h"
38 38
39 interface IMFSample; 39 interface IMFSample;
40 interface IDirect3DSurface9; 40 interface IDirect3DSurface9;
41 41
42 namespace gfx { 42 namespace gfx {
43 class GLContext; 43 class GLContext;
44 } 44 }
45 45
46 typedef HRESULT (WINAPI* CreateDXGIDeviceManager)( 46 typedef HRESULT(WINAPI* CreateDXGIDeviceManager)(
47 UINT* reset_token, 47 UINT* reset_token,
48 IMFDXGIDeviceManager** device_manager); 48 IMFDXGIDeviceManager** device_manager);
49 49
50 namespace content { 50 namespace media {
51 51
52 // Provides functionality to detect H.264 stream configuration changes. 52 // Provides functionality to detect H.264 stream configuration changes.
53 // TODO(ananta) 53 // TODO(ananta)
54 // Move this to a common place so that all VDA's can use this. 54 // Move this to a common place so that all VDA's can use this.
55 class H264ConfigChangeDetector { 55 class H264ConfigChangeDetector {
56 public: 56 public:
57 H264ConfigChangeDetector(); 57 H264ConfigChangeDetector();
58 ~H264ConfigChangeDetector(); 58 ~H264ConfigChangeDetector();
59 59
60 // Detects stream configuration changes. 60 // Detects stream configuration changes.
61 // Returns false on failure. 61 // Returns false on failure.
62 bool DetectConfig(const uint8_t* stream, unsigned int size); 62 bool DetectConfig(const uint8_t* stream, unsigned int size);
63 63
64 bool config_changed() const { 64 bool config_changed() const { return config_changed_; }
65 return config_changed_;
66 }
67 65
68 private: 66 private:
69 // These fields are used to track the SPS/PPS in the H.264 bitstream and 67 // These fields are used to track the SPS/PPS in the H.264 bitstream and
70 // are eventually compared against the SPS/PPS in the bitstream to detect 68 // are eventually compared against the SPS/PPS in the bitstream to detect
71 // a change. 69 // a change.
72 int last_sps_id_; 70 int last_sps_id_;
73 std::vector<uint8_t> last_sps_; 71 std::vector<uint8_t> last_sps_;
74 int last_pps_id_; 72 int last_pps_id_;
75 std::vector<uint8_t> last_pps_; 73 std::vector<uint8_t> last_pps_;
76 // Set to true if we detect a stream configuration change. 74 // Set to true if we detect a stream configuration change.
77 bool config_changed_; 75 bool config_changed_;
78 // We want to indicate configuration changes only after we see IDR slices. 76 // We want to indicate configuration changes only after we see IDR slices.
79 // This flag tracks that we potentially have a configuration change which 77 // This flag tracks that we potentially have a configuration change which
80 // we want to honor after we see an IDR slice. 78 // we want to honor after we see an IDR slice.
81 bool pending_config_changed_; 79 bool pending_config_changed_;
82 80
83 std::unique_ptr<media::H264Parser> parser_; 81 std::unique_ptr<media::H264Parser> parser_;
84 82
85 DISALLOW_COPY_AND_ASSIGN(H264ConfigChangeDetector); 83 DISALLOW_COPY_AND_ASSIGN(H264ConfigChangeDetector);
86 }; 84 };
87 85
88
89 // Class to provide a DXVA 2.0 based accelerator using the Microsoft Media 86 // Class to provide a DXVA 2.0 based accelerator using the Microsoft Media
90 // foundation APIs via the VideoDecodeAccelerator interface. 87 // foundation APIs via the VideoDecodeAccelerator interface.
91 // This class lives on a single thread and DCHECKs that it is never accessed 88 // This class lives on a single thread and DCHECKs that it is never accessed
92 // from any other. 89 // from any other.
93 class CONTENT_EXPORT DXVAVideoDecodeAccelerator 90 class MEDIA_GPU_EXPORT DXVAVideoDecodeAccelerator
94 : public media::VideoDecodeAccelerator { 91 : public media::VideoDecodeAccelerator {
95 public: 92 public:
96 enum State { 93 enum State {
97 kUninitialized, // un-initialized. 94 kUninitialized, // un-initialized.
98 kNormal, // normal playing state. 95 kNormal, // normal playing state.
99 kResetting, // upon received Reset(), before ResetDone() 96 kResetting, // upon received Reset(), before ResetDone()
100 kStopped, // upon output EOS received. 97 kStopped, // upon output EOS received.
101 kFlushing, // upon flush request received. 98 kFlushing, // upon flush request received.
102 kConfigChange, // stream configuration change detected. 99 kConfigChange, // stream configuration change detected.
103 }; 100 };
104 101
105 // Does not take ownership of |client| which must outlive |*this|. 102 // Does not take ownership of |client| which must outlive |*this|.
106 DXVAVideoDecodeAccelerator( 103 DXVAVideoDecodeAccelerator(
107 const GetGLContextCallback& get_gl_context_cb, 104 const GetGLContextCallback& get_gl_context_cb,
108 const MakeGLContextCurrentCallback& make_context_current_cb, 105 const MakeGLContextCurrentCallback& make_context_current_cb,
109 bool enable_accelerated_vpx_decode); 106 bool enable_accelerated_vpx_decode);
110 ~DXVAVideoDecodeAccelerator() override; 107 ~DXVAVideoDecodeAccelerator() override;
111 108
112 // media::VideoDecodeAccelerator implementation. 109 // media::VideoDecodeAccelerator implementation.
113 bool Initialize(const Config& config, Client* client) override; 110 bool Initialize(const Config& config, Client* client) override;
114 void Decode(const media::BitstreamBuffer& bitstream_buffer) override; 111 void Decode(const media::BitstreamBuffer& bitstream_buffer) override;
115 void AssignPictureBuffers( 112 void AssignPictureBuffers(
116 const std::vector<media::PictureBuffer>& buffers) override; 113 const std::vector<media::PictureBuffer>& buffers) override;
117 void ReusePictureBuffer(int32_t picture_buffer_id) override; 114 void ReusePictureBuffer(int32_t picture_buffer_id) override;
118 void Flush() override; 115 void Flush() override;
119 void Reset() override; 116 void Reset() override;
120 void Destroy() override; 117 void Destroy() override;
121 bool TryToSetupDecodeOnSeparateThread( 118 bool TryToSetupDecodeOnSeparateThread(
122 const base::WeakPtr<Client>& decode_client, 119 const base::WeakPtr<Client>& decode_client,
123 const scoped_refptr<base::SingleThreadTaskRunner>& decode_task_runner) 120 const scoped_refptr<base::SingleThreadTaskRunner>& decode_task_runner)
124 override; 121 override;
125 GLenum GetSurfaceInternalFormat() const override; 122 GLenum GetSurfaceInternalFormat() const override;
126 123
127 static media::VideoDecodeAccelerator::SupportedProfiles 124 static media::VideoDecodeAccelerator::SupportedProfiles
128 GetSupportedProfiles(); 125 GetSupportedProfiles();
129 126
130 // Preload dlls required for decoding. 127 // Preload dlls required for decoding.
131 static void PreSandboxInitialization(); 128 static void PreSandboxInitialization();
132 129
133 private: 130 private:
134 typedef void* EGLConfig; 131 typedef void* EGLConfig;
135 typedef void* EGLSurface; 132 typedef void* EGLSurface;
136 133
137 // Returns the minimum resolution for the |profile| passed in. 134 // Returns the minimum resolution for the |profile| passed in.
138 static std::pair<int, int> GetMinResolution( 135 static std::pair<int, int> GetMinResolution(
139 const media::VideoCodecProfile profile); 136 const media::VideoCodecProfile profile);
140 137
141 // Returns the maximum resolution for the |profile| passed in. 138 // Returns the maximum resolution for the |profile| passed in.
142 static std::pair<int, int> GetMaxResolution( 139 static std::pair<int, int> GetMaxResolution(
143 const media::VideoCodecProfile profile); 140 const media::VideoCodecProfile profile);
144 141
145 // Returns the maximum resolution for H264 video. 142 // Returns the maximum resolution for H264 video.
146 static std::pair<int, int> GetMaxH264Resolution(); 143 static std::pair<int, int> GetMaxH264Resolution();
147 144
148 // Certain AMD GPU drivers like R600, R700, Evergreen and Cayman and 145 // Certain AMD GPU drivers like R600, R700, Evergreen and Cayman and
149 // some second generation Intel GPU drivers crash if we create a video 146 // some second generation Intel GPU drivers crash if we create a video
150 // device with a resolution higher then 1920 x 1088. This function 147 // device with a resolution higher then 1920 x 1088. This function
151 // checks if the GPU is in this list and if yes returns true. 148 // checks if the GPU is in this list and if yes returns true.
152 static bool IsLegacyGPU(ID3D11Device* device); 149 static bool IsLegacyGPU(ID3D11Device* device);
153 150
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 // Notifies the client that the decoder was flushed. 209 // Notifies the client that the decoder was flushed.
213 void NotifyFlushDone(); 210 void NotifyFlushDone();
214 211
215 // Notifies the client that the decoder was reset. 212 // Notifies the client that the decoder was reset.
216 void NotifyResetDone(); 213 void NotifyResetDone();
217 214
218 // Requests picture buffers from the client. 215 // Requests picture buffers from the client.
219 void RequestPictureBuffers(int width, int height); 216 void RequestPictureBuffers(int width, int height);
220 217
221 // Notifies the client about the availability of a picture. 218 // Notifies the client about the availability of a picture.
222 void NotifyPictureReady(int picture_buffer_id, 219 void NotifyPictureReady(int picture_buffer_id, int input_buffer_id);
223 int input_buffer_id);
224 220
225 // Sends pending input buffer processed acks to the client if we don't have 221 // Sends pending input buffer processed acks to the client if we don't have
226 // output samples waiting to be processed. 222 // output samples waiting to be processed.
227 void NotifyInputBuffersDropped(); 223 void NotifyInputBuffersDropped();
228 224
229 // Decodes pending input buffers. 225 // Decodes pending input buffers.
230 void DecodePendingInputBuffers(); 226 void DecodePendingInputBuffers();
231 227
232 // Helper for handling the Flush operation. 228 // Helper for handling the Flush operation.
233 void FlushInternal(); 229 void FlushInternal();
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 media::VideoDecodeAccelerator::Client* client_; 335 media::VideoDecodeAccelerator::Client* client_;
340 336
341 base::win::ScopedComPtr<IMFTransform> decoder_; 337 base::win::ScopedComPtr<IMFTransform> decoder_;
342 base::win::ScopedComPtr<IMFTransform> video_format_converter_mft_; 338 base::win::ScopedComPtr<IMFTransform> video_format_converter_mft_;
343 339
344 base::win::ScopedComPtr<IDirect3D9Ex> d3d9_; 340 base::win::ScopedComPtr<IDirect3D9Ex> d3d9_;
345 base::win::ScopedComPtr<IDirect3DDevice9Ex> d3d9_device_ex_; 341 base::win::ScopedComPtr<IDirect3DDevice9Ex> d3d9_device_ex_;
346 base::win::ScopedComPtr<IDirect3DDeviceManager9> device_manager_; 342 base::win::ScopedComPtr<IDirect3DDeviceManager9> device_manager_;
347 base::win::ScopedComPtr<IDirect3DQuery9> query_; 343 base::win::ScopedComPtr<IDirect3DQuery9> query_;
348 344
349 base::win::ScopedComPtr<ID3D11Device > d3d11_device_; 345 base::win::ScopedComPtr<ID3D11Device> d3d11_device_;
350 base::win::ScopedComPtr<IMFDXGIDeviceManager> d3d11_device_manager_; 346 base::win::ScopedComPtr<IMFDXGIDeviceManager> d3d11_device_manager_;
351 base::win::ScopedComPtr<ID3D10Multithread> multi_threaded_; 347 base::win::ScopedComPtr<ID3D10Multithread> multi_threaded_;
352 base::win::ScopedComPtr<ID3D11DeviceContext> d3d11_device_context_; 348 base::win::ScopedComPtr<ID3D11DeviceContext> d3d11_device_context_;
353 base::win::ScopedComPtr<ID3D11Query> d3d11_query_; 349 base::win::ScopedComPtr<ID3D11Query> d3d11_query_;
354 350
355 // Ideally the reset token would be a stack variable which is used while 351 // Ideally the reset token would be a stack variable which is used while
356 // creating the device manager. However it seems that the device manager 352 // creating the device manager. However it seems that the device manager
357 // holds onto the token and attempts to access it if the underlying device 353 // holds onto the token and attempts to access it if the underlying device
358 // changes. 354 // changes.
359 // TODO(ananta): This needs to be verified. 355 // TODO(ananta): This needs to be verified.
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
480 476
481 // WeakPtrFactory for posting tasks back to |this|. 477 // WeakPtrFactory for posting tasks back to |this|.
482 base::WeakPtrFactory<DXVAVideoDecodeAccelerator> weak_this_factory_; 478 base::WeakPtrFactory<DXVAVideoDecodeAccelerator> weak_this_factory_;
483 479
484 // Function pointer for the MFCreateDXGIDeviceManager API. 480 // Function pointer for the MFCreateDXGIDeviceManager API.
485 static CreateDXGIDeviceManager create_dxgi_device_manager_; 481 static CreateDXGIDeviceManager create_dxgi_device_manager_;
486 482
487 DISALLOW_COPY_AND_ASSIGN(DXVAVideoDecodeAccelerator); 483 DISALLOW_COPY_AND_ASSIGN(DXVAVideoDecodeAccelerator);
488 }; 484 };
489 485
490 } // namespace content 486 } // namespace media
491 487
492 #endif // CONTENT_COMMON_GPU_MEDIA_DXVA_VIDEO_DECODE_ACCELERATOR_H_ 488 #endif // MEDIA_GPU_DXVA_VIDEO_DECODE_ACCELERATOR_H_
OLDNEW
« no previous file with comments | « media/gpu/avda_surface_tracker.cc ('k') | media/gpu/dxva_video_decode_accelerator_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698