Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FFmpeg/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClément Bœsch <u@pkh.me>2013-09-08 20:05:11 +0400
committerClément Bœsch <u@pkh.me>2013-09-08 20:48:35 +0400
commit378a830e7b9a5e023c2f7eece6d7260016dfd13b (patch)
tree6cc7101ac85ea5d7de3974176ff7d12b05ea1ee8 /libavformat/subtitles.h
parent90fc00a623de44e137fe1601b91356e8cd8bdd54 (diff)
avformat/subtitles: support standalone CR (MacOS).
Recent .srt files with CR only were found in the wild.
Diffstat (limited to 'libavformat/subtitles.h')
-rw-r--r--libavformat/subtitles.h13
1 files changed, 11 insertions, 2 deletions
diff --git a/libavformat/subtitles.h b/libavformat/subtitles.h
index 96de9fa5d4..eced380ff2 100644
--- a/libavformat/subtitles.h
+++ b/libavformat/subtitles.h
@@ -99,11 +99,20 @@ void ff_subtitles_read_chunk(AVIOContext *pb, AVBPrint *buf);
/**
* Get the number of characters to increment to jump to the next line, or to
* the end of the string.
+ * The function handles the following line breaks schemes: LF (any sane
+ * system), CRLF (MS), or standalone CR (old MacOS).
*/
static av_always_inline int ff_subtitles_next_line(const char *ptr)
{
- int n = strcspn(ptr, "\n");
- return n + !!*ptr;
+ int n = strcspn(ptr, "\r\n");
+ ptr += n;
+ if (*ptr == '\r') {
+ ptr++;
+ n++;
+ }
+ if (*ptr == '\n')
+ n++;
+ return n;
}
#endif /* AVFORMAT_SUBTITLES_H */