Index: branches/SHM-dev/source/Lib/TLibEncoder/TEnc3DAsymLUT.cpp
===================================================================
--- branches/SHM-dev/source/Lib/TLibEncoder/TEnc3DAsymLUT.cpp	(revision 1483)
+++ branches/SHM-dev/source/Lib/TLibEncoder/TEnc3DAsymLUT.cpp	(revision 1487)
@@ -218,13 +218,25 @@
         if( rCuboidColorInfo.N > 0 )
         {
+#if SCALABLE_REXT
+          dErrorLuma += xCalEstPelDist( rCuboidColorInfo.N , rCuboidColorInfo.Ys , rCuboidColorInfo.Yy , rCuboidColorInfo.Yu , rCuboidColorInfo.Yv , rCuboidColorInfo.ys , rCuboidColorInfo.us , rCuboidColorInfo.vs , rCuboidColorInfo.yy , rCuboidColorInfo.yu , rCuboidColorInfo.yv , rCuboidColorInfo.uu , rCuboidColorInfo.uv , rCuboidColorInfo.vv , rCuboidColorInfo.YY ,
+            rCuboid.P[0].Y , rCuboid.P[1].Y , rCuboid.P[2].Y , rCuboid.P[3].Y );
+#else
           dErrorLuma += xCalEstDist( rCuboidColorInfo.N , rCuboidColorInfo.Ys , rCuboidColorInfo.Yy , rCuboidColorInfo.Yu , rCuboidColorInfo.Yv , rCuboidColorInfo.ys , rCuboidColorInfo.us , rCuboidColorInfo.vs , rCuboidColorInfo.yy , rCuboidColorInfo.yu , rCuboidColorInfo.yv , rCuboidColorInfo.uu , rCuboidColorInfo.uv , rCuboidColorInfo.vv , rCuboidColorInfo.YY ,
             rCuboid.P[0].Y , rCuboid.P[1].Y , rCuboid.P[2].Y , rCuboid.P[3].Y );
+#endif
         }
         if( rCuboidColorInfoC.N > 0 )
         {
+#if SCALABLE_REXT
+          dErrorChroma += xCalEstPelDist( rCuboidColorInfoC.N , rCuboidColorInfoC.Us , rCuboidColorInfoC.Uy , rCuboidColorInfoC.Uu , rCuboidColorInfoC.Uv , rCuboidColorInfoC.ys , rCuboidColorInfoC.us , rCuboidColorInfoC.vs , rCuboidColorInfoC.yy , rCuboidColorInfoC.yu , rCuboidColorInfoC.yv , rCuboidColorInfoC.uu , rCuboidColorInfoC.uv , rCuboidColorInfoC.vv , rCuboidColorInfoC.UU ,
+            rCuboid.P[0].U , rCuboid.P[1].U , rCuboid.P[2].U , rCuboid.P[3].U );
+          dErrorChroma += xCalEstPelDist( rCuboidColorInfoC.N , rCuboidColorInfoC.Vs , rCuboidColorInfoC.Vy , rCuboidColorInfoC.Vu , rCuboidColorInfoC.Vv , rCuboidColorInfoC.ys , rCuboidColorInfoC.us , rCuboidColorInfoC.vs , rCuboidColorInfoC.yy , rCuboidColorInfoC.yu , rCuboidColorInfoC.yv , rCuboidColorInfoC.uu , rCuboidColorInfoC.uv , rCuboidColorInfoC.vv , rCuboidColorInfoC.VV ,
+            rCuboid.P[0].V , rCuboid.P[1].V , rCuboid.P[2].V , rCuboid.P[3].V );
+#else
           dErrorChroma += xCalEstDist( rCuboidColorInfoC.N , rCuboidColorInfoC.Us , rCuboidColorInfoC.Uy , rCuboidColorInfoC.Uu , rCuboidColorInfoC.Uv , rCuboidColorInfoC.ys , rCuboidColorInfoC.us , rCuboidColorInfoC.vs , rCuboidColorInfoC.yy , rCuboidColorInfoC.yu , rCuboidColorInfoC.yv , rCuboidColorInfoC.uu , rCuboidColorInfoC.uv , rCuboidColorInfoC.vv , rCuboidColorInfoC.UU ,
             rCuboid.P[0].U , rCuboid.P[1].U , rCuboid.P[2].U , rCuboid.P[3].U );
           dErrorChroma += xCalEstDist( rCuboidColorInfoC.N , rCuboidColorInfoC.Vs , rCuboidColorInfoC.Vy , rCuboidColorInfoC.Vu , rCuboidColorInfoC.Vv , rCuboidColorInfoC.ys , rCuboidColorInfoC.us , rCuboidColorInfoC.vs , rCuboidColorInfoC.yy , rCuboidColorInfoC.yu , rCuboidColorInfoC.yv , rCuboidColorInfoC.uu , rCuboidColorInfoC.uv , rCuboidColorInfoC.vv , rCuboidColorInfoC.VV ,
             rCuboid.P[0].V , rCuboid.P[1].V , rCuboid.P[2].V , rCuboid.P[3].V );
+#endif
         }
       }
