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" | |
10 #include "base/message_loop/message_loop_proxy.h" | 9 #include "base/message_loop/message_loop_proxy.h" |
11 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
12 #include "base/numerics/safe_conversions.h" | 11 #include "base/numerics/safe_conversions.h" |
13 #include "content/common/gpu/media/h264_dpb.h" | 12 #include "content/common/gpu/media/h264_dpb.h" |
14 #include "content/public/common/content_switches.h" | |
15 #include "media/base/bind_to_current_loop.h" | 13 #include "media/base/bind_to_current_loop.h" |
16 #include "third_party/libva/va/va_enc_h264.h" | 14 #include "third_party/libva/va/va_enc_h264.h" |
17 | 15 |
18 #define DVLOGF(level) DVLOG(level) << __FUNCTION__ << "(): " | 16 #define DVLOGF(level) DVLOG(level) << __FUNCTION__ << "(): " |
19 | 17 |
20 #define NOTIFY_ERROR(error, msg) \ | 18 #define NOTIFY_ERROR(error, msg) \ |
21 do { \ | 19 do { \ |
22 SetState(kError); \ | 20 SetState(kError); \ |
23 LOG(ERROR) << msg; \ | 21 LOG(ERROR) << msg; \ |
24 LOG(ERROR) << "Calling NotifyError(" << error << ")";\ | 22 LOG(ERROR) << "Calling NotifyError(" << error << ")";\ |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 struct VaapiVideoEncodeAccelerator::BitstreamBufferRef { | 98 struct VaapiVideoEncodeAccelerator::BitstreamBufferRef { |
101 BitstreamBufferRef(int32 id, scoped_ptr<base::SharedMemory> shm, size_t size) | 99 BitstreamBufferRef(int32 id, scoped_ptr<base::SharedMemory> shm, size_t size) |
102 : id(id), shm(shm.Pass()), size(size) {} | 100 : id(id), shm(shm.Pass()), size(size) {} |
103 const int32 id; | 101 const int32 id; |
104 const scoped_ptr<base::SharedMemory> shm; | 102 const scoped_ptr<base::SharedMemory> shm; |
105 const size_t size; | 103 const size_t size; |
106 }; | 104 }; |
107 | 105 |
108 std::vector<media::VideoEncodeAccelerator::SupportedProfile> | 106 std::vector<media::VideoEncodeAccelerator::SupportedProfile> |
109 VaapiVideoEncodeAccelerator::GetSupportedProfiles() { | 107 VaapiVideoEncodeAccelerator::GetSupportedProfiles() { |
110 std::vector<SupportedProfile> profiles; | |
111 | 108 |
112 const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); | 109 return VaapiWrapper::GetSupportedEncodeProfiles(); |
113 if (cmd_line->HasSwitch(switches::kDisableVaapiAcceleratedVideoEncode)) | |
114 return profiles; | |
115 | |
116 std::vector<media::VideoCodecProfile> hw_profiles = | |
117 VaapiWrapper::GetSupportedEncodeProfiles(base::Bind(&base::DoNothing)); | |
118 | |
119 media::VideoEncodeAccelerator::SupportedProfile profile; | |
120 profile.max_resolution.SetSize(1920, 1088); | |
121 profile.max_framerate_numerator = kDefaultFramerate; | |
122 profile.max_framerate_denominator = 1; | |
123 for (size_t i = 0; i < hw_profiles.size(); i++) { | |
124 profile.profile = hw_profiles[i]; | |
125 profiles.push_back(profile); | |
126 } | |
127 return profiles; | |
128 } | 110 } |
129 | 111 |
130 static unsigned int Log2OfPowerOf2(unsigned int x) { | 112 static unsigned int Log2OfPowerOf2(unsigned int x) { |
131 CHECK_GT(x, 0u); | 113 CHECK_GT(x, 0u); |
132 DCHECK_EQ(x & (x - 1), 0u); | 114 DCHECK_EQ(x & (x - 1), 0u); |
133 | 115 |
134 int log = 0; | 116 int log = 0; |
135 while (x > 1) { | 117 while (x > 1) { |
136 x >>= 1; | 118 x >>= 1; |
137 ++log; | 119 ++log; |
(...skipping 942 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1080 } | 1062 } |
1081 | 1063 |
1082 VaapiVideoEncodeAccelerator::EncodeJob::EncodeJob() | 1064 VaapiVideoEncodeAccelerator::EncodeJob::EncodeJob() |
1083 : coded_buffer(VA_INVALID_ID), keyframe(false) { | 1065 : coded_buffer(VA_INVALID_ID), keyframe(false) { |
1084 } | 1066 } |
1085 | 1067 |
1086 VaapiVideoEncodeAccelerator::EncodeJob::~EncodeJob() { | 1068 VaapiVideoEncodeAccelerator::EncodeJob::~EncodeJob() { |
1087 } | 1069 } |
1088 | 1070 |
1089 } // namespace content | 1071 } // namespace content |
OLD | NEW |