demux_sys_t *p_sys;
int i_width=-1, i_height=-1;
unsigned u_fps_num=0, u_fps_den=1;
- char *psz_ext;
vlc_fourcc_t i_chroma;
unsigned int i_sar_num = 0;
unsigned int i_sar_den = 0;
const struct preset_t *p_preset = NULL;
const uint8_t *p_peek;
- bool b_valid = false;
bool b_y4m = false;
if( stream_Peek( p_demux->s, &p_peek, 9 ) == 9 )
/* http://wiki.multimedia.cx/index.php?title=YUV4MPEG2 */
if( !strncmp( (char *)p_peek, "YUV4MPEG2", 9 ) )
{
- b_valid = true;
b_y4m = true;
+ goto valid;
}
}
- /* guess preset based on file extension */
- psz_ext = strrchr( p_demux->psz_path, '.' );
- if( psz_ext )
+ if( !p_demux->b_force )
{
+ /* guess preset based on file extension */
+ if( !p_demux->psz_file )
+ return VLC_EGENERIC;
+
+ const char *psz_ext = strrchr( p_demux->psz_file, '.' );
+ if( !psz_ext )
+ return VLC_EGENERIC;
psz_ext++;
- for( int i = 0; p_presets[i].psz_ext ; i++ )
+
+ for( unsigned i = 0; p_presets[i].psz_ext ; i++ )
{
if( !strcasecmp( psz_ext, p_presets[i].psz_ext ) )
{
p_preset = &p_presets[i];
- b_valid = true;
- break;
+ goto valid;
}
}
- }
- if( !b_valid && !p_demux->b_force )
return VLC_EGENERIC;
-
+ }
+valid:
/* Set p_input field */
p_demux->pf_demux = Demux;
p_demux->pf_control = Control;
u_fps_num, u_fps_den, 0);
date_Init( &p_sys->pcr, p_sys->fmt_video.video.i_frame_rate,
p_sys->fmt_video.video.i_frame_rate_base );
- date_Set( &p_sys->pcr, 1 );
+ date_Set( &p_sys->pcr, 0 );
if( !p_sys->fmt_video.video.i_bits_per_pixel )
{
return VLC_SUCCESS;
error:
+ stream_Seek( p_demux->s, 0 ); // Workaround, but y4m uses stream_ReadLines
free( p_sys );
return VLC_EGENERIC;
}
mtime_t i_pcr = date_Get( &p_sys->pcr );
/* Call the pace control */
- es_out_Control( p_demux->out, ES_OUT_SET_PCR, i_pcr );
+ es_out_Control( p_demux->out, ES_OUT_SET_PCR, VLC_TS_0 + i_pcr );
if( p_sys->b_y4m )
{
return 0;
}
- p_block->i_dts = p_block->i_pts = i_pcr;
+ p_block->i_dts = p_block->i_pts = VLC_TS_0 + i_pcr;
es_out_Send( p_demux->out, p_sys->p_es_video, p_block );
date_Increment( &p_sys->pcr, 1 );