Index: /branches/SHM-dev/source/App/TAppEncoder/TAppEncTop.cpp
===================================================================
--- /branches/SHM-dev/source/App/TAppEncoder/TAppEncTop.cpp	(revision 868)
+++ /branches/SHM-dev/source/App/TAppEncoder/TAppEncTop.cpp	(revision 869)
@@ -181,4 +181,13 @@
     repFormat->setBitDepthVpsChroma         ( getInternalBitDepthC()                        );  // Need modification to change for each layer
 #endif
+
+#if R0156_CONF_WINDOW_IN_REP_FORMAT
+    repFormat->getConformanceWindowVps().setWindow(
+      m_acLayerCfg[mapIdxToLayer[idx]].m_confWinLeft, 
+      m_acLayerCfg[mapIdxToLayer[idx]].m_confWinRight, 
+      m_acLayerCfg[mapIdxToLayer[idx]].m_confWinTop,
+      m_acLayerCfg[mapIdxToLayer[idx]].m_confWinBottom );
+#endif
+
 #if HIGHER_LAYER_IRAP_SKIP_FLAG
     m_acTEncTop[mapIdxToLayer[idx]].setSkipPictureAtArcSwitch( m_skipPictureAtArcSwitch );
Index: /branches/SHM-dev/source/Lib/TLibCommon/TComPic.cpp
===================================================================
--- /branches/SHM-dev/source/Lib/TLibCommon/TComPic.cpp	(revision 868)
+++ /branches/SHM-dev/source/Lib/TLibCommon/TComPic.cpp	(revision 869)
@@ -84,4 +84,11 @@
   if (!bIsVirtual)
   {
+#if R0156_CONF_WINDOW_IN_REP_FORMAT
+#if AUXILIARY_PICTURES
+    m_apcPicYuv[0]  = new TComPicYuv;  m_apcPicYuv[0]->create( iWidth, iHeight, chromaFormatIDC, uiMaxWidth, uiMaxHeight, uiMaxDepth, &conformanceWindow );
+#else
+    m_apcPicYuv[0]  = new TComPicYuv;  m_apcPicYuv[0]->create( iWidth, iHeight, uiMaxWidth, uiMaxHeight, uiMaxDepth, &conformanceWindow );
+#endif
+#else
 #if AUXILIARY_PICTURES
     m_apcPicYuv[0]  = new TComPicYuv;  m_apcPicYuv[0]->create( iWidth, iHeight, chromaFormatIDC, uiMaxWidth, uiMaxHeight, uiMaxDepth, pcSps );
@@ -89,5 +96,13 @@
     m_apcPicYuv[0]  = new TComPicYuv;  m_apcPicYuv[0]->create( iWidth, iHeight, uiMaxWidth, uiMaxHeight, uiMaxDepth, pcSps );
 #endif
-  }
+#endif
+  }
+#if R0156_CONF_WINDOW_IN_REP_FORMAT
+#if AUXILIARY_PICTURES
+  m_apcPicYuv[1]  = new TComPicYuv;  m_apcPicYuv[1]->create( iWidth, iHeight, chromaFormatIDC, uiMaxWidth, uiMaxHeight, uiMaxDepth, &conformanceWindow );
+#else
+  m_apcPicYuv[1]  = new TComPicYuv;  m_apcPicYuv[1]->create( iWidth, iHeight, uiMaxWidth, uiMaxHeight, uiMaxDepth, &conformanceWindow );
+#endif
+#else
 #if AUXILIARY_PICTURES
   m_apcPicYuv[1]  = new TComPicYuv;  m_apcPicYuv[1]->create( iWidth, iHeight, chromaFormatIDC, uiMaxWidth, uiMaxHeight, uiMaxDepth, pcSps );
@@ -95,4 +110,5 @@
   m_apcPicYuv[1]  = new TComPicYuv;  m_apcPicYuv[1]->create( iWidth, iHeight, uiMaxWidth, uiMaxHeight, uiMaxDepth, pcSps );
 #endif
+#endif
 
   for( Int i = 0; i < MAX_LAYERS; i++ )
