]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/subtitles.h
Merge commit '459f2b393a3f89ed08d10fbceb4738d1429f268e'
[ffmpeg] / libavformat / subtitles.h
index 455b374f259a35987a10bc11ccf18a72057a872d..eced380ff25f3f9d3f5dc4da377389c200612959 100644 (file)
@@ -96,4 +96,23 @@ const char *ff_smil_get_attr_ptr(const char *s, const char *attr);
  */
 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, "\r\n");
+    ptr += n;
+    if (*ptr == '\r') {
+        ptr++;
+        n++;
+    }
+    if (*ptr == '\n')
+        n++;
+    return n;
+}
+
 #endif /* AVFORMAT_SUBTITLES_H */