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