[Mplayer-cvslog] CVS: main subreader.c,1.27,1.28
Megyer Laszlo
laaz at mplayer.dev.hu
Fri Oct 12 15:52:34 CEST 2001
Update of /cvsroot/mplayer/main
In directory mplayer:/var/tmp.root/cvs-serv22468
Modified Files:
subreader.c
Log Message:
mpsub read support
Index: subreader.c
===================================================================
RCS file: /cvsroot/mplayer/main/subreader.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -r1.27 -r1.28
--- subreader.c 10 Oct 2001 13:07:42 -0000 1.27
+++ subreader.c 12 Oct 2001 13:51:58 -0000 1.28
@@ -22,6 +22,9 @@
char *sub_cp=NULL;
#endif
+
+static long int mpsub_position=0;
+
int sub_uses_time=0;
int sub_errs=0;
int sub_num=0; // number of subtitle structs
@@ -33,6 +36,7 @@
// 5 for RT format
// 6 for ssa (Sub Station Alpha)
// 7 for ... erm ... dunnowhat. tell me if you know
+ // 8 for the glorious MPsub
int eol(char p) {
return (p=='\r' || p=='\n' || p=='\0');
@@ -367,10 +371,45 @@
return current;
}
+subtitle *sub_read_line_mpsub(FILE *fd, subtitle *current) {
+ char line[1000];
+ int a,b,num=0;
+ char *p, *q;
+
+ do
+ {
+ if (!fgets(line, 1000, fd)) return NULL;
+ } while (sscanf (line, "%d %d", &a, &b) !=2);
+
+ mpsub_position += (a*100);
+ current->start=mpsub_position+1;
+ mpsub_position += (b*100);
+ current->end=mpsub_position;
+
+ while (num < SUB_MAX_TEXT) {
+ if (!fgets (line, 1000, fd)) return NULL;
+ p=line;
+ while (isspace(*p)) p++;
+ if (eol(*p) && num > 0) return current;
+ if (eol(*p)) return NULL;
+
+ for (q=p; !eol(*q); q++);
+ *q='\0';
+ if (strlen(p)) {
+ current->text[num]=strdup(p);
+ current->lines = ++num;
+ } else {
+ if (num) return current;
+ else return NULL;
+ }
+ }
+}
+
+
int sub_autodetect (FILE *fd) {
char line[1001];
int i,j=0;
-// char *p;
+ char p;
while (j < 100) {
j++;
@@ -400,6 +439,10 @@
{sub_uses_time=1; return 6;}
if (sscanf (line, "%d,%d,\"%c", &i, &i, (char *) &i) == 3)
{sub_uses_time=0;return 7;}
+ if (sscanf (line, "FORMAT=%d", &i) == 1)
+ {sub_uses_time=0; return 8;}
+ if (sscanf (line, "FORMAT=TIM%c", &p)==1 && p=='E')
+ {sub_uses_time=1; return 8;}
}
return -1; // too many bad lines
@@ -485,7 +528,8 @@
sub_read_line_vplayer,
sub_read_line_rt,
sub_read_line_ssa,
- sub_read_line_dunnowhat
+ sub_read_line_dunnowhat,
+ sub_read_line_mpsub
};
fd=fopen (filename, "r"); if (!fd) return NULL;
More information about the MPlayer-cvslog
mailing list