| 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" |
| 11 #include "base/metrics/histogram.h" | 11 #include "base/metrics/histogram.h" |
| 12 #include "base/numerics/safe_conversions.h" | 12 #include "base/numerics/safe_conversions.h" |
| 13 #include "content/common/gpu/media/h264_dpb.h" | 13 #include "content/common/gpu/media/h264_dpb.h" |
| 14 #include "content/public/common/content_switches.h" | 14 #include "content/public/common/content_switches.h" |
| 15 #include "media/base/bind_to_current_loop.h" | 15 #include "media/base/bind_to_current_loop.h" |
| 16 #include "third_party/libva/va/va_enc_h264.h" | 16 #include "third_party/libva/va/va_enc_h264.h" |
| 17 | 17 |
| 18 #define DVLOGF(level) DVLOG(level) << __FUNCTION__ << "(): " | 18 #define DVLOGF(level) DVLOG(level) << __FUNCTION__ << "(): " |
| 19 | 19 |
| 20 #define NOTIFY_ERROR(error, msg) \ | 20 #define NOTIFY_ERROR(error, msg) \ |
| 21 do { \ | 21 do { \ |
| 22 SetState(kError); \ | 22 SetState(kError); \ |
| 23 DVLOGF(1) << msg; \ | 23 LOG(ERROR) << msg; \ |
| 24 DVLOGF(1) << "Calling NotifyError(" << error << ")"; \ | 24 LOG(ERROR) << "Calling NotifyError(" << error << ")";\ |
| 25 NotifyError(error); \ | 25 NotifyError(error); \ |
| 26 } while (0) | 26 } while (0) |
| 27 | 27 |
| 28 namespace content { | 28 namespace content { |
| 29 | 29 |
| 30 namespace { | 30 namespace { |
| 31 // Need 2 surfaces for each frame: one for input data and one for | 31 // Need 2 surfaces for each frame: one for input data and one for |
| 32 // reconstructed picture, which is later used for reference. | 32 // reconstructed picture, which is later used for reference. |
| 33 const size_t kMinSurfacesToEncode = 2; | 33 const size_t kMinSurfacesToEncode = 2; |
| 34 | 34 |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 mb_height_ = coded_size_.height() / 16; | 213 mb_height_ = coded_size_.height() / 16; |
| 214 output_buffer_byte_size_ = coded_size_.GetArea(); | 214 output_buffer_byte_size_ = coded_size_.GetArea(); |
| 215 | 215 |
| 216 UpdateRates(initial_bitrate, kDefaultFramerate); | 216 UpdateRates(initial_bitrate, kDefaultFramerate); |
| 217 | 217 |
| 218 vaapi_wrapper_ = VaapiWrapper::Create(VaapiWrapper::kEncode, | 218 vaapi_wrapper_ = VaapiWrapper::Create(VaapiWrapper::kEncode, |
| 219 output_profile, | 219 output_profile, |
| 220 x_display_, | 220 x_display_, |
| 221 base::Bind(&ReportToUMA, VAAPI_ERROR)); | 221 base::Bind(&ReportToUMA, VAAPI_ERROR)); |
| 222 if (!vaapi_wrapper_) { | 222 if (!vaapi_wrapper_) { |
| 223 DVLOGF(1) << "Failed initializing VAAPI"; | 223 LOG(ERROR) << "Failed initializing VAAPI"; |
| 224 return false; | 224 return false; |
| 225 } | 225 } |
| 226 | 226 |
| 227 if (!encoder_thread_.Start()) { | 227 if (!encoder_thread_.Start()) { |
| 228 DVLOGF(1) << "Failed to start encoder thread"; | 228 LOG(ERROR) << "Failed to start encoder thread"; |
| 229 return false; | 229 return false; |
| 230 } | 230 } |
| 231 encoder_thread_proxy_ = encoder_thread_.message_loop_proxy(); | 231 encoder_thread_proxy_ = encoder_thread_.message_loop_proxy(); |
| 232 | 232 |
| 233 // Finish the remaining initialization on the encoder thread. | 233 // Finish the remaining initialization on the encoder thread. |
| 234 encoder_thread_proxy_->PostTask( | 234 encoder_thread_proxy_->PostTask( |
| 235 FROM_HERE, | 235 FROM_HERE, |
| 236 base::Bind(&VaapiVideoEncodeAccelerator::InitializeTask, | 236 base::Bind(&VaapiVideoEncodeAccelerator::InitializeTask, |
| 237 base::Unretained(this))); | 237 base::Unretained(this))); |
| 238 | 238 |
| (...skipping 820 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1059 } | 1059 } |
| 1060 | 1060 |
| 1061 VaapiVideoEncodeAccelerator::EncodeJob::EncodeJob() | 1061 VaapiVideoEncodeAccelerator::EncodeJob::EncodeJob() |
| 1062 : coded_buffer(VA_INVALID_ID), keyframe(false) { | 1062 : coded_buffer(VA_INVALID_ID), keyframe(false) { |
| 1063 } | 1063 } |
| 1064 | 1064 |
| 1065 VaapiVideoEncodeAccelerator::EncodeJob::~EncodeJob() { | 1065 VaapiVideoEncodeAccelerator::EncodeJob::~EncodeJob() { |
| 1066 } | 1066 } |
| 1067 | 1067 |
| 1068 } // namespace content | 1068 } // namespace content |
| OLD | NEW |