From fb563de2550858f9ae6cdb239d44a415e5e91135 Mon Sep 17 00:00:00 2001 From: wm4 Date: Tue, 7 Aug 2012 19:21:46 +0200 Subject: sub: fix confusion of ass_library handles Commit 7484ae8e2ee5327 attempted to introduce two ass_library handles (as it was needed to deal with how ass_library manages fonts), but the commit was completely bogus: it assumed osd_state->ass_library would be used by osd_libass.c only, which is not the case. As result, some of the subtitle code used the wrong ass_library handle. We need two ass_library handles in osd_state. The one from the mplayer core for subtitles (osd_state->ass_library), and one for OSD rendering (osd_state->osd_ass_library). --- sub/osd_libass.c | 14 +++++++------- sub/sub.c | 3 ++- sub/sub.h | 8 +++++--- 3 files changed, 14 insertions(+), 11 deletions(-) (limited to 'sub') 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); -- cgit v1.2.3