<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Oct 9, 2013 at 12:55 AM, Steve Borho <span dir="ltr"><<a href="mailto:steve@borho.org" target="_blank">steve@borho.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote"><div class="im">On Tue, Oct 8, 2013 at 6:41 AM,  <span dir="ltr"><<a href="mailto:shazeb@multicorewareinc.com" target="_blank">shazeb@multicorewareinc.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"># HG changeset patch<br>
# User Shazeb Nawaz Khan <<a href="mailto:shazeb@multicorewareinc.com" target="_blank">shazeb@multicorewareinc.com</a>><br>
# Date 1381232285 -19800<br>
#      Tue Oct 08 17:08:05 2013 +0530<br>
# Node ID ad8608b0a64869c3b8bbc32e0bb418f7b1dde4bb<br>
# Parent  18a5d7c3464d1a3fa98afa95a0fe7a8894bcd3d2<br>
Enabling weight prediction for half and full pel<br>
<br>
diff -r 18a5d7c3464d -r ad8608b0a648 source/common/reference.cpp<br>
--- a/source/common/reference.cpp       Tue Oct 08 16:56:39 2013 +0530<br>
+++ b/source/common/reference.cpp       Tue Oct 08 17:08:05 2013 +0530<br>
@@ -58,6 +58,7 @@<br>
 int MotionReference::init(TComPicYuv* pic, wpScalingParam *w)<br>
 {<br>
     m_reconPic = pic;<br>
+    unweightedFPelPlane = pic->getLumaAddr();<br></blockquote><div><br></div></div><div>the motion reference object has m_reconPic, so it can call m_reconPic->getLumaAddr() at any time.  I don't see the need for another pointer</div>
</div></div></div></blockquote><div><br></div><div>Its not possible to refer m_reconPic in subpelInterpolate(), since the parameter is catched in ReferencePlanes type pointer rather than MotionReference pointer. Its required to have/use a pointer in superclass. Can there be another way?</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div class="im">
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
     lumaStride = pic->getStride();<br>
     m_startPad = pic->m_lumaMarginY * lumaStride + pic->m_lumaMarginX;<br>
     m_next = NULL;<br>
diff -r 18a5d7c3464d -r ad8608b0a648 source/common/reference.h<br>
--- a/source/common/reference.h Tue Oct 08 16:56:39 2013 +0530<br>
+++ b/source/common/reference.h Tue Oct 08 17:08:05 2013 +0530<br>
@@ -43,6 +43,7 @@<br>
<br>
     pixel* fpelPlane;<br>
     pixel* lowresPlane[4];<br>
+    pixel* unweightedFPelPlane;<br>
<br>
     bool isWeighted;<br>
     bool isLowres;<br>
diff -r 18a5d7c3464d -r ad8608b0a648 source/encoder/frameencoder.cpp<br>
--- a/source/encoder/frameencoder.cpp   Tue Oct 08 16:56:39 2013 +0530<br>
+++ b/source/encoder/frameencoder.cpp   Tue Oct 08 17:08:05 2013 +0530<br>
@@ -909,6 +909,10 @@<br>
                     {<br>
                         refpic->m_reconRowWait.wait();<br>
                     }<br>
+                    if(slice->getPPS()->getUseWP() && (slice->getSliceType() == P_SLICE))<br></blockquote><div><br></div></div><div>white-space</div><div class="im"><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">


+                    {<br>
+                        slice->m_mref[list][ref]->applyWeight(refpic, row + refLagRows, m_numRows);<br>
+                    }<br>
                 }<br>
             }<br>
<br>
@@ -941,6 +945,10 @@<br>
                         {<br>
                             refpic->m_reconRowWait.wait();<br>
                         }<br>
+                        if(slice->getPPS()->getUseWP() && (slice->getSliceType() == P_SLICE))<br></blockquote><div><br></div></div><div>white-space</div><div class="im"><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">


+                        {<br>
+                            slice->m_mref[list][ref]->applyWeight(refpic, i + refLagRows, m_numRows);<br>
+                        }<br>
                     }<br>
                 }<br>
<br>
diff -r 18a5d7c3464d -r ad8608b0a648 source/encoder/motion.cpp<br>
--- a/source/encoder/motion.cpp Tue Oct 08 16:56:39 2013 +0530<br>
+++ b/source/encoder/motion.cpp Tue Oct 08 17:08:05 2013 +0530<br>
@@ -89,6 +89,7 @@<br>
     fenc = (pixel*)X265_MALLOC(pixel, MAX_CU_SIZE * MAX_CU_SIZE);<br>
     subpelbuf = (pixel*)X265_MALLOC(pixel, (MAX_CU_SIZE + 1) * (MAX_CU_SIZE + 1));<br>
     immedVal = (short*)X265_MALLOC(short, (MAX_CU_SIZE + 1) * (MAX_CU_SIZE + 1 + NTAPS_LUMA - 1));<br>
