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

Side by Side Diff: content/common/gpu/media/vaapi_video_decode_accelerator.cc

Issue 1839193003: Reland: Introduce GpuVideoDecodeAcceleratorFactory. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months 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 #include "content/common/gpu/media/vaapi_video_decode_accelerator.h" 5 #include "content/common/gpu/media/vaapi_video_decode_accelerator.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 Pictures::iterator it = pictures_.find(picture_buffer_id); 285 Pictures::iterator it = pictures_.find(picture_buffer_id);
286 if (it == pictures_.end()) { 286 if (it == pictures_.end()) {
287 LOG(ERROR) << "Picture id " << picture_buffer_id << " does not exist"; 287 LOG(ERROR) << "Picture id " << picture_buffer_id << " does not exist";
288 return NULL; 288 return NULL;
289 } 289 }
290 290
291 return it->second.get(); 291 return it->second.get();
292 } 292 }
293 293
294 VaapiVideoDecodeAccelerator::VaapiVideoDecodeAccelerator( 294 VaapiVideoDecodeAccelerator::VaapiVideoDecodeAccelerator(
295 const MakeContextCurrentCallback& make_context_current, 295 const MakeGLContextCurrentCallback& make_context_current_cb,
296 const BindImageCallback& bind_image) 296 const BindGLImageCallback& bind_image_cb)
297 : make_context_current_(make_context_current), 297 : state_(kUninitialized),
298 state_(kUninitialized),
299 input_ready_(&lock_), 298 input_ready_(&lock_),
300 surfaces_available_(&lock_), 299 surfaces_available_(&lock_),
301 message_loop_(base::MessageLoop::current()), 300 message_loop_(base::MessageLoop::current()),
302 decoder_thread_("VaapiDecoderThread"), 301 decoder_thread_("VaapiDecoderThread"),
303 num_frames_at_client_(0), 302 num_frames_at_client_(0),
304 num_stream_bufs_at_decoder_(0), 303 num_stream_bufs_at_decoder_(0),
305 finish_flush_pending_(false), 304 finish_flush_pending_(false),
306 awaiting_va_surfaces_recycle_(false), 305 awaiting_va_surfaces_recycle_(false),
307 requested_num_pics_(0), 306 requested_num_pics_(0),
308 bind_image_(bind_image), 307 make_context_current_cb_(make_context_current_cb),
308 bind_image_cb_(bind_image_cb),
309 weak_this_factory_(this) { 309 weak_this_factory_(this) {
310 weak_this_ = weak_this_factory_.GetWeakPtr(); 310 weak_this_ = weak_this_factory_.GetWeakPtr();
311 va_surface_release_cb_ = media::BindToCurrentLoop( 311 va_surface_release_cb_ = media::BindToCurrentLoop(
312 base::Bind(&VaapiVideoDecodeAccelerator::RecycleVASurfaceID, weak_this_)); 312 base::Bind(&VaapiVideoDecodeAccelerator::RecycleVASurfaceID, weak_this_));
313 } 313 }
314 314
315 VaapiVideoDecodeAccelerator::~VaapiVideoDecodeAccelerator() { 315 VaapiVideoDecodeAccelerator::~VaapiVideoDecodeAccelerator() {
316 DCHECK_EQ(message_loop_, base::MessageLoop::current()); 316 DCHECK_EQ(message_loop_, base::MessageLoop::current());
317 } 317 }
318 318
319 bool VaapiVideoDecodeAccelerator::Initialize(const Config& config, 319 bool VaapiVideoDecodeAccelerator::Initialize(const Config& config,
320 Client* client) { 320 Client* client) {
321 DCHECK_EQ(message_loop_, base::MessageLoop::current()); 321 DCHECK_EQ(message_loop_, base::MessageLoop::current());
322 322
323 if (make_context_current_cb_.is_null() || bind_image_cb_.is_null()) {
324 NOTREACHED() << "GL callbacks are required for this VDA";
325 return false;
326 }
327
323 if (config.is_encrypted) { 328 if (config.is_encrypted) {
324 NOTREACHED() << "Encrypted streams are not supported for this VDA"; 329 NOTREACHED() << "Encrypted streams are not supported for this VDA";
325 return false; 330 return false;
326 } 331 }
327 332
328 client_ptr_factory_.reset(new base::WeakPtrFactory<Client>(client)); 333 client_ptr_factory_.reset(new base::WeakPtrFactory<Client>(client));
329 client_ = client_ptr_factory_->GetWeakPtr(); 334 client_ = client_ptr_factory_->GetWeakPtr();
330 335
331 media::VideoCodecProfile profile = config.profile; 336 media::VideoCodecProfile profile = config.profile;
332 337
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
735 "Failed creating VA Surfaces", PLATFORM_FAILURE, ); 740 "Failed creating VA Surfaces", PLATFORM_FAILURE, );
736 DCHECK_EQ(va_surface_ids.size(), buffers.size()); 741 DCHECK_EQ(va_surface_ids.size(), buffers.size());
737 742
738 for (size_t i = 0; i < buffers.size(); ++i) { 743 for (size_t i = 0; i < buffers.size(); ++i) {
739 DCHECK_LE(1u, buffers[i].texture_ids().size()); 744 DCHECK_LE(1u, buffers[i].texture_ids().size());
740 DVLOG(2) << "Assigning picture id: " << buffers[i].id() 745 DVLOG(2) << "Assigning picture id: " << buffers[i].id()
741 << " to texture id: " << buffers[i].texture_ids()[0] 746 << " to texture id: " << buffers[i].texture_ids()[0]
742 << " VASurfaceID: " << va_surface_ids[i]; 747 << " VASurfaceID: " << va_surface_ids[i];
743 748
744 linked_ptr<VaapiPicture> picture(VaapiPicture::CreatePicture( 749 linked_ptr<VaapiPicture> picture(VaapiPicture::CreatePicture(
745 vaapi_wrapper_, make_context_current_, buffers[i].id(), 750 vaapi_wrapper_, make_context_current_cb_, buffers[i].id(),
746 buffers[i].texture_ids()[0], requested_pic_size_)); 751 buffers[i].texture_ids()[0], requested_pic_size_));
747 752
748 scoped_refptr<gl::GLImage> image = picture->GetImageToBind(); 753 scoped_refptr<gl::GLImage> image = picture->GetImageToBind();
749 if (image) { 754 if (image) {
750 DCHECK_LE(1u, buffers[i].internal_texture_ids().size()); 755 DCHECK_LE(1u, buffers[i].internal_texture_ids().size());
751 bind_image_.Run(buffers[i].internal_texture_ids()[0], 756 RETURN_AND_NOTIFY_ON_FAILURE(
752 VaapiPicture::GetGLTextureTarget(), image, true); 757 bind_image_cb_.Run(buffers[i].internal_texture_ids()[0],
758 VaapiPicture::GetGLTextureTarget(), image, true),
759 "Failed to bind image", PLATFORM_FAILURE, );
753 } 760 }
754 761
755 RETURN_AND_NOTIFY_ON_FAILURE( 762 RETURN_AND_NOTIFY_ON_FAILURE(
756 picture.get(), "Failed assigning picture buffer to a texture.", 763 picture.get(), "Failed assigning picture buffer to a texture.",
757 PLATFORM_FAILURE, ); 764 PLATFORM_FAILURE, );
758 765
759 bool inserted = 766 bool inserted =
760 pictures_.insert(std::make_pair(buffers[i].id(), picture)).second; 767 pictures_.insert(std::make_pair(buffers[i].id(), picture)).second;
761 DCHECK(inserted); 768 DCHECK(inserted);
762 769
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
957 964
958 state_ = kUninitialized; 965 state_ = kUninitialized;
959 } 966 }
960 967
961 void VaapiVideoDecodeAccelerator::Destroy() { 968 void VaapiVideoDecodeAccelerator::Destroy() {
962 DCHECK_EQ(message_loop_, base::MessageLoop::current()); 969 DCHECK_EQ(message_loop_, base::MessageLoop::current());
963 Cleanup(); 970 Cleanup();
964 delete this; 971 delete this;
965 } 972 }
966 973
967 bool VaapiVideoDecodeAccelerator::CanDecodeOnIOThread() { 974 bool VaapiVideoDecodeAccelerator::TryToSetupDecodeOnSeparateThread(
975 const base::WeakPtr<Client>& decode_client,
976 const scoped_refptr<base::SingleThreadTaskRunner>& decode_task_runner) {
968 return false; 977 return false;
969 } 978 }
970 979
971 bool VaapiVideoDecodeAccelerator::DecodeSurface( 980 bool VaapiVideoDecodeAccelerator::DecodeSurface(
972 const scoped_refptr<VaapiDecodeSurface>& dec_surface) { 981 const scoped_refptr<VaapiDecodeSurface>& dec_surface) {
973 if (!vaapi_wrapper_->ExecuteAndDestroyPendingBuffers( 982 if (!vaapi_wrapper_->ExecuteAndDestroyPendingBuffers(
974 dec_surface->va_surface()->id())) { 983 dec_surface->va_surface()->id())) {
975 DVLOG(1) << "Failed decoding picture"; 984 DVLOG(1) << "Failed decoding picture";
976 return false; 985 return false;
977 } 986 }
(...skipping 768 matching lines...) Expand 10 before | Expand all | Expand 10 after
1746 return vaapi_pic->dec_surface(); 1755 return vaapi_pic->dec_surface();
1747 } 1756 }
1748 1757
1749 // static 1758 // static
1750 media::VideoDecodeAccelerator::SupportedProfiles 1759 media::VideoDecodeAccelerator::SupportedProfiles
1751 VaapiVideoDecodeAccelerator::GetSupportedProfiles() { 1760 VaapiVideoDecodeAccelerator::GetSupportedProfiles() {
1752 return VaapiWrapper::GetSupportedDecodeProfiles(); 1761 return VaapiWrapper::GetSupportedDecodeProfiles();
1753 } 1762 }
1754 1763
1755 } // namespace content 1764 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698