[Sumover-dev] [svn commit] r4221 - vic/branches/mpeg4/video
sumover-dev at cs.ucl.ac.uk
sumover-dev at cs.ucl.ac.uk
Thu Jul 24 06:41:00 BST 2008
Author: douglask
Date: Thu Jul 24 06:40:55 2008
New Revision: 4221
Modified:
vic/branches/mpeg4/video/grabber-v4l2.cpp
vic/branches/mpeg4/video/grabber-video4linux.cpp
Log:
Apply patch posted by Claus Endres to the AG-tech mailing list, includes fix for resolution selection at large resolution.
Addition fixes include:
debug output fixes, including spelling mistake and missing newlines
fixed pixelformat selection for some UVC webcams that only support uncompressed video at <= QCIF resolution, but MJPEG at higher resolutions
Modified: vic/branches/mpeg4/video/grabber-v4l2.cpp
==============================================================================
--- vic/branches/mpeg4/video/grabber-v4l2.cpp (original)
+++ vic/branches/mpeg4/video/grabber-v4l2.cpp Thu Jul 24 06:40:55 2008
@@ -227,7 +227,7 @@
for (i = 0; dev[i] != NULL; i++) {
debug_msg("V4L2: trying %s... ",dev[i]);
if (-1 == (fd = open(dev[i],O_RDWR))) {
- debug_msg("Error opening: %s : %s", dev[i], strerror(errno));
+ debug_msg("Error opening: %s : %s\n", dev[i], strerror(errno));
continue;
}
memset(&capability,0,sizeof(capability));
@@ -333,25 +333,29 @@
fmt.fmt.pix.height = CIF_HEIGHT;
fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_YUV420;
if (-1 != ioctl(fd_, VIDIOC_S_FMT, &fmt) ) {
- have_YUV420P = 1;
- debug_msg("\nDevice capture V4L2_PIX_FMT_YUV420\n");
+ if (fmt.fmt.pix.height == CIF_HEIGHT) {
+ have_YUV420P = 1;
+ debug_msg("\nDevice supports V4L2_PIX_FMT_YUV420\n");
+ }
}
fmt.fmt.pix.width = CIF_WIDTH;
fmt.fmt.pix.height = CIF_HEIGHT;
fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_YUV422P;
if (-1 != ioctl(fd_, VIDIOC_S_FMT, &fmt) ) {
- have_YUV422P = 1;
- debug_msg("\nDevice capture V4L2_PIX_FMT_YUV422\n");
+ if (fmt.fmt.pix.height == CIF_HEIGHT) {
+ have_YUV422P = 1;
+ debug_msg("\nDevice supports V4L2_PIX_FMT_YUV422\n");
+ }
}
fmt.fmt.pix.width = CIF_WIDTH;
fmt.fmt.pix.height = CIF_HEIGHT;
fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_YUYV;
if (-1 != ioctl(fd_, VIDIOC_S_FMT, &fmt) ) {
- if (fmt.fmt.pix.width <= CIF_WIDTH && fmt.fmt.pix.height <= CIF_HEIGHT) {
+ if (fmt.fmt.pix.height == CIF_HEIGHT) {
have_YUV422 = 1;
- debug_msg("\nDevice capture V4L2_PIX_FMT_YUYV (YUV 4:2:2)\n");
+ debug_msg("\nDevice supports V4L2_PIX_FMT_YUYV (YUV 4:2:2)\n");
}
}
@@ -360,7 +364,7 @@
fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_MJPEG;
if (-1 != ioctl(fd_, VIDIOC_S_FMT, &fmt) ) {
have_MJPEG = 1;
- debug_msg("\nDevice capture V4L2_PIX_FMT_MJPEG\n");
+ debug_msg("\nDevice supports V4L2_PIX_FMT_MJPEG\n");
}
fmt.fmt.pix.width = CIF_WIDTH;
@@ -368,11 +372,11 @@
fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_JPEG;
if (-1 != ioctl(fd_, VIDIOC_S_FMT, &fmt) ) {
have_MJPEG = 1;
- debug_msg("\nDevice capture V4L2_PIX_FMT_JPEG\n");
+ debug_msg("\nDevice supports V4L2_PIX_FMT_JPEG\n");
}
if( !( have_YUV422P || have_YUV422 || have_YUV420P || have_MJPEG || have_JPEG)){
- debug_msg("No suitable palette found\n");
+ debug_msg("No suitable pixelformat found\n");
close(fd_);
status_=-1;
return;
@@ -1141,10 +1145,14 @@
decimate_ = 4;
break;
case 1:
- debug_msg("V4L2: falling back to resolution %dx%d\n", fmt.fmt.pix.width, fmt.fmt.pix.height);
+ debug_msg("V4L2: trying NTSC resolution ...\n");
decimate_ = 0;
- width_ = fmt.fmt.pix.width;
- height_ = fmt.fmt.pix.height;
+ width_ = NTSC_WIDTH;
+ height_ = NTSC_HEIGHT;
+ break;
+ case 0:
+ debug_msg("V4L2: trying resolution under ...\n");
+ decimate_ = 2;
break;
default:
debug_msg("V4L2: giving up ...\n");
Modified: vic/branches/mpeg4/video/grabber-video4linux.cpp
==============================================================================
--- vic/branches/mpeg4/video/grabber-video4linux.cpp (original)
+++ vic/branches/mpeg4/video/grabber-video4linux.cpp Thu Jul 24 06:40:55 2008
@@ -218,7 +218,7 @@
for (i = 0; dev[i] != NULL; i++) {
debug_msg("V4L: trying %s... ", dev[i]);
if (-1 == (fd = open(dev[i], O_RDONLY))) {
- debug_msg("Error opening: %s : %s", dev[i], strerror(errno)); //SV-XXX: sys_errlist deprecated, use strerror()
+ debug_msg("Error opening: %s : %s\n", dev[i], strerror(errno)); //SV-XXX: sys_errlist deprecated, use strerror()
continue;
}
if (-1 == ioctl(fd, VIDIOCGCAP, &capability)) {
@@ -420,7 +420,7 @@
}
if( !( have_422P || have_422 || have_420P)){
- debug_msg("No suituable palette found\n");
+ debug_msg("No suitable palette found\n");
close(fd_);
status_=-1;
return;
More information about the Sumover-dev
mailing list