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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « media/gpu/v4l2_video_decode_accelerator.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "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
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_crop crop; 1084 struct v4l2_rect visible_rect;
1085 memset(&crop, 0, sizeof(crop)); 1085 visible_rect.left = 0;
1086 crop.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; 1086 visible_rect.top = 0;
1087 crop.c.left = 0; 1087 visible_rect.width = visible_size_.width();
1088 crop.c.top = 0; 1088 visible_rect.height = visible_size_.height();
1089 crop.c.width = visible_size_.width(); 1089
1090 crop.c.height = visible_size_.height(); 1090 struct v4l2_selection selection_arg;
1091 IOCTL_OR_ERROR_RETURN_FALSE(VIDIOC_S_CROP, &crop); 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 = visible_rect;
1092 1095
1093 // The width and height might be adjusted by driver. 1096 // The width and height might be adjusted by driver.
1094 // Need to read it back and set to visible_size_. 1097 // Need to read it back and set to visible_size_.
1095 IOCTL_OR_ERROR_RETURN_FALSE(VIDIOC_G_CROP, &crop); 1098 if (device_->Ioctl(VIDIOC_S_SELECTION, &selection_arg) == 0) {
1096 visible_size_.SetSize(crop.c.width, crop.c.height); 1099 DVLOG(2) << "VIDIOC_S_SELECTION is supported";
1100 visible_rect = selection_arg.r;
1101 } else {
1102 DVLOG(2) << "Fallback to VIDIOC_S/G_CROP";
1103 struct v4l2_crop crop;
1104 memset(&crop, 0, sizeof(crop));
1105 crop.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE;
1106 crop.c = visible_rect;
1107 IOCTL_OR_ERROR_RETURN_FALSE(VIDIOC_S_CROP, &crop);
1108 IOCTL_OR_ERROR_RETURN_FALSE(VIDIOC_G_CROP, &crop);
1109 visible_rect = crop.c;
1110 }
1111
1112 visible_size_.SetSize(visible_rect.width, visible_rect.height);
1097 DVLOG(3) << "After adjusted by driver, visible_size_=" 1113 DVLOG(3) << "After adjusted by driver, visible_size_="
1098 << visible_size_.ToString(); 1114 << visible_size_.ToString();
1099 1115
1100 return true; 1116 return true;
1101 } 1117 }
1102 1118
1103 bool V4L2VideoEncodeAccelerator::IsCtrlExposed(uint32_t ctrl_id) { 1119 bool V4L2VideoEncodeAccelerator::IsCtrlExposed(uint32_t ctrl_id) {
1104 struct v4l2_queryctrl query_ctrl; 1120 struct v4l2_queryctrl query_ctrl;
1105 memset(&query_ctrl, 0, sizeof(query_ctrl)); 1121 memset(&query_ctrl, 0, sizeof(query_ctrl));
1106 query_ctrl.id = ctrl_id; 1122 query_ctrl.id = ctrl_id;
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
1333 memset(&reqbufs, 0, sizeof(reqbufs)); 1349 memset(&reqbufs, 0, sizeof(reqbufs));
1334 reqbufs.count = 0; 1350 reqbufs.count = 0;
1335 reqbufs.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; 1351 reqbufs.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
1336 reqbufs.memory = V4L2_MEMORY_MMAP; 1352 reqbufs.memory = V4L2_MEMORY_MMAP;
1337 IOCTL_OR_LOG_ERROR(VIDIOC_REQBUFS, &reqbufs); 1353 IOCTL_OR_LOG_ERROR(VIDIOC_REQBUFS, &reqbufs);
1338 1354
1339 output_buffer_map_.clear(); 1355 output_buffer_map_.clear();
1340 } 1356 }
1341 1357
1342 } // namespace media 1358 } // namespace media
OLDNEW
« 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