[Mplayer-cvslog] CVS: main subreader.c,1.58,1.59 subreader.h,1.13,1.14
Arpi of Ize
arpi at mplayerhq.hu
Mon May 13 22:41:23 CEST 2002
Update of /cvsroot/mplayer/main
In directory mail:/var/tmp.root/cvs-serv32672
Modified Files:
subreader.c subreader.h
Log Message:
patch fixes broken detecniou of AQTitle subtiles and adds support for subtitles created by subrip 0.9 - by Jiri.Svoboda at seznam.cz
Index: subreader.c
===================================================================
RCS file: /cvsroot/mplayer/main/subreader.c,v
retrieving revision 1.58
retrieving revision 1.59
diff -u -r1.58 -r1.59
--- subreader.c 7 May 2002 21:58:01 -0000 1.58
+++ subreader.c 13 May 2002 20:41:20 -0000 1.59
@@ -470,6 +470,8 @@
subtitle *sub_read_line_aqt(FILE *fd,subtitle *current) {
char line[LINE_LEN+1];
+ char *next;
+ int i;
while (1) {
// try to locate next subtitle
@@ -494,8 +496,13 @@
if (!fgets (line, LINE_LEN, fd))
return current;;
- sub_readtext((char *) &line,¤t->text[1]);
- current->lines = 2;
+ next = line,i=1;
+ 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;}
+ }
+ current->lines=i+1;
if ((current->text[0]=="") && (current->text[1]=="")) {
// void subtitle -> end of previous marked and exit
@@ -506,6 +513,53 @@
return current;
}
+subtitle *previous_subrip09_sub = NULL;
+
+subtitle *sub_read_line_subrip09(FILE *fd,subtitle *current) {
+ char line[LINE_LEN+1];
+ int a1,a2,a3;
+ char * next=NULL;
+ int i,len;
+
+ while (1) {
+ // try to locate next subtitle
+ if (!fgets (line, LINE_LEN, fd))
+ return NULL;
+ if (!((len=sscanf (line, "[%d:%d:%d]",&a1,&a2,&a3)) < 3))
+ break;
+ }
+
+ if (previous_subrip09_sub != NULL)
+ previous_subrip09_sub->end = current->start-1;
+
+ previous_subrip09_sub = current;
+
+ if (!fgets (line, LINE_LEN, fd))
+ return NULL;
+
+ current->start = a1*360000+a2*6000+a3*100;
+
+ next = line,i=0;
+
+ current->text[0]==""; // just to be sure that string is clear
+
+ 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;}
+ }
+ current->lines=i+1;
+
+ if ((current->text[0]=="") && (i==0)) {
+ // void subtitle -> end of previous marked and exit
+ previous_subrip09_sub = NULL;
+ return NULL;
+ }
+
+ return current;
+}
+
+
int sub_autodetect (FILE *fd) {
char line[LINE_LEN+1];
int i,j=0;
@@ -548,7 +602,9 @@
if (sscanf (line, "FORMAT=TIM%c", &p)==1 && p=='E')
{sub_uses_time=1; return SUB_MPSUB;}
if (strstr (line, "-->>"))
- {sub_uses_time=0; return SUB_MPSUB;}
+ {sub_uses_time=0; return SUB_AQTITLE;}
+ if (sscanf (line, "[%d:%d:%d]", &i, &i, &i)==3)
+ {sub_uses_time=1;return SUB_SUBRIP09;}
}
return SUB_INVALID; // too many bad lines
@@ -661,7 +717,7 @@
int n_max;
subtitle *first;
char *fmtname[] = { "microdvd", "subrip", "subviewer", "sami", "vplayer",
- "rt", "ssa", "dunnowhat", "mpsub", "aqt", "subviewer 2.0" };
+ "rt", "ssa", "dunnowhat", "mpsub", "aqt", "subviewer 2.0", "subrip 0.9" };
subtitle * (*func[])(FILE *fd,subtitle *dest)=
{
sub_read_line_microdvd,
@@ -674,7 +730,8 @@
sub_read_line_dunnowhat,
sub_read_line_mpsub,
sub_read_line_aqt,
- sub_read_line_subviewer2
+ sub_read_line_subviewer2,
+ sub_read_line_subrip09
};
if(filename==NULL) return NULL; //qnx segfault
Index: subreader.h
===================================================================
RCS file: /cvsroot/mplayer/main/subreader.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- subreader.h 7 May 2002 21:58:01 -0000 1.13
+++ subreader.h 13 May 2002 20:41:20 -0000 1.14
@@ -18,6 +18,7 @@
#define SUB_MPSUB 8
#define SUB_AQTITLE 9
#define SUB_SUBVIEWER2 10
+#define SUB_SUBRIP09 11
// One of the SUB_* constant above
extern int sub_format;
More information about the MPlayer-cvslog
mailing list