[x265] [PATCH 2 of 2] Fix for Testbench fail in weightpUni for Pixel input
shazeb at multicorewareinc.com
shazeb at multicorewareinc.com
Fri Oct 4 13:53:48 CEST 2013
# HG changeset patch
# User Shazeb Nawaz Khan <shazeb at multicorewareinc.com>
# Date 1380886668 -19800
# Fri Oct 04 17:07:48 2013 +0530
# Node ID 0bb2c80a73b7f36f9a491d750d78838bd866e893
# Parent b54b030188bcb53f6c5c64fe99ac29a4d851eb78
Fix for Testbench fail in weightpUni for Pixel input
diff -r b54b030188bc -r 0bb2c80a73b7 source/common/vec/pixel.inc
--- a/source/common/vec/pixel.inc Fri Oct 04 16:40:04 2013 +0530
+++ b/source/common/vec/pixel.inc Fri Oct 04 17:07:48 2013 +0530
@@ -168,8 +168,8 @@
p.blockfil_s[BLOCK_32x32] = blockfil_s_32;
#endif
- p.weightpUniPixel = weightUnidir<pixel>;
- p.weightpUni = weightUnidir<int16_t>;
+ p.weightpUniPixel = weightUnidirPixel;
+ p.weightpUni = weightUnidir;
p.calcresidual[BLOCK_4x4] = getResidual4;
p.calcresidual[BLOCK_8x8] = getResidual8;
diff -r b54b030188bc -r 0bb2c80a73b7 source/common/vec/pixel8.inc
--- a/source/common/vec/pixel8.inc Fri Oct 04 16:40:04 2013 +0530
+++ b/source/common/vec/pixel8.inc Fri Oct 04 17:07:48 2013 +0530
@@ -717,8 +717,7 @@
}
}
-template <typename T>
-void weightUnidir(T *src, pixel *dst, intptr_t srcStride, intptr_t dstStride, int width, int height, int w0, int round, int shift, int offset)
+void weightUnidir(int16_t *src, pixel *dst, intptr_t srcStride, intptr_t dstStride, int width, int height, int w0, int round, int shift, int offset)
{
int x, y;
Vec8s tmp;
@@ -745,3 +744,32 @@
dst += dstStride;
}
}
+
+void weightUnidirPixel(pixel *src, pixel *dst, intptr_t srcStride, intptr_t dstStride, int width, int height, int w0, int round, int shift, int offset)
+{
+ int x, y;
+ Vec16uc tmp;
+
+ Vec4i vw0(w0), vsrc, iofs(IF_INTERNAL_OFFS), ofs(offset), vround(round), vdst;
+ for (y = height - 1; y >= 0; y--)
+ {
+ for (x = 0; x <= width - 4; x += 4)
+ {
+ tmp = load_partial(const_int(4), src + x);
+ // The intermediate results would outgrow 16 bits because internal offset is too high
+ vsrc = extend_low(extend_low(tmp));
+ vdst = ((vw0 * (vsrc + iofs) + vround) >> shift) + ofs;
+ store_partial(const_int(4), dst + x, compress_unsafe(compress_saturated(vdst, vdst), 0));
+ }
+
+ if (width > x)
+ {
+ tmp = load_partial(const_int(4), src + x);
+ vsrc = extend_low(extend_low(tmp));
+ vdst = ((vw0 * (vsrc + iofs) + vround) >> shift) + ofs;
+ compress_unsafe(compress_saturated(vdst, vdst), 0).store_partial(2, dst + x);
+ }
+ src += srcStride;
+ dst += dstStride;
+ }
+}
diff -r b54b030188bc -r 0bb2c80a73b7 source/test/pixelharness.cpp
--- a/source/test/pixelharness.cpp Fri Oct 04 16:40:04 2013 +0530
+++ b/source/test/pixelharness.cpp Fri Oct 04 17:07:48 2013 +0530
@@ -371,8 +371,8 @@
int offset = (rand() % 256) - 128;
for (int i = 0; i < ITERS; i++)
{
- opt((pixel *)sbuf1 + j, opt_dest, 64, 64, width, height, w0, round, shift, offset);
- ref((pixel *)sbuf1 + j, ref_dest, 64, 64, width, height, w0, round, shift, offset);
+ opt(pbuf1 + j, opt_dest, 64, 64, width, height, w0, round, shift, offset);
+ ref(pbuf1 + j, ref_dest, 64, 64, width, height, w0, round, shift, offset);
if (memcmp(ref_dest, opt_dest, 64 * 64 * sizeof(pixel)))
return false;
@@ -636,16 +636,7 @@
{
if (!check_weightpUni(ref.weightpUniPixel, opt.weightpUniPixel))
{
- printf("Weighted Prediction for Unidir failed!\n");
- return false;
- }
- }
-
- if (opt.weightpUniPixel)
- {
- if (!check_weightpUni(ref.weightpUniPixel, opt.weightpUniPixel))
- {
- printf("Weighted Prediction for Unidir failed!\n");
+ printf("Weighted Prediction for Unidir (Pixel) failed!\n");
return false;
}
}
@@ -654,7 +645,7 @@
{
if (!check_weightpUni(ref.weightpUni, opt.weightpUni))
{
- printf("Weighted Prediction for Unidir failed!\n");
+ printf("Weighted Prediction for Unidir (int16_t) failed!\n");
return false;
}
}
More information about the x265-devel
mailing list