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

Unified Diff: media/gpu/v4l2_video_encode_accelerator.cc

Issue 2958213002: V4L2 VDA/VEA: Use VIDIOC_G/S_SELECTION for accelerators (Closed)
Patch Set: Created 3 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: media/gpu/v4l2_video_encode_accelerator.cc
diff --git a/media/gpu/v4l2_video_encode_accelerator.cc b/media/gpu/v4l2_video_encode_accelerator.cc
index b09b6420a3f14c576831fb43f7ccf520b578eea7..99647613b0230277836d48fae30631869811489a 100644
--- a/media/gpu/v4l2_video_encode_accelerator.cc
+++ b/media/gpu/v4l2_video_encode_accelerator.cc
@@ -1081,19 +1081,39 @@ bool V4L2VideoEncodeAccelerator::SetFormats(VideoPixelFormat input_format,
if (!NegotiateInputFormat(input_format))
return false;
+ struct v4l2_rect ioctl_rect;
wuchengli 2017/06/29 07:55:23 s/ioctl_rect/visible_rect/. It's more readable.
+ ioctl_rect.left = 0;
+ ioctl_rect.top = 0;
+ ioctl_rect.width = visible_size_.width();
+ ioctl_rect.height = visible_size_.height();
+
+ struct v4l2_selection selection_arg;
+ memset(&selection_arg, 0, sizeof(selection_arg));
+ selection_arg.type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
+ selection_arg.target = V4L2_SEL_TGT_CROP;
+ selection_arg.r = ioctl_rect;
+
struct v4l2_crop crop;
memset(&crop, 0, sizeof(crop));
crop.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE;
- crop.c.left = 0;
- crop.c.top = 0;
- crop.c.width = visible_size_.width();
- crop.c.height = visible_size_.height();
- IOCTL_OR_ERROR_RETURN_FALSE(VIDIOC_S_CROP, &crop);
+
+ if (device_->Ioctl(VIDIOC_S_SELECTION, &selection_arg) != 0) {
wuchengli 2017/06/29 07:55:23 if (device_->Ioctl(VIDIOC_S_SELECTION, &selection_
+ VLOG(2) << "Fallback to VIDIOC_S_CROP";
wuchengli 2017/06/29 07:55:23 DVLOG
+ crop.c = ioctl_rect;
+ IOCTL_OR_ERROR_RETURN_FALSE(VIDIOC_S_CROP, &crop);
+ }
// The width and height might be adjusted by driver.
// Need to read it back and set to visible_size_.
- IOCTL_OR_ERROR_RETURN_FALSE(VIDIOC_G_CROP, &crop);
- visible_size_.SetSize(crop.c.width, crop.c.height);
+ if (device_->Ioctl(VIDIOC_G_SELECTION, &selection_arg) == 0) {
+ ioctl_rect = selection_arg.r;
+ }
+ else {
+ VLOG(2) << "Fallback to VIDIOC_G_CROP";
wuchengli 2017/06/29 07:55:23 DVLOG
+ IOCTL_OR_ERROR_RETURN_FALSE(VIDIOC_G_CROP, &crop);
+ ioctl_rect = crop.c;
+ }
+ visible_size_.SetSize(ioctl_rect.width, ioctl_rect.height);
DVLOG(3) << "After adjusted by driver, visible_size_="
<< visible_size_.ToString();
« media/gpu/v4l2_video_decode_accelerator.cc ('K') | « media/gpu/v4l2_video_decode_accelerator.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698