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

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

Issue 858653002: vaapi plumbing to allow hardware video overlays (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: make buildable before cc plumbing is in Created 5 years, 11 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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/debug/trace_event.h" 6 #include "base/debug/trace_event.h"
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/metrics/histogram.h" 8 #include "base/metrics/histogram.h"
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
11 #include "base/synchronization/waitable_event.h" 11 #include "base/synchronization/waitable_event.h"
12 #include "content/common/gpu/gpu_channel.h" 12 #include "content/common/gpu/gpu_channel.h"
13 #include "content/common/gpu/media/vaapi_picture.h" 13 #include "content/common/gpu/media/vaapi_picture.h"
14 #include "content/common/gpu/media/vaapi_video_decode_accelerator.h" 14 #include "content/common/gpu/media/vaapi_video_decode_accelerator.h"
15 #include "gpu/command_buffer/service/texture_manager.h"
15 #include "media/base/bind_to_current_loop.h" 16 #include "media/base/bind_to_current_loop.h"
16 #include "media/video/picture.h" 17 #include "media/video/picture.h"
17 #include "ui/gl/gl_bindings.h" 18 #include "ui/gl/gl_bindings.h"
18 19
19 static void ReportToUMA( 20 static void ReportToUMA(
20 content::VaapiH264Decoder::VAVDAH264DecoderFailure failure) { 21 content::VaapiH264Decoder::VAVDAH264DecoderFailure failure) {
21 UMA_HISTOGRAM_ENUMERATION( 22 UMA_HISTOGRAM_ENUMERATION(
22 "Media.VAVDAH264.DecoderFailure", 23 "Media.VAVDAH264.DecoderFailure",
23 failure, 24 failure,
24 content::VaapiH264Decoder::VAVDA_H264_DECODER_FAILURES_MAX); 25 content::VaapiH264Decoder::VAVDA_H264_DECODER_FAILURES_MAX);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 Pictures::iterator it = pictures_.find(picture_buffer_id); 66 Pictures::iterator it = pictures_.find(picture_buffer_id);
66 if (it == pictures_.end()) { 67 if (it == pictures_.end()) {
67 LOG(ERROR) << "Picture id " << picture_buffer_id << " does not exist"; 68 LOG(ERROR) << "Picture id " << picture_buffer_id << " does not exist";
68 return NULL; 69 return NULL;
69 } 70 }
70 71
71 return it->second.get(); 72 return it->second.get();
72 } 73 }
73 74
74 VaapiVideoDecodeAccelerator::VaapiVideoDecodeAccelerator( 75 VaapiVideoDecodeAccelerator::VaapiVideoDecodeAccelerator(
75 const base::Callback<bool(void)>& make_context_current) 76 const base::Callback<bool(void)>& make_context_current,
77 gpu::gles2::TextureManager* texture_manager)
76 : make_context_current_(make_context_current), 78 : make_context_current_(make_context_current),
77 state_(kUninitialized), 79 state_(kUninitialized),
78 input_ready_(&lock_), 80 input_ready_(&lock_),
79 surfaces_available_(&lock_), 81 surfaces_available_(&lock_),
80 message_loop_(base::MessageLoop::current()), 82 message_loop_(base::MessageLoop::current()),
81 decoder_thread_("VaapiDecoderThread"), 83 decoder_thread_("VaapiDecoderThread"),
82 num_frames_at_client_(0), 84 num_frames_at_client_(0),
83 num_stream_bufs_at_decoder_(0), 85 num_stream_bufs_at_decoder_(0),
84 finish_flush_pending_(false), 86 finish_flush_pending_(false),
85 awaiting_va_surfaces_recycle_(false), 87 awaiting_va_surfaces_recycle_(false),
86 requested_num_pics_(0), 88 requested_num_pics_(0),
89 texture_manager_(texture_manager),
87 weak_this_factory_(this) { 90 weak_this_factory_(this) {
88 weak_this_ = weak_this_factory_.GetWeakPtr(); 91 weak_this_ = weak_this_factory_.GetWeakPtr();
89 va_surface_release_cb_ = media::BindToCurrentLoop( 92 va_surface_release_cb_ = media::BindToCurrentLoop(
90 base::Bind(&VaapiVideoDecodeAccelerator::RecycleVASurfaceID, weak_this_)); 93 base::Bind(&VaapiVideoDecodeAccelerator::RecycleVASurfaceID, weak_this_));
91 } 94 }
92 95
93 VaapiVideoDecodeAccelerator::~VaapiVideoDecodeAccelerator() { 96 VaapiVideoDecodeAccelerator::~VaapiVideoDecodeAccelerator() {
94 DCHECK_EQ(message_loop_, base::MessageLoop::current()); 97 DCHECK_EQ(message_loop_, base::MessageLoop::current());
95 } 98 }
96 99
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 &va_surface_ids), 519 &va_surface_ids),
517 "Failed creating VA Surfaces", PLATFORM_FAILURE, ); 520 "Failed creating VA Surfaces", PLATFORM_FAILURE, );
518 DCHECK_EQ(va_surface_ids.size(), buffers.size()); 521 DCHECK_EQ(va_surface_ids.size(), buffers.size());
519 522
520 for (size_t i = 0; i < buffers.size(); ++i) { 523 for (size_t i = 0; i < buffers.size(); ++i) {
521 DVLOG(2) << "Assigning picture id: " << buffers[i].id() 524 DVLOG(2) << "Assigning picture id: " << buffers[i].id()
522 << " to texture id: " << buffers[i].texture_id() 525 << " to texture id: " << buffers[i].texture_id()
523 << " VASurfaceID: " << va_surface_ids[i]; 526 << " VASurfaceID: " << va_surface_ids[i];
524 527
525 linked_ptr<VaapiPicture> picture(VaapiPicture::CreatePicture( 528 linked_ptr<VaapiPicture> picture(VaapiPicture::CreatePicture(
526 vaapi_wrapper_.get(), make_context_current_, buffers[i].id(), 529 vaapi_wrapper_.get(), texture_manager_,
527 buffers[i].texture_id(), requested_pic_size_)); 530 texture_manager_->GetTexture(buffers[i].internal_texture_id()),
531 make_context_current_, buffers[i].id(), buffers[i].texture_id(),
532 requested_pic_size_));
528 533
529 RETURN_AND_NOTIFY_ON_FAILURE( 534 RETURN_AND_NOTIFY_ON_FAILURE(
530 picture.get(), "Failed assigning picture buffer to a texture.", 535 picture.get(), "Failed assigning picture buffer to a texture.",
531 PLATFORM_FAILURE, ); 536 PLATFORM_FAILURE, );
532 537
533 bool inserted = 538 bool inserted =
534 pictures_.insert(std::make_pair(buffers[i].id(), picture)).second; 539 pictures_.insert(std::make_pair(buffers[i].id(), picture)).second;
535 DCHECK(inserted); 540 DCHECK(inserted);
536 541
537 output_buffers_.push(buffers[i].id()); 542 output_buffers_.push(buffers[i].id());
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
732 DCHECK_EQ(message_loop_, base::MessageLoop::current()); 737 DCHECK_EQ(message_loop_, base::MessageLoop::current());
733 Cleanup(); 738 Cleanup();
734 delete this; 739 delete this;
735 } 740 }
736 741
737 bool VaapiVideoDecodeAccelerator::CanDecodeOnIOThread() { 742 bool VaapiVideoDecodeAccelerator::CanDecodeOnIOThread() {
738 return false; 743 return false;
739 } 744 }
740 745
741 } // namespace content 746 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698