@@ -100,8 +116,16 @@
     if( m_bSpatialEnhLayer[i] )
     {
+#if R0156_CONF_WINDOW_IN_REP_FORMAT
+#if AUXILIARY_PICTURES
+      m_pcFullPelBaseRec[i] = new TComPicYuv;  m_pcFullPelBaseRec[i]->create( iWidth, iHeight, chromaFormatIDC, uiMaxWidth, uiMaxHeight, uiMaxDepth, &conformanceWindow );
+#else
+      m_pcFullPelBaseRec[i] = new TComPicYuv;  m_pcFullPelBaseRec[i]->create( iWidth, iHeight, uiMaxWidth, uiMaxHeight, uiMaxDepth, &conformanceWindow );
+#endif
+#else
 #if AUXILIARY_PICTURES
       m_pcFullPelBaseRec[i] = new TComPicYuv;  m_pcFullPelBaseRec[i]->create( iWidth, iHeight, chromaFormatIDC, uiMaxWidth, uiMaxHeight, uiMaxDepth, pcSps );
 #else
       m_pcFullPelBaseRec[i] = new TComPicYuv;  m_pcFullPelBaseRec[i]->create( iWidth, iHeight, uiMaxWidth, uiMaxHeight, uiMaxDepth, pcSps );
+#endif
 #endif
     }
Index: /branches/SHM-dev/source/Lib/TLibCommon/TComPicYuv.cpp
===================================================================
--- /branches/SHM-dev/source/Lib/TLibCommon/TComPicYuv.cpp	(revision 868)
+++ /branches/SHM-dev/source/Lib/TLibCommon/TComPicYuv.cpp	(revision 869)
@@ -69,4 +69,11 @@
 
 #if SVC_EXTENSION
+#if R0156_CONF_WINDOW_IN_REP_FORMAT
+#if AUXILIARY_PICTURES
+Void TComPicYuv::create( Int iPicWidth, Int iPicHeight, ChromaFormat chromaFormatIDC, UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uiMaxCUDepth, Window* conformanceWindow )
+#else
+Void TComPicYuv::create( Int iPicWidth, Int iPicHeight, UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uiMaxCUDepth, Window* conformanceWindow )
+#endif
+#else // R0156_CONF_WINDOW_IN_REP_FORMAT
 #if AUXILIARY_PICTURES
 Void TComPicYuv::create( Int iPicWidth, Int iPicHeight, ChromaFormat chromaFormatIDC, UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uiMaxCUDepth, TComSPS* pcSps )
@@ -74,4 +81,5 @@
 Void TComPicYuv::create( Int iPicWidth, Int iPicHeight, UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uiMaxCUDepth, TComSPS* pcSps )
 #endif
+#endif
 #else
 Void TComPicYuv::create( Int iPicWidth, Int iPicHeight, UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uiMaxCUDepth )
@@ -82,8 +90,15 @@
   
 #if SVC_EXTENSION
+#if R0156_CONF_WINDOW_IN_REP_FORMAT
+  if(conformanceWindow != NULL)
+  {
+    m_conformanceWindow = *conformanceWindow;
+  }
+#else
   if(pcSps != NULL)
   {
     m_conformanceWindow = pcSps->getConformanceWindow();
   }
+#endif
 #endif
 
Index: /branches/SHM-dev/source/Lib/TLibCommon/TComPicYuv.h
===================================================================
--- /branches/SHM-dev/source/Lib/TLibCommon/TComPicYuv.h	(revision 868)
+++ /branches/SHM-dev/source/Lib/TLibCommon/TComPicYuv.h	(revision 869)
@@ -111,8 +111,16 @@
   // ------------------------------------------------------------------------------------------------
 #if SVC_EXTENSION
+#if R0156_CONF_WINDOW_IN_REP_FORMAT
+#if AUXILIARY_PICTURES
+  Void  create      ( Int iPicWidth, Int iPicHeight, ChromaFormat chromaFormatIDC, UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uiMaxCUDepth, Window* conformanceWindow = NULL);
+#else
+  Void  create      ( Int iPicWidth, Int iPicHeight, UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uiMaxCUDepth, Window* conformanceWindow = NULL);
+#endif
+#else
 #if AUXILIARY_PICTURES
   Void  create      ( Int iPicWidth, Int iPicHeight, ChromaFormat chromaFormatIDC, UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uiMaxCUDepth, TComSPS* pcSps = NULL);
 #else
   Void  create      ( Int iPicWidth, Int iPicHeight, UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uiMaxCUDepth, TComSPS* pcSps = NULL);
+#endif
 #endif
 #else
Index: /branches/SHM-dev/source/Lib/TLibCommon/TComSlice.cpp
===================================================================
--- /branches/SHM-dev/source/Lib/TLibCommon/TComSlice.cpp	(revision 868)
+++ /branches/SHM-dev/source/Lib/TLibCommon/TComSlice.cpp	(revision 869)
@@ -2316,4 +2316,45 @@
 }
 
