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

Unified Diff: media/gpu/v4l2_video_encode_accelerator.cc

Issue 2958213002: V4L2 VDA/VEA: Use VIDIOC_G/S_SELECTION for accelerators (Closed)
Patch Set: V4L2 VDA/VEA: Use VIDIOC_G/S_SELECTION for codec drivers Created 3 years, 5 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
« no previous file with comments | « media/gpu/v4l2_video_decode_accelerator.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..144490444aba8ba3e0100e7dcef02bfff26b975c 100644
--- a/media/gpu/v4l2_video_encode_accelerator.cc
+++ b/media/gpu/v4l2_video_encode_accelerator.cc
@@ -1081,19 +1081,35 @@ bool V4L2VideoEncodeAccelerator::SetFormats(VideoPixelFormat input_format,
if (!NegotiateInputFormat(input_format))
return false;
- 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);
+ struct v4l2_rect visible_rect;
+ visible_rect.left = 0;
+ visible_rect.top = 0;
+ visible_rect.width = visible_size_.width();
+ visible_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 = visible_rect;
// 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_S_SELECTION, &selection_arg) == 0) {
+ DVLOG(2) << "VIDIOC_S_SELECTION is supported";
+ visible_rect = selection_arg.r;
+ } else {
+ DVLOG(2) << "Fallback to VIDIOC_S/G_CROP";
+ struct v4l2_crop crop;
+ memset(&crop, 0, sizeof(crop));
+ crop.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE;
+ crop.c = visible_rect;
+ IOCTL_OR_ERROR_RETURN_FALSE(VIDIOC_S_CROP, &crop);
+ IOCTL_OR_ERROR_RETURN_FALSE(VIDIOC_G_CROP, &crop);
+ visible_rect = crop.c;
+ }
+
+ visible_size_.SetSize(visible_rect.width, visible_rect.height);
DVLOG(3) << "After adjusted by driver, visible_size_="
<< visible_size_.ToString();
« no previous file with comments | « 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