summaryrefslogtreecommitdiffstats
path: root/subreader.c
diff options
context:
space:
mode:
authoratlka <atlka@b3059339-0415-0410-9bf9-f77b7e298cf2>2002-01-08 12:45:38 +0000
committeratlka <atlka@b3059339-0415-0410-9bf9-f77b7e298cf2>2002-01-08 12:45:38 +0000
commit723e6e76b3623f22fa30fae382304d8a23fe19a1 (patch)
treeffe917f24649272f306168c73dc7f2c488b3d89f /subreader.c
parent0573693a2b57fce962e36c8d51ab4703c20766c2 (diff)
downloadmpv-723e6e76b3623f22fa30fae382304d8a23fe19a1.tar.bz2
mpv-723e6e76b3623f22fa30fae382304d8a23fe19a1.tar.xz
added adjust_subs_time function which corrects bad sub->end time
after reading subs so it is sub format independent git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@4052 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'subreader.c')
-rw-r--r--subreader.c33
1 files changed, 23 insertions, 10 deletions
diff --git a/subreader.c b/subreader.c
index 4bbd412ab5..d19d1de220 100644
--- a/subreader.c
+++ b/subreader.c
@@ -171,8 +171,6 @@ subtitle *sub_read_line_microdvd(FILE *fd,subtitle *current) {
char *p, *next;
int i;
-static subtitle *prevsub = NULL;
-
memset(current, 0, sizeof(subtitle));
do {
@@ -194,14 +192,6 @@ static subtitle *prevsub = NULL;
}
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 @@ subtitle* subcp_recode (subtitle *sub)
#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 @@ subtitle* sub_read_file (char *filename) {
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;
}