+#if R0156_CONF_WINDOW_IN_REP_FORMAT
+Window& TComSlice::getConformanceWindow()
+{
+  TComSPS *sps = getSPS();
+  TComVPS *vps = getVPS();
+  UInt layerId = getLayerId();
+#if O0096_REP_FORMAT_INDEX
+#if R0279_REP_FORMAT_INBL
+  if ( layerId == 0 || sps->getV1CompatibleSPSFlag() == 1 )
+  {
+    if( layerId == 0 && vps->getAvcBaseLayerFlag() )
+#else
+  if ( layerId == 0 )
+  {
+    if( vps->getAvcBaseLayerFlag() )
+#endif
+    {
+      return vps->getVpsRepFormat(layerId)->getConformanceWindowVps();
+    }
+    else
+    {
+      return sps->getConformanceWindow();
+    }
+  }
+  else
+  {
+    return vps->getVpsRepFormat( vps->getVpsRepFormatIdx(sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : layerId) )->getConformanceWindowVps();
+  }
+#else
+  if( ( layerId == 0 ) || sps->getUpdateRepFormatFlag() )
+  {
+    return sps->getConformanceWindow();
+  }
+  else
+  {
+    return vps->getVpsRepFormat( vps->getVpsRepFormatIdx(layerId) )->getConformanceWindowVps();
+  }
+#endif
+}
+#endif
+
 RepFormat::RepFormat()
 #if AUXILIARY_PICTURES
@@ -2337,4 +2378,7 @@
   m_bitDepthVpsLuma             = 0;
   m_bitDepthVpsChroma           = 0;
+#if R0156_CONF_WINDOW_IN_REP_FORMAT
+  m_conformanceWindowVps.resetWindow();
+#endif
 }
 #endif
@@ -3102,4 +3146,7 @@
     m_bitDepthVpsLuma                 = other.m_bitDepthVpsLuma;
     m_bitDepthVpsChroma               = other.m_bitDepthVpsChroma;
+#if R0156_CONF_WINDOW_IN_REP_FORMAT
+    m_conformanceWindowVps            = other.m_conformanceWindowVps;
+#endif
   }
   return *this;
@@ -4077,5 +4124,5 @@
       TComPic* pcRefPicBL = m_pcBaseColPic[refLayerIdc];
 
-      // copy scalability ratio, it is needed to get the corect location for the motion field of the corresponding reference layer block
+      // copy scalability ratio, it is needed to get the correct location for the motion field of the corresponding reference layer block
       pcIlpPic[refLayerIdc]->setSpatialEnhLayerFlag( refLayerIdc, m_pcPic->isSpatialEnhLayer(refLayerIdc) );
 
Index: /branches/SHM-dev/source/Lib/TLibCommon/TComSlice.h
===================================================================
--- /branches/SHM-dev/source/Lib/TLibCommon/TComSlice.h	(revision 868)
+++ /branches/SHM-dev/source/Lib/TLibCommon/TComSlice.h	(revision 869)
@@ -403,4 +403,66 @@
 };
 
