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

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

Issue 804353003: Revert of Refactor Vaapi video decoder/encoder in preparation of Freon support (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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(base::Bind(&base::DoNothing)); 116 VaapiWrapper::GetSupportedEncodeProfiles(
117 x_display_, base::Bind(&base::DoNothing));
117 118
118 media::VideoEncodeAccelerator::SupportedProfile profile; 119 media::VideoEncodeAccelerator::SupportedProfile profile;
119 profile.max_resolution.SetSize(1920, 1088); 120 profile.max_resolution.SetSize(1920, 1088);
120 profile.max_framerate_numerator = kDefaultFramerate; 121 profile.max_framerate_numerator = kDefaultFramerate;
121 profile.max_framerate_denominator = 1; 122 profile.max_framerate_denominator = 1;
122 for (size_t i = 0; i < hw_profiles.size(); i++) { 123 for (size_t i = 0; i < hw_profiles.size(); i++) {
123 profile.profile = hw_profiles[i]; 124 profile.profile = hw_profiles[i];
124 profiles.push_back(profile); 125 profiles.push_back(profile);
125 } 126 }
126 return profiles; 127 return profiles;
127 } 128 }
128 129
129 static unsigned int Log2OfPowerOf2(unsigned int x) { 130 static unsigned int Log2OfPowerOf2(unsigned int x) {
130 CHECK_GT(x, 0u); 131 CHECK_GT(x, 0u);
131 DCHECK_EQ(x & (x - 1), 0u); 132 DCHECK_EQ(x & (x - 1), 0u);
132 133
133 int log = 0; 134 int log = 0;
134 while (x) { 135 while (x) {
135 x >>= 1; 136 x >>= 1;
136 ++log; 137 ++log;
137 } 138 }
138 return log; 139 return log;
139 } 140 }
140 141
141 VaapiVideoEncodeAccelerator::VaapiVideoEncodeAccelerator() 142 VaapiVideoEncodeAccelerator::VaapiVideoEncodeAccelerator(Display* x_display)
142 : profile_(media::VIDEO_CODEC_PROFILE_UNKNOWN), 143 : profile_(media::VIDEO_CODEC_PROFILE_UNKNOWN),
143 mb_width_(0), 144 mb_width_(0),
144 mb_height_(0), 145 mb_height_(0),
145 output_buffer_byte_size_(0), 146 output_buffer_byte_size_(0),
147 x_display_(x_display),
146 state_(kUninitialized), 148 state_(kUninitialized),
147 frame_num_(0), 149 frame_num_(0),
148 last_idr_frame_num_(0), 150 last_idr_frame_num_(0),
149 bitrate_(0), 151 bitrate_(0),
150 framerate_(0), 152 framerate_(0),
151 cpb_size_(0), 153 cpb_size_(0),
152 encoding_parameters_changed_(false), 154 encoding_parameters_changed_(false),
153 encoder_thread_("VAVEAEncoderThread"), 155 encoder_thread_("VAVEAEncoderThread"),
154 child_message_loop_proxy_(base::MessageLoopProxy::current()), 156 child_message_loop_proxy_(base::MessageLoopProxy::current()),
155 weak_this_ptr_factory_(this) { 157 weak_this_ptr_factory_(this) {
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 coded_size_ = gfx::Size(RoundUpToPowerOf2(visible_size_.width(), 16), 210 coded_size_ = gfx::Size(RoundUpToPowerOf2(visible_size_.width(), 16),
209 RoundUpToPowerOf2(visible_size_.height(), 16)); 211 RoundUpToPowerOf2(visible_size_.height(), 16));
210 mb_width_ = coded_size_.width() / 16; 212 mb_width_ = coded_size_.width() / 16;
211 mb_height_ = coded_size_.height() / 16; 213 mb_height_ = coded_size_.height() / 16;
212 output_buffer_byte_size_ = coded_size_.GetArea(); 214 output_buffer_byte_size_ = coded_size_.GetArea();
213 215
214 UpdateRates(initial_bitrate, kDefaultFramerate); 216 UpdateRates(initial_bitrate, kDefaultFramerate);
215 217
216 vaapi_wrapper_ = VaapiWrapper::Create(VaapiWrapper::kEncode, 218 vaapi_wrapper_ = VaapiWrapper::Create(VaapiWrapper::kEncode,
217 output_profile, 219 output_profile,
220 x_display_,
218 base::Bind(&ReportToUMA, VAAPI_ERROR)); 221 base::Bind(&ReportToUMA, VAAPI_ERROR));
219 if (!vaapi_wrapper_.get()) { 222 if (!vaapi_wrapper_) {
220 LOG(ERROR) << "Failed initializing VAAPI"; 223 LOG(ERROR) << "Failed initializing VAAPI";
221 return false; 224 return false;
222 } 225 }
223 226
224 if (!encoder_thread_.Start()) { 227 if (!encoder_thread_.Start()) {
225 LOG(ERROR) << "Failed to start encoder thread"; 228 LOG(ERROR) << "Failed to start encoder thread";
226 return false; 229 return false;
227 } 230 }
228 encoder_thread_proxy_ = encoder_thread_.message_loop_proxy(); 231 encoder_thread_proxy_ = encoder_thread_.message_loop_proxy();
229 232
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
594 597
595 DCHECK(!current_encode_job_); 598 DCHECK(!current_encode_job_);
596 current_encode_job_.reset(new EncodeJob()); 599 current_encode_job_.reset(new EncodeJob());
597 600
598 if (!vaapi_wrapper_->CreateCodedBuffer(output_buffer_byte_size_, 601 if (!vaapi_wrapper_->CreateCodedBuffer(output_buffer_byte_size_,
599 &current_encode_job_->coded_buffer)) { 602 &current_encode_job_->coded_buffer)) {
600 NOTIFY_ERROR(kPlatformFailureError, "Failed creating coded buffer"); 603 NOTIFY_ERROR(kPlatformFailureError, "Failed creating coded buffer");
601 return false; 604 return false;
602 } 605 }
603 606
604 current_encode_job_->input_surface = new VASurface( 607 current_encode_job_->input_surface =
605 available_va_surface_ids_.back(), coded_size_, va_surface_release_cb_); 608 new VASurface(available_va_surface_ids_.back(), va_surface_release_cb_);
606 available_va_surface_ids_.pop_back(); 609 available_va_surface_ids_.pop_back();
607 610
608 current_encode_job_->recon_surface = new VASurface( 611 current_encode_job_->recon_surface =
609 available_va_surface_ids_.back(), coded_size_, va_surface_release_cb_); 612 new VASurface(available_va_surface_ids_.back(), va_surface_release_cb_);
610 available_va_surface_ids_.pop_back(); 613 available_va_surface_ids_.pop_back();
611 614
612 // Reference surfaces are needed until the job is done, but they get 615 // Reference surfaces are needed until the job is done, but they get
613 // removed from ref_pic_list0_ when it's full at the end of job submission. 616 // removed from ref_pic_list0_ when it's full at the end of job submission.
614 // Keep refs to them along with the job and only release after sync. 617 // Keep refs to them along with the job and only release after sync.
615 current_encode_job_->reference_surfaces = ref_pic_list0_; 618 current_encode_job_->reference_surfaces = ref_pic_list0_;
616 619
617 return true; 620 return true;
618 } 621 }
619 622
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after
1055 } 1058 }
1056 1059
1057 VaapiVideoEncodeAccelerator::EncodeJob::EncodeJob() 1060 VaapiVideoEncodeAccelerator::EncodeJob::EncodeJob()
1058 : coded_buffer(VA_INVALID_ID), keyframe(false) { 1061 : coded_buffer(VA_INVALID_ID), keyframe(false) {
1059 } 1062 }
1060 1063
1061 VaapiVideoEncodeAccelerator::EncodeJob::~EncodeJob() { 1064 VaapiVideoEncodeAccelerator::EncodeJob::~EncodeJob() {
1062 } 1065 }
1063 1066
1064 } // namespace content 1067 } // namespace content
OLDNEW
« no previous file with comments | « content/common/gpu/media/vaapi_video_encode_accelerator.h ('k') | content/common/gpu/media/vaapi_wrapper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698