summaryrefslogtreecommitdiffstats
path: root/sub/sd_ass.c
diff options
context:
space:
mode:
Diffstat (limited to 'sub/sd_ass.c')
-rw-r--r--sub/sd_ass.c53
1 files changed, 43 insertions, 10 deletions
diff --git a/sub/sd_ass.c b/sub/sd_ass.c
index f54c18e805..72dee06018 100644
--- a/sub/sd_ass.c
+++ b/sub/sd_ass.c
@@ -23,6 +23,7 @@
#include "talloc.h"
+#include "options.h"
#include "mpcommon.h"
#include "mp_msg.h"
#include "libmpdemux/stheader.h"
@@ -33,6 +34,7 @@
struct sd_ass_priv {
struct ass_track *ass_track;
+ bool vsfilter_aspect;
bool incomplete_event;
};
@@ -61,9 +63,7 @@ static int init(struct sh_sub *sh, struct osd_state *osd)
ctx->ass_track = mp_ass_default_track(osd->ass_library, sh->opts);
}
- assert(osd->ass_track == NULL);
- osd->ass_track = ctx->ass_track;
- osd->vsfilter_aspect = sh->type == 'a';
+ ctx->vsfilter_aspect = sh->type == 'a';
return 0;
}
@@ -125,6 +125,25 @@ static void decode(struct sh_sub *sh, struct osd_state *osd, void *data,
event->Text = strdup(buf);
}
+static void get_bitmaps(struct sh_sub *sh, struct osd_state *osd,
+ struct sub_bitmaps *res)
+{
+ struct sd_ass_priv *ctx = sh->context;
+ struct MPOpts *opts = osd->opts;
+
+ if (osd->sub_pts == MP_NOPTS_VALUE)
+ return;
+
+ double scale = osd->normal_scale;
+ if (ctx->vsfilter_aspect && opts->ass_vsfilter_aspect_compat)
+ scale = osd->vsfilter_scale;
+ ASS_Renderer *renderer = osd->ass_renderer;
+ mp_ass_configure(renderer, opts, &osd->dim, osd->unscaled);
+ ass_set_aspect_ratio(renderer, scale, 1);
+ res->imgs = ass_render_frame(renderer, ctx->ass_track,
+ osd->sub_pts * 1000 + .5, &res->changed);
+}
+
static void reset(struct sh_sub *sh, struct osd_state *osd)
{
struct sd_ass_priv *ctx = sh->context;
@@ -133,12 +152,6 @@ static void reset(struct sh_sub *sh, struct osd_state *osd)
ctx->incomplete_event = false;
}
-static void switch_off(struct sh_sub *sh, struct osd_state *osd)
-{
- reset(sh, osd);
- osd->ass_track = NULL;
-}
-
static void uninit(struct sh_sub *sh)
{
struct sd_ass_priv *ctx = sh->context;
@@ -150,7 +163,27 @@ static void uninit(struct sh_sub *sh)
const struct sd_functions sd_ass = {
.init = init,
.decode = decode,
+ .get_bitmaps = get_bitmaps,
.reset = reset,
- .switch_off = switch_off,
+ .switch_off = reset,
.uninit = uninit,
};
+
+
+struct sh_sub *sd_ass_create_from_track(struct ass_track *track,
+ bool vsfilter_aspect,
+ struct MPOpts *opts)
+{
+ struct sh_sub *sh = talloc(NULL, struct sh_sub);
+ *sh = (struct sh_sub) {
+ .opts = opts,
+ .type = 'a',
+ .sd_driver = &sd_ass,
+ .context = talloc_struct(sh, struct sd_ass_priv, {
+ .ass_track = track,
+ .vsfilter_aspect = vsfilter_aspect,
+ }),
+ .initialized = true,
+ };
+ return sh;
+}