OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/command_line.h" |
| 7 #include "base/cpu.h" |
6 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
7 #include "base/logging.h" | 9 #include "base/logging.h" |
8 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
9 #include "base/stl_util.h" | 11 #include "base/stl_util.h" |
10 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
11 #include "base/synchronization/waitable_event.h" | 13 #include "base/synchronization/waitable_event.h" |
12 #include "base/threading/non_thread_safe.h" | 14 #include "base/threading/non_thread_safe.h" |
13 #include "content/common/gpu/gpu_channel.h" | 15 #include "content/common/gpu/gpu_channel.h" |
14 #include "content/common/gpu/media/vaapi_video_decode_accelerator.h" | 16 #include "content/common/gpu/media/vaapi_video_decode_accelerator.h" |
15 #include "media/base/bind_to_current_loop.h" | 17 #include "media/base/bind_to_current_loop.h" |
| 18 #include "media/base/media_switches.h" |
16 #include "media/video/picture.h" | 19 #include "media/video/picture.h" |
| 20 #include "ui/gfx/x/x11_types.h" |
17 #include "ui/gl/gl_bindings.h" | 21 #include "ui/gl/gl_bindings.h" |
18 #include "ui/gl/scoped_binders.h" | 22 #include "ui/gl/scoped_binders.h" |
19 | 23 |
20 static void ReportToUMA( | 24 static void ReportToUMA( |
21 content::VaapiH264Decoder::VAVDAH264DecoderFailure failure) { | 25 content::VaapiH264Decoder::VAVDAH264DecoderFailure failure) { |
22 UMA_HISTOGRAM_ENUMERATION( | 26 UMA_HISTOGRAM_ENUMERATION( |
23 "Media.VAVDAH264.DecoderFailure", | 27 "Media.VAVDAH264.DecoderFailure", |
24 failure, | 28 failure, |
25 content::VaapiH264Decoder::VAVDA_H264_DECODER_FAILURES_MAX); | 29 content::VaapiH264Decoder::VAVDA_H264_DECODER_FAILURES_MAX); |
26 } | 30 } |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 VaapiVideoDecodeAccelerator::TFPPictureById(int32 picture_buffer_id) { | 223 VaapiVideoDecodeAccelerator::TFPPictureById(int32 picture_buffer_id) { |
220 TFPPictures::iterator it = tfp_pictures_.find(picture_buffer_id); | 224 TFPPictures::iterator it = tfp_pictures_.find(picture_buffer_id); |
221 if (it == tfp_pictures_.end()) { | 225 if (it == tfp_pictures_.end()) { |
222 LOG(ERROR) << "Picture id " << picture_buffer_id << " does not exist"; | 226 LOG(ERROR) << "Picture id " << picture_buffer_id << " does not exist"; |
223 return NULL; | 227 return NULL; |
224 } | 228 } |
225 | 229 |
226 return it->second.get(); | 230 return it->second.get(); |
227 } | 231 } |
228 | 232 |
| 233 // static |
| 234 std::vector<media::VideoDecodeAccelerator::SupportedProfile> |
| 235 VaapiVideoDecodeAccelerator::GetSupportedProfiles() { |
| 236 std::vector<SupportedProfile> profiles; |
| 237 std::vector<media::VideoCodecProfile> hw_profiles = |
| 238 VaapiWrapper::GetSupportedProfiles( |
| 239 gfx::GetXDisplay(), base::Bind(&base::DoNothing)); |
| 240 |
| 241 SupportedProfile profile; |
| 242 profile.min_resolution.SetSize(1, 1); |
| 243 |
| 244 // Ivy Bridge+ platforms can support more than 1920x1080. |
| 245 base::CPU cpu; |
| 246 const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); |
| 247 bool hw_large_video_support = cmd_line->HasSwitch( |
| 248 switches::kIgnoreResolutionLimitsForAcceleratedVideoDecode) || |
| 249 ((cpu.vendor_name() == "GenuineIntel") && cpu.model() >= 55); |
| 250 if (hw_large_video_support) |
| 251 profile.max_resolution.SetSize(4096, 2160); |
| 252 else |
| 253 profile.max_resolution.SetSize(1920, 1088); |
| 254 |
| 255 for (size_t i = 0; i < hw_profiles.size(); i++) { |
| 256 profile.profile = hw_profiles[i]; |
| 257 profiles.push_back(profile); |
| 258 } |
| 259 return profiles; |
| 260 } |
| 261 |
229 VaapiVideoDecodeAccelerator::VaapiVideoDecodeAccelerator( | 262 VaapiVideoDecodeAccelerator::VaapiVideoDecodeAccelerator( |
230 Display* x_display, | 263 Display* x_display, |
231 const base::Callback<bool(void)>& make_context_current) | 264 const base::Callback<bool(void)>& make_context_current) |
232 : x_display_(x_display), | 265 : x_display_(x_display), |
233 make_context_current_(make_context_current), | 266 make_context_current_(make_context_current), |
234 state_(kUninitialized), | 267 state_(kUninitialized), |
235 input_ready_(&lock_), | 268 input_ready_(&lock_), |
236 surfaces_available_(&lock_), | 269 surfaces_available_(&lock_), |
237 message_loop_(base::MessageLoop::current()), | 270 message_loop_(base::MessageLoop::current()), |
238 decoder_thread_("VaapiDecoderThread"), | 271 decoder_thread_("VaapiDecoderThread"), |
(...skipping 678 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
917 DCHECK_EQ(message_loop_, base::MessageLoop::current()); | 950 DCHECK_EQ(message_loop_, base::MessageLoop::current()); |
918 Cleanup(); | 951 Cleanup(); |
919 delete this; | 952 delete this; |
920 } | 953 } |
921 | 954 |
922 bool VaapiVideoDecodeAccelerator::CanDecodeOnIOThread() { | 955 bool VaapiVideoDecodeAccelerator::CanDecodeOnIOThread() { |
923 return false; | 956 return false; |
924 } | 957 } |
925 | 958 |
926 } // namespace content | 959 } // namespace content |
OLD | NEW |