mirror of
https://github.com/mpv-player/mpv
synced 2025-04-07 01:53:06 +00:00
osd_libass: allocate separate ASS_Library for OSD
osd_libass.c used the same ASS_Library object as the player core. This caused a problem: when playing a new file, all fonts loaded by the ASS_Library object were unloaded, including the OSD font. Parts of the OSD would stop being rendered correctly. Solve this by creating a separate ASS_Library, with its own set of fonts.
This commit is contained in:
parent
0268b1a445
commit
7484ae8e2e
@ -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->ass_library);
|
mpctx->osd = osd_create(opts);
|
||||||
|
|
||||||
init_input(mpctx);
|
init_input(mpctx);
|
||||||
|
|
||||||
|
@ -44,6 +44,7 @@ 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);
|
||||||
ass_add_font(osd->ass_library, "OSD", (void *)osd_font_pfb,
|
ass_add_font(osd->ass_library, "OSD", (void *)osd_font_pfb,
|
||||||
sizeof(osd_font_pfb) - 1);
|
sizeof(osd_font_pfb) - 1);
|
||||||
|
|
||||||
@ -54,9 +55,12 @@ void osd_init_backend(struct osd_state *osd)
|
|||||||
|
|
||||||
void osd_destroy_backend(struct osd_state *osd)
|
void osd_destroy_backend(struct osd_state *osd)
|
||||||
{
|
{
|
||||||
if (osd && osd->osd_render) {
|
if (osd) {
|
||||||
|
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);
|
||||||
|
osd->ass_library = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,6 +36,7 @@
|
|||||||
#include "mp_msg.h"
|
#include "mp_msg.h"
|
||||||
#include "libvo/video_out.h"
|
#include "libvo/video_out.h"
|
||||||
#include "sub.h"
|
#include "sub.h"
|
||||||
|
#include "sub/ass_mp.h"
|
||||||
#include "spudec.h"
|
#include "spudec.h"
|
||||||
|
|
||||||
|
|
||||||
@ -303,12 +304,11 @@ 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 ass_library *asslib)
|
struct osd_state *osd_create(struct MPOpts *opts)
|
||||||
{
|
{
|
||||||
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;
|
||||||
|
@ -161,7 +161,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 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_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
Block a user