Index: /branches/SHM-5.1-dev/source/Lib/TLibCommon/TComUpsampleFilter.cpp
===================================================================
--- /branches/SHM-5.1-dev/source/Lib/TLibCommon/TComUpsampleFilter.cpp	(revision 639)
+++ /branches/SHM-5.1-dev/source/Lib/TLibCommon/TComUpsampleFilter.cpp	(revision 640)
@@ -162,15 +162,26 @@
   UInt currLayerId = currSlice->getLayerId();
   UInt refLayerId  = currSlice->getVPS()->getRefLayerId( currLayerId, refLayerIdc );
-
-  if( scaleX == 65536 && scaleY == 65536 && g_bitDepthYLayer[currLayerId] == g_bitDepthYLayer[refLayerId] && g_bitDepthCLayer[currLayerId] == g_bitDepthCLayer[refLayerId] ) // ratio 1x
-#else
+#endif
+
+  // non-normative software optimization for certain simple resampling cases
   if( scaleX == 65536 && scaleY == 65536 ) // ratio 1x
-#endif
   {
     piSrcY = piSrcBufY;
     piDstY = piDstBufY + scalEL.getWindowLeftOffset() + scalEL.getWindowTopOffset() * strideEL;
+
+#if O0194_JOINT_US_BITSHIFT
+    Int shift = g_bitDepthYLayer[currLayerId] - g_bitDepthYLayer[refLayerId];
+#endif
+
     for( i = 0; i < heightBL; i++ )
     {
+#if O0194_JOINT_US_BITSHIFT
+      for( j = 0; j < widthBL; j++ )
+      {
+        piDstY[j] = piSrcY[j] << shift;
+      }
+#else
       memcpy( piDstY, piSrcY, sizeof(Pel) * widthBL );
+#endif
       piSrcY += strideBL;
       piDstY += strideEL;
@@ -183,6 +194,6 @@
     heightBL >>= 1;
 
-    strideBL  = pcBasePic->getCStride();
-    strideEL  = pcUsPic->getCStride();
+    strideBL = pcBasePic->getCStride();
+    strideEL = pcUsPic->getCStride();
 
     piSrcU = piSrcBufU;
@@ -192,8 +203,20 @@
     piDstV = piDstBufV + ( scalEL.getWindowLeftOffset() >> 1 ) + ( scalEL.getWindowTopOffset() >> 1 ) * strideEL;
 
+#if O0194_JOINT_US_BITSHIFT
+    shift = g_bitDepthCLayer[currLayerId] - g_bitDepthCLayer[refLayerId];
+#endif
+
     for( i = 0; i < heightBL; i++ )
     {
+#if O0194_JOINT_US_BITSHIFT
+      for( j = 0; j < widthBL; j++ )
+      {
+        piDstU[j] = piSrcU[j] << shift;
+        piDstV[j] = piSrcV[j] << shift;
+      }
+#else
       memcpy( piDstU, piSrcU, sizeof(Pel) * widthBL );
       memcpy( piDstV, piSrcV, sizeof(Pel) * widthBL );
+#endif
       piSrcU += strideBL;
       piSrcV += strideBL;
@@ -202,5 +225,5 @@
     }
   }
-  else
+  else // general resampling process
   {
     Int refPos16 = 0;
@@ -223,5 +246,5 @@
 
     pcBasePic->setBorderExtension(false);
-    pcBasePic->extendPicBorder   (); // extend the border.
+    pcBasePic->extendPicBorder(); // extend the border.
 
     Int   shiftX = 16;
@@ -270,5 +293,5 @@
     Int leftOffset = leftStartL > 0 ? leftStartL : 0;
 
-#if  N0214_INTERMEDIATE_BUFFER_16BITS
+#if N0214_INTERMEDIATE_BUFFER_16BITS
 #if O0194_JOINT_US_BITSHIFT
     // g_bitDepthY was set to EL bit-depth, but shift1 should be calculated using BL bit-depth
@@ -293,5 +316,5 @@
       for( j = 0; j < heightBL ; j++ )
       {
-#if  N0214_INTERMEDIATE_BUFFER_16BITS
+#if N0214_INTERMEDIATE_BUFFER_16BITS
         *piDstY = sumLumaHor(piSrcY, coeff) >> shift1;
 #else
@@ -309,5 +332,5 @@
     pcTempPic->setHeight(heightEL);
 
-#if  N0214_INTERMEDIATE_BUFFER_16BITS
+#if N0214_INTERMEDIATE_BUFFER_16BITS
 #if O0194_JOINT_US_BITSHIFT
     Int nShift = 20 - g_bitDepthYLayer[currLayerId];
@@ -417,5 +440,5 @@
     heightBL  = min<Int>( pcBasePic->getHeight() >> 1, heightEL );
 
-#if  N0214_INTERMEDIATE_BUFFER_16BITS
+#if N0214_INTERMEDIATE_BUFFER_16BITS
 #if O0194_JOINT_US_BITSHIFT
     // g_bitDepthC was set to EL bit-depth, but shift1 should be calculated using BL bit-depth
@@ -442,5 +465,5 @@
       for( j = 0; j < heightBL ; j++ )
       {
-#if  N0214_INTERMEDIATE_BUFFER_16BITS
+#if N0214_INTERMEDIATE_BUFFER_16BITS
         *piDstU = sumChromaHor(piSrcU, coeff) >> shift1;
         *piDstV = sumChromaHor(piSrcV, coeff) >> shift1;
@@ -463,5 +486,5 @@
     pcTempPic->setHeight(heightEL << 1);
 
-#if  N0214_INTERMEDIATE_BUFFER_16BITS
+#if N0214_INTERMEDIATE_BUFFER_16BITS
 #if O0194_JOINT_US_BITSHIFT
     nShift = 20 - g_bitDepthCLayer[currLayerId];
