Commit b2867914 authored by Laurent Aimar's avatar Laurent Aimar

* snapshot: small warning fix + coding rules.

 Btw, the module uses input_Tell that is deprecated, Is it really needed ?
 If so, when ?
parent b8df288b
......@@ -77,7 +77,7 @@ struct vout_sys_t
int i_index; /* Index of the next available list member */
int i_size; /* Size of the cache */
int i_datasize; /* Size of an image */
input_thread_t * p_input; /* The input thread */
input_thread_t *p_input; /* The input thread */
};
/*****************************************************************************
......@@ -127,23 +127,20 @@ static int Init( vout_thread_t *p_vout )
i_height = config_GetInt( p_vout, "snapshot-height" );
psz_chroma = config_GetPsz( p_vout, "snapshot-chroma" );
if ( psz_chroma )
if( psz_chroma )
{
if ( strlen( psz_chroma ) < 4 )
if( strlen( psz_chroma ) < 4 )
{
msg_Err( p_vout,
"snapshot-chroma should be 4 characters long.\n" );
msg_Err( p_vout, "snapshot-chroma should be 4 characters long." );
return VLC_EGENERIC;
}
i_chroma = VLC_FOURCC( psz_chroma[0],
psz_chroma[1],
psz_chroma[2],
psz_chroma[3] );
i_chroma = VLC_FOURCC( psz_chroma[0], psz_chroma[1],
psz_chroma[2], psz_chroma[3] );
free( psz_chroma );
}
else
{
msg_Err( p_vout, "Cannot find chroma information.\n" );
msg_Err( p_vout, "Cannot find chroma information." );
return VLC_EGENERIC;
}
......@@ -205,7 +202,7 @@ static int Init( vout_thread_t *p_vout )
return VLC_SUCCESS;
}
vout_AllocatePicture( p_vout, p_pic, p_vout->output.i_chroma,
vout_AllocatePicture( VLC_OBJECT(p_vout), p_pic, p_vout->output.i_chroma,
p_vout->output.i_width, p_vout->output.i_height,
p_vout->output.i_aspect );
......@@ -235,16 +232,15 @@ static int Init( vout_thread_t *p_vout )
return VLC_EGENERIC;
}
p_vout->p_sys->p_list = ( snapshot_t ** )malloc( p_vout->p_sys->i_size * sizeof( snapshot_t * ) );
p_vout->p_sys->p_list = malloc( p_vout->p_sys->i_size * sizeof( snapshot_t * ) );
if( p_vout->p_sys->p_list == NULL )
return VLC_ENOMEM;
/* Initialize the structures for the circular buffer */
for( i_index = 0 ; i_index < p_vout->p_sys->i_size ; i_index++ )
for( i_index = 0; i_index < p_vout->p_sys->i_size; i_index++ )
{
snapshot_t *p_snapshot;
p_snapshot = ( snapshot_t * )malloc( sizeof( snapshot_t ) );
snapshot_t *p_snapshot = malloc( sizeof( snapshot_t ) );
if( p_snapshot == NULL )
return VLC_ENOMEM;
......@@ -256,7 +252,7 @@ static int Init( vout_thread_t *p_vout )
p_snapshot->p_data = ( char* ) malloc( i_datasize );
if( p_snapshot->p_data == NULL )
return VLC_ENOMEM;
p_vout->p_sys->p_list[ i_index ] = p_snapshot;
p_vout->p_sys->p_list[i_index] = p_snapshot;
}
val.i_int = i_width;
......@@ -276,19 +272,20 @@ static int Init( vout_thread_t *p_vout )
p_vout->p_sys->p_input = vlc_object_find( p_vout, VLC_OBJECT_INPUT,
FIND_PARENT );
if( ! p_vout->p_sys->p_input )
if( !p_vout->p_sys->p_input )
return VLC_ENOOBJ;
if( var_Create( p_vout->p_sys->p_input, "snapshot-id", VLC_VAR_INTEGER ) != VLC_SUCCESS )
if( var_Create( p_vout->p_sys->p_input, "snapshot-id", VLC_VAR_INTEGER ) )
{
msg_Err( p_vout, "Cannot create snapshot-id variable in p_input (%d).", p_vout->p_sys->p_input->i_object_id );
msg_Err( p_vout, "Cannot create snapshot-id variable in p_input (%d).",
p_vout->p_sys->p_input->i_object_id );
return VLC_EGENERIC;
}
/* Register the snapshot vout module at the input level */
val.i_int = p_vout->i_object_id;
if( var_Set( p_vout->p_sys->p_input, "snapshot-id", val ) != VLC_SUCCESS )
if( var_Set( p_vout->p_sys->p_input, "snapshot-id", val ) )
{
msg_Err( p_vout, "Cannot register snapshot-id in p_input (%d).",
p_vout->p_sys->p_input->i_object_id );
......@@ -333,21 +330,21 @@ static void Destroy( vlc_object_t *p_this )
}
/* Return the position in ms from the start of the movie */
mtime_t snapshot_GetMovietime( vout_thread_t *p_vout )
static mtime_t snapshot_GetMovietime( vout_thread_t *p_vout )
{
input_thread_t* p_input;
vlc_value_t val;
mtime_t result;
mtime_t i_result;
p_input = p_vout->p_sys->p_input;
if( ! p_input )
if( !p_input )
return 0;
var_Get( p_input, "time", &val );
result = val.i_time;
i_result = val.i_time;
if (result == 0)
if( i_result <= 0 )
{
/* Either we are at the start, or (more probably) the demuxer
does not support the DEMUX_GET_TIME call. Try to fallback to
......@@ -355,9 +352,9 @@ mtime_t snapshot_GetMovietime( vout_thread_t *p_vout )
stream_position_t pos;
input_Tell( p_input, &pos );
result = pos.i_mux_rate * 50 * pos.i_tell;
i_result = pos.i_mux_rate * 50 * pos.i_tell;
}
return( result / 1000 );
return( i_result / 1000 );
}
/*****************************************************************************
......@@ -368,18 +365,17 @@ mtime_t snapshot_GetMovietime( vout_thread_t *p_vout )
static void Display( vout_thread_t *p_vout, picture_t *p_pic )
{
int i_index;
mtime_t date;
mtime_t i_date;
i_index = p_vout->p_sys->i_index;
p_vout->p_vlc->pf_memcpy(
p_vout->p_sys->p_list[i_index]->p_data,
p_vout->p_vlc->pf_memcpy( p_vout->p_sys->p_list[i_index]->p_data,
p_pic->p->p_pixels,
p_vout->p_sys->i_datasize );
date = snapshot_GetMovietime( p_vout );
i_date = snapshot_GetMovietime( p_vout );
p_vout->p_sys->p_list[ i_index ]->date = date;
p_vout->p_sys->p_list[i_index]->date = i_date;
i_index++;
......@@ -389,6 +385,5 @@ static void Display( vout_thread_t *p_vout, picture_t *p_pic )
}
p_vout->p_sys->i_index = i_index;
return;
}
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