diff options
Diffstat (limited to 'libmpcodecs')
-rw-r--r-- | libmpcodecs/vf.h | 9 | ||||
-rw-r--r-- | libmpcodecs/vf_ass.c | 50 | ||||
-rw-r--r-- | libmpcodecs/vf_expand.c | 2 | ||||
-rw-r--r-- | libmpcodecs/vf_vo.c | 78 |
4 files changed, 91 insertions, 48 deletions
diff --git a/libmpcodecs/vf.h b/libmpcodecs/vf.h index 0d10abd6c6..58cfaaf787 100644 --- a/libmpcodecs/vf.h +++ b/libmpcodecs/vf.h @@ -20,6 +20,7 @@ #define MPLAYER_VF_H #include "mp_image.h" +#include "mpcommon.h" struct MPOpts; struct vf_instance; @@ -107,8 +108,8 @@ typedef struct vf_seteq_s #define VFCTRL_DRAW_EOSD 16 /* Render EOSD */ #define VFCTRL_SET_DEINTERLACE 18 /* Set deinterlacing status */ #define VFCTRL_GET_DEINTERLACE 19 /* Get deinterlacing status */ -/* Hack to make the OSD state object available to vf_expand which accesses - * the OSD state outside of normal OSD draw time. */ +/* Hack to make the OSD state object available to vf_expand and vf_ass which + * access OSD/subtitle state outside of normal OSD draw time. */ #define VFCTRL_SET_OSD_OBJ 20 #define VFCTRL_REDRAW_OSD 21 /* Change user-visible OSD immediately */ #define VFCTRL_SET_YUV_COLORSPACE 22 @@ -116,10 +117,6 @@ typedef struct vf_seteq_s #include "vfcap.h" -//FIXME this should be in a common header, but i dunno which -#define MP_NOPTS_VALUE (-1LL<<63) //both int64_t and double should be able to represent this exactly - - // functions: void vf_mpi_clear(mp_image_t* mpi,int x0,int y0,int w,int h); mp_image_t* vf_get_image(vf_instance_t* vf, unsigned int outfmt, int mp_imgtype, int mp_imgflag, int w, int h); diff --git a/libmpcodecs/vf_ass.c b/libmpcodecs/vf_ass.c index 2678986025..4047316a50 100644 --- a/libmpcodecs/vf_ass.c +++ b/libmpcodecs/vf_ass.c @@ -33,13 +33,14 @@ #include "img_format.h" #include "mp_image.h" #include "vf.h" +#include "sub/sub.h" #include "libvo/fastmemcpy.h" #include "m_option.h" #include "m_struct.h" -#include "ass_mp.h" +#include "sub/ass_mp.h" #define _r(c) ((c)>>24) #define _g(c) (((c)>>16)&0xFF) @@ -59,7 +60,9 @@ static const struct vf_priv_s { // 0 = insert always int auto_insert; - ASS_Renderer *ass_priv; + struct osd_state *osd; + ASS_Renderer *renderer_realaspect; + ASS_Renderer *renderer_vsfilter; unsigned char *planes[3]; struct line_limits { @@ -68,9 +71,7 @@ static const struct vf_priv_s { } *line_limits; } vf_priv_dflt; -extern ASS_Track *ass_track; extern float sub_delay; -extern int sub_visibility; static int config(struct vf_instance *vf, int width, int height, int d_width, int d_height, @@ -92,9 +93,14 @@ 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->ass_priv) { - ass_configure(vf->priv->ass_priv, vf->priv->outw, vf->priv->outh, 0); - ass_set_aspect_ratio(vf->priv->ass_priv, 1, 1); + if (vf->priv->renderer_realaspect) { + mp_ass_configure(vf->priv->renderer_realaspect, + vf->priv->outw, vf->priv->outh, 0); + mp_ass_configure(vf->priv->renderer_vsfilter, + vf->priv->outw, vf->priv->outh, 0); + ass_set_aspect_ratio(vf->priv->renderer_realaspect, + (double)width / height * d_height / d_width, 1); + ass_set_aspect_ratio(vf->priv->renderer_vsfilter, 1, 1); } return vf_next_config(vf, vf->priv->outw, vf->priv->outh, d_width, @@ -351,9 +357,12 @@ 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) { ASS_Image *images = 0; - if (sub_visibility && vf->priv->ass_priv && ass_track + ASS_Renderer *renderer = vf->priv->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 = ass_mp_render_frame(vf->priv->ass_priv, ass_track, + images = mp_ass_render_frame(renderer, + vf->priv->osd->ass_track, (pts + sub_delay) * 1000 + .5, NULL); prepare_image(vf, mpi); @@ -377,14 +386,23 @@ static int query_format(struct vf_instance *vf, unsigned int fmt) static int control(vf_instance_t *vf, int request, void *data) { switch (request) { + case VFCTRL_SET_OSD_OBJ: + vf->priv->osd = data; + break; case VFCTRL_INIT_EOSD: - vf->priv->ass_priv = ass_renderer_init((ASS_Library *)data); - if (!vf->priv->ass_priv) + vf->priv->renderer_realaspect = ass_renderer_init((ASS_Library *)data); + if (!vf->priv->renderer_realaspect) + return CONTROL_FALSE; + vf->priv->renderer_vsfilter = ass_renderer_init((ASS_Library *)data); + if (!vf->priv->renderer_vsfilter) { + ass_renderer_done(vf->priv->renderer_realaspect); return CONTROL_FALSE; - ass_configure_fonts(vf->priv->ass_priv); + } + mp_ass_configure_fonts(vf->priv->renderer_realaspect); + mp_ass_configure_fonts(vf->priv->renderer_vsfilter); return CONTROL_TRUE; case VFCTRL_DRAW_EOSD: - if (vf->priv->ass_priv) + if (vf->priv->renderer_realaspect) return CONTROL_TRUE; break; } @@ -393,8 +411,10 @@ static int control(vf_instance_t *vf, int request, void *data) static void uninit(struct vf_instance *vf) { - if (vf->priv->ass_priv) - ass_renderer_done(vf->priv->ass_priv); + if (vf->priv->renderer_realaspect) { + ass_renderer_done(vf->priv->renderer_realaspect); + ass_renderer_done(vf->priv->renderer_vsfilter); + } free(vf->priv->planes[1]); free(vf->priv->planes[2]); free(vf->priv->line_limits); diff --git a/libmpcodecs/vf_expand.c b/libmpcodecs/vf_expand.c index 57226acb93..95580b9f26 100644 --- a/libmpcodecs/vf_expand.c +++ b/libmpcodecs/vf_expand.c @@ -35,7 +35,7 @@ #include "libavutil/avutil.h" #ifdef OSD_SUPPORT -#include "libvo/sub.h" +#include "sub/sub.h" #include "libvo/osd.h" #endif diff --git a/libmpcodecs/vf_vo.c b/libmpcodecs/vf_vo.c index 0e8563d5a6..8bbaf465b3 100644 --- a/libmpcodecs/vf_vo.c +++ b/libmpcodecs/vf_vo.c @@ -29,21 +29,19 @@ #include "libvo/video_out.h" -#ifdef CONFIG_ASS -#include "ass_mp.h" -extern ASS_Track *ass_track; -#endif +#include "sub/ass_mp.h" +#include "sub/sub.h" //===========================================================================// -extern int sub_visibility; extern float sub_delay; struct vf_priv_s { struct vo *vo; #ifdef CONFIG_ASS - ASS_Renderer *ass_priv; - int prev_visibility; + ASS_Renderer *renderer_realaspect; + ASS_Renderer *renderer_vsfilter; + bool prev_visibility; double scale_ratio; #endif }; @@ -86,8 +84,12 @@ static int config(struct vf_instance *vf, #ifdef CONFIG_ASS vf->priv->scale_ratio = (double) d_width / d_height * height / width; - if (vf->priv->ass_priv) - ass_configure(vf->priv->ass_priv, width, height, !!(vf->default_caps & VFCAP_EOSD_UNSCALED)); + if (vf->priv->renderer_realaspect) { + mp_ass_configure(vf->priv->renderer_realaspect, width, height, + vf->default_caps & VFCAP_EOSD_UNSCALED); + mp_ass_configure(vf->priv->renderer_vsfilter, width, height, + vf->default_caps & VFCAP_EOSD_UNSCALED); + } #endif return 1; @@ -133,33 +135,55 @@ static int control(struct vf_instance *vf, int request, void* data) #ifdef CONFIG_ASS case VFCTRL_INIT_EOSD: { - vf->priv->ass_priv = ass_renderer_init((ASS_Library*)data); - if (!vf->priv->ass_priv) return CONTROL_FALSE; - ass_configure_fonts(vf->priv->ass_priv); - vf->priv->prev_visibility = 0; + vf->priv->renderer_realaspect = ass_renderer_init(data); + if (!vf->priv->renderer_realaspect) + return CONTROL_FALSE; + vf->priv->renderer_vsfilter = ass_renderer_init(data); + if (!vf->priv->renderer_vsfilter) { + ass_renderer_done(vf->priv->renderer_realaspect); + return CONTROL_FALSE; + } + mp_ass_configure_fonts(vf->priv->renderer_realaspect); + mp_ass_configure_fonts(vf->priv->renderer_vsfilter); + vf->priv->prev_visibility = false; return CONTROL_TRUE; } case VFCTRL_DRAW_EOSD: { + struct osd_state *osd = data; mp_eosd_images_t images = {NULL, 2}; double pts = video_out->next_pts; - if (!video_out->config_ok || !vf->priv->ass_priv) return CONTROL_FALSE; - if (sub_visibility && vf->priv->ass_priv && ass_track && (pts != MP_NOPTS_VALUE)) { - mp_eosd_res_t res; - memset(&res, 0, sizeof(res)); + ASS_Renderer *renderer; + double scale; + if (osd->vsfilter_aspect) { + renderer = vf->priv->renderer_vsfilter; + scale = vf->priv->scale_ratio; + } else { + renderer = vf->priv->renderer_realaspect; + 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 && (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(vf->priv->ass_priv, res.w, res.h); - ass_set_margins(vf->priv->ass_priv, res.mt, res.mb, res.ml, res.mr); - ass_set_aspect_ratio(vf->priv->ass_priv, vf->priv->scale_ratio, 1); + 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); } - images.imgs = ass_mp_render_frame(vf->priv->ass_priv, ass_track, (pts+sub_delay) * 1000 + .5, &images.changed); + images.imgs = mp_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 = 1; + vf->priv->prev_visibility = true; } else - vf->priv->prev_visibility = 0; - vf->priv->prev_visibility = sub_visibility; + vf->priv->prev_visibility = false; return vo_control(video_out, VOCTRL_DRAW_EOSD, &images) == VO_TRUE; } #endif @@ -223,8 +247,10 @@ static void uninit(struct vf_instance *vf) * to get rid of numbered-mpi references that will now be invalid. */ vo_seek_reset(video_out); #ifdef CONFIG_ASS - if (vf->priv->ass_priv) - ass_renderer_done(vf->priv->ass_priv); + if (vf->priv->renderer_realaspect) { + ass_renderer_done(vf->priv->renderer_realaspect); + ass_renderer_done(vf->priv->renderer_vsfilter); + } #endif free(vf->priv); } |