Index: branches/HM-10.0-dev-SHM/source/Lib/TLibCommon/TComDataCU.cpp
===================================================================
--- branches/HM-10.0-dev-SHM/source/Lib/TLibCommon/TComDataCU.cpp	(revision 69)
+++ branches/HM-10.0-dev-SHM/source/Lib/TLibCommon/TComDataCU.cpp	(revision 71)
@@ -4123,18 +4123,18 @@
 
 #if SVC_UPSAMPLING
-  Int iBWidth   = cBaseColPic->getPicYuvRec()->getWidth () - cBaseColPic->getPicYuvRec()->getPicCropLeftOffset() - cBaseColPic->getPicYuvRec()->getPicCropRightOffset();
-  Int iBHeight  = cBaseColPic->getPicYuvRec()->getHeight() - cBaseColPic->getPicYuvRec()->getPicCropTopOffset() - cBaseColPic->getPicYuvRec()->getPicCropBottomOffset();
-
-  Int iEWidth   = m_pcPic->getPicYuvRec()->getWidth() - m_pcPic->getPicYuvRec()->getPicCropLeftOffset() - m_pcPic->getPicYuvRec()->getPicCropRightOffset();
-  Int iEHeight  = m_pcPic->getPicYuvRec()->getHeight() - m_pcPic->getPicYuvRec()->getPicCropTopOffset() - m_pcPic->getPicYuvRec()->getPicCropBottomOffset();
+  Int widthBL   = cBaseColPic->getPicYuvRec()->getWidth () - cBaseColPic->getPicYuvRec()->getPicCropLeftOffset() - cBaseColPic->getPicYuvRec()->getPicCropRightOffset();
+  Int heightBL  = cBaseColPic->getPicYuvRec()->getHeight() - cBaseColPic->getPicYuvRec()->getPicCropTopOffset() - cBaseColPic->getPicYuvRec()->getPicCropBottomOffset();
+
+  Int widthEL   = m_pcPic->getPicYuvRec()->getWidth() - m_pcPic->getPicYuvRec()->getPicCropLeftOffset() - m_pcPic->getPicYuvRec()->getPicCropRightOffset();
+  Int heightEL  = m_pcPic->getPicYuvRec()->getHeight() - m_pcPic->getPicYuvRec()->getPicCropTopOffset() - m_pcPic->getPicYuvRec()->getPicCropBottomOffset();
 #else
