[x265] [PATCH 1 of 2] C primitives and testbench support for weighted prediction unidirectional

deepthidevaki at multicorewareinc.com deepthidevaki at multicorewareinc.com
Thu Jul 11 11:27:42 CEST 2013


# HG changeset patch
# User Deepthi Devaki
# Date 1373534716 -19800
# Node ID bb29ce5d4caec8a9ca75bcae2aa1c74618ebdb84
# Parent  c1e2e7ee80f86970f383425a7d0db40d3e7ae9c4
C primitives and testbench support for weighted prediction unidirectional.

diff -r c1e2e7ee80f8 -r bb29ce5d4cae source/common/pixel.cpp
--- a/source/common/pixel.cpp	Thu Jul 11 03:10:37 2013 -0500
+++ b/source/common/pixel.cpp	Thu Jul 11 14:55:16 2013 +0530
@@ -27,9 +27,9 @@
 #include "primitives.h"
 #include <algorithm>
 #include <stdlib.h> // abs()
+#include "TLibCommon/CommonDef.h"
+#include "TLibCommon/TComPrediction.h"
 
-template<typename T>
-inline T ClipY(T x) { return std::min<T>(T((1 << 8) - 1), std::max<T>(T(0), x)); }
 
 #define SET_FUNC_PRIMITIVE_TABLE_C_SUBSET(WIDTH, FUNC_PREFIX, FUNC_PREFIX_DEF, FUNC_TYPE_CAST, DATA_TYPE1, DATA_TYPE2) \
     p.FUNC_PREFIX[PARTITION_ ## WIDTH ## x4]   = (FUNC_TYPE_CAST)FUNC_PREFIX_DEF<WIDTH, 4,  DATA_TYPE1, DATA_TYPE2>;  \
@@ -500,6 +500,26 @@
         }
     }
 }
+
+void weightUnidir(short *pSrcY0, pixel *pDstY, int srcStride, int dstStride, int width, int height, int w0, int round, int shift, int offset, int bitDepth)
+{
+    int x, y;
+    for (y = height - 1; y >= 0; y--)
+    {
+        for (x = width - 1; x >= 0; )
+        {
+            // note: luma min width is 4
+            pDstY[x] = (pixel) Clip3(0, ((1 << bitDepth) - 1), ((w0 * (pSrcY0[x] + IF_INTERNAL_OFFS) + round) >> shift) + offset);
+            x--;
+            pDstY[x] = (pixel) Clip3(0, ((1 << bitDepth) - 1), ((w0 * (pSrcY0[x] + IF_INTERNAL_OFFS) + round) >> shift) + offset);
+            x--;
+        }
+
+        pSrcY0 += srcStride;
+        pDstY  += dstStride;
+    }
+}
+
 }  // end anonymous namespace
 
 namespace x265 {
@@ -699,5 +719,7 @@
     p.transpose[2] = transpose<16>;
     p.transpose[3] = transpose<32>;
     p.transpose[4] = transpose<64>;
+
+    p.weightpUni = weightUnidir;
 }
 }
diff -r c1e2e7ee80f8 -r bb29ce5d4cae source/common/primitives.h
--- a/source/common/primitives.h	Thu Jul 11 03:10:37 2013 -0500
+++ b/source/common/primitives.h	Thu Jul 11 14:55:16 2013 +0530
@@ -215,6 +215,7 @@
 typedef void (*dequant_t)(int bitDepth, const int* src, int* dst, int width, int height, int mcqp_miper, int mcqp_mirem, bool useScalingList, unsigned int trSizeLog2, int *dequantCoef);
 typedef uint32_t (*quantaq_t)(int *coef, int *quantCoeff, int *deltaU, int *qCoef, int *arlCCoef, int qBitsC, int qBits, int add, int numCoeff);
 typedef uint32_t (*quant_t)(int *coef, int *quantCoeff, int *deltaU, int *qCoef, int qBits, int add, int numCoeff);
