<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Nov 13, 2013 at 6:06 AM,  <span dir="ltr"><<a href="mailto:dnyaneshwar@multicorewareinc.com" target="_blank">dnyaneshwar@multicorewareinc.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"># HG changeset patch<br>
# User Dnyaneshwar Gorade <<a href="mailto:dnyaneshwar@multicorewareinc.com">dnyaneshwar@multicorewareinc.com</a>><br>
# Date 1384342556 -19800<br>
#      Wed Nov 13 17:05:56 2013 +0530<br>
# Node ID c14e25a6ad035ac664548d6ada3e2e6e244bb3ce<br>
# Parent  c4ca80d19105ccf1ba2ec14dd65915f2820a660d<br>
primitive function for luma and croma for loops in addAvg()<br>
<br>
diff -r c4ca80d19105 -r c14e25a6ad03 source/Lib/TLibCommon/TComYuv.cpp<br>
--- a/source/Lib/TLibCommon/TComYuv.cpp Tue Nov 12 19:10:23 2013 +0530<br>
+++ b/source/Lib/TLibCommon/TComYuv.cpp Wed Nov 13 17:05:56 2013 +0530<br>
@@ -590,7 +590,6 @@<br>
<br>
 void TComYuv::addAvg(TShortYUV* srcYuv0, TShortYUV* srcYuv1, uint32_t partUnitIdx, uint32_t width, uint32_t height, bool bLuma, bool bChroma)<br>
 {<br>
-    int x, y;<br>
     uint32_t src0Stride, src1Stride, dststride;<br>
     int shiftNum, offset;<br>
<br>
@@ -614,20 +613,8 @@<br>
         shiftNum = IF_INTERNAL_PREC + 1 - X265_DEPTH;<br>
         offset = (1 << (shiftNum - 1)) + 2 * IF_INTERNAL_OFFS;<br>
<br>
-        for (y = 0; y < height; y++)<br>
-        {<br>
-            for (x = 0; x < width; x += 4)<br>
-            {<br>
-                dstY[x + 0] = ClipY((srcY0[x + 0] + srcY1[x + 0] + offset) >> shiftNum);<br>
-                dstY[x + 1] = ClipY((srcY0[x + 1] + srcY1[x + 1] + offset) >> shiftNum);<br>
-                dstY[x + 2] = ClipY((srcY0[x + 2] + srcY1[x + 2] + offset) >> shiftNum);<br>
-                dstY[x + 3] = ClipY((srcY0[x + 3] + srcY1[x + 3] + offset) >> shiftNum);<br>
-            }<br>
-<br>
-            srcY0 += src0Stride;<br>
-            srcY1 += src1Stride;<br>
-            dstY  += dststride;<br>
-        }<br>
+        int part = partitionFromSizes(width, height);<br>
+        primitives.addAvg[part](dstY, dststride, srcY0, src0Stride, srcY1, src1Stride);<br>
     }<br>
     if (bChroma)<br>
     {<br>
@@ -641,26 +628,9 @@<br>
         width  >>= m_hChromaShift;<br>
         height >>= m_vChromaShift;<br>
<br>
-        for (y = height - 1; y >= 0; y--)<br>
-        {<br>
-            for (x = width - 1; x >= 0; )<br>
-            {<br>
-                // note: chroma min width is 2<br>
-                dstU[x] = ClipC((srcU0[x] + srcU1[x] + offset) >> shiftNum);<br>
-                dstV[x] = ClipC((srcV0[x] + srcV1[x] + offset) >> shiftNum);<br>
-                x--;<br>
-                dstU[x] = ClipC((srcU0[x] + srcU1[x] + offset) >> shiftNum);<br>
-                dstV[x] = ClipC((srcV0[x] + srcV1[x] + offset) >> shiftNum);<br>
-                x--;<br>
-            }<br>
-<br>
-            srcU0 += src0Stride;<br>
-            srcU1 += src1Stride;<br>
-            srcV0 += src0Stride;<br>
-            srcV1 += src1Stride;<br>
-            dstU  += dststride;<br>
-            dstV  += dststride;<br>
-        }<br>
+        int part = partitionFromSizes(width, height);<br>
+        primitives.addAvg[part](dstU, dststride, srcU0, src0Stride, srcU1, src1Stride);<br>
+        primitives.addAvg[part](dstV, dststride, srcV0, src0Stride, srcV1, src1Stride);<br>
     }<br>
 }<br>
<br>
diff -r c4ca80d19105 -r c14e25a6ad03 source/common/pixel.cpp<br>
--- a/source/common/pixel.cpp   Tue Nov 12 19:10:23 2013 +0530<br>
+++ b/source/common/pixel.cpp   Wed Nov 13 17:05:56 2013 +0530<br>
@@ -794,6 +794,27 @@<br>
         a += dstride;<br>
     }<br>
 }<br>
