summaryrefslogtreecommitdiffstats
path: root/subreader.c
diff options
context:
space:
mode:
authorlaaz <laaz@b3059339-0415-0410-9bf9-f77b7e298cf2>2001-05-31 18:08:24 +0000
committerlaaz <laaz@b3059339-0415-0410-9bf9-f77b7e298cf2>2001-05-31 18:08:24 +0000
commitd7f6f3e341ae2a53c82ec0056257f110c10fdb57 (patch)
tree3972484e233fe63b337914399e921836e02ed1f7 /subreader.c
parentd29c15dbdf56b159bff1a74d23b1e8e09992a196 (diff)
downloadmpv-d7f6f3e341ae2a53c82ec0056257f110c10fdb57.tar.bz2
mpv-d7f6f3e341ae2a53c82ec0056257f110c10fdb57.tar.xz
Added support for .ssa subtitles
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@922 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'subreader.c')
-rw-r--r--subreader.c35
1 files changed, 31 insertions, 4 deletions
diff --git a/subreader.c b/subreader.c
index f6b1ff65db..211ce39627 100644
--- a/subreader.c
+++ b/subreader.c
@@ -21,10 +21,11 @@ int sub_errs=0;
int sub_num=0; // number of subtitle structs
int sub_format=-1; // 0 for microdvd
// 1 for SubRip
- // 2 for the third format (what's this?)
+ // 2 for SubViewer
// 3 for SAMI (smi)
// 4 for vplayer format
// 5 for RT format
+ // 6 for ssa (Sub Station Alpha)
int eol(char p) {
return (p=='\r' || p=='\n' || p=='\0');
@@ -295,7 +296,27 @@ subtitle *sub_read_line_rt(FILE *fd,subtitle *current) {
return current;
}
+subtitle *sub_read_line_ssa(FILE *fd,subtitle *current) {
+ int hour1, min1, sec1, hunsec1,
+ hour2, min2, sec2, hunsec2, nothing;
+
+ char line[1000],
+ line2[1000];
+ do {
+ if (!fgets (line, 1000, fd)) return NULL;
+ } while (sscanf (line, "Dialogue: Marked=%d,%d:%d:%d.%d,%d:%d:%d.%d,"
+ "*Default,%d,%d,%d,%d,,%[^\n\r]", &nothing, &hour1, &min1,
+ &sec1, &hunsec1,
+ &hour2, &min2, &sec2, &hunsec2, &nothing,
+ &nothing, &nothing, &nothing, line2) < 14);
+ current->lines=1;
+ current->start = 360000*hour1 + 6000*min1 + 100*sec1 + hunsec1;
+ current->end = 360000*hour2 + 6000*min2 + 100*sec2 + hunsec2;
+ current->text[0]=(char *) malloc(strlen(line2)+1);
+ strcpy(current->text[0],line2);
+ return current;
+}
int sub_autodetect (FILE *fd) {
char line[1001];
@@ -320,9 +341,14 @@ int sub_autodetect (FILE *fd) {
//TODO: just checking if first line of sub starts with "<" is WAY
// too weak test for RT
// Please someone who knows the format of RT... FIX IT!!!
- // It may conflict with other sub formats in the future
+ // It may conflict with other sub formats in the future (actually it doesn't)
if ( *line == '<' )
{sub_uses_time=1;return 5;}
+
+ // I have only seen only 1 piece of .ssa file.
+ // It may be not correct (tell me if it's not)
+ if (!memcmp(line, "Dialogue: Marked", 16))
+ {sub_uses_time=1; return 6;}
}
return -1; // too many bad lines
@@ -333,14 +359,15 @@ subtitle* sub_read_file (char *filename) {
FILE *fd;
int n_max;
subtitle *first;
- subtitle * (*func[6])(FILE *fd,subtitle *dest)=
+ subtitle * (*func[7])(FILE *fd,subtitle *dest)=
{
sub_read_line_microdvd,
sub_read_line_subrip,
sub_read_line_third,
sub_read_line_sami,
sub_read_line_vplayer,
- sub_read_line_rt
+ sub_read_line_rt,
+ sub_read_line_ssa
};
fd=fopen (filename, "r"); if (!fd) return NULL;