diff options
-rw-r--r-- | command.c | 6 | ||||
-rw-r--r-- | libmpcodecs/vf_ass.c | 14 | ||||
-rw-r--r-- | libmpcodecs/vf_vo.c | 8 | ||||
-rw-r--r-- | sub/ass_mp.c | 19 | ||||
-rw-r--r-- | sub/ass_mp.h | 5 | ||||
-rw-r--r-- | sub/sub.h | 2 |
6 files changed, 27 insertions, 27 deletions
@@ -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) * diff --git a/libmpcodecs/vf_ass.c b/libmpcodecs/vf_ass.c index 4047316a50..a3a47f6b9e 100644 --- a/libmpcodecs/vf_ass.c +++ b/libmpcodecs/vf_ass.c @@ -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, - (pts + sub_delay) * 1000 + .5, NULL); + 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) diff --git a/libmpcodecs/vf_vo.c b/libmpcodecs/vf_vo.c index 8bbaf465b3..8f2f541fb4 100644 --- a/libmpcodecs/vf_vo.c +++ b/libmpcodecs/vf_vo.c @@ -175,10 +175,10 @@ 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, - (pts+sub_delay) * 1000 + .5, - &images.changed); + 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) images.changed = 2; vf->priv->prev_visibility = true; diff --git a/sub/ass_mp.c b/sub/ass_mp.c index 9a7b89a1ed..94c17b83f0 100644 --- a/sub/ass_mp.c +++ b/sub/ass_mp.c @@ -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) { - 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); + 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); + *need_reload = false; } diff --git a/sub/ass_mp.h b/sub/ass_mp.h index 0e60b71103..02c55c8a12 100644 --- a/sub/ass_mp.h +++ b/sub/ass_mp.h @@ -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 */ @@ -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; |