mirror of https://github.com/mpv-player/mpv
sub: fix confusion of ass_library handles
Commit 7484ae8e2e
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).
This commit is contained in:
parent
762ef8d532
commit
fb563de255
|
@ -4286,7 +4286,7 @@ int main(int argc, char *argv[])
|
||||||
mpctx->ass_library = mp_ass_init(opts);
|
mpctx->ass_library = mp_ass_init(opts);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
mpctx->osd = osd_create(opts);
|
mpctx->osd = osd_create(opts, mpctx->ass_library);
|
||||||
|
|
||||||
init_input(mpctx);
|
init_input(mpctx);
|
||||||
|
|
||||||
|
|
|
@ -44,11 +44,11 @@ static const char osd_font_pfb[] =
|
||||||
|
|
||||||
void osd_init_backend(struct osd_state *osd)
|
void osd_init_backend(struct osd_state *osd)
|
||||||
{
|
{
|
||||||
osd->ass_library = mp_ass_init(osd->opts);
|
osd->osd_ass_library = mp_ass_init(osd->opts);
|
||||||
ass_add_font(osd->ass_library, "OSD", (void *)osd_font_pfb,
|
ass_add_font(osd->osd_ass_library, "OSD", (void *)osd_font_pfb,
|
||||||
sizeof(osd_font_pfb) - 1);
|
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);
|
mp_ass_configure_fonts(osd->osd_render);
|
||||||
ass_set_aspect_ratio(osd->osd_render, 1.0, 1.0);
|
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)
|
if (osd->osd_render)
|
||||||
ass_renderer_done(osd->osd_render);
|
ass_renderer_done(osd->osd_render);
|
||||||
osd->osd_render = NULL;
|
osd->osd_render = NULL;
|
||||||
ass_library_done(osd->ass_library);
|
ass_library_done(osd->osd_ass_library);
|
||||||
osd->ass_library = NULL;
|
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)
|
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;
|
ASS_Style *style = track->styles + track->default_style;
|
||||||
|
|
||||||
track->PlayResX = track->PlayResY * 1.33333;
|
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)
|
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;
|
ASS_Style *style = obj->osd_track->styles + obj->osd_track->default_style;
|
||||||
|
|
||||||
|
|
|
@ -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);
|
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);
|
struct osd_state *osd = talloc_zero(NULL, struct osd_state);
|
||||||
*osd = (struct osd_state){
|
*osd = (struct osd_state){
|
||||||
.opts = opts,
|
.opts = opts,
|
||||||
|
.ass_library = asslib,
|
||||||
};
|
};
|
||||||
if(!draw_alpha_init_flag){
|
if(!draw_alpha_init_flag){
|
||||||
draw_alpha_init_flag=1;
|
draw_alpha_init_flag=1;
|
||||||
|
|
|
@ -75,13 +75,15 @@ struct osd_state {
|
||||||
bool ass_force_reload;
|
bool ass_force_reload;
|
||||||
int w, h;
|
int w, h;
|
||||||
char *osd_text;
|
char *osd_text;
|
||||||
struct ass_renderer *osd_render;
|
|
||||||
struct font_desc *sub_font;
|
|
||||||
struct ass_track *ass_track;
|
struct ass_track *ass_track;
|
||||||
double pts;
|
double pts;
|
||||||
double sub_offset;
|
double sub_offset;
|
||||||
bool ass_track_changed;
|
bool ass_track_changed;
|
||||||
bool vsfilter_aspect;
|
bool vsfilter_aspect;
|
||||||
|
|
||||||
|
struct ass_renderer *osd_render;
|
||||||
|
struct ass_library *osd_ass_library;
|
||||||
|
|
||||||
struct MPOpts *opts;
|
struct MPOpts *opts;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -161,7 +163,7 @@ void osd_draw_text_ext(struct osd_state *osd, int dxs, int dys,
|
||||||
int stride),
|
int stride),
|
||||||
void *ctx);
|
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);
|
void osd_set_text(struct osd_state *osd, const char *text);
|
||||||
int osd_update(struct osd_state *osd, int dxs, int dys);
|
int osd_update(struct osd_state *osd, int dxs, int dys);
|
||||||
void vo_osd_changed(int new_value);
|
void vo_osd_changed(int new_value);
|
||||||
|
|
Loading…
Reference in New Issue