Mercurial > mplayer.hg
changeset 4051:0e7c382bc53a
added adjust_subs_time function which corrects bad sub->end time
after reading subs so it is sub format independent
author | atlka |
---|---|
date | Tue, 08 Jan 2002 12:45:38 +0000 |
parents | da61596bcd87 |
children | 505f206d80d1 |
files | subreader.c |
diffstat | 1 files changed, 23 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/subreader.c Tue Jan 08 12:10:33 2002 +0000 +++ b/subreader.c Tue Jan 08 12:45:38 2002 +0000 @@ -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; }