+class Window
+{
+private:
+  Bool          m_enabledFlag;
+  Int           m_winLeftOffset;
+  Int           m_winRightOffset;
+  Int           m_winTopOffset;
+  Int           m_winBottomOffset;
+#if P0312_VERT_PHASE_ADJ
+  Bool          m_vertPhasePositionEnableFlag;
+#endif
+public:
+  Window()
+  : m_enabledFlag (false)
+  , m_winLeftOffset     (0)
+  , m_winRightOffset    (0)
+  , m_winTopOffset      (0)
+  , m_winBottomOffset   (0)
+#if P0312_VERT_PHASE_ADJ
+  , m_vertPhasePositionEnableFlag(false)  
+#endif
+  { }
+
+  Bool          getWindowEnabledFlag() const      { return m_enabledFlag; }
+#if P0312_VERT_PHASE_ADJ
+  Void          resetWindow()                     { m_enabledFlag = false; m_winLeftOffset = m_winRightOffset = m_winTopOffset = m_winBottomOffset = 0; m_vertPhasePositionEnableFlag = false; } 
+#else
+  Void          resetWindow()                     { m_enabledFlag = false; m_winLeftOffset = m_winRightOffset = m_winTopOffset = m_winBottomOffset = 0;} 
+#endif
+  Int           getWindowLeftOffset() const       { return m_enabledFlag ? m_winLeftOffset : 0; }
+  Void          setWindowLeftOffset(Int val)      { if(val) {m_winLeftOffset = val; m_enabledFlag = true;} }
+  Int           getWindowRightOffset() const      { return m_enabledFlag ? m_winRightOffset : 0; }
+  Void          setWindowRightOffset(Int val)     { if(val) {m_winRightOffset = val; m_enabledFlag = true;} }
+  Int           getWindowTopOffset() const        { return m_enabledFlag ? m_winTopOffset : 0; }
+  Void          setWindowTopOffset(Int val)       { if(val) {m_winTopOffset = val; m_enabledFlag = true;} }
+  Int           getWindowBottomOffset() const     { return m_enabledFlag ? m_winBottomOffset: 0; }
+  Void          setWindowBottomOffset(Int val)    { if(val) {m_winBottomOffset = val; m_enabledFlag = true;} }
+#if P0312_VERT_PHASE_ADJ
+  Bool          getVertPhasePositionEnableFlag() const     { return m_vertPhasePositionEnableFlag;  }
+  Void          setVertPhasePositionEnableFlag(Bool val)    { m_vertPhasePositionEnableFlag = val;  }
+#endif
+
+#if P0312_VERT_PHASE_ADJ
+  Void          setWindow(Int offsetLeft, Int offsetLRight, Int offsetLTop, Int offsetLBottom, Bool vertPhasePositionEnableFlag = 0)
+#else
+  Void          setWindow(Int offsetLeft, Int offsetLRight, Int offsetLTop, Int offsetLBottom)
+#endif
+  {
+    if(offsetLeft || offsetLRight || offsetLTop || offsetLBottom) 
+    {
+      m_enabledFlag       = true;
+      m_winLeftOffset     = offsetLeft;
+      m_winRightOffset    = offsetLRight;
+      m_winTopOffset      = offsetLTop;
+      m_winBottomOffset   = offsetLBottom;
+    }
+#if P0312_VERT_PHASE_ADJ
+    m_vertPhasePositionEnableFlag = vertPhasePositionEnableFlag;    
+#endif
+  }
+};
+
 #if REPN_FORMAT_IN_VPS
 class RepFormat
@@ -420,4 +482,8 @@
   Int  m_bitDepthVpsChroma;             // coded as minus8
 
+#if R0156_CONF_WINDOW_IN_REP_FORMAT
+  Window m_conformanceWindowVps;
+#endif
+
 public:
   RepFormat();
@@ -454,4 +520,9 @@
   Int  getBitDepthVpsChroma()           { return m_bitDepthVpsChroma;   }
   Void setBitDepthVpsChroma(Int x)      { m_bitDepthVpsChroma = x;      }
+
+#if R0156_CONF_WINDOW_IN_REP_FORMAT
+  Window& getConformanceWindowVps()                           { return  m_conformanceWindowVps;             }
+  Void    setConformanceWindowVps(Window& conformanceWindow ) { m_conformanceWindowVps = conformanceWindow; }
+#endif
 };
 #endif
@@ -1246,64 +1317,4 @@
 };
 
