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, ...@@ -284,40 +284,31 @@ float GetAbsoluteMaxFrameRate( vlc_object_t *obj, int fd,
fse.discrete.width, fse.discrete.height ); fse.discrete.width, fse.discrete.height );
if( fps > max ) if( fps > max )
max = fps; max = fps;
msg_Dbg( obj, " discrete size %"PRIu32"x%"PRIu32" supported",
fse.discrete.width, fse.discrete.height );
fse.index++; fse.index++;
} while( v4l2_ioctl( fd, VIDIOC_ENUM_FRAMESIZES, &fse ) >= 0 ); } while( v4l2_ioctl( fd, VIDIOC_ENUM_FRAMESIZES, &fse ) >= 0 );
break; break;
case V4L2_FRMSIZE_TYPE_STEPWISE: case V4L2_FRMSIZE_TYPE_STEPWISE:
for( uint32_t width = fse.stepwise.min_width, case V4L2_FRMSIZE_TYPE_CONTINUOUS:
height = fse.stepwise.min_height; msg_Dbg( obj, " sizes from %"PRIu32"x%"PRIu32" "
width <= fse.stepwise.max_width "to %"PRIu32"x%"PRIu32" supported",
&& height <= fse.stepwise.max_width; fse.stepwise.min_width, fse.stepwise.min_height,
width += fse.stepwise.step_width, 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 ) height += fse.stepwise.step_height )
{ {
float fps = GetMaxFPS( obj, fd, pixel_format, width, height ); float fps = GetMaxFPS( obj, fd, pixel_format, width, height );
if( fps > max ) if( fps > max )
max = fps; 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; break;
} }
return max; return max;
...@@ -346,6 +337,9 @@ void GetMaxDimensions( vlc_object_t *obj, int fd, uint32_t pixel_format, ...@@ -346,6 +337,9 @@ void GetMaxDimensions( vlc_object_t *obj, int fd, uint32_t pixel_format,
case V4L2_FRMSIZE_TYPE_DISCRETE: case V4L2_FRMSIZE_TYPE_DISCRETE:
do do
{ {
msg_Dbg( obj, " discrete size %"PRIu32"x%"PRIu32" supported",
fse.discrete.width, fse.discrete.height );
float fps = GetMaxFPS( obj, fd, pixel_format, float fps = GetMaxFPS( obj, fd, pixel_format,
fse.discrete.width, fse.discrete.height ); fse.discrete.width, fse.discrete.height );
if( fps >= fps_min && fse.discrete.width > *pwidth ) if( fps >= fps_min && fse.discrete.width > *pwidth )
...@@ -354,15 +348,25 @@ void GetMaxDimensions( vlc_object_t *obj, int fd, uint32_t pixel_format, ...@@ -354,15 +348,25 @@ void GetMaxDimensions( vlc_object_t *obj, int fd, uint32_t pixel_format,
*pheight = fse.discrete.height; *pheight = fse.discrete.height;
} }
fse.index++; fse.index++;
} while( v4l2_ioctl( fd, VIDIOC_ENUM_FRAMESIZES, &fse ) >= 0 ); }
while( v4l2_ioctl( fd, VIDIOC_ENUM_FRAMESIZES, &fse ) >= 0 );
break; break;
case V4L2_FRMSIZE_TYPE_STEPWISE: case V4L2_FRMSIZE_TYPE_STEPWISE:
for( uint32_t width = fse.stepwise.min_width, case V4L2_FRMSIZE_TYPE_CONTINUOUS:
height = fse.stepwise.min_height; msg_Dbg( obj, " sizes from %"PRIu32"x%"PRIu32" "
width <= fse.stepwise.max_width "to %"PRIu32"x%"PRIu32" supported",
&& height <= fse.stepwise.max_width; fse.stepwise.min_width, fse.stepwise.min_height,
width += fse.stepwise.step_width, 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 ) height += fse.stepwise.step_height )
{ {
float fps = GetMaxFPS( obj, fd, pixel_format, width, 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, ...@@ -373,19 +377,6 @@ void GetMaxDimensions( vlc_object_t *obj, int fd, uint32_t pixel_format,
} }
} }
break; 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 #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