summaryrefslogtreecommitdiff
path: root/libavcodec/movtextdec.c
diff options
context:
space:
mode:
authorClément Bœsch <u@pkh.me>2016-01-06 13:43:23 +0100
committerClément Bœsch <u@pkh.me>2016-02-26 21:49:34 +0100
commit29412821241050c846dbceaad4b9752857659977 (patch)
treeeb42444a7a6bf5d2dc66cdec8c7aa26be32bed99 /libavcodec/movtextdec.c
parent805685fffd3115d3f9260d8df15ef36b6b3b8006 (diff)
lavc: allow subtitle text format to be ASS without timing
Diffstat (limited to 'libavcodec/movtextdec.c')
-rw-r--r--libavcodec/movtextdec.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/libavcodec/movtextdec.c b/libavcodec/movtextdec.c
index 8d0e8141d3..fa70497439 100644
--- a/libavcodec/movtextdec.c
+++ b/libavcodec/movtextdec.c
@@ -99,6 +99,7 @@ typedef struct {
uint64_t tracksize;
int size_var;
int count_s, count_f;
+ int readorder;
} MovTextContext;
typedef struct {
@@ -424,7 +425,7 @@ static int mov_text_decode_frame(AVCodecContext *avctx,
{
AVSubtitle *sub = data;
MovTextContext *m = avctx->priv_data;
- int ret, ts_start, ts_end;
+ int ret;
AVBPrint buf;
char *ptr = avpkt->data;
char *end;
@@ -454,13 +455,6 @@ static int mov_text_decode_frame(AVCodecContext *avctx,
end = ptr + FFMIN(2 + text_length, avpkt->size);
ptr += 2;
- ts_start = av_rescale_q(avpkt->pts,
- avctx->time_base,
- (AVRational){1,100});
- ts_end = av_rescale_q(avpkt->pts + avpkt->duration,
- avctx->time_base,
- (AVRational){1,100});
-
tsmb_size = 0;
m->tracksize = 2 + text_length;
m->style_entries = 0;
@@ -506,7 +500,7 @@ static int mov_text_decode_frame(AVCodecContext *avctx,
} else
text_to_ass(&buf, ptr, end, m);
- ret = ff_ass_add_rect_bprint(sub, &buf, ts_start, ts_end - ts_start);
+ ret = ff_ass_add_rect(sub, buf.str, m->readorder++, 0, NULL, NULL);
av_bprint_finalize(&buf, NULL);
if (ret < 0)
return ret;
@@ -521,6 +515,12 @@ static int mov_text_decode_close(AVCodecContext *avctx)
return 0;
}
+static void mov_text_flush(AVCodecContext *avctx)
+{
+ MovTextContext *m = avctx->priv_data;
+ m->readorder = 0;
+}
+
AVCodec ff_movtext_decoder = {
.name = "mov_text",
.long_name = NULL_IF_CONFIG_SMALL("3GPP Timed Text subtitle"),
@@ -530,4 +530,5 @@ AVCodec ff_movtext_decoder = {
.init = mov_text_init,
.decode = mov_text_decode_frame,
.close = mov_text_decode_close,
+ .flush = mov_text_flush,
};