[Mplayer-cvslog] CVS: main subreader.c,1.38,1.39

Arpi of Ize arpi at mplayer.dev.hu
Sat Dec 1 00:45:50 CET 2001


Update of /cvsroot/mplayer/main
In directory mplayer:/var/tmp.root/cvs-serv2990

Modified Files:
	subreader.c 
Log Message:
patch fixes the showing last line of subtitles and support of SAMI Slacktime option by Evgeny Chukreev <codedj at echo.ru>

Index: subreader.c
===================================================================
RCS file: /cvsroot/mplayer/main/subreader.c,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -r1.38 -r1.39
--- subreader.c	15 Nov 2001 16:46:52 -0000	1.38
+++ subreader.c	30 Nov 2001 23:45:48 -0000	1.39
@@ -34,6 +34,7 @@
 int sub_uses_time=0;
 int sub_errs=0;
 int sub_num=0;          // number of subtitle structs
+int sub_slacktime=2000; // 20 seconds
 
 /* Use the SUB_* constant defined in the header file */
 int sub_format=SUB_INVALID;
@@ -52,7 +53,7 @@
 
 subtitle *sub_read_line_sami(FILE *fd, subtitle *current) {
     static char line[LINE_LEN+1];
-    static char *s = NULL;
+    static char *s = NULL, *slacktime_s;
     char text[LINE_LEN+1], *p, *q;
     int state;
 
@@ -66,7 +67,10 @@
     do {
 	switch (state) {
 
-	case 0: /* find "START=" */
+	case 0: /* find "START=" or "Slacktime:" */
+	    slacktime_s = strstr (s, "Slacktime:");
+	    if (slacktime_s) sub_slacktime = strtol (slacktime_s + 10, NULL, 0) / 10;
+
 	    s = strstr (s, "Start=");
 	    if (s) {
 		current->start = strtol (s + 6, &s, 0) / 10;
@@ -83,7 +87,7 @@
 	    break;
  
 	case 3: /* get all text until '<' appears */
-	    if (*s == '\0') { break; }
+	    if (*s == '\0') break;
 	    else if (!strncasecmp (s, "<br>", 4)) {
 		*p = '\0'; p = text; trail_space (text);
 		if (text[0] != '\0')
@@ -117,10 +121,20 @@
 	}
 
 	/* read next line */
-	if (state != 99 && !(s = fgets (line, LINE_LEN, fd))) return 0;
-
+	if (state != 99 && !(s = fgets (line, LINE_LEN, fd)))
+	    if (current->start > 0) break; // if it is the last subtitle
+	    else return 0;
+	    
     } while (state != 99);
 
+    // For the last subtitle
+    if (current->end <= 0) {
+        current->end = current->start + sub_slacktime;
+	*p = '\0'; trail_space (text);
+	if (text[0] != '\0')
+	    current->text[current->lines++] = strdup (text);
+    }
+    
     return current;
 }
 




More information about the MPlayer-cvslog mailing list