1
mirror of https://github.com/mpv-player/mpv synced 2024-09-12 23:45:53 +02:00

sub: clear libavformat demuxed subtitles on seeking

libavformat demuxes ass subtitles in a broken way, that forces the
player to throw away all subtitle events received so far. See mplayer
svn commit 31293.
This commit is contained in:
wm4 2012-12-02 01:25:33 +01:00
parent a4177fd581
commit 01584151c8

View File

@ -38,6 +38,7 @@ struct sd_ass_priv {
bool vsfilter_aspect;
bool incomplete_event;
struct sub_bitmap *parts;
bool flush_on_seek;
};
static void free_last_event(ASS_Track *track)
@ -78,6 +79,8 @@ static void decode(struct sh_sub *sh, struct osd_state *osd, void *data,
if (sh->type == 'a') { // ssa/ass subs
if (bstr_startswith0((bstr){data, data_len}, "Dialogue: ")) {
// broken ffmpeg ASS packet format
ctx->flush_on_seek = true;
ass_process_data(track, data, data_len);
} else {
ass_process_chunk(track, data, data_len,
@ -160,6 +163,9 @@ static void reset(struct sh_sub *sh, struct osd_state *osd)
if (ctx->incomplete_event)
free_last_event(ctx->ass_track);
ctx->incomplete_event = false;
if (ctx->flush_on_seek)
ass_flush_events(ctx->ass_track);
ctx->flush_on_seek = false;
}
static void uninit(struct sh_sub *sh)