Mercurial > mplayer.hg
changeset 818:16ba80b47ec4
Support for vplayer subtitles
author | eyck |
---|---|
date | Thu, 17 May 2001 09:17:16 +0000 |
parents | 5fccfe90850c |
children | 291de1f95724 |
files | subreader.c subreader.h |
diffstat | 2 files changed, 48 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/subreader.c Thu May 17 01:07:56 2001 +0000 +++ b/subreader.c Thu May 17 09:17:16 2001 +0000 @@ -23,6 +23,7 @@ // 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 @@ 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 @@ {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 @@ 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;
--- a/subreader.h Thu May 17 01:07:56 2001 +0000 +++ b/subreader.h Thu May 17 09:17:16 2001 +0000 @@ -9,6 +9,7 @@ // 1 for SubRip // 2 for the third format // 3 for SAMI (smi) + // 4 for vplayer format #define SUB_MAX_TEXT 5 @@ -25,4 +26,4 @@ subtitle* sub_read_file (char *filename); char * sub_filename( char * fname ); -#endif \ No newline at end of file +#endif