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

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
321 bool VaapiVideoDecodeAccelerator::Initialize(const Config& config, 320 bool VaapiVideoDecodeAccelerator::Initialize(const Config& config,
322 Client* client) { 321 Client* client) {
323 DCHECK_EQ(message_loop_, base::MessageLoop::current()); 322 DCHECK_EQ(message_loop_, base::MessageLoop::current());
324 323
324 if (make_context_current_cb_.is_null() || bind_image_cb_.is_null()) {
325 NOTREACHED() << "GL callbacks are required for this VDA";
326 return false;
327 }
328
325 if (config.is_encrypted) { 329 if (config.is_encrypted) {
326 NOTREACHED() << "Encrypted streams are not supported for this VDA"; 330 NOTREACHED() << "Encrypted streams are not supported for this VDA";
327 return false; 331 return false;
328 } 332 }
329 333
330 client_ptr_factory_.reset(new base::WeakPtrFactory<Client>(client)); 334 client_ptr_factory_.reset(new base::WeakPtrFactory<Client>(client));
331 client_ = client_ptr_factory_->GetWeakPtr(); 335 client_ = client_ptr_factory_->GetWeakPtr();
332 336
333 media::VideoCodecProfile profile = config.profile; 337 media::VideoCodecProfile profile = config.profile;
334 338
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
738 buffers.size(), &va_surface_ids), 742 buffers.size(), &va_surface_ids),
739 "Failed creating VA Surfaces", PLATFORM_FAILURE, ); 743 "Failed creating VA Surfaces", PLATFORM_FAILURE, );
740 DCHECK_EQ(va_surface_ids.size(), buffers.size()); 744 DCHECK_EQ(va_surface_ids.size(), buffers.size());
741 745
742 for (size_t i = 0; i < buffers.size(); ++i) { 746 for (size_t i = 0; i < buffers.size(); ++i) {
743 DVLOG(2) << "Assigning picture id: " << buffers[i].id() 747 DVLOG(2) << "Assigning picture id: " << buffers[i].id()
744 << " to texture id: " << buffers[i].texture_id() 748 << " to texture id: " << buffers[i].texture_id()
745 << " VASurfaceID: " << va_surface_ids[i]; 749 << " VASurfaceID: " << va_surface_ids[i];
746 750
747 linked_ptr<VaapiPicture> picture(VaapiPicture::CreatePicture( 751 linked_ptr<VaapiPicture> picture(VaapiPicture::CreatePicture(
748 vaapi_wrapper_, make_context_current_, buffers[i].id(), 752 vaapi_wrapper_, make_context_current_cb_, buffers[i].id(),
749 buffers[i].texture_id(), requested_pic_size_)); 753 buffers[i].texture_id(), requested_pic_size_));
750 754
751 scoped_refptr<gl::GLImage> image = picture->GetImageToBind(); 755 scoped_refptr<gl::GLImage> image = picture->GetImageToBind();
752 if (image) { 756 if (image) {
753 bind_image_.Run(buffers[i].internal_texture_id(), 757 RETURN_AND_NOTIFY_ON_FAILURE(
754 VaapiPicture::GetGLTextureTarget(), image); 758 bind_image_cb_.Run(buffers[i].internal_texture_id(),
759 VaapiPicture::GetGLTextureTarget(), image),
760 "Failed to bind image", PLATFORM_FAILURE, );
755 } 761 }
756 762
757 RETURN_AND_NOTIFY_ON_FAILURE( 763 RETURN_AND_NOTIFY_ON_FAILURE(
758 picture.get(), "Failed assigning picture buffer to a texture.", 764 picture.get(), "Failed assigning picture buffer to a texture.",
759 PLATFORM_FAILURE, ); 765 PLATFORM_FAILURE, );
760 766
761 bool inserted = 767 bool inserted =
762 pictures_.insert(std::make_pair(buffers[i].id(), picture)).second; 768 pictures_.insert(std::make_pair(buffers[i].id(), picture)).second;
763 DCHECK(inserted); 769 DCHECK(inserted);
764 770
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
959 965
960 state_ = kUninitialized; 966 state_ = kUninitialized;
961 } 967 }
962 968
963 void VaapiVideoDecodeAccelerator::Destroy() { 969 void VaapiVideoDecodeAccelerator::Destroy() {
964 DCHECK_EQ(message_loop_, base::MessageLoop::current()); 970 DCHECK_EQ(message_loop_, base::MessageLoop::current());
965 Cleanup(); 971 Cleanup();
966 delete this; 972 delete this;
967 } 973 }
968 974
969 bool VaapiVideoDecodeAccelerator::CanDecodeOnIOThread() { 975 bool VaapiVideoDecodeAccelerator::TryInitializeDecodeOnSeparateThread(
976 const base::WeakPtr<Client>& decode_client,
977 const scoped_refptr<base::SingleThreadTaskRunner>& decode_task_runner) {
970 return false; 978 return false;
971 } 979 }
972 980
973 bool VaapiVideoDecodeAccelerator::DecodeSurface( 981 bool VaapiVideoDecodeAccelerator::DecodeSurface(
974 const scoped_refptr<VaapiDecodeSurface>& dec_surface) { 982 const scoped_refptr<VaapiDecodeSurface>& dec_surface) {
975 if (!vaapi_wrapper_->ExecuteAndDestroyPendingBuffers( 983 if (!vaapi_wrapper_->ExecuteAndDestroyPendingBuffers(
976 dec_surface->va_surface()->id())) { 984 dec_surface->va_surface()->id())) {
977 DVLOG(1) << "Failed decoding picture"; 985 DVLOG(1) << "Failed decoding picture";
978 return false; 986 return false;
979 } 987 }
(...skipping 768 matching lines...) Expand 10 before | Expand all | Expand 10 after
1748 return vaapi_pic->dec_surface(); 1756 return vaapi_pic->dec_surface();
1749 } 1757 }
1750 1758
1751 // static 1759 // static
1752 media::VideoDecodeAccelerator::SupportedProfiles 1760 media::VideoDecodeAccelerator::SupportedProfiles
1753 VaapiVideoDecodeAccelerator::GetSupportedProfiles() { 1761 VaapiVideoDecodeAccelerator::GetSupportedProfiles() {
1754 return VaapiWrapper::GetSupportedDecodeProfiles(); 1762 return VaapiWrapper::GetSupportedDecodeProfiles();
1755 } 1763 }
1756 1764
1757 } // namespace content 1765 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698