Index: /branches/SHM-dev/source/Lib/TLibCommon/TComRdCost.cpp
===================================================================
--- /branches/SHM-dev/source/Lib/TLibCommon/TComRdCost.cpp	(revision 1388)
+++ /branches/SHM-dev/source/Lib/TLibCommon/TComRdCost.cpp	(revision 1389)
@@ -55,8 +55,7 @@
 
 // Calculate RD functions
-Double TComRdCost::calcRdCost( UInt uiBits, Distortion uiDistortion, Bool bFlag, DFunc eDFunc )
-{
-  Double dRdCost = 0.0;
-  Double dLambda = 0.0;
+Double TComRdCost::calcRdCost( Double numBits, Double distortion, DFunc eDFunc )
+{
+  Double lambda = 1.0;
 
   switch ( eDFunc )
@@ -66,15 +65,11 @@
       break;
     case DF_SAD:
-#if RExt__HIGH_BIT_DEPTH_SUPPORT
-      dLambda = m_dLambdaMotionSAD[0]; // 0 is valid, because for lossless blocks, the cost equation is modified to compensate.
-#else
-      dLambda = (Double)m_uiLambdaMotionSAD[0]; // 0 is valid, because for lossless blocks, the cost equation is modified to compensate.
-#endif
+      lambda = m_dLambdaMotionSAD[0]; // 0 is valid, because for lossless blocks, the cost equation is modified to compensate.
       break;
     case DF_DEFAULT:
-      dLambda =         m_dLambda;
+      lambda = m_dLambda;
       break;
     case DF_SSE_FRAME:
-      dLambda =         m_dFrameLambda;
+      lambda = m_dFrameLambda;
       break;
     default:
@@ -83,112 +78,26 @@
   }
 
-  if (bFlag) //NOTE: this "bFlag" is never true
-  {
-    // Intra8x8, Intra4x4 Block only...
+  if (eDFunc == DF_SAD)
+  {
     if (m_costMode != COST_STANDARD_LOSSY)
     {
-      dRdCost = (Double(uiDistortion) / dLambda) + Double(uiBits); // all lossless costs would have uiDistortion=0, and therefore this cost function can be used.
+      return ((distortion * 65536.0) / lambda) + numBits; // all lossless costs would have uiDistortion=0, and therefore this cost function can be used.
     }
     else
     {
-      dRdCost = (((Double)uiDistortion) + ((Double)uiBits * dLambda));
+      return distortion + (((numBits * lambda) ) / 65536.0);
     }
   }
   else
   {
-    if (eDFunc == DF_SAD)
-    {
-      if (m_costMode != COST_STANDARD_LOSSY)
-      {
-        dRdCost = ((Double(uiDistortion) * 65536) / dLambda) + Double(uiBits); // all lossless costs would have uiDistortion=0, and therefore this cost function can be used.
-      }
-      else
-      {
-        dRdCost = Double(uiDistortion) + ((Double(uiBits) * dLambda) / 65536.0);
-      }
+    if (m_costMode != COST_STANDARD_LOSSY)
+    {
+      return (distortion / lambda) + numBits; // all lossless costs would have uiDistortion=0, and therefore this cost function can be used.
     }
     else
     {
-      if (m_costMode != COST_STANDARD_LOSSY)
-      {
-        dRdCost = (Double(uiDistortion) / dLambda) + Double(uiBits); // all lossless costs would have uiDistortion=0, and therefore this cost function can be used.
-      }
-      else
-      {
-        dRdCost = Double(uiDistortion) + (Double(uiBits) * dLambda);
-      }
-    }
-  }
-
-  return dRdCost;
-}
-
-Double TComRdCost::calcRdCost64( UInt64 uiBits, UInt64 uiDistortion, Bool bFlag, DFunc eDFunc )
-{
-  Double dRdCost = 0.0;
-  Double dLambda = 0.0;
-
-  switch ( eDFunc )
-  {
-    case DF_SSE:
-      assert(0);
-      break;
-    case DF_SAD:
-#if RExt__HIGH_BIT_DEPTH_SUPPORT
-      dLambda = m_dLambdaMotionSAD[0]; // 0 is valid, because for lossless blocks, the cost equation is modified to compensate.
-#else
-      dLambda = (Double)m_uiLambdaMotionSAD[0]; // 0 is valid, because for lossless blocks, the cost equation is modified to compensate.
-#endif
-      break;
-    case DF_DEFAULT:
-      dLambda =         m_dLambda;
-      break;
-    case DF_SSE_FRAME:
-      dLambda =         m_dFrameLambda;
-      break;
-    default:
-      assert (0);
-      break;
-  }
-
-  if (bFlag) //NOTE: this "bFlag" is never true
-  {
-    // Intra8x8, Intra4x4 Block only...
-    if (m_costMode != COST_STANDARD_LOSSY)
-    {
-      dRdCost = (Double(uiDistortion) / dLambda) + Double(uiBits); // all lossless costs would have uiDistortion=0, and therefore this cost function can be used.
-    }
-    else
-    {
-      dRdCost = (((Double)(Int64)uiDistortion) + ((Double)(Int64)uiBits * dLambda));
-    }
-  }
-  else
-  {
-    if (eDFunc == DF_SAD)
-    {
-      if (m_costMode != COST_STANDARD_LOSSY)
-      {
-        dRdCost = ((Double(uiDistortion) * 65536) / dLambda) + Double(uiBits); // all lossless costs would have uiDistortion=0, and therefore this cost function can be used.
-      }
-      else
-      {
-        dRdCost = Double(uiDistortion) + ((Double(uiBits) * dLambda) / 65536.0);
-      }
-    }
-    else
-    {
-      if (m_costMode != COST_STANDARD_LOSSY)
-      {
-        dRdCost = (Double(uiDistortion) / dLambda) + Double(uiBits); // all lossless costs would have uiDistortion=0, and therefore this cost function can be used.
-      }
-      else
-      {
-        dRdCost = Double(uiDistortion) + (Double(uiBits) * dLambda);
-      }
-    }
-  }
-
-  return dRdCost;
+      return distortion + (numBits * lambda);
+    }
+  }
 }
 
