Index: branches/SHM-4.0-dev/source/Lib/TLibCommon/TComDataCU.cpp
===================================================================
--- branches/SHM-4.0-dev/source/Lib/TLibCommon/TComDataCU.cpp	(revision 444)
+++ branches/SHM-4.0-dev/source/Lib/TLibCommon/TComDataCU.cpp	(revision 445)
@@ -4004,5 +4004,7 @@
   uiPelY = (UInt)Clip3<UInt>(0, m_pcPic->getPicYuvRec()->getHeight() - 1, uiPelY);
 
+#if !LAYER_CTB
   UInt uiMinUnitSize = m_pcPic->getMinCUWidth();
+#endif
 
 #if SCALED_REF_LAYER_OFFSETS
@@ -4034,12 +4036,26 @@
   }
 
+#if LAYER_CTB
+  UInt baseMaxCUHeight = cBaseColPic->getPicSym()->getMaxCUHeight();
+  UInt baseMaxCUWidth  = cBaseColPic->getPicSym()->getMaxCUWidth();
+  UInt baseMinUnitSize = cBaseColPic->getMinCUWidth();
+  
+  uiCUAddrBase = ( iBY / cBaseColPic->getPicSym()->getMaxCUHeight() ) * cBaseColPic->getFrameWidthInCU() + ( iBX / cBaseColPic->getPicSym()->getMaxCUWidth() );
+#else
   uiCUAddrBase = (iBY/g_uiMaxCUHeight)*cBaseColPic->getFrameWidthInCU() + (iBX/g_uiMaxCUWidth);
+#endif
 
   assert(uiCUAddrBase < cBaseColPic->getNumCUsInFrame());
 
+#if LAYER_CTB
+  UInt uiRasterAddrBase = ( iBY - (iBY/baseMaxCUHeight)*baseMaxCUHeight ) / baseMinUnitSize * cBaseColPic->getNumPartInWidth() + ( iBX - (iBX/baseMaxCUWidth)*baseMaxCUWidth ) / baseMinUnitSize;
+  
+  uiAbsPartIdxBase = g_auiLayerRasterToZscan[cBaseColPic->getLayerId()][uiRasterAddrBase];
+#else
   UInt uiRasterAddrBase = (iBY - (iBY/g_uiMaxCUHeight)*g_uiMaxCUHeight)/uiMinUnitSize*cBaseColPic->getNumPartInWidth()
     + (iBX - (iBX/g_uiMaxCUWidth)*g_uiMaxCUWidth)/uiMinUnitSize;
 
   uiAbsPartIdxBase = g_auiRasterToZscan[uiRasterAddrBase];
+#endif
 
   return cBaseColPic->getCU(uiCUAddrBase);
Index: branches/SHM-4.0-dev/source/Lib/TLibCommon/TComPicSym.h
===================================================================
--- branches/SHM-4.0-dev/source/Lib/TLibCommon/TComPicSym.h	(revision 444)
+++ branches/SHM-4.0-dev/source/Lib/TLibCommon/TComPicSym.h	(revision 445)
@@ -126,4 +126,9 @@
   TComDataCU*&  getCU( UInt uiCUAddr )  { return m_apcTComDataCU[uiCUAddr];     }
   
+#if LAYER_CTB
+  UInt        getMaxCUWidth()           { return m_uiMaxCUWidth;                }
+  UInt        getMaxCUHeight()          { return m_uiMaxCUHeight;               }
+#endif
+
 #if AVC_SYNTAX
   UInt        getMaxCUWidth()           { return m_uiMaxCUWidth;                }
Index: branches/SHM-4.0-dev/source/Lib/TLibCommon/TComPicYuv.cpp
===================================================================
--- branches/SHM-4.0-dev/source/Lib/TLibCommon/TComPicYuv.cpp	(revision 444)
+++ branches/SHM-4.0-dev/source/Lib/TLibCommon/TComPicYuv.cpp	(revision 445)
@@ -90,6 +90,11 @@
   Int numCuInHeight = m_iPicHeight / m_iCuHeight + (m_iPicHeight % m_iCuHeight != 0);
   
+#if LAYER_CTB
+  m_iLumaMarginX    = uiMaxCUWidth  + 16; // for 16-byte alignment
+  m_iLumaMarginY    = uiMaxCUHeight + 16;  // margin for 8-tap filter and infinite padding
+#else
   m_iLumaMarginX    = g_uiMaxCUWidth  + 16; // for 16-byte alignment
   m_iLumaMarginY    = g_uiMaxCUHeight + 16;  // margin for 8-tap filter and infinite padding
+#endif
   
   m_iChromaMarginX  = m_iLumaMarginX>>1;
