From e5c094754157102a964364041d6fb0caf2188809 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sat, 29 Jun 2013 01:34:11 +0200 Subject: dec_sub: introduce sub_control(), use it for sub_step This means the direct libass usage can be removed from command.c, and no weird hacks for retrieving the ASS_Track are needed. Also fix a bug when using this feature with ordered chapters. --- sub/sd_ass.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) (limited to 'sub/sd_ass.c') diff --git a/sub/sd_ass.c b/sub/sd_ass.c index 9c51398f33..c82e1e80bb 100644 --- a/sub/sd_ass.c +++ b/sub/sd_ass.c @@ -318,6 +318,20 @@ static void uninit(struct sd *sd) talloc_free(ctx); } +static int control(struct sd *sd, enum sd_ctrl cmd, void *arg) +{ + struct sd_ass_priv *ctx = sd->priv; + switch (cmd) { + case SD_CTRL_SUB_STEP: { + double *a = arg; + a[0] = ass_step_sub(ctx->ass_track, a[0] * 1000 + .5, a[1]) / 1000.0; + return CONTROL_OK; + } + default: + return CONTROL_UNKNOWN; + } +} + const struct sd_functions sd_ass = { .name = "ass", .accept_packets_in_advance = true, @@ -327,16 +341,7 @@ const struct sd_functions sd_ass = { .get_bitmaps = get_bitmaps, .get_text = get_text, .fix_events = fix_events, + .control = control, .reset = reset, .uninit = uninit, }; - -struct ass_track *sub_get_ass_track(struct dec_sub *sub) -{ - struct sd *sd = sub_get_last_sd(sub); - if (sd && sd->driver == &sd_ass && sd->priv) { - struct sd_ass_priv *ctx = sd->priv; - return ctx->ass_track; - } - return NULL; -} -- cgit v1.2.3