diff options
author | wm4 <wm4@nowhere> | 2012-09-01 19:49:04 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2012-09-18 21:04:46 +0200 |
commit | b554a59b5818640734486555064af86383154ace (patch) | |
tree | 69fb972ec4bf24d01e01ac9e9b296df2f48fd69f | |
parent | fd52cb65f43d262493724899c7b0fb49971f745d (diff) | |
download | mpv-b554a59b5818640734486555064af86383154ace.tar.bz2 mpv-b554a59b5818640734486555064af86383154ace.tar.xz |
subs: restore support for sub_step command with libass
This was destroyed by Uoti Urpala in commit "subs: always use sub...".
Features should be either kept working or completely removed, but not
just crippled, which only inflates the code and frustrates users.
-rw-r--r-- | command.c | 24 | ||||
-rw-r--r-- | sub/dec_sub.h | 4 | ||||
-rw-r--r-- | sub/sd_ass.c | 10 |
3 files changed, 28 insertions, 10 deletions
@@ -2365,18 +2365,22 @@ void run_command(MPContext *mpctx, mp_cmd_t *cmd) if (sh_video) { int movement = cmd->args[0].v.i; struct track *track = mpctx->current_track[STREAM_SUB]; - if (track && track->subdata) + bool available = false; + if (track && track->subdata) { + available = true; step_sub(track->subdata, mpctx->video_pts, movement); -#if 0 - // currently not implemented with libass - if (mpctx->osd->ass_track) - sub_delay += - ass_step_sub(mpctx->osd->ass_track, - (mpctx->video_pts + - sub_delay) * 1000 + .5, movement) / 1000.; + } +#ifdef CONFIG_ASS + struct ass_track *ass_track = sub_get_ass_track(mpctx->osd); + if (ass_track) { + available = true; + sub_delay += ass_step_sub(ass_track, + (mpctx->video_pts + sub_delay) * 1000 + .5, movement) / 1000.; + } #endif - set_osd_tmsg(mpctx, OSD_MSG_SUB_DELAY, 1, osd_duration, - "Sub delay: %d ms", ROUND(sub_delay * 1000)); + if (available) + set_osd_tmsg(mpctx, OSD_MSG_SUB_DELAY, 1, osd_duration, + "Sub delay: %d ms", ROUND(sub_delay * 1000)); } break; diff --git a/sub/dec_sub.h b/sub/dec_sub.h index ae39f15f31..efbfdc9ce7 100644 --- a/sub/dec_sub.h +++ b/sub/dec_sub.h @@ -32,4 +32,8 @@ struct sh_sub *sd_ass_create_from_track(struct ass_track *track, bool vsfilter_aspect, struct MPOpts *opts); +#ifdef CONFIG_ASS +struct ass_track *sub_get_ass_track(struct osd_state *osd); +#endif + #endif diff --git a/sub/sd_ass.c b/sub/sd_ass.c index 67bbd4665e..37c220a4b5 100644 --- a/sub/sd_ass.c +++ b/sub/sd_ass.c @@ -192,3 +192,13 @@ struct sh_sub *sd_ass_create_from_track(struct ass_track *track, }; return sh; } + +struct ass_track *sub_get_ass_track(struct osd_state *osd) +{ + struct sh_sub *sh = osd ? osd->sh_sub : NULL; + if (sh && sh->sd_driver == &sd_ass && sh->context) { + struct sd_ass_priv *ctx = sh->context; + return ctx->ass_track; + } + return NULL; +} |