summaryrefslogtreecommitdiffstats
path: root/subreader.c
diff options
context:
space:
mode:
authoralex <alex@b3059339-0415-0410-9bf9-f77b7e298cf2>2004-04-06 11:52:31 +0000
committeralex <alex@b3059339-0415-0410-9bf9-f77b7e298cf2>2004-04-06 11:52:31 +0000
commit928e11d1f1e19a08b976b29b97e52798fa78cc2b (patch)
tree2515609f22b4354ffafacdd5ffed967fd3d46ab0 /subreader.c
parent3ab4de18b0fb555e5732124871c138902eef6dba (diff)
downloadmpv-928e11d1f1e19a08b976b29b97e52798fa78cc2b.tar.bz2
mpv-928e11d1f1e19a08b976b29b97e52798fa78cc2b.tar.xz
MPL2 subreader, patch by Cezary Jackiewicz (cjackiewicz@poczta.onet.pl)
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@12139 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'subreader.c')
-rw-r--r--subreader.c31
1 files changed, 30 insertions, 1 deletions
diff --git a/subreader.c b/subreader.c
index e245de86b5..430cd66dae 100644
--- a/subreader.c
+++ b/subreader.c
@@ -248,6 +248,32 @@ subtitle *sub_read_line_microdvd(FILE *fd,subtitle *current) {
return current;
}
+subtitle *sub_read_line_mpl2(FILE *fd,subtitle *current) {
+ char line[LINE_LEN+1];
+ char line2[LINE_LEN+1];
+ char *p, *next;
+ int i;
+
+ do {
+ if (!fgets (line, LINE_LEN, fd)) return NULL;
+ } while ((sscanf (line,
+ "[%ld][%ld]%[^\r\n]",
+ &(current->start), &(current->end), line2) < 3));
+ current->start *= 10;
+ current->end *= 10;
+ p=line2;
+
+ 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) { mp_msg(MSGT_SUBREADER,MSGL_WARN,"Too many lines in a subtitle\n");current->lines=i;return current;}
+ }
+ current->lines= ++i;
+
+ return current;
+}
+
subtitle *sub_read_line_subrip(FILE *fd, subtitle *current) {
char line[LINE_LEN+1];
int a1,a2,a3,a4,b1,b2,b3,b4;
@@ -954,6 +980,8 @@ int sub_autodetect (FILE *fd, int *uses_time) {
{*uses_time=0;return SUB_MICRODVD;}
if (sscanf (line, "{%d}{}", &i)==1)
{*uses_time=0;return SUB_MICRODVD;}
+ if (sscanf (line, "[%d][%d]", &i, &i)==2)
+ {*uses_time=1;return SUB_MPL2;}
if (sscanf (line, "%d:%d:%d.%d,%d:%d:%d.%d", &i, &i, &i, &i, &i, &i, &i, &i)==8)
{*uses_time=1;return SUB_SUBRIP;}
if (sscanf (line, "%d:%d:%d%[,.:]%d --> %d:%d:%d%[,.:]%d", &i, &i, &i, (char *)&i, &i, &i, &i, &i, (char *)&i, &i)==10)
@@ -1239,7 +1267,8 @@ sub_data* sub_read_file (char *filename, float fps) {
{ sub_read_line_aqt, NULL, "aqt" },
{ sub_read_line_subviewer2, NULL, "subviewer 2.0" },
{ sub_read_line_subrip09, NULL, "subrip 0.9" },
- { sub_read_line_jacosub, NULL, "jacosub" }
+ { sub_read_line_jacosub, NULL, "jacosub" },
+ { sub_read_line_mpl2, NULL, "mpl2" }
};
struct subreader *srp;