Index: subreader.c =================================================================== --- subreader.c (revision 31341) +++ subreader.c (working copy) @@ -35,6 +35,7 @@ #include "stream/stream.h" #include "libavutil/common.h" #include "libavutil/avstring.h" +#include "libvo/sub.h" #ifdef CONFIG_ENCA #include @@ -135,7 +136,9 @@ s = stristr (s, "Start="); if (s) { - current->start = strtol (s + 6, &s, 0) / 10; + s += 6; + if (*s == '"') s++; + current->start = strtol (s, &s, 0) / 10; /* eat '>' */ for (; *s != '>' && *s != '\0'; s++); s++; @@ -161,17 +164,30 @@ case 3: /* get all text until '<' appears */ if (*s == '\0') break; - else if (!strncasecmp (s, "
", 4)) { + /* catch
,
, and
*/ + else if (!strncasecmp (s, "", 4)) { *p = '\0'; p = text; trail_space (text); if (text[0] != '\0') current->text[current->lines++] = strdup (text); - s += 4; + s = strchr (s, '>'); + if (!s) break; + s++; } else if ((*s == '{') && !sub_no_text_pp) { state = 5; ++s; continue; } else if (*s == '<') { state = 4; } - else if (!strncasecmp (s, " ", 6)) { *p++ = ' '; s += 6; } + else if (!strncasecmp (s, " ", 6) || + !strncmp(s, " ", 6)) { *p++ = ' '; s += 6; } else if (*s == '\t') { *p++ = ' '; s++; } else if (*s == '\r' || *s == '\n') { s++; } + else if (!strncmp (s, "&#", 2)) { + uint32_t c; + uint8_t tmp; + q = s+2; + c = strtoul(q, &s, 0); + /* ignore negative numbers */ + if (!memchr(q, '-', s-q)) PUT_UTF8(c, tmp, *p++ = tmp;) + if (*s == ';') s++; } else *p++ = *s++; /* skip duplicated space */ @@ -1080,7 +1096,6 @@ return SUB_INVALID; // too many bad lines } -extern int sub_utf8; int sub_utf8_prev=0; extern float sub_delay; @@ -1391,6 +1406,8 @@ if (sub_format==SUB_INVALID) {mp_msg(MSGT_SUBREADER,MSGL_WARN,"SUB: Could not determine file format\n");return NULL;} srp=sr+sub_format; mp_msg(MSGT_SUBREADER, MSGL_V, "SUB: Detected subtitle file format: %s\n", srp->name); + if (sub_format == SUB_SAMI) + sub_utf8 = 1; #ifdef CONFIG_ICONV sub_utf8_prev=sub_utf8;