Re: [FFmpeg-devel] [PATCH 11/12] lavf/sccdec: fix timestamps and demux one eai608 frame at a time

2019-06-27 Thread Paul B Mahol
On 11/25/18, Paul B Mahol  wrote:
> On 7/4/18, Baptiste Coudurier  wrote:
>> ---
>>  libavformat/sccdec.c | 100 ---
>>  1 file changed, 56 insertions(+), 44 deletions(-)
>>
>
> Will those scc patches be applied?
>

This one breaks FATE.
Forcing positive first timestamp drops initial captions.
___
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".

Re: [FFmpeg-devel] [PATCH 11/12] lavf/sccdec: fix timestamps and demux one eai608 frame at a time

2018-11-25 Thread Paul B Mahol
On 7/4/18, Baptiste Coudurier  wrote:
> ---
>  libavformat/sccdec.c | 100 ---
>  1 file changed, 56 insertions(+), 44 deletions(-)
>

Will those scc patches be applied?
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH 11/12] lavf/sccdec: fix timestamps and demux one eai608 frame at a time

2018-07-04 Thread Baptiste Coudurier
---
 libavformat/sccdec.c | 100 ---
 1 file changed, 56 insertions(+), 44 deletions(-)

diff --git a/libavformat/sccdec.c b/libavformat/sccdec.c
index 89d21b9c1f..0472b4e031 100644
--- a/libavformat/sccdec.c
+++ b/libavformat/sccdec.c
@@ -24,9 +24,14 @@
 #include "subtitles.h"
 #include "libavutil/bprint.h"
 #include "libavutil/intreadwrite.h"
+#include "libavutil/timecode.h"
+#include "libavutil/opt.h"
 
 typedef struct SCCContext {
+AVClass *av_class;
 FFDemuxSubtitlesQueue q;
+AVTimecode initial_tc;
+char *timecode_start;
 } SCCContext;
 
 static int scc_probe(AVProbeData *p)
@@ -62,57 +67,53 @@ static int scc_read_header(AVFormatContext *s)
 {
 SCCContext *scc = s->priv_data;
 AVStream *st = avformat_new_stream(s, NULL);
-char line[4096], line2[4096];
-int count = 0, ret = 0;
-ptrdiff_t len2, len;
-uint8_t out[4096];
+char line[4096];
+int ret = 0;
+ptrdiff_t len;
 FFTextReader tr;
+const AVRational frame_rate = {3,1001};
 
 ff_text_init_avio(s, , s->pb);
 
 if (!st)
 return AVERROR(ENOMEM);
-avpriv_set_pts_info(st, 64, 1, 1000);
+avpriv_set_pts_info(st, 64, 1001, 3);
 st->codecpar->codec_type = AVMEDIA_TYPE_SUBTITLE;
 st->codecpar->codec_id   = AV_CODEC_ID_EIA_608;
 
+if (av_timecode_init_from_string(>initial_tc,
+ (AVRational){3, 1001},
+ scc->timecode_start, s) < 0)
+return -1;
+
+while (!ff_text_eof()) {
+len = ff_subtitles_read_line(, line, sizeof(line));
+if (!strncmp(line, "Scenarist_SCC V1.0", 18))
+break;
+}
+
 while (!ff_text_eof()) {
 const int64_t pos = ff_text_pos();
 char *saveptr = NULL, *lline;
-int hh1, mm1, ss1, fs1, i;
-int hh2, mm2, ss2, fs2;
-int64_t ts_start, ts_end;
+AVTimecode tc_start;
+int i;
 AVPacket *sub;
-
-if (count == 0) {
-while (!ff_text_eof()) {
-len = ff_subtitles_read_line(, line, sizeof(line));
-if (len > 13)
-break;
-}
-}
-
-if (!strncmp(line, "Scenarist_SCC V1.0", 18))
-continue;
-if (sscanf(line, "%d:%d:%d%*[:;]%d", , , , ) != 4)
-continue;
-
-ts_start = (hh1 * 3600LL + mm1 * 60LL + ss1) * 1000LL + fs1 * 33;
+char out[4];
 
 while (!ff_text_eof()) {
-len2 = ff_subtitles_read_line(, line2, sizeof(line2));
-if (len2 > 13)
+len = ff_subtitles_read_line(, line, sizeof(line));
+if (len > 13)
 break;
 }
-if (sscanf(line2, "%d:%d:%d%*[:;]%d", , , , ) != 4)
-continue;
 
-ts_end = (hh2 * 3600LL + mm2 * 60LL + ss2) * 1000LL + fs2 * 33;
-count++;
+if (av_timecode_init_from_string(_start, frame_rate, line, s) < 0)
+continue;
 
 lline = (char *)
 lline += 12;
 
+out[3] = 0;
+
 for (i = 0; i < 4095; i += 3) {
 char *ptr = av_strtok(lline, " ", );
 char c1, c2, c3, c4;
@@ -124,21 +125,17 @@ static int scc_read_header(AVFormatContext *s)
 break;
 
 lline = NULL;
-out[i+0] = 0xfc;
-out[i+1] = convert(c2) | (convert(c1) << 4);
-out[i+2] = convert(c4) | (convert(c3) << 4);
+out[0] = 0xfc;
+out[1] = convert(c2) | (convert(c1) << 4);
+out[2] = convert(c4) | (convert(c3) << 4);
+
+sub = ff_subtitles_queue_insert(>q, out, 3, 0);
+if (!sub)
+return AVERROR(ENOMEM);
+sub->pos = pos + i * 3;
+sub->pts = tc_start.start + i / 3;
+sub->duration = 1;
 }
-out[i] = 0;
-
-sub = ff_subtitles_queue_insert(>q, out, i, 0);
-if (!sub)
-return AVERROR(ENOMEM);
-
-sub->pos = pos;
-sub->pts = ts_start;
-sub->duration = FFMAX(1200, ts_end - ts_start);
-memmove(line, line2, sizeof(line));
-FFSWAP(ptrdiff_t, len, len2);
 }
 
 ff_subtitles_queue_finalize(s, >q);
@@ -149,7 +146,8 @@ static int scc_read_header(AVFormatContext *s)
 static int scc_read_packet(AVFormatContext *s, AVPacket *pkt)
 {
 SCCContext *scc = s->priv_data;
-return ff_subtitles_queue_read_packet(>q, pkt);
+int ret = ff_subtitles_queue_read_packet(>q, pkt);
+return ret;
 }
 
 static int scc_read_seek(AVFormatContext *s, int stream_index,
@@ -167,6 +165,19 @@ static int scc_read_close(AVFormatContext *s)
 return 0;
 }
 
+static const AVOption scc_options[] = {
+{ "timecode_start", "Set the SCC file initial timecode, to adjust 
timestamps",
+  offsetof(SCCContext, timecode_start), AV_OPT_TYPE_STRING, {.str = 
"00:00:00;00"}, CHAR_MIN, CHAR_MAX, AV_OPT_FLAG_ENCODING_PARAM},
+{ NULL },
+};