summaryrefslogtreecommitdiffstats
path: root/libmpcodecs
diff options
context:
space:
mode:
Diffstat (limited to 'libmpcodecs')
-rw-r--r--libmpcodecs/vf_ass.c43
-rw-r--r--libmpcodecs/vf_vo.c59
2 files changed, 30 insertions, 72 deletions
diff --git a/libmpcodecs/vf_ass.c b/libmpcodecs/vf_ass.c
index f7e3e62ec0..a346f658cf 100644
--- a/libmpcodecs/vf_ass.c
+++ b/libmpcodecs/vf_ass.c
@@ -62,9 +62,7 @@ static const struct vf_priv_s {
int auto_insert;
struct osd_state *osd;
- ASS_Renderer *renderer;
-
- double realaspect;
+ double aspect_correction;
unsigned char *planes[3];
struct line_limits {
@@ -93,11 +91,7 @@ static int config(struct vf_instance *vf,
vf->priv->planes[2] = malloc(vf->priv->outw * vf->priv->outh);
vf->priv->line_limits = malloc((vf->priv->outh + 1) / 2 * sizeof(*vf->priv->line_limits));
- if (vf->priv->renderer) {
- mp_ass_configure(vf->priv->renderer, opts,
- vf->priv->outw, vf->priv->outh, 0);
- vf->priv->realaspect = (double)width / height * d_height / d_width;
- }
+ vf->priv->aspect_correction = (double)width / height * d_height / d_width;
return vf_next_config(vf, vf->priv->outw, vf->priv->outh, d_width,
d_height, flags, outfmt);
@@ -360,22 +354,21 @@ 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;
- double scale = osd->vsfilter_aspect
- && vf->opts->ass_vsfilter_aspect_compat
- ? 1 : vf->priv->realaspect;
- if (sub_visibility && vf->priv->renderer && osd->ass_track
- && (pts != MP_NOPTS_VALUE)) {
- ass_set_aspect_ratio(vf->priv->renderer, scale, 1);
- if (osd->ass_force_reload)
- mp_ass_reload_options(vf->priv->renderer, vf->opts);
- osd->ass_force_reload = false;
- images = ass_render_frame(vf->priv->renderer, osd->ass_track,
+ ASS_Renderer *renderer = osd->ass_renderer;
+ bool vs = osd->vsfilter_aspect && vf->opts->ass_vsfilter_aspect_compat;
+ if (sub_visibility && osd->ass_track && (pts != MP_NOPTS_VALUE)) {
+ struct mp_eosd_res dim = { .w = vf->priv->outw, .h = vf->priv->outh,
+ .mt = vf->opts->ass_top_margin,
+ .mb = vf->opts->ass_bottom_margin };
+ mp_ass_configure(renderer, vf->opts, &dim, 0);
+ ass_set_aspect_ratio(renderer,
+ vs ? 1. : vf->priv->aspect_correction, 1);
+ images = ass_render_frame(renderer, osd->ass_track,
(pts - osd->sub_offset + sub_delay) * 1000 + .5, NULL);
}
prepare_image(vf, mpi);
- if (images)
- render_frame(vf, mpi, images);
+ render_frame(vf, mpi, images);
return vf_next_put_image(vf, vf->dmpi, pts);
}
@@ -398,23 +391,15 @@ static int control(vf_instance_t *vf, int request, void *data)
vf->priv->osd = data;
break;
case VFCTRL_INIT_EOSD:
- vf->priv->renderer = ass_renderer_init((ASS_Library *)data);
- if (!vf->priv->renderer)
- return CONTROL_FALSE;
- mp_ass_configure_fonts(vf->priv->renderer);
return CONTROL_TRUE;
case VFCTRL_DRAW_EOSD:
- if (vf->priv->renderer)
- return CONTROL_TRUE;
- break;
+ return CONTROL_TRUE;
}
return vf_next_control(vf, request, data);
}
static void uninit(struct vf_instance *vf)
{
- if (vf->priv->renderer)
- ass_renderer_done(vf->priv->renderer);
free(vf->priv->planes[1]);
free(vf->priv->planes[2]);
free(vf->priv->line_limits);
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, &param) == 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);
}
}