From 723e6e76b3623f22fa30fae382304d8a23fe19a1 Mon Sep 17 00:00:00 2001 From: atlka Date: Tue, 8 Jan 2002 12:45:38 +0000 Subject: 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 --- subreader.c | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) (limited to 'subreader.c') 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; } -- cgit v1.2.3