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

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

Issue 2503063002: media: Inform VideoBlit/MFTransform of video color information (Closed)
Patch Set: merged Created 4 years 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 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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 // TODO(ananta) 64 // TODO(ananta)
65 // Move this to a common place so that all VDA's can use this. 65 // Move this to a common place so that all VDA's can use this.
66 class H264ConfigChangeDetector { 66 class H264ConfigChangeDetector {
67 public: 67 public:
68 H264ConfigChangeDetector(); 68 H264ConfigChangeDetector();
69 ~H264ConfigChangeDetector(); 69 ~H264ConfigChangeDetector();
70 70
71 // Detects stream configuration changes. 71 // Detects stream configuration changes.
72 // Returns false on failure. 72 // Returns false on failure.
73 bool DetectConfig(const uint8_t* stream, unsigned int size); 73 bool DetectConfig(const uint8_t* stream, unsigned int size);
74
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; 76 gfx::ColorSpace current_color_space() const;
78 77
79 private: 78 private:
80 // These fields are used to track the SPS/PPS in the H.264 bitstream and 79 // 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 80 // are eventually compared against the SPS/PPS in the bitstream to detect
82 // a change. 81 // a change.
83 int last_sps_id_; 82 int last_sps_id_;
84 std::vector<uint8_t> last_sps_; 83 std::vector<uint8_t> last_sps_;
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 // some second generation Intel GPU drivers crash if we create a video 161 // some second generation Intel GPU drivers crash if we create a video
163 // device with a resolution higher then 1920 x 1088. This function 162 // device with a resolution higher then 1920 x 1088. This function
164 // checks if the GPU is in this list and if yes returns true. 163 // checks if the GPU is in this list and if yes returns true.
165 static bool IsLegacyGPU(ID3D11Device* device); 164 static bool IsLegacyGPU(ID3D11Device* device);
166 165
167 // Creates and initializes an instance of the D3D device and the 166 // Creates and initializes an instance of the D3D device and the
168 // corresponding device manager. The device manager instance is eventually 167 // corresponding device manager. The device manager instance is eventually
169 // passed to the IMFTransform interface implemented by the decoder. 168 // passed to the IMFTransform interface implemented by the decoder.
170 bool CreateD3DDevManager(); 169 bool CreateD3DDevManager();
171 170
171 // TODO(hubbe): COMMENT
172 bool CreateVideoProcessor();
173
172 // Creates and initializes an instance of the DX11 device and the 174 // Creates and initializes an instance of the DX11 device and the
173 // corresponding device manager. The device manager instance is eventually 175 // corresponding device manager. The device manager instance is eventually
174 // passed to the IMFTransform interface implemented by the decoder. 176 // passed to the IMFTransform interface implemented by the decoder.
175 bool CreateDX11DevManager(); 177 bool CreateDX11DevManager();
176 178
177 // Creates, initializes and sets the media codec types for the decoder. 179 // Creates, initializes and sets the media codec types for the decoder.
178 bool InitDecoder(VideoCodecProfile profile); 180 bool InitDecoder(VideoCodecProfile profile);
179 181
180 // Validates whether the decoder supports hardware video acceleration. 182 // Validates whether the decoder supports hardware video acceleration.
181 bool CheckDecoderDxvaSupport(); 183 bool CheckDecoderDxvaSupport();
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 // Returns if we have output samples waiting to be processed. We only 277 // Returns if we have output samples waiting to be processed. We only
276 // allow one output sample to be present in the output queue at any given 278 // allow one output sample to be present in the output queue at any given
277 // time. 279 // time.
278 bool OutputSamplesPresent(); 280 bool OutputSamplesPresent();
279 281
280 // Copies the source surface |src_surface| to the destination |dest_surface|. 282 // Copies the source surface |src_surface| to the destination |dest_surface|.
281 // The copying is done on the decoder thread. 283 // The copying is done on the decoder thread.
282 void CopySurface(IDirect3DSurface9* src_surface, 284 void CopySurface(IDirect3DSurface9* src_surface,
283 IDirect3DSurface9* dest_surface, 285 IDirect3DSurface9* dest_surface,
284 int picture_buffer_id, 286 int picture_buffer_id,
285 int input_buffer_id); 287 int input_buffer_id,
288 const gfx::ColorSpace& color_space);
286 289
287 // This is a notification that the source surface |src_surface| was copied to 290 // This is a notification that the source surface |src_surface| was copied to
288 // the destination |dest_surface|. Received on the main thread. 291 // the destination |dest_surface|. Received on the main thread.
289 void CopySurfaceComplete(IDirect3DSurface9* src_surface, 292 void CopySurfaceComplete(IDirect3DSurface9* src_surface,
290 IDirect3DSurface9* dest_surface, 293 IDirect3DSurface9* dest_surface,
291 int picture_buffer_id, 294 int picture_buffer_id,
292 int input_buffer_id); 295 int input_buffer_id);
293 296
294 void BindPictureBufferToSample(base::win::ScopedComPtr<IMFSample> sample, 297 void BindPictureBufferToSample(base::win::ScopedComPtr<IMFSample> sample,
295 int picture_buffer_id, 298 int picture_buffer_id,
296 int input_buffer_id); 299 int input_buffer_id);
297 300
298 // Copies the source texture |src_texture| to the destination |dest_texture|. 301 // Copies the source texture |src_texture| to the destination |dest_texture|.
299 // The copying is done on the decoder thread. 302 // The copying is done on the decoder thread.
300 void CopyTexture(ID3D11Texture2D* src_texture, 303 void CopyTexture(ID3D11Texture2D* src_texture,
301 ID3D11Texture2D* dest_texture, 304 ID3D11Texture2D* dest_texture,
302 base::win::ScopedComPtr<IDXGIKeyedMutex> dest_keyed_mutex, 305 base::win::ScopedComPtr<IDXGIKeyedMutex> dest_keyed_mutex,
303 uint64_t keyed_mutex_value, 306 uint64_t keyed_mutex_value,
304 int picture_buffer_id, 307 int picture_buffer_id,
305 int input_buffer_id); 308 int input_buffer_id,
309 const gfx::ColorSpace& color_space);
306 310
307 // Copies the |video_frame| to the destination |dest_texture|. 311 // Copies the |video_frame| to the destination |dest_texture|.
308 void CopyTextureOnDecoderThread( 312 void CopyTextureOnDecoderThread(
309 ID3D11Texture2D* dest_texture, 313 ID3D11Texture2D* dest_texture,
310 base::win::ScopedComPtr<IDXGIKeyedMutex> dest_keyed_mutex, 314 base::win::ScopedComPtr<IDXGIKeyedMutex> dest_keyed_mutex,
311 uint64_t keyed_mutex_value, 315 uint64_t keyed_mutex_value,
312 IMFSample* video_frame, 316 IMFSample* video_frame,
313 int picture_buffer_id, 317 int picture_buffer_id,
314 int input_buffer_id); 318 int input_buffer_id);
315 319
316 // Flushes the decoder device to ensure that the decoded surface is copied 320 // Flushes the decoder device to ensure that the decoded surface is copied
317 // to the target surface. |iterations| helps to maintain an upper limit on 321 // to the target surface. |iterations| helps to maintain an upper limit on
318 // the number of times we try to complete the flush operation. 322 // the number of times we try to complete the flush operation.
319 void FlushDecoder(int iterations, 323 void FlushDecoder(int iterations,
320 IDirect3DSurface9* src_surface, 324 IDirect3DSurface9* src_surface,
321 IDirect3DSurface9* dest_surface, 325 IDirect3DSurface9* dest_surface,
322 int picture_buffer_id, 326 int picture_buffer_id,
323 int input_buffer_id); 327 int input_buffer_id);
324 328
325 // Polls to wait for GPU commands to be finished on the picture buffer 329 // Polls to wait for GPU commands to be finished on the picture buffer
326 // before reusing it. 330 // before reusing it.
327 void WaitForOutputBuffer(int32_t picture_buffer_id, int count); 331 void WaitForOutputBuffer(int32_t picture_buffer_id, int count);
328 332
329 // Initializes the DX11 Video format converter media types. 333 // Initializes the DX11 Video format converter media types.
330 // Returns true on success. 334 // Returns true on success.
331 bool InitializeDX11VideoFormatConverterMediaType(int width, int height); 335 bool InitializeDX11VideoFormatConverterMediaType(
336 int width,
337 int height,
338 const gfx::ColorSpace& color_space);
332 339
333 // Returns the output video frame dimensions (width, height). 340 // Returns the output video frame dimensions (width, height).
334 // |sample| :- This is the output sample containing the video frame. 341 // |sample| :- This is the output sample containing the video frame.
335 // |width| :- The width is returned here. 342 // |width| :- The width is returned here.
336 // |height| :- The height is returned here. 343 // |height| :- The height is returned here.
337 // Returns true on success. 344 // Returns true on success.
338 bool GetVideoFrameDimensions(IMFSample* sample, int* width, int* height); 345 bool GetVideoFrameDimensions(IMFSample* sample, int* width, int* height);
339 346
340 // Sets the output type on the |transform| to the GUID identified by the 347 // Sets the output type on the |transform| to the GUID identified by the
341 // the |output_type| parameter. The GUID can be MFVideoFormat_RGB32, 348 // the |output_type| parameter. The GUID can be MFVideoFormat_RGB32,
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 base::win::ScopedComPtr<IDirect3DDeviceManager9> device_manager_; 380 base::win::ScopedComPtr<IDirect3DDeviceManager9> device_manager_;
374 base::win::ScopedComPtr<IDirect3DQuery9> query_; 381 base::win::ScopedComPtr<IDirect3DQuery9> query_;
375 382
376 base::win::ScopedComPtr<ID3D11Device> d3d11_device_; 383 base::win::ScopedComPtr<ID3D11Device> d3d11_device_;
377 base::win::ScopedComPtr<ID3D11Device> angle_device_; 384 base::win::ScopedComPtr<ID3D11Device> angle_device_;
378 base::win::ScopedComPtr<IMFDXGIDeviceManager> d3d11_device_manager_; 385 base::win::ScopedComPtr<IMFDXGIDeviceManager> d3d11_device_manager_;
379 base::win::ScopedComPtr<ID3D10Multithread> multi_threaded_; 386 base::win::ScopedComPtr<ID3D10Multithread> multi_threaded_;
380 base::win::ScopedComPtr<ID3D11DeviceContext> d3d11_device_context_; 387 base::win::ScopedComPtr<ID3D11DeviceContext> d3d11_device_context_;
381 base::win::ScopedComPtr<ID3D11Query> d3d11_query_; 388 base::win::ScopedComPtr<ID3D11Query> d3d11_query_;
382 389
390 base::win::ScopedComPtr<IDirectXVideoProcessorService>
391 video_processor_service_;
392 base::win::ScopedComPtr<IDirectXVideoProcessor> processor_;
393 DXVA2_ProcAmpValues default_procamp_values_;
394
383 // Ideally the reset token would be a stack variable which is used while 395 // Ideally the reset token would be a stack variable which is used while
384 // creating the device manager. However it seems that the device manager 396 // creating the device manager. However it seems that the device manager
385 // holds onto the token and attempts to access it if the underlying device 397 // holds onto the token and attempts to access it if the underlying device
386 // changes. 398 // changes.
387 // TODO(ananta): This needs to be verified. 399 // TODO(ananta): This needs to be verified.
388 uint32_t dev_manager_reset_token_; 400 uint32_t dev_manager_reset_token_;
389 401
390 // Reset token for the DX11 device manager. 402 // Reset token for the DX11 device manager.
391 uint32_t dx11_dev_manager_reset_token_; 403 uint32_t dx11_dev_manager_reset_token_;
392 404
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 bool pending_flush_; 497 bool pending_flush_;
486 498
487 // Use CODECAPI_AVLowLatencyMode. 499 // Use CODECAPI_AVLowLatencyMode.
488 bool enable_low_latency_; 500 bool enable_low_latency_;
489 501
490 bool share_nv12_textures_; 502 bool share_nv12_textures_;
491 503
492 // Copy NV12 texture to another NV12 texture. 504 // Copy NV12 texture to another NV12 texture.
493 bool copy_nv12_textures_; 505 bool copy_nv12_textures_;
494 506
507 // When converting YUV to RGB, make sure we tell the blitter about the input
508 // color space so that it can convert it correctly.
509 bool use_color_info_ = true;
510
495 // Defaults to false. Indicates if we should use D3D or DX11 interfaces for 511 // Defaults to false. Indicates if we should use D3D or DX11 interfaces for
496 // H/W decoding. 512 // H/W decoding.
497 bool use_dx11_; 513 bool use_dx11_;
498 514
499 // True when using Microsoft's VP9 HMFT for decoding. 515 // True when using Microsoft's VP9 HMFT for decoding.
500 bool using_ms_vp9_mft_ = false; 516 bool using_ms_vp9_mft_ = false;
501 517
502 // True if we should use DXGI keyed mutexes to synchronize between the two 518 // True if we should use DXGI keyed mutexes to synchronize between the two
503 // contexts. 519 // contexts.
504 bool use_keyed_mutex_; 520 bool use_keyed_mutex_;
505 521
506 // Set to true if the DX11 video format converter input media types need to 522 // Set to true if the DX11 video format converter input media types need to
507 // be initialized. Defaults to true. 523 // be initialized. Defaults to true.
508 bool dx11_video_format_converter_media_type_needs_init_; 524 bool dx11_video_format_converter_media_type_needs_init_;
509 525
526 // Color spaced used when initializing the dx11 format converter.
527 gfx::ColorSpace dx11_converter_color_space_;
528
510 // Set to true if we are sharing ANGLE's device. 529 // Set to true if we are sharing ANGLE's device.
511 bool using_angle_device_; 530 bool using_angle_device_;
512 531
513 // Enables experimental hardware acceleration for VP8/VP9 video decoding. 532 // Enables experimental hardware acceleration for VP8/VP9 video decoding.
514 const gpu::GpuPreferences::VpxDecodeVendors enable_accelerated_vpx_decode_; 533 const gpu::GpuPreferences::VpxDecodeVendors enable_accelerated_vpx_decode_;
515 534
516 // The media foundation H.264 decoder has problems handling changes like 535 // The media foundation H.264 decoder has problems handling changes like
517 // resolution change, bitrate change etc. If we reinitialize the decoder 536 // resolution change, bitrate change etc. If we reinitialize the decoder
518 // when these changes occur then, the decoder works fine. The 537 // when these changes occur then, the decoder works fine. The
519 // H264ConfigChangeDetector class provides functionality to check if the 538 // H264ConfigChangeDetector class provides functionality to check if the
(...skipping 11 matching lines...) Expand all
531 550
532 // Function pointer for the MFCreateDXGIDeviceManager API. 551 // Function pointer for the MFCreateDXGIDeviceManager API.
533 static CreateDXGIDeviceManager create_dxgi_device_manager_; 552 static CreateDXGIDeviceManager create_dxgi_device_manager_;
534 553
535 DISALLOW_COPY_AND_ASSIGN(DXVAVideoDecodeAccelerator); 554 DISALLOW_COPY_AND_ASSIGN(DXVAVideoDecodeAccelerator);
536 }; 555 };
537 556
538 } // namespace media 557 } // namespace media
539 558
540 #endif // MEDIA_GPU_DXVA_VIDEO_DECODE_ACCELERATOR_WIN_H_ 559 #endif // MEDIA_GPU_DXVA_VIDEO_DECODE_ACCELERATOR_WIN_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698