Skip to content
Permalink
Browse files

[coreSubtitles] Accept period as decimal separator in SRT, don't drop…

… the last subtitle on conversion to SSA when followed by EOF instead of an empty line
  • Loading branch information...
eumagga0x2a committed Jan 8, 2019
1 parent 3b9fd40 commit 1872ec3c3d42b0593c895cb60fd9ab77ad176548
Showing with 10 additions and 7 deletions.
  1. +10 −7 avidemux_core/ADM_coreSubtitles/src/ADM_subLoader.cpp
@@ -66,7 +66,11 @@ static bool splitSrtTiming(const char *str,uint64_t &start,uint64_t &end )
int n=sscanf(str,"%d:%d:%d,%d --> %d:%d:%d,%d",&h1,&m1,&s1,&ms1,&h2,&m2,&s2,&ms2);
if(n!=8)
{
return false;
n=sscanf(str,"%d:%d:%d.%d --> %d:%d:%d.%d",&h1,&m1,&s1,&ms1,&h2,&m2,&s2,&ms2);
if(n==8)
ADM_warning("Wrong decimal separator in .srt file, should be comma, not period.\n");
else
return false;
}
start=split2us(h1,m1,s1,ms1);
end=split2us(h2,m2,s2,ms2);
@@ -117,6 +121,8 @@ bool loadSrt(const char *file,ListOfSubtitleLines &lines)
{
if(!fgets(buffer,1023,fd))
{
if(entry.texts.size())
lines.push_back(entry);
break;
}
int length=strlen(buffer);
@@ -125,14 +131,11 @@ bool loadSrt(const char *file,ListOfSubtitleLines &lines)
while((*p=='\n' || *p=='\r')&& (p>buffer)) p--;
p[1]=0;
length=strlen(buffer);

int lineno;
printf("%d\n",state);
// printf("%d\n",state);
switch(state)
{
case STATE_LINENO:
if(!length) continue;
lineno=atoi(buffer);
state=STATE_TIMING;
break;
case STATE_TIMING:
@@ -160,8 +163,8 @@ bool loadSrt(const char *file,ListOfSubtitleLines &lines)
lines.push_back(entry);
entry.texts.clear();
state=STATE_LINENO;
break;
}

entry.texts.push_back(std::string(buffer));
break;
case STATE_IDLE: break;
@@ -172,4 +175,4 @@ bool loadSrt(const char *file,ListOfSubtitleLines &lines)
//updateSrtTiming(lines);
return true;
}
}
}

0 comments on commit 1872ec3

Please sign in to comment.
You can’t perform that action at this time.