summaryrefslogtreecommitdiffstats
path: root/player/sub.c
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 /player/sub.c
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.
Diffstat (limited to 'player/sub.c')
-rw-r--r--player/sub.c21
1 files changed, 14 insertions, 7 deletions
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.