Index: branches/SHM-2.0-dev/source/App/TAppEncoder/TAppEncCfg.cpp
===================================================================
--- branches/SHM-2.0-dev/source/App/TAppEncoder/TAppEncCfg.cpp	(revision 174)
+++ branches/SHM-2.0-dev/source/App/TAppEncoder/TAppEncCfg.cpp	(revision 175)
@@ -400,5 +400,14 @@
   ("OutputBitDepthC",       m_outputBitDepthC,   0, "As per OutputBitDepth but for chroma component. (default:InternalBitDepthC)")
   ("InternalBitDepthC",     m_internalBitDepthC, 0, "As per InternalBitDepth but for chroma component. (default:IntrenalBitDepth)")
-
+#if SCALED_REF_LAYER_OFFSETS
+  ("ScaledRefLayerLeftOffset",   m_scaledRefLayerLeftOffset,  0, "Horizontal offset of top-left luma sample of scaled base layer picture with respect to"
+                                                                 " top-left luma sample of the EL picture, in units of two luma samples")
+  ("ScaledRefLayerTopOffset",    m_scaledRefLayerTopOffset,   0,   "Vertical offset of top-left luma sample of scaled base layer picture with respect to"
+                                                                 " top-left luma sample of the EL picture, in units of two luma samples")
+  ("ScaledRefLayerRightOffset",  m_scaledRefLayerRightOffset, 0, "Horizontal offset of bottom-right luma sample of scaled base layer picture with respect to"
+                                                                 " bottom-right luma sample of the EL picture, in units of two luma samples")
+  ("ScaledRefLayerBottomOffset", m_scaledRefLayerBottomOffset,0, "Vertical offset of bottom-right luma sample of scaled base layer picture with respect to"
+                                                                 " bottom-right luma sample of the EL picture, in units of two luma samples")
+#endif
 #if AVC_BASE
   ("AvcBase",                 m_avcBaseLayerFlag,     0, "AVC_BASElayer_flag")
Index: branches/SHM-2.0-dev/source/App/TAppEncoder/TAppEncCfg.h
===================================================================
--- branches/SHM-2.0-dev/source/App/TAppEncoder/TAppEncCfg.h	(revision 174)
+++ branches/SHM-2.0-dev/source/App/TAppEncoder/TAppEncCfg.h	(revision 175)
@@ -361,5 +361,10 @@
   Int*      m_constantPicRateIdc;                                ///< Indicates constant picture rate idc for various sub-layers
 #endif
-  #
+#if SCALED_REF_LAYER_OFFSETS
+  Int       m_scaledRefLayerLeftOffset;
+  Int       m_scaledRefLayerTopOffset;
+  Int       m_scaledRefLayerRightOffset;
+  Int       m_scaledRefLayerBottomOffset;
+#endif  
 public:
   TAppEncCfg();
Index: branches/SHM-2.0-dev/source/App/TAppEncoder/TAppEncTop.cpp
===================================================================
--- branches/SHM-2.0-dev/source/App/TAppEncoder/TAppEncTop.cpp	(revision 174)
+++ branches/SHM-2.0-dev/source/App/TAppEncoder/TAppEncTop.cpp	(revision 175)
@@ -418,4 +418,11 @@
     m_acTEncTop[layer].setElRapSliceTypeB(layer == 0? 0 : m_elRapSliceBEnabled);
 #endif
+#if SCALED_REF_LAYER_OFFSETS
+    if( layer > 0 )
+    {
+      m_acTEncTop[layer].getScaledRefLayerWindow().setWindow( 2*m_scaledRefLayerLeftOffset, 2*m_scaledRefLayerRightOffset,
+                                                  2*m_scaledRefLayerTopOffset, 2*m_scaledRefLayerBottomOffset);  
+    }
+#endif
   }
 }
Index: branches/SHM-2.0-dev/source/Lib/TLibCommon/TComDataCU.cpp
===================================================================
--- branches/SHM-2.0-dev/source/Lib/TLibCommon/TComDataCU.cpp	(revision 174)
+++ branches/SHM-2.0-dev/source/Lib/TLibCommon/TComDataCU.cpp	(revision 175)
@@ -4200,6 +4200,13 @@
 
 #if SIMPLIFIED_MV_POS_SCALING
