[MPlayer-cvslog] r25683 - in trunk: libmpdemux/demux_mkv.c mpcommon.c

eugeni subversion at mplayerhq.hu
Fri Jan 11 22:45:18 CET 2008


Author: eugeni
Date: Fri Jan 11 22:45:17 2008
New Revision: 25683

Log:
Move all subtitle parsing from mkv demuxer to update_subtitles().


Modified:
   trunk/libmpdemux/demux_mkv.c
   trunk/mpcommon.c

Modified: trunk/libmpdemux/demux_mkv.c
==============================================================================
--- trunk/libmpdemux/demux_mkv.c	(original)
+++ trunk/libmpdemux/demux_mkv.c	Fri Jan 11 22:45:17 2008
@@ -2702,8 +2702,6 @@ handle_subtitles(demuxer_t *demuxer, mkv
                  int64_t size, uint64_t block_duration, uint64_t timecode)
 {
   demux_packet_t *dp;
-  char *ptr1;
-  int i;
 
   if (block_duration == 0)
     {
@@ -2712,28 +2710,9 @@ handle_subtitles(demuxer_t *demuxer, mkv
       return;
     }
 
-#ifdef USE_ASS
-  if (ass_enabled && track->subtitle_type == MATROSKA_SUBTYPE_SSA) {
-    ass_process_chunk(track->sh_sub->ass_track, block, size, (long long)timecode, (long long)block_duration);
-    return;
-  }
-#endif
-
-  ptr1 = block;
-  if (track->subtitle_type == MATROSKA_SUBTYPE_SSA)
-    {
-      /* Find text section. */
-      for (i=0; i < 8 && *ptr1 != '\0'; ptr1++)
-        if (*ptr1 == ',')
-          i++;
-      if (*ptr1 == '\0')  /* Broken line? */
-        return;
-    }
-
   sub_utf8 = 1;
-  size -= ptr1 - block;
   dp = new_demux_packet(size);
-  memcpy(dp->buffer, ptr1, size);
+  memcpy(dp->buffer, block, size);
   dp->pts = timecode / 1000.0f;
   dp->endpts = (timecode + block_duration) / 1000.0f;
   ds_add_packet(demuxer->sub, dp);

Modified: trunk/mpcommon.c
==============================================================================
--- trunk/mpcommon.c	(original)
+++ trunk/mpcommon.c	Fri Jan 11 22:45:17 2008
@@ -28,11 +28,6 @@ void update_subtitles(sh_video_t *sh_vid
     int len;
     char type = d_dvdsub->sh ? ((sh_sub_t *)d_dvdsub->sh)->type : 'v';
     static subtitle subs;
-    if (dvdsub_id >= 0 && type == 'a')
-#ifdef USE_ASS
-      if (!ass_enabled)
-#endif
-      type = 't';
     if (reset) {
         sub_clear_text(&subs, MP_NOPTS_VALUE);
         if (vo_sub) {
@@ -104,7 +99,7 @@ void update_subtitles(sh_video_t *sh_vid
 
         if (spudec_changed(vo_spudec))
             vo_osd_changed(OSDTYPE_SPU);
-    } else if (dvdsub_id >= 0 && type == 't') {
+    } else if (dvdsub_id >= 0 && (type == 't' || type == 'a')) {
         double curpts = sh_video->pts + sub_delay;
         double endpts;
         vo_sub = &subs;
@@ -115,7 +110,16 @@ void update_subtitles(sh_video_t *sh_vid
             endpts = d_dvdsub->first->endpts;
             len = ds_get_packet_sub(d_dvdsub, &packet);
 #ifdef USE_ASS
-            if (ass_enabled) {
+            if (type == 'a' && ass_enabled) { // ssa/ass subs with libass
+                sh_sub_t* sh = d_dvdsub->sh;
+                ass_track = sh ? sh->ass_track : NULL;
+                if (ass_track)
+                    ass_process_chunk(ass_track, packet, len,
+                                      (long long)(pts*1000 + 0.5),
+                                      (long long)((endpts-pts)*1000 + 0.5));
+                continue;
+            }
+            if (type == 't' && ass_enabled) { // plaintext subs with libass
                 static ass_track_t *global_ass_track = NULL;
                 if (!global_ass_track) global_ass_track = ass_default_track(ass_library);
                 ass_track = global_ass_track;
@@ -128,11 +132,23 @@ void update_subtitles(sh_video_t *sh_vid
                     subs.end = endpts * 100;
                     ass_process_subtitle(ass_track, &subs);
                 }
-            } else
+                continue;
+            }
 #endif
             if (pts != MP_NOPTS_VALUE) {
                 if (endpts == MP_NOPTS_VALUE)
                     sub_clear_text(&subs, MP_NOPTS_VALUE);
+                if (type == 'a') { // ssa/ass subs without libass => convert to plaintext
+                    int i;
+                    unsigned char* p = packet;
+                    for (i=0; i < 8 && *p != '\0'; p++)
+                        if (*p == ',')
+                            i++;
+                    if (*p == '\0')  /* Broken line? */
+                        continue;
+                    len -= p - packet;
+                    packet = p;
+                }
                 sub_add_text(&subs, packet, len, endpts);
                 vo_osd_changed(OSDTYPE_SUBTITLE);
             }



More information about the MPlayer-cvslog mailing list