summaryrefslogtreecommitdiffstats
path: root/libmpcodecs
diff options
context:
space:
mode:
authormichael <michael@b3059339-0415-0410-9bf9-f77b7e298cf2>2006-10-16 20:21:31 +0000
committermichael <michael@b3059339-0415-0410-9bf9-f77b7e298cf2>2006-10-16 20:21:31 +0000
commit84aad40d58f69b2997fcd3bcee024e978ec89aec (patch)
tree9b3a0fc00342e8f01b0b6d5871b6e3aa939dd768 /libmpcodecs
parent28ecbe3cc3e410d351f8db3dd41d41d04d143400 (diff)
downloadmpv-84aad40d58f69b2997fcd3bcee024e978ec89aec.tar.bz2
mpv-84aad40d58f69b2997fcd3bcee024e978ec89aec.tar.xz
bilinear interpolation
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@20276 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libmpcodecs')
-rw-r--r--libmpcodecs/vf_geq.c33
1 files changed, 20 insertions, 13 deletions
diff --git a/libmpcodecs/vf_geq.c b/libmpcodecs/vf_geq.c
index ee1bf3a1af..da33eac71d 100644
--- a/libmpcodecs/vf_geq.c
+++ b/libmpcodecs/vf_geq.c
@@ -87,27 +87,34 @@ static void get_image(struct vf_instance_s* vf, mp_image_t *mpi){
mpi->flags|=MP_IMGFLAG_DIRECT;
}
-//FIXME spatial interpolate
+static double inline getpix(struct vf_instance_s* vf, double x, double y, int plane){
+ int xi, yi;
+ mp_image_t *mpi= vf->priv->mpi;
+ int stride= mpi->stride[plane];
+ uint8_t *src= mpi->planes[plane];
+ xi=x= FFMIN(FFMAX(x, 0), (mpi->w >> (plane ? mpi->chroma_x_shift : 0))-1);
+ yi=y= FFMIN(FFMAX(y, 0), (mpi->h >> (plane ? mpi->chroma_y_shift : 0))-1);
+
+ x-=xi;
+ y-=yi;
+
+ return
+ (1-y)*((1-x)*src[xi + yi * stride] + x*src[xi + 1 + yi * stride])
+ + y *((1-x)*src[xi + (yi+1) * stride] + x*src[xi + 1 + (yi+1) * stride]);
+}
+
+//FIXME cubic interpolate
//FIXME keep the last few frames
static double lum(struct vf_instance_s* vf, double x, double y){
- mp_image_t *mpi= vf->priv->mpi;
- x= clip(x, 0, vf->priv->mpi->w-1);
- y= clip(y, 0, vf->priv->mpi->h-1);
- return mpi->planes[0][(int)x + (int)y * mpi->stride[0]];
+ return getpix(vf, x, y, 0);
}
static double cb(struct vf_instance_s* vf, double x, double y){
- mp_image_t *mpi= vf->priv->mpi;
- x= clip(x, 0, (vf->priv->mpi->w >> mpi->chroma_x_shift)-1);
- y= clip(y, 0, (vf->priv->mpi->h >> mpi->chroma_y_shift)-1);
- return mpi->planes[1][(int)x + (int)y * mpi->stride[1]];
+ return getpix(vf, x, y, 1);
}
static double cr(struct vf_instance_s* vf, double x, double y){
- mp_image_t *mpi= vf->priv->mpi;
- x= clip(x, 0, (vf->priv->mpi->w >> mpi->chroma_x_shift)-1);
- y= clip(y, 0, (vf->priv->mpi->h >> mpi->chroma_y_shift)-1);
- return mpi->planes[2][(int)x + (int)y * mpi->stride[2]];
+ return getpix(vf, x, y, 2);
}
static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){