[FFmpeg-cvslog] avformat/lrcenc: Unify writing timestamps
Andreas Rheinhardt
git at videolan.org
Thu Oct 7 13:06:08 EEST 2021
ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at outlook.com> | Fri Oct 1 22:41:49 2021 +0200| [14baf4cd92062994931044d919f63587aaaa4cdd] | committer: Andreas Rheinhardt
avformat/lrcenc: Unify writing timestamps
Reviewed-by: Paul B Mahol <onemda at gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=14baf4cd92062994931044d919f63587aaaa4cdd
---
libavformat/lrcenc.c | 21 ++++++++-------------
1 file changed, 8 insertions(+), 13 deletions(-)
diff --git a/libavformat/lrcenc.c b/libavformat/lrcenc.c
index 78d9c6d362..5703a95180 100644
--- a/libavformat/lrcenc.c
+++ b/libavformat/lrcenc.c
@@ -109,19 +109,14 @@ static int lrc_write_packet(AVFormatContext *s, AVPacket *pkt)
"Subtitle starts with '[', may cause problems with LRC format.\n");
}
- if(pkt->pts >= 0) {
- avio_printf(s->pb, "[%02"PRId64":%02"PRId64".%02"PRId64"]",
- (pkt->pts / 6000),
- ((pkt->pts / 100) % 60),
- (pkt->pts % 100));
- } else {
- /* Offset feature of LRC can easily make pts negative,
- * we just output it directly and let the player drop it. */
- avio_printf(s->pb, "[-%02"PRId64":%02"PRId64".%02"PRId64"]",
- (-pkt->pts) / 6000,
- ((-pkt->pts) / 100) % 60,
- (-pkt->pts) % 100);
- }
+ /* Offset feature of LRC can easily make pts negative,
+ * we just output it directly and let the player drop it. */
+ avio_write(s->pb, "[-", 1 + (pkt->pts < 0));
+ avio_printf(s->pb, "%02"PRIu64":%02"PRIu64".%02"PRIu64"]",
+ (FFABS64U(pkt->pts) / 6000),
+ ((FFABS64U(pkt->pts) / 100) % 60),
+ (FFABS64U(pkt->pts) % 100));
+
avio_write(s->pb, line, size);
avio_w8(s->pb, '\n');
line = next_line;
More information about the ffmpeg-cvslog
mailing list