From c54fc507da8edcc2c5d3bc3f50b0881d1c1406d7 Mon Sep 17 00:00:00 2001 From: wm4 Date: Mon, 5 Nov 2012 14:25:04 +0100 Subject: video/filter: change filter API, use refcounting, remove filter DR Change the entire filter API to use reference counted images instead of vf_get_image(). Remove filter "direct rendering". This was useful for vf_expand and (in rare cases) vf_sub: DR allowed these filters to pass a cropped image to the filters before them. Then, on filtering, the image was "uncropped", so that black bars could be added around the image without copying. This means that in some cases, vf_expand will be slower (-vf gradfun,expand for example). Note that another form of DR used for in-place filters has been replaced by simpler logic. Instead of trying to do DR, filters can check if the image is writeable (with mp_image_is_writeable()), and do true in-place if that's the case. This affects filters like vf_gradfun and vf_sub. Everything has to support strides now. If something doesn't, making a copy of the image data is required. --- video/filter/vf_yadif.c | 50 ++++++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 25 deletions(-) (limited to 'video/filter/vf_yadif.c') diff --git a/video/filter/vf_yadif.c b/video/filter/vf_yadif.c index 1158cffbbf..4e53ef168c 100644 --- a/video/filter/vf_yadif.c +++ b/video/filter/vf_yadif.c @@ -394,11 +394,11 @@ static int config(struct vf_instance *vf, return vf_next_config(vf,width,height,d_width,d_height,flags,outfmt); } -static int continue_buffered_image(struct vf_instance *vf); +static int continue_buffered_image(struct vf_instance *vf, struct mp_image *mpi); -static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts){ +static int filter_image(struct vf_instance *vf, struct mp_image *mpi) +{ int tff; - if(vf->priv->parity < 0) { if (mpi->fields & MP_IMGFIELD_ORDERED) tff = !!(mpi->fields & MP_IMGFIELD_TOP_FIRST); @@ -414,47 +414,47 @@ static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts){ if (vf->priv->buffered_pts == MP_NOPTS_VALUE) delta = 1001.0/60000.0; // delta = field time distance else - delta = (pts - vf->priv->buffered_pts) / 2; + delta = (mpi->pts - vf->priv->buffered_pts) / 2; if (delta <= 0.0 || delta >= 0.5) delta = 0.0; vf->priv->buffered_pts_delta = delta; } - vf->priv->buffered_mpi = mpi; vf->priv->buffered_tff = tff; vf->priv->buffered_i = 0; - vf->priv->buffered_pts = pts; - - if(vf->priv->do_deinterlace == 0) - return vf_next_put_image(vf, mpi, pts); - else if(vf->priv->do_deinterlace == 1){ - vf->priv->do_deinterlace= 2; - return 0; - }else - return continue_buffered_image(vf); + vf->priv->buffered_pts = mpi->pts; + + if (vf->priv->do_deinterlace == 0) { + vf_add_output_frame(vf, mpi); + mpi = NULL; + } else if (vf->priv->do_deinterlace == 1) { + vf->priv->do_deinterlace = 2; + } else { + while (continue_buffered_image(vf, mpi)) { + } + } + + talloc_free(mpi); + + return 0; } -static int continue_buffered_image(struct vf_instance *vf) +static int continue_buffered_image(struct vf_instance *vf, struct mp_image *mpi) { - mp_image_t *mpi = vf->priv->buffered_mpi; int tff = vf->priv->buffered_tff; double pts = vf->priv->buffered_pts; int i; int ret=0; - mp_image_t *dmpi; pts += (vf->priv->buffered_i - 0.5 * (vf->priv->mode&1)) * vf->priv->buffered_pts_delta; for(i = vf->priv->buffered_i; i<=(vf->priv->mode&1); i++){ - dmpi=vf_get_image(vf->next,mpi->imgfmt, - MP_IMGTYPE_TEMP, - MP_IMGFLAG_ACCEPT_STRIDE|MP_IMGFLAG_PREFER_ALIGNED_STRIDE, - mpi->width,mpi->height); - vf_clone_mpi_attributes(dmpi, mpi); + struct mp_image *dmpi = vf_alloc_out_image(vf); + mp_image_copy_attributes(dmpi, mpi); filter(vf->priv, dmpi->planes, dmpi->stride, mpi->w, mpi->h, i ^ tff ^ 1, tff); if (i < (vf->priv->mode & 1)) - vf_queue_frame(vf, continue_buffered_image); - ret |= vf_next_put_image(vf, dmpi, pts); + ret = 1; // more images to come + vf_add_output_frame(vf, dmpi); break; } vf->priv->buffered_i = 1; @@ -502,7 +502,7 @@ static int control(struct vf_instance *vf, int request, void* data){ static int vf_open(vf_instance_t *vf, char *args){ vf->config=config; - vf->put_image=put_image; + vf->filter_ext=filter_image; vf->query_format=query_format; vf->uninit=uninit; vf->priv=malloc(sizeof(struct vf_priv_s)); -- cgit v1.2.3