summaryrefslogtreecommitdiffstats
path: root/player/sub.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-11-17 01:54:02 +0100
committerwm4 <wm4@nowhere>2015-11-17 01:56:23 +0100
commit5a89150a4652d987f24d7d386d5cdc6d9109e66d (patch)
treefc6085143661672f537a604b6645f79e0dced3ad /player/sub.c
parent85450d06a1b1a08fce277f7f14d5ee33b12f8eab (diff)
downloadmpv-5a89150a4652d987f24d7d386d5cdc6d9109e66d.tar.bz2
mpv-5a89150a4652d987f24d7d386d5cdc6d9109e66d.tar.xz
player: remove OSD subtitle render path
This was used with --no-sub-ass (aka --no-ass). This option (which is not yet removed) strips all styling from the subtitles, and renders them as plaintext only. For some reason, it originally seemed convenient to reuse all the OSD text rendering code (osd_libass.c). While this was indeed simple, it had a bad influence on the rest of the code. For example, it had to decide whether to go through the OSD code path, or the proper subtitle renderer in sd_ass.c. Kill the OSD subtitle renderer. Reimplement --no-sub-ass and also "secondary" subtitles in sd_ass.c. fill_plaintext() contains some rather minor code duplication with osd_libass.c for setting up a dummy ASS_Event and escaping the stripped text. Since sd_ass.c already has to handle "normal" text subtitles, and has code for stripping ASS tags, this remains all relatively simple. Remove all the unnecessary crap from the rest of the code.
Diffstat (limited to 'player/sub.c')
-rw-r--r--player/sub.c53
1 files changed, 7 insertions, 46 deletions
diff --git a/player/sub.c b/player/sub.c
index e326b3e2fd..0a55936f54 100644
--- a/player/sub.c
+++ b/player/sub.c
@@ -133,11 +133,9 @@ void uninit_sub_renderer(struct MPContext *mpctx) {}
static void reset_subtitles(struct MPContext *mpctx, int order)
{
- int obj = order ? OSDTYPE_SUB2 : OSDTYPE_SUB;
if (mpctx->d_sub[order])
sub_reset(mpctx->d_sub[order]);
- set_osd_subtitle(mpctx, NULL);
- osd_set_text(mpctx->osd, obj, NULL);
+ term_osd_set_subs(mpctx, NULL);
}
void reset_subtitle_state(struct MPContext *mpctx)
@@ -162,7 +160,7 @@ void uninit_sub(struct MPContext *mpctx, int order)
if (mpctx->d_sub[order]) {
reset_subtitles(mpctx, order);
mpctx->d_sub[order] = NULL; // Note: not free'd.
- update_osd_sub_state(mpctx, order, NULL); // unset
+ osd_set_sub(mpctx->osd, OSDTYPE_SUB + order, NULL);
reselect_demux_streams(mpctx);
}
}
@@ -191,33 +189,6 @@ static bool is_interleaved(struct MPContext *mpctx, struct track *track)
return track->demuxer == mpctx->demuxer;
}
-void update_osd_sub_state(struct MPContext *mpctx, int order,
- struct osd_sub_state *out_state)
-{
- struct MPOpts *opts = mpctx->opts;
- struct dec_sub *dec_sub = mpctx->d_sub[order];
- int obj = order ? OSDTYPE_SUB2 : OSDTYPE_SUB;
- bool textsub = dec_sub && sub_has_get_text(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 || !textsub,
- };
-
- // Secondary subs are rendered with the "text" renderer to transform them
- // to toptitles.
- if (order == 1 && textsub)
- 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;
@@ -227,17 +198,12 @@ static void update_subtitle(struct MPContext *mpctx, int order)
if (!track || !dec_sub)
return;
- int obj = order ? OSDTYPE_SUB2 : OSDTYPE_SUB;
-
if (mpctx->d_video) {
struct mp_image_params params = mpctx->d_video->vfilter->override_params;
if (params.imgfmt)
sub_control(dec_sub, SD_CTRL_SET_VIDEO_PARAMS, &params);
}
- struct osd_sub_state state;
- update_osd_sub_state(mpctx, order, &state);
-
double refpts_s = mpctx->playback_pts;
double curpts_s = refpts_s - opts->sub_delay;
@@ -272,12 +238,8 @@ static void update_subtitle(struct MPContext *mpctx, int order)
}
// Handle displaying subtitles on terminal; never done for secondary subs
- if (order == 0) {
- if (!state.render_bitmap_subs || !mpctx->video_out)
- set_osd_subtitle(mpctx, sub_get_text(dec_sub, curpts_s));
- } else if (order == 1) {
- osd_set_text(mpctx->osd, obj, sub_get_text(dec_sub, curpts_s));
- }
+ if (order == 0 && !mpctx->video_out)
+ term_osd_set_subs(mpctx, sub_get_text(dec_sub, curpts_s));
}
void update_subtitles(struct MPContext *mpctx)
@@ -335,8 +297,7 @@ void reinit_subs(struct MPContext *mpctx, int order)
sh->sub->dec_sub = sub_create(mpctx->global);
mpctx->d_sub[order] = sh->sub->dec_sub;
- struct dec_sub *dec_sub = mpctx->d_sub[order];
- reinit_subdec(mpctx, track, dec_sub);
-
- update_osd_sub_state(mpctx, order, NULL);
+ reinit_subdec(mpctx, track, sh->sub->dec_sub);
+ osd_set_sub(mpctx->osd, OSDTYPE_SUB + order, sh->sub->dec_sub);
+ sub_control(sh->sub->dec_sub, SD_CTRL_SET_TOP, &(bool){!!order});
}