if( !p_sys->b_seekable )
msg_Warn( p_demux, "stream is not seekable, skipping seektable" );
else if( SeekTableLoad( p_demux, p_sys ) )
- goto error;
-
+ {
+ p_sys->b_index = false;
+ msg_Warn( p_demux, "Seektable is broken, seek won't be accurate" );
+ }
}
else
{
fmt.video.i_height = p_sys->hdr.i_height;
fmt.i_extra = p_sys->i_extra_f;
fmt.p_extra = p_sys->p_extra_f;
- fmt.video.i_aspect = VOUT_ASPECT_FACTOR * p_sys->hdr.d_aspect;
+ fmt.video.i_sar_num = p_sys->hdr.d_aspect * fmt.video.i_height;
+ fmt.video.i_sar_den = fmt.video.i_width;
p_sys->p_es_video = es_out_Add( p_demux->out, &fmt );
}
if( ( p_data = stream_Block( p_demux->s, fh.i_length ) ) == NULL )
return 0;
- p_data->i_dts = (int64_t)fh.i_timecode * 1000;
- p_data->i_pts = (fh.i_type == 'V') ? 0 : p_data->i_dts;
+ p_data->i_dts = VLC_TS_0 + (int64_t)fh.i_timecode * 1000;
+ p_data->i_pts = (fh.i_type == 'V') ? VLC_TS_INVALID : p_data->i_dts;
/* only add keyframes to index */
if( !fh.i_keyframe && !p_sys->b_index )
- demux_IndexAppend( &p_sys->idx, p_data->i_dts, stream_Tell(p_demux->s) - NUV_FH_SIZE );
+ demux_IndexAppend( &p_sys->idx,
+ p_data->i_dts - VLC_TS_0,
+ stream_Tell(p_demux->s) - NUV_FH_SIZE );
/* */
- if( p_data->i_dts > p_sys->i_pcr )
+ if( p_sys->i_pcr < 0 || p_sys->i_pcr < p_data->i_dts - VLC_TS_0 )
{
- p_sys->i_pcr = p_data->i_dts;
- es_out_Control( p_demux->out, ES_OUT_SET_PCR, p_sys->i_pcr );
+ p_sys->i_pcr = p_data->i_dts - VLC_TS_0;
+ es_out_Control( p_demux->out, ES_OUT_SET_PCR, VLC_TS_0 + p_sys->i_pcr );
}
if( fh.i_type == 'A' && p_sys->p_es_audio )
{
frame_header_t fh;
int64_t i_original_pos;
- uint8_t* p_seek_table;
- uint8_t* p_kfa_table;
- int32_t i_seek_elements = 0, i_kfa_elements = 0, j;
int64_t i_time, i_offset;
int keyframe, last_keyframe = 0, frame = 0, kfa_entry_id = 0;
if( FrameHeaderLoad( p_demux, &fh ) )
return VLC_EGENERIC;
- if( fh.i_type == 'Q' )
- {
- p_seek_table = malloc( fh.i_length );
- if( p_seek_table == NULL )
- return VLC_ENOMEM;
-
- if( stream_Read( p_demux->s, p_seek_table, fh.i_length ) != fh.i_length )
- {
- free( p_seek_table );
- return VLC_EGENERIC;
- }
-
- i_seek_elements = fh.i_length / 12;
- }
- else
+ if( fh.i_type != 'Q' )
{
msg_Warn( p_demux, "invalid seektable, frame type=%c", fh.i_type );
stream_Seek( p_demux->s, i_original_pos );
return VLC_EGENERIC;
}
+ /* */
+ uint8_t *p_seek_table = malloc( fh.i_length );
+ if( p_seek_table == NULL )
+ return VLC_ENOMEM;
+
+ if( stream_Read( p_demux->s, p_seek_table, fh.i_length ) != fh.i_length )
+ {
+ free( p_seek_table );
+ return VLC_EGENERIC;
+ }
+ const int32_t i_seek_elements = fh.i_length / 12;
/* Get keyframe adjust offsets */
+ int32_t i_kfa_elements;
+ uint8_t *p_kfa_table;
+
if( p_sys->exh.i_keyframe_adjust_offset > 0 )
{
msg_Dbg( p_demux, "seeking in stream to %"PRIi64, p_sys->exh.i_keyframe_adjust_offset );
i_kfa_elements = fh.i_length / 8;
}
}
+ else
+ {
+ i_kfa_elements = 0;
+ }
if( i_kfa_elements > 0 )
msg_Warn( p_demux, "untested keyframe adjust support, upload samples" );
- for(j=0; j < i_seek_elements; j++)
+ for( int32_t j = 0; j < i_seek_elements; j++)
{
#if 0
uint8_t* p = p_seek_table + j * 12;
else
{
p_idx->i_idx_max += 1000;
- p_idx->idx = realloc( p_idx->idx,
- p_idx->i_idx_max*sizeof(demux_index_entry_t));
+ p_idx->idx = xrealloc( p_idx->idx,
+ p_idx->i_idx_max*sizeof(demux_index_entry_t));
}
}