summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-11-15 19:43:43 +0100
committerwm4 <wm4@nowhere>2014-11-15 19:43:43 +0100
commit2125e49422137fa3164b37f7d64e2df68f07da9b (patch)
treee8b58f58e0c32a834ce1b959dd89bbc97a69292d
parenta6694d27889b4b65ab6d05641396724ae9696f77 (diff)
downloadmpv-2125e49422137fa3164b37f7d64e2df68f07da9b.tar.bz2
mpv-2125e49422137fa3164b37f7d64e2df68f07da9b.tar.xz
sub: workaround braindead libass API
libass won't use embedded fonts, unless ass_set_fonts() (called by mp_ass_configure_fonts()) is called. However, we call this function when the ASS_Renderer is initialized, which is long before the .ass file is actually loaded. (I'm not sure why it tries to keep 1 ASS_Renderer, but it always did this.) Fix by calling mp_ass_configure_fonts() after loading them. This also means this function will be called multiple times - hopefully this is harmless (it will reinit fontconfig every time, though). While we're at it, also initialize the ASS_Renderer lazily. Fixes #1244.
-rw-r--r--player/core.h1
-rw-r--r--player/loadfile.c2
-rw-r--r--player/sub.c21
3 files changed, 14 insertions, 10 deletions
diff --git a/player/core.h b/player/core.h
index 32239f28e3..e7402cfe5d 100644
--- a/player/core.h
+++ b/player/core.h
@@ -468,7 +468,6 @@ void uninit_sub(struct MPContext *mpctx, int order);
void uninit_sub_all(struct MPContext *mpctx);
void update_osd_msg(struct MPContext *mpctx);
void update_subtitles(struct MPContext *mpctx);
-void init_sub_renderer(struct MPContext *mpctx);
void uninit_sub_renderer(struct MPContext *mpctx);
void get_osd_sub_state(struct MPContext *mpctx, int order,
struct osd_sub_state *out_state);
diff --git a/player/loadfile.c b/player/loadfile.c
index 6e556a672d..b27ba94860 100644
--- a/player/loadfile.c
+++ b/player/loadfile.c
@@ -1079,8 +1079,6 @@ goto_reopen_demuxer: ;
"Displaying attached picture. Use --no-audio-display to prevent this.\n");
}
- init_sub_renderer(mpctx);
-
#if HAVE_ENCODING
if (mpctx->encode_lavc_ctx && mpctx->current_track[0][STREAM_VIDEO])
encode_lavc_expect_stream(mpctx->encode_lavc_ctx, AVMEDIA_TYPE_VIDEO);
diff --git a/player/sub.c b/player/sub.c
index f694296c90..3d42e0a662 100644
--- a/player/sub.c
+++ b/player/sub.c
@@ -92,11 +92,12 @@ static void add_subtitle_fonts_from_sources(struct MPContext *mpctx)
}
}
-void init_sub_renderer(struct MPContext *mpctx)
+static void init_sub_renderer(struct MPContext *mpctx)
{
struct MPOpts *opts = mpctx->opts;
- uninit_sub_renderer(mpctx);
+ if (mpctx->ass_renderer)
+ return;
if (!mpctx->ass_log)
mpctx->ass_log = mp_log_new(mpctx, mpctx->global->log, "!libass");
@@ -109,10 +110,6 @@ void init_sub_renderer(struct MPContext *mpctx)
ass_set_style_overrides(mpctx->ass_library, opts->ass_force_style_list);
mpctx->ass_renderer = ass_renderer_init(mpctx->ass_library);
- if (mpctx->ass_renderer) {
- mp_ass_configure_fonts(mpctx->ass_renderer, opts->sub_text_style,
- mpctx->global, mpctx->ass_log);
- }
}
void uninit_sub_renderer(struct MPContext *mpctx)
@@ -127,9 +124,12 @@ void uninit_sub_renderer(struct MPContext *mpctx)
#else /* HAVE_LIBASS */
-void init_sub_renderer(struct MPContext *mpctx) {}
+static void init_sub_renderer(struct MPContext *mpctx) {}
void uninit_sub_renderer(struct MPContext *mpctx) {}
+void mp_ass_configure(ASS_Renderer *priv, struct MPOpts *opts,
+ struct mp_osd_res *dim) {}
+
#endif
void uninit_stream_sub_decoders(struct demuxer *demuxer)
@@ -306,11 +306,18 @@ static void reinit_subdec(struct MPContext *mpctx, struct track *track,
int h = sh_video ? sh_video->disp_h : 0;
float fps = sh_video ? sh_video->fps : 25;
+ init_sub_renderer(mpctx);
+
sub_set_video_res(dec_sub, w, h);
sub_set_video_fps(dec_sub, fps);
sub_set_ass_renderer(dec_sub, mpctx->ass_library, mpctx->ass_renderer);
sub_init_from_sh(dec_sub, track->stream);
+ if (mpctx->ass_renderer) {
+ mp_ass_configure_fonts(mpctx->ass_renderer, opts->sub_text_style,
+ mpctx->global, mpctx->ass_log);
+ }
+
// Don't do this if the file has video/audio streams. Don't do it even
// if it has only sub streams, because reading packets will change the
// demuxer position.