1
0
mirror of https://github.com/mpv-player/mpv synced 2025-03-20 02:09:52 +00:00

player: don't store subtitle renderer in osd_state

This doesn't have much value. It can't be accessed by anything else than
the actual subtitle renderer (sd_ass.c). sd_ass.c could create the
renderer itself, except that we apparently want to save memory (and some
font loading time) when using ordered chapters or multiple subtitle
tracks.
This commit is contained in:
wm4 2013-12-15 13:43:26 +01:00
parent 4ca740ccf9
commit 3194058309
6 changed files with 16 additions and 17 deletions

View File

@ -91,9 +91,9 @@ void uninit_player(struct MPContext *mpctx, unsigned int mask)
if (mask & INITIALIZED_LIBASS) {
mpctx->initialized_flags &= ~INITIALIZED_LIBASS;
#if HAVE_LIBASS
if (mpctx->osd->ass_renderer)
ass_renderer_done(mpctx->osd->ass_renderer);
mpctx->osd->ass_renderer = NULL;
if (mpctx->ass_renderer)
ass_renderer_done(mpctx->ass_renderer);
mpctx->ass_renderer = NULL;
ass_clear_fonts(mpctx->ass_library);
#endif
}
@ -847,13 +847,11 @@ static void init_sub_renderer(struct MPContext *mpctx)
{
#if HAVE_LIBASS
assert(!(mpctx->initialized_flags & INITIALIZED_LIBASS));
assert(!mpctx->osd->ass_renderer);
assert(!mpctx->ass_renderer);
mpctx->osd->ass_renderer = ass_renderer_init(mpctx->osd->ass_library);
if (mpctx->osd->ass_renderer) {
mp_ass_configure_fonts(mpctx->osd->ass_renderer,
mpctx->opts->sub_text_style);
}
mpctx->ass_renderer = ass_renderer_init(mpctx->ass_library);
if (mpctx->ass_renderer)
mp_ass_configure_fonts(mpctx->ass_renderer, mpctx->opts->sub_text_style);
mpctx->initialized_flags |= INITIALIZED_LIBASS;
#endif
}

View File

@ -397,7 +397,7 @@ static int mpv_main(int argc, char *argv[])
MP_WARN(mpctx, "There will be no OSD and no text subtitles.\n");
#endif
mpctx->osd = osd_create(opts, mpctx->ass_library);
mpctx->osd = osd_create(opts);
if (opts->force_vo) {
opts->fixed_vo = 1;

View File

@ -308,6 +308,11 @@ typedef struct MPContext {
int last_chapter_seek;
double last_chapter_pts;
/* Subtitle renderer. This is separate, because we want to keep fonts
* loaded across ordered chapters, instead of reloading and rescanning
* them on each transition. (Both of these objects contain this state.)
*/
struct ass_renderer *ass_renderer;
struct ass_library *ass_library;
int last_dvb_step;

View File

@ -211,8 +211,7 @@ void reinit_subs(struct MPContext *mpctx)
set_dvdsub_fake_extradata(dec_sub, track->demuxer->stream, w, h);
sub_set_video_res(dec_sub, w, h);
sub_set_video_fps(dec_sub, fps);
sub_set_ass_renderer(dec_sub, mpctx->osd->ass_library,
mpctx->osd->ass_renderer);
sub_set_ass_renderer(dec_sub, mpctx->ass_library, mpctx->ass_renderer);
sub_init_from_sh(dec_sub, sh);
// Don't do this if the file has video/audio streams. Don't do it even

View File

@ -79,12 +79,11 @@ static bool osd_res_equals(struct mp_osd_res a, struct mp_osd_res b)
&& a.display_par == b.display_par;
}
struct osd_state *osd_create(struct MPOpts *opts, struct ass_library *asslib)
struct osd_state *osd_create(struct MPOpts *opts)
{
struct osd_state *osd = talloc_zero(NULL, struct osd_state);
*osd = (struct osd_state) {
.opts = opts,
.ass_library = asslib,
.osd_text = talloc_strdup(osd, ""),
.sub_text = talloc_strdup(osd, ""),
.progbar_type = -1,

View File

@ -122,8 +122,6 @@ struct osd_object {
struct osd_state {
struct osd_object *objs[MAX_OSD_PARTS];
struct ass_library *ass_library;
struct ass_renderer *ass_renderer;
double video_offset;
double vo_pts;
@ -206,7 +204,7 @@ struct osd_style_opts {
extern const struct m_sub_options osd_style_conf;
struct osd_state *osd_create(struct MPOpts *opts, struct ass_library *asslib);
struct osd_state *osd_create(struct MPOpts *opts);
void osd_set_text(struct osd_state *osd, const char *text);
void osd_set_sub(struct osd_state *osd, const char *text);
void osd_changed(struct osd_state *osd, int new_value);