diff options
author | Uoti Urpala <uau@mplayer2.org> | 2012-08-25 21:22:39 +0300 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2012-09-18 21:04:46 +0200 |
commit | 89a57148934ec7f150a6170ac1313f6f5c636596 (patch) | |
tree | acff6dbda4ea8623ea4ce4d86834fe74f015653e /sub/dec_sub.c | |
parent | 9bb03b7db40408b9dc4a0e1405a5bac754893e2b (diff) | |
download | mpv-89a57148934ec7f150a6170ac1313f6f5c636596.tar.bz2 mpv-89a57148934ec7f150a6170ac1313f6f5c636596.tar.xz |
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
Diffstat (limited to 'sub/dec_sub.c')
-rw-r--r-- | sub/dec_sub.c | 29 |
1 files changed, 26 insertions, 3 deletions
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; } |