-  Int iBWidth   = cBaseColPic->getPicYuvRec()->getWidth();
-  Int iBHeight  = cBaseColPic->getPicYuvRec()->getHeight();
-
-  Int iEWidth   = m_pcPic->getPicYuvRec()->getWidth();
-  Int iEHeight  = m_pcPic->getPicYuvRec()->getHeight();
-#endif
-
-  if (iBWidth == iEWidth && iEHeight == iBHeight)
+  Int widthBL   = cBaseColPic->getPicYuvRec()->getWidth();
+  Int heightBL  = cBaseColPic->getPicYuvRec()->getHeight();
+
+  Int widthEL   = m_pcPic->getPicYuvRec()->getWidth();
+  Int heightEL  = m_pcPic->getPicYuvRec()->getHeight();
+#endif
+
+  if (widthBL == widthEL && heightEL == heightBL)
   {
     uiAbsPartIdxBase = uiCuAbsPartIdx + m_uiAbsIdxInLCU;
@@ -4150,6 +4150,6 @@
     Int iEY = m_uiCUPelY + uiMinUnitSize*(uiRasterAddr/uiNumPartInCUWidth);
 
-    Int iBX = (iEX*iBWidth + iEWidth/2)/iEWidth;
-    Int iBY = (iEY*iBHeight+ iEHeight/2)/iEHeight;
+    Int iBX = (iEX*widthBL + widthEL/2)/widthEL;
+    Int iBY = (iEY*heightBL+ heightEL/2)/heightEL;
 
     uiCUAddrBase = (iBY/g_uiMaxCUHeight)*cBaseColPic->getFrameWidthInCU() + (iBX/g_uiMaxCUWidth);
@@ -4175,15 +4175,15 @@
   const Window &confEL = m_pcPic->getPicYuvRec()->getConformanceWindow();
 
-  Int iBWidth   = m_pcSlice->getBaseColPic()->getPicYuvRec()->getWidth () - confBL.getWindowLeftOffset() - confBL.getWindowRightOffset();
-  Int iBHeight  = m_pcSlice->getBaseColPic()->getPicYuvRec()->getHeight() - confBL.getWindowTopOffset() - confBL.getWindowBottomOffset();
-
-  Int iEWidth   = m_pcPic->getPicYuvRec()->getWidth() - confEL.getWindowLeftOffset() - confEL.getWindowRightOffset();
-  Int iEHeight  = m_pcPic->getPicYuvRec()->getHeight() - confEL.getWindowTopOffset() - confEL.getWindowBottomOffset();
+  Int widthBL   = m_pcSlice->getBaseColPic()->getPicYuvRec()->getWidth () - confBL.getWindowLeftOffset() - confBL.getWindowRightOffset();
+  Int heightBL  = m_pcSlice->getBaseColPic()->getPicYuvRec()->getHeight() - confBL.getWindowTopOffset() - confBL.getWindowBottomOffset();
+
+  Int widthEL   = m_pcPic->getPicYuvRec()->getWidth() - confEL.getWindowLeftOffset() - confEL.getWindowRightOffset();
+  Int heightEL  = m_pcPic->getPicYuvRec()->getHeight() - confEL.getWindowTopOffset() - confEL.getWindowBottomOffset();
 #else
-  Int iBWidth   = cBaseColPic->getPicYuvRec()->getWidth();
-  Int iBHeight  = cBaseColPic->getPicYuvRec()->getHeight();
-
-  Int iEWidth   = m_pcPic->getPicYuvRec()->getWidth();
-  Int iEHeight  = m_pcPic->getPicYuvRec()->getHeight();
+  Int widthBL   = cBaseColPic->getPicYuvRec()->getWidth();
+  Int heightBL  = cBaseColPic->getPicYuvRec()->getHeight();
+
+  Int widthEL   = m_pcPic->getPicYuvRec()->getWidth();
+  Int heightEL  = m_pcPic->getPicYuvRec()->getHeight();
 #endif
 
@@ -4193,6 +4193,6 @@
   UInt uiMinUnitSize = m_pcPic->getMinCUWidth();
 
-  Int iBX = (uiPelX*iBWidth + iEWidth/2)/iEWidth;
-  Int iBY = (uiPelY*iBHeight+ iEHeight/2)/iEHeight;
+  Int iBX = (uiPelX*widthBL + widthEL/2)/widthEL;
+  Int iBY = (uiPelY*heightBL+ heightEL/2)/heightEL;
 
   if ( iBX >= cBaseColPic->getPicYuvRec()->getWidth() || iBY >= cBaseColPic->getPicYuvRec()->getHeight())
@@ -4202,5 +4202,5 @@
 
 #if AVC_SYNTAX
-  if( iBX >= iBWidth || iBY >= iBHeight ) //outside of the reference layer cropped picture
+  if( iBX >= widthBL || iBY >= heightBL ) //outside of the reference layer cropped picture
   {
     return NULL;
@@ -4229,19 +4229,19 @@
   const Window &confEL = m_pcPic->getPicYuvRec()->getConformanceWindow();
 
-  Int iBWidth   = m_pcSlice->getBaseColPic()->getPicYuvRec()->getWidth () - confBL.getWindowLeftOffset() - confBL.getWindowRightOffset();
-  Int iBHeight  = m_pcSlice->getBaseColPic()->getPicYuvRec()->getHeight() - confBL.getWindowTopOffset() - confBL.getWindowBottomOffset();
-
-  Int iEWidth   = m_pcPic->getPicYuvRec()->getWidth() - confEL.getWindowLeftOffset() - confEL.getWindowRightOffset();
-  Int iEHeight  = m_pcPic->getPicYuvRec()->getHeight() - confEL.getWindowTopOffset() - confEL.getWindowBottomOffset();
+  Int widthBL   = m_pcSlice->getBaseColPic()->getPicYuvRec()->getWidth () - confBL.getWindowLeftOffset() - confBL.getWindowRightOffset();
+  Int heightBL  = m_pcSlice->getBaseColPic()->getPicYuvRec()->getHeight() - confBL.getWindowTopOffset() - confBL.getWindowBottomOffset();
+
+  Int widthEL   = m_pcPic->getPicYuvRec()->getWidth() - confEL.getWindowLeftOffset() - confEL.getWindowRightOffset();
+  Int heightEL  = m_pcPic->getPicYuvRec()->getHeight() - confEL.getWindowTopOffset() - confEL.getWindowBottomOffset();
 #else
-  Int iBWidth   = m_pcSlice->getBaseColPic()->getPicYuvRec()->getWidth();
-  Int iBHeight  = m_pcSlice->getBaseColPic()->getPicYuvRec()->getHeight();
-
-  Int iEWidth   = m_pcPic->getPicYuvRec()->getWidth();
-  Int iEHeight  = m_pcPic->getPicYuvRec()->getHeight();
-#endif
-
-  Int iMvX = (rcMvFieldBase.getHor()*iEWidth + (iBWidth/2 -1) * (rcMvFieldBase.getHor() > 0 ? 1: -1) )/iBWidth;
-  Int iMvY = (rcMvFieldBase.getVer()*iEHeight + (iBHeight/2 -1) * (rcMvFieldBase.getVer() > 0 ? 1: -1) )/iBHeight;
+  Int widthBL   = m_pcSlice->getBaseColPic()->getPicYuvRec()->getWidth();
+  Int heightBL  = m_pcSlice->getBaseColPic()->getPicYuvRec()->getHeight();
+
+  Int widthEL   = m_pcPic->getPicYuvRec()->getWidth();
+  Int heightEL  = m_pcPic->getPicYuvRec()->getHeight();
+#endif
+
+  Int iMvX = (rcMvFieldBase.getHor()*widthEL + (widthBL/2 -1) * (rcMvFieldBase.getHor() > 0 ? 1: -1) )/widthBL;
+  Int iMvY = (rcMvFieldBase.getVer()*heightEL + (heightBL/2 -1) * (rcMvFieldBase.getVer() > 0 ? 1: -1) )/heightBL;
 
   cMv.set(iMvX, iMvY);
Index: branches/HM-10.0-dev-SHM/source/Lib/TLibCommon/TComPic.cpp
===================================================================
--- branches/HM-10.0-dev-SHM/source/Lib/TLibCommon/TComPic.cpp	(revision 69)
+++ branches/HM-10.0-dev-SHM/source/Lib/TLibCommon/TComPic.cpp	(revision 71)
@@ -589,35 +589,35 @@
 #if REF_IDX_MFM
 #if !REUSE_BLKMAPPING
-Void TComPic::deriveUnitIdxBase( UInt uiUpsamplePelX, UInt uiUpsamplePelY, UInt ratio, UInt& uiBaseCUAddr, UInt& uiBaseAbsPartIdx )
+Void TComPic::deriveUnitIdxBase( UInt upsamplePelX, UInt upsamplePelY, UInt ratio, UInt& baseCUAddr, UInt& baseAbsPartIdx )
 {
   //pixel in the base layer
 
-  UInt uiPelX       = (uiUpsamplePelX<<1)/ratio;
-  UInt uiPelY       = (uiUpsamplePelY<<1)/ratio;
-  UInt uiBaseWidth  = getPicYuvRec()->getWidth();
-  UInt uiBaseHeight = getPicYuvRec()->getHeight();
+  UInt pelX       = (upsamplePelX<<1)/ratio;
+  UInt pelY       = (upsamplePelY<<1)/ratio;
+  UInt baseWidth  = getPicYuvRec()->getWidth();
+  UInt baseHeight = getPicYuvRec()->getHeight();
   
-  UInt uiWidthInCU       = ( uiBaseWidth % g_uiMaxCUWidth  ) ? uiBaseWidth /g_uiMaxCUWidth  + 1 : uiBaseWidth /g_uiMaxCUWidth;
+  UInt widthInCU       = ( baseWidth % g_uiMaxCUWidth  ) ? baseWidth /g_uiMaxCUWidth  + 1 : baseWidth /g_uiMaxCUWidth;
 
 #if MFM_CLIPPING_FIX
-  uiPelX     = (UInt)Clip3<UInt>(0, getPicYuvRec()->getWidth() - 1, uiPelX);
-  uiPelY     = (UInt)Clip3<UInt>(0, getPicYuvRec()->getHeight() - 1, uiPelY);
+  pelX     = (UInt)Clip3<UInt>(0, getPicYuvRec()->getWidth() - 1, pelX);
+  pelY     = (UInt)Clip3<UInt>(0, getPicYuvRec()->getHeight() - 1, pelY);
 #else
-  UInt uiHeightInCU      = ( uiBaseHeight% g_uiMaxCUHeight ) ? uiBaseHeight/ g_uiMaxCUHeight + 1 : uiBaseHeight/ g_uiMaxCUHeight;
-
-  uiPelX     = (UInt)Clip3<UInt>(0, uiWidthInCU * g_uiMaxCUWidth - 1, uiPelX);
-  uiPelY     = (UInt)Clip3<UInt>(0, uiHeightInCU * g_uiMaxCUHeight - 1, uiPelY);
+  UInt heightInCU      = ( baseHeight% g_uiMaxCUHeight ) ? baseHeight/ g_uiMaxCUHeight + 1 : baseHeight/ g_uiMaxCUHeight;
+
+  pelX     = (UInt)Clip3<UInt>(0, widthInCU * g_uiMaxCUWidth - 1, pelX);
+  pelY     = (UInt)Clip3<UInt>(0, heightInCU * g_uiMaxCUHeight - 1, pelY);
 #endif
   
-  uiBaseCUAddr = uiPelY / g_uiMaxCUHeight * uiWidthInCU + uiPelX / g_uiMaxCUWidth;
-
-  UInt uiWidthMinPU = g_uiMaxCUWidth / (1<<g_uiMaxCUDepth);
-  UInt uiHeightMinPU = g_uiMaxCUHeight/(1<<g_uiMaxCUDepth);
+  baseCUAddr = pelY / g_uiMaxCUHeight * widthInCU + pelX / g_uiMaxCUWidth;
+
+  UInt widthMinPU = g_uiMaxCUWidth / (1<<g_uiMaxCUDepth);
+  UInt heightMinPU = g_uiMaxCUHeight/(1<<g_uiMaxCUDepth);
   
-  UInt uiAbsPelX = uiPelX - (uiPelX / g_uiMaxCUWidth) * g_uiMaxCUWidth;
-  UInt uiAbsPelY = uiPelY - (uiPelY / g_uiMaxCUHeight) * g_uiMaxCUHeight;
-
-  UInt RasterIdx = uiAbsPelY / uiHeightMinPU * (g_uiMaxCUWidth/uiWidthMinPU) + uiAbsPelX / uiWidthMinPU;
-  uiBaseAbsPartIdx = g_auiRasterToZscan[RasterIdx];
+  UInt absPelX = pelX - (pelX / g_uiMaxCUWidth) * g_uiMaxCUWidth;
+  UInt absPelY = pelY - (pelY / g_uiMaxCUHeight) * g_uiMaxCUHeight;
+
+  UInt rasterIdx = absPelY / heightMinPU * (g_uiMaxCUWidth/widthMinPU) + absPelX / widthMinPU;
+  baseAbsPartIdx = g_auiRasterToZscan[rasterIdx];
 
   return;
@@ -631,22 +631,22 @@
   const Window &confEL = getPicYuvRec()->getConformanceWindow();
 
-  Int iBWidth   = pcPicBase->getPicYuvRec()->getWidth () - confBL.getWindowLeftOffset() - confBL.getWindowRightOffset();
-  Int iBHeight  = pcPicBase->getPicYuvRec()->getHeight() - confBL.getWindowTopOffset() - confBL.getWindowBottomOffset();
-
-  Int iEWidth   = getPicYuvRec()->getWidth() - confEL.getWindowLeftOffset() - confEL.getWindowRightOffset();
-  Int iEHeight  = getPicYuvRec()->getHeight() - confEL.getWindowTopOffset() - confEL.getWindowBottomOffset();
+  Int widthBL   = pcPicBase->getPicYuvRec()->getWidth () - confBL.getWindowLeftOffset() - confBL.getWindowRightOffset();
+  Int heightBL  = pcPicBase->getPicYuvRec()->getHeight() - confBL.getWindowTopOffset() - confBL.getWindowBottomOffset();
+
+  Int widthEL   = getPicYuvRec()->getWidth() - confEL.getWindowLeftOffset() - confEL.getWindowRightOffset();
+  Int heightEL  = getPicYuvRec()->getHeight() - confEL.getWindowTopOffset() - confEL.getWindowBottomOffset();
 #endif
   
 #if !REUSE_MVSCALE  || !REUSE_BLKMAPPING
   UInt upSampleRatio = 0;
-  if(iEWidth == iBWidth && iEHeight == iBHeight)
+  if(widthEL == widthBL && heightEL == heightBL)
   {
     upSampleRatio = 2;
   }
-  else if(2*iEWidth == 3*iBWidth && 2*iEHeight == 3*iBHeight)
+  else if(2*widthEL == 3*widthBL && 2*heightEL == 3*heightBL)
   {
     upSampleRatio = 3;
   }
-  else if(iEWidth == 2*iBWidth && iEHeight == 2*iBHeight)
+  else if(widthEL == 2*widthBL && heightEL == 2*heightBL)
   {
     upSampleRatio = 4;
@@ -658,8 +658,8 @@
 #endif
 
-  UInt uiNumPartitions   = 1<<(g_uiMaxCUDepth<<1);
-  UInt uiWidthMinPU      = g_uiMaxCUWidth/(1<<g_uiMaxCUDepth);
-  UInt uiHeightMinPU     = g_uiMaxCUHeight/(1<<g_uiMaxCUDepth);
-  Int  unitNum           = max (1, (Int)((16/uiWidthMinPU)*(16/uiHeightMinPU)) ); 
+  UInt numPartitions   = 1<<(g_uiMaxCUDepth<<1);
+  UInt widthMinPU      = g_uiMaxCUWidth/(1<<g_uiMaxCUDepth);
+  UInt heightMinPU     = g_uiMaxCUHeight/(1<<g_uiMaxCUDepth);
+  Int  unitNum         = max (1, (Int)((16/widthMinPU)*(16/heightMinPU)) ); 
 
   for(UInt cuIdx = 0; cuIdx < getPicSym()->getNumberOfCUsInFrame(); cuIdx++)  //each LCU
@@ -667,32 +667,32 @@
     TComDataCU*             pcCUDes = getCU(cuIdx);
 
-    for(UInt uiAbsPartIdx = 0; uiAbsPartIdx < uiNumPartitions; uiAbsPartIdx+=unitNum )  //each 16x16 unit
+    for(UInt absPartIdx = 0; absPartIdx < numPartitions; absPartIdx+=unitNum )  //each 16x16 unit
     {
       //pixel position of each unit in up-sampled layer
-      UInt  uiPelX = pcCUDes->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ];
-      UInt  uiPelY = pcCUDes->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ];
-      UInt uiBaseCUAddr, uiBaseAbsPartIdx;
+      UInt  pelX = pcCUDes->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[absPartIdx] ];
+      UInt  pelY = pcCUDes->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[absPartIdx] ];
+      UInt baseCUAddr, baseAbsPartIdx;
 
 #if REUSE_BLKMAPPING
       TComDataCU *pcColCU = 0;
-      pcColCU = pcCUDes->getBaseColCU(uiPelX + 8, uiPelY + 8, uiBaseCUAddr, uiBaseAbsPartIdx);
+      pcColCU = pcCUDes->getBaseColCU(pelX + 8, pelY + 8, baseCUAddr, baseAbsPartIdx);
 #else 
-      pcPicBase->deriveUnitIdxBase(uiPelX + 8, uiPelY + 8, upSampleRatio, uiBaseCUAddr, uiBaseAbsPartIdx);
+      pcPicBase->deriveUnitIdxBase(pelX + 8, pelY + 8, upSampleRatio, baseCUAddr, baseAbsPartIdx);
 #endif
 
 #if AVC_SYNTAX
-      Int iBX = ( (uiPelX + 8) * iBWidth + iEWidth/2 ) / iEWidth;
-      Int iBY = ( (uiPelY + 8) * iBHeight+ iEHeight/2 ) / iEHeight;
+      Int xBL = ( (pelX + 8) * widthBL + widthEL/2 ) / widthEL;
+      Int yBL = ( (pelY + 8) * heightBL+ heightEL/2 ) / heightEL;
 
 #if REUSE_BLKMAPPING
-      if( ( iBX < iBWidth && iBY < iBHeight ) && pcColCU && (pcColCU->getPredictionMode(uiBaseAbsPartIdx) != MODE_NONE) && (pcColCU->getPredictionMode(uiBaseAbsPartIdx) != MODE_INTRA) )  //base layer unit not skip and invalid mode
+      if( ( xBL < widthBL && yBL < heightBL ) && pcColCU && (pcColCU->getPredictionMode(baseAbsPartIdx) != MODE_NONE) && (pcColCU->getPredictionMode(baseAbsPartIdx) != MODE_INTRA) )  //base layer unit not skip and invalid mode
 #else
-      if( ( iBX < iBWidth && iBY < iBHeight ) && (pcPicBase->getCU(uiBaseCUAddr)->getPredictionMode(uiBaseAbsPartIdx) != MODE_NONE) && (pcPicBase->getCU(uiBaseCUAddr)->getPredictionMode(uiBaseAbsPartIdx) != MODE_INTRA) )  //base layer unit not skip and invalid mode
+      if( ( xBL < widthBL && yBL < heightBL ) && (pcPicBase->getCU(baseCUAddr)->getPredictionMode(baseAbsPartIdx) != MODE_NONE) && (pcPicBase->getCU(baseCUAddr)->getPredictionMode(baseAbsPartIdx) != MODE_INTRA) )  //base layer unit not skip and invalid mode
 #endif
 #else
 #if REUSE_BLKMAPPING
-      if( pcColCU && (pcColCU->getPredictionMode(uiBaseAbsPartIdx) != MODE_NONE) && (pcColCU->getPredictionMode(uiBaseAbsPartIdx) != MODE_INTRA) )  //base layer unit not skip and invalid mode
+      if( pcColCU && (pcColCU->getPredictionMode(baseAbsPartIdx) != MODE_NONE) && (pcColCU->getPredictionMode(baseAbsPartIdx) != MODE_INTRA) )  //base layer unit not skip and invalid mode
 #else
-      if( (pcPicBase->getCU(uiBaseCUAddr)->getPredictionMode(uiBaseAbsPartIdx) != MODE_NONE) && (pcPicBase->getCU(uiBaseCUAddr)->getPredictionMode(uiBaseAbsPartIdx) != MODE_INTRA) )  //base layer unit not skip and invalid mode
+      if( (pcPicBase->getCU(baseCUAddr)->getPredictionMode(baseAbsPartIdx) != MODE_NONE) && (pcPicBase->getCU(baseCUAddr)->getPredictionMode(baseAbsPartIdx) != MODE_INTRA) )  //base layer unit not skip and invalid mode
 #endif
 #endif
@@ -703,23 +703,23 @@
           TComMvField sMvFieldBase, sMvField;
 #if REUSE_BLKMAPPING
-          pcColCU->getMvField( pcColCU, uiBaseAbsPartIdx, (RefPicList)refPicList, sMvFieldBase);
+          pcColCU->getMvField( pcColCU, baseAbsPartIdx, (RefPicList)refPicList, sMvFieldBase);
 #else
-          pcPicBase->getCU(uiBaseCUAddr)->getMvField( pcPicBase->getCU(uiBaseCUAddr), uiBaseAbsPartIdx, (RefPicList)refPicList, sMvFieldBase);
+          pcPicBase->getCU(baseCUAddr)->getMvField( pcPicBase->getCU(baseCUAddr), baseAbsPartIdx, (RefPicList)refPicList, sMvFieldBase);
 #endif
           pcCUDes->scaleBaseMV( sMvField, sMvFieldBase );
 #else
-          TComMv cMv = pcPicBase->getCU(uiBaseCUAddr)->getCUMvField((RefPicList)refPicList)->getMv(uiBaseAbsPartIdx);
-          Int refIdx = pcPicBase->getCU(uiBaseCUAddr)->getCUMvField((RefPicList)refPicList)->getRefIdx(uiBaseAbsPartIdx);
-
-          Int Hor =  ((Int)upSampleRatio * cMv.getHor())/2 ;
-          Int Ver =  ((Int)upSampleRatio * cMv.getVer())/2 ;
-
-          TComMv cScaledMv(Hor, Ver);
+          TComMv cMv = pcPicBase->getCU(baseCUAddr)->getCUMvField((RefPicList)refPicList)->getMv(baseAbsPartIdx);
+          Int refIdx = pcPicBase->getCU(baseCUAddr)->getCUMvField((RefPicList)refPicList)->getRefIdx(baseAbsPartIdx);
+
+          Int hor =  ((Int)upSampleRatio * cMv.getHor())/2 ;
+          Int ver =  ((Int)upSampleRatio * cMv.getVer())/2 ;
+
+          TComMv cScaledMv(hor, ver);
           TComMvField sMvField;
           sMvField.setMvField(cScaledMv, refIdx);
 #endif
 
-          pcCUDes->getCUMvField((RefPicList)refPicList)->setMvField(sMvField, uiAbsPartIdx);
-          pcCUDes->setPredictionMode(uiAbsPartIdx, MODE_INTER);
+          pcCUDes->getCUMvField((RefPicList)refPicList)->setMvField(sMvField, absPartIdx);
+          pcCUDes->setPredictionMode(absPartIdx, MODE_INTER);
         }
       }