@@ -197,5 +106,4 @@
   m_dLambda           = dLambda;
   m_sqrtLambda        = sqrt(m_dLambda);
-#if RExt__HIGH_BIT_DEPTH_SUPPORT
   m_dLambdaMotionSAD[0] = 65536.0 * m_sqrtLambda;
   m_dLambdaMotionSSE[0] = 65536.0 * m_dLambda;
@@ -207,15 +115,4 @@
   m_dLambdaMotionSAD[1] = 65536.0 * sqrt(dLambda);
   m_dLambdaMotionSSE[1] = 65536.0 * dLambda;
-#else
-  m_uiLambdaMotionSAD[0] = (UInt)floor(65536.0 * m_sqrtLambda);
-  m_uiLambdaMotionSSE[0] = (UInt)floor(65536.0 * m_dLambda   );
-#if FULL_NBIT
-  dLambda = 0.57 * pow(2.0, ((LOSSLESS_AND_MIXED_LOSSLESS_RD_COST_TEST_QP_PRIME - 12) / 3.0));
-#else
-  dLambda = 0.57 * pow(2.0, ((LOSSLESS_AND_MIXED_LOSSLESS_RD_COST_TEST_QP_PRIME - 12 - 6 * (bitDepths.recon[CHANNEL_TYPE_LUMA] - 8)) / 3.0));
-#endif
-  m_uiLambdaMotionSAD[1] = (UInt)floor(65536.0 * sqrt(dLambda));
-  m_uiLambdaMotionSSE[1] = (UInt)floor(65536.0 * dLambda   );
-#endif
 }
 
@@ -268,9 +165,5 @@
   m_costMode                   = COST_STANDARD_LOSSY;
 
-#if RExt__HIGH_BIT_DEPTH_SUPPORT
   m_dCost                      = 0;
-#else
-  m_uiCost                     = 0;
-#endif
   m_iCostScale                 = 0;
 }
