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.