changeset 850:2cc743142e79

Preliminary support for RT-type subs.
author eyck
date Tue, 22 May 2001 11:09:26 +0000
parents 0d4f64301c21
children 8a99c95b0f56
files configure debian/files debian/mplayer.conf subreader.c
diffstat 4 files changed, 57 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/configure	Tue May 22 07:45:35 2001 +0000
+++ b/configure	Tue May 22 11:09:26 2001 +0000
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 
 #
 # MPlayer configurator.   (C) 2000 Pontscho/fresh!mindworkz
--- a/debian/files	Tue May 22 07:45:35 2001 +0000
+++ b/debian/files	Tue May 22 11:09:26 2001 +0000
@@ -1,1 +1,1 @@
-mplayer_0.17a-1_i386.deb unknown optional
+mplayer_0.17a-2_i386.deb unknown optional
--- a/debian/mplayer.conf	Tue May 22 07:45:35 2001 +0000
+++ b/debian/mplayer.conf	Tue May 22 11:09:26 2001 +0000
@@ -41,7 +41,6 @@
 ##
 
 sound	= 1
-nosound	= nein
 mixer	= /dev/mixer
 master	= no		# no : set PCM volume  	yes : set MASTER volume
 
@@ -83,7 +82,7 @@
 # forcexv = yes		# force XVideo even if not detected
 
 
-# nodshow		# disable usage of DirectShow video codecs
+# nodshow = 1		# disable usage of DirectShow video codecs
 
 ##
 ## You can also include other configfiles
--- a/subreader.c	Tue May 22 07:45:35 2001 +0000
+++ b/subreader.c	Tue May 22 11:09:26 2001 +0000
@@ -24,6 +24,7 @@
 		     // 2 for the third format (what's this?)
 		    // 3 for SAMI (smi)
 		   // 4 for vplayer format
+		  // 5 for RT format
 
 int eol(char p) {
     return (p=='\r' || p=='\n' || p=='\0');
@@ -253,6 +254,46 @@
 	return current;
 }
 
+subtitle *sub_read_line_rt(FILE *fd,subtitle *current) {
+	//TODO: This format uses quite rich (sub/super)set of xhtml 
+	// I couldn't check it since DTD is not included.
+	// WARNING: full XML parses can be required for proper parsing 
+    char line[1001];
+    int a1,a2,a3,a4,b1,b2,b3,b4;
+    char *p=NULL,*next=NULL;
+    int i,len,plen;
+    
+    bzero (current, sizeof(current));
+    
+    while (!current->text[0]) {
+	if (!fgets (line, 1000, fd)) return NULL;
+	//TODO: it seems that format of time is not easily determined, it may be 1:12, 1:12.0 or 0:1:12.0
+	//to describe the same moment in time. Maybe there are even more formats in use.
+	//if ((len=sscanf (line, "<Time Begin=\"%d:%d:%d.%d\" End=\"%d:%d:%d.%d\"",&a1,&a2,&a3,&a4,&b1,&b2,&b3,&b4)) < 8)
+	plen=a1=a2=a3=a4=b1=b2=b3=b4=0;
+	if (
+	((len=sscanf (line, "<%*[tT]ime %*[bB]egin=\"%d:%d\" %*[Ee]nd=\"%d:%d\"%*[^<]<clear/>%n",&a2,&a3,&b2,&b3,&plen)) < 4) &&
+	((len=sscanf (line, "<%*[tT]ime %*[bB]egin=\"%d:%d\" %*[Ee]nd=\"%d:%d.%d\"%*[^<]<clear/>%n",&a2,&a3,&b2,&b3,&b4,&plen)) < 5) &&
+//	((len=sscanf (line, "<%*[tT]ime %*[bB]egin=\"%d:%d.%d\" %*[Ee]nd=\"%d:%d\"%*[^<]<clear/>%n",&a2,&a3,&a4,&b2,&b3,&plen)) < 5) &&
+	((len=sscanf (line, "<%*[tT]ime %*[bB]egin=\"%d:%d.%d\" %*[Ee]nd=\"%d:%d.%d\"%*[^<]<clear/>%n",&a2,&a3,&a4,&b2,&b3,&b4,&plen)) < 6) &&
+	((len=sscanf (line, "<%*[tT]ime %*[bB]egin=\"%d:%d:%d.%d\" %*[Ee]nd=\"%d:%d:%d.%d\"%*[^<]<clear/>%n",&a1,&a2,&a3,&a4,&b1,&b2,&b3,&b4,&plen)) < 8) 
+	)
+	    continue;
+	current->start = a1*360000+a2*6000+a3*100+a4/10;
+	current->end   = b1*360000+b2*6000+b3*100+b4/10;
+	p=line;	p+=plen;i=0;
+	// TODO: I don't know what kind of convention is here for marking multiline subs, maybe <br/> like in xml?
+	next = strstr(line,"<clear/>")+8;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) {
@@ -275,7 +316,10 @@
 		{sub_uses_time=1; return 3;}
 	if (sscanf (line, "%d:%d:%d:",     &i, &i, &i )==3)
 		{sub_uses_time=1;return 4;}
-
+	//TODO: just checking if first line of sub starts with "<" is WAY
+	// to weak test for RT
+	if (strcmp("<",line))
+		{sub_uses_time=1;return 5;}
     }
 
     return -1;  // too many bad lines
@@ -286,13 +330,14 @@
     FILE *fd;
     int n_max;
     subtitle *first;
-    subtitle * (*func[5])(FILE *fd,subtitle *dest)=
+    subtitle * (*func[6])(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_vplayer,
+	    sub_read_line_rt
     };
 
     fd=fopen (filename, "r"); if (!fd) return NULL;
@@ -344,14 +389,18 @@
  char * sub_name = NULL;
  char * sub_tmp  = NULL;
  int    i;
-#define SUB_EXTS 6
+#define SUB_EXTS 10
  char * sub_exts[SUB_EXTS] = 
   { ".sub",
     ".SUB",
     ".srt",
     ".SRT",
     ".smi",
-    ".SMI"};
+    ".SMI",
+    ".rt",
+    ".RT",
+    ".txt",
+    ".TXT"};
  
  if ( fname == NULL ) return NULL;
  for( i=strlen( fname );i>0;i-- )