<div dir="ltr">simulation comparision data<div class="gmail_extra"><br><div class="gmail_quote">On Sun, Aug 7, 2016 at 11:35 AM, <span dir="ltr"><<a href="mailto:nvijay.anand@trispacetech.com" target="_blank">nvijay.anand@trispacetech.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 N Vijay Anand <<a href="mailto:nvijay.anand@trispacetech.com">nvijay.anand@trispacetech.com</a><wbr>><br>
# Date 1470549890 -19800<br>
# Sun Aug 07 11:34:50 2016 +0530<br>
# Node ID 340dd470d7ebbdd6e9532b9ea6e830<wbr>627600d3bf<br>
# Parent f46e843a27cbaa4a1c79f1a43d41a0<wbr>4d63f601c4<br>
Parameter passing optimisation<br>
<br>
diff -r f46e843a27cb -r 340dd470d7eb source/encoder/motion.cpp<br>
--- a/source/encoder/motion.cpp Fri Aug 05 17:02:17 2016 +0530<br>
+++ b/source/encoder/motion.cpp Sun Aug 07 11:34:50 2016 +0530<br>
@@ -100,23 +100,21 @@<br>
<br>
}<br>
<br>
-#define MAX_NUM_BESTVECTORS (16)<br>
-<br>
-inline void PushToBMVStack(MV *bStack, MV & bv, int *bCostStack, int bcost, int maxNumBmv)<br>
+inline void PushToBMVStack(BmvStack *bStack, MV & bv, int bcost)<br>
{<br>
- for (int i=0; i<maxNumBmv; i++)<br>
+ for (int i=0; i<bStack->maxNumBmv; i++)<br>
{<br>
- if((bCostStack[i] == bcost) && (bv == bStack[i]))<br>
+ if((bStack->bmvCostStack[i] == bcost) && (bv == bStack->bmvStack[i]))<br>
break;<br>
- if((bCostStack[i] >= bcost) && (bv != bStack[i]))<br>
+ if((bStack->bmvCostStack[i] >= bcost) && (bv != bStack->bmvStack[i]))<br>
{<br>
- for (int j=maxNumBmv-1; j>i; j--)<br>
+ for (int j=bStack->maxNumBmv-1; j>i; j--)<br>
{<br>
- bStack[j] = bStack[j-1];<br>
- bCostStack[j] = bCostStack[j-1];<br>
+ bStack->bmvStack[j] = bStack->bmvStack[j-1];<br>
+ bStack->bmvCostStack[j] = bStack->bmvCostStack[j-1];<br>
}<br>
- bStack[i] = bv;<br>
- bCostStack[i] = bcost;<br>
+ bStack->bmvStack[i] = bv;<br>
+ bStack->bmvCostStack[i] = bcost;<br>
break;<br>
}<br>
}<br>
@@ -247,7 +245,7 @@<br>
bmv = tmv; \<br>
bPointNr = point; \<br>
bDistance = dist; \<br>
- PushToBMVStack(bmvStack, tmv, bmvCostStack, cost, maxNumBmv); \<br>
+ PushToBMVStack(bmvStack, tmv, cost); \<br>
} \<br>
} while (0)<br>
<br>
@@ -257,7 +255,7 @@<br>
int cost = sad(fenc, FENC_STRIDE, fref + (mx) + (my) * stride, stride); \<br>
cost += mvcost(MV(mx, my) << 2); \<br>
COPY2_IF_LT(bcost, cost, bmv, MV(mx, my)); \<br>
- PushToBMVStack(bmvStack, MV(mx,my), bmvCostStack, cost, maxNumBmv); \<br>
+ PushToBMVStack(bmvStack, MV(mx,my), cost); \<br>
} while (0)<br>
<br>
#define COST_MV_X3_DIR(m0x, m0y, m1x, m1y, m2x, m2y, costs) \<br>
@@ -271,9 +269,9 @@<br>
(costs)[0] += mvcost((bmv + MV(m0x, m0y)) << 2); \<br>
(costs)[1] += mvcost((bmv + MV(m1x, m1y)) << 2); \<br>
(costs)[2] += mvcost((bmv + MV(m2x, m2y)) << 2); \<br>
- PushToBMVStack(bmvStack, bmv+MV(m0x,m0y), bmvCostStack, (costs)[0], maxNumBmv); \<br>
- PushToBMVStack(bmvStack, bmv+MV(m1x,m1y), bmvCostStack, (costs)[1], maxNumBmv); \<br>
- PushToBMVStack(bmvStack, bmv+MV(m2x,m2y), bmvCostStack, (costs)[2], maxNumBmv); \<br>
+ PushToBMVStack(bmvStack, bmv+MV(m0x,m0y), (costs)[0]); \<br>
+ PushToBMVStack(bmvStack, bmv+MV(m1x,m1y), (costs)[1]); \<br>
+ PushToBMVStack(bmvStack, bmv+MV(m2x,m2y), (costs)[2]); \<br>
}<br>
<br>
#define COST_MV_PT_DIST_X4(m0x, m0y, p0, d0, m1x, m1y, p1, d1, m2x, m2y, p2, d2, m3x, m3y, p3, d3) \<br>
@@ -289,13 +287,13 @@<br>
(costs)[2] += mvcost(MV(m2x, m2y) << 2); \<br>
(costs)[3] += mvcost(MV(m3x, m3y) << 2); \<br>
COPY4_IF_LT(bcost, costs[0], bmv, MV(m0x, m0y), bPointNr, p0, bDistance, d0); \<br>
- PushToBMVStack(bmvStack, MV(m0x,m0y), bmvCostStack, (costs)[0], maxNumBmv); \<br>
+ PushToBMVStack(bmvStack, MV(m0x,m0y), (costs)[0]); \<br>
COPY4_IF_LT(bcost, costs[1], bmv, MV(m1x, m1y), bPointNr, p1, bDistance, d1); \<br>
- PushToBMVStack(bmvStack, MV(m1x,m1y), bmvCostStack, (costs)[1], maxNumBmv); \<br>
+ PushToBMVStack(bmvStack, MV(m1x,m1y), (costs)[1]); \<br>
COPY4_IF_LT(bcost, costs[2], bmv, MV(m2x, m2y), bPointNr, p2, bDistance, d2); \<br>
- PushToBMVStack(bmvStack, MV(m2x,m2y), bmvCostStack, (costs)[2], maxNumBmv); \<br>
+ PushToBMVStack(bmvStack, MV(m2x,m2y), (costs)[2]); \<br>
COPY4_IF_LT(bcost, costs[3], bmv, MV(m3x, m3y), bPointNr, p3, bDistance, d3); \<br>
- PushToBMVStack(bmvStack, MV(m3x,m3y), bmvCostStack, (costs)[3], maxNumBmv); \<br>
+ PushToBMVStack(bmvStack, MV(m3x,m3y), (costs)[3]); \<br>
}<br>
<br>
#define COST_MV_X4(m0x, m0y, m1x, m1y, m2x, m2y, m3x, m3y) \<br>
@@ -312,13 +310,13 @@<br>
costs[2] += mvcost((omv + MV(m2x, m2y)) << 2); \<br>
costs[3] += mvcost((omv + MV(m3x, m3y)) << 2); \<br>
COPY2_IF_LT(bcost, costs[0], bmv, omv + MV(m0x, m0y)); \<br>
- PushToBMVStack(bmvStack, omv+MV(m0x,m0y), bmvCostStack, costs[0], maxNumBmv); \<br>
+ PushToBMVStack(bmvStack, omv+MV(m0x,m0y), costs[0]); \<br>
COPY2_IF_LT(bcost, costs[1], bmv, omv + MV(m1x, m1y)); \<br>
- PushToBMVStack(bmvStack, omv+MV(m1x,m1y), bmvCostStack, costs[1], maxNumBmv); \<br>
+ PushToBMVStack(bmvStack, omv+MV(m1x,m1y), costs[1]); \<br>
COPY2_IF_LT(bcost, costs[2], bmv, omv + MV(m2x, m2y)); \<br>
- PushToBMVStack(bmvStack, omv+MV(m2x,m2y), bmvCostStack, costs[2], maxNumBmv); \<br>
+ PushToBMVStack(bmvStack, omv+MV(m2x,m2y), costs[2]); \<br>
COPY2_IF_LT(bcost, costs[3], bmv, omv + MV(m3x, m3y)); \<br>
- PushToBMVStack(bmvStack, omv+MV(m3x,m3y), bmvCostStack, costs[3], maxNumBmv); \<br>
+ PushToBMVStack(bmvStack, omv+MV(m3x,m3y), costs[3]); \<br>
}<br>
<br>
#define COST_MV_X4_DIR(m0x, m0y, m1x, m1y, m2x, m2y, m3x, m3y, costs) \<br>
@@ -334,10 +332,10 @@<br>
(costs)[1] += mvcost((bmv + MV(m1x, m1y)) << 2); \<br>
(costs)[2] += mvcost((bmv + MV(m2x, m2y)) << 2); \<br>
(costs)[3] += mvcost((bmv + MV(m3x, m3y)) << 2); \<br>
- PushToBMVStack(bmvStack, bmv+MV(m0x,m0y), bmvCostStack, (costs)[0], maxNumBmv); \<br>
- PushToBMVStack(bmvStack, bmv+MV(m1x,m1y), bmvCostStack, (costs)[1], maxNumBmv); \<br>
- PushToBMVStack(bmvStack, bmv+MV(m2x,m2y), bmvCostStack, (costs)[2], maxNumBmv); \<br>
- PushToBMVStack(bmvStack, bmv+MV(m3x,m3y), bmvCostStack, (costs)[3], maxNumBmv); \<br>
+ PushToBMVStack(bmvStack, bmv+MV(m0x,m0y), (costs)[0]); \<br>
+ PushToBMVStack(bmvStack, bmv+MV(m1x,m1y), (costs)[1]); \<br>
+ PushToBMVStack(bmvStack, bmv+MV(m2x,m2y), (costs)[2]); \<br>
+ PushToBMVStack(bmvStack, bmv+MV(m3x,m3y), (costs)[3]); \<br>
}<br>
<br>
#define DIA1_ITER(mx, my) \<br>
@@ -377,9 +375,7 @@<br>
const MV & mvmax,<br>
MV & bmv,<br>
int & bcost,<br>
- MV *bmvStack,<br>
- int *bmvCostStack,<br>
- int maxNumBmv,<br>
+ BmvStack *bmvStack,<br>
int & bPointNr,<br>
int & bDistance,<br>
int earlyExitIters,<br>
@@ -658,23 +654,24 @@<br>
<br>
/* re-measure full pel rounded MVP with SAD as search start point */<br>
MV bmv = pmv.roundToFPel();<br>
- MV bmvStack[MAX_NUM_BESTVECTORS];<br>
- int bmvCostStack[MAX_NUM_<wbr>BESTVECTORS];<br>
- int bcost = bprecost;<br>
- const int maxNumBmv = 1 << searchMethod;<br>
+ BmvStack *bmvStack, bMVStack;<br>
+ int bcost = bprecost;<br>
<br>
- bmvStack[0] = bmv;<br>
- bmvCostStack[0] = bprecost;<br>
- for (int i=1 ; i < maxNumBmv; i++)<br>
+ bmvStack = &bMVStack;<br>
+ bmvStack->bmvStack[0] = bmv;<br>
+ bmvStack->bmvCostStack[0] = bprecost;<br>
+ bmvStack->maxNumBmv = 1 << searchMethod;<br>
+<br>
+ for (int i=1 ; i < bmvStack->maxNumBmv; i++)<br>
{<br>
- bmvStack[i] = bmv;<br>
- bmvCostStack[i] = 0x7fffffff;<br>
+ bmvStack->bmvStack[i] = bmv;<br>
+ bmvStack->bmvCostStack[i] = 0x7fffffff;<br>
}<br>
<br>
if (pmv.isSubpel())<br>
{<br>
bcost = sad(fenc, FENC_STRIDE, fref + bmv.x + bmv.y * stride, stride) + mvcost(bmv << 2);<br>
- bmvCostStack[0] = bcost;<br>
+ bmvStack->bmvCostStack[0] = bcost;<br>
}<br>
<br>
// measure SAD cost at MV(0) if MVP is not zero<br>
@@ -685,8 +682,8 @@<br>
{<br>
bcost = cost;<br>
bmv = 0;<br>
- bmvStack[0] = bmv;<br>
- bmvCostStack[0] = bcost;<br>
+ bmvStack->bmvStack[0] = bmv;<br>
+ bmvStack->bmvCostStack[0] = bcost;<br>
}<br>
}<br>
<br>
@@ -816,8 +813,8 @@<br>
/* refine predictors */<br>
omv = bmv;<br>
ucost1 = bcost;<br>
- bmvStack[0] = bmv;<br>
- bmvCostStack[0] = bcost;<br>
+ bmvStack->bmvStack[0] = bmv;<br>
+ bmvStack->bmvCostStack[0] = bcost;<br>
DIA1_ITER(pmv.x, pmv.y);<br>
if (pmv.notZero())<br>
DIA1_ITER(0, 0);<br>
@@ -945,7 +942,7 @@<br>
do \<br>
{ \<br>
COPY2_IF_LT(bcost, costs[k], dir, x * 16 + (y & 15)); \<br>
- PushToBMVStack(bmvStack, omv+MV(x*i,y*i), bmvCostStack, costs[k], maxNumBmv); \<br>
+ PushToBMVStack(bmvStack, omv+MV(x*i,y*i), costs[k]); \<br>
} while (0)<br>
<br>
SADS(0, +0, -4, +0, +4, -2, -3, +2, -3);<br>
@@ -1007,7 +1004,7 @@<br>
int bDistance = 0;<br>
<br>
const int EarlyExitIters = 3;<br>
- StarPatternSearch(ref, mvmin, mvmax, bmv, bcost, bmvStack, bmvCostStack, maxNumBmv, bPointNr, bDistance, EarlyExitIters, merange);<br>
+ StarPatternSearch(ref, mvmin, mvmax, bmv, bcost, bmvStack, bPointNr, bDistance, EarlyExitIters, merange);<br>
<br>
if (bDistance == 1)<br>
{<br>
@@ -1059,19 +1056,19 @@<br>
stride, costs);<br>
costs[0] += mvcost(tmv << 2);<br>
COPY2_IF_LT(bcost, costs[0], bmv, tmv);<br>
- PushToBMVStack(bmvStack, tmv, bmvCostStack, (costs)[0], maxNumBmv);<br>
+ PushToBMVStack(bmvStack, tmv, (costs)[0]);<br>
tmv.x += RasterDistance;<br>
costs[1] += mvcost(tmv << 2);<br>
COPY2_IF_LT(bcost, costs[1], bmv, tmv);<br>
- PushToBMVStack(bmvStack, tmv, bmvCostStack, (costs)[1], maxNumBmv);<br>
+ PushToBMVStack(bmvStack, tmv, (costs)[1]);<br>
tmv.x += RasterDistance;<br>
costs[2] += mvcost(tmv << 2);<br>
COPY2_IF_LT(bcost, costs[2], bmv, tmv);<br>
- PushToBMVStack(bmvStack, tmv, bmvCostStack, (costs)[2], maxNumBmv);<br>
+ PushToBMVStack(bmvStack, tmv, (costs)[2]);<br>
tmv.x += RasterDistance;<br>
costs[3] += mvcost(tmv << 3);<br>
COPY2_IF_LT(bcost, costs[3], bmv, tmv);<br>
- PushToBMVStack(bmvStack, tmv, bmvCostStack, (costs)[3], maxNumBmv);<br>
+ PushToBMVStack(bmvStack, tmv, (costs)[3]);<br>
}<br>
else<br>
COST_MV(tmv.x, tmv.y);<br>
@@ -1085,7 +1082,7 @@<br>
bDistance = 0;<br>
bPointNr = 0;<br>
const int MaxIters = 32;<br>
- StarPatternSearch(ref, mvmin, mvmax, bmv, bcost, bmvStack, bmvCostStack, maxNumBmv, bPointNr, bDistance, MaxIters, merange);<br>
+ StarPatternSearch(ref, mvmin, mvmax, bmv, bcost, bmvStack, bPointNr, bDistance, MaxIters, merange);<br>
<br>
if (bDistance == 1)<br>
{<br>
@@ -1135,19 +1132,19 @@<br>
stride, costs);<br>
costs[0] += mvcost(tmv << 2);<br>
COPY2_IF_LT(bcost, costs[0], bmv, tmv);<br>
- PushToBMVStack(bmvStack, tmv, bmvCostStack, (costs)[0], maxNumBmv);<br>
+ PushToBMVStack(bmvStack, tmv, (costs)[0]);<br>
tmv.x++;<br>
costs[1] += mvcost(tmv << 2);<br>
COPY2_IF_LT(bcost, costs[1], bmv, tmv);<br>
- PushToBMVStack(bmvStack, tmv, bmvCostStack, (costs)[1], maxNumBmv);<br>
+ PushToBMVStack(bmvStack, tmv, (costs)[1]);<br>
tmv.x++;<br>
costs[2] += mvcost(tmv << 2);<br>
COPY2_IF_LT(bcost, costs[2], bmv, tmv);<br>
- PushToBMVStack(bmvStack, tmv, bmvCostStack, (costs)[2], maxNumBmv);<br>
+ PushToBMVStack(bmvStack, tmv, (costs)[2]);<br>
tmv.x++;<br>
costs[3] += mvcost(tmv << 2);<br>
COPY2_IF_LT(bcost, costs[3], bmv, tmv);<br>
- PushToBMVStack(bmvStack, tmv, bmvCostStack, (costs)[3], maxNumBmv);<br>
+ PushToBMVStack(bmvStack, tmv, (costs)[3]);<br>
}<br>
else<br>
COST_MV(tmv.x, tmv.y);<br>
@@ -1166,14 +1163,14 @@<br>
{<br>
bmv = bestpre;<br>
bcost = bprecost;<br>
- PushToBMVStack(bmvStack, bmv, bmvCostStack, bcost, maxNumBmv);<br>
+ PushToBMVStack(bmvStack, bmv, bcost);<br>
}<br>
else<br>
{<br>
bmv = bmv.toQPel(); // promote search bmv to qpel<br>
- for (int i=0; i<maxNumBmv; i++)<br>
+ for (int i=0; i<bmvStack->maxNumBmv; i++)<br>
{<br>
- bmvStack[i] = bmvStack[i].toQPel();<br>
+ bmvStack->bmvStack[i] = bmvStack->bmvStack[i].toQPel()<wbr>;<br>
}<br>
}<br>
<br>
@@ -1188,11 +1185,11 @@<br>
else if (ref->isLowres)<br>
{<br>
int bdir = 0;<br>
- for (int nBmv=0; nBmv<maxNumBmv; nBmv++)<br>
+ for (int nBmv=0; nBmv<bmvStack->maxNumBmv; nBmv++)<br>
{<br>
bdir = 0;<br>
- bmv = bmvStack[nBmv];<br>
- bcost = bmvCostStack[nBmv];<br>
+ bmv = bmvStack->bmvStack[nBmv];<br>
+ bcost = bmvStack->bmvCostStack[nBmv];<br>
<br>
for (int i = 1; i <= wl.hpel_dirs; i++)<br>
{<br>
@@ -1213,18 +1210,18 @@<br>
}<br>
<br>
bmv += square1[bdir];<br>
- bmvStack[nBmv] = bmv;<br>
- bmvCostStack[nBmv] = bcost;<br>
+ bmvStack->bmvStack[nBmv] = bmv;<br>
+ bmvStack->bmvCostStack[nBmv] = bcost;<br>
}<br>
<br>
- bmv = bmvStack[0];<br>
- bcost = bmvCostStack[0];<br>
- for (int i=1; i<maxNumBmv; i++)<br>
+ bmv = bmvStack->bmvStack[0];<br>
+ bcost = bmvStack->bmvCostStack[0];<br>
+ for (int i=1; i<bmvStack->maxNumBmv; i++)<br>
{<br>
- if (bmvCostStack[i]<bcost)<br>
+ if (bmvStack->bmvCostStack[i]<<wbr>bcost)<br>
{<br>
- bmv = bmvStack[i];<br>
- bcost = bmvCostStack[i];<br>
+ bmv = bmvStack->bmvStack[i];<br>
+ bcost = bmvStack->bmvCostStack[i];<br>
}<br>
}<br>
}<br>
@@ -1232,10 +1229,10 @@<br>
{<br>
pixelcmp_t hpelcomp;<br>
<br>
- for (int nBmv=0; nBmv<maxNumBmv; nBmv++)<br>
+ for (int nBmv=0; nBmv<bmvStack->maxNumBmv; nBmv++)<br>
{<br>
- bmv = bmvStack[nBmv];<br>
- bcost = bmvCostStack[nBmv];<br>
+ bmv = bmvStack->bmvStack[nBmv];<br>
+ bcost = bmvStack->bmvCostStack[nBmv];<br>
<br>
if (wl.hpel_satd)<br>
{<br>
@@ -1281,18 +1278,18 @@<br>
break;<br>
}<br>
<br>
- bmvStack[nBmv] = bmv;<br>
- bmvCostStack[nBmv] = bcost;<br>
+ bmvStack->bmvStack[nBmv] = bmv;<br>
+ bmvStack->bmvCostStack[nBmv] = bcost;<br>
}<br>
<br>
- bmv = bmvStack[0];<br>
- bcost = bmvCostStack[0];<br>
- for (int i=1; i<maxNumBmv; i++)<br>
+ bmv = bmvStack->bmvStack[0];<br>
+ bcost = bmvStack->bmvCostStack[0];<br>
+ for (int i=1; i<bmvStack->maxNumBmv; i++)<br>
{<br>
- if (bmvCostStack[i]<bcost)<br>
+ if (bmvStack->bmvCostStack[i]<<wbr>bcost)<br>
{<br>
- bmv = bmvStack[i];<br>
- bcost = bmvCostStack[i];<br>
+ bmv = bmvStack->bmvStack[i];<br>
+ bcost = bmvStack->bmvCostStack[i];<br>
}<br>
}<br>
}<br>
diff -r f46e843a27cb -r 340dd470d7eb source/encoder/motion.h<br>
--- a/source/encoder/motion.h Fri Aug 05 17:02:17 2016 +0530<br>
+++ b/source/encoder/motion.h Sun Aug 07 11:34:50 2016 +0530<br>
@@ -34,6 +34,15 @@<br>
namespace X265_NS {<br>
// private x265 namespace<br>
<br>
+#define MAX_NUM_BESTVECTORS (16)<br>
+<br>
+typedef struct _BmvStack<br>
+{<br>
+ MV bmvStack[MAX_NUM_BESTVECTORS];<br>
+ int bmvCostStack[MAX_NUM_<wbr>BESTVECTORS];<br>
+ int maxNumBmv;<br>
+}BmvStack;<br>
+<br>
class MotionEstimate : public BitCost<br>
{<br>
protected:<br>
@@ -101,9 +110,7 @@<br>
const MV & mvmax,<br>
MV & bmv,<br>
int & bcost,<br>
- MV *bmvStack,<br>
- int *bCostStack,<br>
- int maxNumBmv,<br>
+ BmvStack *bmvStack,<br>
int & bPointNr,<br>
int & bDistance,<br>
int earlyExitIters,<br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div>Principal Architect and Director,</div><div>TriSpace Technologies Pvt Ltd.,</div><div><span style="font-size:12.8000001907349px">Bangalore</span><br></div><div><span style="font-size:12.8000001907349px"><br></span></div><div><span style="font-size:12.8px">CONFIDENTIALITY NOTE : The information in this e-mail is confidential and privileged; it is intended for use solely by the individual or entity named as the recipient hereof. Disclosure, copying, distribution, or use of the contents of this e-mail by persons other than the intended recipient is strictly prohibited and may violate applicable laws. If you have received this e-mail in error, please delete the original message and notify us by return email or collect call immediately. Thank you. TriSpace Technologies Pvt. Ltd.</span><span style="font-size:12.8000001907349px"><br></span></div><div><span style="font-size:12.8px"><br></span></div></div></div></div></div></div></div>
</div></div>