| 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()) { |
| 892 // The picture buffer handles the actual binding of its contents to |
| 893 // texture ids. This call just causes the texture manager to hold a |
| 894 // reference to the GLImage as long as either texture exists. |
| 895 bind_image_cb_.Run(client_id, GetTextureTarget(), |
| 896 picture_buffer->gl_image(), true); |
| 897 } |
| 898 } |
| 888 | 899 |
| 889 bool inserted = | 900 bool inserted = |
| 890 output_picture_buffers_ | 901 output_picture_buffers_ |
| 891 .insert(std::make_pair(buffers[buffer_index].id(), picture_buffer)) | 902 .insert(std::make_pair(buffers[buffer_index].id(), picture_buffer)) |
| 892 .second; | 903 .second; |
| 893 DCHECK(inserted); | 904 DCHECK(inserted); |
| 894 } | 905 } |
| 895 | 906 |
| 896 ProcessPendingSamples(); | 907 ProcessPendingSamples(); |
| 897 if (pending_flush_ || processing_config_changed_) { | 908 if (pending_flush_ || processing_config_changed_) { |
| (...skipping 1031 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1929 if (GetState() != kUninitialized && client_) { | 1940 if (GetState() != kUninitialized && client_) { |
| 1930 // When sharing NV12 textures, the client needs to provide 2 texture IDs | 1941 // 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. | 1942 // 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 | 1943 // They're shared to ANGLE using EGL_NV_stream_consumer_gltexture_yuv, so |
| 1933 // they need to be GL_TEXTURE_EXTERNAL_OES. | 1944 // they need to be GL_TEXTURE_EXTERNAL_OES. |
| 1934 bool provide_nv12_textures = share_nv12_textures_ || copy_nv12_textures_; | 1945 bool provide_nv12_textures = share_nv12_textures_ || copy_nv12_textures_; |
| 1935 client_->ProvidePictureBuffers( | 1946 client_->ProvidePictureBuffers( |
| 1936 kNumPictureBuffers, | 1947 kNumPictureBuffers, |
| 1937 provide_nv12_textures ? PIXEL_FORMAT_NV12 : PIXEL_FORMAT_UNKNOWN, | 1948 provide_nv12_textures ? PIXEL_FORMAT_NV12 : PIXEL_FORMAT_UNKNOWN, |
| 1938 provide_nv12_textures ? 2 : 1, gfx::Size(width, height), | 1949 provide_nv12_textures ? 2 : 1, gfx::Size(width, height), |
| 1939 provide_nv12_textures ? GL_TEXTURE_EXTERNAL_OES : GL_TEXTURE_2D); | 1950 GetTextureTarget()); |
| 1940 } | 1951 } |
| 1941 } | 1952 } |
| 1942 | 1953 |
| 1943 void DXVAVideoDecodeAccelerator::NotifyPictureReady( | 1954 void DXVAVideoDecodeAccelerator::NotifyPictureReady( |
| 1944 int picture_buffer_id, | 1955 int picture_buffer_id, |
| 1945 int input_buffer_id, | 1956 int input_buffer_id, |
| 1946 const gfx::ColorSpace& color_space) { | 1957 const gfx::ColorSpace& color_space) { |
| 1947 DCHECK(main_thread_task_runner_->BelongsToCurrentThread()); | 1958 DCHECK(main_thread_task_runner_->BelongsToCurrentThread()); |
| 1948 // This task could execute after the decoder has been torn down. | 1959 // This task could execute after the decoder has been torn down. |
| 1949 if (GetState() != kUninitialized && client_) { | 1960 if (GetState() != kUninitialized && client_) { |
| (...skipping 792 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2742 | 2753 |
| 2743 SetState(kConfigChange); | 2754 SetState(kConfigChange); |
| 2744 Invalidate(); | 2755 Invalidate(); |
| 2745 Initialize(config_, client_); | 2756 Initialize(config_, client_); |
| 2746 decoder_thread_task_runner_->PostTask( | 2757 decoder_thread_task_runner_->PostTask( |
| 2747 FROM_HERE, | 2758 FROM_HERE, |
| 2748 base::Bind(&DXVAVideoDecodeAccelerator::DecodePendingInputBuffers, | 2759 base::Bind(&DXVAVideoDecodeAccelerator::DecodePendingInputBuffers, |
| 2749 base::Unretained(this))); | 2760 base::Unretained(this))); |
| 2750 } | 2761 } |
| 2751 | 2762 |
| 2763 uint32_t DXVAVideoDecodeAccelerator::GetTextureTarget() const { |
| 2764 bool provide_nv12_textures = share_nv12_textures_ || copy_nv12_textures_; |
| 2765 return provide_nv12_textures ? GL_TEXTURE_EXTERNAL_OES : GL_TEXTURE_2D; |
| 2766 } |
| 2767 |
| 2752 } // namespace media | 2768 } // namespace media |
| OLD | NEW |