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

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

Issue 1832123002: Revert of 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 MakeGLContextCurrentCallback& make_context_current_cb, 295 const MakeContextCurrentCallback& make_context_current,
296 const BindGLImageCallback& bind_image_cb) 296 const BindImageCallback& bind_image)
297 : state_(kUninitialized), 297 : make_context_current_(make_context_current),
298 state_(kUninitialized),
298 input_ready_(&lock_), 299 input_ready_(&lock_),
299 surfaces_available_(&lock_), 300 surfaces_available_(&lock_),
300 message_loop_(base::MessageLoop::current()), 301 message_loop_(base::MessageLoop::current()),
301 decoder_thread_("VaapiDecoderThread"), 302 decoder_thread_("VaapiDecoderThread"),
302 num_frames_at_client_(0), 303 num_frames_at_client_(0),
303 num_stream_bufs_at_decoder_(0), 304 num_stream_bufs_at_decoder_(0),
304 finish_flush_pending_(false), 305 finish_flush_pending_(false),
305 awaiting_va_surfaces_recycle_(false), 306 awaiting_va_surfaces_recycle_(false),
306 requested_num_pics_(0), 307 requested_num_pics_(0),
307 make_context_current_cb_(make_context_current_cb), 308 bind_image_(bind_image),
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
328 if (config.is_encrypted) { 323 if (config.is_encrypted) {
329 NOTREACHED() << "Encrypted streams are not supported for this VDA"; 324 NOTREACHED() << "Encrypted streams are not supported for this VDA";
330 return false; 325 return false;
331 } 326 }
332 327
333 client_ptr_factory_.reset(new base::WeakPtrFactory<Client>(client)); 328 client_ptr_factory_.reset(new base::WeakPtrFactory<Client>(client));
334 client_ = client_ptr_factory_->GetWeakPtr(); 329 client_ = client_ptr_factory_->GetWeakPtr();
335 330
336 media::VideoCodecProfile profile = config.profile; 331 media::VideoCodecProfile profile = config.profile;
337 332
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after
739 buffers.size(), &va_surface_ids), 734 buffers.size(), &va_surface_ids),
740 "Failed creating VA Surfaces", PLATFORM_FAILURE, ); 735 "Failed creating VA Surfaces", PLATFORM_FAILURE, );
741 DCHECK_EQ(va_surface_ids.size(), buffers.size()); 736 DCHECK_EQ(va_surface_ids.size(), buffers.size());
742 737
743 for (size_t i = 0; i < buffers.size(); ++i) { 738 for (size_t i = 0; i < buffers.size(); ++i) {
744 DVLOG(2) << "Assigning picture id: " << buffers[i].id() 739 DVLOG(2) << "Assigning picture id: " << buffers[i].id()
745 << " to texture id: " << buffers[i].texture_id() 740 << " to texture id: " << buffers[i].texture_id()
746 << " VASurfaceID: " << va_surface_ids[i]; 741 << " VASurfaceID: " << va_surface_ids[i];
747 742
748 linked_ptr<VaapiPicture> picture(VaapiPicture::CreatePicture( 743 linked_ptr<VaapiPicture> picture(VaapiPicture::CreatePicture(
749 vaapi_wrapper_, make_context_current_cb_, buffers[i].id(), 744 vaapi_wrapper_, make_context_current_, buffers[i].id(),
750 buffers[i].texture_id(), requested_pic_size_)); 745 buffers[i].texture_id(), requested_pic_size_));
751 746
752 scoped_refptr<gl::GLImage> image = picture->GetImageToBind(); 747 scoped_refptr<gl::GLImage> image = picture->GetImageToBind();
753 if (image) { 748 if (image) {
754 RETURN_AND_NOTIFY_ON_FAILURE( 749 bind_image_.Run(buffers[i].internal_texture_id(),
755 bind_image_cb_.Run(buffers[i].internal_texture_id(), 750 VaapiPicture::GetGLTextureTarget(), image, true);
756 VaapiPicture::GetGLTextureTarget(), image, true),
757 "Failed to bind image", PLATFORM_FAILURE, );
758 } 751 }
759 752
760 RETURN_AND_NOTIFY_ON_FAILURE( 753 RETURN_AND_NOTIFY_ON_FAILURE(
761 picture.get(), "Failed assigning picture buffer to a texture.", 754 picture.get(), "Failed assigning picture buffer to a texture.",
762 PLATFORM_FAILURE, ); 755 PLATFORM_FAILURE, );
763 756
764 bool inserted = 757 bool inserted =
765 pictures_.insert(std::make_pair(buffers[i].id(), picture)).second; 758 pictures_.insert(std::make_pair(buffers[i].id(), picture)).second;
766 DCHECK(inserted); 759 DCHECK(inserted);
767 760
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
962 955
963 state_ = kUninitialized; 956 state_ = kUninitialized;
964 } 957 }
965 958
966 void VaapiVideoDecodeAccelerator::Destroy() { 959 void VaapiVideoDecodeAccelerator::Destroy() {
967 DCHECK_EQ(message_loop_, base::MessageLoop::current()); 960 DCHECK_EQ(message_loop_, base::MessageLoop::current());
968 Cleanup(); 961 Cleanup();
969 delete this; 962 delete this;
970 } 963 }
971 964
972 bool VaapiVideoDecodeAccelerator::TryToSetupDecodeOnSeparateThread( 965 bool VaapiVideoDecodeAccelerator::CanDecodeOnIOThread() {
973 const base::WeakPtr<Client>& decode_client,
974 const scoped_refptr<base::SingleThreadTaskRunner>& decode_task_runner) {
975 return false; 966 return false;
976 } 967 }
977 968
978 bool VaapiVideoDecodeAccelerator::DecodeSurface( 969 bool VaapiVideoDecodeAccelerator::DecodeSurface(
979 const scoped_refptr<VaapiDecodeSurface>& dec_surface) { 970 const scoped_refptr<VaapiDecodeSurface>& dec_surface) {
980 if (!vaapi_wrapper_->ExecuteAndDestroyPendingBuffers( 971 if (!vaapi_wrapper_->ExecuteAndDestroyPendingBuffers(
981 dec_surface->va_surface()->id())) { 972 dec_surface->va_surface()->id())) {
982 DVLOG(1) << "Failed decoding picture"; 973 DVLOG(1) << "Failed decoding picture";
983 return false; 974 return false;
984 } 975 }
(...skipping 768 matching lines...) Expand 10 before | Expand all | Expand 10 after
1753 return vaapi_pic->dec_surface(); 1744 return vaapi_pic->dec_surface();
1754 } 1745 }
1755 1746
1756 // static 1747 // static
1757 media::VideoDecodeAccelerator::SupportedProfiles 1748 media::VideoDecodeAccelerator::SupportedProfiles
1758 VaapiVideoDecodeAccelerator::GetSupportedProfiles() { 1749 VaapiVideoDecodeAccelerator::GetSupportedProfiles() {
1759 return VaapiWrapper::GetSupportedDecodeProfiles(); 1750 return VaapiWrapper::GetSupportedDecodeProfiles();
1760 } 1751 }
1761 1752
1762 } // namespace content 1753 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698