+#if SCALED_REF_LAYER_OFFSETS
+  Int leftStartL = this->getSlice()->getSPS()->getScaledRefLayerWindow().getWindowLeftOffset();
+  Int topStartL  = this->getSlice()->getSPS()->getScaledRefLayerWindow().getWindowTopOffset();
+  Int iBX = ((uiPelX - leftStartL)*g_posScalingFactor[m_layerId][0] + (1<<15)) >> 16;
+  Int iBY = ((uiPelY - topStartL )*g_posScalingFactor[m_layerId][1] + (1<<15)) >> 16;
+#else
   Int iBX = (uiPelX*g_posScalingFactor[m_layerId][0] + (1<<15)) >> 16;
   Int iBY = (uiPelY*g_posScalingFactor[m_layerId][1] + (1<<15)) >> 16;
+#endif
 #else
   Int iBX = (uiPelX*widthBL + widthEL/2)/widthEL;
@@ -4207,5 +4214,10 @@
 #endif
 
+#if SCALED_REF_LAYER_OFFSETS
+  if ( iBX >= cBaseColPic->getPicYuvRec()->getWidth() || iBY >= cBaseColPic->getPicYuvRec()->getHeight() ||
+       iBX < 0                                        || iBY < 0                                           )
+#else
   if ( iBX >= cBaseColPic->getPicYuvRec()->getWidth() || iBY >= cBaseColPic->getPicYuvRec()->getHeight())
+#endif
   {
     return NULL;
Index: branches/SHM-2.0-dev/source/Lib/TLibCommon/TComPrediction.cpp
===================================================================
--- branches/SHM-2.0-dev/source/Lib/TLibCommon/TComPrediction.cpp	(revision 174)
+++ branches/SHM-2.0-dev/source/Lib/TLibCommon/TComPrediction.cpp	(revision 175)
@@ -773,8 +773,15 @@
 
 #if SVC_UPSAMPLING
+#if SCALED_REF_LAYER_OFFSETS
+Void TComPrediction::upsampleBasePic( TComPicYuv* pcUsPic, TComPicYuv* pcBasePic, TComPicYuv* pcTempPic, const Window window)
+{
+  m_cUsf.upsampleBasePic( pcUsPic, pcBasePic, pcTempPic, window);
+}
+#else
 Void TComPrediction::upsampleBasePic( TComPicYuv* pcUsPic, TComPicYuv* pcBasePic, TComPicYuv* pcTempPic)
 {
   m_cUsf.upsampleBasePic( pcUsPic, pcBasePic, pcTempPic);
 }
+#endif
 #endif
 //! \}
Index: branches/SHM-2.0-dev/source/Lib/TLibCommon/TComPrediction.h
===================================================================
--- branches/SHM-2.0-dev/source/Lib/TLibCommon/TComPrediction.h	(revision 174)
+++ branches/SHM-2.0-dev/source/Lib/TLibCommon/TComPrediction.h	(revision 175)
@@ -122,5 +122,9 @@
 
 #if SVC_UPSAMPLING
+#if SCALED_REF_LAYER_OFFSETS
+  Void upsampleBasePic( TComPicYuv* pcUsPic, TComPicYuv* pcBasePic, TComPicYuv* pcTempPic, const Window window );
+#else
   Void upsampleBasePic( TComPicYuv* pcUsPic, TComPicYuv* pcBasePic, TComPicYuv* pcTempPic );
+#endif
 #endif
 };
Index: branches/SHM-2.0-dev/source/Lib/TLibCommon/TComSlice.h
===================================================================
--- branches/SHM-2.0-dev/source/Lib/TLibCommon/TComSlice.h	(revision 174)
+++ branches/SHM-2.0-dev/source/Lib/TLibCommon/TComSlice.h	(revision 175)
@@ -1020,4 +1020,7 @@
 #if REF_IDX_MFM
   Bool m_bMFMEnabledFlag;
+#endif
+#if SCALED_REF_LAYER_OFFSETS
+  Window      m_scaledRefLayerWindow;
 #endif
 public:
@@ -1160,4 +1163,7 @@
   Bool     getMFMEnabledFlag()          {return m_bMFMEnabledFlag;}
 #endif