+<br>
+template<int bx, int by><br>
+void addAvg(pixel* dst, intptr_t dstStride, int16_t* src0, intptr_t src0Stride, int16_t* src1, intptr_t src1Stride)<br>
+{<br>
+    int shiftNum, offset;<br>
+    shiftNum = IF_INTERNAL_PREC + 1 - X265_DEPTH;<br>
+    offset = (1 << (shiftNum - 1)) + 2 * IF_INTERNAL_OFFS;<br>
+<br>
+    for (int y = 0; y < by; y++)<br>
+    {<br>
+        for (int x = 0; x < bx; x += 2)<br>
+        {<br>
+            dst[x + 0] = ClipY((src0[x + 0] + src1[x + 0] + offset) >> shiftNum);<br>
+            dst[x + 1] = ClipY((src0[x + 1] + src1[x + 1] + offset) >> shiftNum);<br>
+        }<br>
+<br>
+        src0 += src0Stride;<br>
+        src1 += src1Stride;<br>
+        dst  += dstStride;<br>
+    }<br>
+}<br>
 }  // end anonymous namespace<br>
<br>
 namespace x265 {<br>
@@ -807,6 +828,33 @@<br>
     SET_FUNC_PRIMITIVE_TABLE_C2(sad_x4)<br>
     SET_FUNC_PRIMITIVE_TABLE_C2(pixelavg_pp)<br>
<br>
+    //addAvg<br></blockquote><div><br></div><div>space after //</div><div>but in general, the comment is not necessary</div><div> </div><div>can you use: SET_FUNC_PRIMITIVE_TABLE_C2(addAvg) here?  If not, please fix the macro so it can be used more generally.</div>
<div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
+    p.addAvg[LUMA_4x4]   = addAvg<4, 4>;<br>
+    p.addAvg[LUMA_8x8]   = addAvg<8, 8>;<br>
+    p.addAvg[LUMA_8x4]   = addAvg<8, 4>;<br>
+    p.addAvg[LUMA_4x8]   = addAvg<4, 8>;<br>
+    p.addAvg[LUMA_16x16] = addAvg<16, 16>;<br>
+    p.addAvg[LUMA_16x8]  = addAvg<16,  8>;<br>
+    p.addAvg[LUMA_8x16]  = addAvg<8,  16>;<br>
+    p.addAvg[LUMA_16x12] = addAvg<16, 12>;<br>
+    p.addAvg[LUMA_12x16] = addAvg<12, 16>;<br>
+    p.addAvg[LUMA_16x4]  = addAvg<16,  4>;<br>
+    p.addAvg[LUMA_4x16]  = addAvg<4,  16>;<br>
+    p.addAvg[LUMA_32x32] = addAvg<32, 32>;<br>
+    p.addAvg[LUMA_32x16] = addAvg<32, 16>;<br>
+    p.addAvg[LUMA_16x32] = addAvg<16, 32>;<br>
+    p.addAvg[LUMA_32x24] = addAvg<32, 24>;<br>
+    p.addAvg[LUMA_24x32] = addAvg<24, 32>;<br>
+    p.addAvg[LUMA_32x8]  = addAvg<32,  8>;<br>
+    p.addAvg[LUMA_8x32]  = addAvg<8,  32>;<br>
+    p.addAvg[LUMA_64x64] = addAvg<64, 64>;<br>
+    p.addAvg[LUMA_64x32] = addAvg<64, 32>;<br>
+    p.addAvg[LUMA_32x64] = addAvg<32, 64>;<br>
+    p.addAvg[LUMA_64x48] = addAvg<64, 48>;<br>
+    p.addAvg[LUMA_48x64] = addAvg<48, 64>;<br>
+    p.addAvg[LUMA_64x16] = addAvg<64, 16>;<br>
+    p.addAvg[LUMA_16x64] = addAvg<16, 64>;<br>
+<br>
     // satd<br>
     p.satd[LUMA_4x4]   = satd_4x4;<br>
     p.satd[LUMA_8x8]   = satd8<8, 8>;<br>
diff -r c4ca80d19105 -r c14e25a6ad03 source/common/primitives.h<br>
--- a/source/common/primitives.h        Tue Nov 12 19:10:23 2013 +0530<br>
+++ b/source/common/primitives.h        Wed Nov 13 17:05:56 2013 +0530<br>
@@ -208,6 +208,8 @@<br>
<br>
 typedef void (*pixel_sub_ps_t)(int16_t *dst, intptr_t dstride, pixel *src0, pixel *src1, intptr_t sstride0, intptr_t sstride1);<br>
<br>
+typedef void (*addAvg_t)(pixel* dst, intptr_t dstStride, int16_t* src0, intptr_t src0Stride, int16_t* src1, intptr_t src1Stride);<br>
+<br>
 /* Define a structure containing function pointers to optimized encoder<br>
  * primitives.  Each pointer can reference either an assembly routine,<br>
  * a vectorized primitive, or a C function. */<br>
@@ -288,6 +290,8 @@<br>
     var_t           var[NUM_LUMA_PARTITIONS];<br>
     ssim_4x4x2_core_t ssim_4x4x2_core;<br>
     plane_copy_deinterleave_t plane_copy_deinterleave_c;<br>
+<br>
+    addAvg_t        addAvg[NUM_LUMA_PARTITIONS];<br>
 };<br>
<br>
 /* This copy of the table is what gets used by the encoder.<br>
_______________________________________________<br>
x265-devel mailing list<br>
<a href="mailto:x265-devel@videolan.org">x265-devel@videolan.org</a><br>
<a href="https://mailman.videolan.org/listinfo/x265-devel" target="_blank">https://mailman.videolan.org/listinfo/x265-devel</a><br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br>Steve Borho
</div></div>