Commit 89779c4a authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

V4L2: merge two switches

parent 7a82c844
......@@ -1931,7 +1931,7 @@ static int OpenVideoDev( vlc_object_t *p_obj, const char *path,
#endif
/* Init IO method */
/* Init I/O method */
switch( p_sys->io )
{
case IO_METHOD_READ:
......@@ -1942,55 +1942,6 @@ static int OpenVideoDev( vlc_object_t *p_obj, const char *path,
case IO_METHOD_MMAP:
if( InitMmap( p_obj, p_sys, i_fd ) )
goto error;
break;
case IO_METHOD_USERPTR:
if( InitUserP( p_obj, p_sys, i_fd, fmt.fmt.pix.sizeimage ) )
goto error;
break;
}
if( b_demux )
{
int ar = 4 * VOUT_ASPECT_FACTOR / 3;
char *str = var_InheritString( p_obj, CFG_PREFIX"aspect-ratio" );
if( likely(str != NULL) )
{
const char *delim = strchr( str, ':' );
if( delim )
ar = atoi( str ) * VOUT_ASPECT_FACTOR / atoi( delim + 1 );
free( str );
}
/* Add */
es_fmt.video.i_width = width;
es_fmt.video.i_height = height;
/* Get aspect-ratio */
es_fmt.video.i_sar_num = ar * es_fmt.video.i_height;
es_fmt.video.i_sar_den = VOUT_ASPECT_FACTOR * es_fmt.video.i_width;
/* Framerate */
es_fmt.video.i_frame_rate = lround(f_fps * 1000000.);
es_fmt.video.i_frame_rate_base = 1000000;
demux_t *p_demux = (demux_t *) p_obj;
msg_Dbg( p_demux, "added new video es %4.4s %dx%d",
(char*)&es_fmt.i_codec, es_fmt.video.i_width, es_fmt.video.i_height );
msg_Dbg( p_obj, " frame rate: %f", f_fps );
p_sys->p_es = es_out_Add( p_demux->out, &es_fmt );
}
/* Start Capture */
switch( p_sys->io )
{
case IO_METHOD_READ:
/* Nothing to do */
break;
case IO_METHOD_MMAP:
for (unsigned int i = 0; i < p_sys->i_nbuffers; ++i)
{
struct v4l2_buffer buf;
......@@ -2013,10 +1964,11 @@ static int OpenVideoDev( vlc_object_t *p_obj, const char *path,
msg_Err( p_obj, "VIDIOC_STREAMON failed" );
goto error;
}
break;
case IO_METHOD_USERPTR:
if( InitUserP( p_obj, p_sys, i_fd, fmt.fmt.pix.sizeimage ) )
goto error;
for( unsigned int i = 0; i < p_sys->i_nbuffers; ++i )
{
struct v4l2_buffer buf;
......@@ -2045,6 +1997,38 @@ static int OpenVideoDev( vlc_object_t *p_obj, const char *path,
}
free( codecs );
if( b_demux )
{
int ar = 4 * VOUT_ASPECT_FACTOR / 3;
char *str = var_InheritString( p_obj, CFG_PREFIX"aspect-ratio" );
if( likely(str != NULL) )
{
const char *delim = strchr( str, ':' );
if( delim )
ar = atoi( str ) * VOUT_ASPECT_FACTOR / atoi( delim + 1 );
free( str );
}
/* Add */
es_fmt.video.i_width = width;
es_fmt.video.i_height = height;
/* Get aspect-ratio */
es_fmt.video.i_sar_num = ar * es_fmt.video.i_height;
es_fmt.video.i_sar_den = VOUT_ASPECT_FACTOR * es_fmt.video.i_width;
/* Framerate */
es_fmt.video.i_frame_rate = lround(f_fps * 1000000.);
es_fmt.video.i_frame_rate_base = 1000000;
demux_t *p_demux = (demux_t *) p_obj;
msg_Dbg( p_demux, "added new video es %4.4s %dx%d",
(char*)&es_fmt.i_codec, es_fmt.video.i_width, es_fmt.video.i_height );
msg_Dbg( p_obj, " frame rate: %f", f_fps );
p_sys->p_es = es_out_Add( p_demux->out, &es_fmt );
}
return i_fd;
error:
......
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