Index: branches/HTM-DEV-2.0-dev3-SCU-Hisilicon/source/Lib/TLibCommon/TComPrediction.cpp
===================================================================
--- branches/HTM-DEV-2.0-dev3-SCU-Hisilicon/source/Lib/TLibCommon/TComPrediction.cpp	(revision 582)
+++ branches/HTM-DEV-2.0-dev3-SCU-Hisilicon/source/Lib/TLibCommon/TComPrediction.cpp	(revision 583)
@@ -2142,6 +2142,6 @@
 
 #if SCU_HS_DMM4_REMOVE_DIV_E0242
-Int cuMaxLog2Size = g_aucConvertToBit[g_uiMaxCUWidth]+2;
-iDC = iDC >> (cuMaxLog2Size - pcCU->getDepth(0))*2;
+  Int cuMaxLog2Size = g_aucConvertToBit[g_uiMaxCUWidth]+2;
+  iDC = iDC >> (cuMaxLog2Size - pcCU->getDepth(0))*2;
 #else
   iDC /= (uiWidth*uiHeight);
Index: branches/HTM-DEV-2.0-dev3-SCU-Hisilicon/source/Lib/TLibCommon/TComRdCost.cpp
===================================================================
--- branches/HTM-DEV-2.0-dev3-SCU-Hisilicon/source/Lib/TLibCommon/TComRdCost.cpp	(revision 582)
+++ branches/HTM-DEV-2.0-dev3-SCU-Hisilicon/source/Lib/TLibCommon/TComRdCost.cpp	(revision 583)
@@ -486,33 +486,34 @@
 #if SCU_HS_FAST_DEPTH_INTRA_E0238
 
-UInt TComRdCost::calcVAR (Pel* pi0, Int uiWidth, Int uiHeight, Int cuDepth)
+UInt TComRdCost::calcVAR (Pel* pi0, Int width, Int height, Int stride, Int cuDepth)
 { 
-  Int x, y;
   Int temp = 0;
 
-  for (x = 0; x <  uiHeight; x++)
-  {
-     for (y = 0; y < uiWidth; y++)
-      {
-         temp += pi0[x*uiHeight+y]; 
-      }
-  }
+  for (Int y = 0; y < height; y++)
+  {
+    for (Int x = 0; x < width; x++)
+    {
+      temp += pi0[ y * stride + x ]; 
+    }
+  }
+
   Int cuMaxLog2Size = g_aucConvertToBit[g_uiMaxCUWidth]+2;
-  if (uiWidth == 4)
-  {
-     cuDepth = cuMaxLog2Size-2;
-  }
-
-  temp = temp >> (cuMaxLog2Size-cuDepth)*2;
-
-  UInt uiSum = 0;
-    for (x = 0; x <  uiHeight; x++)
-  {
-      for (y = 0; y < uiWidth; y++)
-      {
-        uiSum += (pi0[x*uiHeight+y]-temp)*(pi0[x*uiHeight+y]-temp);
-      }
-  }
-     return (uiSum >> (cuMaxLog2Size-cuDepth)*2);
+  
+  if ( width == 4 ) // GT: What is the rational behind this? 
+  {
+    cuDepth = cuMaxLog2Size - 2;
+  }
+
+  temp = temp >> (cuMaxLog2Size-cuDepth) * 2;
+
+  UInt sum = 0;
+  for (Int y = 0; y < height; y++)
+  {
+    for (Int x = 0; x <  width; x++)
+    {
+      sum += (pi0[ y * stride + x ] - temp ) * (pi0[ y * stride + x ] - temp );
+    }
+  }
+  return (sum >> (cuMaxLog2Size-cuDepth)*2);
 
 }
Index: branches/HTM-DEV-2.0-dev3-SCU-Hisilicon/source/Lib/TLibCommon/TComRdCost.h
===================================================================
--- branches/HTM-DEV-2.0-dev3-SCU-Hisilicon/source/Lib/TLibCommon/TComRdCost.h	(revision 582)
+++ branches/HTM-DEV-2.0-dev3-SCU-Hisilicon/source/Lib/TLibCommon/TComRdCost.h	(revision 583)
@@ -229,5 +229,5 @@
   UInt    calcHAD(Int bitDepth, Pel* pi0, Int iStride0, Pel* pi1, Int iStride1, Int iWidth, Int iHeight );
 #if SCU_HS_FAST_DEPTH_INTRA_E0238
-  UInt    calcVAR(Pel* pi0, Int uiWidth, Int uiHeight, Int cuDepth);
+  UInt    calcVAR(Pel* pi0, Int width, Int height, Int stride, Int cuDepth);
 #endif  
   // for motion cost
Index: branches/HTM-DEV-2.0-dev3-SCU-Hisilicon/source/Lib/TLibEncoder/TEncSearch.cpp
===================================================================
--- branches/HTM-DEV-2.0-dev3-SCU-Hisilicon/source/Lib/TLibEncoder/TEncSearch.cpp	(revision 582)
+++ branches/HTM-DEV-2.0-dev3-SCU-Hisilicon/source/Lib/TLibEncoder/TEncSearch.cpp	(revision 583)
@@ -2835,7 +2835,7 @@
 
 #if SCU_HS_FAST_DEPTH_INTRA_E0238
-Int threshold = max(((pcCU->getQP(0))>>3)-1,3);
-Int varThreshold = (Int)(threshold*threshold - 8);
-UInt uiVarCU=m_pcRdCost->calcVAR(piOrg, uiWidth,uiHeight,pcCU->getDepth(0));
+      Int  threshold    = max(((pcCU->getQP(0))>>3)-1,3);
+      Int  varThreshold = (Int)( threshold * threshold - 8 );
+      UInt varCU      = m_pcRdCost->calcVAR(piOrg, uiStride, uiWidth,uiHeight,pcCU->getDepth(0));
 #endif
 
@@ -2844,5 +2844,5 @@
       if( m_pcEncCfg->getUseDMM()
 #if SCU_HS_FAST_DEPTH_INTRA_E0238
-         && (uiRdModeList[0] != 0 || uiVarCU >= varThreshold)
+         && (uiRdModeList[0] != 0 || varCU >= varThreshold)
 #endif
         )
@@ -2922,5 +2922,5 @@
       if( m_pcEncCfg->getUseRBC()
 #if SCU_HS_FAST_DEPTH_INTRA_E0238
-          && (uiRdModeList[0] != 0 || uiVarCU >= varThreshold)
+          && (uiRdModeList[0] != 0 || varCU >= varThreshold)
 #endif
         )