Index: /branches/SHM-dev/source/Lib/TLibCommon/TComRdCost.h
===================================================================
--- /branches/SHM-dev/source/Lib/TLibCommon/TComRdCost.h	(revision 1388)
+++ /branches/SHM-dev/source/Lib/TLibCommon/TComRdCost.h	(revision 1389)
@@ -112,20 +112,11 @@
   Double                  m_dLambda;
   Double                  m_sqrtLambda;
-#if RExt__HIGH_BIT_DEPTH_SUPPORT
   Double                  m_dLambdaMotionSAD[2 /* 0=standard, 1=for transquant bypass when mixed-lossless cost evaluation enabled*/];
   Double                  m_dLambdaMotionSSE[2 /* 0=standard, 1=for transquant bypass when mixed-lossless cost evaluation enabled*/];
-#else
-  UInt                    m_uiLambdaMotionSAD[2 /* 0=standard, 1=for transquant bypass when mixed-lossless cost evaluation enabled*/];
-  UInt                    m_uiLambdaMotionSSE[2 /* 0=standard, 1=for transquant bypass when mixed-lossless cost evaluation enabled*/];
-#endif
   Double                  m_dFrameLambda;
 
   // for motion cost
   TComMv                  m_mvPredictor;
-#if RExt__HIGH_BIT_DEPTH_SUPPORT
   Double                  m_dCost;
-#else
-  UInt                    m_uiCost;
-#endif
   Int                     m_iCostScale;
 
@@ -134,6 +125,5 @@
   virtual ~TComRdCost();
 
-  Double  calcRdCost  ( UInt   uiBits, Distortion uiDistortion, Bool bFlag = false, DFunc eDFunc = DF_DEFAULT );
-  Double  calcRdCost64( UInt64 uiBits, UInt64 uiDistortion, Bool bFlag = false, DFunc eDFunc = DF_DEFAULT );
+  Double calcRdCost( Double numBits, Double distortion, DFunc eDFunc = DF_DEFAULT );
 
   Void    setDistortionWeight  ( const ComponentID compID, const Double distortionWeight ) { m_distortionWeight[compID] = distortionWeight; }
@@ -160,9 +150,5 @@
   // for motion cost
   static UInt    xGetExpGolombNumberOfBits( Int iVal );
-#if RExt__HIGH_BIT_DEPTH_SUPPORT
   Void    getMotionCost( Bool bSad, Int iAdd, Bool bIsTransquantBypass ) { m_dCost = (bSad ? m_dLambdaMotionSAD[(bIsTransquantBypass && m_costMode==COST_MIXED_LOSSLESS_LOSSY_CODING) ?1:0] + iAdd : m_dLambdaMotionSSE[(bIsTransquantBypass && m_costMode==COST_MIXED_LOSSLESS_LOSSY_CODING)?1:0] + iAdd); }
-#else
-  Void    getMotionCost( Bool bSad, Int iAdd, Bool bIsTransquantBypass ) { m_uiCost = (bSad ? m_uiLambdaMotionSAD[(bIsTransquantBypass && m_costMode==COST_MIXED_LOSSLESS_LOSSY_CODING) ?1:0] + iAdd : m_uiLambdaMotionSSE[(bIsTransquantBypass && m_costMode==COST_MIXED_LOSSLESS_LOSSY_CODING)?1:0] + iAdd); }
-#endif
   Void    setPredictor( TComMv& rcMv )
   {
@@ -172,15 +158,7 @@
   __inline Distortion getCost( Int x, Int y )
   {
-#if RExt__HIGH_BIT_DEPTH_SUPPORT
     return Distortion((m_dCost * getBits(x, y)) / 65536.0);
-#else
-    return m_uiCost * getBits(x, y) >> 16;
-#endif
-  }
-#if RExt__HIGH_BIT_DEPTH_SUPPORT
+  }
   Distortion getCost( UInt b )                 { return Distortion(( m_dCost * b ) / 65536.0); }
