[Mplayer-cvslog] CVS: main subreader.c,1.46,1.47

Adam Tla/lka atlka at mplayer.dev.hu
Tue Jan 8 13:45:41 CET 2002


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

Modified Files:
	subreader.c 
Log Message:
added adjust_subs_time function which corrects bad sub->end time
after reading subs so it is sub format independent


Index: subreader.c
===================================================================
RCS file: /cvsroot/mplayer/main/subreader.c,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -r1.46 -r1.47
--- subreader.c	8 Jan 2002 11:03:43 -0000	1.46
+++ subreader.c	8 Jan 2002 12:45:38 -0000	1.47
@@ -171,8 +171,6 @@
     char *p, *next;
     int i;
 
-static subtitle *prevsub = NULL;
-
     memset(current, 0, sizeof(subtitle));
 
     do {
@@ -194,14 +192,6 @@
     }
     current->lines= ++i;
 
-    if (!current->end)
-	current->end = current->start + 150; /* approx 6 sec */
-
-    if (prevsub && (prevsub->end >= current->start))
-	prevsub->end = current->start - 1; /* correct previous end time */
-
-    prevsub = current;
-	
     return current;
 }
 
@@ -609,6 +599,24 @@
 
 #endif
 
+static void adjust_subs_time(subtitle* sub, unsigned long subtime){
+	int i = sub_num;
+	subtitle* nextsub;
+
+	for (;;){	
+		if (sub->end <= sub->start)
+			sub->end = sub->start + subtime;
+		if (!--i) return;
+		nextsub = sub + 1;
+		if (sub->end >= nextsub->start){
+			sub->end = nextsub->start - 1;
+			if (sub->end - sub->start > subtime)
+				sub->end = sub->start + subtime;
+		}
+		sub = nextsub;
+	}
+}
+
 subtitle* sub_read_file (char *filename) {
     FILE *fd;
     int n_max;
@@ -674,6 +682,11 @@
 	return NULL;
     }
 
+// if sub->end time is 0 set it to sub_>start + ~6 sec but not 
+// after next sub->start time
+// correct also if sub->end time is below sub->start time
+// maybe default subtime (150fms) should be a program option AST
+    adjust_subs_time(first, 150);
     return first;
 }
 




More information about the MPlayer-cvslog mailing list