-class Window
-{
-private:
-  Bool          m_enabledFlag;
-  Int           m_winLeftOffset;
-  Int           m_winRightOffset;
-  Int           m_winTopOffset;
-  Int           m_winBottomOffset;
-#if P0312_VERT_PHASE_ADJ
-  Bool          m_vertPhasePositionEnableFlag;
-#endif
-public:
-  Window()
-  : m_enabledFlag (false)
-  , m_winLeftOffset     (0)
-  , m_winRightOffset    (0)
-  , m_winTopOffset      (0)
-  , m_winBottomOffset   (0)
-#if P0312_VERT_PHASE_ADJ
-  , m_vertPhasePositionEnableFlag(false)  
-#endif
-  { }
-
-  Bool          getWindowEnabledFlag() const      { return m_enabledFlag; }
-#if P0312_VERT_PHASE_ADJ
-  Void          resetWindow()                     { m_enabledFlag = false; m_winLeftOffset = m_winRightOffset = m_winTopOffset = m_winBottomOffset = 0; m_vertPhasePositionEnableFlag = false; } 
-#else
-  Void          resetWindow()                     { m_enabledFlag = false; m_winLeftOffset = m_winRightOffset = m_winTopOffset = m_winBottomOffset = 0;} 
-#endif
-  Int           getWindowLeftOffset() const       { return m_enabledFlag ? m_winLeftOffset : 0; }
-  Void          setWindowLeftOffset(Int val)      { m_winLeftOffset = val; m_enabledFlag = true; }
-  Int           getWindowRightOffset() const      { return m_enabledFlag ? m_winRightOffset : 0; }
-  Void          setWindowRightOffset(Int val)     { m_winRightOffset = val; m_enabledFlag = true; }
-  Int           getWindowTopOffset() const        { return m_enabledFlag ? m_winTopOffset : 0; }
-  Void          setWindowTopOffset(Int val)       { m_winTopOffset = val; m_enabledFlag = true; }
-  Int           getWindowBottomOffset() const     { return m_enabledFlag ? m_winBottomOffset: 0; }
-  Void          setWindowBottomOffset(Int val)    { m_winBottomOffset = val; m_enabledFlag = true; }
-#if P0312_VERT_PHASE_ADJ
-  Bool          getVertPhasePositionEnableFlag() const     { return m_vertPhasePositionEnableFlag;  }
-  Void          setVertPhasePositionEnableFlag(Bool val)    { m_vertPhasePositionEnableFlag = val;  }
-#endif
-
-#if P0312_VERT_PHASE_ADJ
-  Void          setWindow(Int offsetLeft, Int offsetLRight, Int offsetLTop, Int offsetLBottom, Bool vertPhasePositionEnableFlag = 0)
-#else
-  Void          setWindow(Int offsetLeft, Int offsetLRight, Int offsetLTop, Int offsetLBottom)
-#endif
-  {
-    m_enabledFlag       = true;
-    m_winLeftOffset     = offsetLeft;
-    m_winRightOffset    = offsetLRight;
-    m_winTopOffset      = offsetLTop;
-    m_winBottomOffset   = offsetLBottom;
-#if P0312_VERT_PHASE_ADJ
-    m_vertPhasePositionEnableFlag = vertPhasePositionEnableFlag;    
-#endif
-  }
-};
-
-
 class TComVUI
 {
@@ -2571,4 +2582,8 @@
   Int  getQpBDOffsetY();
   Int  getQpBDOffsetC();
+
+#if R0156_CONF_WINDOW_IN_REP_FORMAT
+  Window& getConformanceWindow();
+#endif
 #endif
 
Index: /branches/SHM-dev/source/Lib/TLibCommon/TypeDef.h
===================================================================
--- /branches/SHM-dev/source/Lib/TLibCommon/TypeDef.h	(revision 868)
+++ /branches/SHM-dev/source/Lib/TLibCommon/TypeDef.h	(revision 869)
@@ -209,4 +209,6 @@
 #define Q0195_REP_FORMAT_CLEANUP         1      ///< JCTVC-Q0195: restructureing of rep_format() signaling
 #define REP_FORMAT_FIX                   1      ///< update_rep_format_flag should be inferred to be equal to 0
+
+#define R0156_CONF_WINDOW_IN_REP_FORMAT  O0096_REP_FORMAT_INDEX ///< JCTVC-R0156: add conformance window cropping offsets to rep_format()
 
 #define RESAMPLING_CONSTRAINT_BUG_FIX    1
Index: /branches/SHM-dev/source/Lib/TLibDecoder/TDecCAVLC.cpp
===================================================================
--- /branches/SHM-dev/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 868)
+++ /branches/SHM-dev/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 869)
@@ -729,20 +729,37 @@
 #endif
 #endif
