diff --git a/mplayer.c b/mplayer.c index a7b76b63cd..f99b645494 100644 --- a/mplayer.c +++ b/mplayer.c @@ -4286,7 +4286,7 @@ int main(int argc, char *argv[]) mpctx->ass_library = mp_ass_init(opts); #endif - mpctx->osd = osd_create(opts); + mpctx->osd = osd_create(opts, mpctx->ass_library); init_input(mpctx); diff --git a/sub/osd_libass.c b/sub/osd_libass.c index 3f6564fbca..3e6c9a872a 100644 --- a/sub/osd_libass.c +++ b/sub/osd_libass.c @@ -44,11 +44,11 @@ static const char osd_font_pfb[] = void osd_init_backend(struct osd_state *osd) { - osd->ass_library = mp_ass_init(osd->opts); - ass_add_font(osd->ass_library, "OSD", (void *)osd_font_pfb, + osd->osd_ass_library = mp_ass_init(osd->opts); + ass_add_font(osd->osd_ass_library, "OSD", (void *)osd_font_pfb, sizeof(osd_font_pfb) - 1); - osd->osd_render = ass_renderer_init(osd->ass_library); + osd->osd_render = ass_renderer_init(osd->osd_ass_library); mp_ass_configure_fonts(osd->osd_render); ass_set_aspect_ratio(osd->osd_render, 1.0, 1.0); } @@ -59,8 +59,8 @@ void osd_destroy_backend(struct osd_state *osd) if (osd->osd_render) ass_renderer_done(osd->osd_render); osd->osd_render = NULL; - ass_library_done(osd->ass_library); - osd->ass_library = NULL; + ass_library_done(osd->osd_ass_library); + osd->osd_ass_library = NULL; } } @@ -185,7 +185,7 @@ static void update_font_scale(ASS_Track *track, ASS_Style *style, double factor) static ASS_Track *create_osd_ass_track(struct osd_state *osd) { - ASS_Track *track = mp_ass_default_track(osd->ass_library, osd->opts); + ASS_Track *track = mp_ass_default_track(osd->osd_ass_library, osd->opts); ASS_Style *style = track->styles + track->default_style; track->PlayResX = track->PlayResY * 1.33333; @@ -344,7 +344,7 @@ void vo_update_text_sub(struct osd_state *osd, mp_osd_obj_t* obj) } if (!obj->osd_track) - obj->osd_track = mp_ass_default_track(osd->ass_library, osd->opts); + obj->osd_track = mp_ass_default_track(osd->osd_ass_library, osd->opts); ASS_Style *style = obj->osd_track->styles + obj->osd_track->default_style; diff --git a/sub/sub.c b/sub/sub.c index 056d03d1e5..52c79c1d40 100644 --- a/sub/sub.c +++ b/sub/sub.c @@ -304,11 +304,12 @@ int osd_update(struct osd_state *osd, int dxs, int dys) return osd_update_ext(osd, dxs, dys, 0, 0, 0, 0, dxs, dys); } -struct osd_state *osd_create(struct MPOpts *opts) +struct osd_state *osd_create(struct MPOpts *opts, struct ass_library *asslib) { struct osd_state *osd = talloc_zero(NULL, struct osd_state); *osd = (struct osd_state){ .opts = opts, + .ass_library = asslib, }; if(!draw_alpha_init_flag){ draw_alpha_init_flag=1; diff --git a/sub/sub.h b/sub/sub.h index 2c4117a92a..3390f7fa18 100644 --- a/sub/sub.h +++ b/sub/sub.h @@ -75,13 +75,15 @@ struct osd_state { bool ass_force_reload; int w, h; char *osd_text; - struct ass_renderer *osd_render; - struct font_desc *sub_font; struct ass_track *ass_track; double pts; double sub_offset; bool ass_track_changed; bool vsfilter_aspect; + + struct ass_renderer *osd_render; + struct ass_library *osd_ass_library; + struct MPOpts *opts; }; @@ -161,7 +163,7 @@ void osd_draw_text_ext(struct osd_state *osd, int dxs, int dys, int stride), void *ctx); -struct osd_state *osd_create(struct MPOpts *opts); +struct osd_state *osd_create(struct MPOpts *opts, struct ass_library *asslib); void osd_set_text(struct osd_state *osd, const char *text); int osd_update(struct osd_state *osd, int dxs, int dys); void vo_osd_changed(int new_value);