@@ -727,17 +727,17 @@
       {
         TComMvField zeroMvField;  //zero MV and invalid reference index
-        pcCUDes->getCUMvField(REF_PIC_LIST_0)->setMvField(zeroMvField, uiAbsPartIdx);
-        pcCUDes->getCUMvField(REF_PIC_LIST_1)->setMvField(zeroMvField, uiAbsPartIdx);
-        pcCUDes->setPredictionMode(uiAbsPartIdx, MODE_INTRA);
+        pcCUDes->getCUMvField(REF_PIC_LIST_0)->setMvField(zeroMvField, absPartIdx);
+        pcCUDes->getCUMvField(REF_PIC_LIST_1)->setMvField(zeroMvField, absPartIdx);
+        pcCUDes->setPredictionMode(absPartIdx, MODE_INTRA);
       }
 
       for(UInt i = 1; i < unitNum; i++ )  
       {
-        pcCUDes->getCUMvField(REF_PIC_LIST_0)->setMvField(pcCUDes->getCUMvField(REF_PIC_LIST_0)->getMv(uiAbsPartIdx), pcCUDes->getCUMvField(REF_PIC_LIST_0)->getRefIdx(uiAbsPartIdx), uiAbsPartIdx + i);
-        pcCUDes->getCUMvField(REF_PIC_LIST_1)->setMvField(pcCUDes->getCUMvField(REF_PIC_LIST_1)->getMv(uiAbsPartIdx), pcCUDes->getCUMvField(REF_PIC_LIST_1)->getRefIdx(uiAbsPartIdx), uiAbsPartIdx + i);
-        pcCUDes->setPredictionMode(uiAbsPartIdx+i, pcCUDes->getPredictionMode(uiAbsPartIdx))  ;
-      }
-    }
-      memset( pcCUDes->getPartitionSize(), SIZE_2Nx2N, sizeof(char)*uiNumPartitions);
+        pcCUDes->getCUMvField(REF_PIC_LIST_0)->setMvField(pcCUDes->getCUMvField(REF_PIC_LIST_0)->getMv(absPartIdx), pcCUDes->getCUMvField(REF_PIC_LIST_0)->getRefIdx(absPartIdx), absPartIdx + i);
+        pcCUDes->getCUMvField(REF_PIC_LIST_1)->setMvField(pcCUDes->getCUMvField(REF_PIC_LIST_1)->getMv(absPartIdx), pcCUDes->getCUMvField(REF_PIC_LIST_1)->getRefIdx(absPartIdx), absPartIdx + i);
+        pcCUDes->setPredictionMode(absPartIdx+i, pcCUDes->getPredictionMode(absPartIdx))  ;
+      }
+    }
+      memset( pcCUDes->getPartitionSize(), SIZE_2Nx2N, sizeof(char)*numPartitions);
   }
 }