-  READ_FLAG(     uiCode, "conformance_window_flag");
-  if (uiCode != 0)
-  {
-    Window &conf = pcSPS->getConformanceWindow();
+
+#if R0156_CONF_WINDOW_IN_REP_FORMAT
 #if REPN_FORMAT_IN_VPS
-    READ_UVLC(   uiCode, "conf_win_left_offset" );               conf.setWindowLeftOffset  ( uiCode );
-    READ_UVLC(   uiCode, "conf_win_right_offset" );              conf.setWindowRightOffset ( uiCode );
-    READ_UVLC(   uiCode, "conf_win_top_offset" );                conf.setWindowTopOffset   ( uiCode );
-    READ_UVLC(   uiCode, "conf_win_bottom_offset" );             conf.setWindowBottomOffset( uiCode );
-#else
-    READ_UVLC(   uiCode, "conf_win_left_offset" );               conf.setWindowLeftOffset  ( uiCode * TComSPS::getWinUnitX( pcSPS->getChromaFormatIdc() ) );
-    READ_UVLC(   uiCode, "conf_win_right_offset" );              conf.setWindowRightOffset ( uiCode * TComSPS::getWinUnitX( pcSPS->getChromaFormatIdc() ) );
-    READ_UVLC(   uiCode, "conf_win_top_offset" );                conf.setWindowTopOffset   ( uiCode * TComSPS::getWinUnitY( pcSPS->getChromaFormatIdc() ) );
-    READ_UVLC(   uiCode, "conf_win_bottom_offset" );             conf.setWindowBottomOffset( uiCode * TComSPS::getWinUnitY( pcSPS->getChromaFormatIdc() ) );
-#endif
-  }
+#if O0096_REP_FORMAT_INDEX
+  if( pcSPS->getLayerId() == 0 )
+#else
+  if(  pcSPS->getLayerId() == 0 || pcSPS->getUpdateRepFormatFlag() )
+#endif
+  {
+#endif
+#endif
+    READ_FLAG(     uiCode, "conformance_window_flag");
+    if (uiCode != 0)
+    {
+      Window &conf = pcSPS->getConformanceWindow();
+#if REPN_FORMAT_IN_VPS
+      READ_UVLC(   uiCode, "conf_win_left_offset" );               conf.setWindowLeftOffset  ( uiCode );
+      READ_UVLC(   uiCode, "conf_win_right_offset" );              conf.setWindowRightOffset ( uiCode );
+      READ_UVLC(   uiCode, "conf_win_top_offset" );                conf.setWindowTopOffset   ( uiCode );
+      READ_UVLC(   uiCode, "conf_win_bottom_offset" );             conf.setWindowBottomOffset( uiCode );
+#else
+      READ_UVLC(   uiCode, "conf_win_left_offset" );               conf.setWindowLeftOffset  ( uiCode * TComSPS::getWinUnitX( pcSPS->getChromaFormatIdc() ) );
+      READ_UVLC(   uiCode, "conf_win_right_offset" );              conf.setWindowRightOffset ( uiCode * TComSPS::getWinUnitX( pcSPS->getChromaFormatIdc() ) );
+      READ_UVLC(   uiCode, "conf_win_top_offset" );                conf.setWindowTopOffset   ( uiCode * TComSPS::getWinUnitY( pcSPS->getChromaFormatIdc() ) );
+      READ_UVLC(   uiCode, "conf_win_bottom_offset" );             conf.setWindowBottomOffset( uiCode * TComSPS::getWinUnitY( pcSPS->getChromaFormatIdc() ) );
+#endif
+    }
+#if R0156_CONF_WINDOW_IN_REP_FORMAT
+#if REPN_FORMAT_IN_VPS
+  }
+#endif
+#endif
+
 #if REPN_FORMAT_IN_VPS
 #if O0096_REP_FORMAT_INDEX
@@ -2069,4 +2086,5 @@
     repFormat->setBitDepthVpsChroma         ( repFormatPrev->getBitDepthVpsChroma() );
   }
+
 #else 
 #if AUXILIARY_PICTURES
@@ -2087,4 +2105,16 @@
   READ_CODE( 4, uiCode, "bit_depth_chroma_minus8" );         repFormat->setBitDepthVpsChroma( uiCode + 8 );
 #endif 
+
+#if R0156_CONF_WINDOW_IN_REP_FORMAT
+  READ_FLAG( uiCode, "conformance_window_vps_flag" );
+  if( uiCode != 0) 
+  {
+    Window &conf = repFormat->getConformanceWindowVps();
+    READ_UVLC( uiCode, "conf_win_vps_left_offset" );         conf.setWindowLeftOffset  ( uiCode );
+    READ_UVLC( uiCode, "conf_win_vps_right_offset" );        conf.setWindowRightOffset ( uiCode );
+    READ_UVLC( uiCode, "conf_win_vps_top_offset" );          conf.setWindowTopOffset   ( uiCode );
+    READ_UVLC( uiCode, "conf_win_vps_bottom_offset" );       conf.setWindowBottomOffset( uiCode );
+  }
+#endif
 }
 #endif
Index: /branches/SHM-dev/source/Lib/TLibDecoder/TDecTop.cpp
===================================================================
--- /branches/SHM-dev/source/Lib/TLibDecoder/TDecTop.cpp	(revision 868)
+++ /branches/SHM-dev/source/Lib/TLibDecoder/TDecTop.cpp	(revision 869)
@@ -214,5 +214,9 @@
 
     Int  numReorderPics[MAX_TLAYER];
