summaryrefslogtreecommitdiffstats
path: root/subreader.c
diff options
context:
space:
mode:
authoreyck <eyck@b3059339-0415-0410-9bf9-f77b7e298cf2>2001-05-17 09:17:16 +0000
committereyck <eyck@b3059339-0415-0410-9bf9-f77b7e298cf2>2001-05-17 09:17:16 +0000
commit9e372bc823c8987189f46911a9584d71b4ef2609 (patch)
tree8a629164293e6f2e5fb3d1612a2a38d2e3aa0279 /subreader.c
parentad6d62e21014a4424b49ea1a2ca013be6116bd4a (diff)
downloadmpv-9e372bc823c8987189f46911a9584d71b4ef2609.tar.bz2
mpv-9e372bc823c8987189f46911a9584d71b4ef2609.tar.xz
Support for vplayer subtitles
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@819 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'subreader.c')
-rw-r--r--subreader.c48
1 files changed, 46 insertions, 2 deletions
diff --git a/subreader.c b/subreader.c
index 6e20dc22a1..d0cb84567d 100644
--- a/subreader.c
+++ b/subreader.c
@@ -23,6 +23,7 @@ int sub_format=-1; // 0 for microdvd
// 1 for SubRip
// 2 for the third format (what's this?)
// 3 for SAMI (smi)
+ // 4 for vplayer format
int eol(char p) {
return (p=='\r' || p=='\n' || p=='\0');
@@ -214,6 +215,45 @@ subtitle *sub_read_line_third(FILE *fd,subtitle *current) {
return current;
}
+subtitle *sub_read_line_vplayer(FILE *fd,subtitle *current) {
+ char line[1001];
+ char line2[1001];
+ int a1,a2,a3,b1,b2,b3;
+ int setime,etime;
+ char *p=NULL, *q=NULL, *l=NULL,*next;
+ int i,len,len2;
+
+ bzero (current, sizeof(current));
+
+ while (!current->text[0]) {
+ if (!fgets (line, 1000, fd)) return NULL;
+ if ((len=sscanf (line, "%d:%d:%d:",&a1,&a2,&a3)) < 3)
+ continue;
+ if (!fgets (line2, 1000, fd)) return NULL;
+ if ((len2=sscanf (line2, "%d:%d:%d:",&b1,&b2,&b3)) < 3)
+ continue;
+ // przewiń o linijkę do tyłu:
+ fseek(fd,-strlen(line2),SEEK_CUR);
+
+ current->start = a1*360000+a2*6000+a3*100;
+ current->end = b1*360000+b2*6000+b3*100;
+ // teraz czas na wkopiowanie stringu
+ p=line; p+=9;i=0;
+ if (*p!='|') {
+ //
+ next = p,i=0;
+ while ((next =sub_readtext (next, &(current->text[i])))) {
+ if (current->text[i]==ERR) {return ERR;}
+ i++;
+ if (i>=SUB_MAX_TEXT) { printf ("Too many lines in a subtitle\n");current->lines=i;return;}
+ }
+ current->lines=i+1;
+ }
+ }
+ return current;
+}
+
+
int sub_autodetect (FILE *fd) {
char line[1001];
@@ -233,6 +273,9 @@ int sub_autodetect (FILE *fd) {
{sub_uses_time=1;return 2;}
if (strstr (line, "<SAMI>"))
{sub_uses_time=1; return 3;}
+ if (sscanf (line, "%d:%d:%d:", &i, &i, &i )==3)
+ {sub_uses_time=1;return 4;}
+
}
return -1; // too many bad lines
@@ -243,12 +286,13 @@ subtitle* sub_read_file (char *filename) {
FILE *fd;
int n_max;
subtitle *first;
- subtitle * (*func[4])(FILE *fd,subtitle *dest)=
+ subtitle * (*func[5])(FILE *fd,subtitle *dest)=
{
sub_read_line_microdvd,
sub_read_line_subrip,
sub_read_line_third,
- sub_read_line_sami
+ sub_read_line_sami,
+ sub_read_line_vplayer
};
fd=fopen (filename, "r"); if (!fd) return NULL;