summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-12-15 13:43:26 +0100
committerwm4 <wm4@nowhere>2013-12-15 13:44:39 +0100
commit319405830996b2bc73e9cdf437e389f2045adafe (patch)
tree70095e57e72d584d2a1b97dcf64d423e7a019e9a
parent4ca740ccf9314f77078e08f1923d86b060643aa5 (diff)
downloadmpv-319405830996b2bc73e9cdf437e389f2045adafe.tar.bz2
mpv-319405830996b2bc73e9cdf437e389f2045adafe.tar.xz
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.
-rw-r--r--mpvcore/player/loadfile.c16
-rw-r--r--mpvcore/player/main.c2
-rw-r--r--mpvcore/player/mp_core.h5
-rw-r--r--mpvcore/player/sub.c3
-rw-r--r--sub/osd.c3
-rw-r--r--sub/osd.h4
6 files changed, 16 insertions, 17 deletions
diff --git a/mpvcore/player/loadfile.c b/mpvcore/player/loadfile.c
index 33d10ed610..b4e8921089 100644
--- a/mpvcore/player/loadfile.c
+++ b/mpvcore/player/loadfile.c
@@ -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
}
diff --git a/mpvcore/player/main.c b/mpvcore/player/main.c
index 59eadfd676..d95546f923 100644
--- a/mpvcore/player/main.c
+++ b/mpvcore/player/main.c
@@ -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;
diff --git a/mpvcore/player/mp_core.h b/mpvcore/player/mp_core.h
index 9827387e2c..21ce0ba3cb 100644
--- a/mpvcore/player/mp_core.h
+++ b/mpvcore/player/mp_core.h
@@ -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;
diff --git a/mpvcore/player/sub.c b/mpvcore/player/sub.c
index d3ce466121..f514d3345b 100644
--- a/mpvcore/player/sub.c
+++ b/mpvcore/player/sub.c
@@ -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
diff --git a/sub/osd.c b/sub/osd.c
index a1daa1b390..02b28b3885 100644
--- a/sub/osd.c
+++ b/sub/osd.c
@@ -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,
diff --git a/sub/osd.h b/sub/osd.h
index 6399804288..7f8a2f2141 100644
--- a/sub/osd.h
+++ b/sub/osd.h
@@ -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);