]> git.sesse.net Git - vlc/commitdiff
* modules/demux/asf/* use index for seeking if available and if there's a video track.
authorGildas Bazin <gbazin@videolan.org>
Fri, 13 Apr 2007 23:51:24 +0000 (23:51 +0000)
committerGildas Bazin <gbazin@videolan.org>
Fri, 13 Apr 2007 23:51:24 +0000 (23:51 +0000)
modules/demux/asf/libasf.c

index d68edeaab19878baff44ecf5f975a28f15bf9e5a..d0404e78780aa836111c33453a498cd44eea91fd 100644 (file)
@@ -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 )
 {
     asf_object_index_t *p_index = (asf_object_index_t*)p_obj;
-    int                i_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 );
     p_index->i_index_entry_time_interval = GetQWLE( p_peek + 40 );
     p_index->i_max_packet_count = GetDWLE( p_peek + 48 );
     p_index->i_index_entry_count = GetDWLE( p_peek + 52 );
-    p_index->index_entry = NULL; /* FIXME */
+    p_index->index_entry = NULL;
 
 #ifdef ASF_DEBUG
     msg_Dbg( s,
@@ -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 );
 #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;
 }