mirror of
https://github.com/mpv-player/mpv
synced 2025-03-23 00:14:24 +01:00
patch fixes broken detecniou of AQTitle subtiles and adds support for subtitles created by subrip 0.9 - by Jiri.Svoboda@seznam.cz
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@6077 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
parent
a6199c8388
commit
6fe43d0d87
67
subreader.c
67
subreader.c
@ -470,6 +470,8 @@ subtitle *previous_aqt_sub = NULL;
|
|||||||
|
|
||||||
subtitle *sub_read_line_aqt(FILE *fd,subtitle *current) {
|
subtitle *sub_read_line_aqt(FILE *fd,subtitle *current) {
|
||||||
char line[LINE_LEN+1];
|
char line[LINE_LEN+1];
|
||||||
|
char *next;
|
||||||
|
int i;
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
// try to locate next subtitle
|
// try to locate next subtitle
|
||||||
@ -494,8 +496,13 @@ subtitle *sub_read_line_aqt(FILE *fd,subtitle *current) {
|
|||||||
if (!fgets (line, LINE_LEN, fd))
|
if (!fgets (line, LINE_LEN, fd))
|
||||||
return current;;
|
return current;;
|
||||||
|
|
||||||
sub_readtext((char *) &line,¤t->text[1]);
|
next = line,i=1;
|
||||||
current->lines = 2;
|
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]=="")) {
|
if ((current->text[0]=="") && (current->text[1]=="")) {
|
||||||
// void subtitle -> end of previous marked and exit
|
// void subtitle -> end of previous marked and exit
|
||||||
@ -506,6 +513,53 @@ subtitle *sub_read_line_aqt(FILE *fd,subtitle *current) {
|
|||||||
return current;
|
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) {
|
int sub_autodetect (FILE *fd) {
|
||||||
char line[LINE_LEN+1];
|
char line[LINE_LEN+1];
|
||||||
int i,j=0;
|
int i,j=0;
|
||||||
@ -548,7 +602,9 @@ int sub_autodetect (FILE *fd) {
|
|||||||
if (sscanf (line, "FORMAT=TIM%c", &p)==1 && p=='E')
|
if (sscanf (line, "FORMAT=TIM%c", &p)==1 && p=='E')
|
||||||
{sub_uses_time=1; return SUB_MPSUB;}
|
{sub_uses_time=1; return SUB_MPSUB;}
|
||||||
if (strstr (line, "-->>"))
|
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
|
return SUB_INVALID; // too many bad lines
|
||||||
@ -661,7 +717,7 @@ subtitle* sub_read_file (char *filename, float fps) {
|
|||||||
int n_max;
|
int n_max;
|
||||||
subtitle *first;
|
subtitle *first;
|
||||||
char *fmtname[] = { "microdvd", "subrip", "subviewer", "sami", "vplayer",
|
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)=
|
subtitle * (*func[])(FILE *fd,subtitle *dest)=
|
||||||
{
|
{
|
||||||
sub_read_line_microdvd,
|
sub_read_line_microdvd,
|
||||||
@ -674,7 +730,8 @@ subtitle* sub_read_file (char *filename, float fps) {
|
|||||||
sub_read_line_dunnowhat,
|
sub_read_line_dunnowhat,
|
||||||
sub_read_line_mpsub,
|
sub_read_line_mpsub,
|
||||||
sub_read_line_aqt,
|
sub_read_line_aqt,
|
||||||
sub_read_line_subviewer2
|
sub_read_line_subviewer2,
|
||||||
|
sub_read_line_subrip09
|
||||||
|
|
||||||
};
|
};
|
||||||
if(filename==NULL) return NULL; //qnx segfault
|
if(filename==NULL) return NULL; //qnx segfault
|
||||||
|
@ -18,6 +18,7 @@ extern int sub_num; // number of subtitle structs
|
|||||||
#define SUB_MPSUB 8
|
#define SUB_MPSUB 8
|
||||||
#define SUB_AQTITLE 9
|
#define SUB_AQTITLE 9
|
||||||
#define SUB_SUBVIEWER2 10
|
#define SUB_SUBVIEWER2 10
|
||||||
|
#define SUB_SUBRIP09 11
|
||||||
|
|
||||||
// One of the SUB_* constant above
|
// One of the SUB_* constant above
|
||||||
extern int sub_format;
|
extern int sub_format;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user