| 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 : profile_(media::VIDEO_CODEC_PROFILE_UNKNOWN), | 146 : profile_(media::VIDEO_CODEC_PROFILE_UNKNOWN), |
| 147 mb_width_(0), | 147 mb_width_(0), |
| 148 mb_height_(0), | 148 mb_height_(0), |
| 149 output_buffer_byte_size_(0), | 149 output_buffer_byte_size_(0), |
| 150 x_display_(x_display), | |
| 151 state_(kUninitialized), | 150 state_(kUninitialized), |
| 152 frame_num_(0), | 151 frame_num_(0), |
| 153 last_idr_frame_num_(0), | 152 last_idr_frame_num_(0), |
| 154 bitrate_(0), | 153 bitrate_(0), |
| 155 framerate_(0), | 154 framerate_(0), |
| 156 cpb_size_(0), | 155 cpb_size_(0), |
| 157 encoding_parameters_changed_(false), | 156 encoding_parameters_changed_(false), |
| 158 encoder_thread_("VAVEAEncoderThread"), | 157 encoder_thread_("VAVEAEncoderThread"), |
| 159 child_message_loop_proxy_(base::MessageLoopProxy::current()), | 158 child_message_loop_proxy_(base::MessageLoopProxy::current()), |
| 160 weak_this_ptr_factory_(this) { | 159 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), | 212 coded_size_ = gfx::Size(RoundUpToPowerOf2(visible_size_.width(), 16), |
| 214 RoundUpToPowerOf2(visible_size_.height(), 16)); | 213 RoundUpToPowerOf2(visible_size_.height(), 16)); |
| 215 mb_width_ = coded_size_.width() / 16; | 214 mb_width_ = coded_size_.width() / 16; |
| 216 mb_height_ = coded_size_.height() / 16; | 215 mb_height_ = coded_size_.height() / 16; |
| 217 output_buffer_byte_size_ = coded_size_.GetArea(); | 216 output_buffer_byte_size_ = coded_size_.GetArea(); |
| 218 | 217 |
| 219 UpdateRates(initial_bitrate, kDefaultFramerate); | 218 UpdateRates(initial_bitrate, kDefaultFramerate); |
| 220 | 219 |
| 221 vaapi_wrapper_ = VaapiWrapper::Create(VaapiWrapper::kEncode, | 220 vaapi_wrapper_ = VaapiWrapper::Create(VaapiWrapper::kEncode, |
| 222 output_profile, | 221 output_profile, |
| 223 x_display_, | |
| 224 base::Bind(&ReportToUMA, VAAPI_ERROR)); | 222 base::Bind(&ReportToUMA, VAAPI_ERROR)); |
| 225 if (!vaapi_wrapper_) { | 223 if (!vaapi_wrapper_) { |
| 226 DVLOGF(1) << "Failed initializing VAAPI"; | 224 DVLOGF(1) << "Failed initializing VAAPI"; |
| 227 return false; | 225 return false; |
| 228 } | 226 } |
| 229 | 227 |
| 230 if (!encoder_thread_.Start()) { | 228 if (!encoder_thread_.Start()) { |
| 231 DVLOGF(1) << "Failed to start encoder thread"; | 229 DVLOGF(1) << "Failed to start encoder thread"; |
| 232 return false; | 230 return false; |
| 233 } | 231 } |
| (...skipping 828 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1062 } | 1060 } |
| 1063 | 1061 |
| 1064 VaapiVideoEncodeAccelerator::EncodeJob::EncodeJob() | 1062 VaapiVideoEncodeAccelerator::EncodeJob::EncodeJob() |
| 1065 : coded_buffer(VA_INVALID_ID), keyframe(false) { | 1063 : coded_buffer(VA_INVALID_ID), keyframe(false) { |
| 1066 } | 1064 } |
| 1067 | 1065 |
| 1068 VaapiVideoEncodeAccelerator::EncodeJob::~EncodeJob() { | 1066 VaapiVideoEncodeAccelerator::EncodeJob::~EncodeJob() { |
| 1069 } | 1067 } |
| 1070 | 1068 |
| 1071 } // namespace content | 1069 } // namespace content |
| OLD | NEW |