Commit 8cf44c19 authored by Gildas Bazin's avatar Gildas Bazin

* modules/demux/asf/* use index for seeking if available and if there's a video track.

parent 44cb59ea
...@@ -211,18 +211,21 @@ static int ASF_ReadObject_Data( stream_t *s, asf_object_t *p_obj ) ...@@ -211,18 +211,21 @@ static int ASF_ReadObject_Data( stream_t *s, asf_object_t *p_obj )
static int ASF_ReadObject_Index( stream_t *s, asf_object_t *p_obj ) static int ASF_ReadObject_Index( stream_t *s, asf_object_t *p_obj )
{ {
asf_object_index_t *p_index = (asf_object_index_t*)p_obj; asf_object_index_t *p_index = (asf_object_index_t*)p_obj;
int i_peek;
uint8_t *p_peek; uint8_t *p_peek;
int i;
if( ( i_peek = stream_Peek( s, &p_peek, 56 ) ) < 56 ) if( stream_Peek( s, &p_peek, p_index->i_object_size ) <
(int)p_index->i_object_size )
{ {
return VLC_EGENERIC; /* Just ignore */
return VLC_SUCCESS;
} }
ASF_GetGUID( &p_index->i_file_id, p_peek + 24 ); ASF_GetGUID( &p_index->i_file_id, p_peek + 24 );
p_index->i_index_entry_time_interval = GetQWLE( p_peek + 40 ); p_index->i_index_entry_time_interval = GetQWLE( p_peek + 40 );
p_index->i_max_packet_count = GetDWLE( p_peek + 48 ); p_index->i_max_packet_count = GetDWLE( p_peek + 48 );
p_index->i_index_entry_count = GetDWLE( p_peek + 52 ); p_index->i_index_entry_count = GetDWLE( p_peek + 52 );
p_index->index_entry = NULL; /* FIXME */ p_index->index_entry = NULL;
#ifdef ASF_DEBUG #ifdef ASF_DEBUG
msg_Dbg( s, msg_Dbg( s,
...@@ -235,6 +238,20 @@ static int ASF_ReadObject_Index( stream_t *s, asf_object_t *p_obj ) ...@@ -235,6 +238,20 @@ static int ASF_ReadObject_Index( stream_t *s, asf_object_t *p_obj )
(long int)p_index->i_index_entry_count ); (long int)p_index->i_index_entry_count );
#endif #endif
/* Sanity checking */
if( p_index->i_index_entry_count > (p_index->i_object_size - 56) / 6 )
p_index->i_index_entry_count = (p_index->i_object_size - 56) / 6;
p_index->index_entry = malloc( sizeof(asf_index_entry_t) *
p_index->i_index_entry_count );
for( i = 0, p_peek += 56; i < (int)p_index->i_index_entry_count;
i++, p_peek += 6 )
{
p_index->index_entry[i].i_packet_number = GetDWLE( p_peek );
p_index->index_entry[i].i_packet_count = GetDWLE( p_peek + 4 );
}
return VLC_SUCCESS; return VLC_SUCCESS;
} }
......
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