Skip to content

Commit

Permalink
[coreSubtitles] Accept period as decimal separator in SRT, don't drop…
Browse files Browse the repository at this point in the history
… 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 1872ec3
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions avidemux_core/ADM_coreSubtitles/src/ADM_subLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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:
Expand Down Expand Up @@ -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;
Expand All @@ -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.