Index: branches/SHM-dev/source/Lib/TLibEncoder/TEnc3DAsymLUT.h
===================================================================
--- branches/SHM-dev/source/Lib/TLibEncoder/TEnc3DAsymLUT.h	(revision 1483)
+++ branches/SHM-dev/source/Lib/TLibEncoder/TEnc3DAsymLUT.h	(revision 1487)
@@ -175,7 +175,13 @@
 
   inline Double xCalEstDist( Double N, Double Ys, Double Yy, Double Yu, Double Yv, Double ys, Double us, Double vs, Double yy, Double yu, Double yv, Double uu, Double uv, Double vv, Double YY, Double a, Double b, Double c, Double d );
-
+#if SCALABLE_REXT
+/* 
+former xCalEstDist(Double, Double, Double, Double, Double, Double, Double, Double, Double, Double, Double, Double, Double, Double, Double, Pel, Pel, Pel, Pel)
+replaced by this fucntion because behaving differently than other xCalEstDist and was conflicting with xCalEstDist when RExt__HIGH_BIT_DEPTH_SUPPORT = 1
+*/
+  inline Double xCalEstPelDist( Double N, Double Ys, Double Yy, Double Yu, Double Yv, Double ys, Double us, Double vs, Double yy, Double yu, Double yv, Double uu, Double uv, Double vv, Double YY, Pel nP0, Pel nP1, Pel nP3, Pel nP7 );
+#else
   inline Double xCalEstDist( Double N, Double Ys, Double Yy, Double Yu, Double Yv, Double ys, Double us, Double vs, Double yy, Double yu, Double yv, Double uu, Double uv, Double vv, Double YY, Pel nP0, Pel nP1, Pel nP3, Pel nP7 );
-
+#endif
 #if R0179_ENC_OPT_3DLUT_SIZE
   Void    xConsolidateData( SLUTSize *pCurLUTSize, SLUTSize *pMaxLUTSize );
@@ -202,5 +208,11 @@
 };
 
-Double TEnc3DAsymLUT::xCalEstDist( Double N, Double Ys, Double Yy, Double Yu, Double Yv, Double ys, Double us, Double vs, Double yy, Double yu, Double yv, Double uu, Double uv, Double vv, Double YY, Pel nP0, Pel nP1, Pel nP3, Pel nP7 )  
+
+#if SCALABLE_REXT
+/* 
+former xCalEstDist(Double, Double, Double, Double, Double, Double, Double, Double, Double, Double, Double, Double, Double, Double, Double, Pel, Pel, Pel, Pel)
+replaced by this fucntion because behaving differently than other xCalEstDist and was conflicting with xCalEstDist when RExt__HIGH_BIT_DEPTH_SUPPORT = 1
+*/
+Double TEnc3DAsymLUT::xCalEstPelDist( Double N, Double Ys, Double Yy, Double Yu, Double Yv, Double ys, Double us, Double vs, Double yy, Double yu, Double yv, Double uu, Double uv, Double vv, Double YY, Pel nP0, Pel nP1, Pel nP3, Pel nP7 )  
 {
   const Int nOne = xGetNormCoeffOne();
@@ -212,6 +224,18 @@
   return( dError );
 };
