[x265] [PATCH] Coding conventions

nvijay.anand at trispacetech.com nvijay.anand at trispacetech.com
Fri Aug 12 09:43:34 CEST 2016


# HG changeset patch
# User N Vijay Anand <nvijay.anand at trispacetech.com>
# Date 1470987469 -19800
#      Fri Aug 12 13:07:49 2016 +0530
# Node ID 54155ecf97fcc6dc0c4d91aaba9055ad0a0ea4f1
# Parent  340dd470d7ebbdd6e9532b9ea6e830627600d3bf
Coding conventions

diff -r 340dd470d7eb -r 54155ecf97fc source/encoder/motion.cpp
--- a/source/encoder/motion.cpp	Sun Aug 07 11:34:50 2016 +0530
+++ b/source/encoder/motion.cpp	Fri Aug 12 13:07:49 2016 +0530
@@ -102,13 +102,14 @@
 
 inline void PushToBMVStack(BmvStack *bStack, MV & bv, int bcost)
 {
-    for (int i=0; i<bStack->maxNumBmv; i++)
+    for (int i = 0; i < bStack->maxNumBmv; i++)
     {
-        if((bStack->bmvCostStack[i] == bcost) && (bv == bStack->bmvStack[i]))
+        if ((bStack->bmvCostStack[i] == bcost) && (bv == bStack->bmvStack[i]))
             break;
-        if((bStack->bmvCostStack[i] >= bcost) && (bv != bStack->bmvStack[i]))
+
+        if ((bStack->bmvCostStack[i] >= bcost) && (bv != bStack->bmvStack[i]))
         {
-            for (int j=bStack->maxNumBmv-1; j>i; j--)
+            for (int j = bStack->maxNumBmv - 1; j > i; j--)
             {
                 bStack->bmvStack[j] = bStack->bmvStack[j-1];
                 bStack->bmvCostStack[j] = bStack->bmvCostStack[j-1];
@@ -662,7 +663,7 @@
     bmvStack->bmvCostStack[0] = bprecost;
     bmvStack->maxNumBmv = 1 << searchMethod;
 
-    for (int i=1 ; i < bmvStack->maxNumBmv; i++)
+    for (int i = 1 ; i < bmvStack->maxNumBmv; i++)
     {
         bmvStack->bmvStack[i] = bmv;
         bmvStack->bmvCostStack[i] = 0x7fffffff;
@@ -1168,9 +1169,9 @@
     else
     {
         bmv = bmv.toQPel(); // promote search bmv to qpel
-        for (int i=0; i<bmvStack->maxNumBmv; i++)
+        for (int i = 0; i < bmvStack->maxNumBmv; i++)
         {
-          bmvStack->bmvStack[i] = bmvStack->bmvStack[i].toQPel();
+            bmvStack->bmvStack[i] = bmvStack->bmvStack[i].toQPel();
         }
     }
 
@@ -1185,112 +1186,112 @@
     else if (ref->isLowres)
     {
         int bdir = 0;
-        for (int nBmv=0; nBmv<bmvStack->maxNumBmv; nBmv++)
+        for (int nBmv = 0; nBmv < bmvStack->maxNumBmv; nBmv++)
         {
-          bdir = 0;
-          bmv =  bmvStack->bmvStack[nBmv];
-          bcost = bmvStack->bmvCostStack[nBmv];
-
-          for (int i = 1; i <= wl.hpel_dirs; i++)
-          {
-              MV qmv = bmv + square1[i] * 2;
-              int cost = ref->lowresQPelCost(fenc, blockOffset, qmv, sad) + mvcost(qmv);
-              COPY2_IF_LT(bcost, cost, bdir, i);
-          }
+            bdir = 0;
+            bmv =  bmvStack->bmvStack[nBmv];
+            bcost = bmvStack->bmvCostStack[nBmv];
 
-          bmv += square1[bdir] * 2;
-          bcost = ref->lowresQPelCost(fenc, blockOffset, bmv, satd) + mvcost(bmv);
+            for (int i = 1; i <= wl.hpel_dirs; i++)
+            {
+                MV qmv = bmv + square1[i] * 2;
+                int cost = ref->lowresQPelCost(fenc, blockOffset, qmv, sad) + mvcost(qmv);
+                COPY2_IF_LT(bcost, cost, bdir, i);
+            }
 
-          bdir = 0;
-          for (int i = 1; i <= wl.qpel_dirs; i++)
-          {
-              MV qmv = bmv + square1[i];
-              int cost = ref->lowresQPelCost(fenc, blockOffset, qmv, satd) + mvcost(qmv);
-              COPY2_IF_LT(bcost, cost, bdir, i);
-          }
+            bmv += square1[bdir] * 2;
+            bcost = ref->lowresQPelCost(fenc, blockOffset, bmv, satd) + mvcost(bmv);
 
-          bmv += square1[bdir];
-          bmvStack->bmvStack[nBmv] = bmv;
-          bmvStack->bmvCostStack[nBmv] = bcost;
+            bdir = 0;
+            for (int i = 1; i <= wl.qpel_dirs; i++)
+            {
+                MV qmv = bmv + square1[i];
+                int cost = ref->lowresQPelCost(fenc, blockOffset, qmv, satd) + mvcost(qmv);
+                COPY2_IF_LT(bcost, cost, bdir, i);
+            }
+
+            bmv += square1[bdir];
+            bmvStack->bmvStack[nBmv] = bmv;
+            bmvStack->bmvCostStack[nBmv] = bcost;
         }
 
         bmv = bmvStack->bmvStack[0];
         bcost = bmvStack->bmvCostStack[0];
-        for (int i=1; i<bmvStack->maxNumBmv; i++)
+        for (int i = 1; i < bmvStack->maxNumBmv; i++)
         {
-          if (bmvStack->bmvCostStack[i]<bcost)
-          {
-            bmv = bmvStack->bmvStack[i];
-            bcost = bmvStack->bmvCostStack[i];
-          }
+            if (bmvStack->bmvCostStack[i] < bcost)
+            {
+                bmv = bmvStack->bmvStack[i];
+                bcost = bmvStack->bmvCostStack[i];
+            }
         }
     }
     else
     {
         pixelcmp_t hpelcomp;
 
-        for (int nBmv=0; nBmv<bmvStack->maxNumBmv; nBmv++)
+        for (int nBmv = 0; nBmv < bmvStack->maxNumBmv; nBmv++)
         {
-          bmv =  bmvStack->bmvStack[nBmv];
-          bcost = bmvStack->bmvCostStack[nBmv];
-
-          if (wl.hpel_satd)
-          {
-              bcost = subpelCompare(ref, bmv, satd) + mvcost(bmv);
-              hpelcomp = satd;
-          }
-          else
-              hpelcomp = sad;
-
-          for (int iter = 0; iter < wl.hpel_iters; iter++)
-          {
-              int bdir = 0;
-              for (int i = 1; i <= wl.hpel_dirs; i++)
-              {
-                  MV qmv = bmv + square1[i] * 2;
-                  int cost = subpelCompare(ref, qmv, hpelcomp) + mvcost(qmv);
-                  COPY2_IF_LT(bcost, cost, bdir, i);
-              }
+            bmv =  bmvStack->bmvStack[nBmv];
+            bcost = bmvStack->bmvCostStack[nBmv];
 
-              if (bdir)
-                  bmv += square1[bdir] * 2;
-              else
-                  break;
-          }
-
-          /* if HPEL search used SAD, remeasure with SATD before QPEL */
-          if (!wl.hpel_satd)
-              bcost = subpelCompare(ref, bmv, satd) + mvcost(bmv);
+            if (wl.hpel_satd)
+            {
+                bcost = subpelCompare(ref, bmv, satd) + mvcost(bmv);
+                hpelcomp = satd;
+            }
+            else
+                hpelcomp = sad;
 
-          for (int iter = 0; iter < wl.qpel_iters; iter++)
-          {
-              int bdir = 0;
-              for (int i = 1; i <= wl.qpel_dirs; i++)
-              {
-                  MV qmv = bmv + square1[i];
-                  int cost = subpelCompare(ref, qmv, satd) + mvcost(qmv);
-                  COPY2_IF_LT(bcost, cost, bdir, i);
-              }
+            for (int iter = 0; iter < wl.hpel_iters; iter++)
+            {
+                int bdir = 0;
+                for (int i = 1; i <= wl.hpel_dirs; i++)
+                {
+                    MV qmv = bmv + square1[i] * 2;
+                    int cost = subpelCompare(ref, qmv, hpelcomp) + mvcost(qmv);
+                    COPY2_IF_LT(bcost, cost, bdir, i);
+                }
 
-              if (bdir)
-                  bmv += square1[bdir];
-              else
-                  break;
-          }
+                if (bdir)
+                    bmv += square1[bdir] * 2;
+                else
+                    break;
+            }
 
-          bmvStack->bmvStack[nBmv] = bmv;
-          bmvStack->bmvCostStack[nBmv] = bcost;
+            /* if HPEL search used SAD, remeasure with SATD before QPEL */
+            if (!wl.hpel_satd)
+                bcost = subpelCompare(ref, bmv, satd) + mvcost(bmv);
+
+            for (int iter = 0; iter < wl.qpel_iters; iter++)
+            {
+                int bdir = 0;
+                for (int i = 1; i <= wl.qpel_dirs; i++)
+                {
+                    MV qmv = bmv + square1[i];
+                    int cost = subpelCompare(ref, qmv, satd) + mvcost(qmv);
+                    COPY2_IF_LT(bcost, cost, bdir, i);
+                }
+
+                if (bdir)
+                    bmv += square1[bdir];
+                else
+                    break;
+            }
+
+            bmvStack->bmvStack[nBmv] = bmv;
+            bmvStack->bmvCostStack[nBmv] = bcost;
         }
 
         bmv = bmvStack->bmvStack[0];
         bcost = bmvStack->bmvCostStack[0];
-        for (int i=1; i<bmvStack->maxNumBmv; i++)
+        for (int i = 1; i < bmvStack->maxNumBmv; i++)
         {
-          if (bmvStack->bmvCostStack[i]<bcost)
-          {
-            bmv = bmvStack->bmvStack[i];
-            bcost = bmvStack->bmvCostStack[i];
-          }
+            if (bmvStack->bmvCostStack[i] < bcost)
+            {
+                bmv = bmvStack->bmvStack[i];
+                bcost = bmvStack->bmvCostStack[i];
+            }
         }
     }
 
diff -r 340dd470d7eb -r 54155ecf97fc source/encoder/motion.h
--- a/source/encoder/motion.h	Sun Aug 07 11:34:50 2016 +0530
+++ b/source/encoder/motion.h	Fri Aug 12 13:07:49 2016 +0530
@@ -36,12 +36,12 @@
 
 #define MAX_NUM_BESTVECTORS     (16)
 
-typedef struct _BmvStack
+struct BmvStack
 {
     MV  bmvStack[MAX_NUM_BESTVECTORS];
     int bmvCostStack[MAX_NUM_BESTVECTORS];
     int maxNumBmv;
-}BmvStack;
+};
 
 class MotionEstimate : public BitCost
 {


More information about the x265-devel mailing list