Commit 8853c752 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

v4l2: fix step-wise and continuous frame sizes enumeration

Width and height are independent for step-wise frame sizes (yes,
enumerating is slow). Continuous frame sizes are step-size with one
pixel steps for both dimensions (yes, enumerationg is very slow).

A few device drivers use either of those two types, though the discrete
type is much more common.
parent b79c09ce
......@@ -284,40 +284,31 @@ float GetAbsoluteMaxFrameRate( vlc_object_t *obj, int fd,
fse.discrete.width, fse.discrete.height );
if( fps > max )
max = fps;
msg_Dbg( obj, " discrete size %"PRIu32"x%"PRIu32" supported",
fse.discrete.width, fse.discrete.height );
fse.index++;
} while( v4l2_ioctl( fd, VIDIOC_ENUM_FRAMESIZES, &fse ) >= 0 );
break;
case V4L2_FRMSIZE_TYPE_STEPWISE:
for( uint32_t width = fse.stepwise.min_width,
height = fse.stepwise.min_height;
width <= fse.stepwise.max_width
&& height <= fse.stepwise.max_width;
width += fse.stepwise.step_width,
case V4L2_FRMSIZE_TYPE_CONTINUOUS:
msg_Dbg( obj, " sizes from %"PRIu32"x%"PRIu32" "
"to %"PRIu32"x%"PRIu32" supported",
fse.stepwise.min_width, fse.stepwise.min_height,
fse.stepwise.max_width, fse.stepwise.max_height );
if( fse.type == V4L2_FRMSIZE_TYPE_STEPWISE )
msg_Dbg( obj, " with %"PRIu32"x%"PRIu32" steps",
fse.stepwise.step_width, fse.stepwise.step_height );
for( uint32_t width = fse.stepwise.min_width;
width <= fse.stepwise.max_width;
width += fse.stepwise.step_width )
for( uint32_t height = fse.stepwise.min_height;
height <= fse.stepwise.max_width;
height += fse.stepwise.step_height )
{
float fps = GetMaxFPS( obj, fd, pixel_format, width, height );
if( fps > max )
max = fps;
}
msg_Dbg( obj, " sizes from %"PRIu32"x%"PRIu32" to %"PRIu32
"x%"PRIu32" supported with %"PRIu32"x%"PRIu32" steps",
fse.stepwise.min_width, fse.stepwise.min_height,
fse.stepwise.max_width, fse.stepwise.max_height,
fse.stepwise.step_width, fse.stepwise.step_height );
break;
case V4L2_FRMSIZE_TYPE_CONTINUOUS:
/* FIXME */
msg_Err( obj, "V4L2_FRMSIZE_TYPE_CONTINUOUS support incorrect" );
max = GetMaxFPS( obj, fd, pixel_format, fse.stepwise.max_width,
fse.stepwise.max_height );
msg_Dbg( obj, " sizes from %"PRIu32"x%"PRIu32" to %"PRIu32
"x%"PRIu32" all supported",
fse.stepwise.min_width, fse.stepwise.min_height,
fse.stepwise.max_width, fse.stepwise.max_height );
break;
}
return max;
......@@ -346,6 +337,9 @@ void GetMaxDimensions( vlc_object_t *obj, int fd, uint32_t pixel_format,
case V4L2_FRMSIZE_TYPE_DISCRETE:
do
{
msg_Dbg( obj, " discrete size %"PRIu32"x%"PRIu32" supported",
fse.discrete.width, fse.discrete.height );
float fps = GetMaxFPS( obj, fd, pixel_format,
fse.discrete.width, fse.discrete.height );
if( fps >= fps_min && fse.discrete.width > *pwidth )
......@@ -354,15 +348,25 @@ void GetMaxDimensions( vlc_object_t *obj, int fd, uint32_t pixel_format,
*pheight = fse.discrete.height;
}
fse.index++;
} while( v4l2_ioctl( fd, VIDIOC_ENUM_FRAMESIZES, &fse ) >= 0 );
}
while( v4l2_ioctl( fd, VIDIOC_ENUM_FRAMESIZES, &fse ) >= 0 );
break;
case V4L2_FRMSIZE_TYPE_STEPWISE:
for( uint32_t width = fse.stepwise.min_width,
height = fse.stepwise.min_height;
width <= fse.stepwise.max_width
&& height <= fse.stepwise.max_width;
width += fse.stepwise.step_width,
case V4L2_FRMSIZE_TYPE_CONTINUOUS:
msg_Dbg( obj, " sizes from %"PRIu32"x%"PRIu32" "
"to %"PRIu32"x%"PRIu32" supported",
fse.stepwise.min_width, fse.stepwise.min_height,
fse.stepwise.max_width, fse.stepwise.max_height );
if( fse.type == V4L2_FRMSIZE_TYPE_STEPWISE )
msg_Dbg( obj, " with %"PRIu32"x%"PRIu32" steps",
fse.stepwise.step_width, fse.stepwise.step_height );
for( uint32_t width = fse.stepwise.min_width;
width <= fse.stepwise.max_width;
width += fse.stepwise.step_width )
for( uint32_t height = fse.stepwise.min_height;
height <= fse.stepwise.max_width;
height += fse.stepwise.step_height )
{
float fps = GetMaxFPS( obj, fd, pixel_format, width, height );
......@@ -373,19 +377,6 @@ void GetMaxDimensions( vlc_object_t *obj, int fd, uint32_t pixel_format,
}
}
break;
case V4L2_FRMSIZE_TYPE_CONTINUOUS:
{
float fps = GetMaxFPS( obj, fd, pixel_format,
fse.stepwise.max_width, fse.stepwise.max_height );
msg_Err( obj, "V4L2_FRMSIZE_TYPE_CONTINUOUS support incorrect" );
if( fps >= fps_min && fse.stepwise.max_width > *pwidth )
{
*pwidth = fse.stepwise.max_width;
*pheight = fse.stepwise.max_height;
}
break;
}
}
#endif
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment