changeset 2343:da8dbcfb89d0

AQT type support patch by Jiri.Svoboda@seznam.cz
author arpi
date Sun, 21 Oct 2001 17:19:59 +0000
parents c8caaf8cd683
children 1c573fed42dd
files subreader.c
diffstat 1 files changed, 51 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/subreader.c	Sun Oct 21 16:32:26 2001 +0000
+++ b/subreader.c	Sun Oct 21 17:19:59 2001 +0000
@@ -37,6 +37,7 @@
 		 // 6 for ssa (Sub Station Alpha)
 		// 7 for ... erm ... dunnowhat. tell me if you know
 	       // 8 for the glorious MPsub
+	      // 9 for AQTitle
 
 int eol(char p) {
     return (p=='\r' || p=='\n' || p=='\0');
@@ -49,6 +50,7 @@
 	while (i > 0 && isspace(s[i])) s[i--] = '\0';
 }
 
+
 subtitle *sub_read_line_sami(FILE *fd, subtitle *current) {
     static char line[1001];
     static char *s = NULL;
@@ -406,6 +408,47 @@
 	}
 }
 
+subtitle *previous_aqt_sub = NULL;
+
+subtitle *sub_read_line_aqt(FILE *fd,subtitle *current) {
+    char line[1001];
+
+    bzero (current, sizeof(subtitle));
+
+    while (1) {
+    // try to locate next subtitle
+        if (!fgets (line, 1000, fd))
+		return NULL;
+        if (!(sscanf (line, "-->> %ld", &(current->start)) <1))
+		break;
+    }
+    
+    if (previous_aqt_sub != NULL) 
+	previous_aqt_sub->end = current->start-1;
+    
+    previous_aqt_sub = current;
+
+    if (!fgets (line, 1000, fd))
+	return NULL;
+
+    sub_readtext(&line,&current->text[0]);
+    current->lines = 1;
+    current->end = current->start; // will be corrected by next subtitle
+
+    if (!fgets (line, 1000, fd))
+	return current;;
+
+    sub_readtext(&line,&current->text[1]);
+    current->lines = 2;
+
+    if ((current->text[0]=="") && (current->text[1]=="")) {
+	// void subtitle -> end of previous marked and exit
+	previous_aqt_sub = NULL;
+	return NULL;
+	}
+
+    return current;
+}
 
 int sub_autodetect (FILE *fd) {
     char line[1001];
@@ -444,6 +487,8 @@
 		{sub_uses_time=0; return 8;}
 	if (sscanf (line, "FORMAT=TIM%c", &p)==1 && p=='E')
 		{sub_uses_time=1; return 8;}
+	if (strstr (line, "-->>"))
+		{sub_uses_time=0; return 9;}
     }
 
     return -1;  // too many bad lines
@@ -530,7 +575,9 @@
 	    sub_read_line_rt,
 	    sub_read_line_ssa,
 	    sub_read_line_dunnowhat,
-	    sub_read_line_mpsub
+	    sub_read_line_mpsub,
+	    sub_read_line_aqt
+
     };
 
     fd=fopen (filename, "r"); if (!fd) return NULL;
@@ -612,7 +659,9 @@
     ".txt",
     ".TXT",
     ".ssa",
-    ".SSA"};
+    ".SSA",
+    ".aqt",
+    ".AQT"};
 
 
  if ( fname == NULL ) return NULL;