summaryrefslogtreecommitdiffstats
path: root/video/filter/vf_flip.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2012-11-05 14:25:04 +0100
committerwm4 <wm4@nowhere>2013-01-13 20:04:10 +0100
commitc54fc507da8edcc2c5d3bc3f50b0881d1c1406d7 (patch)
tree530d112301256e1c3ea50d7bb416b7ba2109130b /video/filter/vf_flip.c
parent1c412169aca2f0ad38380b0c89f2485e6a256766 (diff)
downloadmpv-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_flip.c')
-rw-r--r--video/filter/vf_flip.c61
1 files changed, 12 insertions, 49 deletions
diff --git a/video/filter/vf_flip.c b/video/filter/vf_flip.c
index d5792f27ca..49d6993023 100644
--- a/video/filter/vf_flip.c
+++ b/video/filter/vf_flip.c
@@ -37,64 +37,27 @@ 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_ACCEPT_STRIDE){
- // try full DR !
- vf->dmpi=vf_get_image(vf->next,mpi->imgfmt,
- mpi->type, mpi->flags, mpi->width, mpi->height);
- // set up mpi as a upside-down image of dmpi:
- mpi->planes[0]=vf->dmpi->planes[0]+
- vf->dmpi->stride[0]*(vf->dmpi->height-1);
- mpi->stride[0]=-vf->dmpi->stride[0];
- if(mpi->flags&MP_IMGFLAG_PLANAR){
- mpi->planes[1]=vf->dmpi->planes[1]+
- vf->dmpi->stride[1]*((vf->dmpi->height>>mpi->chroma_y_shift)-1);
- mpi->stride[1]=-vf->dmpi->stride[1];
- mpi->planes[2]=vf->dmpi->planes[2]+
- vf->dmpi->stride[2]*((vf->dmpi->height>>mpi->chroma_y_shift)-1);
- mpi->stride[2]=-vf->dmpi->stride[2];
- }
- mpi->flags|=MP_IMGFLAG_DIRECT;
- mpi->priv=(void*)vf->dmpi;
- }
-}
-
-static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts){
- if(mpi->flags&MP_IMGFLAG_DIRECT){
- // we've used DR, so we're ready...
- if(!(mpi->flags&MP_IMGFLAG_PLANAR))
- ((mp_image_t*)mpi->priv)->planes[1] = mpi->planes[1]; // passthrough rgb8 palette
- return vf_next_put_image(vf,(mp_image_t*)mpi->priv, pts);
- }
-
- vf->dmpi=vf_get_image(vf->next,mpi->imgfmt,
- MP_IMGTYPE_EXPORT, MP_IMGFLAG_ACCEPT_STRIDE,
- mpi->width, mpi->height);
-
- // set up mpi as a upside-down image of dmpi:
- vf->dmpi->planes[0]=mpi->planes[0]+
+static struct mp_image *filter(struct vf_instance *vf, struct mp_image *mpi)
+{
+ mpi->planes[0]=mpi->planes[0]+
mpi->stride[0]*(mpi->height-1);
- vf->dmpi->stride[0]=-mpi->stride[0];
- if(vf->dmpi->flags&MP_IMGFLAG_PLANAR){
- vf->dmpi->planes[1]=mpi->planes[1]+
+ mpi->stride[0]=-mpi->stride[0];
+ if(mpi->flags&MP_IMGFLAG_PLANAR){
+ mpi->planes[1]=mpi->planes[1]+
mpi->stride[1]*((mpi->height>>mpi->chroma_y_shift)-1);
- vf->dmpi->stride[1]=-mpi->stride[1];
- vf->dmpi->planes[2]=mpi->planes[2]+
+ mpi->stride[1]=-mpi->stride[1];
+ mpi->planes[2]=mpi->planes[2]+
mpi->stride[2]*((mpi->height>>mpi->chroma_y_shift)-1);
- vf->dmpi->stride[2]=-mpi->stride[2];
- } else
- vf->dmpi->planes[1]=mpi->planes[1]; // passthru bgr8 palette!!!
-
- return vf_next_put_image(vf,vf->dmpi, pts);
+ mpi->stride[2]=-mpi->stride[2];
+ }
+ return mpi;
}
//===========================================================================//
static int vf_open(vf_instance_t *vf, char *args){
vf->config=config;
- vf->get_image=get_image;
- vf->put_image=put_image;
- vf->default_reqs=VFCAP_ACCEPT_STRIDE;
+ vf->filter=filter;
return 1;
}