Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FFmpeg/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClément Bœsch <u@pkh.me>2016-01-06 15:43:23 +0300
committerClément Bœsch <u@pkh.me>2016-02-26 23:49:34 +0300
commit29412821241050c846dbceaad4b9752857659977 (patch)
treeeb42444a7a6bf5d2dc66cdec8c7aa26be32bed99 /libavcodec/textdec.c
parent805685fffd3115d3f9260d8df15ef36b6b3b8006 (diff)
lavc: allow subtitle text format to be ASS without timing
Diffstat (limited to 'libavcodec/textdec.c')
-rw-r--r--libavcodec/textdec.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/libavcodec/textdec.c b/libavcodec/textdec.c
index a6c8722c1d..4e2ff2c144 100644
--- a/libavcodec/textdec.c
+++ b/libavcodec/textdec.c
@@ -32,6 +32,7 @@ typedef struct {
AVClass *class;
const char *linebreaks;
int keep_ass_markup;
+ int readorder;
} TextContext;
#define OFFSET(x) offsetof(TextContext, x)
@@ -48,15 +49,12 @@ static int text_decode_frame(AVCodecContext *avctx, void *data,
AVBPrint buf;
AVSubtitle *sub = data;
const char *ptr = avpkt->data;
- const TextContext *text = avctx->priv_data;
- const int ts_start = av_rescale_q(avpkt->pts, avctx->time_base, (AVRational){1,100});
- const int ts_duration = avpkt->duration != -1 ?
- av_rescale_q(avpkt->duration, avctx->time_base, (AVRational){1,100}) : -1;
+ TextContext *text = avctx->priv_data;
av_bprint_init(&buf, 0, AV_BPRINT_SIZE_UNLIMITED);
if (ptr && avpkt->size > 0 && *ptr) {
ff_ass_bprint_text_event(&buf, ptr, avpkt->size, text->linebreaks, text->keep_ass_markup);
- ret = ff_ass_add_rect_bprint(sub, &buf, ts_start, ts_duration);
+ ret = ff_ass_add_rect(sub, buf.str, text->readorder++, 0, NULL, NULL);
}
av_bprint_finalize(&buf, NULL);
if (ret < 0)
@@ -65,6 +63,12 @@ static int text_decode_frame(AVCodecContext *avctx, void *data,
return avpkt->size;
}
+static void text_flush(AVCodecContext *avctx)
+{
+ TextContext *text = avctx->priv_data;
+ text->readorder = 0;
+}
+
#define DECLARE_CLASS(decname) static const AVClass decname ## _decoder_class = { \
.class_name = #decname " decoder", \
.item_name = av_default_item_name, \
@@ -85,6 +89,7 @@ AVCodec ff_text_decoder = {
.decode = text_decode_frame,
.init = ff_ass_subtitle_header_default,
.priv_class = &text_decoder_class,
+ .flush = text_flush,
};
#endif
@@ -110,6 +115,7 @@ AVCodec ff_vplayer_decoder = {
.decode = text_decode_frame,
.init = linebreak_init,
.priv_class = &vplayer_decoder_class,
+ .flush = text_flush,
};
#endif
@@ -126,6 +132,7 @@ AVCodec ff_stl_decoder = {
.decode = text_decode_frame,
.init = linebreak_init,
.priv_class = &stl_decoder_class,
+ .flush = text_flush,
};
#endif
@@ -142,6 +149,7 @@ AVCodec ff_pjs_decoder = {
.decode = text_decode_frame,
.init = linebreak_init,
.priv_class = &pjs_decoder_class,
+ .flush = text_flush,
};
#endif
@@ -158,6 +166,7 @@ AVCodec ff_subviewer1_decoder = {
.decode = text_decode_frame,
.init = linebreak_init,
.priv_class = &subviewer1_decoder_class,
+ .flush = text_flush,
};
#endif