aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomi Valkeinen2017-10-03 04:45:59 -0500
committerTomi Valkeinen2017-10-03 04:45:59 -0500
commit35d54fdddd6d7add49efbb0d9dec30816de96c90 (patch)
tree144da02be879de6864bac55d15931d4a2e4b872c
parent3ae05a32c0b9dcc4a83463c51f1abf5289cb4fe9 (diff)
downloadexternal-libkmsxx-35d54fdddd6d7add49efbb0d9dec30816de96c90.tar.gz
external-libkmsxx-35d54fdddd6d7add49efbb0d9dec30816de96c90.tar.xz
external-libkmsxx-35d54fdddd6d7add49efbb0d9dec30816de96c90.zip
kmscapture: fix capture videomode heuristic
-rw-r--r--utils/kmscapture.cpp25
1 files changed, 18 insertions, 7 deletions
diff --git a/utils/kmscapture.cpp b/utils/kmscapture.cpp
index 1a9b51b..01eac61 100644
--- a/utils/kmscapture.cpp
+++ b/utils/kmscapture.cpp
@@ -110,15 +110,23 @@ CameraPipeline::CameraPipeline(int cam_fd, Card& card, Crtc *crtc, Plane* plane,
110 struct v4l2_frmsizeenum v4lfrms = { }; 110 struct v4l2_frmsizeenum v4lfrms = { };
111 v4lfrms.pixel_format = (uint32_t)pixfmt; 111 v4lfrms.pixel_format = (uint32_t)pixfmt;
112 while (ioctl(m_fd, VIDIOC_ENUM_FRAMESIZES, &v4lfrms) == 0) { 112 while (ioctl(m_fd, VIDIOC_ENUM_FRAMESIZES, &v4lfrms) == 0) {
113 if (v4lfrms.type == V4L2_FRMSIZE_TYPE_DISCRETE) { 113 if (v4lfrms.type != V4L2_FRMSIZE_TYPE_DISCRETE) {
114 if (better_size(&v4lfrms.discrete, iw, ih, 114 v4lfrms.index++;
115 best_w, best_h)) { 115 continue;
116 best_w = v4lfrms.discrete.width; 116 }
117 best_h = v4lfrms.discrete.height; 117
118 } 118 if (v4lfrms.discrete.width > iw || v4lfrms.discrete.height > ih) {
119 } else { 119 //skip
120 } else if (v4lfrms.discrete.width == iw && v4lfrms.discrete.height == ih) {
121 // Exact match
122 best_w = v4lfrms.discrete.width;
123 best_h = v4lfrms.discrete.height;
120 break; 124 break;
125 } else if (v4lfrms.discrete.width >= best_w || v4lfrms.discrete.height >= ih) {
126 best_w = v4lfrms.discrete.width;
127 best_h = v4lfrms.discrete.height;
121 } 128 }
129
122 v4lfrms.index++; 130 v4lfrms.index++;
123 }; 131 };
124 132
@@ -128,6 +136,8 @@ CameraPipeline::CameraPipeline(int cam_fd, Card& card, Crtc *crtc, Plane* plane,
128 m_out_x = x + iw / 2 - m_out_width / 2; 136 m_out_x = x + iw / 2 - m_out_width / 2;
129 m_out_y = y + ih / 2 - m_out_height / 2; 137 m_out_y = y + ih / 2 - m_out_height / 2;
130 138
139 printf("Capture: %ux%u\n", best_w, best_h);
140
131 struct v4l2_format v4lfmt = { }; 141 struct v4l2_format v4lfmt = { };
132 v4lfmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; 142 v4lfmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
133 r = ioctl(m_fd, VIDIOC_G_FMT, &v4lfmt); 143 r = ioctl(m_fd, VIDIOC_G_FMT, &v4lfmt);
@@ -341,6 +351,7 @@ int main(int argc, char** argv)
341 } 351 }
342 352
343 camera_fds.push_back(fd); 353 camera_fds.push_back(fd);
354 printf("Using %s\n", vidpath.c_str());
344 355
345 if (single_cam) 356 if (single_cam)
346 break; 357 break;