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 MEDIA_GPU_DXVA_VIDEO_DECODE_ACCELERATOR_WIN_H_ | 5 #ifndef MEDIA_GPU_DXVA_VIDEO_DECODE_ACCELERATOR_WIN_H_ |
6 #define MEDIA_GPU_DXVA_VIDEO_DECODE_ACCELERATOR_WIN_H_ | 6 #define MEDIA_GPU_DXVA_VIDEO_DECODE_ACCELERATOR_WIN_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 18 matching lines...) Expand all Loading... |
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 "gpu/command_buffer/service/gpu_preferences.h" | 34 #include "gpu/command_buffer/service/gpu_preferences.h" |
35 #include "media/filters/h264_parser.h" | 35 #include "media/filters/h264_parser.h" |
36 #include "media/gpu/gpu_video_decode_accelerator_helpers.h" | 36 #include "media/gpu/gpu_video_decode_accelerator_helpers.h" |
37 #include "media/gpu/media_gpu_export.h" | 37 #include "media/gpu/media_gpu_export.h" |
38 #include "media/video/video_decode_accelerator.h" | 38 #include "media/video/video_decode_accelerator.h" |
| 39 #include "ui/gfx/color_space.h" |
39 | 40 |
40 interface IMFSample; | 41 interface IMFSample; |
41 interface IDirect3DSurface9; | 42 interface IDirect3DSurface9; |
42 | 43 |
43 namespace gl { | 44 namespace gl { |
44 class GLContext; | 45 class GLContext; |
45 } | 46 } |
46 | 47 |
47 namespace gpu { | 48 namespace gpu { |
48 class GpuDriverBugWorkarounds; | 49 class GpuDriverBugWorkarounds; |
(...skipping 17 matching lines...) Expand all Loading... |
66 public: | 67 public: |
67 H264ConfigChangeDetector(); | 68 H264ConfigChangeDetector(); |
68 ~H264ConfigChangeDetector(); | 69 ~H264ConfigChangeDetector(); |
69 | 70 |
70 // Detects stream configuration changes. | 71 // Detects stream configuration changes. |
71 // Returns false on failure. | 72 // Returns false on failure. |
72 bool DetectConfig(const uint8_t* stream, unsigned int size); | 73 bool DetectConfig(const uint8_t* stream, unsigned int size); |
73 | 74 |
74 bool config_changed() const { return config_changed_; } | 75 bool config_changed() const { return config_changed_; } |
75 | 76 |
| 77 gfx::ColorSpace current_color_space() const; |
| 78 |
76 private: | 79 private: |
77 // These fields are used to track the SPS/PPS in the H.264 bitstream and | 80 // These fields are used to track the SPS/PPS in the H.264 bitstream and |
78 // are eventually compared against the SPS/PPS in the bitstream to detect | 81 // are eventually compared against the SPS/PPS in the bitstream to detect |
79 // a change. | 82 // a change. |
80 int last_sps_id_; | 83 int last_sps_id_; |
81 std::vector<uint8_t> last_sps_; | 84 std::vector<uint8_t> last_sps_; |
82 int last_pps_id_; | 85 int last_pps_id_; |
83 std::vector<uint8_t> last_pps_; | 86 std::vector<uint8_t> last_pps_; |
84 // Set to true if we detect a stream configuration change. | 87 // Set to true if we detect a stream configuration change. |
85 bool config_changed_; | 88 bool config_changed_; |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 | 192 |
190 // Registers the output media type for the decoder. | 193 // Registers the output media type for the decoder. |
191 bool SetDecoderOutputMediaType(const GUID& subtype); | 194 bool SetDecoderOutputMediaType(const GUID& subtype); |
192 | 195 |
193 // Passes a command message to the decoder. This includes commands like | 196 // Passes a command message to the decoder. This includes commands like |
194 // start of stream, end of stream, flush, drain the decoder, etc. | 197 // start of stream, end of stream, flush, drain the decoder, etc. |
195 bool SendMFTMessage(MFT_MESSAGE_TYPE msg, int32_t param); | 198 bool SendMFTMessage(MFT_MESSAGE_TYPE msg, int32_t param); |
196 | 199 |
197 // The bulk of the decoding happens here. This function handles errors, | 200 // The bulk of the decoding happens here. This function handles errors, |
198 // format changes and processes decoded output. | 201 // format changes and processes decoded output. |
199 void DoDecode(); | 202 void DoDecode(const gfx::ColorSpace& color_space); |
200 | 203 |
201 // Invoked when we have a valid decoded output sample. Retrieves the D3D | 204 // Invoked when we have a valid decoded output sample. Retrieves the D3D |
202 // surface and maintains a copy of it which is passed eventually to the | 205 // surface and maintains a copy of it which is passed eventually to the |
203 // client when we have a picture buffer to copy the surface contents to. | 206 // client when we have a picture buffer to copy the surface contents to. |
204 bool ProcessOutputSample(IMFSample* sample); | 207 bool ProcessOutputSample(IMFSample* sample, |
| 208 const gfx::ColorSpace& color_space); |
205 | 209 |
206 // Processes pending output samples by copying them to available picture | 210 // Processes pending output samples by copying them to available picture |
207 // slots. | 211 // slots. |
208 void ProcessPendingSamples(); | 212 void ProcessPendingSamples(); |
209 | 213 |
210 // Helper function to notify the accelerator client about the error. | 214 // Helper function to notify the accelerator client about the error. |
211 void StopOnError(VideoDecodeAccelerator::Error error); | 215 void StopOnError(VideoDecodeAccelerator::Error error); |
212 | 216 |
213 // Transitions the decoder to the uninitialized state. The decoder will stop | 217 // Transitions the decoder to the uninitialized state. The decoder will stop |
214 // accepting requests in this state. | 218 // accepting requests in this state. |
215 void Invalidate(); | 219 void Invalidate(); |
216 | 220 |
217 // Notifies the client that the input buffer identifed by input_buffer_id has | 221 // Notifies the client that the input buffer identifed by input_buffer_id has |
218 // been processed. | 222 // been processed. |
219 void NotifyInputBufferRead(int input_buffer_id); | 223 void NotifyInputBufferRead(int input_buffer_id); |
220 | 224 |
221 // Notifies the client that the decoder was flushed. | 225 // Notifies the client that the decoder was flushed. |
222 void NotifyFlushDone(); | 226 void NotifyFlushDone(); |
223 | 227 |
224 // Notifies the client that the decoder was reset. | 228 // Notifies the client that the decoder was reset. |
225 void NotifyResetDone(); | 229 void NotifyResetDone(); |
226 | 230 |
227 // Requests picture buffers from the client. | 231 // Requests picture buffers from the client. |
228 void RequestPictureBuffers(int width, int height); | 232 void RequestPictureBuffers(int width, int height); |
229 | 233 |
230 // Notifies the client about the availability of a picture. | 234 // Notifies the client about the availability of a picture. |
231 void NotifyPictureReady(int picture_buffer_id, int input_buffer_id); | 235 void NotifyPictureReady(int picture_buffer_id, |
| 236 int input_buffer_id, |
| 237 const gfx::ColorSpace& color_space); |
232 | 238 |
233 // Sends pending input buffer processed acks to the client if we don't have | 239 // Sends pending input buffer processed acks to the client if we don't have |
234 // output samples waiting to be processed. | 240 // output samples waiting to be processed. |
235 void NotifyInputBuffersDropped(); | 241 void NotifyInputBuffersDropped(); |
236 | 242 |
237 // Decodes pending input buffers. | 243 // Decodes pending input buffers. |
238 void DecodePendingInputBuffers(); | 244 void DecodePendingInputBuffers(); |
239 | 245 |
240 // Helper for handling the Flush operation. | 246 // Helper for handling the Flush operation. |
241 void FlushInternal(); | 247 void FlushInternal(); |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
387 EGLConfig egl_config_; | 393 EGLConfig egl_config_; |
388 | 394 |
389 // Current state of the decoder. | 395 // Current state of the decoder. |
390 volatile State state_; | 396 volatile State state_; |
391 | 397 |
392 MFT_INPUT_STREAM_INFO input_stream_info_; | 398 MFT_INPUT_STREAM_INFO input_stream_info_; |
393 MFT_OUTPUT_STREAM_INFO output_stream_info_; | 399 MFT_OUTPUT_STREAM_INFO output_stream_info_; |
394 | 400 |
395 // Contains information about a decoded sample. | 401 // Contains information about a decoded sample. |
396 struct PendingSampleInfo { | 402 struct PendingSampleInfo { |
397 PendingSampleInfo(int32_t buffer_id, IMFSample* sample); | 403 PendingSampleInfo(int32_t buffer_id, |
| 404 IMFSample* sample, |
| 405 const gfx::ColorSpace& color_space); |
398 PendingSampleInfo(const PendingSampleInfo& other); | 406 PendingSampleInfo(const PendingSampleInfo& other); |
399 ~PendingSampleInfo(); | 407 ~PendingSampleInfo(); |
400 | 408 |
401 int32_t input_buffer_id; | 409 int32_t input_buffer_id; |
402 | 410 |
403 // The target picture buffer id where the frame would be copied to. | 411 // The target picture buffer id where the frame would be copied to. |
404 // Defaults to -1. | 412 // Defaults to -1. |
405 int picture_buffer_id; | 413 int picture_buffer_id; |
406 | 414 |
| 415 // The color space of this picture. |
| 416 gfx::ColorSpace color_space; |
| 417 |
407 base::win::ScopedComPtr<IMFSample> output_sample; | 418 base::win::ScopedComPtr<IMFSample> output_sample; |
408 }; | 419 }; |
409 | 420 |
410 typedef std::list<PendingSampleInfo> PendingOutputSamples; | 421 typedef std::list<PendingSampleInfo> PendingOutputSamples; |
411 | 422 |
412 // List of decoded output samples. Protected by |decoder_lock_|. | 423 // List of decoded output samples. Protected by |decoder_lock_|. |
413 PendingOutputSamples pending_output_samples_; | 424 PendingOutputSamples pending_output_samples_; |
414 | 425 |
415 // This map maintains the picture buffers passed the client for decoding. | 426 // This map maintains the picture buffers passed the client for decoding. |
416 // The key is the picture buffer id. | 427 // The key is the picture buffer id. |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
513 | 524 |
514 // Function pointer for the MFCreateDXGIDeviceManager API. | 525 // Function pointer for the MFCreateDXGIDeviceManager API. |
515 static CreateDXGIDeviceManager create_dxgi_device_manager_; | 526 static CreateDXGIDeviceManager create_dxgi_device_manager_; |
516 | 527 |
517 DISALLOW_COPY_AND_ASSIGN(DXVAVideoDecodeAccelerator); | 528 DISALLOW_COPY_AND_ASSIGN(DXVAVideoDecodeAccelerator); |
518 }; | 529 }; |
519 | 530 |
520 } // namespace media | 531 } // namespace media |
521 | 532 |
522 #endif // MEDIA_GPU_DXVA_VIDEO_DECODE_ACCELERATOR_WIN_H_ | 533 #endif // MEDIA_GPU_DXVA_VIDEO_DECODE_ACCELERATOR_WIN_H_ |
OLD | NEW |