+#if SCALED_REF_LAYER_OFFSETS
+  Window&  getScaledRefLayerWindow(     )   { return m_scaledRefLayerWindow; }
+#endif
 };
 
Index: branches/SHM-2.0-dev/source/Lib/TLibCommon/TComUpsampleFilter.cpp
===================================================================
--- branches/SHM-2.0-dev/source/Lib/TLibCommon/TComUpsampleFilter.cpp	(revision 174)
+++ branches/SHM-2.0-dev/source/Lib/TLibCommon/TComUpsampleFilter.cpp	(revision 175)
@@ -128,5 +128,9 @@
 }
 
+#if SCALED_REF_LAYER_OFFSETS
+Void TComUpsampleFilter::upsampleBasePic( TComPicYuv* pcUsPic, TComPicYuv* pcBasePic, TComPicYuv* pcTempPic, const Window window )
+#else
 Void TComUpsampleFilter::upsampleBasePic( TComPicYuv* pcUsPic, TComPicYuv* pcBasePic, TComPicYuv* pcTempPic )
+#endif
 {
   assert ( NTAPS_US_LUMA == 8 );
@@ -136,4 +140,15 @@
 
   //========== Y component upsampling ===========
+#if SCALED_REF_LAYER_OFFSETS
+  const Window &scalEL = window;
+
+  Int widthBL   = pcBasePic->getWidth ();
+  Int heightBL  = pcBasePic->getHeight();
+  Int strideBL  = pcBasePic->getStride();
+
+  Int widthEL   = pcUsPic->getWidth () - scalEL.getWindowLeftOffset() - scalEL.getWindowRightOffset();
+  Int heightEL  = pcUsPic->getHeight() - scalEL.getWindowTopOffset()  - scalEL.getWindowBottomOffset();
+  Int strideEL  = pcUsPic->getStride();
+#else
   const Window &confBL = pcBasePic->getConformanceWindow();
   const Window &confEL = pcUsPic->getConformanceWindow();
@@ -146,5 +161,5 @@
   Int heightEL  = pcUsPic->getHeight() - confEL.getWindowTopOffset() - confEL.getWindowBottomOffset();
   Int strideEL  = pcUsPic->getStride();
-  
+#endif
   Pel* piTempBufY = pcTempPic->getLumaAddr();
   Pel* piSrcBufY  = pcBasePic->getLumaAddr();
@@ -329,5 +344,4 @@
   const Double sFactor12 = sFactor * 12;
 #endif
-
 #if ILP_DECODED_PICTURE
   widthBL   = pcBasePic->getWidth ();
@@ -337,10 +351,23 @@
   heightEL  = pcUsPic->getHeight();
 #endif
+#if SCALED_REF_LAYER_OFFSETS
+  Int leftStartL = scalEL.getWindowLeftOffset();
+  Int rightEndL  = pcUsPic->getWidth() - scalEL.getWindowRightOffset();
+  Int topStartL  = scalEL.getWindowTopOffset();
+  Int bottomEndL = pcUsPic->getHeight() - scalEL.getWindowBottomOffset();
+#endif
 
   //========== horizontal upsampling ===========
   for( i = 0; i < widthEL; i++ )
   {
+#if SCALED_REF_LAYER_OFFSETS
+    Int x = Clip3( leftStartL, rightEndL - 1, i );
+#endif
 #if PHASE_DERIVATION_IN_INTEGER
+#if SCALED_REF_LAYER_OFFSETS
+    refPos16 = (((x - leftStartL)*scaleX + addX) >> shiftXM4) - deltaX;
+#else
     refPos16 = ((i*scaleX + addX) >> shiftXM4) - deltaX;
+#endif
     phase    = refPos16 & 15;
     refPos   = refPos16 >> 4;
@@ -374,8 +401,19 @@
   Int iOffset = 1 << (nShift - 1); 
 
+#if SCALED_REF_LAYER_OFFSETS
+  for( j = 0; j < pcTempPic->getHeight(); j++ )
+#else
   for( j = 0; j < heightEL; j++ )
-  {
+#endif
+  {
+#if SCALED_REF_LAYER_OFFSETS
+    Int y = Clip3(topStartL, bottomEndL - 1, j);
+#endif
 #if PHASE_DERIVATION_IN_INTEGER
+#if SCALED_REF_LAYER_OFFSETS
+    refPos16 = ((( y - topStartL )*scaleY + addY) >> shiftYM4) - deltaY;
+#else
     refPos16 = ((j*scaleY + addY) >> shiftYM4) - deltaY;
+#endif
     phase    = refPos16 & 15;
     refPos   = refPos16 >> 4;
@@ -390,9 +428,21 @@
     piSrcY = piTempBufY + (refPos -((NTAPS_US_LUMA>>1) - 1))*strideEL;
     piDstY = piDstBufY + j * strideEL;
-
+#if SCALED_REF_LAYER_OFFSETS
+    for( i = 0; i < pcTempPic->getWidth(); i++ )
+#else
     for( i = 0; i < widthEL; i++ )
+#endif
     {
       *piDstY = ClipY( (sumLumaVer(piSrcY, coeff, strideEL) + iOffset) >> (nShift));
+#if SCALED_REF_LAYER_OFFSETS
+      // Only increase the x position of reference upsample picture when within the window
+      // "-2" to ensure that pointer doesn't go beyond the boundeary rightEndL-1
+      if( (i >= leftStartL) && (i <= rightEndL-2) )
+      {
+        piSrcY++;
+      }
+#else
       piSrcY++;
+#endif
       piDstY++;
     }
@@ -400,4 +450,11 @@
 
 #if ILP_DECODED_PICTURE
+#if SCALED_REF_LAYER_OFFSETS
+  widthBL   = pcBasePic->getWidth ();
+  heightBL  = pcBasePic->getHeight();
+
+  widthEL   = pcUsPic->getWidth () - scalEL.getWindowLeftOffset() - scalEL.getWindowRightOffset();
+  heightEL  = pcUsPic->getHeight() - scalEL.getWindowTopOffset()  - scalEL.getWindowBottomOffset();
+#else
   widthBL   = pcBasePic->getWidth () - confBL.getWindowLeftOffset() - confBL.getWindowRightOffset();
   heightBL  = pcBasePic->getHeight() - confBL.getWindowTopOffset() - confBL.getWindowBottomOffset();
@@ -406,4 +463,5 @@
   heightEL  = pcUsPic->getHeight() - confEL.getWindowTopOffset() - confEL.getWindowBottomOffset();
 #endif
+#endif
 
   //========== UV component upsampling ===========
@@ -417,4 +475,10 @@
   strideBL  = pcBasePic->getCStride();
   strideEL  = pcUsPic->getCStride();
+#if SCALED_REF_LAYER_OFFSETS
+  Int leftStartC = scalEL.getWindowLeftOffset() >> 1;
+  Int rightEndC  = (pcUsPic->getWidth() >> 1) - (scalEL.getWindowRightOffset() >> 1);
+  Int topStartC  = scalEL.getWindowTopOffset() >> 1;
+  Int bottomEndC = (pcUsPic->getHeight() >> 1) - (scalEL.getWindowBottomOffset() >> 1);
+#endif
 
 #if PHASE_DERIVATION_IN_INTEGER
@@ -449,6 +513,13 @@
   for( i = 0; i < widthEL; i++ )
   {
+#if SCALED_REF_LAYER_OFFSETS
+    Int x = Clip3(leftStartC, rightEndC - 1, i);
+#endif
 #if PHASE_DERIVATION_IN_INTEGER
+#if SCALED_REF_LAYER_OFFSETS
+    refPos16 = (((x - leftStartC)*scaleX + addX) >> shiftXM4) - deltaX;
+#else
     refPos16 = ((i*scaleX + addX) >> shiftXM4) - deltaX;
+#endif
     phase    = refPos16 & 15;
     refPos   = refPos16 >> 4;
@@ -484,8 +555,19 @@
   pcTempPic->setHeight(heightEL << 1);
 
-  for( j = 0; j < heightEL; j++ )
-  {
+#if SCALED_REF_LAYER_OFFSETS
+  for( j = 0; j < pcTempPic->getHeight() >> 1; j++ )
+#else
+    for( j = 0; j < heightEL; j++ )
+#endif
+  {
+#if SCALED_REF_LAYER_OFFSETS
+    Int y = Clip3(topStartC, bottomEndC - 1, j);
+#endif
 #if PHASE_DERIVATION_IN_INTEGER
+#if SCALED_REF_LAYER_OFFSETS
+    refPos16 = (((y - topStartC)*scaleY + addY) >> shiftYM4) - deltaY;
+#else
     refPos16 = ((j*scaleY + addY) >> shiftYM4) - deltaY;
+#endif
     phase    = refPos16 & 15;
     refPos   = refPos16 >> 4; 
@@ -512,11 +594,25 @@
     piDstV = piDstBufV + j*strideEL;
 
+#if SCALED_REF_LAYER_OFFSETS
+    for( i = 0; i < pcTempPic->getWidth() >> 1; i++ )
+#else
     for( i = 0; i < widthEL; i++ )
+#endif
     {
       *piDstU = ClipC( (sumChromaVer(piSrcU, coeff, strideEL) + iOffset) >> (nShift));
       *piDstV = ClipC( (sumChromaVer(piSrcV, coeff, strideEL) + iOffset) >> (nShift));
 
+#if SCALED_REF_LAYER_OFFSETS
+      // Only increase the x position of reference upsample picture when within the window
+      // "-2" to ensure that pointer doesn't go beyond the boundeary rightEndC-1
+      if( (i >= leftStartC) && (i <= rightEndC-2) )
+      {
+        piSrcU++;
+        piSrcV++;
+      }
+#else
       piSrcU++;
       piSrcV++;
+#endif
       piDstU++;
       piDstV++;
Index: branches/SHM-2.0-dev/source/Lib/TLibCommon/TComUpsampleFilter.h
===================================================================
--- branches/SHM-2.0-dev/source/Lib/TLibCommon/TComUpsampleFilter.h	(revision 174)
+++ branches/SHM-2.0-dev/source/Lib/TLibCommon/TComUpsampleFilter.h	(revision 175)
@@ -52,5 +52,9 @@
   ~TComUpsampleFilter(void);
 
+#if SCALED_REF_LAYER_OFFSETS
+  Void upsampleBasePic( TComPicYuv* pcUsPic, TComPicYuv* pcBasePic, TComPicYuv* pcTempPic, const Window window );
+#else
  Void upsampleBasePic( TComPicYuv* pcUsPic, TComPicYuv* pcBasePic, TComPicYuv* pcTempPic );
+#endif
 };
 
Index: branches/SHM-2.0-dev/source/Lib/TLibCommon/TypeDef.h
===================================================================
--- branches/SHM-2.0-dev/source/Lib/TLibCommon/TypeDef.h	(revision 174)
+++ branches/SHM-2.0-dev/source/Lib/TLibCommon/TypeDef.h	(revision 175)
@@ -44,4 +44,5 @@
 
 #if SVC_EXTENSION
+#define SCALED_REF_LAYER_OFFSETS         1      ///< M0309: Signal scaled reference layer offsets in SPS
 #define MAX_LAYERS                       2      ///< max number of layers the codec is supposed to handle
 
Index: branches/SHM-2.0-dev/source/Lib/TLibDecoder/TDecCAVLC.cpp
===================================================================
--- branches/SHM-2.0-dev/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 174)
+++ branches/SHM-2.0-dev/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 175)
@@ -712,4 +712,16 @@
   }
 
+#if SCALED_REF_LAYER_OFFSETS
+  if( pcSPS->getLayerId() > 0 )
+  {
+    Int iCode;
+    Window& scaledWindow = pcSPS->getScaledRefLayerWindow();
+    READ_SVLC( iCode, "scaled_ref_layer_left_offset" );    scaledWindow.setWindowLeftOffset  (iCode << 1);
+    READ_SVLC( iCode, "scaled_ref_layer_top_offset" );     scaledWindow.setWindowTopOffset   (iCode << 1);
+    READ_SVLC( iCode, "scaled_ref_layer_right_offset" );   scaledWindow.setWindowRightOffset (iCode << 1);
+    READ_SVLC( iCode, "scaled_ref_layer_bottom_offset" );  scaledWindow.setWindowBottomOffset(iCode << 1);
+  }
+#endif
+
   READ_FLAG( uiCode, "sps_extension_flag");
   if (uiCode)
Index: branches/SHM-2.0-dev/source/Lib/TLibDecoder/TDecTop.cpp
===================================================================
--- branches/SHM-2.0-dev/source/Lib/TLibDecoder/TDecTop.cpp	(revision 174)
+++ branches/SHM-2.0-dev/source/Lib/TLibDecoder/TDecTop.cpp	(revision 175)
@@ -836,5 +836,9 @@
       if ( pcPic->isSpatialEnhLayer())
       {    
+#if SCALED_REF_LAYER_OFFSETS
+        m_cPrediction.upsampleBasePic( pcPic->getFullPelBaseRec(), pcSlice->getBaseColPic()->getPicYuvRec(), pcPic->getPicYuvRec(), pcSlice->getSPS()->getScaledRefLayerWindow() );
+#else
         m_cPrediction.upsampleBasePic( pcPic->getFullPelBaseRec(), pcSlice->getBaseColPic()->getPicYuvRec(), pcPic->getPicYuvRec() );
+#endif
       }
       else
@@ -948,4 +952,13 @@
   if (m_layerId > 0)
   {
+#if SCALED_REF_LAYER_OFFSETS
+    const Window &scalEL = pcSlice->getSPS()->getScaledRefLayerWindow();
+
+    Int widthBL   = pcSlice->getBaseColPic()->getPicYuvRec()->getWidth();
+    Int heightBL  = pcSlice->getBaseColPic()->getPicYuvRec()->getHeight();
+
+    Int widthEL   = pcPic->getPicYuvRec()->getWidth()  - scalEL.getWindowLeftOffset() - scalEL.getWindowRightOffset();
+    Int heightEL  = pcPic->getPicYuvRec()->getHeight() - scalEL.getWindowTopOffset()  - scalEL.getWindowBottomOffset();
+#else
     const Window &confBL = pcSlice->getBaseColPic()->getPicYuvRec()->getConformanceWindow();
     const Window &confEL = pcPic->getPicYuvRec()->getConformanceWindow();
@@ -956,5 +969,5 @@
     Int widthEL   = pcPic->getPicYuvRec()->getWidth() - confEL.getWindowLeftOffset() - confEL.getWindowRightOffset();
     Int heightEL  = pcPic->getPicYuvRec()->getHeight() - confEL.getWindowTopOffset() - confEL.getWindowBottomOffset();
-
+#endif
     g_mvScalingFactor[m_layerId][0] = Clip3(-4096, 4095, ((widthEL  << 8) + (widthBL  >> 1)) / widthBL);
     g_mvScalingFactor[m_layerId][1] = Clip3(-4096, 4095, ((heightEL << 8) + (heightBL >> 1)) / heightBL);
Index: branches/SHM-2.0-dev/source/Lib/TLibEncoder/TEncCavlc.cpp
===================================================================
--- branches/SHM-2.0-dev/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 174)
+++ branches/SHM-2.0-dev/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 175)
@@ -553,4 +553,14 @@
       codeVUI(pcSPS->getVuiParameters(), pcSPS);
   }
+#if SCALED_REF_LAYER_OFFSETS
+  if( pcSPS->getLayerId() > 0 )
+  {
+    Window scaledWindow = pcSPS->getScaledRefLayerWindow();
+    WRITE_SVLC( scaledWindow.getWindowLeftOffset()   >> 1, "scaled_ref_layer_left_offset" );
+    WRITE_SVLC( scaledWindow.getWindowTopOffset()    >> 1, "scaled_ref_layer_top_offset" );
+    WRITE_SVLC( scaledWindow.getWindowRightOffset()  >> 1, "scaled_ref_layer_right_offset" );
+    WRITE_SVLC( scaledWindow.getWindowBottomOffset() >> 1, "scaled_ref_layer_bottom_offset" );
+  }
+#endif
 
   WRITE_FLAG( 0, "sps_extension_flag" );
Index: branches/SHM-2.0-dev/source/Lib/TLibEncoder/TEncGOP.cpp
===================================================================
--- branches/SHM-2.0-dev/source/Lib/TLibEncoder/TEncGOP.cpp	(revision 174)
+++ branches/SHM-2.0-dev/source/Lib/TLibEncoder/TEncGOP.cpp	(revision 175)
@@ -690,6 +690,10 @@
 #if SVC_UPSAMPLING
       if ( pcPic->isSpatialEnhLayer())
-      {    
+      { 
+#if SCALED_REF_LAYER_OFFSETS
+        m_pcPredSearch->upsampleBasePic( pcPic->getFullPelBaseRec(), pcSlice->getBaseColPic()->getPicYuvRec(), pcPic->getPicYuvRec(), pcSlice->getSPS()->getScaledRefLayerWindow() );
+#else
         m_pcPredSearch->upsampleBasePic( pcPic->getFullPelBaseRec(), pcSlice->getBaseColPic()->getPicYuvRec(), pcPic->getPicYuvRec() );
+#endif
       }
       else
@@ -976,4 +980,13 @@
     if (m_layerId > 0)
     {
+#if SCALED_REF_LAYER_OFFSETS
+      const Window &scalEL = m_pcEncTop->getScaledRefLayerWindow();
+
+      Int widthBL   = pcSlice->getBaseColPic()->getPicYuvRec()->getWidth();
+      Int heightBL  = pcSlice->getBaseColPic()->getPicYuvRec()->getHeight();
+
+      Int widthEL   = pcPic->getPicYuvRec()->getWidth()  - scalEL.getWindowLeftOffset() - scalEL.getWindowRightOffset();
+      Int heightEL  = pcPic->getPicYuvRec()->getHeight() - scalEL.getWindowTopOffset()  - scalEL.getWindowBottomOffset();
+#else
       const Window &confBL = pcSlice->getBaseColPic()->getPicYuvRec()->getConformanceWindow();
       const Window &confEL = pcPic->getPicYuvRec()->getConformanceWindow();
@@ -984,5 +997,5 @@
       Int widthEL   = pcPic->getPicYuvRec()->getWidth() - confEL.getWindowLeftOffset() - confEL.getWindowRightOffset();
       Int heightEL  = pcPic->getPicYuvRec()->getHeight() - confEL.getWindowTopOffset() - confEL.getWindowBottomOffset();
-
+#endif
       g_mvScalingFactor[m_layerId][0] = Clip3(-4096, 4095, ((widthEL  << 8) + (widthBL  >> 1)) / widthBL);
       g_mvScalingFactor[m_layerId][1] = Clip3(-4096, 4095, ((heightEL << 8) + (heightBL >> 1)) / heightBL);
Index: branches/SHM-2.0-dev/source/Lib/TLibEncoder/TEncTop.cpp
===================================================================
--- branches/SHM-2.0-dev/source/Lib/TLibEncoder/TEncTop.cpp	(revision 174)
+++ branches/SHM-2.0-dev/source/Lib/TLibEncoder/TEncTop.cpp	(revision 175)
@@ -576,4 +576,7 @@
   m_cSPS.setMFMEnabledFlag(m_bMFMEnabledFlag);
 #endif
+#if SCALED_REF_LAYER_OFFSETS
+  m_cSPS.getScaledRefLayerWindow() = m_scaledRefLayerWindow;
+#endif
   ProfileTierLevel& profileTierLevel = *m_cSPS.getPTL()->getGeneralPTL();
   profileTierLevel.setLevelIdc(m_level);
Index: branches/SHM-2.0-dev/source/Lib/TLibEncoder/TEncTop.h
===================================================================
--- branches/SHM-2.0-dev/source/Lib/TLibEncoder/TEncTop.h	(revision 174)
+++ branches/SHM-2.0-dev/source/Lib/TLibEncoder/TEncTop.h	(revision 175)
@@ -139,4 +139,7 @@
   Bool                    m_bMFMEnabledFlag;
 #endif
+#if SCALED_REF_LAYER_OFFSETS
+  Window                  m_scaledRefLayerWindow;
+#endif
 protected:
   Void  xGetNewPicBuffer  ( TComPic*& rpcPic );           ///< get picture buffer which will be processed
@@ -203,4 +206,7 @@
   Void                    setNumPicRcvd         ( Int num ) { m_iNumPicRcvd = num;      }
 #endif
+#if SCALED_REF_LAYER_OFFSETS
+  Window&  getScaledRefLayerWindow()            { return m_scaledRefLayerWindow; }
+#endif
 
   // -------------------------------------------------------------------------------------------------------------------
