summaryrefslogtreecommitdiffstats
path: root/sub/dec_sub.c
diff options
context:
space:
mode:
Diffstat (limited to 'sub/dec_sub.c')
-rw-r--r--sub/dec_sub.c29
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;
}