+    immedVal2 = (int16_t*)X265_MALLOC(int16_t, (MAX_CU_SIZE + 1) * (MAX_CU_SIZE + 1 + NTAPS_LUMA - 1));<br></blockquote><div><br></div></div><div>this is the same as immedVal (short==int16_t most everywhere).  It would be better to change immedVal's type to int16_t* and to cast it as short everywhere necessary in the short term until we can fix all the interpolation primitives to use int16_t instead of short.</div>
</div></div></div></blockquote><div><br></div><div>In subpelInterpolate</div><div><br></div><div>pixel      -----------[interpolatePS]------>   immedVal    -------[interpolateSS]------->    immedVal2    ---------[weightp]--------->      subpellbuf</div>
<div><br></div><div>immedVal2 serves as intermediate buffer.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">
<div class="im">
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
 }<br>
<br>
 MotionEstimate::~MotionEstimate()<br>
@@ -96,6 +97,7 @@<br>
     X265_FREE(fenc);<br>
     X265_FREE(subpelbuf);<br>
     X265_FREE(immedVal);<br>
+    X265_FREE(immedVal2);<br>
 }<br>
<br>
 void MotionEstimate::setSourcePU(int offset, int width, int height)<br>
@@ -831,7 +833,7 @@<br>
                 }<br>
                 else<br>
                 {<br>
-                    subpelInterpolate(fqref, ref->lumaStride, xFrac, yFrac, dir);<br>
+                    subpelInterpolate(ref, qmv0, dir);<br>
                     cost0 = hpelcomp(fenc, FENC_STRIDE, subpelbuf, FENC_STRIDE + (dir == 2)) + mvcost0;<br>
                     cost1 = hpelcomp(fenc, FENC_STRIDE, subpelbuf + (dir == 2) + (dir == 1 ? FENC_STRIDE : 0), FENC_STRIDE + (dir == 2)) + mvcost1;<br>
                 }<br>
@@ -1140,47 +1142,61 @@<br>
         {<br>
             return cmp(fenc, FENC_STRIDE, fref, ref->lumaStride);<br>
         }<br>
