summaryrefslogtreecommitdiffstats
path: root/subreader.c
diff options
context:
space:
mode:
authoralex <alex@b3059339-0415-0410-9bf9-f77b7e298cf2>2002-06-29 10:39:58 +0000
committeralex <alex@b3059339-0415-0410-9bf9-f77b7e298cf2>2002-06-29 10:39:58 +0000
commitc282ad5a4c102b8e05121fc4b9f226946540de32 (patch)
treee54cc484b3157af27d2a301a0ddbb4bf9f1719fb /subreader.c
parent8bdba96f163b24c74b56517686a227127d6a63b3 (diff)
downloadmpv-c282ad5a4c102b8e05121fc4b9f226946540de32.tar.bz2
mpv-c282ad5a4c102b8e05121fc4b9f226946540de32.tar.xz
support for SSA v4 by Dirk <noisyb at gmx.net>
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@6598 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'subreader.c')
-rw-r--r--subreader.c30
1 files changed, 26 insertions, 4 deletions
diff --git a/subreader.c b/subreader.c
index ef613ee73c..66767d9282 100644
--- a/subreader.c
+++ b/subreader.c
@@ -376,6 +376,19 @@ subtitle *sub_read_line_rt(FILE *fd,subtitle *current) {
}
subtitle *sub_read_line_ssa(FILE *fd,subtitle *current) {
+/*
+ * Sub Station Alpha v4 (and v2?) scripts have 9 commas before subtitle
+ * other Sub Station Alpha scripts have only 8 commas before subtitle
+ * Reading the "ScriptType:" field is not reliable since many scripts appear
+ * w/o it
+ *
+ * http://www.scriptclub.org is a good place to find more examples
+ * http://www.eswat.demon.co.uk is where the SSA specs can be found
+ */
+ int comma;
+ static int max_comma = 32; /* let's use 32 for the case that the */
+ /* amount of commas increase with newer SSA versions */
+
int hour1, min1, sec1, hunsec1,
hour2, min2, sec2, hunsec2, nothing;
int num;
@@ -392,10 +405,19 @@ subtitle *sub_read_line_ssa(FILE *fd,subtitle *current) {
&hour1, &min1, &sec1, &hunsec1,
&hour2, &min2, &sec2, &hunsec2,
line3) < 9);
- line2=strstr(line3,",,");
- if (!line2) return NULL;
- line2 ++;
- line2 ++;
+
+ line2=strchr(line3, ',');
+
+ for (comma = 4; comma < max_comma; comma ++)
+ {
+ tmp = line2;
+ if(!(tmp=strchr(++tmp, ','))) break;
+ if(*(++tmp) == ' ') break;
+ /* a space after a comma means we're already in a sentence */
+ line2 = tmp;
+ }
+
+ if(comma < max_comma)max_comma = comma;
current->lines=0;num=0;
current->start = 360000*hour1 + 6000*min1 + 100*sec1 + hunsec1;