Index: branches/SHM-4.0-dev/source/Lib/TLibCommon/TComRom.cpp
===================================================================
--- branches/SHM-4.0-dev/source/Lib/TLibCommon/TComRom.cpp	(revision 444)
+++ branches/SHM-4.0-dev/source/Lib/TLibCommon/TComRom.cpp	(revision 445)
@@ -86,5 +86,14 @@
 // Data structure related table & variable
 // ====================================================================================================================
-
+#if LAYER_CTB
+UInt g_auiLayerMaxCUWidth[MAX_LAYERS];
+UInt g_auiLayerMaxCUHeight[MAX_LAYERS];
+UInt g_auiLayerMaxCUDepth[MAX_LAYERS];
+UInt g_auiLayerAddCUDepth[MAX_LAYERS];
+UInt g_auiLayerZscanToRaster[MAX_LAYERS][ MAX_NUM_SPU_W*MAX_NUM_SPU_W ];
+UInt g_auiLayerRasterToZscan[MAX_LAYERS][ MAX_NUM_SPU_W*MAX_NUM_SPU_W ];
+UInt g_auiLayerRasterToPelX[MAX_LAYERS][ MAX_NUM_SPU_W*MAX_NUM_SPU_W ];
+UInt g_auiLayerRasterToPelY[MAX_LAYERS][ MAX_NUM_SPU_W*MAX_NUM_SPU_W ];
+#endif
 UInt g_uiMaxCUWidth  = MAX_CU_SIZE;
 UInt g_uiMaxCUHeight = MAX_CU_SIZE;
Index: branches/SHM-4.0-dev/source/Lib/TLibCommon/TComRom.h
===================================================================
--- branches/SHM-4.0-dev/source/Lib/TLibCommon/TComRom.h	(revision 444)
+++ branches/SHM-4.0-dev/source/Lib/TLibCommon/TComRom.h	(revision 445)
@@ -81,4 +81,14 @@
 
 // global variable (LCU width/height, max. CU depth)
+#if LAYER_CTB
+extern       UInt g_auiLayerMaxCUWidth[MAX_LAYERS];
+extern       UInt g_auiLayerMaxCUHeight[MAX_LAYERS];
+extern       UInt g_auiLayerMaxCUDepth[MAX_LAYERS];
+extern       UInt g_auiLayerAddCUDepth[MAX_LAYERS];
+extern       UInt g_auiLayerZscanToRaster[MAX_LAYERS][ MAX_NUM_SPU_W*MAX_NUM_SPU_W ];
+extern       UInt g_auiLayerRasterToZscan[MAX_LAYERS][ MAX_NUM_SPU_W*MAX_NUM_SPU_W ];
+extern       UInt g_auiLayerRasterToPelX[MAX_LAYERS][ MAX_NUM_SPU_W*MAX_NUM_SPU_W ];
+extern       UInt g_auiLayerRasterToPelY[MAX_LAYERS][ MAX_NUM_SPU_W*MAX_NUM_SPU_W ];
+#endif
 extern       UInt g_uiMaxCUWidth;
 extern       UInt g_uiMaxCUHeight;
Index: branches/SHM-4.0-dev/source/Lib/TLibCommon/TypeDef.h
===================================================================
--- branches/SHM-4.0-dev/source/Lib/TLibCommon/TypeDef.h	(revision 444)
+++ branches/SHM-4.0-dev/source/Lib/TLibCommon/TypeDef.h	(revision 445)
@@ -64,4 +64,5 @@
 #define VERT_MV_CONSTRAINT               1      ///< Vertical MV component constraint flag
 #define SCALABILITY_MASK_E0104           1      ///< JCT3V-E0104: scalability mask for depth
+#define LAYER_CTB                        0      ///< enable layer-specific CTB structure
 
 #define ILP_SSH_SIG                      1      ///< JCTVC-N0195 proposal 2, JCTVC-N0118: add presence flag in VPS ext to condition inter-layer prediction signaling in slice segment header
Index: branches/SHM-4.0-dev/source/Lib/TLibEncoder/TEncTop.cpp
===================================================================
--- branches/SHM-4.0-dev/source/Lib/TLibEncoder/TEncTop.cpp	(revision 444)
+++ branches/SHM-4.0-dev/source/Lib/TLibEncoder/TEncTop.cpp	(revision 445)
@@ -175,4 +175,11 @@
     }
   }
+
+#if LAYER_CTB
+  memcpy(g_auiLayerZscanToRaster[m_layerId], g_auiZscanToRaster, sizeof( g_auiZscanToRaster ) );
+  memcpy(g_auiLayerRasterToZscan[m_layerId], g_auiRasterToZscan, sizeof( g_auiRasterToZscan ) );
+  memcpy(g_auiLayerRasterToPelX[m_layerId],  g_auiRasterToPelX,  sizeof( g_auiRasterToPelX ) );
+  memcpy(g_auiLayerRasterToPelY[m_layerId],  g_auiRasterToPelY,  sizeof( g_auiRasterToPelY ) );
+#endif
 }
 
