changeset 25658:0d0c48ecba90

Instead of keeping attachments in mkv demuxer, use demuxer_add_attachment(). These attachments are passed to libass after demuxer is opened.
author eugeni
date Sat, 12 Jan 2008 01:12:39 +0000
parents dfeb8ea2a7a8
children 706d6ecf3c7c
files libmpdemux/demux_mkv.c mplayer.c
diffstat 2 files changed, 14 insertions(+), 44 deletions(-) [+]
line wrap: on
line diff
--- a/libmpdemux/demux_mkv.c	Sat Jan 12 01:12:36 2008 +0000
+++ b/libmpdemux/demux_mkv.c	Sat Jan 12 01:12:39 2008 +0000
@@ -143,15 +143,6 @@
   uint64_t timecode, filepos;
 } mkv_index_t;
 
-typedef struct mkv_attachment
-{
-  char* name;
-  char* mime;
-  uint64_t uid;
-  void* data;
-  unsigned int data_size;
-} mkv_attachment_t;
-
 typedef struct mkv_demuxer
 {
   off_t segment_start;
@@ -186,9 +177,6 @@
   
   int last_aid;
   int audio_tracks[MAX_A_STREAMS];
-  
-  mkv_attachment_t *attachments;
-  int num_attachments;
 } mkv_demuxer_t;
 
 #define REALHEADER_SIZE    16
@@ -1457,7 +1445,6 @@
               int i;
               char* name = NULL;
               char* mime = NULL;
-              uint64_t uid = 0;
               char* data = NULL;
               int data_size = 0;
 
@@ -1466,9 +1453,6 @@
 
               mp_msg (MSGT_DEMUX, MSGL_V, "[mkv] | + an attachment...\n");
 
-              grow_array(&mkv_d->attachments, mkv_d->num_attachments,
-                         sizeof(*mkv_d->attachments));
-
               while (len > 0)
                 {
                   uint64_t l;
@@ -1492,10 +1476,6 @@
                         mime);
                       break;
 
-                    case MATROSKA_ID_FILEUID:
-                      uid = ebml_read_uint (s, &l);
-                      break;
-
                     case MATROSKA_ID_FILEDATA:
                       {
                         int x;
@@ -1521,22 +1501,10 @@
                   len -= l + il;
                 }
 
-              mkv_d->attachments[mkv_d->num_attachments].name = name;
-              mkv_d->attachments[mkv_d->num_attachments].mime = mime;
-              mkv_d->attachments[mkv_d->num_attachments].uid = uid;
-              mkv_d->attachments[mkv_d->num_attachments].data = data;
-              mkv_d->attachments[mkv_d->num_attachments].data_size = data_size;
-              mkv_d->num_attachments ++;
+              demuxer_add_attachment(demuxer, name, mime, data, data_size);
               mp_msg(MSGT_DEMUX, MSGL_V,
                      "[mkv] Attachment: %s, %s, %u bytes\n",
                      name, mime, data_size);
-#ifdef USE_ASS
-              if (ass_library &&
-                  extract_embedded_fonts && name && data && data_size &&
-                  mime && (strcmp(mime, "application/x-truetype-font") == 0 ||
-                  strcmp(mime, "application/x-font") == 0))
-                ass_add_font(ass_library, name, data, data_size);
-#endif
               break;
             }
 
@@ -2596,17 +2564,6 @@
         free (mkv_d->parsed_cues);
       if (mkv_d->parsed_seekhead)
         free (mkv_d->parsed_seekhead);
-      if (mkv_d->attachments) {
-        for (i = 0; i < mkv_d->num_attachments; ++i) {
-          if (mkv_d->attachments[i].name)
-            free (mkv_d->attachments[i].name);
-          if (mkv_d->attachments[i].mime)
-            free (mkv_d->attachments[i].mime);
-          if (mkv_d->attachments[i].data)
-            free (mkv_d->attachments[i].data);
-        }
-        free (mkv_d->attachments);
-      }
       free (mkv_d);
     }
 }
--- a/mplayer.c	Sat Jan 12 01:12:36 2008 +0000
+++ b/mplayer.c	Sat Jan 12 01:12:39 2008 +0000
@@ -3118,6 +3118,19 @@
 if (mpctx->global_sub_size <= mpctx->global_sub_indices[SUB_SOURCE_DEMUX] + dvdsub_id)
   mpctx->global_sub_size = mpctx->global_sub_indices[SUB_SOURCE_DEMUX] + dvdsub_id + 1;
 
+#ifdef USE_ASS
+if (ass_enabled && ass_library) {
+  for (i = 0; i < mpctx->demuxer->num_attachments; ++i) {
+    demux_attachment_t* att = mpctx->demuxer->attachments + i;
+    if (extract_embedded_fonts &&
+        att->name && att->type && att->data && att->data_size &&
+        (strcmp(att->type, "application/x-truetype-font") == 0 ||
+         strcmp(att->type, "application/x-font") == 0))
+      ass_add_font(ass_library, att->name, att->data, att->data_size);
+  }
+}
+#endif
+
 current_module="demux_open2";
 
 //file_format=demuxer->file_format;