于 2014年07月09日 22:24, Derek Buitenhuis 写道:
+/*
+ * LRC lyrics file format decoder
+ * Copyright (c) 2014 StarBrilliant <m13...@hotmail.com>

For copyright purposes we generally use real names.

Thank you for your reminder.
But I consider my real name piracy.
If this really causes trouble to FFmpeg team, I will change it.

+#include "libavcodec/internal.h"

Ew. What are you using from this?

I copied this line from assdec.c, I used to think it is useful.
Removing it is okay.

+#include "libavutil/bprint.h"
+#include "libavutil/dict.h"
+
+typedef struct LRCContext {
+    FFDemuxSubtitlesQueue q;
+    int ts_offset;

Is int enough for a timestamp difference?

bprint is used for string and buffer manipulation. Again this #include is adapted from assdec.c.

timestamp difference is far from enough, since LRC comes with arbitrary line order. Another reason is repeated line feature. LRC can have single line that is sung multiple times assigned with different timestamps.
This is why I use FFDemuxSubtitlesQueue to sort those lines.

ts_offset is a metadata item. By specifying "offset" in metadata, the whole lyrics would shift in timestamps to get sync with different versions of music. My implementation does offset shifting on demuxing. So I have to keep a ts_offset member.

+        *start = -(mm*60000LL + ss*1000LL + cs*10LL); // just in case negative 
pts

Why are you mangling the timestamps? Negative timestamps are technically valid.

Negative timestamps are not effective in real LRCs. However, with the feature called "offset" mentioned just above. A normal timestamp can easily become negative. Since most players ignore uneffective lines (LRC has no official spec, it is a de-facto standard). So I will let the players drop those negative timestamps, instead of losing data at FFmpeg layer.


Finally, I attached an incremental patch, fixing an #include issue and a mistype.
>From 09ec0f4f8d26a6da760694bc35f6530952915933 Mon Sep 17 00:00:00 2001
From: Star Brilliant <m13...@hotmail.com>
Date: Wed, 9 Jul 2014 22:52:12 +0800
Subject: [PATCH] AVFormat: LRC demuxer and muxer

---
 libavformat/lrcdec.c | 3 +--
 libavformat/lrcenc.c | 1 -
 2 files changed, 1 insertion(+), 3 deletions(-)

diff --git a/libavformat/lrcdec.c b/libavformat/lrcdec.c
index 49bdd13..373c2ac 100644
--- a/libavformat/lrcdec.c
+++ b/libavformat/lrcdec.c
@@ -27,7 +27,6 @@
 #include "lrc.h"
 #include "metadata.h"
 #include "subtitles.h"
-#include "libavcodec/internal.h"
 #include "libavutil/bprint.h"
 #include "libavutil/dict.h"
 
@@ -195,7 +194,7 @@ static int lrc_read_header(AVFormatContext *s)
                     return AVERROR(ENOMEM);
                 }
                 sub->pos = pos;
-                sub->pts = ts_start + lrc->ts_offset*1LL;
+                sub->pts = ts_start - lrc->ts_offset*1LL;
                 sub->duration = -1;
             }
         }
diff --git a/libavformat/lrcenc.c b/libavformat/lrcenc.c
index b874b77..6fae053 100644
--- a/libavformat/lrcenc.c
+++ b/libavformat/lrcenc.c
@@ -28,7 +28,6 @@
 #include "metadata.h"
 #include "subtitles.h"
 #include "version.h"
-#include "libavcodec/internal.h"
 #include "libavutil/bprint.h"
 #include "libavutil/dict.h"
 #include "libavutil/log.h"
-- 
2.0.1

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

Reply via email to