From 89a57148934ec7f150a6170ac1313f6f5c636596 Mon Sep 17 00:00:00 2001 From: Uoti Urpala Date: Sat, 25 Aug 2012 21:22:39 +0300 Subject: subs: always use sub decoder framework for libass rendering Remove subtitle selection code setting osd->ass_track directly and vf_ass/vf_vo code rendering the track directly with libass. Instead, do track selection and rendering with dec_sub.c functions. Before, mpctx->set_of_ass_tracks[] contained bare libass tracks generated from external subtitle files. For use with dec_sub.c, it now contains struct sh_sub instances with decoder already initialized. This commit breaks the sub_step command ('g' and 'y' keys) for libass-rendered subtitles. It could be fixed, but it's so useless - especially as with the existing implementation there's no practical way to get subtitle delay back to normal after using it - that I didn't bother. Conflicts: command.c mp_core.h mplayer.c --- sub/dec_sub.c | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) (limited to 'sub/dec_sub.c') diff --git a/sub/dec_sub.c b/sub/dec_sub.c index 7528e90e58..c710ff575a 100644 --- a/sub/dec_sub.c +++ b/sub/dec_sub.c @@ -22,8 +22,9 @@ #include "config.h" #include "libmpdemux/stheader.h" -#include "sd.h" -#include "dec_sub.h" +#include "sub/sd.h" +#include "sub/sub.h" +#include "sub/dec_sub.h" #include "options.h" extern const struct sd_functions sd_ass; @@ -33,6 +34,7 @@ void sub_init(struct sh_sub *sh, struct osd_state *osd) { struct MPOpts *opts = sh->opts; + assert(!osd->sh_sub); #ifdef CONFIG_ASS if (opts->ass_enabled && is_text_sub(sh->type)) sh->sd_driver = &sd_ass; @@ -42,6 +44,8 @@ void sub_init(struct sh_sub *sh, struct osd_state *osd) if (sh->sd_driver) { if (sh->sd_driver->init(sh, osd) < 0) return; + osd->sh_sub = sh; + osd->changed_outside_sd = true; sh->initialized = true; sh->active = true; } @@ -54,6 +58,22 @@ void sub_decode(struct sh_sub *sh, struct osd_state *osd, void *data, sh->sd_driver->decode(sh, osd, data, data_len, pts, duration); } +void sub_get_bitmaps(struct osd_state *osd, struct sub_bitmaps *res) +{ + struct MPOpts *opts = osd->opts; + + *res = (struct sub_bitmaps){.imgs = NULL, .changed = 2}; + if (!opts->sub_visibility || !osd->sh_sub || !osd->sh_sub->active) { + osd->changed_outside_sd = true; + return; + } + if (osd->sh_sub->sd_driver->get_bitmaps) + osd->sh_sub->sd_driver->get_bitmaps(osd->sh_sub, osd, res); + if (osd->changed_outside_sd) + res->changed = 2; + osd->changed_outside_sd = false; +} + void sub_reset(struct sh_sub *sh, struct osd_state *osd) { if (sh->active && sh->sd_driver->reset) @@ -62,8 +82,11 @@ void sub_reset(struct sh_sub *sh, struct osd_state *osd) void sub_switchoff(struct sh_sub *sh, struct osd_state *osd) { - if (sh->active && sh->sd_driver->switch_off) + if (sh->active && sh->sd_driver->switch_off) { + assert(osd->sh_sub == sh); sh->sd_driver->switch_off(sh, osd); + osd->sh_sub = NULL; + } sh->active = false; } -- cgit v1.2.3