[MPlayer-dev-eng] [PATCH] SSA subtitle reader fix v2
Dirk
noisyb at gmx.net
Wed Jun 26 19:13:30 CEST 2002
ok.. no more lazy replying by using other threads.. damn.. i have to use
the address book now :(
this patch will detect the right amount of commas before subtitle faster
by checkin' if there's a space after the comma.. if there's a space then
it must be a comma in a sentence and the prior comma will be used...
Dirk
-------------- next part --------------
Index: subreader.c
===================================================================
RCS file: /cvsroot/mplayer/main/subreader.c,v
retrieving revision 1.64
diff -u -r1.64 subreader.c
--- subreader.c 3 Jun 2002 23:23:02 -0000 1.64
+++ subreader.c 26 Jun 2002 11:12:17 -0000
@@ -376,6 +376,19 @@
}
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 @@
&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;
More information about the MPlayer-dev-eng
mailing list