- p_sys->f_fps = GetAbsoluteMaxFrameRate( p_demux, i_fd,
- fmt.fmt.pix.pixelformat );
- msg_Dbg( p_demux, "Found maximum framerate of %f", p_sys->f_fps );
+ if( p_sys->f_fps <= 0 )
+ {
+ p_sys->f_fps = GetAbsoluteMaxFrameRate( p_demux, i_fd,
+ fmt.fmt.pix.pixelformat );
+ msg_Dbg( p_demux, "Found maximum framerate of %f", p_sys->f_fps );
+ }
+ uint32_t i_width, i_height;
+ GetMaxDimensions( p_demux, i_fd,
+ fmt.fmt.pix.pixelformat, p_sys->f_fps,
+ &i_width, &i_height );
+ if( 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 )
+ {
+ 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, "
+ "falling back to driver default." );
+ }