+#if R0156_CONF_WINDOW_IN_REP_FORMAT
+    Window &conformanceWindow = slice->getConformanceWindow();
+#else
     Window &conformanceWindow = pcSPS->getConformanceWindow();
+#endif
     Window defaultDisplayWindow = pcSPS->getVuiParametersPresentFlag() ? pcSPS->getVuiParameters()->getDefaultDisplayWindow() : Window();
 
@@ -303,5 +307,9 @@
 {
   Int  numReorderPics[MAX_TLAYER];
+#if R0156_CONF_WINDOW_IN_REP_FORMAT
+  Window &conformanceWindow = pcSlice->getConformanceWindow();
+#else
   Window &conformanceWindow = pcSlice->getSPS()->getConformanceWindow();
+#endif
   Window defaultDisplayWindow = pcSlice->getSPS()->getVuiParametersPresentFlag() ? pcSlice->getSPS()->getVuiParameters()->getDefaultDisplayWindow() : Window();
 
@@ -765,11 +773,21 @@
 
       Int  numReorderPics[MAX_TLAYER];
+#if !R0156_CONF_WINDOW_IN_REP_FORMAT
       Window conformanceWindow;
+#endif
       Window defaultDisplayWindow;
 
+#if R0156_CONF_WINDOW_IN_REP_FORMAT
+#if AUXILIARY_PICTURES
+      pBLPic->create( repFormat->getPicWidthVpsInLumaSamples(), repFormat->getPicHeightVpsInLumaSamples(), repFormat->getChromaFormatVpsIdc(), activeSPS->getMaxCUWidth(), activeSPS->getMaxCUHeight(), activeSPS->getMaxCUDepth(), repFormat->getConformanceWindowVps(), defaultDisplayWindow, numReorderPics, NULL, true);
+#else
+      pBLPic->create( repFormat->getPicWidthVpsInLumaSamples(), repFormat->getPicHeightVpsInLumaSamples(), activeSPS->getMaxCUWidth(), activeSPS->getMaxCUHeight(), activeSPS->getMaxCUDepth(), repFormat->getConformanceWindowVps(), defaultDisplayWindow, numReorderPics, NULL, true);
+#endif
+#else
 #if AUXILIARY_PICTURES
       pBLPic->create( repFormat->getPicWidthVpsInLumaSamples(), repFormat->getPicHeightVpsInLumaSamples(), repFormat->getChromaFormatVpsIdc(), activeSPS->getMaxCUWidth(), activeSPS->getMaxCUHeight(), activeSPS->getMaxCUDepth(), conformanceWindow, defaultDisplayWindow, numReorderPics, NULL, true);
 #else
       pBLPic->create( repFormat->getPicWidthVpsInLumaSamples(), repFormat->getPicHeightVpsInLumaSamples(), activeSPS->getMaxCUWidth(), activeSPS->getMaxCUHeight(), activeSPS->getMaxCUDepth(), conformanceWindow, defaultDisplayWindow, numReorderPics, NULL, true);
+#endif
 #endif
       // it is needed where the VPS is accessed through the slice
Index: /branches/SHM-dev/source/Lib/TLibEncoder/TEncCavlc.cpp
===================================================================
--- /branches/SHM-dev/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 868)
+++ /branches/SHM-dev/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 869)
@@ -555,21 +555,37 @@
 #endif
 #endif
