summaryrefslogtreecommitdiffstats
path: root/player
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
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')
-rw-r--r--player/command.c7
-rw-r--r--player/core.h4
-rw-r--r--player/osd.c11
-rw-r--r--player/sub.c53
4 files changed, 12 insertions, 63 deletions
diff --git a/player/command.c b/player/command.c
index f6ccf22cae..7d520d78ac 100644
--- a/player/command.c
+++ b/player/command.c
@@ -4472,14 +4472,13 @@ int run_command(struct MPContext *mpctx, struct mp_cmd *cmd, struct mpv_node *re
case MP_CMD_SUB_SEEK: {
if (!mpctx->playback_initialized)
return -1;
- struct osd_sub_state state;
- update_osd_sub_state(mpctx, 0, &state);
+ struct dec_sub *sub = mpctx->d_sub[0];
double refpts = get_current_time(mpctx);
- if (state.dec_sub && refpts != MP_NOPTS_VALUE) {
+ if (sub && refpts != MP_NOPTS_VALUE) {
double a[2];
a[0] = refpts - opts->sub_delay;
a[1] = cmd->args[0].v.i;
- if (sub_control(state.dec_sub, SD_CTRL_SUB_STEP, a) > 0) {
+ if (sub_control(sub, SD_CTRL_SUB_STEP, a) > 0) {
if (cmd->id == MP_CMD_SUB_STEP) {
opts->sub_delay -= a[0];
osd_changed_all(mpctx->osd);
diff --git a/player/core.h b/player/core.h
index a7b643864d..2f9d2828ac 100644
--- a/player/core.h
+++ b/player/core.h
@@ -475,7 +475,7 @@ void set_osd_bar(struct MPContext *mpctx, int type,
bool set_osd_msg(struct MPContext *mpctx, int level, int time,
const char* fmt, ...) PRINTF_ATTRIBUTE(4,5);
void set_osd_function(struct MPContext *mpctx, int osd_function);
-void set_osd_subtitle(struct MPContext *mpctx, const char *text);
+void term_osd_set_subs(struct MPContext *mpctx, const char *text);
void get_current_osd_sym(struct MPContext *mpctx, char *buf, size_t buf_size);
void set_osd_bar_chapters(struct MPContext *mpctx, int type);
@@ -523,8 +523,6 @@ void uninit_sub_all(struct MPContext *mpctx);
void update_osd_msg(struct MPContext *mpctx);
void update_subtitles(struct MPContext *mpctx);
void uninit_sub_renderer(struct MPContext *mpctx);
-void update_osd_sub_state(struct MPContext *mpctx, int order,
- struct osd_sub_state *out_state);
// video.c
void reset_video_state(struct MPContext *mpctx);
diff --git a/player/osd.c b/player/osd.c
index ce3ba103cd..e26439432d 100644
--- a/player/osd.c
+++ b/player/osd.c
@@ -103,7 +103,7 @@ static void term_osd_update(struct MPContext *mpctx)
}
}
-static void term_osd_set_subs(struct MPContext *mpctx, const char *text)
+void term_osd_set_subs(struct MPContext *mpctx, const char *text)
{
if (mpctx->video_out || !text)
text = ""; // disable
@@ -386,15 +386,6 @@ void set_osd_function(struct MPContext *mpctx, int osd_function)
mpctx->sleeptime = 0;
}
-/**
- * \brief Display text subtitles on the OSD
- */
-void set_osd_subtitle(struct MPContext *mpctx, const char *text)
-{
- osd_set_text(mpctx->osd, OSDTYPE_SUB, text);
- term_osd_set_subs(mpctx, text);
-}
-
void get_current_osd_sym(struct MPContext *mpctx, char *buf, size_t buf_size)
{
int sym = mpctx->osd_function;
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});
}