]> git.sesse.net Git - vlc/blobdiff - modules/demux/asf/libasf.c
* all: A little clean up.
[vlc] / modules / demux / asf / libasf.c
index 93d02892ebdcafb19741933abf8ff79b1ec6cfc0..37d8f6eb3c0dcdfcb8481ba158d2e6aa2640a7a8 100644 (file)
@@ -1,15 +1,15 @@
 /*****************************************************************************
- * libasf.c : 
+ * libasf.c :
  *****************************************************************************
  * Copyright (C) 2001 VideoLAN
- * $Id: libasf.c,v 1.1 2002/10/20 17:22:33 fenrir Exp $
+ * $Id: libasf.c,v 1.14 2003/08/17 23:42:37 fenrir Exp $
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
- * 
+ *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or
  * (at your option) any later version.
- * 
+ *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  *****************************************************************************/
 
 #include <stdlib.h>                                      /* malloc(), free() */
-#include <string.h>                                              /* strdup() */
-#include <errno.h>
-#include <sys/types.h>
 
 #include <vlc/vlc.h>
 #include <vlc/input.h>
 
+#include "codecs.h"                        /* BITMAPINFOHEADER, WAVEFORMATEX */
 #include "libasf.h"
 
 #define ASF_DEBUG 1
 
 #define FREE( p ) \
     if( p ) {free( p ); p = NULL; }
-   
+
 #define GUID_FMT "0x%x-0x%x-0x%x-0x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x"
 #define GUID_PRINT( guid )  \
     (guid).v1,              \
     (guid).v4[0],(guid).v4[1],(guid).v4[2],(guid).v4[3],    \
     (guid).v4[4],(guid).v4[5],(guid).v4[6],(guid).v4[7]
 
-/* Some functions to manipulate memory */
-static u16 GetWLE( u8 *p_buff )
-{
-    return( (p_buff[0]) + ( p_buff[1] <<8 ) );
-}
-
-static u32 GetDWLE( u8 *p_buff )
-{
-    return( p_buff[0] + ( p_buff[1] <<8 ) +
-            ( p_buff[2] <<16 ) + ( p_buff[3] <<24 ) );
-}
-
-static u64 GetQWLE( u8 *p_buff )
-{
-    return( ( (u64)GetDWLE( p_buff ) )|( (u64)GetDWLE( p_buff + 4 ) << 32) );
-}
-
-void GetGUID( guid_t *p_guid, u8 *p_data )
+void ASF_GetGUID( guid_t *p_guid, uint8_t *p_data )
 {
     p_guid->v1 = GetDWLE( p_data );
     p_guid->v2 = GetWLE( p_data + 4);
@@ -68,7 +49,7 @@ void GetGUID( guid_t *p_guid, u8 *p_data )
     memcpy( p_guid->v4, p_data + 8, 8 );
 }
 