+typedef void (*weightpUni_t)(short *pSrcY0, pixel *pDstY, int srcStride, int dstStride, int width, int height, int w0, int round, int shift, int offset, int bitDepth);
 
 /* Define a structure containing function pointers to optimized encoder
  * primitives.  Each pointer can reference either an assembly routine,
@@ -264,6 +265,8 @@
     calcresidual_t  calcresidual[NUM_SQUARE_BLOCKS];
     calcrecon_t     calcrecon[NUM_SQUARE_BLOCKS];
     transpose_t     transpose[NUM_SQUARE_BLOCKS];
+
+    weightpUni_t    weightpUni;
 };
 
 /* This copy of the table is what gets used by the encoder.
diff -r c1e2e7ee80f8 -r bb29ce5d4cae source/test/pixelharness.cpp
--- a/source/test/pixelharness.cpp	Thu Jul 11 03:10:37 2013 -0500
+++ b/source/test/pixelharness.cpp	Thu Jul 11 14:55:16 2013 +0530
@@ -325,6 +325,33 @@
     return true;
 }
 
+bool PixelHarness::check_weightpUni(x265::weightpUni_t ref, x265::weightpUni_t opt)
+{
+    ALIGN_VAR_16(pixel, ref_dest[64 * 64]);
+    ALIGN_VAR_16(pixel, opt_dest[64 * 64]);
+
+    memset(ref_dest, 0, 64 * 64 * sizeof(pixel));
+    memset(opt_dest, 0, 64 * 64 * sizeof(pixel));
+    int j = 0;
+    int width = 8;
+    int height = 8;
+    int w0 = rand() % 256;
+    int shift = rand() % 12;
+    int round   = shift ? (1 << (shift - 1)) : 0;
+    int offset = (rand() % 256) - 128;
+    for (int i = 0; i <= 100; i++)
+    {
+        opt(sbuf1+j, opt_dest, 64, 64, width, height, w0, round, shift, offset, BIT_DEPTH);
+        ref(sbuf1+j, ref_dest, 64, 64, width, height, w0, round, shift, offset, BIT_DEPTH);
+
+        if (memcmp(ref_dest, opt_dest, 64 * 64 * sizeof(pixel)))
+            return false;
+
+        j += 4;
+    }
+    return true;
+}
+
 bool PixelHarness::testCorrectness(const EncoderPrimitives& ref, const EncoderPrimitives& opt)
 {
     for (uint16_t curpar = 0; curpar < NUM_PARTITIONS; curpar++)
@@ -465,6 +492,16 @@
             return false;
         }
     }
+    
+    if (opt.weightpUni)
+    {
+        if (!check_weightpUni(ref.weightpUni, opt.weightpUni))
+        {
+            printf("Weighted Prediction for Unidir failed!\n");
+            return false;
+        }
+    }
+
 
     return true;
 }
@@ -568,4 +605,10 @@
         printf("s_c   cpy");
         REPORT_SPEEDUP(opt.blockcpy_sc, ref.blockcpy_sc, 64, 64, (short*)pbuf1, FENC_STRIDE, (uint8_t*)pbuf2, STRIDE);
     }
+
+    if (opt.weightpUni)
+    {
+        printf("WeightpUni");
+        REPORT_SPEEDUP(opt.weightpUni, ref.weightpUni, sbuf1, pbuf1, 64, 64, 32, 32, 128, 1<<9, 10, 100, BIT_DEPTH);
+    }
 }
diff -r c1e2e7ee80f8 -r bb29ce5d4cae source/test/pixelharness.h
--- a/source/test/pixelharness.h	Thu Jul 11 03:10:37 2013 -0500
+++ b/source/test/pixelharness.h	Thu Jul 11 14:55:16 2013 +0530
@@ -46,6 +46,7 @@
     bool check_block_copy_s_c(x265::blockcpy_sc_t ref, x265::blockcpy_sc_t opt);
     bool check_calresidual(x265::calcresidual_t ref, x265::calcresidual_t opt);
     bool check_calcrecon(x265::calcrecon_t ref, x265::calcrecon_t opt);
+    bool check_weightpUni(x265::weightpUni_t ref, x265::weightpUni_t opt);
 
 public:
 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: xhevc_deepthid-1.patch
Type: text/x-patch
Size: 5662 bytes
Desc: not available
URL: <http://mailman.videolan.org/pipermail/x265-devel/attachments/20130711/066f767f/attachment-0001.bin>


More information about the x265-devel mailing list