Index: branches/SHM-dev/source/Lib/TLibCommon/TComSlice.cpp
===================================================================
--- branches/SHM-dev/source/Lib/TLibCommon/TComSlice.cpp	(revision 872)
+++ branches/SHM-dev/source/Lib/TLibCommon/TComSlice.cpp	(revision 873)
@@ -287,4 +287,5 @@
 }
 #endif
+
 /**
  - allocate table to contain substream sizes to be written to the slice header.
@@ -3540,4 +3541,18 @@
 }
 #endif
+
+#if RESAMPLING_FIX
+#if R0209_GENERIC_PHASE
+Bool TComPPS::hasZeroResamplingPhase(Int refLayerIdc)
+{
+  Int phaseHorLuma   = this->getPhaseHorLuma(refLayerIdc);
+  Int phaseVerLuma   = this->getPhaseVerLuma(refLayerIdc);
+  Int phaseHorChroma = this->getPhaseHorChroma(refLayerIdc);
+  Int phaseVerChroma = this->getPhaseVerChroma(refLayerIdc);
+  return ( phaseHorLuma == 0 && phaseHorChroma == 0 && phaseVerLuma == 0 && phaseVerChroma == 0);
+}
+#endif
+#endif
+
 #endif
 
Index: branches/SHM-dev/source/Lib/TLibCommon/TComSlice.h
===================================================================
--- branches/SHM-dev/source/Lib/TLibCommon/TComSlice.h	(revision 872)
+++ branches/SHM-dev/source/Lib/TLibCommon/TComSlice.h	(revision 873)
@@ -443,4 +443,13 @@
   Bool          getVertPhasePositionEnableFlag() const     { return m_vertPhasePositionEnableFlag;  }
   Void          setVertPhasePositionEnableFlag(Bool val)    { m_vertPhasePositionEnableFlag = val;  }
+#endif
+#if REF_REGION_OFFSET && RESAMPLING_FIX
+  Bool          hasEqualOffset(const Window& ref) const
+  {
+    return (    this->getWindowLeftOffset()   == ref.getWindowLeftOffset()
+             && this->getWindowTopOffset()    == ref.getWindowTopOffset()
+             && this->getWindowRightOffset()  == ref.getWindowRightOffset()
+             && this->getWindowBottomOffset() == ref.getWindowBottomOffset() );
+  }
 #endif
 
@@ -2040,4 +2049,7 @@
   Bool getResamplePhaseSetPresentFlag(Int x) { return m_resamplePhaseSetPresentFlag[x]; }
   Void setResamplePhaseSetPresentFlag(Int x, Bool b) { m_resamplePhaseSetPresentFlag[x] = b; }
+#if RESAMPLING_FIX
+  Bool hasZeroResamplingPhase(Int layerId);
+#endif
 #endif
 #endif
@@ -2629,5 +2641,4 @@
 #endif
 
-
 #endif //SVC_EXTENSION
 protected:
Index: branches/SHM-dev/source/Lib/TLibCommon/TypeDef.h
===================================================================
--- branches/SHM-dev/source/Lib/TLibCommon/TypeDef.h	(revision 872)
+++ branches/SHM-dev/source/Lib/TLibCommon/TypeDef.h	(revision 873)
@@ -255,4 +255,5 @@
 #define R0209_GENERIC_PHASE              1      ///< JCTVC-R0209: resampling with generic phase
 #define R0220_REMOVE_EL_CLIP             1      ///< JCTVC-R0220: remove clip to scaled ref window in resampling process
+#define RESAMPLING_FIX                   1      ///< Resampling fix -- equal offset check and conformance check
 #endif
 #else
Index: branches/SHM-dev/source/Lib/TLibDecoder/TDecTop.cpp
===================================================================
--- branches/SHM-dev/source/Lib/TLibDecoder/TDecTop.cpp	(revision 872)
+++ branches/SHM-dev/source/Lib/TLibDecoder/TDecTop.cpp	(revision 873)
@@ -381,6 +381,13 @@
 #if REF_REGION_OFFSET
         const Window refEL = pcSlice->getPPS()->getRefLayerWindowForLayer(pcSlice->getVPS()->getRefLayerId(m_layerId, i));
+#if RESAMPLING_FIX
+        Bool equalOffsets = scalEL.hasEqualOffset(refEL);
+#if R0209_GENERIC_PHASE
+        Bool zeroPhase = pcSlice->getPPS()->hasZeroResamplingPhase(pcSlice->getVPS()->getRefLayerId(m_layerId, i));
+#endif
+#else
         Bool zeroOffsets = ( scalEL.getWindowLeftOffset() == 0 && scalEL.getWindowRightOffset() == 0 && scalEL.getWindowTopOffset() == 0 && scalEL.getWindowBottomOffset() == 0
                              && refEL.getWindowLeftOffset() == 0 && refEL.getWindowRightOffset() == 0 && refEL.getWindowTopOffset() == 0 && refEL.getWindowBottomOffset() == 0 );
+#endif
 #else
         Bool zeroOffsets = ( scalEL.getWindowLeftOffset() == 0 && scalEL.getWindowRightOffset() == 0 && scalEL.getWindowTopOffset() == 0 && scalEL.getWindowBottomOffset() == 0 );
@@ -399,5 +406,13 @@
         Bool sameBitDepths = ( g_bitDepthYLayer[m_layerId] == g_bitDepthYLayer[refLayerId] ) && ( g_bitDepthCLayer[m_layerId] == g_bitDepthCLayer[refLayerId] );
 
-        if( pcPicYuvRecBase->getWidth() != pcSlice->getPicWidthInLumaSamples() || pcPicYuvRecBase->getHeight() != pcSlice->getPicHeightInLumaSamples() || !zeroOffsets || !sameBitDepths
+        if( pcPicYuvRecBase->getWidth() != pcSlice->getPicWidthInLumaSamples() || pcPicYuvRecBase->getHeight() != pcSlice->getPicHeightInLumaSamples() || !sameBitDepths
+#if REF_REGION_OFFSET && RESAMPLING_FIX
+          || !equalOffsets
+#if R0209_GENERIC_PHASE
+          || !zeroPhase
+#endif
+#else
+          || !zeroOffsets
+#endif
 #if Q0048_CGS_3D_ASYMLUT
           || pcSlice->getPPS()->getCGSFlag() > 0
@@ -408,8 +423,26 @@
           )
 #else
-        if(pcPicYuvRecBase->getWidth() != pcSlice->getPicWidthInLumaSamples() || pcPicYuvRecBase->getHeight() != pcSlice->getPicHeightInLumaSamples() || !zeroOffsets )
-#endif
-#else
-        if(pcPicYuvRecBase->getWidth() != pcSlice->getSPS()->getPicWidthInLumaSamples() || pcPicYuvRecBase->getHeight() != pcSlice->getSPS()->getPicHeightInLumaSamples() || !zeroOffsets )
+        if(pcPicYuvRecBase->getWidth() != pcSlice->getPicWidthInLumaSamples() || pcPicYuvRecBase->getHeight() != pcSlice->getPicHeightInLumaSamples()
+#if REF_REGION_OFFSET && RESAMPLING_FIX
+          || !equalOffsets
+#if R0209_GENERIC_PHASE
+          || !zeroPhase
+#endif
+#else
+          || !zeroOffsets
+#endif
+        )
+#endif
+#else
+        if(pcPicYuvRecBase->getWidth() != pcSlice->getSPS()->getPicWidthInLumaSamples() || pcPicYuvRecBase->getHeight() != pcSlice->getSPS()->getPicHeightInLumaSamples()
+#if REF_REGION_OFFSET && RESAMPLING_FIX
+          || !equalOffsets
+#if R0209_GENERIC_PHASE
+          || !zeroPhase
+#endif
+#else
+          || !zeroOffsets
+#endif
+        )
 #endif
         {
@@ -1974,4 +2007,24 @@
         Int widthEL   = pcPic->getPicYuvRec()->getWidth()  - scalEL.getWindowLeftOffset() - scalEL.getWindowRightOffset();
         Int heightEL  = pcPic->getPicYuvRec()->getHeight() - scalEL.getWindowTopOffset()  - scalEL.getWindowBottomOffset();
+
+#if RESAMPLING_FIX
+#if REF_REGION_OFFSET
+        // conformance check: the values of RefLayerRegionWidthInSamplesY, RefLayerRegionHeightInSamplesY, ScaledRefRegionWidthInSamplesY and ScaledRefRegionHeightInSamplesY shall be greater than 0
+        assert(widthEL > 0 && heightEL > 0 && widthBL > 0 && widthEL > 0);
+
+        // conformance check: ScaledRefRegionWidthInSamplesY shall be greater or equal to RefLayerRegionWidthInSamplesY and ScaledRefRegionHeightInSamplesY shall be greater or equal to RefLayerRegionHeightInSamplesY
+        assert(widthEL >= widthBL && heightEL >= heightBL);
+
+#if R0209_GENERIC_PHASE
+        // conformance check: when ScaledRefRegionWidthInSamplesY is equal to RefLayerRegionWidthInSamplesY, PhaseHorY shall be equal to 0, when ScaledRefRegionWidthInSamplesC is equal to RefLayerRegionWidthInSamplesC, PhaseHorC shall be equal to 0, when ScaledRefRegionHeightInSamplesY is equal to RefLayerRegionHeightInSamplesY, PhaseVerY shall be equal to 0, and when ScaledRefRegionHeightInSamplesC is equal to RefLayerRegionHeightInSamplesC, PhaseVerC shall be equal to 0.
+        Int phaseHorLuma   = pcSlice->getPPS()->getPhaseHorLuma(refLayerIdc);
+        Int phaseVerLuma   = pcSlice->getPPS()->getPhaseVerLuma(refLayerIdc);
+        Int phaseHorChroma = pcSlice->getPPS()->getPhaseHorChroma(refLayerIdc);
+        Int phaseVerChroma = pcSlice->getPPS()->getPhaseVerChroma(refLayerIdc);
+        assert( ( (widthEL  != widthBL)  || (phaseHorLuma == 0 && phaseHorChroma == 0) )
+             && ( (heightEL != heightBL) || (phaseVerLuma == 0 && phaseVerChroma == 0) ) );
+#endif
+#endif
+#endif
 
         g_mvScalingFactor[refLayerIdc][0] = widthEL  == widthBL  ? 4096 : Clip3(-4096, 4095, ((widthEL  << 8) + (widthBL  >> 1)) / widthBL);
Index: branches/SHM-dev/source/Lib/TLibEncoder/TEncGOP.cpp
===================================================================
--- branches/SHM-dev/source/Lib/TLibEncoder/TEncGOP.cpp	(revision 872)
+++ branches/SHM-dev/source/Lib/TLibEncoder/TEncGOP.cpp	(revision 873)
@@ -1124,4 +1124,24 @@
         Int widthEL   = pcPic->getPicYuvRec()->getWidth()  - scalEL.getWindowLeftOffset() - scalEL.getWindowRightOffset();
         Int heightEL  = pcPic->getPicYuvRec()->getHeight() - scalEL.getWindowTopOffset()  - scalEL.getWindowBottomOffset();
+
+#if RESAMPLING_FIX
+#if REF_REGION_OFFSET
+        // conformance check: the values of RefLayerRegionWidthInSamplesY, RefLayerRegionHeightInSamplesY, ScaledRefRegionWidthInSamplesY and ScaledRefRegionHeightInSamplesY shall be greater than 0
+        assert(widthEL > 0 && heightEL > 0 && widthBL > 0 && widthEL > 0);
+
+        // conformance check: ScaledRefRegionWidthInSamplesY shall be greater or equal to RefLayerRegionWidthInSamplesY and ScaledRefRegionHeightInSamplesY shall be greater or equal to RefLayerRegionHeightInSamplesY
+        assert(widthEL >= widthBL && heightEL >= heightBL);
+
+#if R0209_GENERIC_PHASE
+        // conformance check: when ScaledRefRegionWidthInSamplesY is equal to RefLayerRegionWidthInSamplesY, PhaseHorY shall be equal to 0, when ScaledRefRegionWidthInSamplesC is equal to RefLayerRegionWidthInSamplesC, PhaseHorC shall be equal to 0, when ScaledRefRegionHeightInSamplesY is equal to RefLayerRegionHeightInSamplesY, PhaseVerY shall be equal to 0, and when ScaledRefRegionHeightInSamplesC is equal to RefLayerRegionHeightInSamplesC, PhaseVerC shall be equal to 0.
+        Int phaseHorLuma   = pcSlice->getPPS()->getPhaseHorLuma(refLayerIdc);
+        Int phaseVerLuma   = pcSlice->getPPS()->getPhaseVerLuma(refLayerIdc);
+        Int phaseHorChroma = pcSlice->getPPS()->getPhaseHorChroma(refLayerIdc);
+        Int phaseVerChroma = pcSlice->getPPS()->getPhaseVerChroma(refLayerIdc);
+        assert( ( (widthEL  != widthBL)  || (phaseHorLuma == 0 && phaseHorChroma == 0) )
+             && ( (heightEL != heightBL) || (phaseVerLuma == 0 && phaseVerChroma == 0) ) );
+#endif
+#endif
+#endif
 
         g_mvScalingFactor[refLayerIdc][0] = widthEL  == widthBL  ? 4096 : Clip3(-4096, 4095, ((widthEL  << 8) + (widthBL  >> 1)) / widthBL);
Index: branches/SHM-dev/source/Lib/TLibEncoder/TEncTop.cpp
===================================================================
--- branches/SHM-dev/source/Lib/TLibEncoder/TEncTop.cpp	(revision 872)
+++ branches/SHM-dev/source/Lib/TLibEncoder/TEncTop.cpp	(revision 873)
@@ -794,6 +794,13 @@
 #if REF_REGION_OFFSET
           const Window altRL  = getPPS()->getRefLayerWindowForLayer(m_cVPS.getRefLayerId(m_layerId, i));
+#if RESAMPLING_FIX
+          Bool equalOffsets = scalEL.hasEqualOffset(altRL);
+#if R0209_GENERIC_PHASE
+          Bool zeroPhase = getPPS()->hasZeroResamplingPhase(m_cVPS.getRefLayerId(m_layerId, i));
+#endif
+#else
           Bool zeroOffsets = ( scalEL.getWindowLeftOffset() == 0 && scalEL.getWindowRightOffset() == 0 && scalEL.getWindowTopOffset() == 0 && scalEL.getWindowBottomOffset() == 0
                                && altRL.getWindowLeftOffset() == 0 && altRL.getWindowRightOffset() == 0 && altRL.getWindowTopOffset() == 0 && altRL.getWindowBottomOffset() == 0);
+#endif
 #else
           Bool zeroOffsets = ( scalEL.getWindowLeftOffset() == 0 && scalEL.getWindowRightOffset() == 0 && scalEL.getWindowTopOffset() == 0 && scalEL.getWindowBottomOffset() == 0 );
@@ -809,5 +816,13 @@
           Bool sameBitDepths = ( g_bitDepthYLayer[m_layerId] == g_bitDepthYLayer[refLayerId] ) && ( g_bitDepthCLayer[m_layerId] == g_bitDepthCLayer[refLayerId] );
 
-          if( m_iSourceWidth != pcEncTopBase->getSourceWidth() || m_iSourceHeight != pcEncTopBase->getSourceHeight() || !zeroOffsets || !sameBitDepths 
+          if( m_iSourceWidth != pcEncTopBase->getSourceWidth() || m_iSourceHeight != pcEncTopBase->getSourceHeight() || !sameBitDepths 
+#if REF_REGION_OFFSET && RESAMPLING_FIX
+            || !equalOffsets
+#if R0209_GENERIC_PHASE
+            || !zeroPhase
+#endif
+#else
+            || !zeroOffsets
+#endif
 #if Q0048_CGS_3D_ASYMLUT
             || m_cPPS.getCGSFlag() > 0
@@ -818,5 +833,14 @@
             )
 #else
-          if(m_iSourceWidth != pcEncTopBase->getSourceWidth() || m_iSourceHeight != pcEncTopBase->getSourceHeight() || !zeroOffsets )
+          if(m_iSourceWidth != pcEncTopBase->getSourceWidth() || m_iSourceHeight != pcEncTopBase->getSourceHeight()
+#if REF_REGION_OFFSET && RESAMPLING_FIX
+            || !equalOffsets
+#if R0209_GENERIC_PHASE
+            || !zeroPhase
+#endif
+#else
+            || !zeroOffsets
+#endif
+          )
 #endif
           {
@@ -868,6 +892,13 @@
 #if REF_REGION_OFFSET
           const Window altRL  = getPPS()->getRefLayerWindowForLayer(m_cVPS.getRefLayerId(m_layerId, i));
+#if RESAMPLING_FIX
+          Bool equalOffsets = scalEL.hasEqualOffset(altRL);
+#if R0209_GENERIC_PHASE
+          Bool zeroPhase = getPPS()->hasZeroResamplingPhase(m_cVPS.getRefLayerId(m_layerId, i));
+#endif
+#else
           Bool zeroOffsets = ( scalEL.getWindowLeftOffset() == 0 && scalEL.getWindowRightOffset() == 0 && scalEL.getWindowTopOffset() == 0 && scalEL.getWindowBottomOffset() == 0
                                && altRL.getWindowLeftOffset() == 0 && altRL.getWindowRightOffset() == 0 && altRL.getWindowTopOffset() == 0 && altRL.getWindowBottomOffset() == 0);
+#endif
 #else
           Bool zeroOffsets = ( scalEL.getWindowLeftOffset() == 0 && scalEL.getWindowRightOffset() == 0 && scalEL.getWindowTopOffset() == 0 && scalEL.getWindowBottomOffset() == 0 );
@@ -883,5 +914,13 @@
           Bool sameBitDepths = ( g_bitDepthYLayer[m_layerId] == g_bitDepthYLayer[refLayerId] ) && ( g_bitDepthCLayer[m_layerId] == g_bitDepthCLayer[refLayerId] );
 
-          if( m_iSourceWidth != pcEncTopBase->getSourceWidth() || m_iSourceHeight != pcEncTopBase->getSourceHeight() || !zeroOffsets || !sameBitDepths 
+          if( m_iSourceWidth != pcEncTopBase->getSourceWidth() || m_iSourceHeight != pcEncTopBase->getSourceHeight() || !sameBitDepths 
+#if REF_REGION_OFFSET && RESAMPLING_FIX
+            || !equalOffsets 
+#if R0209_GENERIC_PHASE
+            || !zeroPhase
+#endif
+#else
+            || !zeroOffsets 
+#endif
 #if Q0048_CGS_3D_ASYMLUT
             || m_cPPS.getCGSFlag() > 0
@@ -892,5 +931,14 @@
 )
 #else
-          if(m_iSourceWidth != pcEncTopBase->getSourceWidth() || m_iSourceHeight != pcEncTopBase->getSourceHeight() || !zeroOffsets )
+          if(m_iSourceWidth != pcEncTopBase->getSourceWidth() || m_iSourceHeight != pcEncTopBase->getSourceHeight()
+#if REF_REGION_OFFSET && RESAMPLING_FIX
+            || !equalOffsets 
+#if R0209_GENERIC_PHASE
+            || !zeroPhase
+#endif
+#else
+            || !zeroOffsets 
+#endif
+          )
 #endif
           {
