changeset 10861:59e3d641c48c

Marked SSA subs as UTF-8. Better newline handling for SSA subs. Patch by Tristan <z80@oceanfree.net>.
author mosu
date Fri, 12 Sep 2003 21:56:03 +0000
parents 472c5531b695
children 5e5f230b102d
files libmpdemux/demux_mkv.cpp
diffstat 1 files changed, 17 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/libmpdemux/demux_mkv.cpp	Fri Sep 12 21:47:28 2003 +0000
+++ b/libmpdemux/demux_mkv.cpp	Fri Sep 12 21:56:03 2003 +0000
@@ -448,18 +448,9 @@
 
     /* Load text. */
     while ((unsigned int)(s1 - buffer) < data.Size()) {
-      if ((*s1 == '{') && ((unsigned int)(s1 + 2 - buffer) < data.Size())) {
-        /* Newline */
-        if (*(s1 + 1) == '\\' && (*(s1 + 2) == 'N' || *(s1 + 2) == 'n')) {
-          mkv_d->clear_subs_at[mkv_d->subs.lines - 1] = 
-            block->GlobalTimecode() / 1000000 - mkv_d->first_tc + duration;
-
-          mkv_d->subs.lines++;
-          *s2 = 0;
-          s2 = mkv_d->subs.text[mkv_d->subs.lines - 1];
-        }
+      if (*s1 == '{')
         state = 1;
-      } else if (*s1 == '}' && state == 1)
+      else if ((*s1 == '}') && (state == 1))
         state = 2;
 
       if (state == 0) {
@@ -470,6 +461,18 @@
       }
       s1++;
       
+      /* Newline */
+      if ((*s1 == '\\') && ((unsigned int)(s1 + 1 - buffer) < data.Size()) &&
+          ((*(s1 + 1) == 'N') || (*(s1 + 1) == 'n'))) {
+        mkv_d->clear_subs_at[mkv_d->subs.lines - 1] = 
+          block->GlobalTimecode() / 1000000 - mkv_d->first_tc + duration;
+        
+        mkv_d->subs.lines++;
+        *s2 = 0;
+        s2 = mkv_d->subs.text[mkv_d->subs.lines - 1];
+        s1 += 2;
+      }
+
       if (state == 2)
         state = 0;
     }
@@ -1910,9 +1913,10 @@
 
         if (!strcmp(track->codec_id, MKV_S_TEXTUTF8))
           sub_utf8 = 1;       // Force UTF-8 conversion.
-        if (!strcmp(track->codec_id, MKV_S_TEXTSSA))
+        if (!strcmp(track->codec_id, MKV_S_TEXTSSA)) {
           mkv_d->subtitle_type = MKV_SUBTYPE_SSA;
-        else
+          sub_utf8 = 1;
+        } else
           mkv_d->subtitle_type = MKV_SUBTYPE_TEXT;
       } else
         mp_msg(MSGT_DEMUX, MSGL_ERR, "[mkv] File does not contain a "