diff mbox series

[FFmpeg-devel,19/20] avformat/lrcenc: Unify writing timestamps

Message ID AM7PR03MB6660B4F64B5AF2A5FAAE864D8FAB9@AM7PR03MB6660.eurprd03.prod.outlook.com
State Accepted
Commit 14baf4cd92062994931044d919f63587aaaa4cdd
Headers show
Series [FFmpeg-devel,01/20] libpostproc/postprocess_template: Don't reimplement FFSWAP | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished
andriy/make_ppc success Make finished
andriy/make_fate_ppc success Make fate finished

Commit Message

Andreas Rheinhardt Oct. 1, 2021, 9:08 p.m. UTC
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavformat/lrcenc.c | 21 ++++++++-------------
 1 file changed, 8 insertions(+), 13 deletions(-)

Comments

Paul B Mahol Oct. 2, 2021, 3:03 p.m. UTC | #1
probably ok
diff mbox series

Patch

diff --git a/libavformat/lrcenc.c b/libavformat/lrcenc.c
index 21cb3860ab..4fa14ea427 100644
--- a/libavformat/lrcenc.c
+++ b/libavformat/lrcenc.c
@@ -111,19 +111,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;