diff options
Diffstat (limited to 'libmpcodecs/vf_vo.c')
-rw-r--r-- | libmpcodecs/vf_vo.c | 59 |
1 files changed, 16 insertions, 43 deletions
diff --git a/libmpcodecs/vf_vo.c b/libmpcodecs/vf_vo.c index 0c747beb83..0db75b670e 100644 --- a/libmpcodecs/vf_vo.c +++ b/libmpcodecs/vf_vo.c @@ -35,11 +35,8 @@ struct vf_priv_s { struct vo *vo; -#ifdef CONFIG_ASS - ASS_Renderer *renderer; bool prev_visibility; double scale_ratio; -#endif }; #define video_out (vf->priv->vo) @@ -79,17 +76,10 @@ static int config(struct vf_instance *vf, if (vo_config(video_out, width, height, d_width, d_height, flags, outfmt)) return 0; -#ifdef CONFIG_ASS vf->priv->scale_ratio = (double) d_width / d_height * height / width; - if (vf->priv->renderer) { - mp_ass_configure(vf->priv->renderer, vf->opts, width, height, - vf->default_caps & VFCAP_EOSD_UNSCALED); - } - // force EOSD change detection reset vf->priv->prev_visibility = false; -#endif return 1; } @@ -133,46 +123,33 @@ static int control(struct vf_instance *vf, int request, void *data) return vo_control(video_out, VOCTRL_GET_EQUALIZER, ¶m) == VO_TRUE; } #ifdef CONFIG_ASS - case VFCTRL_INIT_EOSD: - { - vf->priv->renderer = ass_renderer_init(data); - if (!vf->priv->renderer) - return CONTROL_FALSE; - mp_ass_configure_fonts(vf->priv->renderer); + case VFCTRL_INIT_EOSD: { vf->priv->prev_visibility = false; return CONTROL_TRUE; } + case VFCTRL_DRAW_EOSD: { + struct mp_eosd_res dim = { 0 }; + if (!video_out->config_ok || + vo_control(video_out, VOCTRL_GET_EOSD_RES, &dim) != true) { + vf->priv->prev_visibility = false; + return CONTROL_FALSE; + } struct osd_state *osd = data; - mp_eosd_images_t images = {NULL, 2}; - ASS_Renderer *renderer = vf->priv->renderer; - double scale; - if (osd->vsfilter_aspect && vf->opts->ass_vsfilter_aspect_compat) { + mp_eosd_images_t images = { NULL, 2 }; + ASS_Renderer *renderer = osd->ass_renderer; + double scale = 1; + if (osd->vsfilter_aspect && vf->opts->ass_vsfilter_aspect_compat) scale = vf->priv->scale_ratio; - } else { - scale = 1; - } - if (!video_out->config_ok || !renderer) - return CONTROL_FALSE; - if (osd->ass_track_changed) - vf->priv->prev_visibility = false; - osd->ass_track_changed = false; if (sub_visibility && osd->ass_track && (osd->pts != MP_NOPTS_VALUE)) { - struct mp_eosd_res res = { 0 }; - if (vo_control(video_out, VOCTRL_GET_EOSD_RES, &res) == VO_TRUE) { - ass_set_frame_size(renderer, res.w, res.h); - ass_set_margins(renderer, res.mt, res.mb, res.ml, res.mr); - ass_set_aspect_ratio(renderer, scale, 1); - } - - if (osd->ass_force_reload) - mp_ass_reload_options(vf->priv->renderer, vf->opts); + mp_ass_configure(renderer, vf->opts, &dim, + vf->default_caps & VFCAP_EOSD_UNSCALED); + ass_set_aspect_ratio(renderer, scale, 1); images.imgs = ass_render_frame(renderer, osd->ass_track, (osd->pts + sub_delay) * 1000 + .5, &images.changed); - if (!vf->priv->prev_visibility || osd->ass_force_reload) + if (!vf->priv->prev_visibility) images.changed = 2; - osd->ass_force_reload = false; vf->priv->prev_visibility = true; } else vf->priv->prev_visibility = false; @@ -242,10 +219,6 @@ static void uninit(struct vf_instance *vf) /* Allow VO (which may live on to work with another instance of vf_vo) * to get rid of numbered-mpi references that will now be invalid. */ vo_seek_reset(video_out); -#ifdef CONFIG_ASS - if (vf->priv->renderer) - ass_renderer_done(vf->priv->renderer); -#endif free(vf->priv); } } |