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

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

Issue 490233002: VaapiVideoAccelerator: make Vaapi accelerator work with ozone (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove picture destruction sequence Created 6 years 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_encode_accelerator.h" 5 #include "content/common/gpu/media/vaapi_video_encode_accelerator.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/message_loop/message_loop_proxy.h" 10 #include "base/message_loop/message_loop_proxy.h"
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 106
107 std::vector<media::VideoEncodeAccelerator::SupportedProfile> 107 std::vector<media::VideoEncodeAccelerator::SupportedProfile>
108 VaapiVideoEncodeAccelerator::GetSupportedProfiles() { 108 VaapiVideoEncodeAccelerator::GetSupportedProfiles() {
109 std::vector<SupportedProfile> profiles; 109 std::vector<SupportedProfile> profiles;
110 110
111 const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); 111 const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess();
112 if (cmd_line->HasSwitch(switches::kDisableVaapiAcceleratedVideoEncode)) 112 if (cmd_line->HasSwitch(switches::kDisableVaapiAcceleratedVideoEncode))
113 return profiles; 113 return profiles;
114 114
115 std::vector<media::VideoCodecProfile> hw_profiles = 115 std::vector<media::VideoCodecProfile> hw_profiles =
116 VaapiWrapper::GetSupportedEncodeProfiles( 116 VaapiWrapper::GetSupportedEncodeProfiles(base::Bind(&base::DoNothing));
117 x_display_, base::Bind(&base::DoNothing));
118 117
119 media::VideoEncodeAccelerator::SupportedProfile profile; 118 media::VideoEncodeAccelerator::SupportedProfile profile;
120 profile.max_resolution.SetSize(1920, 1088); 119 profile.max_resolution.SetSize(1920, 1088);
121 profile.max_framerate_numerator = kDefaultFramerate; 120 profile.max_framerate_numerator = kDefaultFramerate;
122 profile.max_framerate_denominator = 1; 121 profile.max_framerate_denominator = 1;
123 for (size_t i = 0; i < hw_profiles.size(); i++) { 122 for (size_t i = 0; i < hw_profiles.size(); i++) {
124 profile.profile = hw_profiles[i]; 123 profile.profile = hw_profiles[i];
125 profiles.push_back(profile); 124 profiles.push_back(profile);
126 } 125 }
127 return profiles; 126 return profiles;
128 } 127 }
129 128
130 static unsigned int Log2OfPowerOf2(unsigned int x) { 129 static unsigned int Log2OfPowerOf2(unsigned int x) {
131 CHECK_GT(x, 0u); 130 CHECK_GT(x, 0u);
132 DCHECK_EQ(x & (x - 1), 0u); 131 DCHECK_EQ(x & (x - 1), 0u);
133 132
134 int log = 0; 133 int log = 0;
135 while (x) { 134 while (x) {
136 x >>= 1; 135 x >>= 1;
137 ++log; 136 ++log;
138 } 137 }
139 return log; 138 return log;
140 } 139 }
141 140
142 VaapiVideoEncodeAccelerator::VaapiVideoEncodeAccelerator(Display* x_display) 141 VaapiVideoEncodeAccelerator::VaapiVideoEncodeAccelerator()
143 : profile_(media::VIDEO_CODEC_PROFILE_UNKNOWN), 142 : profile_(media::VIDEO_CODEC_PROFILE_UNKNOWN),
144 mb_width_(0), 143 mb_width_(0),
145 mb_height_(0), 144 mb_height_(0),
146 output_buffer_byte_size_(0), 145 output_buffer_byte_size_(0),
147 x_display_(x_display),
148 state_(kUninitialized), 146 state_(kUninitialized),
149 frame_num_(0), 147 frame_num_(0),
150 last_idr_frame_num_(0), 148 last_idr_frame_num_(0),
151 bitrate_(0), 149 bitrate_(0),
152 framerate_(0), 150 framerate_(0),
153 cpb_size_(0), 151 cpb_size_(0),
154 encoding_parameters_changed_(false), 152 encoding_parameters_changed_(false),
155 encoder_thread_("VAVEAEncoderThread"), 153 encoder_thread_("VAVEAEncoderThread"),
156 child_message_loop_proxy_(base::MessageLoopProxy::current()), 154 child_message_loop_proxy_(base::MessageLoopProxy::current()),
157 weak_this_ptr_factory_(this) { 155 weak_this_ptr_factory_(this) {
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 coded_size_ = gfx::Size(RoundUpToPowerOf2(visible_size_.width(), 16), 208 coded_size_ = gfx::Size(RoundUpToPowerOf2(visible_size_.width(), 16),
211 RoundUpToPowerOf2(visible_size_.height(), 16)); 209 RoundUpToPowerOf2(visible_size_.height(), 16));
212 mb_width_ = coded_size_.width() / 16; 210 mb_width_ = coded_size_.width() / 16;
213 mb_height_ = coded_size_.height() / 16; 211 mb_height_ = coded_size_.height() / 16;
214 output_buffer_byte_size_ = coded_size_.GetArea(); 212 output_buffer_byte_size_ = coded_size_.GetArea();
215 213
216 UpdateRates(initial_bitrate, kDefaultFramerate); 214 UpdateRates(initial_bitrate, kDefaultFramerate);
217 215
218 vaapi_wrapper_ = VaapiWrapper::Create(VaapiWrapper::kEncode, 216 vaapi_wrapper_ = VaapiWrapper::Create(VaapiWrapper::kEncode,
219 output_profile, 217 output_profile,
220 x_display_,
221 base::Bind(&ReportToUMA, VAAPI_ERROR)); 218 base::Bind(&ReportToUMA, VAAPI_ERROR));
222 if (!vaapi_wrapper_) { 219 if (!vaapi_wrapper_.get()) {
Pawel Osciak 2014/12/08 10:55:15 Is this required?
llandwerlin-old 2014/12/08 16:42:06 Removed by using scoped_refptr.
Pawel Osciak 2014/12/09 01:19:25 What I meant was, do we need to add '.get()'.
llandwerlin-old 2014/12/09 11:19:47 I think that was required at some point with scope
223 LOG(ERROR) << "Failed initializing VAAPI"; 220 LOG(ERROR) << "Failed initializing VAAPI";
224 return false; 221 return false;
225 } 222 }
226 223
227 if (!encoder_thread_.Start()) { 224 if (!encoder_thread_.Start()) {
228 LOG(ERROR) << "Failed to start encoder thread"; 225 LOG(ERROR) << "Failed to start encoder thread";
229 return false; 226 return false;
230 } 227 }
231 encoder_thread_proxy_ = encoder_thread_.message_loop_proxy(); 228 encoder_thread_proxy_ = encoder_thread_.message_loop_proxy();
232 229
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
598 595
599 DCHECK(!current_encode_job_); 596 DCHECK(!current_encode_job_);
600 current_encode_job_.reset(new EncodeJob()); 597 current_encode_job_.reset(new EncodeJob());
601 598
602 if (!vaapi_wrapper_->CreateCodedBuffer(output_buffer_byte_size_, 599 if (!vaapi_wrapper_->CreateCodedBuffer(output_buffer_byte_size_,
603 &current_encode_job_->coded_buffer)) { 600 &current_encode_job_->coded_buffer)) {
604 NOTIFY_ERROR(kPlatformFailureError, "Failed creating coded buffer"); 601 NOTIFY_ERROR(kPlatformFailureError, "Failed creating coded buffer");
605 return false; 602 return false;
606 } 603 }
607 604
608 current_encode_job_->input_surface = 605 current_encode_job_->input_surface = new VASurface(
609 new VASurface(available_va_surface_ids_.back(), va_surface_release_cb_); 606 available_va_surface_ids_.back(), coded_size_, va_surface_release_cb_);
610 available_va_surface_ids_.pop_back(); 607 available_va_surface_ids_.pop_back();
611 608
612 current_encode_job_->recon_surface = 609 current_encode_job_->recon_surface = new VASurface(
613 new VASurface(available_va_surface_ids_.back(), va_surface_release_cb_); 610 available_va_surface_ids_.back(), coded_size_, va_surface_release_cb_);
614 available_va_surface_ids_.pop_back(); 611 available_va_surface_ids_.pop_back();
615 612
616 // Reference surfaces are needed until the job is done, but they get 613 // Reference surfaces are needed until the job is done, but they get
617 // removed from ref_pic_list0_ when it's full at the end of job submission. 614 // removed from ref_pic_list0_ when it's full at the end of job submission.
618 // Keep refs to them along with the job and only release after sync. 615 // Keep refs to them along with the job and only release after sync.
619 current_encode_job_->reference_surfaces = ref_pic_list0_; 616 current_encode_job_->reference_surfaces = ref_pic_list0_;
620 617
621 return true; 618 return true;
622 } 619 }
623 620
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after
1059 } 1056 }
1060 1057
1061 VaapiVideoEncodeAccelerator::EncodeJob::EncodeJob() 1058 VaapiVideoEncodeAccelerator::EncodeJob::EncodeJob()
1062 : coded_buffer(VA_INVALID_ID), keyframe(false) { 1059 : coded_buffer(VA_INVALID_ID), keyframe(false) {
1063 } 1060 }
1064 1061
1065 VaapiVideoEncodeAccelerator::EncodeJob::~EncodeJob() { 1062 VaapiVideoEncodeAccelerator::EncodeJob::~EncodeJob() {
1066 } 1063 }
1067 1064
1068 } // namespace content 1065 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698