[MPlayer-dev-eng] SSA in mkv with adjacent \N patch

Robert Henney robh at rut.org
Fri Nov 18 22:02:10 CET 2005


This patch was submitted back in February but neither committed nor 
rejected.  With the year almost at its end I decided it was about time
to bring it up again.

In summary it improves the handling of instances of double '\N' and 
cases where SUB_MAX_TEXT is exceeded.

Amazingly the patch still appears to apply cleanly, so the attached
patch is the same one that went to this list in February.

The Feb 17 thread of the same subject provides a bit more context.

-- 
robh
-------------- next part --------------
Index: subreader.h
===================================================================
RCS file: /cvsroot/mplayer/main/subreader.h,v
retrieving revision 1.37
diff -u -r1.37 subreader.h
--- subreader.h 18 Oct 2004 20:41:05 -0000      1.37
+++ subreader.h 17 Feb 2005 17:14:11 -0000
@@ -29,7 +29,7 @@
 
 #define MAX_SUBTITLE_FILES 128
 
-#define SUB_MAX_TEXT 10
+#define SUB_MAX_TEXT 12
 #define SUB_ALIGNMENT_BOTTOMLEFT       1
 #define SUB_ALIGNMENT_BOTTOMCENTER     2
 #define SUB_ALIGNMENT_BOTTOMRIGHT      3
Index: libmpdemux/demux_mkv.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demux_mkv.c,v
retrieving revision 1.37
diff -u -r1.37 demux_mkv.c
--- libmpdemux/demux_mkv.c      21 Jan 2005 18:25:44 -0000      1.37
+++ libmpdemux/demux_mkv.c      17 Feb 2005 17:14:12 -0000
@@ -2583,16 +2583,19 @@
           ptr1++;
       
           /* Newline */
-          if (*ptr1 == '\\' && ptr1+1-block < size && (*(ptr1+1)|0x20) == 'n')
+          while (*ptr1 == '\\' && ptr1+1-block < size && (*(ptr1+1)|0x20) == 'n')
             {
               mkv_d->clear_subs_at[mkv_d->subs.lines++]
                 = timecode + block_duration;
               *ptr2 = '\0';
               if (mkv_d->subs.lines >= SUB_MAX_TEXT)
                 {
-                  mp_msg (MSGT_DEMUX, MSGL_WARN, "[mkv] Warning: too many "
-                          "sublines to render, skipping\n");
-                  return;
+                  mp_msg (MSGT_DEMUX, MSGL_WARN, "\n[mkv] Warning: too many "
+                          "sublines to render, skipping after first %i\n",
+                         SUB_MAX_TEXT);
+                  mkv_d->subs.lines--;
+                  ptr1=block+size;
+                  break;
                 }
               ptr2 = mkv_d->subs.text[mkv_d->subs.lines];
               ptr1 += 2;
@@ -2605,7 +2608,7 @@
     }
   else
     {
-      while (ptr1 - block != size)
+      while (ptr1 - block < size)
         {
           if (*ptr1 == '\n' || *ptr1 == '\r')
             {
@@ -2616,9 +2619,12 @@
                     = timecode + block_duration;
                   if (mkv_d->subs.lines >= SUB_MAX_TEXT)
                     {
-                      mp_msg (MSGT_DEMUX, MSGL_WARN, "[mkv] Warning: too many "
-                              "sublines to render, skipping\n");
-                      return;
+                      mp_msg (MSGT_DEMUX, MSGL_WARN, "\n[mkv] Warning: too many "
+                              "sublines to render, skipping after first %i\n",
+                             SUB_MAX_TEXT);
+                      mkv_d->subs.lines--;
+                      ptr1=block+size;
+                      break;
                     }
                   ptr2 = mkv_d->subs.text[mkv_d->subs.lines];
                   state = 1;


More information about the MPlayer-dev-eng mailing list