Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(167)

Side by Side Diff: content/common/gpu/media/v4l2_device.cc

Issue 1097913002: Remove kIgnoreResolutionLimitsForAcceleratedVideoDecode flag (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <libdrm/drm_fourcc.h> 5 #include <libdrm/drm_fourcc.h>
6 #include <linux/videodev2.h> 6 #include <linux/videodev2.h>
7 7
8 #include "base/numerics/safe_conversions.h" 8 #include "base/numerics/safe_conversions.h"
9 #include "content/common/gpu/media/generic_v4l2_device.h" 9 #include "content/common/gpu/media/generic_v4l2_device.h"
10 #if defined(ARCH_CPU_ARMEL) 10 #if defined(ARCH_CPU_ARMEL)
11 #include "content/common/gpu/media/tegra_v4l2_device.h" 11 #include "content/common/gpu/media/tegra_v4l2_device.h"
12 #endif 12 #endif
13 13
14 namespace content { 14 namespace content {
15 15
16 V4L2Device::V4L2Device(Type type) : type_(type) {
17 }
18
16 V4L2Device::~V4L2Device() { 19 V4L2Device::~V4L2Device() {
17 } 20 }
18 21
19 // static 22 // static
20 scoped_refptr<V4L2Device> V4L2Device::Create(Type type) { 23 scoped_refptr<V4L2Device> V4L2Device::Create(Type type) {
21 DVLOG(3) << __PRETTY_FUNCTION__; 24 DVLOG(3) << __PRETTY_FUNCTION__;
22 25
23 scoped_refptr<GenericV4L2Device> generic_device(new GenericV4L2Device(type)); 26 scoped_refptr<GenericV4L2Device> generic_device(new GenericV4L2Device(type));
24 if (generic_device->Initialize()) 27 if (generic_device->Initialize())
25 return generic_device; 28 return generic_device;
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 193
191 // Sanity checks. Calculated coded size has to contain given visible size 194 // Sanity checks. Calculated coded size has to contain given visible size
192 // and fulfill buffer byte size requirements. 195 // and fulfill buffer byte size requirements.
193 DCHECK(gfx::Rect(coded_size).Contains(gfx::Rect(visible_size))); 196 DCHECK(gfx::Rect(coded_size).Contains(gfx::Rect(visible_size)));
194 DCHECK_LE(sizeimage, 197 DCHECK_LE(sizeimage,
195 media::VideoFrame::AllocationSize(frame_format, coded_size)); 198 media::VideoFrame::AllocationSize(frame_format, coded_size));
196 199
197 return coded_size; 200 return coded_size;
198 } 201 }
199 202
203 void V4L2Device::GetSupportedResolution(uint32_t pixelformat,
204 gfx::Size* min_resolution,
205 gfx::Size* max_resolution) {
206 max_resolution->SetSize(0, 0);
207 min_resolution->SetSize(0, 0);
208 v4l2_frmsizeenum frame_size;
209 memset(&frame_size, 0, sizeof(frame_size));
210 frame_size.pixel_format = pixelformat;
211 for (; Ioctl(VIDIOC_ENUM_FRAMESIZES, &frame_size) == 0; ++frame_size.index) {
212 if (frame_size.type == V4L2_FRMSIZE_TYPE_DISCRETE) {
213 if (frame_size.discrete.width >=
214 base::checked_cast<uint32_t>(max_resolution->width()) &&
215 frame_size.discrete.height >=
216 base::checked_cast<uint32_t>(max_resolution->height())) {
217 max_resolution->SetSize(frame_size.discrete.width,
218 frame_size.discrete.height);
219 }
220 if (min_resolution->IsEmpty() ||
221 (frame_size.discrete.width <=
222 base::checked_cast<uint32_t>(min_resolution->width()) &&
223 frame_size.discrete.height <=
224 base::checked_cast<uint32_t>(min_resolution->height()))) {
225 min_resolution->SetSize(frame_size.discrete.width,
226 frame_size.discrete.height);
227 }
228 } else if (frame_size.type == V4L2_FRMSIZE_TYPE_STEPWISE ||
229 frame_size.type == V4L2_FRMSIZE_TYPE_CONTINUOUS) {
230 max_resolution->SetSize(frame_size.stepwise.max_width,
231 frame_size.stepwise.max_height);
232 min_resolution->SetSize(frame_size.stepwise.min_width,
233 frame_size.stepwise.min_height);
234 break;
235 }
236 }
237 if (max_resolution->IsEmpty()) {
238 max_resolution->SetSize(1920, 1088);
239 LOG(ERROR) << "GetSupportedResolution failed to get maximum resolution for "
240 << "fourcc " << std::hex << pixelformat
241 << ", fall back to " << max_resolution->ToString();
242 }
243 if (min_resolution->IsEmpty()) {
244 min_resolution->SetSize(16, 16);
245 LOG(ERROR) << "GetSupportedResolution failed to get minimum resolution for "
246 << "fourcc " << std::hex << pixelformat
247 << ", fall back to " << min_resolution->ToString();
248 }
249 }
250
251 media::VideoDecodeAccelerator::SupportedProfiles
252 V4L2Device::GetSupportedDecodeProfiles(const size_t num_formats,
253 const uint32_t pixelformats[]) {
254 DCHECK_EQ(type_, kDecoder);
255 media::VideoDecodeAccelerator::SupportedProfiles profiles;
256 media::VideoDecodeAccelerator::SupportedProfile profile;
257 v4l2_fmtdesc fmtdesc;
258 memset(&fmtdesc, 0, sizeof(fmtdesc));
259 fmtdesc.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE;
260
261 for (; Ioctl(VIDIOC_ENUM_FMT, &fmtdesc) == 0; ++fmtdesc.index) {
262 if (std::find(pixelformats, pixelformats + num_formats,
263 fmtdesc.pixelformat) == pixelformats + num_formats)
264 continue;
265 int min_profile, max_profile;
266 switch (fmtdesc.pixelformat) {
267 case V4L2_PIX_FMT_H264:
268 case V4L2_PIX_FMT_H264_SLICE:
269 min_profile = media::H264PROFILE_MIN;
270 max_profile = media::H264PROFILE_MAX;
271 break;
272 case V4L2_PIX_FMT_VP8:
273 case V4L2_PIX_FMT_VP8_FRAME:
274 min_profile = media::VP8PROFILE_MIN;
275 max_profile = media::VP8PROFILE_MAX;
276 break;
277 case V4L2_PIX_FMT_VP9:
278 min_profile = media::VP9PROFILE_MIN;
279 max_profile = media::VP9PROFILE_MAX;
280 break;
281 default:
282 NOTREACHED() << "Unhandled pixelformat " << std::hex
283 << fmtdesc.pixelformat;
284 return profiles;
285 }
286 GetSupportedResolution(fmtdesc.pixelformat, &profile.min_resolution,
287 &profile.max_resolution);
288 for (int media_profile = min_profile; media_profile <= max_profile;
289 ++media_profile) {
290 profile.profile = static_cast<media::VideoCodecProfile>(media_profile);
291 profiles.push_back(profile);
292 }
293 }
294 return profiles;
295 }
296
200 } // namespace content 297 } // namespace content
OLDNEW
« no previous file with comments | « content/common/gpu/media/v4l2_device.h ('k') | content/common/gpu/media/v4l2_slice_video_decode_accelerator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698