Oops, forgot to actually attach the patch
From fccc13f728c50a676d20f3ca5b822fa1da60b259 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tomas=20H=C3=A4rdin?= <g...@haerdin.se>
Date: Thu, 28 Mar 2024 20:30:37 +0100
Subject: [PATCH 1/3] lavf/subtitles: Do not eat \n\n

---
 libavformat/subtitles.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/libavformat/subtitles.c b/libavformat/subtitles.c
index 3413763c7b..bda549abd0 100644
--- a/libavformat/subtitles.c
+++ b/libavformat/subtitles.c
@@ -446,11 +446,12 @@ int ff_subtitles_read_chunk(AVIOContext *pb, AVBPrint *buf)
 ptrdiff_t ff_subtitles_read_line(FFTextReader *tr, char *buf, size_t size)
 {
     size_t cur = 0;
+    unsigned char c;
     if (!size)
         return 0;
     buf[0] = '\0';
     while (cur + 1 < size) {
-        unsigned char c = ff_text_r8(tr);
+        c = ff_text_r8(tr);
         if (!c)
             return ff_text_eof(tr) ? cur : AVERROR_INVALIDDATA;
         if (c == '\r' || c == '\n')
@@ -458,9 +459,13 @@ ptrdiff_t ff_subtitles_read_line(FFTextReader *tr, char *buf, size_t size)
         buf[cur++] = c;
         buf[cur] = '\0';
     }
-    while (ff_text_peek_r8(tr) == '\r')
-        ff_text_r8(tr);
-    if (ff_text_peek_r8(tr) == '\n')
-        ff_text_r8(tr);
+    // don't eat \n\n
+    if (c == '\r') {
+        // sub/ticket5032-rrn.srt has \r\r\n
+        while (ff_text_peek_r8(tr) == '\r')
+            ff_text_r8(tr);
+        if (ff_text_peek_r8(tr) == '\n')
+            ff_text_r8(tr);
+    }
     return cur;
 }
-- 
2.39.2

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Reply via email to