@@ -755,30 +755,30 @@
 
   const Window &conf = this->getPicYuvRec()->getConformanceWindow();
-  UInt   uiWidth      = this->getPicYuvRec()->getWidth() - conf.getWindowLeftOffset() - conf.getWindowRightOffset();
-  UInt   uiHeight     = this->getPicYuvRec()->getHeight() - conf.getWindowTopOffset() - conf.getWindowBottomOffset();
-  UInt64 uiPOC        = (UInt64)this->getPOC();
-  UInt   uiPartWidth  = uiWidth / 4;
-  UInt   uiPartHeight = uiHeight / 4;
-
-  UInt uiNumPartInWidth    = this->getNumPartInWidth();
-  UInt uiNumPartInHeight   = this->getNumPartInHeight();
-  UInt uiNumPartLCUInWidth = this->getFrameWidthInCU();
-
-  UInt64 uiPos = (UInt64)uiPOC * uiWidth * uiHeight * numBytes / 16;
+  UInt   width      = this->getPicYuvRec()->getWidth() - conf.getWindowLeftOffset() - conf.getWindowRightOffset();
+  UInt   height     = this->getPicYuvRec()->getHeight() - conf.getWindowTopOffset() - conf.getWindowBottomOffset();
+  UInt64 poc        = (UInt64)this->getPOC();
+  UInt   partWidth  = width / 4;
+  UInt   partHeight = height / 4;
+
+  UInt numPartInWidth    = this->getNumPartInWidth();
+  UInt numPartInHeight   = this->getNumPartInHeight();
+  UInt numPartLCUInWidth = this->getFrameWidthInCU();
+
+  UInt64 uiPos = (UInt64)poc * width * height * numBytes / 16;
    
   filestream->seekg( uiPos, ios_base::beg );
 