-int CmpGUID( const guid_t *p_guid1, const guid_t *p_guid2 )
+int ASF_CmpGUID( const guid_t *p_guid1, const guid_t *p_guid2 )
 {
     if( (p_guid1->v1 != p_guid2->v1 )||(p_guid1->v2 != p_guid2->v2 )||
         (p_guid1->v3 != p_guid2->v3 )||
@@ -85,7 +66,7 @@ int CmpGUID( const guid_t *p_guid1, const guid_t *p_guid2 )
  * Some basic functions to manipulate stream more easily in vlc
  *
  * ASF_TellAbsolute get file position
- * 
+ *
  * ASF_SeekAbsolute seek in the file
  *
  * ASF_ReadData read data from the file in a buffer
@@ -94,44 +75,73 @@ int CmpGUID( const guid_t *p_guid1, const guid_t *p_guid2 )
 off_t ASF_TellAbsolute( input_thread_t *p_input )
 {
     off_t i_pos;
-    
+
     vlc_mutex_lock( &p_input->stream.stream_lock );
-    
-    i_pos= p_input->stream.p_selected_area->i_tell -
-            ( p_input->p_last_data - p_input->p_current_data  );
+
+    i_pos= p_input->stream.p_selected_area->i_tell;
+//           - ( p_input->p_last_data - p_input->p_current_data  );
 
     vlc_mutex_unlock( &p_input->stream.stream_lock );
 
     return( i_pos );
 }
+
 int ASF_SeekAbsolute( input_thread_t *p_input,
                       off_t i_pos)
 {
     off_t i_filepos;
 
-    if( i_pos >= p_input->stream.p_selected_area->i_size )
+    i_filepos = ASF_TellAbsolute( p_input );
+    if( i_pos == i_filepos )
     {
+        return( 1 );
+    }
+
+    if( !p_input->stream.b_seekable && i_pos < i_filepos )
+    {
+        msg_Err( p_input, "cannot seek" );
         return( 0 );
     }
-            
-    i_filepos = ASF_TellAbsolute( p_input );
-    if( i_pos != i_filepos )
+
+    if( p_input->stream.b_seekable &&
+        ( p_input->stream.i_method == INPUT_METHOD_FILE ||
+          i_pos < i_filepos ||
+          i_pos - i_filepos > 10000 ) )
     {
-        p_input->pf_seek( p_input, i_pos );
         input_AccessReinit( p_input );
+        p_input->pf_seek( p_input, i_pos );
+        return( 1 );
+    }
+    else if( i_pos > i_filepos )
+    {
+        uint64_t i_size = i_pos - i_filepos;
+        do
+        {
+            data_packet_t *p_data;
+            int i_read;
+
+            i_read =
+                input_SplitBuffer(p_input, &p_data, __MIN( i_size, 1024 ) );
+            if( i_read <= 0 )
+            {
+                return( 0 );
+            }
+            input_DeletePacket( p_input->p_method_data, p_data );
+            i_size -= i_read;
+
+        } while( i_size > 0 );
     }
     return( 1 );
 }
 
 /* return 1 if success, 0 if fail */
-int ASF_ReadData( input_thread_t *p_input, u8 *p_buff, int i_size )
+int ASF_ReadData( input_thread_t *p_input, uint8_t *p_buff, int i_size )
 {
     data_packet_t *p_data;
 
     int i_read;
 
-                
+
     if( !i_size )
     {
         return( 1 );
@@ -146,44 +156,44 @@ int ASF_ReadData( input_thread_t *p_input, u8 *p_buff, int i_size )
         }
         memcpy( p_buff, p_data->p_payload_start, i_read );
         input_DeletePacket( p_input->p_method_data, p_data );
-        
+
         p_buff += i_read;
         i_size -= i_read;
-                
+
     } while( i_size );
-    
+
     return( 1 );
 }
 
 int  ASF_SkipBytes( input_thread_t *p_input, int i_count )
 {
-    return( ASF_SeekAbsolute( p_input, 
+    return( ASF_SeekAbsolute( p_input,
                               ASF_TellAbsolute( p_input ) + i_count ) );
 }
 
 /****************************************************************************/
-int  ASF_ReadObjectCommon( input_thread_t *p_input, 
+int  ASF_ReadObjectCommon( input_thread_t *p_input,
                            asf_object_t *p_obj )
 {
     asf_object_common_t *p_common = (asf_object_common_t*)p_obj;
-    u8  *p_peek;
+    uint8_t             *p_peek;
 
     if( input_Peek( p_input, &p_peek, 24 ) < 24 )
     {
         return( 0 );
     }
-    GetGUID( &p_common->i_object_id, p_peek ); 
+    ASF_GetGUID( &p_common->i_object_id, p_peek );
     p_common->i_object_size = GetQWLE( p_peek + 16 );
     p_common->i_object_pos = ASF_TellAbsolute( p_input );
     p_common->p_next = NULL;
 #ifdef ASF_DEBUG
     msg_Dbg(p_input,
-            "Found Object guid: " GUID_FMT " size:%lld",
+            "Found Object guid: " GUID_FMT " size:"I64Fd,
             GUID_PRINT( p_common->i_object_id ),
             p_common->i_object_size );
 #endif
-    
-    return( 1 ); 
+
+    return( 1 );
 }
 
 int ASF_NextObject( input_thread_t *p_input,
@@ -203,17 +213,17 @@ int ASF_NextObject( input_thread_t *p_input,
     {
         return( 0 ); /* failed */
     }
-    if( p_obj->common.p_father )
+    if( p_obj->common.p_father && p_obj->common.p_father->common.i_object_size != 0 )
     {
         if( p_obj->common.p_father->common.i_object_pos + p_obj->common.p_father->common.i_object_size <
-                p_obj->common.i_object_pos + p_obj->common.i_object_size + 24 )  
+                p_obj->common.i_object_pos + p_obj->common.i_object_size + 24 )
                                 /* 24 is min size of an object */
         {
             return( 0 );
         }
 
     }
-    return( ASF_SeekAbsolute( p_input, 
+    return( ASF_SeekAbsolute( p_input,
                               p_obj->common.i_object_pos + p_obj->common.i_object_size ) );
 }
 
@@ -239,10 +249,10 @@ int  ASF_ReadObject_Header( input_thread_t *p_input,
                             asf_object_t *p_obj )
 {
     asf_object_header_t *p_hdr = (asf_object_header_t*)p_obj;
-    asf_object_t *p_subobj;
-    int i_peek;
-    u8  *p_peek;
-    
+    asf_object_t        *p_subobj;
+    int                 i_peek;
+    uint8_t             *p_peek;
+
     if( ( i_peek = input_Peek( p_input, &p_peek, 30 ) ) < 30 )
     {
        return( 0 );
@@ -267,7 +277,7 @@ int  ASF_ReadObject_Header( input_thread_t *p_input,
 
         if( !( ASF_ReadObject( p_input, p_subobj, (asf_object_t*)p_hdr ) ) )
         {
-            break; 
+            break;
         }
         if( !ASF_NextObject( p_input, p_subobj ) ) /* Go to the next object */
         {
@@ -281,19 +291,20 @@ int  ASF_ReadObject_Data( input_thread_t *p_input,
                           asf_object_t *p_obj )
 {
     asf_object_data_t *p_data = (asf_object_data_t*)p_obj;
-    int i_peek;
-    u8  *p_peek;
-    
+    int               i_peek;
+    uint8_t           *p_peek;
+
     if( ( i_peek = input_Peek( p_input, &p_peek, 50 ) ) < 50 )
     {
        return( 0 );
     }
-    GetGUID( &p_data->i_file_id, p_peek + 24 );
+    ASF_GetGUID( &p_data->i_file_id, p_peek + 24 );
     p_data->i_total_data_packets = GetQWLE( p_peek + 40 );
     p_data->i_reserved = GetWLE( p_peek + 48 );
 #ifdef ASF_DEBUG
     msg_Dbg( p_input,
-            "Read \"Data Object\" file_id:" GUID_FMT " total data packet:%lld reserved:%d",
+            "Read \"Data Object\" file_id:" GUID_FMT " total data packet:"
+            I64Fd" reserved:%d",
             GUID_PRINT( p_data->i_file_id ),
             p_data->i_total_data_packets,
             p_data->i_reserved );
@@ -305,14 +316,14 @@ int  ASF_ReadObject_Index( input_thread_t *p_input,
                            asf_object_t *p_obj )
 {
     asf_object_index_t *p_index = (asf_object_index_t*)p_obj;
-    int i_peek;
-    u8  *p_peek;
-    
+    int                i_peek;
+    uint8_t            *p_peek;
+
     if( ( i_peek = input_Peek( p_input, &p_peek, 56 ) ) < 56 )
     {
        return( 0 );
     }
-    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_max_packet_count = GetDWLE( p_peek + 48 );
     p_index->i_index_entry_count = GetDWLE( p_peek + 52 );
@@ -320,10 +331,13 @@ int  ASF_ReadObject_Index( input_thread_t *p_input,
 
 #ifdef ASF_DEBUG
     msg_Dbg( p_input,
-            "Read \"Index Object\" file_id:" GUID_FMT " index_entry_time_interval:%lld max_packet_count:%d index_entry_count:%d",
+            "Read \"Index Object\" file_id:" GUID_FMT
+            " index_entry_time_interval:"I64Fd" max_packet_count:%d "
+            "index_entry_count:%ld",
             GUID_PRINT( p_index->i_file_id ),
+            p_index->i_index_entry_time_interval,
             p_index->i_max_packet_count,
-            p_index->i_index_entry_count );
+            (long int)p_index->i_index_entry_count );
 #endif
     return( 1 );
 }
@@ -339,14 +353,14 @@ int  ASF_ReadObject_file_properties( input_thread_t *p_input,
                                      asf_object_t *p_obj )
 {
     asf_object_file_properties_t *p_fp = (asf_object_file_properties_t*)p_obj;
-    int i_peek;
-    u8  *p_peek;
-    
+    int      i_peek;
+    uint8_t  *p_peek;
+
     if( ( i_peek = input_Peek( p_input, &p_peek,  92) ) < 92 )
     {
        return( 0 );
     }
-    GetGUID( &p_fp->i_file_id, p_peek + 24 );
+    ASF_GetGUID( &p_fp->i_file_id, p_peek + 24 );
     p_fp->i_file_size = GetQWLE( p_peek + 40 );
     p_fp->i_creation_date = GetQWLE( p_peek + 48 );
     p_fp->i_data_packets_count = GetQWLE( p_peek + 56 );
@@ -357,10 +371,14 @@ int  ASF_ReadObject_file_properties( input_thread_t *p_input,
     p_fp->i_min_data_packet_size = GetDWLE( p_peek + 92 );
     p_fp->i_max_data_packet_size = GetDWLE( p_peek + 96 );
     p_fp->i_max_bitrate = GetDWLE( p_peek + 100 );
-        
+
 #ifdef ASF_DEBUG
     msg_Dbg( p_input,
-            "Read \"File Properties Object\" file_id:" GUID_FMT " file_size:%lld creation_date:%lld data_packets_count:%lld play_duration:%lld send_duration:%lld preroll:%lld flags:%d min_data_packet_size:%d max_data_packet_size:%d max_bitrate:%d",
+            "Read \"File Properties Object\" file_id:" GUID_FMT
+            " file_size:"I64Fd" creation_date:"I64Fd" data_packets_count:"
+            I64Fd" play_duration:"I64Fd" send_duration:"I64Fd" preroll:"
+            I64Fd" flags:%d min_data_packet_size:%d max_data_packet_size:%d "
+            "max_bitrate:%d",
             GUID_PRINT( p_fp->i_file_id ),
             p_fp->i_file_size,
             p_fp->i_creation_date,
@@ -380,14 +398,14 @@ int  ASF_ReadObject_header_extention( input_thread_t *p_input,
                                       asf_object_t *p_obj )
 {
     asf_object_header_extention_t *p_he = (asf_object_header_extention_t*)p_obj;
-    int i_peek;
-    u *p_peek;
-    
+    int     i_peek;
+    uint8_t *p_peek;
+
     if( ( i_peek = input_Peek( p_input, &p_peek, p_he->i_object_size ) ) <  46)
     {
        return( 0 );
     }
-    GetGUID( &p_he->i_reserved1, p_peek + 24 );
+    ASF_GetGUID( &p_he->i_reserved1, p_peek + 24 );
     p_he->i_reserved2 = GetWLE( p_peek + 40 );
     p_he->i_header_extention_size = GetDWLE( p_peek + 42 );
     if( p_he->i_header_extention_size )
@@ -407,7 +425,7 @@ int  ASF_ReadObject_header_extention( input_thread_t *p_input,
             GUID_PRINT( p_he->i_reserved1 ),
             p_he->i_reserved2,
             p_he->i_header_extention_size );
-#endif 
+#endif
     return( 1 );
 }
 void ASF_FreeObject_header_extention( input_thread_t *p_input,
@@ -421,17 +439,17 @@ void ASF_FreeObject_header_extention( input_thread_t *p_input,
 int  ASF_ReadObject_stream_properties( input_thread_t *p_input,
                                        asf_object_t *p_obj )
 {
-    asf_object_stream_properties_t *p_sp = 
+    asf_object_stream_properties_t *p_sp =
                     (asf_object_stream_properties_t*)p_obj;
-    int i_peek;
-    u *p_peek;
-    
+    int     i_peek;
+    uint8_t *p_peek;
+
     if( ( i_peek = input_Peek( p_input, &p_peek,  p_sp->i_object_size ) ) < 74 )
     {
        return( 0 );
     }
-    GetGUID( &p_sp->i_stream_type, p_peek + 24 );
-    GetGUID( &p_sp->i_error_correction_type, p_peek + 40 );
+    ASF_GetGUID( &p_sp->i_stream_type, p_peek + 24 );
+    ASF_GetGUID( &p_sp->i_error_correction_type, p_peek + 40 );
     p_sp->i_time_offset = GetQWLE( p_peek + 56 );
     p_sp->i_type_specific_data_length = GetDWLE( p_peek + 64 );
     p_sp->i_error_correction_data_length = GetDWLE( p_peek + 68 );
@@ -463,7 +481,10 @@ int  ASF_ReadObject_stream_properties( input_thread_t *p_input,
 
 #ifdef ASF_DEBUG
     msg_Dbg( p_input,
-            "Read \"Stream Properties Object\" stream_type:" GUID_FMT " error_correction_type:" GUID_FMT " time_offset:%lld type_specific_data_length:%d error_correction_data_length:%d flags:0x%x stream_number:%d",
+            "Read \"Stream Properties Object\" stream_type:" GUID_FMT
+            " error_correction_type:" GUID_FMT " time_offset:"I64Fd
+            " type_specific_data_length:%d error_correction_data_length:%d"
+            " flags:0x%x stream_number:%d",
             GUID_PRINT( p_sp->i_stream_type ),
             GUID_PRINT( p_sp->i_error_correction_type ),
             p_sp->i_time_offset,
@@ -479,7 +500,7 @@ int  ASF_ReadObject_stream_properties( input_thread_t *p_input,
 void ASF_FreeObject_stream_properties( input_thread_t *p_input,
                                       asf_object_t *p_obj )
 {
-    asf_object_stream_properties_t *p_sp = 
+    asf_object_stream_properties_t *p_sp =
                 (asf_object_stream_properties_t*)p_obj;
 
     FREE( p_sp->p_type_specific_data );
@@ -491,17 +512,17 @@ int  ASF_ReadObject_codec_list( input_thread_t *p_input,
                                 asf_object_t *p_obj )
 {
     asf_object_codec_list_t *p_cl = (asf_object_codec_list_t*)p_obj;
-    int i_peek;
-    u8  *p_peek, *p_data;
+    int     i_peek;
+    uint8_t *p_peek, *p_data;
+
+    unsigned int i_codec;
 
-    int i_codec;
-    
     if( ( i_peek = input_Peek( p_input, &p_peek, p_cl->i_object_size ) ) < 44 )
     {
        return( 0 );
     }
 
-    GetGUID( &p_cl->i_reserved, p_peek + 24 );
+    ASF_GetGUID( &p_cl->i_reserved, p_peek + 24 );
     p_cl->i_codec_entries_count = GetWLE( p_peek + 40 );
     if( p_cl->i_codec_entries_count > 0 )
     {
@@ -535,7 +556,7 @@ int  ASF_ReadObject_codec_list( input_thread_t *p_input,
             }
             codec.psz_description[i_len] = '\0';
             p_data += 2 * i_len;
-            
+
             /* opaque information */
             codec.i_information_length = GetWLE( p_data ); p_data += 2;
             if( codec.i_information_length > 0 )
@@ -564,15 +585,22 @@ int  ASF_ReadObject_codec_list( input_thread_t *p_input,
             p_cl->i_codec_entries_count );
     for( i_codec = 0; i_codec < p_cl->i_codec_entries_count; i_codec++ )
     {
+        char psz_cat[sizeof("Stream ")+10];
+        input_info_category_t *p_cat;
+        sprintf( psz_cat, "Stream %d", i_codec );
+        p_cat = input_InfoCategory( p_input, psz_cat);
+
 #define codec p_cl->codec[i_codec]
-         msg_Dbg( p_input,
+        input_AddInfo( p_cat, _("Codec name"), codec.psz_name );
+        input_AddInfo( p_cat, _("Codec description"), codec.psz_description );
+        msg_Dbg( p_input,
                  "Read \"Codec List Object\" codec[%d] %s name:\"%s\" description:\"%s\" information_length:%d",
                  i_codec,
                  ( codec.i_type == ASF_CODEC_TYPE_VIDEO ) ? "video" : ( ( codec.i_type == ASF_CODEC_TYPE_AUDIO ) ? "audio" : "unknown" ),
-                 codec.psz_name, 
-                 codec.psz_description, 
+                 codec.psz_name,
+                 codec.psz_description,
                  codec.i_information_length );
-       
+
 #undef  codec
     }
 #endif
@@ -582,7 +610,7 @@ void ASF_FreeObject_codec_list( input_thread_t *p_input,
                                 asf_object_t *p_obj )
 {
     asf_object_codec_list_t *p_cl = (asf_object_codec_list_t*)p_obj;
-    int i_codec;
+    unsigned int i_codec;
 
     for( i_codec = 0; i_codec < p_cl->i_codec_entries_count; i_codec++ )
     {
@@ -601,9 +629,10 @@ void ASF_FreeObject_codec_list( input_thread_t *p_input,
 int  ASF_ReadObject_content_description( input_thread_t *p_input,
                                          asf_object_t *p_obj )
 {
-    asf_object_content_description_t *p_cd = (asf_object_content_description_t*)p_obj;
-    int i_peek;
-    u8  *p_peek, *p_data;
+    asf_object_content_description_t *p_cd =
+                                    (asf_object_content_description_t*)p_obj;
+    int     i_peek;
+    uint8_t *p_peek, *p_data;
 
     int i_len;
     int i_title;
@@ -611,7 +640,7 @@ int  ASF_ReadObject_content_description( input_thread_t *p_input,
     int i_copyright;
     int i_description;
     int i_rating;
-    
+
 #define GETSTRINGW( psz_str, i_size ) \
    psz_str = calloc( i_size/2 + 1, sizeof( char ) ); \
    for( i_len = 0; i_len < i_size/2; i_len++ ) \
@@ -620,7 +649,7 @@ int  ASF_ReadObject_content_description( input_thread_t *p_input,
    } \
    psz_str[i_size/2] = '\0'; \
    p_data += i_size;
-   
+
     if( ( i_peek = input_Peek( p_input, &p_peek, p_cd->i_object_size ) ) < 34 )
     {
        return( 0 );
@@ -642,6 +671,14 @@ int  ASF_ReadObject_content_description( input_thread_t *p_input,
 #undef  GETSTRINGW
 
 #ifdef ASF_DEBUG
+    {
+        input_info_category_t *p_cat = input_InfoCategory( p_input, _("Asf") );
+        input_AddInfo( p_cat, _("Title"), p_cd->psz_title );
+        input_AddInfo( p_cat, _("Author"), p_cd->psz_author );
+        input_AddInfo( p_cat, _("Copyright"), p_cd->psz_copyright );
+        input_AddInfo( p_cat, _("Description"), p_cd->psz_description );
+        input_AddInfo( p_cat, _("Rating"), p_cd->psz_rating );
+    }
     msg_Dbg( p_input,
              "Read \"Content Description Object\" title:\"%s\" author:\"%s\" copyright:\"%s\" description:\"%s\" rating:\"%s\"",
              p_cd->psz_title,
@@ -649,7 +686,7 @@ int  ASF_ReadObject_content_description( input_thread_t *p_input,
              p_cd->psz_copyright,
              p_cd->psz_description,
              p_cd->psz_rating );
-#endif 
+#endif
     return( 1 );
 }
 
@@ -657,7 +694,7 @@ void ASF_FreeObject_content_description( input_thread_t *p_input,
                                          asf_object_t *p_obj )
 {
     asf_object_content_description_t *p_cd = (asf_object_content_description_t*)p_obj;
-    
+
     FREE( p_cd->psz_title );
     FREE( p_cd->psz_author );
     FREE( p_cd->psz_copyright );
@@ -669,7 +706,7 @@ static struct
 {
     const guid_t  *p_id;
     int     i_type;
-    int     (*ASF_ReadObject_function)( input_thread_t *p_input, 
+    int     (*ASF_ReadObject_function)( input_thread_t *p_input,
                                         asf_object_t *p_obj );
     void    (*ASF_FreeObject_function)( input_thread_t *p_input,
                                         asf_object_t *p_obj );
@@ -708,7 +745,7 @@ int  ASF_ReadObject( input_thread_t *p_input,
     p_obj->common.p_first = NULL;
     p_obj->common.p_next = NULL;
     p_obj->common.p_last = NULL;
-    
+
 
     if( p_obj->common.i_object_size < 24 )
     {
@@ -718,9 +755,9 @@ int  ASF_ReadObject( input_thread_t *p_input,
     /* find this object */
     for( i_index = 0; ; i_index++ )
     {
-        if( CmpGUID( ASF_Object_Function[i_index].p_id,
+        if( ASF_CmpGUID( ASF_Object_Function[i_index].p_id,
                      &p_obj->common.i_object_id )||
-            CmpGUID( ASF_Object_Function[i_index].p_id,
+            ASF_CmpGUID( ASF_Object_Function[i_index].p_id,
                      &asf_object_null_guid ) )
         {
             break;
@@ -737,11 +774,11 @@ int  ASF_ReadObject( input_thread_t *p_input,
     else
     {
         /* XXX ASF_ReadObject_function realloc *pp_obj XXX */
-        i_result =  
+        i_result =
             (ASF_Object_Function[i_index].ASF_ReadObject_function)( p_input,
                                                                     p_obj );
     }
-    
+
     /* link this object with father */
     if( p_father )
     {
@@ -764,12 +801,12 @@ void ASF_FreeObject( input_thread_t *p_input,
 {
     int i_index;
     asf_object_t *p_child;
-    
+
     if( !p_obj )
     {
         return;
     }
-    
+
     /* Free all child object */
     p_child = p_obj->common.p_first;
     while( p_child )
@@ -783,9 +820,9 @@ void ASF_FreeObject( input_thread_t *p_input,
     /* find this object */
     for( i_index = 0; ; i_index++ )
     {
-        if( CmpGUID( ASF_Object_Function[i_index].p_id,
+        if( ASF_CmpGUID( ASF_Object_Function[i_index].p_id,
                      &p_obj->common.i_object_id )||
-            CmpGUID( ASF_Object_Function[i_index].p_id,
+            ASF_CmpGUID( ASF_Object_Function[i_index].p_id,
                      &asf_object_null_guid ) )
         {
             break;
@@ -795,14 +832,14 @@ void ASF_FreeObject( input_thread_t *p_input,
     /* Now free this object */
     if( ASF_Object_Function[i_index].ASF_FreeObject_function == NULL )
     {
-        msg_Warn( p_input, 
+        msg_Warn( p_input,
                   "Unknown asf object " GUID_FMT,
                   GUID_PRINT( p_obj->common.i_object_id ) );
     }
     else
     {
 #ifdef ASF_DEBUG
-        msg_Dbg( p_input, 
+        msg_Dbg( p_input,
                   "Free asf object " GUID_FMT,
                   GUID_PRINT( p_obj->common.i_object_id ) );
 #endif
@@ -832,7 +869,7 @@ int ASF_ReadObjectRoot( input_thread_t *p_input,
     p_root->p_hdr = NULL;
     p_root->p_data = NULL;
     p_root->p_index = NULL;
-   
+
     for( ; ; )
     {
         p_obj  = malloc( sizeof( asf_object_t ) );
@@ -873,7 +910,7 @@ void ASF_FreeObjectRoot( input_thread_t *p_input,
                          asf_object_root_t *p_root )
 {
     asf_object_t *p_obj;
-    
+
     p_obj = p_root->p_first;
     while( p_obj )
     {
@@ -889,10 +926,10 @@ void ASF_FreeObjectRoot( input_thread_t *p_input,
     p_root->p_hdr = NULL;
     p_root->p_data = NULL;
     p_root->p_index = NULL;
-    
+
 }
 
-int  ASF_CountObject( asf_object_t *p_obj, const guid_t *p_guid )
+int  __ASF_CountObject( asf_object_t *p_obj, const guid_t *p_guid )
 {
     int i_count;
     asf_object_t *p_child;
@@ -906,7 +943,7 @@ int  ASF_CountObject( asf_object_t *p_obj, const guid_t *p_guid )
     p_child = p_obj->common.p_first;
     while( p_child )
     {
-        if( CmpGUID( &p_child->common.i_object_id, p_guid ) )
+        if( ASF_CmpGUID( &p_child->common.i_object_id, p_guid ) )
         {
             i_count++;
         }
@@ -915,7 +952,7 @@ int  ASF_CountObject( asf_object_t *p_obj, const guid_t *p_guid )
     return( i_count );
 }
 
-asf_object_t *ASF_FindObject( asf_object_t *p_obj, const guid_t *p_guid, int i_number )
+void *__ASF_FindObject( asf_object_t *p_obj, const guid_t *p_guid, int i_number )
 {
     asf_object_t *p_child;
 
@@ -923,7 +960,7 @@ asf_object_t *ASF_FindObject( asf_object_t *p_obj, const guid_t *p_guid, int i_n
 
     while( p_child )
     {
-        if( CmpGUID( &p_child->common.i_object_id, p_guid ) )
+        if( ASF_CmpGUID( &p_child->common.i_object_id, p_guid ) )
         {
             if( i_number == 0 )
             {