diff options
author | Miao Wang <miaowang@google.com> | 2014-11-11 14:26:05 -0800 |
---|---|---|
committer | Miao Wang <miaowang@google.com> | 2014-11-13 11:18:05 -0800 |
commit | a2bd5e85ddb7c4cc439f4b4646dafa21558ea5c7 (patch) | |
tree | 9d262eaf9529d3a8b9c1d81ef73492d97822f2f9 /cpu_ref/rsCpuIntrinsicResize.cpp | |
parent | 9a965037d934386509e2587193939eed952c4521 (diff) | |
download | rs-a2bd5e85ddb7c4cc439f4b4646dafa21558ea5c7.tar.gz |
Fix off-by-one bug of resize, when scale = 1;
Use a better way to do scaling.
bug 18296081
Change-Id: I3858d6d0f1cd0166d9862e9013386b1d844bd3f9
Diffstat (limited to 'cpu_ref/rsCpuIntrinsicResize.cpp')
-rw-r--r-- | cpu_ref/rsCpuIntrinsicResize.cpp | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/cpu_ref/rsCpuIntrinsicResize.cpp b/cpu_ref/rsCpuIntrinsicResize.cpp index 9be6ef17..99c0d3e9 100644 --- a/cpu_ref/rsCpuIntrinsicResize.cpp +++ b/cpu_ref/rsCpuIntrinsicResize.cpp @@ -83,7 +83,7 @@ static float cubicInterpolate(float p0,float p1,float p2,float p3 , float x) { static uchar4 OneBiCubic(const uchar4 *yp0, const uchar4 *yp1, const uchar4 *yp2, const uchar4 *yp3, float xf, float yf, int width) { - int startx = (int) floor(xf - 2); + int startx = (int) floor(xf - 1); xf = xf - floor(xf); int maxx = width - 1; int xs0 = rsMax(0, startx + 0); @@ -118,7 +118,7 @@ static uchar4 OneBiCubic(const uchar4 *yp0, const uchar4 *yp1, const uchar4 *yp2 static uchar2 OneBiCubic(const uchar2 *yp0, const uchar2 *yp1, const uchar2 *yp2, const uchar2 *yp3, float xf, float yf, int width) { - int startx = (int) floor(xf - 2); + int startx = (int) floor(xf - 1); xf = xf - floor(xf); int maxx = width - 1; int xs0 = rsMax(0, startx + 0); @@ -153,7 +153,7 @@ static uchar2 OneBiCubic(const uchar2 *yp0, const uchar2 *yp1, const uchar2 *yp2 static uchar OneBiCubic(const uchar *yp0, const uchar *yp1, const uchar *yp2, const uchar *yp3, float xf, float yf, int width) { - int startx = (int) floor(xf - 2); + int startx = (int) floor(xf - 1); xf = xf - floor(xf); int maxx = width - 1; int xs0 = rsMax(0, startx + 0); @@ -189,8 +189,8 @@ void RsdCpuScriptIntrinsicResize::kernelU4(const RsExpandKernelParams *p, const int srcWidth = cp->mAlloc->mHal.drvState.lod[0].dimX; const size_t stride = cp->mAlloc->mHal.drvState.lod[0].stride; - float yf = p->y * cp->scaleY; - int starty = (int) floor(yf - 2); + float yf = (p->y + 0.5f) * cp->scaleY - 0.5f; + int starty = (int) floor(yf - 1); yf = yf - floor(yf); int maxy = srcHeight - 1; int ys0 = rsMax(0, starty + 0); @@ -208,7 +208,7 @@ void RsdCpuScriptIntrinsicResize::kernelU4(const RsExpandKernelParams *p, uint32_t x2 = xend; while(x1 < x2) { - float xf = x1 * cp->scaleX; + float xf = (x1 + 0.5f) * cp->scaleX - 0.5f; *out = OneBiCubic(yp0, yp1, yp2, yp3, xf, yf, srcWidth); out++; x1++; @@ -229,8 +229,8 @@ void RsdCpuScriptIntrinsicResize::kernelU2(const RsExpandKernelParams *p, const int srcWidth = cp->mAlloc->mHal.drvState.lod[0].dimX; const size_t stride = cp->mAlloc->mHal.drvState.lod[0].stride; - float yf = p->y * cp->scaleY; - int starty = (int) floor(yf - 2); + float yf = (p->y + 0.5f) * cp->scaleY - 0.5f; + int starty = (int) floor(yf - 1); yf = yf - floor(yf); int maxy = srcHeight - 1; int ys0 = rsMax(0, starty + 0); @@ -248,7 +248,7 @@ void RsdCpuScriptIntrinsicResize::kernelU2(const RsExpandKernelParams *p, uint32_t x2 = xend; while(x1 < x2) { - float xf = x1 * cp->scaleX; + float xf = (x1 + 0.5f) * cp->scaleX - 0.5f; *out = OneBiCubic(yp0, yp1, yp2, yp3, xf, yf, srcWidth); out++; x1++; @@ -269,8 +269,8 @@ void RsdCpuScriptIntrinsicResize::kernelU1(const RsExpandKernelParams *p, const int srcWidth = cp->mAlloc->mHal.drvState.lod[0].dimX; const size_t stride = cp->mAlloc->mHal.drvState.lod[0].stride; - float yf = p->y * cp->scaleY; - int starty = (int) floor(yf - 2); + float yf = (p->y + 0.5f) * cp->scaleY - 0.5f; + int starty = (int) floor(yf - 1); yf = yf - floor(yf); int maxy = srcHeight - 1; int ys0 = rsMax(0, starty + 0); @@ -288,7 +288,7 @@ void RsdCpuScriptIntrinsicResize::kernelU1(const RsExpandKernelParams *p, uint32_t x2 = xend; while(x1 < x2) { - float xf = x1 * cp->scaleX; + float xf = (x1 + 0.5f) * cp->scaleX - 0.5f; *out = OneBiCubic(yp0, yp1, yp2, yp3, xf, yf, srcWidth); out++; x1++; |