Chromium Code Reviews| 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 "media/gpu/v4l2_video_encode_accelerator.h" | 5 #include "media/gpu/v4l2_video_encode_accelerator.h" |
| 6 | 6 |
| 7 #include <fcntl.h> | 7 #include <fcntl.h> |
| 8 #include <linux/videodev2.h> | 8 #include <linux/videodev2.h> |
| 9 #include <poll.h> | 9 #include <poll.h> |
| 10 #include <string.h> | 10 #include <string.h> |
| (...skipping 1063 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1074 DCHECK(child_task_runner_->BelongsToCurrentThread()); | 1074 DCHECK(child_task_runner_->BelongsToCurrentThread()); |
| 1075 DCHECK(!input_streamon_); | 1075 DCHECK(!input_streamon_); |
| 1076 DCHECK(!output_streamon_); | 1076 DCHECK(!output_streamon_); |
| 1077 | 1077 |
| 1078 if (!SetOutputFormat(output_profile)) | 1078 if (!SetOutputFormat(output_profile)) |
| 1079 return false; | 1079 return false; |
| 1080 | 1080 |
| 1081 if (!NegotiateInputFormat(input_format)) | 1081 if (!NegotiateInputFormat(input_format)) |
| 1082 return false; | 1082 return false; |
| 1083 | 1083 |
| 1084 struct v4l2_rect ioctl_rect; | |
|
wuchengli
2017/06/29 07:55:23
s/ioctl_rect/visible_rect/. It's more readable.
| |
| 1085 ioctl_rect.left = 0; | |
| 1086 ioctl_rect.top = 0; | |
| 1087 ioctl_rect.width = visible_size_.width(); | |
| 1088 ioctl_rect.height = visible_size_.height(); | |
| 1089 | |
| 1090 struct v4l2_selection selection_arg; | |
| 1091 memset(&selection_arg, 0, sizeof(selection_arg)); | |
| 1092 selection_arg.type = V4L2_BUF_TYPE_VIDEO_OUTPUT; | |
| 1093 selection_arg.target = V4L2_SEL_TGT_CROP; | |
| 1094 selection_arg.r = ioctl_rect; | |
| 1095 | |
| 1084 struct v4l2_crop crop; | 1096 struct v4l2_crop crop; |
| 1085 memset(&crop, 0, sizeof(crop)); | 1097 memset(&crop, 0, sizeof(crop)); |
| 1086 crop.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; | 1098 crop.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; |
| 1087 crop.c.left = 0; | 1099 |
| 1088 crop.c.top = 0; | 1100 if (device_->Ioctl(VIDIOC_S_SELECTION, &selection_arg) != 0) { |
|
wuchengli
2017/06/29 07:55:23
if (device_->Ioctl(VIDIOC_S_SELECTION, &selection_
| |
| 1089 crop.c.width = visible_size_.width(); | 1101 VLOG(2) << "Fallback to VIDIOC_S_CROP"; |
|
wuchengli
2017/06/29 07:55:23
DVLOG
| |
| 1090 crop.c.height = visible_size_.height(); | 1102 crop.c = ioctl_rect; |
| 1091 IOCTL_OR_ERROR_RETURN_FALSE(VIDIOC_S_CROP, &crop); | 1103 IOCTL_OR_ERROR_RETURN_FALSE(VIDIOC_S_CROP, &crop); |
| 1104 } | |
| 1092 | 1105 |
| 1093 // The width and height might be adjusted by driver. | 1106 // The width and height might be adjusted by driver. |
| 1094 // Need to read it back and set to visible_size_. | 1107 // Need to read it back and set to visible_size_. |
| 1095 IOCTL_OR_ERROR_RETURN_FALSE(VIDIOC_G_CROP, &crop); | 1108 if (device_->Ioctl(VIDIOC_G_SELECTION, &selection_arg) == 0) { |
| 1096 visible_size_.SetSize(crop.c.width, crop.c.height); | 1109 ioctl_rect = selection_arg.r; |
| 1110 } | |
| 1111 else { | |
| 1112 VLOG(2) << "Fallback to VIDIOC_G_CROP"; | |
|
wuchengli
2017/06/29 07:55:23
DVLOG
| |
| 1113 IOCTL_OR_ERROR_RETURN_FALSE(VIDIOC_G_CROP, &crop); | |
| 1114 ioctl_rect = crop.c; | |
| 1115 } | |
| 1116 visible_size_.SetSize(ioctl_rect.width, ioctl_rect.height); | |
| 1097 DVLOG(3) << "After adjusted by driver, visible_size_=" | 1117 DVLOG(3) << "After adjusted by driver, visible_size_=" |
| 1098 << visible_size_.ToString(); | 1118 << visible_size_.ToString(); |
| 1099 | 1119 |
| 1100 return true; | 1120 return true; |
| 1101 } | 1121 } |
| 1102 | 1122 |
| 1103 bool V4L2VideoEncodeAccelerator::IsCtrlExposed(uint32_t ctrl_id) { | 1123 bool V4L2VideoEncodeAccelerator::IsCtrlExposed(uint32_t ctrl_id) { |
| 1104 struct v4l2_queryctrl query_ctrl; | 1124 struct v4l2_queryctrl query_ctrl; |
| 1105 memset(&query_ctrl, 0, sizeof(query_ctrl)); | 1125 memset(&query_ctrl, 0, sizeof(query_ctrl)); |
| 1106 query_ctrl.id = ctrl_id; | 1126 query_ctrl.id = ctrl_id; |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1333 memset(&reqbufs, 0, sizeof(reqbufs)); | 1353 memset(&reqbufs, 0, sizeof(reqbufs)); |
| 1334 reqbufs.count = 0; | 1354 reqbufs.count = 0; |
| 1335 reqbufs.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; | 1355 reqbufs.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; |
| 1336 reqbufs.memory = V4L2_MEMORY_MMAP; | 1356 reqbufs.memory = V4L2_MEMORY_MMAP; |
| 1337 IOCTL_OR_LOG_ERROR(VIDIOC_REQBUFS, &reqbufs); | 1357 IOCTL_OR_LOG_ERROR(VIDIOC_REQBUFS, &reqbufs); |
| 1338 | 1358 |
| 1339 output_buffer_map_.clear(); | 1359 output_buffer_map_.clear(); |
| 1340 } | 1360 } |
| 1341 | 1361 |
| 1342 } // namespace media | 1362 } // namespace media |
| OLD | NEW |