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

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

Issue 1745903002: Introduce GpuVideoDecodeAcceleratorFactory. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 Pictures::iterator it = pictures_.find(picture_buffer_id); 286 Pictures::iterator it = pictures_.find(picture_buffer_id);
287 if (it == pictures_.end()) { 287 if (it == pictures_.end()) {
288 LOG(ERROR) << "Picture id " << picture_buffer_id << " does not exist"; 288 LOG(ERROR) << "Picture id " << picture_buffer_id << " does not exist";
289 return NULL; 289 return NULL;
290 } 290 }
291 291
292 return it->second.get(); 292 return it->second.get();
293 } 293 }
294 294
295 VaapiVideoDecodeAccelerator::VaapiVideoDecodeAccelerator( 295 VaapiVideoDecodeAccelerator::VaapiVideoDecodeAccelerator(
296 const base::Callback<bool(void)>& make_context_current, 296 const gpu_vda_helpers::MakeGLContextCurrentCb& make_context_current_cb,
297 const base::Callback<void(uint32_t, uint32_t, scoped_refptr<gl::GLImage>)>& 297 const gpu_vda_helpers::BindGLImageCb& bind_image_cb)
298 bind_image) 298 : state_(kUninitialized),
299 : make_context_current_(make_context_current),
300 state_(kUninitialized),
301 input_ready_(&lock_), 299 input_ready_(&lock_),
302 surfaces_available_(&lock_), 300 surfaces_available_(&lock_),
303 message_loop_(base::MessageLoop::current()), 301 message_loop_(base::MessageLoop::current()),
304 decoder_thread_("VaapiDecoderThread"), 302 decoder_thread_("VaapiDecoderThread"),
305 num_frames_at_client_(0), 303 num_frames_at_client_(0),
306 num_stream_bufs_at_decoder_(0), 304 num_stream_bufs_at_decoder_(0),
307 finish_flush_pending_(false), 305 finish_flush_pending_(false),
308 awaiting_va_surfaces_recycle_(false), 306 awaiting_va_surfaces_recycle_(false),
309 requested_num_pics_(0), 307 requested_num_pics_(0),
310 bind_image_(bind_image), 308 make_context_current_cb_(make_context_current_cb),
309 bind_image_cb_(bind_image_cb),
311 weak_this_factory_(this) { 310 weak_this_factory_(this) {
312 weak_this_ = weak_this_factory_.GetWeakPtr(); 311 weak_this_ = weak_this_factory_.GetWeakPtr();
313 va_surface_release_cb_ = media::BindToCurrentLoop( 312 va_surface_release_cb_ = media::BindToCurrentLoop(
314 base::Bind(&VaapiVideoDecodeAccelerator::RecycleVASurfaceID, weak_this_)); 313 base::Bind(&VaapiVideoDecodeAccelerator::RecycleVASurfaceID, weak_this_));
315 } 314 }
316 315
317 VaapiVideoDecodeAccelerator::~VaapiVideoDecodeAccelerator() { 316 VaapiVideoDecodeAccelerator::~VaapiVideoDecodeAccelerator() {
318 DCHECK_EQ(message_loop_, base::MessageLoop::current()); 317 DCHECK_EQ(message_loop_, base::MessageLoop::current());
319 } 318 }
320 319
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after
738 buffers.size(), &va_surface_ids), 737 buffers.size(), &va_surface_ids),
739 "Failed creating VA Surfaces", PLATFORM_FAILURE, ); 738 "Failed creating VA Surfaces", PLATFORM_FAILURE, );
740 DCHECK_EQ(va_surface_ids.size(), buffers.size()); 739 DCHECK_EQ(va_surface_ids.size(), buffers.size());
741 740
742 for (size_t i = 0; i < buffers.size(); ++i) { 741 for (size_t i = 0; i < buffers.size(); ++i) {
743 DVLOG(2) << "Assigning picture id: " << buffers[i].id() 742 DVLOG(2) << "Assigning picture id: " << buffers[i].id()
744 << " to texture id: " << buffers[i].texture_id() 743 << " to texture id: " << buffers[i].texture_id()
745 << " VASurfaceID: " << va_surface_ids[i]; 744 << " VASurfaceID: " << va_surface_ids[i];
746 745
747 linked_ptr<VaapiPicture> picture(VaapiPicture::CreatePicture( 746 linked_ptr<VaapiPicture> picture(VaapiPicture::CreatePicture(
748 vaapi_wrapper_, make_context_current_, buffers[i].id(), 747 vaapi_wrapper_, make_context_current_cb_, buffers[i].id(),
749 buffers[i].texture_id(), requested_pic_size_)); 748 buffers[i].texture_id(), requested_pic_size_));
750 749
751 scoped_refptr<gl::GLImage> image = picture->GetImageToBind(); 750 scoped_refptr<gl::GLImage> image = picture->GetImageToBind();
752 if (image) { 751 if (image) {
753 bind_image_.Run(buffers[i].internal_texture_id(), 752 RETURN_AND_NOTIFY_ON_FAILURE(
754 VaapiPicture::GetGLTextureTarget(), image); 753 bind_image_cb_.Run(buffers[i].internal_texture_id(),
754 VaapiPicture::GetGLTextureTarget(), image),
755 "Failed to bind image", PLATFORM_FAILURE, );
755 } 756 }
756 757
757 RETURN_AND_NOTIFY_ON_FAILURE( 758 RETURN_AND_NOTIFY_ON_FAILURE(
758 picture.get(), "Failed assigning picture buffer to a texture.", 759 picture.get(), "Failed assigning picture buffer to a texture.",
759 PLATFORM_FAILURE, ); 760 PLATFORM_FAILURE, );
760 761
761 bool inserted = 762 bool inserted =
762 pictures_.insert(std::make_pair(buffers[i].id(), picture)).second; 763 pictures_.insert(std::make_pair(buffers[i].id(), picture)).second;
763 DCHECK(inserted); 764 DCHECK(inserted);
764 765
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
959 960
960 state_ = kUninitialized; 961 state_ = kUninitialized;
961 } 962 }
962 963
963 void VaapiVideoDecodeAccelerator::Destroy() { 964 void VaapiVideoDecodeAccelerator::Destroy() {
964 DCHECK_EQ(message_loop_, base::MessageLoop::current()); 965 DCHECK_EQ(message_loop_, base::MessageLoop::current());
965 Cleanup(); 966 Cleanup();
966 delete this; 967 delete this;
967 } 968 }
968 969
969 bool VaapiVideoDecodeAccelerator::CanDecodeOnIOThread() { 970 bool VaapiVideoDecodeAccelerator::TryInitializeDecodeOnSeparateThread(
971 const base::WeakPtr<Client>& decode_client,
972 const scoped_refptr<base::SingleThreadTaskRunner>& decode_task_runner) {
970 return false; 973 return false;
971 } 974 }
972 975
973 bool VaapiVideoDecodeAccelerator::DecodeSurface( 976 bool VaapiVideoDecodeAccelerator::DecodeSurface(
974 const scoped_refptr<VaapiDecodeSurface>& dec_surface) { 977 const scoped_refptr<VaapiDecodeSurface>& dec_surface) {
975 if (!vaapi_wrapper_->ExecuteAndDestroyPendingBuffers( 978 if (!vaapi_wrapper_->ExecuteAndDestroyPendingBuffers(
976 dec_surface->va_surface()->id())) { 979 dec_surface->va_surface()->id())) {
977 DVLOG(1) << "Failed decoding picture"; 980 DVLOG(1) << "Failed decoding picture";
978 return false; 981 return false;
979 } 982 }
(...skipping 768 matching lines...) Expand 10 before | Expand all | Expand 10 after
1748 return vaapi_pic->dec_surface(); 1751 return vaapi_pic->dec_surface();
1749 } 1752 }
1750 1753
1751 // static 1754 // static
1752 media::VideoDecodeAccelerator::SupportedProfiles 1755 media::VideoDecodeAccelerator::SupportedProfiles
1753 VaapiVideoDecodeAccelerator::GetSupportedProfiles() { 1756 VaapiVideoDecodeAccelerator::GetSupportedProfiles() {
1754 return VaapiWrapper::GetSupportedDecodeProfiles(); 1757 return VaapiWrapper::GetSupportedDecodeProfiles();
1755 } 1758 }
1756 1759
1757 } // namespace content 1760 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698