X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Fsamidec.c;h=16f3f58c1cfeb7fba0bdf91d4ba0ba263901a543;hb=305344d89e21ed11c74274167cf597f151778c42;hp=95f35abd42ffb63551bd4864339d68398f956bc5;hpb=55cada301049cd3a4133ac8349d3f80db2a48b97;p=ffmpeg diff --git a/libavcodec/samidec.c b/libavcodec/samidec.c index 95f35abd42f..16f3f58c1cf 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,13 @@ static av_cold int sami_close(AVCodecContext *avctx) return 0; } +static void sami_flush(AVCodecContext *avctx) +{ + SAMIContext *sami = avctx->priv_data; + if (!(avctx->flags2 & AV_CODEC_FLAG2_RO_FLUSH_NOOP)) + sami->readorder = 0; +} + AVCodec ff_sami_decoder = { .name = "sami", .long_name = NULL_IF_CONFIG_SMALL("SAMI subtitle"), @@ -173,4 +179,5 @@ AVCodec ff_sami_decoder = { .init = sami_init, .close = sami_close, .decode = sami_decode_frame, + .flush = sami_flush, };