[vlc-devel] commit: v4l2: rework size detection (Pierre Ynard )
git version control
git at videolan.org
Mon Oct 19 21:41:27 CEST 2009
vlc | branch: 1.0-bugfix | Pierre Ynard <linkfanel at yahoo.fr> | Fri Oct 16 19:21:51 2009 +0200| [396918e806738b2786db08c4a39033f9a0399e74] | committer: Pierre Ynard
v4l2: rework size detection
This fixes my TV card, and should be backported after testing
(cherry picked from commit 881aa894c58b3d4105276088e7b3593677ee2098)
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=396918e806738b2786db08c4a39033f9a0399e74
---
modules/access/v4l2.c | 40 +++++++++++++++++++++-------------------
1 files changed, 21 insertions(+), 19 deletions(-)
diff --git a/modules/access/v4l2.c b/modules/access/v4l2.c
index 113162d..41d3566 100644
--- a/modules/access/v4l2.c
+++ b/modules/access/v4l2.c
@@ -1996,7 +1996,7 @@ static int OpenVideoDev( vlc_object_t *p_obj, demux_sys_t *p_sys, bool b_demux )
memset( &fmt, 0, sizeof(fmt) );
fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
- if( p_sys->i_width == 0 || p_sys->i_height == 0 )
+ if( p_sys->i_width <= 0 || p_sys->i_height <= 0 )
{
/* Use current width and height settings */
if( v4l2_ioctl( i_fd, VIDIOC_G_FMT, &fmt ) < 0 )
@@ -2005,26 +2005,22 @@ static int OpenVideoDev( vlc_object_t *p_obj, demux_sys_t *p_sys, bool b_demux )
goto open_failed;
}
- p_sys->i_width = fmt.fmt.pix.width;
- p_sys->i_height = fmt.fmt.pix.height;
+ msg_Dbg( p_obj, "found default width and height of %ux%u",
+ fmt.fmt.pix.width, fmt.fmt.pix.height );
- if( fmt.fmt.pix.field == V4L2_FIELD_ALTERNATE )
+ if( p_sys->i_width < 0 || p_sys->i_height < 0 )
{
- p_sys->i_height = p_sys->i_height * 2;
+ msg_Dbg( p_obj, "will try to find optimal width and height." );
}
}
- else if( p_sys->i_width < 0 || p_sys->i_height < 0 )
- {
- msg_Dbg( p_obj, "will try to find optimal width and height." );
- }
else
{
/* Use user specified width and height */
msg_Dbg( p_obj, "trying specified size %dx%d", p_sys->i_width, p_sys->i_height );
+ fmt.fmt.pix.width = p_sys->i_width;
+ fmt.fmt.pix.height = p_sys->i_height;
}
- fmt.fmt.pix.width = __MAX(0, p_sys->i_width);
- fmt.fmt.pix.height = __MAX(0, p_sys->i_height);
fmt.fmt.pix.field = V4L2_FIELD_NONE;
if (b_demux)
@@ -2108,23 +2104,28 @@ static int OpenVideoDev( vlc_object_t *p_obj, demux_sys_t *p_sys, bool b_demux )
&i_width, &i_height );
if( i_width || i_height )
{
- msg_Dbg( p_demux, "Found optimal dimensions for framerate %f of %dx%d",
- p_sys->f_fps, i_width, i_height );
+ msg_Dbg( p_demux, "Found optimal dimensions for framerate %f "
+ "of %ux%u", p_sys->f_fps, i_width, i_height );
fmt.fmt.pix.width = i_width;
fmt.fmt.pix.height = i_height;
- if( v4l2_ioctl( i_fd, VIDIOC_S_FMT, &fmt ) < 0 ) {;}
+ if( v4l2_ioctl( i_fd, VIDIOC_S_FMT, &fmt ) < 0 )
+ {
+ msg_Err( p_obj, "Cannot set size to optimal dimensions "
+ "%ux%u", i_width, i_height );
+ goto open_failed;
+ }
}
else
{
- msg_Warn( p_obj, "Could not find optimal width and height." );
+ msg_Warn( p_obj, "Could not find optimal width and height, "
+ "falling back to driver default." );
}
}
-
- /* Reassign width, height and chroma incase driver override */
- p_sys->i_width = fmt.fmt.pix.width;
- p_sys->i_height = fmt.fmt.pix.height;
}
+ p_sys->i_width = fmt.fmt.pix.width;
+ p_sys->i_height = fmt.fmt.pix.height;
+
if( v4l2_ioctl( i_fd, VIDIOC_G_FMT, &fmt ) < 0 ) {;}
/* Print extra info */
msg_Dbg( p_obj, "Driver requires at most %d bytes to store a complete image", fmt.fmt.pix.sizeimage );
@@ -2151,6 +2152,7 @@ static int OpenVideoDev( vlc_object_t *p_obj, demux_sys_t *p_sys, bool b_demux )
break;
case V4L2_FIELD_ALTERNATE:
msg_Dbg( p_obj, "Interlacing setting: alternate fields" );
+ p_sys->i_height = p_sys->i_height * 2;
break;
case V4L2_FIELD_INTERLACED_TB:
msg_Dbg( p_obj, "Interlacing setting: interleaved top bottom" );
More information about the vlc-devel
mailing list