diff options
author | Clément Bœsch <u@pkh.me> | 2016-01-06 13:43:23 +0100 |
---|---|---|
committer | Clément Bœsch <u@pkh.me> | 2016-02-26 21:49:34 +0100 |
commit | 29412821241050c846dbceaad4b9752857659977 (patch) | |
tree | eb42444a7a6bf5d2dc66cdec8c7aa26be32bed99 /libavcodec/samidec.c | |
parent | 805685fffd3115d3f9260d8df15ef36b6b3b8006 (diff) | |
download | ffmpeg-29412821241050c846dbceaad4b9752857659977.tar.gz |
lavc: allow subtitle text format to be ASS without timing
Diffstat (limited to 'libavcodec/samidec.c')
-rw-r--r-- | libavcodec/samidec.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/libavcodec/samidec.c b/libavcodec/samidec.c index 95f35abd42..2874e216f9 100644 --- a/libavcodec/samidec.c +++ b/libavcodec/samidec.c @@ -35,6 +35,7 @@ typedef struct { AVBPrint encoded_source; AVBPrint encoded_content; AVBPrint full; + int readorder; } SAMIContext; static int sami_paragraph_to_ass(AVCodecContext *avctx, const char *src) @@ -131,10 +132,8 @@ static int sami_decode_frame(AVCodecContext *avctx, SAMIContext *sami = avctx->priv_data; if (ptr && avpkt->size > 0 && !sami_paragraph_to_ass(avctx, ptr)) { - int ts_start = av_rescale_q(avpkt->pts, avctx->time_base, (AVRational){1,100}); - int ts_duration = avpkt->duration != -1 ? - av_rescale_q(avpkt->duration, avctx->time_base, (AVRational){1,100}) : -1; - int ret = ff_ass_add_rect_bprint(sub, &sami->full, ts_start, ts_duration); + // TODO: pass escaped sami->encoded_source.str as source + int ret = ff_ass_add_rect(sub, sami->full.str, sami->readorder++, 0, NULL, NULL); if (ret < 0) return ret; } @@ -164,6 +163,12 @@ static av_cold int sami_close(AVCodecContext *avctx) return 0; } +static void sami_flush(AVCodecContext *avctx) +{ + SAMIContext *sami = avctx->priv_data; + sami->readorder = 0; +} + AVCodec ff_sami_decoder = { .name = "sami", .long_name = NULL_IF_CONFIG_SMALL("SAMI subtitle"), @@ -173,4 +178,5 @@ AVCodec ff_sami_decoder = { .init = sami_init, .close = sami_close, .decode = sami_decode_frame, + .flush = sami_flush, }; |