[vlc-commits] ASF/WMV: parser chapters

Jean-Baptiste Kempf git at videolan.org
Fri May 11 20:53:50 CEST 2012


vlc | branch: master | Jean-Baptiste Kempf <jb at videolan.org> | Fri May 11 20:53:47 2012 +0200| [fd146628bc246e356c21b3532b5fb0ef1ec45da8] | committer: Jean-Baptiste Kempf

ASF/WMV: parser chapters

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=fd146628bc246e356c21b3532b5fb0ef1ec45da8
---

 modules/demux/asf/libasf.c |   62 +++++++++++++++++++++++++++++++++++++++++++-
 modules/demux/asf/libasf.h |   11 +------
 2 files changed, 63 insertions(+), 10 deletions(-)

diff --git a/modules/demux/asf/libasf.c b/modules/demux/asf/libasf.c
index 6240b14..eb7153d 100644
--- a/modules/demux/asf/libasf.c
+++ b/modules/demux/asf/libasf.c
@@ -1187,6 +1187,65 @@ static void ASF_FreeObject_extended_content_description( asf_object_t *p_obj)
     FREENULL( p_ec->ppsz_value );
 }
 
+static int ASF_ReadObject_marker(stream_t *s, asf_object_t *p_obj)
+{
+    asf_object_marker_t *p_mk = (asf_object_marker_t *)p_obj;
+    const uint8_t *p_peek, *p_data;
+    int i_peek;
+
+    if( ( i_peek = stream_Peek( s, &p_peek, p_mk->i_object_size ) ) < 24 )
+       return VLC_EGENERIC;
+
+    p_data = &p_peek[24];
+
+    ASF_GetGUID( &p_mk->i_reserved1, p_data );
+    ASF_SKIP( 16 );
+    p_mk->i_count = ASF_READ4();
+    p_mk->i_reserved2 = ASF_READ2();
+    p_mk->name = ASF_READS( ASF_READ2() );
+
+    if( p_mk->i_count > 0 )
+    {
+        p_mk->marker = calloc( p_mk->i_count,
+                              sizeof( asf_marker_t ) );
+        if( !p_mk->marker )
+            return VLC_ENOMEM;
+
+        for( unsigned i = 0; i < p_mk->i_count; i++ )
+        {
+            asf_marker_t *p_marker = &p_mk->marker[i];
+
+            if( !ASF_HAVE(8+8+2+4+4+4) )
+                break;
+
+            p_marker->i_offset = ASF_READ8();
+            p_marker->i_presentation_time = ASF_READ8();
+            p_marker->i_entry_length = ASF_READ2();
+            p_marker->i_send_time = ASF_READ4();
+            p_marker->i_flags = ASF_READ4();
+            p_marker->i_marker_description_length = ASF_READ4();
+            p_marker->p_marker_description = ASF_READS( p_marker->i_marker_description_length * 2 );
+        }
+    }
+
+#ifdef ASF_DEBUG
+    msg_Dbg( s, "Read \"marker object\": %i chapters: %s", p_mk->i_count, p_mk->name );
+
+    for( unsigned i = 0; i < p_mk->i_count; i++ )
+        msg_Dbg( s, "New chapter named: %s", p_mk->marker[i].p_marker_description );
+#endif
+    return VLC_SUCCESS;
+}
+static void ASF_FreeObject_marker( asf_object_t *p_obj)
+{
+    asf_object_marker_t *p_mk = (asf_object_marker_t *)p_obj;
+
+    for( unsigned i = 0; i < p_mk->i_count; i++ )
+    {
+        FREENULL( p_mk->marker[i].p_marker_description  );
+    }
+    FREENULL( p_mk->name );
+}
 
 #if 0
 static int ASF_ReadObject_XXX(stream_t *s, asf_object_t *p_obj)
@@ -1242,7 +1301,8 @@ static const struct
       ASF_ReadObject_metadata, ASF_FreeObject_metadata},
     { &asf_object_codec_list_guid, ASF_OBJECT_CODEC_LIST,
       ASF_ReadObject_codec_list, ASF_FreeObject_codec_list },
-    { &asf_object_marker_guid, ASF_OBJECT_MARKER, NULL, NULL },
+    { &asf_object_marker_guid, ASF_OBJECT_MARKER, 
+      ASF_ReadObject_marker, ASF_FreeObject_marker },
     { &asf_object_padding, ASF_OBJECT_PADDING, NULL, NULL },
     { &asf_object_compatibility_guid, ASF_OBJECT_OTHER, NULL, NULL },
     { &asf_object_content_description_guid, ASF_OBJECT_CONTENT_DESCRIPTION,
diff --git a/modules/demux/asf/libasf.h b/modules/demux/asf/libasf.h
index 6e7ae94..c25a4b2 100644
--- a/modules/demux/asf/libasf.h
+++ b/modules/demux/asf/libasf.h
@@ -181,13 +181,6 @@ typedef struct
 
 } asf_object_content_description_t;
 
-typedef struct
-{
-    uint16_t i_length;
-    uint16_t *i_char;
-
-} string16_t;
-
 #define ASF_CODEC_TYPE_VIDEO    0x0001
 #define ASF_CODEC_TYPE_AUDIO    0x0002
 #define ASF_CODEC_TYPE_UNKNOWN  0xffff
@@ -219,7 +212,7 @@ typedef struct
     uint32_t     i_send_time;
     uint32_t     i_flags;
     uint32_t     i_marker_description_length;
-    uint8_t      *i_marker_description;
+    uint8_t      *p_marker_description;
 
 } asf_marker_t;
 
@@ -229,7 +222,7 @@ typedef struct
     guid_t      i_reserved1;
     uint32_t    i_count;
     uint16_t    i_reserved2;
-    string16_t name;
+    char *name;
     asf_marker_t *marker;
 
 } asf_object_marker_t;



More information about the vlc-commits mailing list