summaryrefslogtreecommitdiff
path: root/libavformat/subtitles.c
diff options
context:
space:
mode:
authorClément Bœsch <u@pkh.me>2013-09-08 18:05:11 +0200
committerClément Bœsch <u@pkh.me>2013-09-08 18:48:35 +0200
commit378a830e7b9a5e023c2f7eece6d7260016dfd13b (patch)
tree6cc7101ac85ea5d7de3974176ff7d12b05ea1ee8 /libavformat/subtitles.c
parent90fc00a623de44e137fe1601b91356e8cd8bdd54 (diff)
avformat/subtitles: support standalone CR (MacOS).
Recent .srt files with CR only were found in the wild.
Diffstat (limited to 'libavformat/subtitles.c')
-rw-r--r--libavformat/subtitles.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/libavformat/subtitles.c b/libavformat/subtitles.c
index d4607970ac..6c9e72ba75 100644
--- a/libavformat/subtitles.c
+++ b/libavformat/subtitles.c
@@ -228,7 +228,7 @@ static inline int is_eol(char c)
void ff_subtitles_read_chunk(AVIOContext *pb, AVBPrint *buf)
{
- char eol_buf[5];
+ char eol_buf[5], last_was_cr = 0;
int n = 0, i = 0, nb_eol = 0;
av_bprint_clear(buf);
@@ -245,12 +245,13 @@ void ff_subtitles_read_chunk(AVIOContext *pb, AVBPrint *buf)
/* line break buffering: we don't want to add the trailing \r\n */
if (is_eol(c)) {
- nb_eol += c == '\n';
+ nb_eol += c == '\n' || last_was_cr;
if (nb_eol == 2)
break;
eol_buf[i++] = c;
if (i == sizeof(eol_buf) - 1)
break;
+ last_was_cr = c == '\r';
continue;
}