Current function count_ts will count invalid timestamp formats like [00:00:00] [00-00-00] or [00:00.00][[[00:00.00]]] as valid timestamp. This could cause some subtitles would be incorrectly counted as timestamp. Fix it by using function read_ts to check valid timestamp and get the offset.
Fixes trac #7255. Signed-off-by: Zhao, Gang <gang.zhao...@gmail.com> --- libavformat/lrcdec.c | 38 +++++++++++++------------------------- 1 file changed, 13 insertions(+), 25 deletions(-) diff --git libavformat/lrcdec.c libavformat/lrcdec.c index a9a117691a..3b206cf079 100644 --- libavformat/lrcdec.c +++ libavformat/lrcdec.c @@ -49,31 +49,6 @@ static int64_t find_header(const char *p) } } -static int64_t count_ts(const char *p) -{ - int64_t offset = 0; - int in_brackets = 0; - - for(;;) { - if(p[offset] == ' ' || p[offset] == '\t') { - offset++; - } else if(p[offset] == '[') { - offset++; - in_brackets++; - } else if (p[offset] == ']' && in_brackets) { - offset++; - in_brackets--; - } else if(in_brackets && - (p[offset] == ':' || p[offset] == '.' || p[offset] == '-' || - (p[offset] >= '0' && p[offset] <= '9'))) { - offset++; - } else { - break; - } - } - return offset; -} - static int64_t read_ts(const char *p, int64_t *start) { int64_t offset = 0; @@ -99,6 +74,19 @@ static int64_t read_ts(const char *p, int64_t *start) return offset; } +static int64_t count_ts(const char *p) +{ + int64_t total_offset = 0; + int64_t offset, start; + + while ((offset = read_ts(p, &start)) != 0) { + total_offset += offset; + p += offset; + } + + return total_offset; +} + static int64_t read_line(AVBPrint *buf, AVIOContext *pb) { int64_t pos = avio_tell(pb); -- 2.17.1 _______________________________________________ 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".