Chromium Code Reviews| 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(); |