diff options
author | wm4 <wm4@nowhere> | 2012-11-05 14:25:04 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2013-01-13 20:04:10 +0100 |
commit | c54fc507da8edcc2c5d3bc3f50b0881d1c1406d7 (patch) | |
tree | 530d112301256e1c3ea50d7bb416b7ba2109130b /video/filter/vf_delogo.c | |
parent | 1c412169aca2f0ad38380b0c89f2485e6a256766 (diff) | |
download | mpv-c54fc507da8edcc2c5d3bc3f50b0881d1c1406d7.tar.bz2 mpv-c54fc507da8edcc2c5d3bc3f50b0881d1c1406d7.tar.xz |
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.
Diffstat (limited to 'video/filter/vf_delogo.c')
-rw-r--r-- | video/filter/vf_delogo.c | 62 |
1 files changed, 15 insertions, 47 deletions
diff --git a/video/filter/vf_delogo.c b/video/filter/vf_delogo.c index f53e5059bd..f709aad4d0 100644 --- a/video/filter/vf_delogo.c +++ b/video/filter/vf_delogo.c @@ -101,7 +101,7 @@ static void update_sub(struct vf_priv_s *p, double pts) } static void delogo(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int width, int height, - int logo_x, int logo_y, int logo_w, int logo_h, int band, int show, int direct) { + int logo_x, int logo_y, int logo_w, int logo_h, int band, int show) { int y, x; int interp, dist; uint8_t *xdst, *xsrc; @@ -124,8 +124,6 @@ static void delogo(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int topright = src+logo_y1*srcStride+logo_x2-1; botleft = src+(logo_y2-1)*srcStride+logo_x1; - if (!direct) memcpy_pic(dst, src, width, height, dstStride, srcStride); - dst += (logo_y1+1)*dstStride; src += (logo_y1+1)*srcStride; @@ -175,55 +173,26 @@ static int config(struct vf_instance *vf, return vf_next_config(vf,width,height,d_width,d_height,flags,outfmt); } - -static void get_image(struct vf_instance *vf, mp_image_t *mpi){ - if(mpi->flags&MP_IMGFLAG_PRESERVE) return; // don't change - if(mpi->imgfmt!=vf->priv->outfmt) return; // colorspace differ - // ok, we can do pp in-place (or pp disabled): - mpi->priv = - vf->dmpi=vf_get_image(vf->next,mpi->imgfmt, - mpi->type, mpi->flags, mpi->w, mpi->h); - mpi->planes[0]=vf->dmpi->planes[0]; - mpi->stride[0]=vf->dmpi->stride[0]; - mpi->width=vf->dmpi->width; - if(mpi->flags&MP_IMGFLAG_PLANAR){ - mpi->planes[1]=vf->dmpi->planes[1]; - mpi->planes[2]=vf->dmpi->planes[2]; - mpi->stride[1]=vf->dmpi->stride[1]; - mpi->stride[2]=vf->dmpi->stride[2]; - } - mpi->flags|=MP_IMGFLAG_DIRECT; -} - -static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts){ - mp_image_t *dmpi; - - if(mpi->flags&MP_IMGFLAG_DIRECT) { - vf->dmpi = mpi->priv; - mpi->priv = NULL; - } else { - // no DR, so get a new image! hope we'll get DR buffer: - vf->dmpi=vf_get_image(vf->next,vf->priv->outfmt, - MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE, - mpi->w,mpi->h); +static struct mp_image *filter(struct vf_instance *vf, struct mp_image *mpi) +{ + struct mp_image *dmpi = mpi; + if (!mp_image_is_writeable(mpi)) { + dmpi = vf_alloc_out_image(vf); + mp_image_copy_attributes(dmpi, mpi); } - dmpi= vf->dmpi; if (vf->priv->timed_rect) - update_sub(vf->priv, pts); + update_sub(vf->priv, dmpi->pts); delogo(dmpi->planes[0], mpi->planes[0], dmpi->stride[0], mpi->stride[0], mpi->w, mpi->h, - vf->priv->xoff, vf->priv->yoff, vf->priv->lw, vf->priv->lh, vf->priv->band, vf->priv->show, - mpi->flags&MP_IMGFLAG_DIRECT); + vf->priv->xoff, vf->priv->yoff, vf->priv->lw, vf->priv->lh, vf->priv->band, vf->priv->show); delogo(dmpi->planes[1], mpi->planes[1], dmpi->stride[1], mpi->stride[1], mpi->w/2, mpi->h/2, - vf->priv->xoff/2, vf->priv->yoff/2, vf->priv->lw/2, vf->priv->lh/2, vf->priv->band/2, vf->priv->show, - mpi->flags&MP_IMGFLAG_DIRECT); + vf->priv->xoff/2, vf->priv->yoff/2, vf->priv->lw/2, vf->priv->lh/2, vf->priv->band/2, vf->priv->show); delogo(dmpi->planes[2], mpi->planes[2], dmpi->stride[2], mpi->stride[2], mpi->w/2, mpi->h/2, - vf->priv->xoff/2, vf->priv->yoff/2, vf->priv->lw/2, vf->priv->lh/2, vf->priv->band/2, vf->priv->show, - mpi->flags&MP_IMGFLAG_DIRECT); - - vf_clone_mpi_attributes(dmpi, mpi); + vf->priv->xoff/2, vf->priv->yoff/2, vf->priv->lw/2, vf->priv->lh/2, vf->priv->band/2, vf->priv->show); - return vf_next_put_image(vf,dmpi, pts); + if (dmpi != mpi) + talloc_free(mpi); + return dmpi; } static void uninit(struct vf_instance *vf){ @@ -323,8 +292,7 @@ load_error: static int vf_open(vf_instance_t *vf, char *args){ vf->config=config; - vf->put_image=put_image; - vf->get_image=get_image; + vf->filter=filter; vf->query_format=query_format; vf->uninit=uninit; |