-
-#endif
-
-#endif
+#else
+Double TEnc3DAsymLUT::xCalEstDist( Double N, Double Ys, Double Yy, Double Yu, Double Yv, Double ys, Double us, Double vs, Double yy, Double yu, Double yv, Double uu, Double uv, Double vv, Double YY, Pel nP0, Pel nP1, Pel nP3, Pel nP7 )  
+{
+  const Int nOne = xGetNormCoeffOne();
+  Double a = 1.0 * nP0 / nOne;
+  Double b = 1.0 * nP1 / nOne;
+  Double c = 1.0 * nP3 / nOne;
+  Double d = nP7;
+  Double dError = N * d * d + 2 * b * c * uv + 2 * a * c * yv + 2 * a * b * yu - 2 * c * Yv - 2 * b * Yu - 2 * a * Yy + 2 * c * d * vs + 2 * b * d * us + 2 * a * d * ys + a * a * yy + c * c * vv + b * b * uu - 2 * d * Ys + YY;
+  return( dError );
+};
+#endif
+
+#endif
+
+#endif
Index: branches/SHM-dev/source/Lib/TLibEncoder/TEncCavlc.cpp
===================================================================
--- branches/SHM-dev/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 1483)
+++ branches/SHM-dev/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 1487)
@@ -1412,5 +1412,9 @@
   WRITE_FLAG(ptl->getFrameOnlyConstraintFlag(), PTL_TRACE_TEXT("frame_only_constraint_flag"      ));
 
-  if (ptl->getProfileIdc() == Profile::MAINREXT || ptl->getProfileIdc() == Profile::HIGHTHROUGHPUTREXT )
+  if (ptl->getProfileIdc() == Profile::MAINREXT || ptl->getProfileIdc() == Profile::HIGHTHROUGHPUTREXT 
+#if SCALABLE_REXT
+    || ptl->getProfileIdc() == Profile::SCALABLEREXT
+#endif
+    )
   {
     const UInt         bitDepthConstraint=ptl->getBitDepthConstraint();
Index: branches/SHM-dev/source/Lib/TLibEncoder/TEncSearch.cpp
===================================================================
--- branches/SHM-dev/source/Lib/TLibEncoder/TEncSearch.cpp	(revision 1483)
+++ branches/SHM-dev/source/Lib/TLibEncoder/TEncSearch.cpp	(revision 1487)
@@ -5960,5 +5960,9 @@
                                            TComMv& rcMvHalf,
                                            TComMv& rcMvQter,
-                                           UInt& ruiCost     )                                           
+#if SCALABLE_REXT
+                                           Distortion& ruiCost     )
+#else
+                                           UInt& ruiCost     )
+#endif
 {
   assert(pcMvInt->getHor() == 0 && pcMvInt->getVer() == 0);
@@ -5995,7 +5999,13 @@
   UInt          uiLastMode = 0;
 
+#if SCALABLE_REXT
+  Distortion    uiCost[2]   = { MAX_UINT, MAX_UINT };     //uni, rdCost
+  Distortion    uiCostTemp;
+  Distortion    biPDistTemp = MAX_INT;
+#else
   UInt          uiCost[2]   = { MAX_UINT, MAX_UINT };     //uni, rdCost
   UInt          uiCostTemp;
   UInt          biPDistTemp = MAX_INT;
+#endif
   UInt          uiBitsTemp;
 
Index: branches/SHM-dev/source/Lib/TLibEncoder/TEncSearch.h
===================================================================
--- branches/SHM-dev/source/Lib/TLibEncoder/TEncSearch.h	(revision 1483)
+++ branches/SHM-dev/source/Lib/TLibEncoder/TEncSearch.h	(revision 1487)
@@ -480,5 +480,9 @@
                                    TComMv&       rcMvHalf,
                                    TComMv&       rcMvQter,
+#if SCALABLE_REXT
+                                   Distortion&   ruiCost     );
+#else
                                    UInt&         ruiCost     );
+#endif
 #endif //SVC_EXTENSION  
 