-  Window conf = pcSPS->getConformanceWindow();
-
-  WRITE_FLAG( conf.getWindowEnabledFlag(),          "conformance_window_flag" );
-  if (conf.getWindowEnabledFlag())
-  {
+
+#if R0156_CONF_WINDOW_IN_REP_FORMAT
 #if REPN_FORMAT_IN_VPS
-    WRITE_UVLC( conf.getWindowLeftOffset(),   "conf_win_left_offset"   );
-    WRITE_UVLC( conf.getWindowRightOffset(),  "conf_win_right_offset"  );
-    WRITE_UVLC( conf.getWindowTopOffset(),    "conf_win_top_offset"    );
-    WRITE_UVLC( conf.getWindowBottomOffset(), "conf_win_bottom_offset" );
-#else
-    WRITE_UVLC( conf.getWindowLeftOffset()   / TComSPS::getWinUnitX(pcSPS->getChromaFormatIdc() ), "conf_win_left_offset" );
-    WRITE_UVLC( conf.getWindowRightOffset()  / TComSPS::getWinUnitX(pcSPS->getChromaFormatIdc() ), "conf_win_right_offset" );
-    WRITE_UVLC( conf.getWindowTopOffset()    / TComSPS::getWinUnitY(pcSPS->getChromaFormatIdc() ), "conf_win_top_offset" );
-    WRITE_UVLC( conf.getWindowBottomOffset() / TComSPS::getWinUnitY(pcSPS->getChromaFormatIdc() ), "conf_win_bottom_offset" );
-#endif
-  }
+#if O0096_REP_FORMAT_INDEX
+  if( pcSPS->getLayerId() == 0 ) 
+#else
+  if( pcSPS->getLayerId() == 0 || pcSPS->getUpdateRepFormatFlag() ) 
+#endif  
+  {
+#endif
+#endif
+    Window conf = pcSPS->getConformanceWindow();
+
+    WRITE_FLAG( conf.getWindowEnabledFlag(),          "conformance_window_flag" );
+    if (conf.getWindowEnabledFlag())
+    {
+#if REPN_FORMAT_IN_VPS
+      WRITE_UVLC( conf.getWindowLeftOffset(),   "conf_win_left_offset"   );
+      WRITE_UVLC( conf.getWindowRightOffset(),  "conf_win_right_offset"  );
+      WRITE_UVLC( conf.getWindowTopOffset(),    "conf_win_top_offset"    );
+      WRITE_UVLC( conf.getWindowBottomOffset(), "conf_win_bottom_offset" );
+#else
+      WRITE_UVLC( conf.getWindowLeftOffset()   / TComSPS::getWinUnitX(pcSPS->getChromaFormatIdc() ), "conf_win_left_offset" );
+      WRITE_UVLC( conf.getWindowRightOffset()  / TComSPS::getWinUnitX(pcSPS->getChromaFormatIdc() ), "conf_win_right_offset" );
+      WRITE_UVLC( conf.getWindowTopOffset()    / TComSPS::getWinUnitY(pcSPS->getChromaFormatIdc() ), "conf_win_top_offset" );
+      WRITE_UVLC( conf.getWindowBottomOffset() / TComSPS::getWinUnitY(pcSPS->getChromaFormatIdc() ), "conf_win_bottom_offset" );
+#endif
+    }
+#if R0156_CONF_WINDOW_IN_REP_FORMAT
+#if REPN_FORMAT_IN_VPS
+  }
+#endif
+#endif
 
 #if REPN_FORMAT_IN_VPS
@@ -1471,4 +1487,17 @@
   WRITE_CODE( repFormat->getBitDepthVpsLuma() - 8,   4, "bit_depth_luma_minus8" );           
   WRITE_CODE( repFormat->getBitDepthVpsChroma() - 8, 4, "bit_depth_chroma_minus8" );
+#endif
+
+#if R0156_CONF_WINDOW_IN_REP_FORMAT
+  Window conf = repFormat->getConformanceWindowVps();
+
+  WRITE_FLAG( conf.getWindowEnabledFlag(),    "conformance_window_vps_flag" );
+  if (conf.getWindowEnabledFlag())
+  {
+    WRITE_UVLC( conf.getWindowLeftOffset(),   "conf_win_vps_left_offset"   );
+    WRITE_UVLC( conf.getWindowRightOffset(),  "conf_win_vps_right_offset"  );
+    WRITE_UVLC( conf.getWindowTopOffset(),    "conf_win_vps_top_offset"    );
+    WRITE_UVLC( conf.getWindowBottomOffset(), "conf_win_vps_bottom_offset" );
+  }
 #endif
 }
Index: /branches/SHM-dev/source/Lib/TLibEncoder/TEncTop.cpp
===================================================================
--- /branches/SHM-dev/source/Lib/TLibEncoder/TEncTop.cpp	(revision 868)
+++ /branches/SHM-dev/source/Lib/TLibEncoder/TEncTop.cpp	(revision 869)
@@ -1698,5 +1698,9 @@
 
     Int  numReorderPics[MAX_TLAYER];
+#if R0156_CONF_WINDOW_IN_REP_FORMAT
+    Window &conformanceWindow = repFormat->getConformanceWindowVps();
+#else
     Window &conformanceWindow = m_cSPS.getConformanceWindow();
+#endif
     Window defaultDisplayWindow = m_cSPS.getVuiParametersPresentFlag() ? m_cSPS.getVuiParameters()->getDefaultDisplayWindow() : Window();
 
