| OLD | NEW |
| 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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 DCHECK_EQ(x & (x - 1), 0u); | 135 DCHECK_EQ(x & (x - 1), 0u); |
| 136 | 136 |
| 137 int log = 0; | 137 int log = 0; |
| 138 while (x) { | 138 while (x) { |
| 139 x >>= 1; | 139 x >>= 1; |
| 140 ++log; | 140 ++log; |
| 141 } | 141 } |
| 142 return log; | 142 return log; |
| 143 } | 143 } |
| 144 | 144 |
| 145 VaapiVideoEncodeAccelerator::VaapiVideoEncodeAccelerator(Display* x_display) | 145 VaapiVideoEncodeAccelerator::VaapiVideoEncodeAccelerator( |
| 146 gfx::GLContext* gl_context, |
| 147 const base::Callback<bool(void)>& make_context_current) |
| 146 : profile_(media::VIDEO_CODEC_PROFILE_UNKNOWN), | 148 : profile_(media::VIDEO_CODEC_PROFILE_UNKNOWN), |
| 147 mb_width_(0), | 149 mb_width_(0), |
| 148 mb_height_(0), | 150 mb_height_(0), |
| 149 output_buffer_byte_size_(0), | 151 output_buffer_byte_size_(0), |
| 150 x_display_(x_display), | 152 make_context_current_(make_context_current), |
| 153 gl_context_(gl_context), |
| 151 state_(kUninitialized), | 154 state_(kUninitialized), |
| 152 frame_num_(0), | 155 frame_num_(0), |
| 153 last_idr_frame_num_(0), | 156 last_idr_frame_num_(0), |
| 154 bitrate_(0), | 157 bitrate_(0), |
| 155 framerate_(0), | 158 framerate_(0), |
| 156 cpb_size_(0), | 159 cpb_size_(0), |
| 157 encoding_parameters_changed_(false), | 160 encoding_parameters_changed_(false), |
| 158 encoder_thread_("VAVEAEncoderThread"), | 161 encoder_thread_("VAVEAEncoderThread"), |
| 159 child_message_loop_proxy_(base::MessageLoopProxy::current()), | 162 child_message_loop_proxy_(base::MessageLoopProxy::current()), |
| 160 weak_this_ptr_factory_(this) { | 163 weak_this_ptr_factory_(this) { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 coded_size_ = gfx::Size(RoundUpToPowerOf2(visible_size_.width(), 16), | 216 coded_size_ = gfx::Size(RoundUpToPowerOf2(visible_size_.width(), 16), |
| 214 RoundUpToPowerOf2(visible_size_.height(), 16)); | 217 RoundUpToPowerOf2(visible_size_.height(), 16)); |
| 215 mb_width_ = coded_size_.width() / 16; | 218 mb_width_ = coded_size_.width() / 16; |
| 216 mb_height_ = coded_size_.height() / 16; | 219 mb_height_ = coded_size_.height() / 16; |
| 217 output_buffer_byte_size_ = coded_size_.GetArea(); | 220 output_buffer_byte_size_ = coded_size_.GetArea(); |
| 218 | 221 |
| 219 UpdateRates(initial_bitrate, kDefaultFramerate); | 222 UpdateRates(initial_bitrate, kDefaultFramerate); |
| 220 | 223 |
| 221 vaapi_wrapper_ = VaapiWrapper::Create(VaapiWrapper::kEncode, | 224 vaapi_wrapper_ = VaapiWrapper::Create(VaapiWrapper::kEncode, |
| 222 output_profile, | 225 output_profile, |
| 223 x_display_, | 226 gl_context_, |
| 227 make_context_current_, |
| 224 base::Bind(&ReportToUMA, VAAPI_ERROR)); | 228 base::Bind(&ReportToUMA, VAAPI_ERROR)); |
| 225 if (!vaapi_wrapper_) { | 229 if (!vaapi_wrapper_) { |
| 226 DVLOGF(1) << "Failed initializing VAAPI"; | 230 DVLOGF(1) << "Failed initializing VAAPI"; |
| 227 return false; | 231 return false; |
| 228 } | 232 } |
| 229 | 233 |
| 230 if (!encoder_thread_.Start()) { | 234 if (!encoder_thread_.Start()) { |
| 231 DVLOGF(1) << "Failed to start encoder thread"; | 235 DVLOGF(1) << "Failed to start encoder thread"; |
| 232 return false; | 236 return false; |
| 233 } | 237 } |
| (...skipping 828 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1062 } | 1066 } |
| 1063 | 1067 |
| 1064 VaapiVideoEncodeAccelerator::EncodeJob::EncodeJob() | 1068 VaapiVideoEncodeAccelerator::EncodeJob::EncodeJob() |
| 1065 : coded_buffer(VA_INVALID_ID), keyframe(false) { | 1069 : coded_buffer(VA_INVALID_ID), keyframe(false) { |
| 1066 } | 1070 } |
| 1067 | 1071 |
| 1068 VaapiVideoEncodeAccelerator::EncodeJob::~EncodeJob() { | 1072 VaapiVideoEncodeAccelerator::EncodeJob::~EncodeJob() { |
| 1069 } | 1073 } |
| 1070 | 1074 |
| 1071 } // namespace content | 1075 } // namespace content |
| OLD | NEW |