AVBPrint encoded_source;
AVBPrint encoded_content;
AVBPrint full;
+ int readorder;
} SAMIContext;
static int sami_paragraph_to_ass(AVCodecContext *avctx, const char *src)
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;
}
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"),
.init = sami_init,
.close = sami_close,
.decode = sami_decode_frame,
+ .flush = sami_flush,
};