summaryrefslogtreecommitdiffstats
path: root/mpcommon.c
diff options
context:
space:
mode:
authorUoti Urpala <uau@glyph.nonexistent.invalid>2009-12-02 17:57:47 +0200
committerUoti Urpala <uau@glyph.nonexistent.invalid>2009-12-02 17:57:47 +0200
commit55f94a1a91bf9bf28b5b33f698c28a86c08e0e75 (patch)
tree1cf609022ba17dda11cf467eb337147b08bac1a6 /mpcommon.c
parent9afcdab6944587aaee7db0307f3087b5a275771d (diff)
downloadmpv-55f94a1a91bf9bf28b5b33f698c28a86c08e0e75.tar.bz2
mpv-55f94a1a91bf9bf28b5b33f698c28a86c08e0e75.tar.xz
subtitles: Fix recent filter-rendered libass timing problem
commit 4c552b2e420ba4cb6d888b12360c7bf63e7cd03a ("core: Do OSD/subtitle updates at a more accurate point") made filter-rendered libass subtitles appear one frame too late the first time they became visible (VO rendering was not affected, and filter rendering was accurate if seeking back later). The reason was that the subtitle code did not feed the subtitle events to libass before their starting time, and this now happened after the filtering phase. Fix this by skipping the time check in the libass case and feeding demuxed subtitles to it unconditionally (as timing is done separately anyway with libass). There are still at least theoretically possible new problems in the filter-rendered case because the filter now relies on packets demuxed before the _previous_ frame. There's a bigger chance of getting the subtitle packet too late, and the filter can't see packets for the first frame after a seek. However the former is not an issue for the samples I tested even with -nosound, and subtitles are not in general guaranteed to be shown when seeking to a new position (though it could be worth a later improvement).
Diffstat (limited to 'mpcommon.c')
-rw-r--r--mpcommon.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/mpcommon.c b/mpcommon.c
index 3fb38ece17..2401578d1c 100644
--- a/mpcommon.c
+++ b/mpcommon.c
@@ -157,8 +157,14 @@ void update_subtitles(struct MPContext *mpctx, struct MPOpts *opts,
ds_get_next_pts(d_dvdsub);
while (d_dvdsub->first) {
double subpts = ds_get_next_pts(d_dvdsub) + sub_offset;
- if (subpts > curpts)
- break;
+ if (subpts > curpts) {
+ // Libass handled subs can be fed to it in advance
+ if (!opts->ass_enabled || type == 'd')
+ break;
+ // Try to avoid demuxing whole file at once
+ if (d_dvdsub->non_interleaved && subpts > curpts + 1)
+ break;
+ }
endpts = d_dvdsub->first->endpts + sub_offset;
len = ds_get_packet_sub(d_dvdsub, &packet);
if (type == 'm') {