summaryrefslogtreecommitdiffstats
path: root/subreader.c
diff options
context:
space:
mode:
authorarpi <arpi@b3059339-0415-0410-9bf9-f77b7e298cf2>2001-11-30 23:45:48 +0000
committerarpi <arpi@b3059339-0415-0410-9bf9-f77b7e298cf2>2001-11-30 23:45:48 +0000
commit69bc5817db45a6731aa19df18872156e4b7b4c2d (patch)
tree70fedb17c6ea207e70a79374c41c48fdcfd3f4b1 /subreader.c
parent9b27b3eb401c3340933b26c954a58b77bdfd7e83 (diff)
downloadmpv-69bc5817db45a6731aa19df18872156e4b7b4c2d.tar.bz2
mpv-69bc5817db45a6731aa19df18872156e4b7b4c2d.tar.xz
patch fixes the showing last line of subtitles and support of SAMI Slacktime option by Evgeny Chukreev <codedj@echo.ru>
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@3236 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'subreader.c')
-rw-r--r--subreader.c24
1 files changed, 19 insertions, 5 deletions
diff --git a/subreader.c b/subreader.c
index c26f85d540..d9e31c247d 100644
--- a/subreader.c
+++ b/subreader.c
@@ -34,6 +34,7 @@ static float mpsub_position=0;
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 @@ static inline void trail_space(char *s) {
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 @@ subtitle *sub_read_line_sami(FILE *fd, subtitle *current) {
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 @@ subtitle *sub_read_line_sami(FILE *fd, subtitle *current) {
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 @@ subtitle *sub_read_line_sami(FILE *fd, subtitle *current) {
}
/* 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;
}