summaryrefslogtreecommitdiffstats
path: root/player
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2017-12-29 15:39:38 +0100
committerKevin Mitchell <kevmitch@gmail.com>2018-01-02 14:27:37 -0800
commit3bf7df4a5e1f46248c78e9e596cd8dab6ff57356 (patch)
tree1b49e9e053e063b397552038c7f3309878d65c86 /player
parent828bd2963cd10a851e0a977809687aed4d377dc3 (diff)
downloadmpv-3bf7df4a5e1f46248c78e9e596cd8dab6ff57356.tar.bz2
mpv-3bf7df4a5e1f46248c78e9e596cd8dab6ff57356.tar.xz
sub: move all subtitle timestamp messing code to a central place
It was split at least across osd.c and sd_ass.c/sd_lavc.c. sd_lavc.c actually ignored most of the more obscure subtitle timing things. There's no reason for this - just move it all to dec_sub.c (mostly from sd_ass.c, because it has some of the most complex stuff). Now timestamps are transformed as they enter or leave dec_sub.c. There appear to have been some subtle mismatches about how subtitle timestamps were transformed, e.g. sd_functions.accepts_packet didn't apply the subtitle speed to the timestamp. This patch should fix them, although it's not clear if they caused actual misbehavior. The semantics of SD_CTRL_SUB_STEP are slightly changed, which is the reason for the changes in command.c and sd_lavc.c.
Diffstat (limited to 'player')
-rw-r--r--player/command.c10
-rw-r--r--player/sub.c3
2 files changed, 4 insertions, 9 deletions
diff --git a/player/command.c b/player/command.c
index 412afc5e11..61d47a2319 100644
--- a/player/command.c
+++ b/player/command.c
@@ -3081,8 +3081,6 @@ static int mp_property_sub_text(void *ctx, struct m_property *prop,
if (!sub || pts == MP_NOPTS_VALUE)
return M_PROPERTY_UNAVAILABLE;
- pts -= mpctx->opts->sub_delay;
-
char *text = sub_get_text(sub, pts);
if (!text)
text = "";
@@ -5078,11 +5076,11 @@ int run_command(struct MPContext *mpctx, struct mp_cmd *cmd, struct mpv_node *re
double refpts = get_current_time(mpctx);
if (sub && refpts != MP_NOPTS_VALUE) {
double a[2];
- a[0] = refpts - opts->sub_delay;
+ a[0] = refpts;
a[1] = cmd->args[0].v.i;
if (sub_control(sub, SD_CTRL_SUB_STEP, a) > 0) {
if (cmd->id == MP_CMD_SUB_STEP) {
- opts->sub_delay -= a[0];
+ opts->sub_delay -= a[0] - refpts;
osd_changed(mpctx->osd);
show_property_osd(mpctx, "sub-delay", on_osd);
} else {
@@ -5092,9 +5090,9 @@ int run_command(struct MPContext *mpctx, struct mp_cmd *cmd, struct mpv_node *re
// rounding for the mess of it.
a[0] += 0.01 * (a[1] >= 0 ? 1 : -1);
mark_seek(mpctx);
- queue_seek(mpctx, MPSEEK_RELATIVE, a[0], MPSEEK_EXACT,
+ queue_seek(mpctx, MPSEEK_ABSOLUTE, a[0], MPSEEK_EXACT,
MPSEEK_FLAG_DELAY);
- set_osd_function(mpctx, (a[0] > 0) ? OSD_FFW : OSD_REW);
+ set_osd_function(mpctx, (a[0] > refpts) ? OSD_FFW : OSD_REW);
if (bar_osd)
mpctx->add_osd_seek_info |= OSD_SEEK_INFO_BAR;
if (msg_or_nobar_osd)
diff --git a/player/sub.c b/player/sub.c
index 2702e7bf55..0de02ea61b 100644
--- a/player/sub.c
+++ b/player/sub.c
@@ -84,7 +84,6 @@ void uninit_sub_all(struct MPContext *mpctx)
static bool update_subtitle(struct MPContext *mpctx, double video_pts,
struct track *track)
{
- struct MPOpts *opts = mpctx->opts;
struct dec_sub *dec_sub = track ? track->d_sub : NULL;
if (!dec_sub || video_pts == MP_NOPTS_VALUE)
@@ -96,8 +95,6 @@ static bool update_subtitle(struct MPContext *mpctx, double video_pts,
sub_control(dec_sub, SD_CTRL_SET_VIDEO_PARAMS, &params);
}
- video_pts -= opts->sub_delay;
-
if (track->demuxer->fully_read && sub_can_preload(dec_sub)) {
// Assume fully_read implies no interleaved audio/video streams.
// (Reading packets will change the demuxer position.)