-  for( Int i = 0; i < uiPartHeight; i++ )
-  {
-    for( Int j = 0; j < uiPartWidth; j++ )
-    {
-      UInt uiX = ( j / uiNumPartInWidth );
-      UInt uiY = ( i / uiNumPartInHeight );
-
-      UInt uiLCUAddr = uiY * uiNumPartLCUInWidth + uiX;
-      UInt uiPartAddr = ( i - uiY * uiNumPartInHeight ) * uiNumPartInWidth + ( j - uiX * uiNumPartInWidth );
-      uiPartAddr = g_auiRasterToZscan[uiPartAddr];
+  for( Int i = 0; i < partHeight; i++ )
+  {
+    for( Int j = 0; j < partWidth; j++ )
+    {
+      UInt x = ( j / numPartInWidth );
+      UInt y = ( i / numPartInHeight );
+
+      UInt addrLCU = y * numPartLCUInWidth + x;
+      UInt partAddr = ( i - y * numPartInHeight ) * numPartInWidth + ( j - x * numPartInWidth );
+      partAddr = g_auiRasterToZscan[partAddr];
       
-      TComDataCU* pcCU = this->getCU( uiLCUAddr );
+      TComDataCU* pcCU = this->getCU( addrLCU );
       
       TComMv mv;
@@ -789,5 +789,5 @@
       filestream->read( &refIdxL0, 1 );
       assert( refIdxL0 >= -1 );
-      pcCU->getCUMvField( REF_PIC_LIST_0 )->setRefIdx( (Int)refIdxL0, uiPartAddr );
+      pcCU->getCUMvField( REF_PIC_LIST_0 )->setRefIdx( (Int)refIdxL0, partAddr );
 
       // RefIdxL1
@@ -795,5 +795,5 @@
       filestream->read( &refIdxL1, 1 );
       assert( refIdxL1 >= -1 );
-      pcCU->getCUMvField( REF_PIC_LIST_1 )->setRefIdx( (Int)refIdxL1, uiPartAddr );
+      pcCU->getCUMvField( REF_PIC_LIST_1 )->setRefIdx( (Int)refIdxL1, partAddr );
 
       // MV L0
@@ -804,5 +804,5 @@
       filestream->read( reinterpret_cast<char*>(&temp), 2 );
       mv.setVer( (Short)temp );
-      pcCU->getCUMvField( REF_PIC_LIST_0 )->setMv( mv, uiPartAddr );
+      pcCU->getCUMvField( REF_PIC_LIST_0 )->setMv( mv, partAddr );
 
       // MV L1
@@ -813,11 +813,11 @@
       filestream->read( reinterpret_cast<char*>(&temp), 2 );
       mv.setVer( (Short)temp );
-      pcCU->getCUMvField( REF_PIC_LIST_1 )->setMv( mv, uiPartAddr );
+      pcCU->getCUMvField( REF_PIC_LIST_1 )->setMv( mv, partAddr );
 
       // set dependent information
-      pcCU->setPredictionMode( uiPartAddr, ( refIdxL0 == NOT_VALID && refIdxL1 == NOT_VALID ) ? MODE_INTRA : MODE_INTER );
-      UInt uiInterDir = ( refIdxL0 != NOT_VALID ) + ( refIdxL1 != NOT_VALID && this->getSlice(0)->isInterB() ) * 2;
-      assert( uiInterDir >= 0 && uiInterDir <= 3 );
-      pcCU->setInterDir( uiPartAddr, uiInterDir );      
+      pcCU->setPredictionMode( partAddr, ( refIdxL0 == NOT_VALID && refIdxL1 == NOT_VALID ) ? MODE_INTRA : MODE_INTER );
+      UInt interDir = ( refIdxL0 != NOT_VALID ) + ( refIdxL1 != NOT_VALID && this->getSlice(0)->isInterB() ) * 2;
+      assert( interDir >= 0 && interDir <= 3 );
+      pcCU->setInterDir( partAddr, interDir );      
     }
   }
@@ -833,28 +833,30 @@
   }
 
-  UInt   uiWidth      = this->getPicYuvRec()->getWidth() - getSlice(0)->getSPS()->getPicCropLeftOffset() - getSlice(0)->getSPS()->getPicCropRightOffset();
-  UInt   uiHeight     = this->getPicYuvRec()->getHeight() - getSlice(0)->getSPS()->getPicCropTopOffset() - getSlice(0)->getSPS()->getPicCropBottomOffset();
-  UInt64 uiPOC        = (UInt64)this->getPOC();
-  UInt   uiPartWidth  = uiWidth / 4;
-  UInt   uiPartHeight = uiHeight / 4;
-
-  UInt uiNumPartInWidth    = this->getNumPartInWidth();
-  UInt uiNumPartInHeight   = this->getNumPartInHeight();
-  UInt uiNumPartLCUInWidth = this->getFrameWidthInCU();
-
-  filestream->seekg( uiPOC * uiWidth * uiHeight * numBytes / 16 );
+  const Window &conf = this->getConformanceWindow();
+  UInt   width       = this->getPicYuvRec()->getWidth() - conf.getWindowLeftOffset() - conf.getWindowRightOffset();
+  UInt   height      = this->getPicYuvRec()->getHeight() - conf.getWindowTopOffset() - conf.getWindowBottomOffset();
+
+  UInt64 poc        = (UInt64)this->getPOC();
+  UInt   partWidth  = width / 4;
+  UInt   partHeight = height / 4;
+
+  UInt numPartInWidth    = this->getNumPartInWidth();
+  UInt numPartInHeight   = this->getNumPartInHeight();
+  UInt numPartLCUInWidth = this->getFrameWidthInCU();
+
+  filestream->seekg( poc * width * height * numBytes / 16 );
     
-  for( Int i = 0; i < uiPartHeight; i++ )
-  {
-    for( Int j = 0; j < uiPartWidth; j++ )
-    {
-      UInt uiX = ( j / uiNumPartInWidth );
-      UInt uiY = ( i / uiNumPartInHeight );
-
-      UInt uiLCUAddr = uiY * uiNumPartLCUInWidth + uiX;
-      UInt uiPartAddr = ( i - uiY * uiNumPartInHeight ) * uiNumPartInWidth + ( j - uiX * uiNumPartInWidth );
-      uiPartAddr = g_auiRasterToZscan[uiPartAddr];
+  for( Int i = 0; i < partHeight; i++ )
+  {
+    for( Int j = 0; j < partWidth; j++ )
+    {
+      UInt x = ( j / numPartInWidth );
+      UInt y = ( i / numPartInHeight );
+
+      UInt addrLCU = y * numPartLCUInWidth + x;
+      UInt partAddr = ( i - y * numPartInHeight ) * numPartInWidth + ( j - x * numPartInWidth );
+      partAddr = g_auiRasterToZscan[partAddr];
       
-      TComDataCU* pcCU = this->getCU( uiLCUAddr );
+      TComDataCU* pcCU = this->getCU( addrLCU );
       
       TComMv mv;
@@ -863,8 +865,8 @@
 
       // RefIdx
-      if( !pcCU->isIntra( uiPartAddr ) )
-      {
-        refIdxL0 = (Char)pcCU->getCUMvField( REF_PIC_LIST_0 )->getRefIdx( uiPartAddr );
-        refIdxL1 = (Char)pcCU->getCUMvField( REF_PIC_LIST_1 )->getRefIdx( uiPartAddr );
+      if( !pcCU->isIntra( partAddr ) )
+      {
+        refIdxL0 = (Char)pcCU->getCUMvField( REF_PIC_LIST_0 )->getRefIdx( partAddr );
+        refIdxL1 = (Char)pcCU->getCUMvField( REF_PIC_LIST_1 )->getRefIdx( partAddr );
       }
       assert( refIdxL0 >= - 1 && refIdxL1 >= - 1 );
@@ -876,5 +878,5 @@
       if( refIdxL0 >= 0 )
       {
-        mv = pcCU->getCUMvField( REF_PIC_LIST_0 )->getMv( uiPartAddr );
+        mv = pcCU->getCUMvField( REF_PIC_LIST_0 )->getMv( partAddr );
       }
       temp = (Short)mv.getHor();
@@ -887,5 +889,5 @@
       if( refIdxL1 >= 0 )
       {
-        mv = pcCU->getCUMvField( REF_PIC_LIST_1 )->getMv( uiPartAddr );
+        mv = pcCU->getCUMvField( REF_PIC_LIST_1 )->getMv( partAddr );
       }
       temp = (Short)mv.getHor();
Index: branches/HM-10.0-dev-SHM/source/Lib/TLibCommon/TComPic.h
===================================================================
--- branches/HM-10.0-dev-SHM/source/Lib/TLibCommon/TComPic.h	(revision 69)
+++ branches/HM-10.0-dev-SHM/source/Lib/TLibCommon/TComPic.h	(revision 71)
@@ -134,5 +134,5 @@
   Void          copyUpsampledMvField  (  TComPic* pcPicBase );
 #if !REUSE_BLKMAPPING
-  Void          deriveUnitIdxBase     (  UInt uiUpsamplePelX, UInt uiUpsamplePelY, UInt ratio, UInt& uiBaseCUAddr, UInt& uiBaseAbsPartIdx );
+  Void          deriveUnitIdxBase     (  UInt upsamplePelX, UInt upsamplePelY, UInt ratio, UInt& baseCUAddr, UInt& baseAbsPartIdx );
 #endif
 #endif
Index: branches/HM-10.0-dev-SHM/source/Lib/TLibCommon/TComSlice.cpp
===================================================================
--- branches/HM-10.0-dev-SHM/source/Lib/TLibCommon/TComSlice.cpp	(revision 69)
+++ branches/HM-10.0-dev-SHM/source/Lib/TLibCommon/TComSlice.cpp	(revision 71)
@@ -2066,6 +2066,5 @@
       // should be set if the base layer has its own instance of the reference picture lists, currently EL RPL is reused.
       getRefPic( eRefPicList, refIdx )->setLayerId( 0 );
-      getRefPic( eRefPicList, refIdx )->setIsLongTerm( pcSlice->getRefPic( eRefPicList, refIdx )->getIsLongTerm() );
-      getRefPic( eRefPicList, refIdx )->setIsUsedAsLongTerm( pcSlice->getRefPic( eRefPicList, refIdx )->getIsUsedAsLongTerm() );
+      getRefPic( eRefPicList, refIdx )->setIsLongTerm( pcSlice->getRefPic( eRefPicList, refIdx )->getIsLongTerm() );      
       */
 
Index: branches/HM-10.0-dev-SHM/source/Lib/TLibCommon/TComUpsampleFilter.cpp
===================================================================
--- branches/HM-10.0-dev-SHM/source/Lib/TLibCommon/TComUpsampleFilter.cpp	(revision 69)
+++ branches/HM-10.0-dev-SHM/source/Lib/TLibCommon/TComUpsampleFilter.cpp	(revision 71)
@@ -139,11 +139,11 @@
   const Window &confEL = pcUsPic->getConformanceWindow();
 
-  Int iBWidth   = pcBasePic->getWidth () - confBL.getWindowLeftOffset() - confBL.getWindowRightOffset();
-  Int iBHeight  = pcBasePic->getHeight() - confBL.getWindowTopOffset() - confBL.getWindowBottomOffset();
-  Int iBStride  = pcBasePic->getStride();
-
-  Int iEWidth   = pcUsPic->getWidth () - confEL.getWindowLeftOffset() - confEL.getWindowRightOffset();
-  Int iEHeight  = pcUsPic->getHeight() - confEL.getWindowTopOffset() - confEL.getWindowBottomOffset();
-  Int iEStride  = pcUsPic->getStride();
+  Int widthBL   = pcBasePic->getWidth () - confBL.getWindowLeftOffset() - confBL.getWindowRightOffset();
+  Int heightBL  = pcBasePic->getHeight() - confBL.getWindowTopOffset() - confBL.getWindowBottomOffset();
+  Int strideBL  = pcBasePic->getStride();
+
+  Int widthEL   = pcUsPic->getWidth () - confEL.getWindowLeftOffset() - confEL.getWindowRightOffset();
+  Int heightEL  = pcUsPic->getHeight() - confEL.getWindowTopOffset() - confEL.getWindowBottomOffset();
+  Int strideEL  = pcUsPic->getStride();
   
   Pel* piTempBufY = pcTempPic->getLumaAddr();
@@ -196,5 +196,5 @@
   
 #if PHASE_DERIVATION_IN_INTEGER
-  Int iRefPos16 = 0;
+  Int refPos16 = 0;
   Int phase    = 0;
   Int refPos   = 0; 
@@ -212,5 +212,5 @@
 
   Int chromaPhaseDenominator;
-  if (iEWidth == 2*iBWidth) // 2x scalability
+  if (widthEL == 2*widthBL) // 2x scalability
   {
     for ( i = 0; i < 8; i++)
@@ -230,6 +230,6 @@
 #endif
 
-  assert ( iEWidth == 2*iBWidth || 2*iEWidth == 3*iBWidth );
-  assert ( iEHeight == 2*iBHeight || 2*iEHeight == 3*iBHeight );
+  assert ( widthEL == 2*widthBL || 2*widthEL == 3*widthBL );
+  assert ( heightEL == 2*heightBL || 2*heightEL == 3*heightBL );
 
 #if JCTVC_L0178
@@ -237,10 +237,10 @@
   if( tempBufSizeRight )
   {
-    piSrcY = piSrcBufY + iBWidth;
+    piSrcY = piSrcBufY + widthBL;
     piDstY = tempBufRight;
     for( i = 0; i < pcBasePic->getHeight(); i++ )
     {
       memcpy(piDstY, piSrcY, sizeof(Pel) * confBL.getWindowRightOffset());
-      piSrcY += iBStride;
+      piSrcY += strideBL;
       piDstY += confBL.getWindowRightOffset();
     }
@@ -248,8 +248,8 @@
     if(confBL.getWindowRightOffset()>>1)
     {
-      Int iBStrideChroma = (iBStride>>1);
-      piSrcU = piSrcBufU + (iBWidth>>1);
+      Int strideBLChroma = (strideBL>>1);
+      piSrcU = piSrcBufU + (widthBL>>1);
       piDstU = tempBufRight + confBL.getWindowRightOffset() * pcBasePic->getHeight();
-      piSrcV = piSrcBufV + (iBWidth>>1);
+      piSrcV = piSrcBufV + (widthBL>>1);
       piDstV = piDstU + (confBL.getWindowRightOffset()>>1) * (pcBasePic->getHeight()>>1);
     
@@ -257,24 +257,24 @@
       {
         memcpy(piDstU, piSrcU, sizeof(Pel) * (confBL.getWindowRightOffset()>>1));
-        piSrcU += iBStrideChroma;
+        piSrcU += strideBLChroma;
         piDstU += (confBL.getWindowRightOffset()>>1);
         
         memcpy(piDstV, piSrcV, sizeof(Pel) * (confBL.getWindowRightOffset()>>1));
-        piSrcV += iBStrideChroma;
+        piSrcV += strideBLChroma;
         piDstV += (confBL.getWindowRightOffset()>>1);
       }
     }
     
-    pcBasePic->setWidth(iBWidth);
+    pcBasePic->setWidth(widthBL);
   }
   
   if( tempBufSizeBottom )
   {
-    piSrcY = piSrcBufY + iBHeight * iBStride;
+    piSrcY = piSrcBufY + heightBL * strideBL;
     piDstY = tempBufBottom;
     for( i = 0; i < confBL.getWindowBottomOffset(); i++ )
     {
       memcpy(piDstY, piSrcY, sizeof(Pel) * pcBasePic->getWidth());
-      piSrcY += iBStride;
+      piSrcY += strideBL;
       piDstY += pcBasePic->getWidth();
     }
@@ -282,8 +282,8 @@
     if(confBL.getWindowBottomOffset()>>1)
     {
-      Int iBStrideChroma = (iBStride>>1);
-      piSrcU = piSrcBufU + (iBHeight>>1) * iBStrideChroma;
+      Int strideBLChroma = (strideBL>>1);
+      piSrcU = piSrcBufU + (heightBL>>1) * strideBLChroma;
       piDstU = tempBufBottom + confBL.getWindowBottomOffset() * pcBasePic->getWidth();
-      piSrcV = piSrcBufV + (iBHeight>>1) * iBStrideChroma;
+      piSrcV = piSrcBufV + (heightBL>>1) * strideBLChroma;
       piDstV = piDstU + (confBL.getWindowBottomOffset()>>1) * (pcBasePic->getWidth()>>1);
       
@@ -291,14 +291,14 @@
       {
         memcpy(piDstU, piSrcU, sizeof(Pel) * (pcBasePic->getWidth()>>1));
-        piSrcU += iBStrideChroma;
+        piSrcU += strideBLChroma;
         piDstU += (pcBasePic->getWidth()>>1);
         
         memcpy(piDstV, piSrcV, sizeof(Pel) * (pcBasePic->getWidth()>>1));
-        piSrcV += iBStrideChroma;
+        piSrcV += strideBLChroma;
         piDstV += (pcBasePic->getWidth()>>1);
       }
     }
 
-    pcBasePic->setHeight(iBHeight);
+    pcBasePic->setHeight(heightBL);
   }
 #endif
@@ -308,34 +308,33 @@
 
 #if PHASE_DERIVATION_IN_INTEGER
-  Int   iShiftX = 16;
-  Int   iShiftY = 16;
-
-  Int   iPhaseX = 0;
-  Int   iPhaseY = 0;
-
-  Int   iAddX       = ( ( ( iBWidth * iPhaseX ) << ( iShiftX - 2 ) ) + ( iEWidth >> 1 ) ) / iEWidth + ( 1 << ( iShiftX - 5 ) );
-  Int   iAddY       = ( ( ( iBHeight * iPhaseY ) << ( iShiftY - 2 ) ) + ( iEHeight >> 1 ) ) / iEHeight+ ( 1 << ( iShiftY - 5 ) );
-
-  Int   iDeltaX     = 4 * iPhaseX;
-  Int   iDeltaY     = 4 * iPhaseY;  
-
-
-  Int iShiftXM4 = iShiftX - 4;
-  Int iShiftYM4 = iShiftY - 4;
-
-  Int   iScaleX     = ( ( iBWidth << iShiftX ) + ( iEWidth >> 1 ) ) / iEWidth;
-  Int   iScaleY     = ( ( iBHeight << iShiftY ) + ( iEHeight >> 1 ) ) / iEHeight;
-#else
-  const Double sFactor = 1.0 * iBWidth / iEWidth;
+  Int   shiftX = 16;
+  Int   shiftY = 16;
+
+  Int   phaseX = 0;
+  Int   phaseY = 0;
+
+  Int   addX       = ( ( ( widthBL * phaseX ) << ( shiftX - 2 ) ) + ( widthEL >> 1 ) ) / widthEL + ( 1 << ( shiftX - 5 ) );
+  Int   addY       = ( ( ( heightBL * phaseY ) << ( shiftY - 2 ) ) + ( heightEL >> 1 ) ) / heightEL+ ( 1 << ( shiftY - 5 ) );
+
+  Int   deltaX     = 4 * phaseX;
+  Int   deltaY     = 4 * phaseY;  
+  
+  Int shiftXM4 = shiftX - 4;
+  Int shiftYM4 = shiftY - 4;
+
+  Int   scaleX     = ( ( widthBL << shiftX ) + ( widthEL >> 1 ) ) / widthEL;
+  Int   scaleY     = ( ( heightBL << shiftY ) + ( heightEL >> 1 ) ) / heightEL;
+#else
+  const Double sFactor = 1.0 * widthBL / widthEL;
   const Double sFactor12 = sFactor * 12;
 #endif
 
   //========== horizontal upsampling ===========
-  for( i = 0; i < iEWidth; i++ )
-  {
-#if PHASE_DERIVATION_IN_INTEGER
-    iRefPos16 = ((i*iScaleX + iAddX) >> iShiftXM4) - iDeltaX;
-    phase    = iRefPos16 & 15;
-    refPos   = iRefPos16 >> 4;
+  for( i = 0; i < widthEL; i++ )
+  {
+#if PHASE_DERIVATION_IN_INTEGER
+    refPos16 = ((i*scaleX + addX) >> shiftXM4) - deltaX;
+    phase    = refPos16 & 15;
+    refPos   = refPos16 >> 4;
     coeff = m_lumaFilter[phase];
 #else
@@ -349,9 +348,9 @@
     piDstY = piTempBufY + i;
 
-    for( j = 0; j < iBHeight ; j++ )
+    for( j = 0; j < heightBL ; j++ )
     {
       *piDstY = sumLumaHor(piSrcY, coeff);
-      piSrcY += iBStride;
-      piDstY += iEStride;
+      piSrcY += strideBL;
+      piDstY += strideEL;
     }
   }
@@ -360,17 +359,17 @@
   //========== vertical upsampling ===========
   pcTempPic->setBorderExtension(false);
-  pcTempPic->setHeight(iBHeight);
+  pcTempPic->setHeight(heightBL);
   pcTempPic->extendPicBorder   (); // extend the border.
-  pcTempPic->setHeight(iEHeight);
+  pcTempPic->setHeight(heightEL);
 
   const Int nShift = US_FILTER_PREC*2;
   Int iOffset = 1 << (nShift - 1); 
 
-  for( j = 0; j < iEHeight; j++ )
-  {
-#if PHASE_DERIVATION_IN_INTEGER
-    iRefPos16 = ((j*iScaleY + iAddY) >> iShiftYM4) - iDeltaY;
-    phase    = iRefPos16 & 15;
-    refPos   = iRefPos16 >> 4;
+  for( j = 0; j < heightEL; j++ )
+  {
+#if PHASE_DERIVATION_IN_INTEGER
+    refPos16 = ((j*scaleY + addY) >> shiftYM4) - deltaY;
+    phase    = refPos16 & 15;
+    refPos   = refPos16 >> 4;
     coeff = m_lumaFilter[phase];
 #else
@@ -381,10 +380,10 @@
 #endif
 
-    piSrcY = piTempBufY + (refPos -((NTAPS_US_LUMA>>1) - 1))*iEStride;
-    piDstY = piDstBufY + j * iEStride;
-
-    for( i = 0; i < iEWidth; i++ )
-    {
-      *piDstY = ClipY( (sumLumaVer(piSrcY, coeff, iEStride) + iOffset) >> (nShift));
+    piSrcY = piTempBufY + (refPos -((NTAPS_US_LUMA>>1) - 1))*strideEL;
+    piDstY = piDstBufY + j * strideEL;
+
+    for( i = 0; i < widthEL; i++ )
+    {
+      *piDstY = ClipY( (sumLumaVer(piSrcY, coeff, strideEL) + iOffset) >> (nShift));
       piSrcY++;
       piDstY++;
@@ -394,40 +393,40 @@
   //========== UV component upsampling ===========
 
-  iEWidth  >>= 1;
-  iEHeight >>= 1;
-
-  iBWidth  >>= 1;
-  iBHeight >>= 1;
-
-  iBStride  = pcBasePic->getCStride();
-  iEStride  = pcUsPic->getCStride();
-
-#if PHASE_DERIVATION_IN_INTEGER
-  iShiftX = 16;
-  iShiftY = 16;
-
-  iPhaseX = 0;
-  iPhaseY = 1;
-
-  iAddX       = ( ( ( iBWidth * iPhaseX ) << ( iShiftX - 2 ) ) + ( iEWidth >> 1 ) ) / iEWidth + ( 1 << ( iShiftX - 5 ) );
-  iAddY       = ( ( ( iBHeight * iPhaseY ) << ( iShiftY - 2 ) ) + ( iEHeight >> 1 ) ) / iEHeight+ ( 1 << ( iShiftY - 5 ) );
-
-  iDeltaX     = 4 * iPhaseX;
-  iDeltaY     = 4 * iPhaseY;
-
-  iShiftXM4 = iShiftX - 4;
-  iShiftYM4 = iShiftY - 4;
-
-  iScaleX     = ( ( iBWidth << iShiftX ) + ( iEWidth >> 1 ) ) / iEWidth;
-  iScaleY     = ( ( iBHeight << iShiftY ) + ( iEHeight >> 1 ) ) / iEHeight;
+  widthEL  >>= 1;
+  heightEL >>= 1;
+
+  widthBL  >>= 1;
+  heightBL >>= 1;
+
+  strideBL  = pcBasePic->getCStride();
+  strideEL  = pcUsPic->getCStride();
+
+#if PHASE_DERIVATION_IN_INTEGER
+  shiftX = 16;
+  shiftY = 16;
+
+  phaseX = 0;
+  phaseY = 1;
+
+  addX       = ( ( ( widthBL * phaseX ) << ( shiftX - 2 ) ) + ( widthEL >> 1 ) ) / widthEL + ( 1 << ( shiftX - 5 ) );
+  addY       = ( ( ( heightBL * phaseY ) << ( shiftY - 2 ) ) + ( heightEL >> 1 ) ) / heightEL+ ( 1 << ( shiftY - 5 ) );
+
+  deltaX     = 4 * phaseX;
+  deltaY     = 4 * phaseY;
+
+  shiftXM4 = shiftX - 4;
+  shiftYM4 = shiftY - 4;
+
+  scaleX     = ( ( widthBL << shiftX ) + ( widthEL >> 1 ) ) / widthEL;
+  scaleY     = ( ( heightBL << shiftY ) + ( heightEL >> 1 ) ) / heightEL;
 #endif
 
   //========== horizontal upsampling ===========
-  for( i = 0; i < iEWidth; i++ )
-  {
-#if PHASE_DERIVATION_IN_INTEGER
-    iRefPos16 = ((i*iScaleX + iAddX) >> iShiftXM4) - iDeltaX;
-    phase    = iRefPos16 & 15;
-    refPos   = iRefPos16 >> 4;
+  for( i = 0; i < widthEL; i++ )
+  {
+#if PHASE_DERIVATION_IN_INTEGER
+    refPos16 = ((i*scaleX + addX) >> shiftXM4) - deltaX;
+    phase    = refPos16 & 15;
+    refPos   = refPos16 >> 4;
     coeff = m_chromaFilter[phase];
 #else
@@ -443,13 +442,13 @@
     piDstV = piTempBufV + i;
 
-    for( j = 0; j < iBHeight ; j++ )
+    for( j = 0; j < heightBL ; j++ )
     {
       *piDstU = sumChromaHor(piSrcU, coeff);
       *piDstV = sumChromaHor(piSrcV, coeff);
 
-      piSrcU += iBStride;
-      piSrcV += iBStride;
-      piDstU += iEStride;
-      piDstV += iEStride;
+      piSrcU += strideBL;
+      piSrcV += strideBL;
+      piDstU += strideEL;
+      piDstV += strideEL;
     }
   }
@@ -457,14 +456,14 @@
   //========== vertical upsampling ===========
   pcTempPic->setBorderExtension(false);
-  pcTempPic->setHeight(iBHeight << 1);
+  pcTempPic->setHeight(heightBL << 1);
   pcTempPic->extendPicBorder   (); // extend the border.
-  pcTempPic->setHeight(iEHeight << 1);
-
-  for( j = 0; j < iEHeight; j++ )
-  {
-#if PHASE_DERIVATION_IN_INTEGER
-    iRefPos16 = ((j*iScaleY + iAddY) >> iShiftYM4) - iDeltaY;
-    phase    = iRefPos16 & 15;
-    refPos   = iRefPos16 >> 4; 
+  pcTempPic->setHeight(heightEL << 1);
+
+  for( j = 0; j < heightEL; j++ )
+  {
+#if PHASE_DERIVATION_IN_INTEGER
+    refPos16 = ((j*scaleY + addY) >> shiftYM4) - deltaY;
+    phase    = refPos16 & 15;
+    refPos   = refPos16 >> 4; 
     coeff = m_chromaFilter[phase];
 #else
@@ -483,14 +482,14 @@
 #endif
 
-    piSrcU = piTempBufU  + (refPos -((NTAPS_US_CHROMA>>1) - 1))*iEStride;
-    piSrcV = piTempBufV  + (refPos -((NTAPS_US_CHROMA>>1) - 1))*iEStride;
-
-    piDstU = piDstBufU + j*iEStride;
-    piDstV = piDstBufV + j*iEStride;
-
-    for( i = 0; i < iEWidth; i++ )
-    {
-      *piDstU = ClipC( (sumChromaVer(piSrcU, coeff, iEStride) + iOffset) >> (nShift));
-      *piDstV = ClipC( (sumChromaVer(piSrcV, coeff, iEStride) + iOffset) >> (nShift));
+    piSrcU = piTempBufU  + (refPos -((NTAPS_US_CHROMA>>1) - 1))*strideEL;
+    piSrcV = piTempBufV  + (refPos -((NTAPS_US_CHROMA>>1) - 1))*strideEL;
+
+    piDstU = piDstBufU + j*strideEL;
+    piDstV = piDstBufV + j*strideEL;
+
+    for( i = 0; i < widthEL; i++ )
+    {
+      *piDstU = ClipC( (sumChromaVer(piSrcU, coeff, strideEL) + iOffset) >> (nShift));
+      *piDstV = ClipC( (sumChromaVer(piSrcV, coeff, strideEL) + iOffset) >> (nShift));
 
       piSrcU++;
@@ -521,13 +520,13 @@
   }
   
-  iBWidth   = pcBasePic->getWidth () - confBL.getWindowLeftOffset() - confBL.getWindowRightOffset();
-  iBHeight  = pcBasePic->getHeight() - confBL.getWindowTopOffset() - confBL.getWindowBottomOffset();
-  
-  iBStride  = pcBasePic->getStride();
+  widthBL   = pcBasePic->getWidth () - confBL.getWindowLeftOffset() - confBL.getWindowRightOffset();
+  heightBL  = pcBasePic->getHeight() - confBL.getWindowTopOffset() - confBL.getWindowBottomOffset();
+  
+  strideBL  = pcBasePic->getStride();
   
   if( tempBufSizeRight )
   {
     piSrcY = tempBufRight;
-    piDstY = piSrcBufY + iBWidth;
+    piDstY = piSrcBufY + widthBL;
     
     for( i = 0; i < pcBasePic->getHeight(); i++ )
@@ -535,14 +534,14 @@
       memcpy(piDstY, piSrcY, sizeof(Pel) * confBL.getWindowRightOffset() );
       piSrcY += confBL.getWindowRightOffset();
-      piDstY += iBStride;
+      piDstY += strideBL;
     }
     
     if(confBL.getWindowRightOffset()>>1)
     {
-      Int iBStrideChroma = (iBStride>>1);
+      Int strideBLChroma = (strideBL>>1);
       piSrcU = tempBufRight + confBL.getWindowRightOffset() * pcBasePic->getHeight();
-      piDstU = piSrcBufU + (iBWidth>>1);
+      piDstU = piSrcBufU + (widthBL>>1);
       piSrcV = piSrcU + (confBL.getWindowRightOffset()>>1) * (pcBasePic->getHeight()>>1);
-      piDstV = piSrcBufV + (iBWidth>>1);
+      piDstV = piSrcBufV + (widthBL>>1);
 
       for( i = 0; i < pcBasePic->getHeight()>>1; i++ )
@@ -550,9 +549,9 @@
         memcpy(piDstU, piSrcU, sizeof(Pel) * (confBL.getWindowRightOffset()>>1));
         piSrcU += (confBL.getWindowRightOffset()>>1);
-        piDstU += iBStrideChroma;
+        piDstU += strideBLChroma;
         
         memcpy(piDstV, piSrcV, sizeof(Pel) * (confBL.getWindowRightOffset()>>1));
         piSrcV += (confBL.getWindowRightOffset()>>1);
-        piDstV += iBStrideChroma;
+        piDstV += strideBLChroma;
       }
     }
@@ -561,10 +560,10 @@
   if( tempBufSizeBottom )
   {
-    piDstY = piSrcBufY + iBHeight * iBStride;
+    piDstY = piSrcBufY + heightBL * strideBL;
     piSrcY = tempBufBottom;
     for( i = 0; i < confBL.getWindowBottomOffset(); i++ )
     {
       memcpy(piDstY, piSrcY, sizeof(Pel) * pcBasePic->getWidth());
-      piDstY += iBStride;
+      piDstY += strideBL;
       piSrcY += pcBasePic->getWidth();
     }
@@ -572,9 +571,9 @@
     if(confBL.getWindowBottomOffset()>>1)
     {
-      Int iBStrideChroma = (iBStride>>1);
+      Int strideBLChroma = (strideBL>>1);
       piSrcU = tempBufBottom + confBL.getWindowBottomOffset() * pcBasePic->getWidth();
-      piDstU = piSrcBufU + (iBHeight>>1) * iBStrideChroma;
+      piDstU = piSrcBufU + (heightBL>>1) * strideBLChroma;
       piSrcV = piSrcU + (confBL.getWindowBottomOffset()>>1) * (pcBasePic->getWidth()>>1);
-      piDstV = piSrcBufV + (iBHeight>>1) * iBStrideChroma;
+      piDstV = piSrcBufV + (heightBL>>1) * strideBLChroma;
             
       for( i = 0; i < confBL.getWindowBottomOffset()>>1; i++ )
@@ -582,9 +581,9 @@
         memcpy(piDstU, piSrcU, sizeof(Pel) * (pcBasePic->getWidth()>>1));
         piSrcU += (pcBasePic->getWidth()>>1);
-        piDstU += iBStrideChroma;
+        piDstU += strideBLChroma;
         
         memcpy(piDstV, piSrcV, sizeof(Pel) * (pcBasePic->getWidth()>>1));
         piSrcV += (pcBasePic->getWidth()>>1);
-        piDstV += iBStrideChroma;
+        piDstV += strideBLChroma;
       }
     }
Index: branches/HM-10.0-dev-SHM/source/Lib/TLibEncoder/TEncGOP.cpp
===================================================================
--- branches/HM-10.0-dev-SHM/source/Lib/TLibEncoder/TEncGOP.cpp	(revision 69)
+++ branches/HM-10.0-dev-SHM/source/Lib/TLibEncoder/TEncGOP.cpp	(revision 71)
@@ -514,20 +514,20 @@
 
 #if SVC_EXTENSION      
-      if(m_layerId > 0)
-      {
-        TComList<TComPic*> *cListPic = m_ppcTEncTop[m_layerId-1]->getListPic();
-        pcSlice->setBaseColPic (*cListPic, m_layerId );
+    if(m_layerId > 0)
+    {
+      TComList<TComPic*> *cListPic = m_ppcTEncTop[m_layerId-1]->getListPic();
+      pcSlice->setBaseColPic (*cListPic, m_layerId );
 #if SVC_UPSAMPLING
-        if ( pcPic->isSpatialEnhLayer())
-        {    
-          m_pcPredSearch->upsampleBasePic( pcPic->getFullPelBaseRec(), pcSlice->getBaseColPic()->getPicYuvRec(), pcPic->getPicYuvRec() );
-        }
-        else
-        {
-          pcPic->setFullPelBaseRec( pcSlice->getBaseColPic()->getPicYuvRec() );
-        }
-        pcSlice->setFullPelBaseRec ( pcPic->getFullPelBaseRec() );
-#endif
-      }
+      if ( pcPic->isSpatialEnhLayer())
+      {    
+        m_pcPredSearch->upsampleBasePic( pcPic->getFullPelBaseRec(), pcSlice->getBaseColPic()->getPicYuvRec(), pcPic->getPicYuvRec() );
+      }
+      else
+      {
+        pcPic->setFullPelBaseRec( pcSlice->getBaseColPic()->getPicYuvRec() );
+      }
+      pcSlice->setFullPelBaseRec ( pcPic->getFullPelBaseRec() );
+#endif
+    }
 #endif 
 
Index: branches/HM-10.0-dev-SHM/source/Lib/TLibEncoder/TEncTop.cpp
===================================================================
--- branches/HM-10.0-dev-SHM/source/Lib/TLibEncoder/TEncTop.cpp	(revision 69)
+++ branches/HM-10.0-dev-SHM/source/Lib/TLibEncoder/TEncTop.cpp	(revision 71)
@@ -407,5 +407,6 @@
 Void TEncTop::encodePrep( TComPicYuv* pcPicYuvOrg )
 {
-  if (pcPicYuvOrg) {
+  if (pcPicYuvOrg) 
+  {
     // get original YUV
     TComPic* pcPicCurr = NULL;
@@ -1094,5 +1095,7 @@
   {
     for(Int i=0; i<m_iNumRowsMinus1; i++)
+    {
       uiCummulativeRowHeight += m_puiRowHeight[i];
+    }
 
     if( uiCummulativeRowHeight >= iHeightInCU )
