From a2e7642d3c8cf20c339a38595212070d2339a2cc Mon Sep 17 00:00:00 2001 From: wm4 Date: Sat, 5 Dec 2015 23:54:00 +0100 Subject: sub: allow feeding bitmap subs in advance Until now, feeding packets to the decoder in advance was done for text subtitles only. This was possible because libass buffers all subtitle data anyway (in ASS_Track). sd_lavc, responsible for bitmap subs, does not do this. But it can buffer a small number of subtitle frames ahead. Enable this. Repurpose the sub_accept_packets_in_advance(). Instead of "can take all packets" it means "can take 1 packet" now. (The old meaning is still needed locally in dec_sub.c; keep it there.) It asks the decoder whether there is place for at least 1 subtitle packet. sd_lavc implements it and returns true if its internal fixed-size subtitle queue still has a free slot. (The implementation of this in dec_sub.c isn't entirely clean. For one, decode_chain() ignores this mechanism, so it's implied that bitmap subtitles do not use the subtitle filter chain in any advanced way.) Also fix 2 bugs in the sd_lavc queue handling. Subtitles must be checked in reverse, because the first entry will often have endpts==NOPTS, which would always match. alloc_sub() must cycle the queue buffer, because it reuses memory allocations (like sub.imgs) by design. --- player/sub.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'player') diff --git a/player/sub.c b/player/sub.c index 0a55936f54..c2a3e80cb3 100644 --- a/player/sub.c +++ b/player/sub.c @@ -222,8 +222,8 @@ static void update_subtitle(struct MPContext *mpctx, int order) if (subpts_s > curpts_s) { MP_DBG(mpctx, "Sub early: c_pts=%5.3f s_pts=%5.3f\n", curpts_s, subpts_s); - // Libass handled subs can be fed to it in advance - if (!sub_accept_packets_in_advance(dec_sub)) + // Often subs can be handled in advance + if (!sub_accepts_packet_in_advance(dec_sub)) break; // Try to avoid demuxing whole file at once if (subpts_s > curpts_s + 1 && !interleaved) -- cgit v1.2.3