1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-26 00:42:57 +00:00

cleanup: move global ass_force_reload to struct osd_state

This commit is contained in:
Uoti Urpala 2011-08-08 05:59:23 +03:00
parent d843c9ca38
commit 9920d64650
6 changed files with 27 additions and 27 deletions

View File

@ -1968,7 +1968,7 @@ static int mp_property_ass_use_margins(m_option_t *prop, int action,
return M_PROPERTY_ERROR;
case M_PROPERTY_STEP_UP:
case M_PROPERTY_STEP_DOWN:
ass_force_reload = 1;
mpctx->osd->ass_force_reload = true;
default:
return m_property_flag(prop, action, arg, &ass_use_margins);
}
@ -2012,7 +2012,7 @@ static int mp_property_sub_scale(m_option_t *prop, int action, void *arg,
#ifdef CONFIG_ASS
if (opts->ass_enabled) {
ass_font_scale = *(float *) arg;
ass_force_reload = 1;
mpctx->osd->ass_force_reload = true;
}
#endif
text_font_scale_factor = *(float *) arg;
@ -2026,7 +2026,7 @@ static int mp_property_sub_scale(m_option_t *prop, int action, void *arg,
ass_font_scale += (arg ? *(float *) arg : 0.1) *
(action == M_PROPERTY_STEP_UP ? 1.0 : -1.0);
M_PROPERTY_CLAMP(prop, ass_font_scale);
ass_force_reload = 1;
mpctx->osd->ass_force_reload = true;
}
#endif
text_font_scale_factor += (arg ? *(float *) arg : 0.1) *

View File

@ -356,14 +356,16 @@ static int render_frame(struct vf_instance *vf, mp_image_t *mpi,
static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts)
{
struct osd_state *osd = vf->priv->osd;
ASS_Image *images = 0;
ASS_Renderer *renderer = vf->priv->osd->vsfilter_aspect ?
ASS_Renderer *renderer = osd->vsfilter_aspect ?
vf->priv->renderer_vsfilter : vf->priv->renderer_realaspect;
if (sub_visibility && renderer && vf->priv->osd->ass_track
&& (pts != MP_NOPTS_VALUE))
images = mp_ass_render_frame(renderer,
vf->priv->osd->ass_track,
if (sub_visibility && renderer && osd->ass_track
&& (pts != MP_NOPTS_VALUE)) {
mp_ass_reload_options(renderer, vf->opts, &osd->ass_force_reload);
images = ass_render_frame(renderer, osd->ass_track,
(pts + sub_delay) * 1000 + .5, NULL);
}
prepare_image(vf, mpi);
if (images)

View File

@ -175,8 +175,8 @@ static int control(struct vf_instance *vf, int request, void* data)
ass_set_aspect_ratio(renderer, scale, 1);
}
images.imgs = mp_ass_render_frame(renderer,
osd->ass_track,
mp_ass_reload_options(renderer, vf->opts, &osd->ass_force_reload);
images.imgs = ass_render_frame(renderer, osd->ass_track,
(pts+sub_delay) * 1000 + .5,
&images.changed);
if (!vf->priv->prev_visibility)

View File

@ -316,16 +316,13 @@ ASS_Library *mp_ass_init(void)
return priv;
}
int ass_force_reload = 0; // flag set if global ass-related settings were changed
ASS_Image *mp_ass_render_frame(ASS_Renderer *priv, ASS_Track *track,
long long now, int *detect_change)
void mp_ass_reload_options(ASS_Renderer *priv, struct MPOpts *opts,
bool *need_reload)
{
if (ass_force_reload) {
if (!*need_reload)
return;
ass_set_margins(priv, ass_top_margin, ass_bottom_margin, 0, 0);
ass_set_use_margins(priv, ass_use_margins);
ass_set_font_scale(priv, ass_font_scale);
ass_force_reload = 0;
}
return ass_render_frame(priv, track, now, detect_change);
*need_reload = false;
}

View File

@ -52,9 +52,8 @@ void mp_ass_configure(ASS_Renderer *priv, int w, int h, bool unscaled);
void mp_ass_configure_fonts(ASS_Renderer *priv);
ASS_Library *mp_ass_init(void);
extern int ass_force_reload;
ASS_Image *mp_ass_render_frame(ASS_Renderer *priv, ASS_Track *track,
long long now, int *detect_change);
void mp_ass_reload_options(ASS_Renderer *priv, struct MPOpts *opts,
bool *need_reload);
#else /* CONFIG_ASS */

View File

@ -70,6 +70,8 @@ typedef struct mp_osd_obj_s {
struct osd_state {
struct ass_library *ass_library;
// flag to signal reinitialization due to ass-related option changes
bool ass_force_reload;
unsigned char osd_text[128];
struct font_desc *sub_font;
struct ass_track *ass_track;