| 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 "media/gpu/vaapi_video_encode_accelerator.h" | 5 #include "media/gpu/vaapi_video_encode_accelerator.h" |
| 6 | 6 |
| 7 #include <string.h> | 7 #include <string.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 VideoCodecProfile output_profile, | 160 VideoCodecProfile output_profile, |
| 161 uint32_t initial_bitrate, | 161 uint32_t initial_bitrate, |
| 162 Client* client) { | 162 Client* client) { |
| 163 DCHECK(child_task_runner_->BelongsToCurrentThread()); | 163 DCHECK(child_task_runner_->BelongsToCurrentThread()); |
| 164 DCHECK(!encoder_thread_.IsRunning()); | 164 DCHECK(!encoder_thread_.IsRunning()); |
| 165 DCHECK_EQ(state_, kUninitialized); | 165 DCHECK_EQ(state_, kUninitialized); |
| 166 | 166 |
| 167 DVLOGF(1) << "Initializing VAVEA, input_format: " | 167 DVLOGF(1) << "Initializing VAVEA, input_format: " |
| 168 << VideoPixelFormatToString(format) | 168 << VideoPixelFormatToString(format) |
| 169 << ", input_visible_size: " << input_visible_size.ToString() | 169 << ", input_visible_size: " << input_visible_size.ToString() |
| 170 << ", output_profile: " << output_profile | 170 << ", output_profile: " << GetProfileName(output_profile) |
| 171 << ", initial_bitrate: " << initial_bitrate; | 171 << ", initial_bitrate: " << initial_bitrate; |
| 172 | 172 |
| 173 client_ptr_factory_.reset(new base::WeakPtrFactory<Client>(client)); | 173 client_ptr_factory_.reset(new base::WeakPtrFactory<Client>(client)); |
| 174 client_ = client_ptr_factory_->GetWeakPtr(); | 174 client_ = client_ptr_factory_->GetWeakPtr(); |
| 175 | 175 |
| 176 const SupportedProfiles& profiles = GetSupportedProfiles(); | 176 const SupportedProfiles& profiles = GetSupportedProfiles(); |
| 177 auto profile = find_if(profiles.begin(), profiles.end(), | 177 auto profile = find_if(profiles.begin(), profiles.end(), |
| 178 [output_profile](const SupportedProfile& profile) { | 178 [output_profile](const SupportedProfile& profile) { |
| 179 return profile.profile == output_profile; | 179 return profile.profile == output_profile; |
| 180 }); | 180 }); |
| 181 if (profile == profiles.end()) { | 181 if (profile == profiles.end()) { |
| 182 DVLOGF(1) << "Unsupported output profile " << output_profile; | 182 DVLOGF(1) << "Unsupported output profile " |
| 183 << GetProfileName(output_profile); |
| 183 return false; | 184 return false; |
| 184 } | 185 } |
| 185 if (input_visible_size.width() > profile->max_resolution.width() || | 186 if (input_visible_size.width() > profile->max_resolution.width() || |
| 186 input_visible_size.height() > profile->max_resolution.height()) { | 187 input_visible_size.height() > profile->max_resolution.height()) { |
| 187 DVLOGF(1) << "Input size too big: " << input_visible_size.ToString() | 188 DVLOGF(1) << "Input size too big: " << input_visible_size.ToString() |
| 188 << ", max supported size: " << profile->max_resolution.ToString(); | 189 << ", max supported size: " << profile->max_resolution.ToString(); |
| 189 return false; | 190 return false; |
| 190 } | 191 } |
| 191 | 192 |
| 192 if (format != PIXEL_FORMAT_I420) { | 193 if (format != PIXEL_FORMAT_I420) { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 205 mb_width_ = coded_size_.width() / 16; | 206 mb_width_ = coded_size_.width() / 16; |
| 206 mb_height_ = coded_size_.height() / 16; | 207 mb_height_ = coded_size_.height() / 16; |
| 207 output_buffer_byte_size_ = coded_size_.GetArea(); | 208 output_buffer_byte_size_ = coded_size_.GetArea(); |
| 208 | 209 |
| 209 UpdateRates(initial_bitrate, kDefaultFramerate); | 210 UpdateRates(initial_bitrate, kDefaultFramerate); |
| 210 | 211 |
| 211 vaapi_wrapper_ = | 212 vaapi_wrapper_ = |
| 212 VaapiWrapper::CreateForVideoCodec(VaapiWrapper::kEncode, output_profile, | 213 VaapiWrapper::CreateForVideoCodec(VaapiWrapper::kEncode, output_profile, |
| 213 base::Bind(&ReportToUMA, VAAPI_ERROR)); | 214 base::Bind(&ReportToUMA, VAAPI_ERROR)); |
| 214 if (!vaapi_wrapper_.get()) { | 215 if (!vaapi_wrapper_.get()) { |
| 215 DVLOGF(1) << "Failed initializing VAAPI for profile " << output_profile; | 216 DVLOGF(1) << "Failed initializing VAAPI for profile " |
| 217 << GetProfileName(output_profile); |
| 216 return false; | 218 return false; |
| 217 } | 219 } |
| 218 | 220 |
| 219 if (!encoder_thread_.Start()) { | 221 if (!encoder_thread_.Start()) { |
| 220 LOG(ERROR) << "Failed to start encoder thread"; | 222 LOG(ERROR) << "Failed to start encoder thread"; |
| 221 return false; | 223 return false; |
| 222 } | 224 } |
| 223 encoder_thread_task_runner_ = encoder_thread_.task_runner(); | 225 encoder_thread_task_runner_ = encoder_thread_.task_runner(); |
| 224 | 226 |
| 225 // Finish the remaining initialization on the encoder thread. | 227 // Finish the remaining initialization on the encoder thread. |
| (...skipping 825 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1051 client_ptr_factory_.reset(); | 1053 client_ptr_factory_.reset(); |
| 1052 } | 1054 } |
| 1053 } | 1055 } |
| 1054 | 1056 |
| 1055 VaapiVideoEncodeAccelerator::EncodeJob::EncodeJob() | 1057 VaapiVideoEncodeAccelerator::EncodeJob::EncodeJob() |
| 1056 : coded_buffer(VA_INVALID_ID), keyframe(false) {} | 1058 : coded_buffer(VA_INVALID_ID), keyframe(false) {} |
| 1057 | 1059 |
| 1058 VaapiVideoEncodeAccelerator::EncodeJob::~EncodeJob() {} | 1060 VaapiVideoEncodeAccelerator::EncodeJob::~EncodeJob() {} |
| 1059 | 1061 |
| 1060 } // namespace media | 1062 } // namespace media |
| OLD | NEW |