summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-10-31 23:43:22 +0100
committerwm4 <wm4@nowhere>2014-10-31 23:43:22 +0100
commit13d408fe8ded849375667de28516bdba28a83be9 (patch)
treec4a6269f7d69b046804fba42e563d91b608c7c20
parent0afc99b33ff8bf624964090bae71d4f0a5830dc9 (diff)
downloadmpv-13d408fe8ded849375667de28516bdba28a83be9.tar.bz2
mpv-13d408fe8ded849375667de28516bdba28a83be9.tar.xz
sub: be more flexible about changes to how subtitles are rendered
For example, if --force-window is used, and video is switched off during playback, then you need to redecide the rendering method to get subs displayed correctly. Do this by moving the state setup code into a function, and call it on every frame.
-rw-r--r--player/sub.c52
1 files changed, 32 insertions, 20 deletions
diff --git a/player/sub.c b/player/sub.c
index d5f76834d3..09da80f1ae 100644
--- a/player/sub.c
+++ b/player/sub.c
@@ -193,6 +193,36 @@ void reset_subtitle_state(struct MPContext *mpctx)
reset_subtitles(mpctx, 1);
}
+static void update_sub_state(struct MPContext *mpctx, int order,
+ struct osd_sub_state *out_state)
+{
+ struct MPOpts *opts = mpctx->opts;
+ struct track *track = mpctx->current_track[order][STREAM_SUB];
+ struct dec_sub *dec_sub = mpctx->d_sub[order];
+ int obj = order ? OSDTYPE_SUB2 : OSDTYPE_SUB;
+
+ assert(track);
+
+ struct osd_sub_state state = {
+ .dec_sub = dec_sub,
+ // Decides whether to use OSD path or normal subtitle rendering path.
+ .render_bitmap_subs = opts->ass_enabled || !sub_has_get_text(dec_sub),
+ .video_offset = get_track_video_offset(mpctx, track),
+ };
+
+ // Secondary subs are rendered with the "text" renderer to transform them
+ // to toptitles.
+ if (order == 1 && sub_has_get_text(dec_sub))
+ state.render_bitmap_subs = false;
+
+ if (!mpctx->current_track[0][STREAM_VIDEO])
+ state.render_bitmap_subs = false;
+
+ osd_set_sub(mpctx->osd, obj, &state);
+ if (out_state)
+ *out_state = state;
+}
+
static void update_subtitle(struct MPContext *mpctx, int order)
{
struct MPOpts *opts = mpctx->opts;
@@ -212,9 +242,7 @@ static void update_subtitle(struct MPContext *mpctx, int order)
}
struct osd_sub_state state;
- osd_get_sub(mpctx->osd, obj, &state);
- state.video_offset = get_track_video_offset(mpctx, track);
- osd_set_sub(mpctx->osd, obj, &state);
+ update_sub_state(mpctx, order, &state);
double refpts_s = mpctx->playback_pts - state.video_offset;
double curpts_s = refpts_s - opts->sub_delay;
@@ -294,9 +322,7 @@ static void reinit_subdec(struct MPContext *mpctx, struct track *track,
void reinit_subs(struct MPContext *mpctx, int order)
{
- struct MPOpts *opts = mpctx->opts;
struct track *track = mpctx->current_track[order][STREAM_SUB];
- int obj = order ? OSDTYPE_SUB2 : OSDTYPE_SUB;
assert(!mpctx->d_sub[order]);
@@ -313,19 +339,5 @@ void reinit_subs(struct MPContext *mpctx, int order)
struct dec_sub *dec_sub = mpctx->d_sub[order];
reinit_subdec(mpctx, track, dec_sub);
- struct osd_sub_state state = {
- .dec_sub = dec_sub,
- // Decides whether to use OSD path or normal subtitle rendering path.
- .render_bitmap_subs = opts->ass_enabled || !sub_has_get_text(dec_sub),
- };
-
- // Secondary subs are rendered with the "text" renderer to transform them
- // to toptitles.
- if (order == 1 && sub_has_get_text(dec_sub))
- state.render_bitmap_subs = false;
-
- if (!mpctx->current_track[0][STREAM_VIDEO])
- state.render_bitmap_subs = false;
-
- osd_set_sub(mpctx->osd, obj, &state);
+ update_sub_state(mpctx, order, NULL);
}