-#else
-  Distortion getCost( UInt b )                 { return ( m_uiCost * b ) >> 16; }
-#endif
   UInt    getBits( Int x, Int y )
   {
Index: /branches/SHM-dev/source/Lib/TLibEncoder/TEncSearch.cpp
===================================================================
--- /branches/SHM-dev/source/Lib/TLibEncoder/TEncSearch.cpp	(revision 1388)
+++ /branches/SHM-dev/source/Lib/TLibEncoder/TEncSearch.cpp	(revision 1389)
@@ -2824,7 +2824,7 @@
 Void TEncSearch::IPCMSearch( TComDataCU* pcCU, TComYuv* pcOrgYuv, TComYuv* pcPredYuv, TComYuv* pcResiYuv, TComYuv* pcRecoYuv )
 {
-  UInt        uiDepth      = pcCU->getDepth(0);
-  const UInt  uiDistortion = 0;
-  UInt        uiBits;
+  UInt              uiDepth      = pcCU->getDepth(0);
+  const Distortion  uiDistortion = 0;
+  UInt              uiBits;
 
   Double dCost;
@@ -3857,5 +3857,5 @@
   uiCost = m_pcRdCost->getDistPart( pcCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_LUMA), pcTemplateCand->getAddr(COMPONENT_Y, uiPartAddr), pcTemplateCand->getStride(COMPONENT_Y), pcOrgYuv->getAddr(COMPONENT_Y, uiPartAddr), pcOrgYuv->getStride(COMPONENT_Y), iSizeX, iSizeY, COMPONENT_Y, DF_SAD );
 #endif
-  uiCost = (UInt) m_pcRdCost->calcRdCost( m_auiMVPIdxCost[iMVPIdx][iMVPNum], uiCost, false, DF_SAD );
+  uiCost = (UInt) m_pcRdCost->calcRdCost( m_auiMVPIdxCost[iMVPIdx][iMVPNum], uiCost, DF_SAD );
   return uiCost;
 }
Index: /branches/SHM-dev/source/Lib/TLibEncoder/TEncSlice.cpp
===================================================================
--- /branches/SHM-dev/source/Lib/TLibEncoder/TEncSlice.cpp	(revision 1388)
+++ /branches/SHM-dev/source/Lib/TLibEncoder/TEncSlice.cpp	(revision 1389)
@@ -688,5 +688,5 @@
 
     // compute RD cost and choose the best
-    Double dPicRdCost = m_pcRdCost->calcRdCost64( m_uiPicTotalBits, uiPicDist, true, DF_SSE_FRAME); // NOTE: Is the 'true' parameter really necessary?
+    Double dPicRdCost = m_pcRdCost->calcRdCost( (Double)m_uiPicTotalBits, (Double)uiPicDist, DF_SSE_FRAME);
 
     if ( dPicRdCost < dPicRdCostBest )
@@ -1376,9 +1376,9 @@
 #if SVC_EXTENSION
 #if JCTVC_M0259_LAMBDAREFINEMENT
-Double TEncSlice::xCalEnhLambdaFactor( Double deltaQP , Double beta )
-{
-  double tmp = beta * pow( 2.0 , deltaQP / 6 );
-  double gamma = tmp / ( tmp + 1 );
-  return( gamma );
+Double TEncSlice::xCalEnhLambdaFactor( Double deltaQP, Double beta )
+{
+  Double tmp = beta * pow( 2.0 , deltaQP / 6 );
+  Double gamma = tmp / ( tmp + 1 );
+  return gamma;
 }
 #endif
Index: /branches/SHM-dev/source/Lib/TLibEncoder/TEncSlice.h
===================================================================
--- /branches/SHM-dev/source/Lib/TLibEncoder/TEncSlice.h	(revision 1388)
+++ /branches/SHM-dev/source/Lib/TLibEncoder/TEncSlice.h	(revision 1389)
@@ -147,5 +147,5 @@
 
 #if SVC_EXTENSION && JCTVC_M0259_LAMBDAREFINEMENT
-  Double  xCalEnhLambdaFactor( Double deltaQP , Double beta );
+  Double  xCalEnhLambdaFactor( Double deltaQP, Double beta );
 #endif
 };