-        else if (yFrac == 0)<br>
+        else<br>
         {<br>
-            primitives.ipfilter_pp[FILTER_H_P_P_8](fref, ref->lumaStride, subpelbuf, FENC_STRIDE, blockwidth, blockheight, g_lumaFilter[xFrac]);<br>
+            subpelInterpolate(ref, qmv, 0);<br></blockquote><div><br></div></div><div>as a post-step; we should try to declare subpelInterpolate as inline</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div><div class="h5">

+        }<br>
+        return cmp(fenc, FENC_STRIDE, subpelbuf, FENC_STRIDE);<br>
+    }<br>
+}<br>
+<br>
+void MotionEstimate::subpelInterpolate(ReferencePlanes *ref, MV qmv, int dir)<br>
+{<br>
+    int xFrac = qmv.x & 0x3;<br>
+    int yFrac = qmv.y & 0x3;<br>
+    assert(yFrac | xFrac);<br>
+    int realWidth = blockwidth + (dir == 2);<br>
+    int realHeight = blockheight + (dir == 1);<br>
+    intptr_t realStride = FENC_STRIDE + (dir == 2);<br>
+    pixel *fref = ref->unweightedFPelPlane + blockOffset + (qmv.x >> 2) + (qmv.y >> 2) * ref->lumaStride;<br>
+<br>
+    if (ref->isWeighted)<br>
+    {<br>
+        if (yFrac == 0)<br>
+        {<br>
+            primitives.ipfilter_ps[FILTER_H_P_S_8](fref, ref->lumaStride, immedVal, realStride, realWidth, realHeight, g_lumaFilter[xFrac]);<br>
+            primitives.weightpUni(immedVal, subpelbuf, realStride, realStride, realWidth, realHeight, ref->weight, ref->round, ref->shift, ref->offset);<br>
         }<br>
         else if (xFrac == 0)<br>
         {<br>
-            primitives.ipfilter_pp[FILTER_V_P_P_8](fref, ref->lumaStride, subpelbuf, FENC_STRIDE, blockwidth, blockheight, g_lumaFilter[yFrac]);<br>
+            primitives.ipfilter_ps[FILTER_V_P_S_8](fref, ref->lumaStride, immedVal, realStride, realWidth, realHeight, g_lumaFilter[yFrac]);<br>
+            primitives.weightpUni(immedVal, subpelbuf, realStride, realStride, realWidth, realHeight, ref->weight, ref->round, ref->shift, ref->offset);<br>
         }<br>
         else<br>
         {<br>
             int filterSize = NTAPS_LUMA;<br>
             int halfFilterSize = (filterSize >> 1);<br>
-            primitives.ipfilter_ps[FILTER_H_P_S_8](fref - (halfFilterSize - 1) * ref->lumaStride, ref->lumaStride, immedVal, blockwidth, blockwidth, blockheight + filterSize - 1, g_lumaFilter[xFrac]);<br>
-            primitives.ipfilter_sp[FILTER_V_S_P_8](immedVal + (halfFilterSize - 1) * blockwidth, blockwidth, subpelbuf, FENC_STRIDE, blockwidth, blockheight, g_lumaFilter[yFrac]);<br>
+            primitives.ipfilter_ps[FILTER_H_P_S_8](fref - (halfFilterSize - 1) * ref->lumaStride, ref->lumaStride, immedVal, realWidth, realWidth, realHeight + filterSize - 1, g_lumaFilter[xFrac]);<br>
+            primitives.ipfilter_ss[FILTER_V_S_S_8](immedVal + (halfFilterSize - 1) * realWidth, realWidth, immedVal2, realStride, realWidth, realHeight, g_lumaFilter[yFrac]);<br>
+            primitives.weightpUni(immedVal2, subpelbuf, realStride, realStride, realWidth, realHeight, ref->weight, ref->round, ref->shift, ref->offset);<br>
         }<br>
-<br>
-        return cmp(fenc, FENC_STRIDE, subpelbuf, FENC_STRIDE);<br>
-    }<br>
-}<br>
-<br>
-void MotionEstimate::subpelInterpolate(pixel *fref, intptr_t lumaStride, int xFrac, int yFrac, int dir)<br>
-{<br>
-    assert(yFrac | xFrac);<br>
-<br>
-    int realWidth = blockwidth + (dir == 2);<br>
-    int realHeight = blockheight + (dir == 1);<br>
-    intptr_t realStride = FENC_STRIDE + (dir == 2);<br>
-<br>
-    if (yFrac == 0)<br>
-    {<br>
-        primitives.ipfilter_pp[FILTER_H_P_P_8](fref, lumaStride, subpelbuf, realStride, realWidth, realHeight, g_lumaFilter[xFrac]);<br>
-    }<br>
-    else if (xFrac == 0)<br>
-    {<br>
-        primitives.ipfilter_pp[FILTER_V_P_P_8](fref, lumaStride, subpelbuf, realStride, realWidth, realHeight, g_lumaFilter[yFrac]);<br>
     }<br>
     else<br>
     {<br>
-        int filterSize = NTAPS_LUMA;<br>
-        int halfFilterSize = (filterSize >> 1);<br>
-        primitives.ipfilter_ps[FILTER_H_P_S_8](fref - (halfFilterSize - 1) * lumaStride, lumaStride, immedVal, realWidth, realWidth, realHeight + filterSize - 1, g_lumaFilter[xFrac]);<br>
-        primitives.ipfilter_sp[FILTER_V_S_P_8](immedVal + (halfFilterSize - 1) * realWidth, realWidth, subpelbuf, realStride, realWidth, realHeight, g_lumaFilter[yFrac]);<br>
+        if (yFrac == 0)<br>
+        {<br>
+            primitives.ipfilter_pp[FILTER_H_P_P_8](fref, ref->lumaStride, subpelbuf, realStride, realWidth, realHeight, g_lumaFilter[xFrac]);<br>
+        }<br>
+        else if (xFrac == 0)<br>
+        {<br>
+            primitives.ipfilter_pp[FILTER_V_P_P_8](fref, ref->lumaStride, subpelbuf, realStride, realWidth, realHeight, g_lumaFilter[yFrac]);<br>
+        }<br>
+        else<br>
+        {<br>
+            int filterSize = NTAPS_LUMA;<br>
+            int halfFilterSize = (filterSize >> 1);<br>
+            primitives.ipfilter_ps[FILTER_H_P_S_8](fref - (halfFilterSize - 1) * ref->lumaStride, ref->lumaStride, immedVal, realWidth, realWidth, realHeight + filterSize - 1, g_lumaFilter[xFrac]);<br>
+            primitives.ipfilter_sp[FILTER_V_S_P_8](immedVal + (halfFilterSize - 1) * realWidth, realWidth, subpelbuf, realStride, realWidth, realHeight, g_lumaFilter[yFrac]);<br>
+        }<br>
     }<br>
 }<br>
diff -r 18a5d7c3464d -r ad8608b0a648 source/encoder/motion.h<br>
--- a/source/encoder/motion.h   Tue Oct 08 16:56:39 2013 +0530<br>
+++ b/source/encoder/motion.h   Tue Oct 08 17:08:05 2013 +0530<br>
@@ -54,6 +54,7 @@<br>
     /* subpel generation buffers */<br>
     pixel *subpelbuf;<br>
     short *immedVal;<br>
+    int16_t *immedVal2;<br>
     int blockwidth;<br>
     int blockheight;<br>
<br>
@@ -96,7 +97,7 @@<br>
<br>
     int subpelCompare(ReferencePlanes *ref, const MV & qmv, pixelcmp_t);<br>
<br>
-    void subpelInterpolate(pixel *fref, intptr_t lumaStride, int xFrac, int yFrac, int dir);<br>
+    void subpelInterpolate(ReferencePlanes *ref, MV qmv, int dir);<br>
<br>
 protected:<br>
<br></div></div>
_______________________________________________<br>
x265-devel mailing list<br>
<a href="mailto:x265-devel@videolan.org" target="_blank">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><span class="HOEnZb"><font color="#888888"><br>
</font></span></blockquote></div><span class="HOEnZb"><font color="#888888"><br><br clear="all"><div><br></div>-- <br>Steve Borho
</font></span></div></div>
<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>
<br></blockquote></div><br></div></div>