Chromium Code Reviews| 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 #include "media/gpu/dxva_video_decode_accelerator_win.h" | 5 #include "media/gpu/dxva_video_decode_accelerator_win.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #if !defined(OS_WIN) | 9 #if !defined(OS_WIN) |
| 10 #error This file should only be built on Windows. | 10 #error This file should only be built on Windows. |
| (...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 479 } | 479 } |
| 480 | 480 |
| 481 DXVAVideoDecodeAccelerator::PendingSampleInfo::PendingSampleInfo( | 481 DXVAVideoDecodeAccelerator::PendingSampleInfo::PendingSampleInfo( |
| 482 const PendingSampleInfo& other) = default; | 482 const PendingSampleInfo& other) = default; |
| 483 | 483 |
| 484 DXVAVideoDecodeAccelerator::PendingSampleInfo::~PendingSampleInfo() {} | 484 DXVAVideoDecodeAccelerator::PendingSampleInfo::~PendingSampleInfo() {} |
| 485 | 485 |
| 486 DXVAVideoDecodeAccelerator::DXVAVideoDecodeAccelerator( | 486 DXVAVideoDecodeAccelerator::DXVAVideoDecodeAccelerator( |
| 487 const GetGLContextCallback& get_gl_context_cb, | 487 const GetGLContextCallback& get_gl_context_cb, |
| 488 const MakeGLContextCurrentCallback& make_context_current_cb, | 488 const MakeGLContextCurrentCallback& make_context_current_cb, |
| 489 const BindGLImageCallback& bind_image_cb, | |
| 489 const gpu::GpuDriverBugWorkarounds& workarounds, | 490 const gpu::GpuDriverBugWorkarounds& workarounds, |
| 490 const gpu::GpuPreferences& gpu_preferences) | 491 const gpu::GpuPreferences& gpu_preferences) |
| 491 : client_(NULL), | 492 : client_(NULL), |
| 492 dev_manager_reset_token_(0), | 493 dev_manager_reset_token_(0), |
| 493 dx11_dev_manager_reset_token_(0), | 494 dx11_dev_manager_reset_token_(0), |
| 494 egl_config_(NULL), | 495 egl_config_(NULL), |
| 495 state_(kUninitialized), | 496 state_(kUninitialized), |
| 496 pictures_requested_(false), | 497 pictures_requested_(false), |
| 497 inputs_before_decode_(0), | 498 inputs_before_decode_(0), |
| 498 sent_drain_message_(false), | 499 sent_drain_message_(false), |
| 499 get_gl_context_cb_(get_gl_context_cb), | 500 get_gl_context_cb_(get_gl_context_cb), |
| 500 make_context_current_cb_(make_context_current_cb), | 501 make_context_current_cb_(make_context_current_cb), |
| 502 bind_image_cb_(bind_image_cb), | |
| 501 codec_(kUnknownVideoCodec), | 503 codec_(kUnknownVideoCodec), |
| 502 decoder_thread_("DXVAVideoDecoderThread"), | 504 decoder_thread_("DXVAVideoDecoderThread"), |
| 503 pending_flush_(false), | 505 pending_flush_(false), |
| 504 enable_low_latency_(gpu_preferences.enable_low_latency_dxva), | 506 enable_low_latency_(gpu_preferences.enable_low_latency_dxva), |
| 505 share_nv12_textures_(gpu_preferences.enable_zero_copy_dxgi_video && | 507 share_nv12_textures_(gpu_preferences.enable_zero_copy_dxgi_video && |
| 506 !workarounds.disable_dxgi_zero_copy_video), | 508 !workarounds.disable_dxgi_zero_copy_video), |
| 507 copy_nv12_textures_(gpu_preferences.enable_nv12_dxgi_video && | 509 copy_nv12_textures_(gpu_preferences.enable_nv12_dxgi_video && |
| 508 !workarounds.disable_nv12_dxgi_video), | 510 !workarounds.disable_nv12_dxgi_video), |
| 509 use_dx11_(false), | 511 use_dx11_(false), |
| 510 use_keyed_mutex_(false), | 512 use_keyed_mutex_(false), |
| (...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 878 "Failed to make context current", | 880 "Failed to make context current", |
| 879 PLATFORM_FAILURE, ); | 881 PLATFORM_FAILURE, ); |
| 880 // Copy the picture buffers provided by the client to the available list, | 882 // Copy the picture buffers provided by the client to the available list, |
| 881 // and mark these buffers as available for use. | 883 // and mark these buffers as available for use. |
| 882 for (size_t buffer_index = 0; buffer_index < buffers.size(); ++buffer_index) { | 884 for (size_t buffer_index = 0; buffer_index < buffers.size(); ++buffer_index) { |
| 883 linked_ptr<DXVAPictureBuffer> picture_buffer = | 885 linked_ptr<DXVAPictureBuffer> picture_buffer = |
| 884 DXVAPictureBuffer::Create(*this, buffers[buffer_index], egl_config_); | 886 DXVAPictureBuffer::Create(*this, buffers[buffer_index], egl_config_); |
| 885 RETURN_AND_NOTIFY_ON_FAILURE(picture_buffer.get(), | 887 RETURN_AND_NOTIFY_ON_FAILURE(picture_buffer.get(), |
| 886 "Failed to allocate picture buffer", | 888 "Failed to allocate picture buffer", |
| 887 PLATFORM_FAILURE, ); | 889 PLATFORM_FAILURE, ); |
| 890 if (bind_image_cb_) { | |
| 891 for (uint32_t client_id : buffers[buffer_index].client_texture_ids()) { | |
|
sandersd (OOO until July 31)
2016/11/15 01:40:06
For people like myself that rarely work with BOUND
| |
| 892 bind_image_cb_.Run(client_id, GetTextureTarget(), | |
| 893 picture_buffer->gl_image(), true); | |
| 894 } | |
| 895 } | |
| 888 | 896 |
| 889 bool inserted = | 897 bool inserted = |
| 890 output_picture_buffers_ | 898 output_picture_buffers_ |
| 891 .insert(std::make_pair(buffers[buffer_index].id(), picture_buffer)) | 899 .insert(std::make_pair(buffers[buffer_index].id(), picture_buffer)) |
| 892 .second; | 900 .second; |
| 893 DCHECK(inserted); | 901 DCHECK(inserted); |
| 894 } | 902 } |
| 895 | 903 |
| 896 ProcessPendingSamples(); | 904 ProcessPendingSamples(); |
| 897 if (pending_flush_ || processing_config_changed_) { | 905 if (pending_flush_ || processing_config_changed_) { |
| (...skipping 1031 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1929 if (GetState() != kUninitialized && client_) { | 1937 if (GetState() != kUninitialized && client_) { |
| 1930 // When sharing NV12 textures, the client needs to provide 2 texture IDs | 1938 // When sharing NV12 textures, the client needs to provide 2 texture IDs |
| 1931 // per picture buffer, 1 for the Y channel and 1 for the UV channels. | 1939 // per picture buffer, 1 for the Y channel and 1 for the UV channels. |
| 1932 // They're shared to ANGLE using EGL_NV_stream_consumer_gltexture_yuv, so | 1940 // They're shared to ANGLE using EGL_NV_stream_consumer_gltexture_yuv, so |
| 1933 // they need to be GL_TEXTURE_EXTERNAL_OES. | 1941 // they need to be GL_TEXTURE_EXTERNAL_OES. |
| 1934 bool provide_nv12_textures = share_nv12_textures_ || copy_nv12_textures_; | 1942 bool provide_nv12_textures = share_nv12_textures_ || copy_nv12_textures_; |
| 1935 client_->ProvidePictureBuffers( | 1943 client_->ProvidePictureBuffers( |
| 1936 kNumPictureBuffers, | 1944 kNumPictureBuffers, |
| 1937 provide_nv12_textures ? PIXEL_FORMAT_NV12 : PIXEL_FORMAT_UNKNOWN, | 1945 provide_nv12_textures ? PIXEL_FORMAT_NV12 : PIXEL_FORMAT_UNKNOWN, |
| 1938 provide_nv12_textures ? 2 : 1, gfx::Size(width, height), | 1946 provide_nv12_textures ? 2 : 1, gfx::Size(width, height), |
| 1939 provide_nv12_textures ? GL_TEXTURE_EXTERNAL_OES : GL_TEXTURE_2D); | 1947 GetTextureTarget()); |
| 1940 } | 1948 } |
| 1941 } | 1949 } |
| 1942 | 1950 |
| 1943 void DXVAVideoDecodeAccelerator::NotifyPictureReady( | 1951 void DXVAVideoDecodeAccelerator::NotifyPictureReady( |
| 1944 int picture_buffer_id, | 1952 int picture_buffer_id, |
| 1945 int input_buffer_id, | 1953 int input_buffer_id, |
| 1946 const gfx::ColorSpace& color_space) { | 1954 const gfx::ColorSpace& color_space) { |
| 1947 DCHECK(main_thread_task_runner_->BelongsToCurrentThread()); | 1955 DCHECK(main_thread_task_runner_->BelongsToCurrentThread()); |
| 1948 // This task could execute after the decoder has been torn down. | 1956 // This task could execute after the decoder has been torn down. |
| 1949 if (GetState() != kUninitialized && client_) { | 1957 if (GetState() != kUninitialized && client_) { |
| (...skipping 792 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2742 | 2750 |
| 2743 SetState(kConfigChange); | 2751 SetState(kConfigChange); |
| 2744 Invalidate(); | 2752 Invalidate(); |
| 2745 Initialize(config_, client_); | 2753 Initialize(config_, client_); |
| 2746 decoder_thread_task_runner_->PostTask( | 2754 decoder_thread_task_runner_->PostTask( |
| 2747 FROM_HERE, | 2755 FROM_HERE, |
| 2748 base::Bind(&DXVAVideoDecodeAccelerator::DecodePendingInputBuffers, | 2756 base::Bind(&DXVAVideoDecodeAccelerator::DecodePendingInputBuffers, |
| 2749 base::Unretained(this))); | 2757 base::Unretained(this))); |
| 2750 } | 2758 } |
| 2751 | 2759 |
| 2760 uint32_t DXVAVideoDecodeAccelerator::GetTextureTarget() const { | |
| 2761 bool provide_nv12_textures = share_nv12_textures_ || copy_nv12_textures_; | |
| 2762 return provide_nv12_textures ? GL_TEXTURE_EXTERNAL_OES : GL_TEXTURE_2D; | |
| 2763 } | |
| 2764 | |
| 2752 } // namespace media | 2765 } // namespace media |
| OLD | NEW |