Index: branches/0.2-HHI/source/Lib/TLibCommon/CommonDef.h
===================================================================
--- branches/0.2-HHI/source/Lib/TLibCommon/CommonDef.h	(revision 16)
+++ branches/0.2-HHI/source/Lib/TLibCommon/CommonDef.h	(revision 20)
@@ -58,5 +58,5 @@
 
 #define HM_VERSION        "3.0rc2"                 ///< Current software version
-#define NV_VERSION        "0.2"                   ///< Current software version
+#define NV_VERSION        "0.2r1-HHI"              ///< Current software version
 
 // ====================================================================================================================
@@ -145,7 +145,6 @@
 
 //>>>>> generation and usage of virtual prediction depth maps >>>>>
-#define PDM_DEPTH_MAP_MCP_FILTER          2         // 0: standard filter, 1:bilinear, 2:nearest neighbour
 #define PDM_ONE_DEPTH_PER_PU              1         // use only a single depth for a prediction unit (in update)
-#define PDM_NO_INTER_UPDATE               0         // no update for inter (but not inter-view) predicted blocks
+#define PDM_NO_INTER_UPDATE               1         // no update for inter (but not inter-view) predicted blocks
 #define PDM_MERGE_POS                     0         // position of pdm in merge list (0..5)
 #define PDM_AMVP_POS                      2         // position of pdm in amvp list  (0..3)
@@ -167,4 +166,8 @@
 #define PDM_USE_FOR_INTER                 2
 #define PDM_USE_FOR_MERGE                 4
+
+#define PDM_SUBSAMPLING_EXP               2         // subsampling factor is 2^PDM_SUBSAMPLING_EXP 
+#define PDM_SUB_SAMP_EXP_X(Pdm)           ((Pdm)==1?PDM_SUBSAMPLING_EXP:0)
+#define PDM_SUB_SAMP_EXP_Y(Pdm)           ((Pdm)==1?PDM_SUBSAMPLING_EXP:0)
 //<<<<< generation and usage of virtual prediction depth maps <<<<<
 
Index: branches/0.2-HHI/source/Lib/TLibCommon/TComDataCU.cpp
===================================================================
--- branches/0.2-HHI/source/Lib/TLibCommon/TComDataCU.cpp	(revision 16)
+++ branches/0.2-HHI/source/Lib/TLibCommon/TComDataCU.cpp	(revision 20)
@@ -4213,13 +4213,22 @@
   RefPicList  eColRefPicList;
   Int iColPOC, iColRefPOC, iCurrPOC, iCurrRefPOC, iScale;
+#if SONY_COLPIC_AVAILABILITY
+	Int iColViewOrderIdx, iColRefViewOrderIdx, iCurrViewOrderIdx, iCurrRefViewOrderIdx;
+#endif
   TComMv cColMv;
 
   iCurrPOC = m_pcSlice->getPOC();    
   iCurrRefPOC = m_pcSlice->getRefPic(eRefPicList, riRefIdx)->getPOC();
-
+#if SONY_COLPIC_AVAILABILITY
+	iCurrViewOrderIdx    = m_pcSlice->getViewOrderIdx();
+	iCurrRefViewOrderIdx = m_pcSlice->getRefPic(eRefPicList, riRefIdx)->getViewOrderIdx();
+#endif
   // use coldir.
   TComPic *pColPic = getSlice()->getRefPic( RefPicList(getSlice()->isInterB() ? getSlice()->getColDir() : 0), 0);
   TComDataCU *pColCU = pColPic->getCU( uiCUAddr );
   iColPOC = pColCU->getSlice()->getPOC();  
+#if SONY_COLPIC_AVAILABILITY
+	iColViewOrderIdx = pColCU->getSlice()->getViewOrderIdx();
+#endif
 
   if (pColCU->isIntra(uiAbsPartAddr))
@@ -4227,7 +4236,8 @@
     return false;
   }
-
+#if !SONY_COLPIC_AVAILABILITY
   if( m_pcSlice->getRefPic(eRefPicList, riRefIdx)->getViewIdx() != m_pcSlice->getViewIdx() )
     return false;
+#endif
 
   // Prefer a vector crossing us.  Prefer shortest.
@@ -4245,8 +4255,24 @@
     }
     iColRefPOC = pColCU->getSlice()->getRefPOC(RefPicList(l), iColRefIdx);
+#if SONY_COLPIC_AVAILABILITY
+		iColRefViewOrderIdx = pColCU->getSlice()->getRefPic(RefPicList(l), iColRefIdx)->getViewOrderIdx();
+		bool bCrosses;
+		int iColDist;
+		if((iColPOC != iColRefPOC)&&(iCurrPOC != iCurrRefPOC)){
+			iColDist = abs(iColRefPOC - iColPOC);
+			bCrosses = iColPOC < iCurrPOC ? iColRefPOC > iCurrPOC : iColRefPOC < iCurrPOC;
+		}else if((iColPOC == iColRefPOC)&&(iCurrPOC == iCurrRefPOC)){
+			iColDist = abs(iColRefViewOrderIdx - iColViewOrderIdx);
+			bCrosses = iColViewOrderIdx < iCurrViewOrderIdx ? iColRefViewOrderIdx > iCurrViewOrderIdx : iColRefViewOrderIdx < iCurrViewOrderIdx;
+		}else{
+		  continue;
+		}
+#else
     if( pColCU->getSlice()->getRefViewIdx(RefPicList(l), iColRefIdx) != pColCU->getSlice()->getViewIdx() )
       continue;
     int iColDist = abs(iColRefPOC - iColPOC);
     bool bCrosses = iColPOC < iCurrPOC ? iColRefPOC > iCurrPOC : iColRefPOC < iCurrPOC;
+#endif
+
     if (iFirstColDist < 0)
     {
@@ -4277,7 +4303,19 @@
   iColRefPOC = pColCU->getSlice()->getRefPOC(eColRefPicList, pColCU->getCUMvField(eColRefPicList)->getRefIdx(uiAbsPartAddr));
   cColMv = pColCU->getCUMvField(eColRefPicList)->getMv(uiAbsPartAddr);
+#if SONY_COLPIC_AVAILABILITY
+	iColRefViewOrderIdx = pColCU->getSlice()->getRefPic( eColRefPicList, pColCU->getCUMvField(eColRefPicList)->getRefIdx(uiAbsPartAddr))->getViewOrderIdx();
+#endif
 
   iCurrRefPOC = m_pcSlice->getRefPic(eRefPicList, riRefIdx)->getPOC();
+#if SONY_COLPIC_AVAILABILITY
+	iScale = 0;
+	iCurrRefViewOrderIdx = m_pcSlice->getRefPic(eRefPicList, riRefIdx)->getViewOrderIdx();
+	if((iColPOC != iColRefPOC)&&(iCurrPOC != iCurrRefPOC))
   iScale = xGetDistScaleFactor(iCurrPOC, iCurrRefPOC, iColPOC, iColRefPOC);
+	else if((iColPOC == iColRefPOC)&&(iCurrPOC == iCurrRefPOC))
+		iScale = xGetDistScaleFactor(iCurrViewOrderIdx, iCurrRefViewOrderIdx, iColViewOrderIdx, iColRefViewOrderIdx);
+#else
+  iScale = xGetDistScaleFactor(iCurrPOC, iCurrRefPOC, iColPOC, iColRefPOC);
+#endif
   if (iScale == 1024)
   {
Index: branches/0.2-HHI/source/Lib/TLibCommon/TComDepthMapGenerator.cpp
===================================================================
--- branches/0.2-HHI/source/Lib/TLibCommon/TComDepthMapGenerator.cpp	(revision 16)
+++ branches/0.2-HHI/source/Lib/TLibCommon/TComDepthMapGenerator.cpp	(revision 20)
@@ -57,4 +57,6 @@
   m_uiMaxDepth          = 0;
   m_uiOrgDepthBitDepth  = 0;
+  m_uiSubSampExpX       = 0;
+  m_uiSubSampExpY       = 0;
   m_ppcYuv              = 0;
   m_ppcCU               = 0;
@@ -68,5 +70,5 @@
 
 Void
-TComDepthMapGenerator::create( Bool bDecoder, UInt uiPicWidth, UInt uiPicHeight, UInt uiMaxCUDepth, UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uiOrgBitDepth )
+TComDepthMapGenerator::create( Bool bDecoder, UInt uiPicWidth, UInt uiPicHeight, UInt uiMaxCUDepth, UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uiOrgBitDepth, UInt uiSubSampExpX, UInt uiSubSampExpY )
 {
   destroy();
@@ -74,4 +76,6 @@
   m_uiMaxDepth          = uiMaxCUDepth;
   m_uiOrgDepthBitDepth  = uiOrgBitDepth;
+  m_uiSubSampExpX       = uiSubSampExpX;
+  m_uiSubSampExpY       = uiSubSampExpY;
   m_ppcYuv              = new TComYuv*    [ m_uiMaxDepth ];
   m_ppcCU               = new TComDataCU* [ m_uiMaxDepth ];
@@ -82,8 +86,8 @@
     UInt  uiHeight  = uiMaxCUHeight >> uiDepth;
 
-    m_ppcYuv[ uiDepth ] = new TComYuv;    m_ppcYuv[ uiDepth ]->create(            uiWidth, uiHeight       );
+    m_ppcYuv[ uiDepth ] = new TComYuv;    m_ppcYuv[ uiDepth ]->create( uiWidth >> m_uiSubSampExpX, uiHeight >> m_uiSubSampExpY );
     m_ppcCU [ uiDepth ] = new TComDataCU; m_ppcCU [ uiDepth ]->create( uiNumPart, uiWidth, uiHeight, true );
   }
-  m_cTmpPic.create( uiPicWidth, uiPicHeight, uiMaxCUWidth, uiMaxCUHeight, uiMaxCUDepth );
+  m_cTmpPic.create( uiPicWidth >> m_uiSubSampExpX, uiPicHeight >> m_uiSubSampExpY, uiMaxCUWidth >> m_uiSubSampExpX, uiMaxCUHeight >> m_uiSubSampExpY, uiMaxCUDepth );
   xSetChroma( &m_cTmpPic, ( 1 << uiOrgBitDepth ) >> 1 );
   m_bCreated    = true;
@@ -106,4 +110,6 @@
     m_uiMaxDepth          = 0;
     m_uiOrgDepthBitDepth  = 0;
+    m_uiSubSampExpX       = 0;
+    m_uiSubSampExpY       = 0;
     m_bDecoder            = false;
   }
@@ -372,4 +378,6 @@
       if( pcBasePic->getPOC() == 0 )
       {
+        pcBasePic->removePrdDepthMapBuffer();
+        pcBasePic->addPrdDepthMapBuffer( PDM_SUB_SAMP_EXP_X(m_pcSPSAccess->getPdm()), PDM_SUB_SAMP_EXP_Y(m_pcSPSAccess->getPdm()) );
         xClearDepthMap( pcBasePic );
       }
@@ -643,9 +651,11 @@
     TComPicYuv* pcBaseRec   = pcBasePic->getPicYuvRec   ();
     Int         iDisparity  = xGetDisparityFromVirtDepth( uiBaseId, iPrdDepth );
-    Int         iBasePosX   = Clip3( 0, pcBasePdm->getWidth () - 1, iCurrPosX + ( ( iDisparity + 2 ) >> 2 ) );
+    Int         iShiftX     = m_uiSubSampExpX + 2;
+    Int         iAddX       = ( 1 << iShiftX ) >> 1;
+    Int         iBasePosX   = Clip3( 0, pcBasePdm->getWidth () - 1, iCurrPosX + ( ( iDisparity + iAddX ) >> iShiftX ) );
     Int         iBasePosY   = Clip3( 0, pcBasePdm->getHeight() - 1, iCurrPosY                               );
     Int         iBaseCUAddr;
     Int         iBaseAbsPartIdx;
-    pcBaseRec->getCUAddrAndPartIdx( iBasePosX, iBasePosY, iBaseCUAddr, iBaseAbsPartIdx );
+    pcBaseRec->getCUAddrAndPartIdx( iBasePosX << m_uiSubSampExpX, iBasePosY << m_uiSubSampExpY, iBaseCUAddr, iBaseAbsPartIdx );
     TComDataCU* pcBaseCU    = pcBasePic->getCU( iBaseCUAddr );
     if( pcBaseCU->getPredictionMode( iBaseAbsPartIdx ) != MODE_INTER && pcBaseCU->getPredictionMode( iBaseAbsPartIdx ) != MODE_SKIP )
@@ -744,4 +754,6 @@
   Pel*        pRefSamples   =  pcRefDepthMap->getLumaAddr( 0 );
   Int         iRefViewIdx   =  pcRef->getViewIdx();
+  Int         iShiftX       = m_uiSubSampExpX + 2;
+  Int         iAddX         = ( 1 << iShiftX ) >> 1;
   for( Int iY = 0; iY < iHeight; iY++, pCurSamples += iCurStride, pRefSamples += iRefStride )
   {
@@ -750,5 +762,5 @@
       Int iDepth = pCurSamples[ iXCur ];
       Int iDisp  = xGetDisparityFromVirtDepth( iRefViewIdx, iDepth );
-      Int iXRef  = iXCur + ( ( iDisp + 2 ) >> 2 );
+      Int iXRef  = iXCur + ( ( iDisp + iAddX ) >> iShiftX );
       if( iXRef >= 0 && iXRef < iWidth && iDepth > pRefSamples[ iXRef ] )
       {
@@ -784,4 +796,6 @@
   Pel*        pCurSamples   =  pcCurDepthMap->getLumaAddr( 0 );
   Int         iRefViewIdx   =  pcRef->getViewIdx();
+  Int         iShiftX       = m_uiSubSampExpX + 2;
+  Int         iAddX         = ( 1 << iShiftX ) >> 1;
   for( Int iY = 0; iY < iHeight; iY++, pRefSamples += iRefStride, pCurSamples += iCurStride )
   {
@@ -790,5 +804,5 @@
       Int iDepth = pRefSamples[ iXRef ];
       Int iDisp  = xGetDisparityFromVirtDepth( iRefViewIdx, iDepth );
-      Int iXCur  = iXRef - ( ( iDisp + 2 ) >> 2 );
+      Int iXCur  = iXRef - ( ( iDisp + iAddX ) >> iShiftX );
       if( iXCur >= 0 && iXCur < iWidth && iDepth > pCurSamples[ iXCur ] )
       {
@@ -1022,8 +1036,10 @@
   if( uiTrMode == uiTrDepth )
   {
-    UInt  uiWidth         = pcCU->getWidth ( 0 ) >> uiTrDepth;
-    UInt  uiHeight        = pcCU->getHeight( 0 ) >> uiTrDepth;
+    UInt  uiWidth         = pcCU->getWidth ( 0 ) >> ( uiTrDepth + m_uiSubSampExpX );
+    UInt  uiHeight        = pcCU->getHeight( 0 ) >> ( uiTrDepth + m_uiSubSampExpY );
     UInt  uiStride        = pcCUDepthMap->getStride  ();
-    Pel*  pDepthMap       = pcCUDepthMap->getLumaAddr( uiAbsPartIdx );
+    UInt  uiBlkX          = g_auiRasterToPelX[ g_auiZscanToRaster[ uiAbsPartIdx ] ] >> m_uiSubSampExpX;
+    UInt  uiBlkY          = g_auiRasterToPelY[ g_auiZscanToRaster[ uiAbsPartIdx ] ] >> m_uiSubSampExpY;
+    Pel*  pDepthMap       = pcCUDepthMap->getLumaAddr() + uiBlkY * pcCUDepthMap->getStride() + uiBlkX;
     UInt  uiLumaPredMode  = pcCU->getLumaIntraDir    ( uiAbsPartIdx );
     Bool  bAboveAvail     = false;
@@ -1034,5 +1050,5 @@
                                         m_pcPrediction->getPredicBufWidth  (),
                                         m_pcPrediction->getPredicBufHeight (),
-                                        bAboveAvail, bLeftAvail, true );
+                                        bAboveAvail, bLeftAvail, true, m_uiSubSampExpX, m_uiSubSampExpY );
     m_pcPrediction->predIntraDepthAng ( pcCU->getPattern(), uiLumaPredMode, pDepthMap, uiStride, uiWidth, uiHeight ); // could be replaced with directional intra prediction
                                                                                                                       // using "predIntraLumaAng", but note: 
@@ -1106,4 +1122,6 @@
   UInt  uiAbsPartIdx;
   pcCU->getPartIndexAndSize( uiPartIdx, uiAbsPartIdx, iWidth, iHeight );
+  iWidth  >>= m_uiSubSampExpX;
+  iHeight >>= m_uiSubSampExpY;
 
   // get depth values
@@ -1125,5 +1143,5 @@
   if( aiPrdDepth[ 0 ] != PDM_UNDEFINED_DEPTH && aiPrdDepth[ 1 ] != PDM_UNDEFINED_DEPTH )
   {
-    iDepthValue = ( aiPrdDepth[ 0 ] + aiPrdDepth[ 1 ] + 1 ) >> 2;
+    iDepthValue = ( aiPrdDepth[ 0 ] + aiPrdDepth[ 1 ] + 1 ) >> 1;
   }
   else
@@ -1135,5 +1153,7 @@
 
   // set depth map for PU
-  Pel*  pDMSamples  = pcCUDepthMap->getLumaAddr( uiAbsPartIdx );
+  UInt  uiBlkX      = g_auiRasterToPelX[ g_auiZscanToRaster[ uiAbsPartIdx ] ] >> m_uiSubSampExpX;
+  UInt  uiBlkY      = g_auiRasterToPelY[ g_auiZscanToRaster[ uiAbsPartIdx ] ] >> m_uiSubSampExpY;
+  Pel*  pDMSamples  = pcCUDepthMap->getLumaAddr() + uiBlkY * pcCUDepthMap->getStride() + uiBlkX;
   Int   iStride     = pcCUDepthMap->getStride  ();
   for( Int iY = 0; iY < iHeight; iY++, pDMSamples += iStride )
@@ -1160,4 +1180,7 @@
   Int             iNum4x4BlksY      = iHeight >> 2;
   Int             iNum4x4BlksX      = iWidth  >> 2;
+  iWidth  >>= m_uiSubSampExpX;
+  iHeight >>= m_uiSubSampExpY;
+
   TComPicYuv*     pcCurrDepthMap    = pcCU->getPic()->getPredDepthMap();
   Pel*            piCurrDepthMap    = pcCurrDepthMap->getLumaAddr();
@@ -1184,4 +1207,8 @@
   Pel*            piBaseDepthMap    = pcBaseDepthMap->getLumaAddr();
   Int             iBaseStride       = pcBaseDepthMap->getStride();
+  Int             iShiftX           = m_uiSubSampExpX + 2;
+  Int             iShiftY           = m_uiSubSampExpY + 2;
+  Int             iAddX             = ( 1 << iShiftX ) >> 1;
+  Int             iAddY             = ( 1 << iShiftY ) >> 1;
 
   //===== initialize 4x4 block arrays =====
@@ -1202,11 +1229,11 @@
     {
       // position parameters
-      Int               iCurrBlkPosX        = iCurrPUPosX + ( i4x4BlkX << 2 );
-      Int               iCurrBlkPosY        = iCurrPUPosY + ( i4x4BlkY << 2 );
-      Int               iCurrSamplePosX     = iCurrBlkPosX + 1;
-      Int               iCurrSamplePosY     = iCurrBlkPosY + 1;
+      Int               iCurrBlkPosX        = iCurrPUPosX + ( ( i4x4BlkX << 2 ) >> m_uiSubSampExpX );
+      Int               iCurrBlkPosY        = iCurrPUPosY + ( ( i4x4BlkY << 2 ) >> m_uiSubSampExpY );
+      Int               iCurrSamplePosX     = iCurrBlkPosX + ( 1 >> m_uiSubSampExpX );
+      Int               iCurrSamplePosY     = iCurrBlkPosY + ( 1 >> m_uiSubSampExpY );
       Int               iCurrPredDepth      = piCurrDepthMap[ iCurrSamplePosY * iCurrStride + iCurrSamplePosX ];
       Int               iCurrPredDisp       = xGetDisparityFromVirtDepth( uiBaseId, iCurrPredDepth );
-      Int               iBaseSamplePosX     = iCurrSamplePosX + ( ( iCurrPredDisp + 2 ) >> 2 );
+      Int               iBaseSamplePosX     = iCurrSamplePosX + ( ( iCurrPredDisp + iAddX ) >> iShiftX );
       Int               iBaseSamplePosY     = iCurrSamplePosY;
       iBaseSamplePosX                       = Clip3( 0, pcBaseDepthMap->getWidth () - 1, iBaseSamplePosX );
@@ -1222,5 +1249,5 @@
       Int               iBaseCUAddr;
       Int               iBaseAbsPartIdx;
-      pcBaseRecPic->getCUAddrAndPartIdx( iBaseSamplePosX, iBaseSamplePosY, iBaseCUAddr, iBaseAbsPartIdx );
+      pcBaseRecPic->getCUAddrAndPartIdx( iBaseSamplePosX << m_uiSubSampExpX, iBaseSamplePosY << m_uiSubSampExpY, iBaseCUAddr, iBaseAbsPartIdx );
       TComDataCU*       pcBaseCU            = pcBasePic->getCU( iBaseCUAddr );
       if( pcBaseCU->getPredictionMode( iBaseAbsPartIdx ) != MODE_INTER && pcBaseCU->getPredictionMode( iBaseAbsPartIdx ) != MODE_SKIP )
@@ -1256,6 +1283,6 @@
         Int             iCurrRefStride      = pcCurrRefDMap->getStride();
         TComMv&         rcCurrMv            = aiCurrMvField[ iCurrRefListId ]->getMv( uiAbsPartIdx );
-        Int             iCurrRefSamplePosX  = iCurrSamplePosX + ( ( rcCurrMv.getHor() + 2 ) >> 2 );
-        Int             iCurrRefSamplePosY  = iCurrSamplePosY + ( ( rcCurrMv.getVer() + 2 ) >> 2 );
+        Int             iCurrRefSamplePosX  = iCurrSamplePosX + ( ( rcCurrMv.getHor() + iAddX ) >> iShiftX );
+        Int             iCurrRefSamplePosY  = iCurrSamplePosY + ( ( rcCurrMv.getVer() + iAddY ) >> iShiftY );
         Int             iCurrRefSamplePosXC = Clip3( 0, pcCurrRefDMap->getWidth () - 1, iCurrRefSamplePosX );
         Int             iCurrRefSamplePosYC = Clip3( 0, pcCurrRefDMap->getHeight() - 1, iCurrRefSamplePosY );
@@ -1271,5 +1298,5 @@
             // location and depth for path currView/currAU -> currView/refAU -> baseView/refAU
             Int         iCurrRefDisp        = xGetDisparityFromVirtDepth( uiBaseId, iCurrRefDepth );
-            Int         iBaseRefSamplePosX  = iCurrRefSamplePosX + ( ( iCurrRefDisp + 2 ) >> 2 );
+            Int         iBaseRefSamplePosX  = iCurrRefSamplePosX + ( ( iCurrRefDisp + iAddX ) >> iShiftX );
             Int         iBaseRefSamplePosY  = iCurrRefSamplePosY;
             TComPic*    pcBaseRefPic        = pcBaseCU->getSlice()->getRefPic( eBaseRefPicList, aiBaseRefIdx[ iBaseRefListId ] );
@@ -1328,6 +1355,6 @@
       for( Int i4x4BlkX = 0; i4x4BlkX < iNum4x4BlksX; i4x4BlkX++ )
       {
-        Int             iCurrSamplePosX     = iCurrPUPosX + ( i4x4BlkX << 2 ) + 1;
-        Int             iCurrSamplePosY     = iCurrPUPosY + ( i4x4BlkY << 2 ) + 1;
+        Int             iCurrSamplePosX     = iCurrPUPosX + ( ( ( i4x4BlkX << 2 ) + 1 ) >> m_uiSubSampExpX );
+        Int             iCurrSamplePosY     = iCurrPUPosY + ( ( ( i4x4BlkY << 2 ) + 1 ) >> m_uiSubSampExpY );
         m_aai4x4Depth[i4x4BlkY][i4x4BlkX]   = piCurrDepthMap[ iCurrSamplePosY * iCurrStride + iCurrSamplePosX ];
         m_aabDepthSet[i4x4BlkY][i4x4BlkX]   = true;
@@ -1389,5 +1416,7 @@
 
   //===== set depth values =====
-  Pel* piDepthMap = pcCUDepthMap->getLumaAddr( uiAbsPartIdx );
+  UInt uiBlkX     = g_auiRasterToPelX[ g_auiZscanToRaster[ uiAbsPartIdx ] ] >> m_uiSubSampExpX;
+  UInt uiBlkY     = g_auiRasterToPelY[ g_auiZscanToRaster[ uiAbsPartIdx ] ] >> m_uiSubSampExpY;
+  Pel* piDepthMap = pcCUDepthMap->getLumaAddr() + uiBlkY * pcCUDepthMap->getStride() + uiBlkX;
   Int  iCUStride  = pcCUDepthMap->getStride  ();
   for( Int iRow = 0; iRow < iHeight; iRow++, piDepthMap += iCUStride )
@@ -1395,5 +1424,5 @@
     for( Int iCol = 0; iCol < iWidth; iCol++ )
     {
-      piDepthMap[ iCol ] = m_aai4x4Depth[ iRow >> 2 ][ iCol >> 2 ];
+      piDepthMap[ iCol ] = m_aai4x4Depth[ (iRow << m_uiSubSampExpY) >> 2  ][ (iCol << m_uiSubSampExpX) >> 2 ];
     }
   }
@@ -1404,5 +1433,5 @@
 TComDepthMapGenerator::xInterPUDepthMapPrediction( TComDataCU* pcCU, TComYuv* pcCUDepthMap, UInt uiPartIdx )
 {
-  m_pcPrediction->motionCompensation( pcCU, pcCUDepthMap, REF_PIC_LIST_X, (Int)uiPartIdx, true );  
+  m_pcPrediction->motionCompensation( pcCU, pcCUDepthMap, REF_PIC_LIST_X, (Int)uiPartIdx, true, m_uiSubSampExpX, m_uiSubSampExpY );  
 }
 
@@ -1432,6 +1461,6 @@
   Int           iCurrPosY;
   pcPredDepthMap->getTopLeftSamplePos( pcCU->getAddr(), pcCU->getZorderIdxInCU() + uiPartAddr, iCurrPosX, iCurrPosY );
-  iCurrPosX  += ( iWidth  - 1 ) >> 1;
-  iCurrPosY  += ( iHeight - 1 ) >> 1;
+  iCurrPosX  += ( ( iWidth  >> m_uiSubSampExpX ) - 1 ) >> 1;
+  iCurrPosY  += ( ( iHeight >> m_uiSubSampExpY ) - 1 ) >> 1;
   riPrdDepth  = piPredDepthMap[ iCurrPosX + iCurrPosY * iCurrStride ];
   if( piPosX )
Index: branches/0.2-HHI/source/Lib/TLibCommon/TComDepthMapGenerator.h
===================================================================
--- branches/0.2-HHI/source/Lib/TLibCommon/TComDepthMapGenerator.h	(revision 16)
+++ branches/0.2-HHI/source/Lib/TLibCommon/TComDepthMapGenerator.h	(revision 20)
@@ -110,5 +110,5 @@
   ~TComDepthMapGenerator();
 
-  Void  create                ( Bool bDecoder, UInt uiPicWidth, UInt uiPicHeight, UInt uiMaxCUDepth, UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uiOrgBitDepth );
+  Void  create                ( Bool bDecoder, UInt uiPicWidth, UInt uiPicHeight, UInt uiMaxCUDepth, UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uiOrgBitDepth, UInt uiSubSampExpX, UInt uiSubSampExpY );
   Void  destroy               ();
 
@@ -126,4 +126,6 @@
 
   UInt  getBaseViewId         ( UInt          uiIdx ) { AOF( uiIdx < m_auiBaseIdList.size() );  return m_auiBaseIdList[uiIdx]; }
+  UInt  getSubSampExpX        ()                      { return m_uiSubSampExpX; }
+  UInt  getSubSampExpY        ()                      { return m_uiSubSampExpY; }
   Int   getDisparity          ( TComPic*      pcPic, Int iPosX, Int iPosY, UInt uiRefViewId );
 #if HHI_INTER_VIEW_MOTION_PRED
@@ -200,4 +202,6 @@
   UInt              m_uiMaxDepth;
   UInt              m_uiOrgDepthBitDepth;
+  UInt              m_uiSubSampExpX;
+  UInt              m_uiSubSampExpY;
   TComYuv**         m_ppcYuv;
   TComDataCU**      m_ppcCU;
Index: branches/0.2-HHI/source/Lib/TLibCommon/TComPattern.cpp
===================================================================
--- branches/0.2-HHI/source/Lib/TLibCommon/TComPattern.cpp	(revision 16)
+++ branches/0.2-HHI/source/Lib/TLibCommon/TComPattern.cpp	(revision 20)
@@ -147,10 +147,18 @@
   if ( iComp == 0 )
   {
+#if DEPTH_MAP_GENERATION
+    m_iPatternStride  = ( bPrdDepthMap ? pcCU->getPic()->getPredDepthMap()->getStride() : pcCU->getPic()->getStride() );
+#else
     m_iPatternStride  = pcCU->getPic()->getStride();
+#endif
     m_piPatternOrigin = pcPic->getLumaAddr(pcCU->getAddr(), uiAbsZorderIdx) - m_iOffsetAbove * m_iPatternStride - m_iOffsetLeft;
   }
   else
   {
+#if DEPTH_MAP_GENERATION
+    m_iPatternStride  = ( bPrdDepthMap ? pcCU->getPic()->getPredDepthMap()->getCStride() : pcCU->getPic()->getCStride() );
+#else
     m_iPatternStride = pcCU->getPic()->getCStride();
+#endif
     if ( iComp == 1 )
       m_piPatternOrigin = pcPic->getCbAddr(pcCU->getAddr(), uiAbsZorderIdx) - m_iOffsetAbove * m_iPatternStride - m_iOffsetLeft;
@@ -242,5 +250,5 @@
 Void TComPattern::initAdiPattern( TComDataCU* pcCU, UInt uiZorderIdxInPart, UInt uiPartDepth, Int* piAdiBuf, Int iOrgBufStride, Int iOrgBufHeight, Bool& bAbove, Bool& bLeft
 #if DEPTH_MAP_GENERATION
-                                , Bool bPrdDepthMap 
+                                , Bool bPrdDepthMap, UInt uiSubSampExpX, UInt uiSubSampExpY
 #endif
                                 )
@@ -254,5 +262,11 @@
   UInt  uiWidth;
   UInt  uiHeight;
+
+#if DEPTH_MAP_GENERATION
+  Int   iPicStride = ( bPrdDepthMap ? pcCU->getPic()->getPredDepthMap()->getStride() : pcCU->getPic()->getStride() );
+#else
   Int   iPicStride = pcCU->getPic()->getStride();
+#endif
+
   Int   iCuAddr;
 #if REFERENCE_SAMPLE_PADDING
@@ -375,6 +389,19 @@
 #endif // REFERENCE_SAMPLE_PADDING
   
+#if DEPTH_MAP_GENERATION
+  if ( bPrdDepthMap )
+  {
+    uiWidth  = ( uiCuWidth2  >> uiSubSampExpX ) + 1;
+    uiHeight = ( uiCuHeight2 >> uiSubSampExpY ) + 1;
+  }
+  else
+  {
   uiWidth=uiCuWidth2+1;
   uiHeight=uiCuHeight2+1;
+  }
+#else
+  uiWidth=uiCuWidth2+1;
+  uiHeight=uiCuHeight2+1;
+#endif
   
   if (((uiWidth<<2)>iOrgBufStride)||((uiHeight<<2)>iOrgBufHeight))
@@ -398,4 +425,7 @@
 #if REFERENCE_SAMPLE_PADDING
 #if DEPTH_MAP_GENERATION
+  if ( bPrdDepthMap )
+    fillReferenceSamples ( pcCU, piRoiOrigin, piAdiTemp, bNeighborFlags, iNumIntraNeighbor, iUnitSize >> uiSubSampExpX, iNumUnitsInCu, iTotalUnits, uiCuWidth >> uiSubSampExpX, uiCuHeight >> uiSubSampExpY, uiWidth, uiHeight, iPicStride, bPrdDepthMap );
+  else
   fillReferenceSamples ( pcCU, piRoiOrigin, piAdiTemp, bNeighborFlags, iNumIntraNeighbor, iUnitSize, iNumUnitsInCu, iTotalUnits, uiCuWidth, uiCuHeight, uiWidth, uiHeight, iPicStride, bPrdDepthMap );
 #else
Index: branches/0.2-HHI/source/Lib/TLibCommon/TComPattern.h
===================================================================
--- branches/0.2-HHI/source/Lib/TLibCommon/TComPattern.h	(revision 16)
+++ branches/0.2-HHI/source/Lib/TLibCommon/TComPattern.h	(revision 20)
@@ -174,5 +174,8 @@
                                 Bool&       bLeft
 #if DEPTH_MAP_GENERATION
-                               ,Bool        bPrdDepthMap = false 
+                               ,
+                               Bool         bPrdDepthMap = false,
+                               UInt         uiSubSampExpX = 0,
+                               UInt         uiSubSampExpY = 0
 #endif
                                );
Index: branches/0.2-HHI/source/Lib/TLibCommon/TComPic.cpp
===================================================================
--- branches/0.2-HHI/source/Lib/TLibCommon/TComPic.cpp	(revision 16)
+++ branches/0.2-HHI/source/Lib/TLibCommon/TComPic.cpp	(revision 20)
@@ -73,5 +73,7 @@
   m_aiNumRefIdx[0]    = 0;
   m_aiNumRefIdx[1]    = 0;
-
+#if SONY_COLPIC_AVAILABILITY
+  m_iViewOrderIdx     = 0;
+#endif
   m_iViewIdx          = 0;
   m_aaiCodedScale     = 0;
@@ -211,5 +213,5 @@
 #if DEPTH_MAP_GENERATION
 Void
-TComPic::addPrdDepthMapBuffer()
+TComPic::addPrdDepthMapBuffer( UInt uiSubSampExpX, UInt uiSubSampExpY )
 {
   AOT( m_pcPredDepthMap );
@@ -221,5 +223,5 @@
   UInt  uiMaxCuDepth  = m_apcPicYuv[1]->getMaxCuDepth ();
   m_pcPredDepthMap    = new TComPicYuv;
-  m_pcPredDepthMap    ->create( iWidth, iHeight, uiMaxCuWidth, uiMaxCuHeight, uiMaxCuDepth );
+  m_pcPredDepthMap    ->create( iWidth >> uiSubSampExpX, iHeight >> uiSubSampExpY, uiMaxCuWidth >> uiSubSampExpX, uiMaxCuHeight >> uiSubSampExpY, uiMaxCuDepth );
 }
 #endif
Index: branches/0.2-HHI/source/Lib/TLibCommon/TComPic.h
===================================================================
--- branches/0.2-HHI/source/Lib/TLibCommon/TComPic.h	(revision 16)
+++ branches/0.2-HHI/source/Lib/TLibCommon/TComPic.h	(revision 20)
@@ -90,4 +90,7 @@
 
   Int                   m_iViewIdx;
+#if SONY_COLPIC_AVAILABILITY
+  Int                   m_iViewOrderIdx;
+#endif
   Int**                 m_aaiCodedScale;
   Int**                 m_aaiCodedOffset;
@@ -159,4 +162,8 @@
   Void          setViewIdx( Int i )                           { m_iViewIdx = i; }
   Int           getViewIdx()                                  { return m_iViewIdx; }
+#if SONY_COLPIC_AVAILABILITY
+  Void          setViewOrderIdx(Int i)                        { m_iViewOrderIdx = i; }
+  Int           getViewOrderIdx()                             { return m_iViewOrderIdx; }
+#endif
 
   Void          setScaleOffset( Int** pS, Int** pO )  { m_aaiCodedScale = pS; m_aaiCodedOffset = pO; }
@@ -200,5 +207,5 @@
 #endif
 #if DEPTH_MAP_GENERATION
-  Void          addPrdDepthMapBuffer    ();
+  Void          addPrdDepthMapBuffer    ( UInt uiSubSampExpX, UInt uiSubSampExpY );
 #endif
 #if HHI_INTER_VIEW_MOTION_PRED
Index: branches/0.2-HHI/source/Lib/TLibCommon/TComPicYuv.cpp
===================================================================
--- branches/0.2-HHI/source/Lib/TLibCommon/TComPicYuv.cpp	(revision 16)
+++ branches/0.2-HHI/source/Lib/TLibCommon/TComPicYuv.cpp	(revision 20)
Index: branches/0.2-HHI/source/Lib/TLibCommon/TComPrediction.cpp
===================================================================
--- branches/0.2-HHI/source/Lib/TLibCommon/TComPrediction.cpp	(revision 16)
+++ branches/0.2-HHI/source/Lib/TLibCommon/TComPrediction.cpp	(revision 20)
@@ -1507,5 +1507,9 @@
 #endif
 
-Void TComPrediction::motionCompensation ( TComDataCU* pcCU, TComYuv* pcYuvPred, RefPicList eRefPicList, Int iPartIdx, Bool bPrdDepthMap )
+#if DEPTH_MAP_GENERATION
+Void TComPrediction::motionCompensation( TComDataCU* pcCU, TComYuv* pcYuvPred, RefPicList eRefPicList, Int iPartIdx, Bool bPrdDepthMap, UInt uiSubSampExpX, UInt uiSubSampExpY )
+#else
+Void TComPrediction::motionCompensation( TComDataCU* pcCU, TComYuv* pcYuvPred, RefPicList eRefPicList, Int iPartIdx )
+#endif
 {
   Int         iWidth;
@@ -1516,7 +1520,20 @@
   {
     pcCU->getPartIndexAndSize( iPartIdx, uiPartAddr, iWidth, iHeight );
+
+#if DEPTH_MAP_GENERATION
+    if( bPrdDepthMap )
+    {
+      iWidth  >>= uiSubSampExpX;
+      iHeight >>= uiSubSampExpY;
+    }
+#endif
+
     if ( eRefPicList != REF_PIC_LIST_X )
     {
-      xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, iPartIdx, bPrdDepthMap );
+#if DEPTH_MAP_GENERATION
+      xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, iPartIdx, bPrdDepthMap, uiSubSampExpX, uiSubSampExpY );
+#else
+      xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, iPartIdx );
+#endif
 #ifdef WEIGHT_PRED
       if ( pcCU->getSlice()->getPPS()->getUseWP() )
@@ -1528,6 +1545,9 @@
     else
     {
-      xPredInterBi  (pcCU, uiPartAddr, iWidth, iHeight, pcYuvPred, iPartIdx, bPrdDepthMap );
-
+#if DEPTH_MAP_GENERATION
+      xPredInterBi  (pcCU, uiPartAddr, iWidth, iHeight, uiSubSampExpX, uiSubSampExpY, pcYuvPred, iPartIdx, bPrdDepthMap );
+#else
+      xPredInterBi  (pcCU, uiPartAddr, iWidth, iHeight, pcYuvPred, iPartIdx );
+#endif
     }
     return;
@@ -1538,7 +1558,19 @@
     pcCU->getPartIndexAndSize( iPartIdx, uiPartAddr, iWidth, iHeight );
 
+#if DEPTH_MAP_GENERATION
+    if( bPrdDepthMap )
+    {
+      iWidth  >>= uiSubSampExpX;
+      iHeight >>= uiSubSampExpY;
+    }
+#endif
+
     if ( eRefPicList != REF_PIC_LIST_X )
     {
-      xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, iPartIdx, bPrdDepthMap );
+#if DEPTH_MAP_GENERATION
+      xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, iPartIdx, bPrdDepthMap, uiSubSampExpX, uiSubSampExpY );
+#else
+      xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, iPartIdx );
+#endif
 #ifdef WEIGHT_PRED
       if ( pcCU->getSlice()->getPPS()->getUseWP() )
@@ -1550,5 +1582,9 @@
     else
     {
-      xPredInterBi  (pcCU, uiPartAddr, iWidth, iHeight, pcYuvPred, iPartIdx, bPrdDepthMap );
+#if DEPTH_MAP_GENERATION
+      xPredInterBi  (pcCU, uiPartAddr, iWidth, iHeight, uiSubSampExpX, uiSubSampExpY, pcYuvPred, iPartIdx, bPrdDepthMap );
+#else
+      xPredInterBi  (pcCU, uiPartAddr, iWidth, iHeight, pcYuvPred, iPartIdx );
+#endif
     }
   }
@@ -1558,5 +1594,5 @@
 #if HIGH_ACCURACY_BI
 #if DEPTH_MAP_GENERATION
-Void TComPrediction::xPredInterUni ( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Int iPartIdx, Bool bPrdDepthMap, Bool bi )
+Void TComPrediction::xPredInterUni ( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Int iPartIdx, Bool bPrdDepthMap, UInt uiSubSampExpX, UInt uiSubSampExpY, Bool bi )
 #else
 Void TComPrediction::xPredInterUni ( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Int iPartIdx, Bool bi )
@@ -1564,5 +1600,5 @@
 #else
 #if DEPTH_MAP_GENERATION
-Void TComPrediction::xPredInterUni ( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Int iPartIdx, Bool bPrdDepthMap )
+Void TComPrediction::xPredInterUni ( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Int iPartIdx, Bool bPrdDepthMap, UInt uiSubSampExpX, UInt uiSubSampExpY )
 #else
 Void TComPrediction::xPredInterUni ( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Int iPartIdx )
@@ -1576,4 +1612,13 @@
 #if DEPTH_MAP_GENERATION
   if( bPrdDepthMap )
+  {
+    UInt uiRShift = 0;
+    xPredInterPrdDepthMap( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPredDepthMap(), uiPartAddr, &cMv, iWidth, iHeight, uiSubSampExpX, uiSubSampExpY, rpcYuvPred, uiRShift );
+    return;
+  }
+#endif
+
+#if HHI_FULL_PEL_DEPTH_MAP_MV_ACC
+  if( pcCU->getSlice()->getSPS()->isDepth() )
   {
 #if HIGH_ACCURACY_BI
@@ -1582,18 +1627,9 @@
     UInt uiRShift = 0;
 #endif
-    xPredInterPrdDepthMap( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPredDepthMap(), uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, uiRShift, PDM_DEPTH_MAP_MCP_FILTER );
-    return;
-  }
-#endif
-
-#if HHI_FULL_PEL_DEPTH_MAP_MV_ACC
-  if( pcCU->getSlice()->getSPS()->isDepth() )
-  {
-#if HIGH_ACCURACY_BI
-    UInt uiRShift = ( bi ? 14-g_uiBitDepth-g_uiBitIncrement : 0 );
+#if DEPTH_MAP_GENERATION
+    xPredInterPrdDepthMap( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, 0, 0, rpcYuvPred, uiRShift );
 #else
-    UInt uiRShift = 0;
-#endif
-    xPredInterPrdDepthMap( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, uiRShift, 2 );
+    xPredInterPrdDepthMap( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, uiRShift );
+#endif
   }
   else
@@ -1630,5 +1666,9 @@
 }
 
-Void TComPrediction::xPredInterBi ( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, TComYuv*& rpcYuvPred, Int iPartIdx, Bool bPrdDepthMap )
+#if DEPTH_MAP_GENERATION
+Void TComPrediction::xPredInterBi ( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, UInt uiSubSampExpX, UInt uiSubSampExpY, TComYuv*& rpcYuvPred, Int iPartIdx, Bool bPrdDepthMap )
+#else
+Void TComPrediction::xPredInterBi ( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, TComYuv*& rpcYuvPred, Int iPartIdx )
+#endif
 {
   TComYuv* pcMbYuv;
@@ -1651,5 +1691,5 @@
     if( pcCU->getCUMvField( REF_PIC_LIST_0 )->getRefIdx( uiPartAddr ) >= 0 && pcCU->getCUMvField( REF_PIC_LIST_1 )->getRefIdx( uiPartAddr ) >= 0 )
 #if DEPTH_MAP_GENERATION
-      xPredInterUni ( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv, iPartIdx, bPrdDepthMap, true );
+      xPredInterUni ( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv, iPartIdx, bPrdDepthMap, uiSubSampExpX, uiSubSampExpY, true );
 #else
       xPredInterUni ( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv, iPartIdx, true );
@@ -1657,5 +1697,5 @@
     else
 #if DEPTH_MAP_GENERATION
-     xPredInterUni ( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv, iPartIdx, bPrdDepthMap );
+     xPredInterUni ( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv, iPartIdx, bPrdDepthMap, uiSubSampExpX, uiSubSampExpY );
 #else
      xPredInterUni ( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv, iPartIdx );
@@ -1663,5 +1703,5 @@
 #else
 #if DEPTH_MAP_GENERATION
-    xPredInterUni ( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv, iPartIdx, bPrdDepthMap );
+    xPredInterUni ( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv, iPartIdx, bPrdDepthMap, uiSubSampExpX, uiSubSampExpY );
 #else
     xPredInterUni ( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv, iPartIdx );
@@ -1677,35 +1717,66 @@
   else
 #endif
+
+#if DEPTH_MAP_GENERATION
+  if ( bPrdDepthMap )
+  {
+    xWeightedAveragePdm( pcCU, &m_acYuvPred[0], &m_acYuvPred[1], iRefIdx[0], iRefIdx[1], uiPartAddr, iWidth, iHeight, rpcYuvPred, uiSubSampExpX, uiSubSampExpY );
+  }
+  else
+  {
+    xWeightedAverage( pcCU, &m_acYuvPred[0], &m_acYuvPred[1], iRefIdx[0], iRefIdx[1], uiPartAddr, iWidth, iHeight, rpcYuvPred );
+  }
+#else
   xWeightedAverage( pcCU, &m_acYuvPred[0], &m_acYuvPred[1], iRefIdx[0], iRefIdx[1], uiPartAddr, iWidth, iHeight, rpcYuvPred );
+#endif
+
 }
 
 
 Void 
-TComPrediction::xPredInterPrdDepthMap( TComDataCU* pcCU, TComPicYuv* pcPicYuvRef, UInt uiPartAddr, TComMv* pcMv, Int iWidth, Int iHeight, TComYuv*& rpcYuv, UInt uiRShift, UInt uiFilterMode ) // 0:std, 1:bilin, 2:nearest neighbour
-{
-  AOF( uiFilterMode <= 2 );
-
+#if DEPTH_MAP_GENERATION
+TComPrediction::xPredInterPrdDepthMap( TComDataCU* pcCU, TComPicYuv* pcPicYuvRef, UInt uiPartAddr, TComMv* pcMv, Int iWidth, Int iHeight, UInt uiSubSampExpX, UInt uiSubSampExpY, TComYuv*& rpcYuv, UInt uiRShift )
+#else
+TComPrediction::xPredInterPrdDepthMap( TComDataCU* pcCU, TComPicYuv* pcPicYuvRef, UInt uiPartAddr, TComMv* pcMv, Int iWidth, Int iHeight, TComYuv*& rpcYuv, UInt uiRShift )
+#endif
+{
+#if DEPTH_MAP_GENERATION
+  Int     iShiftX     = 2 + uiSubSampExpX;
+  Int     iShiftY     = 2 + uiSubSampExpY;
+  Int     iAddX       = ( 1 << iShiftX ) >> 1;
+  Int     iAddY       = ( 1 << iShiftY ) >> 1;
+  Int     iHor        = ( pcMv->getHor() + iAddX ) >> iShiftX;
+  Int     iVer        = ( pcMv->getVer() + iAddY ) >> iShiftY;
+#if HHI_FULL_PEL_DEPTH_MAP_MV_ACC
+  if( pcCU->getSlice()->getSPS()->isDepth() )
+{
+    iHor = pcMv->getHor();
+    iVer = pcMv->getVer();
+  }
+#endif
+  Int     iRefStride  = pcPicYuvRef->getStride();
+  Int     iDstStride  = rpcYuv->getStride();
+  Int     iRefOffset  = iHor + iVer * iRefStride;
+#else
   Int     iFPelMask   = ~3;
   Int     iRefStride  = pcPicYuvRef->getStride();
   Int     iDstStride  = rpcYuv->getStride();
-  Int     iHor        = ( uiFilterMode == 2 ? ( pcMv->getHor() + 2 ) & iFPelMask : pcMv->getHor() );
-  Int     iVer        = ( uiFilterMode == 2 ? ( pcMv->getVer() + 2 ) & iFPelMask : pcMv->getVer() );
+  Int     iHor        = ( pcMv->getHor() + 2 ) & iFPelMask;
+  Int     iVer        = ( pcMv->getVer() + 2 ) & iFPelMask;
 #if HHI_FULL_PEL_DEPTH_MAP_MV_ACC
   if( pcCU->getSlice()->getSPS()->isDepth() )
   {
-    assert( uiFilterMode == 2 );
     iHor = pcMv->getHor() * 4;
     iVer = pcMv->getVer() * 4;
   }
 #endif
-  Int     iRefOffset  = ( iHor >> 2 ) + ( iVer >> 2 ) * iRefStride;
   Int     ixFrac      = iHor & 0x3;
   Int     iyFrac      = iVer & 0x3;
+  Int     iRefOffset  = ( iHor >> 2 ) + ( iVer >> 2 ) * iRefStride;
+#endif
+
   Pel*    piRefY      = pcPicYuvRef->getLumaAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() + uiPartAddr ) + iRefOffset;
   Pel*    piDstY      = rpcYuv->getLumaAddr( uiPartAddr );
 
-  //  Integer position
-  if( ixFrac == 0 && iyFrac == 0 )
-  {
     for( Int y = 0; y < iHeight; y++, piDstY += iDstStride, piRefY += iRefStride )
     {
@@ -1715,30 +1786,4 @@
       }
     }
-    return;
-  }
-
-  // bi-linear interpolation
-  if( uiFilterMode == 1 )
-  {
-    Int   iW00    = ( 4 - ixFrac ) * ( 4 - iyFrac );
-    Int   iW01    = (     ixFrac ) * ( 4 - iyFrac );
-    Int   iW10    = ( 4 - ixFrac ) * (     iyFrac );
-    Int   iW11    = (     ixFrac ) * (     iyFrac );
-    Pel*  piRefY1 = piRefY + iRefStride;
-    for( Int y = 0; y < iHeight; y++, piDstY += iDstStride, piRefY += iRefStride, piRefY1 += iRefStride )
-    {
-      for( Int x = 0; x < iWidth; x++ )
-      {
-        Int iSV     = iW00 * piRefY [ x ] + iW01 * piRefY [ x + 1 ]
-                    + iW10 * piRefY1[ x ] + iW11 * piRefY1[ x + 1 ];
-        iSV       <<= uiRShift;
-        piDstY[ x ] = ( iSV + 8 ) >> 4;
-      }
-    }
-    return;
-  }
-
-  xPredInterLumaBlk( pcCU, pcPicYuvRef, uiPartAddr, pcMv, iWidth, iHeight, rpcYuv );
-  return;
 }
 
@@ -2167,4 +2212,26 @@
 }
 
+#endif
+
+#if DEPTH_MAP_GENERATION
+Void TComPrediction::xWeightedAveragePdm( TComDataCU* pcCU, TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, Int iRefIdx0, Int iRefIdx1, UInt uiPartIdx, Int iWidth, Int iHeight, TComYuv*& rpcYuvDst, UInt uiSubSampExpX, UInt uiSubSampExpY )
+{
+  if( iRefIdx0 >= 0 && iRefIdx1 >= 0 )
+  {
+    rpcYuvDst->addAvgPdm( pcYuvSrc0, pcYuvSrc1, uiPartIdx, iWidth, iHeight, uiSubSampExpX, uiSubSampExpY );
+  }
+  else if ( iRefIdx0 >= 0 && iRefIdx1 <  0 )
+  {
+    pcYuvSrc0->copyPartToPartYuvPdm( rpcYuvDst, uiPartIdx, iWidth, iHeight, uiSubSampExpX, uiSubSampExpY );
+  }
+  else if ( iRefIdx0 <  0 && iRefIdx1 >= 0 )
+  {
+    pcYuvSrc1->copyPartToPartYuvPdm( rpcYuvDst, uiPartIdx, iWidth, iHeight, uiSubSampExpX, uiSubSampExpY );
+  }
+  else
+  {
+    assert (0);
+  }
+}
 #endif
 
Index: branches/0.2-HHI/source/Lib/TLibCommon/TComPrediction.h
===================================================================
--- branches/0.2-HHI/source/Lib/TLibCommon/TComPrediction.h	(revision 16)
+++ branches/0.2-HHI/source/Lib/TLibCommon/TComPrediction.h	(revision 20)
@@ -89,5 +89,5 @@
 #if HIGH_ACCURACY_BI
 #if DEPTH_MAP_GENERATION
-  Void xPredInterUni            ( TComDataCU* pcCU,                          UInt uiPartAddr,               Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Int iPartIdx, Bool bPrdDepthMap, Bool bi=false );
+  Void xPredInterUni            ( TComDataCU* pcCU,                          UInt uiPartAddr,               Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Int iPartIdx, Bool bPrdDepthMap, UInt uiSubSampExpX = 0, UInt uiSubSampExpY = 0, Bool bi=false );
 #else
   Void xPredInterUni            ( TComDataCU* pcCU,                          UInt uiPartAddr,               Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Int iPartIdx, Bool bi=false );
@@ -95,14 +95,25 @@
 #else
 #if DEPTH_MAP_GENERATION
-  Void xPredInterUni            ( TComDataCU* pcCU,                          UInt uiPartAddr,               Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Int iPartIdx, Bool bPrdDepthMap );
+  Void xPredInterUni            ( TComDataCU* pcCU,                          UInt uiPartAddr,               Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Int iPartIdx, Bool bPrdDepthMap, UInt uiSubSampExpX = 0, UInt uiSubSampExpY = 0 );
 #else
   Void xPredInterUni            ( TComDataCU* pcCU,                          UInt uiPartAddr,               Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Int iPartIdx );
 #endif
 #endif
-  Void xPredInterBi             ( TComDataCU* pcCU,                          UInt uiPartAddr,               Int iWidth, Int iHeight,                         TComYuv*& rpcYuvPred, Int iPartIdx, Bool bPrdDepthMap );
-  Void xPredInterPrdDepthMap    ( TComDataCU* pcCU, TComPicYuv* pcPicYuvRef, UInt uiPartAddr, TComMv* pcMv, Int iWidth, Int iHeight,                         TComYuv*& rpcYuv, UInt uiRShift, UInt uiFilterMode ); // 0:std, 1:bilin, 2:nearest neighbour
+#if DEPTH_MAP_GENERATION
+  Void xPredInterBi             ( TComDataCU* pcCU,                          UInt uiPartAddr,               Int iWidth, Int iHeight, UInt uiSubSampExpX, UInt uiSubSampExpY, TComYuv*& rpcYuvPred, Int iPartIdx, Bool bPrdDepthMap );
+  Void xPredInterPrdDepthMap    ( TComDataCU* pcCU, TComPicYuv* pcPicYuvRef, UInt uiPartAddr, TComMv* pcMv, Int iWidth, Int iHeight, UInt uiSubSampExpX, UInt uiSubSampExpY, TComYuv*& rpcYuv, UInt uiRShift );
+#else
+  Void xPredInterBi             ( TComDataCU* pcCU,                          UInt uiPartAddr,               Int iWidth, Int iHeight,                         TComYuv*& rpcYuvPred, Int iPartIdx );
+  Void xPredInterPrdDepthMap    ( TComDataCU* pcCU, TComPicYuv* pcPicYuvRef, UInt uiPartAddr, TComMv* pcMv, Int iWidth, Int iHeight,                         TComYuv*& rpcYuv, UInt uiRShift );
+#endif
   Void xPredInterLumaBlk        ( TComDataCU* pcCU, TComPicYuv* pcPicYuvRef, UInt uiPartAddr, TComMv* pcMv, Int iWidth, Int iHeight,                         TComYuv*& rpcYuv );
   Void xPredInterChromaBlk      ( TComDataCU* pcCU, TComPicYuv* pcPicYuvRef, UInt uiPartAddr, TComMv* pcMv, Int iWidth, Int iHeight,                         TComYuv*& rpcYuv                            );
+  
+#if DEPTH_MAP_GENERATION
+  Void xWeightedAveragePdm      ( TComDataCU* pcCU, TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, Int iRefIdx0, Int iRefIdx1, UInt uiPartAddr, Int iWidth, Int iHeight, TComYuv*& rpcYuvDst, UInt uiSubSampExpX, UInt uiSubSampExpY );
+#endif
   Void xWeightedAverage         ( TComDataCU* pcCU, TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, Int iRefIdx0, Int iRefIdx1, UInt uiPartAddr, Int iWidth, Int iHeight, TComYuv*& rpcYuvDst );
+
+
   Void xDCTIF_FilterC ( Pel*  piRefC, Int iRefStride,Pel*  piDstC,Int iDstStride,Int iWidth, Int iHeight,Int iMVyFrac,Int iMVxFrac);
 
@@ -145,5 +156,9 @@
   
   // inter
-  Void motionCompensation         ( TComDataCU*  pcCU, TComYuv* pcYuvPred, RefPicList eRefPicList = REF_PIC_LIST_X, Int iPartIdx = -1, Bool bPrdDepthMap = false );
+#if DEPTH_MAP_GENERATION
+  Void motionCompensation         ( TComDataCU*  pcCU, TComYuv* pcYuvPred, RefPicList eRefPicList = REF_PIC_LIST_X, Int iPartIdx = -1, Bool bPrdDepthMap = false, UInt uiSubSampExpX = 0, UInt uiSubSampExpY = 0 );
+#else
+  Void motionCompensation         ( TComDataCU*  pcCU, TComYuv* pcYuvPred, RefPicList eRefPicList = REF_PIC_LIST_X, Int iPartIdx = -1 );
+#endif
   
   // motion vector prediction
Index: branches/0.2-HHI/source/Lib/TLibCommon/TComResidualGenerator.cpp
===================================================================
--- branches/0.2-HHI/source/Lib/TLibCommon/TComResidualGenerator.cpp	(revision 16)
+++ branches/0.2-HHI/source/Lib/TLibCommon/TComResidualGenerator.cpp	(revision 20)
@@ -432,6 +432,6 @@
 
   //===== get disparity =====
-  Int           iMidPosX    = Int( uiXPos + ( ( uiBlkWidth  - 1 ) >> 1 ) );
-  Int           iMidPosY    = Int( uiYPos + ( ( uiBlkHeight - 1 ) >> 1 ) );
+  Int           iMidPosX    = Int( uiXPos + ( ( uiBlkWidth  - 1 ) >> 1 ) ) >> m_pcDepthMapGenerator->getSubSampExpX();
+  Int           iMidPosY    = Int( uiYPos + ( ( uiBlkHeight - 1 ) >> 1 ) ) >> m_pcDepthMapGenerator->getSubSampExpY();
   Int           iDisparity  = m_pcDepthMapGenerator->getDisparity( pcPic, iMidPosX, iMidPosY, uiBaseViewId );
 
Index: branches/0.2-HHI/source/Lib/TLibCommon/TComRom.cpp
===================================================================
--- branches/0.2-HHI/source/Lib/TLibCommon/TComRom.cpp	(revision 16)
+++ branches/0.2-HHI/source/Lib/TLibCommon/TComRom.cpp	(revision 20)
@@ -2815,7 +2815,6 @@
   assert( uiWidth == uiHeight );
 
-  UChar uhStartX, uhStartY, uhEndX, uhEndY;
-  Int    iStepStartX, iStepStartY, iStepEndX, iStepEndY;
-
+  UChar  uhStartX = 0, uhStartY = 0, uhEndX = 0, uhEndY = 0;
+  Int    iStepStartX = 0, iStepStartY = 0, iStepEndX = 0, iStepEndY = 0;
   UInt uiBlockSize = 0;
   switch( eWedgeRes )
Index: branches/0.2-HHI/source/Lib/TLibCommon/TComSlice.cpp
===================================================================
--- branches/0.2-HHI/source/Lib/TLibCommon/TComSlice.cpp	(revision 16)
+++ branches/0.2-HHI/source/Lib/TLibCommon/TComSlice.cpp	(revision 20)
@@ -66,4 +66,8 @@
   m_iViewIdx = 0 ;
 
+#if SONY_COLPIC_AVAILABILITY
+  m_iViewOrderIdx = 0;
+#endif
+
   initEqualRef();
   m_bNoBackPredFlag = false;
@@ -440,4 +444,7 @@
   m_iPOC                 = pSrc->m_iPOC;
   m_iViewIdx             = pSrc->m_iViewIdx;
+#if SONY_COLPIC_AVAILABILITY
+  m_iViewOrderIdx        = pSrc->m_iViewOrderIdx;
+#endif
 #if DCM_DECODING_REFRESH
   m_eNalUnitType         = pSrc->m_eNalUnitType;
@@ -676,5 +683,8 @@
   // AMVP parameter
   ::memset( m_aeAMVPMode, 0, sizeof( m_aeAMVPMode ) );
+
+#if ( HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX )
   m_bUseDMM = false;
+#endif
 }
 
Index: branches/0.2-HHI/source/Lib/TLibCommon/TComSlice.h
===================================================================
--- branches/0.2-HHI/source/Lib/TLibCommon/TComSlice.h	(revision 16)
+++ branches/0.2-HHI/source/Lib/TLibCommon/TComSlice.h	(revision 20)
@@ -370,4 +370,7 @@
   UInt        m_uiPPSId;
   Int         m_iPOC;
+#if SONY_COLPIC_AVAILABILITY
+  Int         m_iViewOrderIdx;
+#endif
 #if DCM_DECODING_REFRESH
   NalUnitType m_eNalUnitType;         ///< Nal unit type for the slice
@@ -460,4 +463,7 @@
   SliceType getSliceType    ()                          { return  m_eSliceType;         }
   Int       getPOC          ()                          { return  m_iPOC;           }
+#if SONY_COLPIC_AVAILABILITY
+  Int       getViewOrderIdx ()                          { return  m_iViewOrderIdx;  }
+#endif
   Int       getSliceQp      ()                          { return  m_iSliceQp;           }
   Int       getSliceQpDelta ()                          { return  m_iSliceQpDelta;      }
@@ -495,4 +501,7 @@
   Void      setPPSId            ( UInt u )                      { m_uiPPSId           = u;      }
   Void      setPOC              ( Int i )                       { m_iPOC              = i;      }
+#if SONY_COLPIC_AVAILABILITY
+  Void      setViewOrderIdx     ( Int i )                       { m_iViewOrderIdx     = i;      }
+#endif
 #if DCM_DECODING_REFRESH
   Void      setNalUnitType      ( NalUnitType e )               { m_eNalUnitType      = e;      }
Index: branches/0.2-HHI/source/Lib/TLibCommon/TComYuv.cpp
===================================================================
--- branches/0.2-HHI/source/Lib/TLibCommon/TComYuv.cpp	(revision 16)
+++ branches/0.2-HHI/source/Lib/TLibCommon/TComYuv.cpp	(revision 20)
@@ -300,4 +300,11 @@
 }
 
+#if DEPTH_MAP_GENERATION
+Void TComYuv::copyPartToPartYuvPdm   ( TComYuv* pcYuvDst, UInt uiPartIdx, UInt iWidth, UInt iHeight, UInt uiSubSampExpX, UInt uiSubSampExpY )
+{
+  copyPartToPartLumaPdm   (pcYuvDst, uiPartIdx, iWidth, iHeight, uiSubSampExpX, uiSubSampExpY );
+}
+#endif
+    
 Void TComYuv::copyPartToPartYuv   ( TComYuv* pcYuvDst, UInt uiPartIdx, UInt iWidth, UInt iHeight )
 {
@@ -305,4 +312,30 @@
   copyPartToPartChroma (pcYuvDst, uiPartIdx, iWidth>>1, iHeight>>1 );
 }
+
+#if DEPTH_MAP_GENERATION
+Void TComYuv::copyPartToPartLumaPdm  ( TComYuv* pcYuvDst, UInt uiPartIdx, UInt iWidth, UInt iHeight, UInt uiSubSampExpX, UInt uiSubSampExpY )
+{
+  UInt uiBlkX = g_auiRasterToPelX[ g_auiZscanToRaster[ uiPartIdx ] ] >> uiSubSampExpX;
+  UInt uiBlkY = g_auiRasterToPelY[ g_auiZscanToRaster[ uiPartIdx ] ] >> uiSubSampExpY;
+  Pel* pSrc   = getLumaAddr(uiPartIdx);
+  Pel* pDst   = pcYuvDst->getLumaAddr() + uiBlkY * pcYuvDst->getStride() + uiBlkX;
+  
+  if( pSrc == pDst )
+  {
+    //th not a good idea
+    //th best would be to fix the caller 
+    return ;
+  }
+  
+  UInt  iSrcStride = getStride();
+  UInt  iDstStride = pcYuvDst->getStride();
+  for ( UInt y = iHeight; y != 0; y-- )
+  {
+    ::memcpy( pDst, pSrc, iWidth * sizeof(Pel) );
+    pSrc += iSrcStride;
+    pDst += iDstStride;
+  }
+}
+#endif
 
 Void TComYuv::copyPartToPartLuma  ( TComYuv* pcYuvDst, UInt uiPartIdx, UInt iWidth, UInt iHeight )
@@ -801,4 +834,33 @@
 }
 
+#if DEPTH_MAP_GENERATION
+Void TComYuv::addAvgPdm( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt iPartUnitIdx, UInt iWidth, UInt iHeight, UInt uiSubSampExpX, UInt uiSubSampExpY )
+{
+  Int x, y;
+
+  UInt uiBlkX  = g_auiRasterToPelX[ g_auiZscanToRaster[ iPartUnitIdx ] ] >> uiSubSampExpX;
+  UInt uiBlkY  = g_auiRasterToPelY[ g_auiZscanToRaster[ iPartUnitIdx ] ] >> uiSubSampExpY;
+  Pel* pSrcY0  = pcYuvSrc0->getLumaAddr( iPartUnitIdx );
+  Pel* pSrcY1  = pcYuvSrc1->getLumaAddr( iPartUnitIdx );
+  Pel* pDstY   = getLumaAddr() + uiBlkY * getStride() + uiBlkX;
+  
+  UInt  iSrc0Stride = pcYuvSrc0->getStride();
+  UInt  iSrc1Stride = pcYuvSrc1->getStride();
+  UInt  iDstStride  = getStride();
+
+  for ( y = iHeight-1; y >= 0; y-- )
+  {
+    for ( x = iWidth-1; x >= 0; x-- )
+    {
+      pDstY[x] = (pSrcY0[x] + pSrcY1[x] + 1) >> 1;
+    }
+    pSrcY0 += iSrc0Stride;
+    pSrcY1 += iSrc1Stride;
+    pDstY  += iDstStride;
+  }
+}
+#endif
+
+
 Void TComYuv::removeHighFreq( TComYuv* pcYuvSrc, UInt uiWidht, UInt uiHeight )
 {
Index: branches/0.2-HHI/source/Lib/TLibCommon/TComYuv.h
===================================================================
--- branches/0.2-HHI/source/Lib/TLibCommon/TComYuv.h	(revision 16)
+++ branches/0.2-HHI/source/Lib/TLibCommon/TComYuv.h	(revision 20)
@@ -113,4 +113,8 @@
   Void    copyPartToPartLuma    ( TComYuv*    pcYuvDst, UInt uiPartIdx, UInt uiWidth, UInt uiHeight );
   Void    copyPartToPartChroma  ( TComYuv*    pcYuvDst, UInt uiPartIdx, UInt uiWidth, UInt uiHeight );
+#if DEPTH_MAP_GENERATION
+  Void    copyPartToPartYuvPdm  ( TComYuv*    pcYuvDst, UInt uiPartIdx, UInt uiWidth, UInt uiHeight, UInt uiSubSampExpX, UInt uiSubSampExpY );
+  Void    copyPartToPartLumaPdm ( TComYuv*    pcYuvDst, UInt uiPartIdx, UInt uiWidth, UInt uiHeight, UInt uiSubSampExpX, UInt uiSubSampExpY );
+#endif
   
   // ------------------------------------------------------------------------------------------------------------------
@@ -135,4 +139,7 @@
 #endif
   Void    addAvg            ( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt iPartUnitIdx, UInt iWidth, UInt iHeight );
+#if DEPTH_MAP_GENERATION
+  Void    addAvgPdm         ( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt iPartUnitIdx, UInt iWidth, UInt iHeight, UInt uiSubSampExpX, UInt uiSubSampExpY );
+#endif
 
   //   Remove High frequency
Index: branches/0.2-HHI/source/Lib/TLibCommon/TypeDef.h
===================================================================
--- branches/0.2-HHI/source/Lib/TLibCommon/TypeDef.h	(revision 16)
+++ branches/0.2-HHI/source/Lib/TLibCommon/TypeDef.h	(revision 20)
@@ -40,4 +40,7 @@
 
 
+
+#define SONY_COLPIC_AVAILABILITY  		  1
+
 //>>>>> HHI 3DV tools >>>>>
 #define HHI_INTER_VIEW_MOTION_PRED      1   // inter-view motion parameter prediction
@@ -50,4 +53,5 @@
 #define HHI_VSO_COLOR_PLANES            1   // view synthesis optimization in color planes
 #define HHI_VSO_DIST_INT                1   // view synthesis optimization integer distorition in rdo process
+#define HHI_VSO_LS_TABLE                1   // table based lambda scaling
 
 #if HHI_INTERVIEW_SKIP_LAMBDA_SCALE && !HHI_INTERVIEW_SKIP
@@ -60,4 +64,5 @@
 #define HHI_NO_LowDelayCoding           0   // old-fashioned encoder control, should be adapted to hm5.0
 //<<<<< HHI 3DV tools <<<<<
+
 
 
Index: branches/0.2-HHI/source/Lib/TLibDecoder/TDecTop.cpp
===================================================================
--- branches/0.2-HHI/source/Lib/TLibDecoder/TDecTop.cpp	(revision 16)
+++ branches/0.2-HHI/source/Lib/TLibDecoder/TDecTop.cpp	(revision 20)
@@ -250,4 +250,7 @@
   m_bIsDepth = false ;
   m_iViewIdx = 0 ;
+#if SONY_COLPIC_AVAILABILITY
+  m_iViewOrderIdx = 0;
+#endif
 #if ENC_DEC_TRACE
   g_hTrace = fopen( "TraceDec.txt", "wb" );
@@ -382,5 +385,6 @@
 
 #if DEPTH_MAP_GENERATION
-  Bool bNeedPrdDepthMapBuffer = ( !pcSlice->getSPS()->isDepth() && ( pcSlice->getSPS()->getViewId() == 0 || pcSlice->getSPS()->getPredDepthMapGeneration() > 0 ) );
+  UInt uiPdm                  = ( pcSlice->getSPS()->getViewId() ? pcSlice->getSPS()->getPredDepthMapGeneration() : m_pcTAppDecTop->getSPSAccess()->getPdm() );
+  Bool bNeedPrdDepthMapBuffer = ( !pcSlice->getSPS()->isDepth() && uiPdm > 0 );
 #endif
 
@@ -392,5 +396,5 @@
     if( bNeedPrdDepthMapBuffer )
     {
-      rpcPic->addPrdDepthMapBuffer();
+      rpcPic->addPrdDepthMapBuffer( PDM_SUB_SAMP_EXP_X(uiPdm), PDM_SUB_SAMP_EXP_Y(uiPdm) );
     }
 #endif
@@ -426,5 +430,5 @@
   if( bNeedPrdDepthMapBuffer && !rpcPic->getPredDepthMap() )
   {
-    rpcPic->addPrdDepthMapBuffer();
+    rpcPic->addPrdDepthMapBuffer( PDM_SUB_SAMP_EXP_X(uiPdm), PDM_SUB_SAMP_EXP_Y(uiPdm) );
   }
 #endif
@@ -593,4 +597,7 @@
       m_apcSlicePilot->setSliceIdx(m_uiSliceIdx);
       m_apcSlicePilot->setViewIdx( m_cSPS.getViewId() );
+#if SONY_COLPIC_AVAILABILITY
+      m_apcSlicePilot->setViewOrderIdx( m_cSPS.getViewOrderIdx());
+#endif
       if (!m_bFirstSliceInPicture)
       {
@@ -633,4 +640,8 @@
         pcPic->setViewIdx( m_cSPS.getViewId() );
 
+#if SONY_COLPIC_AVAILABILITY
+        pcPic->setViewOrderIdx( m_cSPS.getViewOrderIdx() );
+#endif
+
         /* transfer any SEI messages that have been received to the picture */
         pcPic->setSEIs(m_SEIs);
@@ -645,5 +656,11 @@
 
 #if DEPTH_MAP_GENERATION
-        m_cDepthMapGenerator.create( true, m_apcSlicePilot->getSPS()->getWidth(), m_apcSlicePilot->getSPS()->getHeight(), g_uiMaxCUDepth, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiBitDepth + g_uiBitIncrement );
+        UInt uiPdm = ( m_cSPS.getViewId() ? m_cSPS.getPredDepthMapGeneration() : getDecTop()->getSPSAccess()->getPdm() );
+        m_cDepthMapGenerator.create( true, m_apcSlicePilot->getSPS()->getWidth(), m_apcSlicePilot->getSPS()->getHeight(), g_uiMaxCUDepth, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiBitDepth + g_uiBitIncrement, PDM_SUB_SAMP_EXP_X(uiPdm), PDM_SUB_SAMP_EXP_Y(uiPdm) );
+        TComDepthMapGenerator* pcDMG0 = getDecTop()->getDecTop0()->getDepthMapGenerator();
+        if( m_cSPS.getViewId() == 1 && ( pcDMG0->getSubSampExpX() != PDM_SUB_SAMP_EXP_X(uiPdm) || pcDMG0->getSubSampExpY() != PDM_SUB_SAMP_EXP_Y(uiPdm) ) )
+        {
+          pcDMG0->create( true, m_apcSlicePilot->getSPS()->getWidth(), m_apcSlicePilot->getSPS()->getHeight(), g_uiMaxCUDepth, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiBitDepth + g_uiBitIncrement, PDM_SUB_SAMP_EXP_X(uiPdm), PDM_SUB_SAMP_EXP_Y(uiPdm) );
+        }
 #endif
 #if HHI_INTER_VIEW_RESIDUAL_PRED
@@ -683,4 +700,7 @@
         pcSlice->setTexturePic( pcTexturePic );
         pcSlice->setViewIdx( pcPic->getViewIdx() );
+#if SONY_COLPIC_AVAILABILITY
+        pcSlice->setViewOrderIdx( pcPic->getViewOrderIdx() );
+#endif
         pcSlice->setRefPicListExplicitlyDecoderSided(m_cListPic, apcSpatRefPics) ;// temporary solution
 
Index: branches/0.2-HHI/source/Lib/TLibDecoder/TDecTop.h
===================================================================
--- branches/0.2-HHI/source/Lib/TLibDecoder/TDecTop.h	(revision 16)
+++ branches/0.2-HHI/source/Lib/TLibDecoder/TDecTop.h	(revision 20)
@@ -140,4 +140,7 @@
   Bool                    m_bIsDepth;
   Int                     m_iViewIdx;
+#if SONY_COLPIC_AVAILABILITY
+  Int                     m_iViewOrderIdx;
+#endif
   TAppDecTop*             m_pcTAppDecTop;
   CamParsCollector*       m_pcCamParsCollector;
@@ -180,4 +183,8 @@
   Void setViewIdx(Int i)					{ m_iViewIdx = i ;}
   Int  getViewIdx()								{ return m_iViewIdx ; }
+#if SONY_COLPIC_AVAILABILITY
+  Void setViewOrderIdx(Int i)					{ m_iViewOrderIdx = i ;}
+  Int  getViewOrderIdx()							{ return m_iViewOrderIdx ; }
+#endif
 
   Void setToDepth(Bool b)         { m_bIsDepth = b ;}
@@ -187,5 +194,8 @@
 
   TComList<TComPic*>*     getListPic            () { return  &m_cListPic;             }
-  TAppDecTop*             getDecTop           ( ){ return  m_pcTAppDecTop ;};
+  TAppDecTop*             getDecTop           ( ){ return  m_pcTAppDecTop ;}
+#if DEPTH_MAP_GENERATION
+  TComDepthMapGenerator*  getDepthMapGenerator  () { return &m_cDepthMapGenerator; }
+#endif
 
   Void                    setSPS                (TComSPS cSPS );
Index: branches/0.2-HHI/source/Lib/TLibEncoder/TEncCfg.h
===================================================================
--- branches/0.2-HHI/source/Lib/TLibEncoder/TEncCfg.h	(revision 16)
+++ branches/0.2-HHI/source/Lib/TLibEncoder/TEncCfg.h	(revision 20)
@@ -355,4 +355,8 @@
 #endif
 
+#if SONY_COLPIC_AVAILABILITY
+  Int       getViewOrderIdx                 ()      { return  m_iViewOrderIdx; }
+#endif
+
 #if HHI_VSO
   //==== VSO  ==========
Index: branches/0.2-HHI/source/Lib/TLibEncoder/TEncSlice.cpp
===================================================================
--- branches/0.2-HHI/source/Lib/TLibEncoder/TEncSlice.cpp	(revision 16)
+++ branches/0.2-HHI/source/Lib/TLibEncoder/TEncSlice.cpp	(revision 20)
@@ -149,4 +149,7 @@
   rpcSlice->initSlice();
   rpcSlice->setPOC( pcPic->getPOC() );
+#if SONY_COLPIC_AVAILABILITY
+  rpcSlice->setViewOrderIdx(m_pcCfg->getViewOrderIdx());
+#endif 
 
   // slice type
Index: branches/0.2-HHI/source/Lib/TLibEncoder/TEncTop.cpp
===================================================================
--- branches/0.2-HHI/source/Lib/TLibEncoder/TEncTop.cpp	(revision 16)
+++ branches/0.2-HHI/source/Lib/TLibEncoder/TEncTop.cpp	(revision 20)
@@ -92,5 +92,5 @@
   m_cLoopFilter.        create( g_uiMaxCUDepth );
 #if DEPTH_MAP_GENERATION
-  m_cDepthMapGenerator. create( false, getSourceWidth(), getSourceHeight(), g_uiMaxCUDepth, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiBitDepth + g_uiBitIncrement );
+  m_cDepthMapGenerator. create( false, getSourceWidth(), getSourceHeight(), g_uiMaxCUDepth, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiBitDepth + g_uiBitIncrement, PDM_SUB_SAMP_EXP_X(m_uiPredDepthMapGeneration), PDM_SUB_SAMP_EXP_Y(m_uiPredDepthMapGeneration) );
 #endif
 #if HHI_INTER_VIEW_RESIDUAL_PRED
@@ -304,5 +304,5 @@
       if( bNeedPrdDepthMapBuf && !pcPic->getPredDepthMap() )
       {
-        pcPic->addPrdDepthMapBuffer();
+        pcPic->addPrdDepthMapBuffer( PDM_SUB_SAMP_EXP_X(m_uiPredDepthMapGeneration), PDM_SUB_SAMP_EXP_Y(m_uiPredDepthMapGeneration) );
       }
 #endif
@@ -798,4 +798,7 @@
   pcPic->setQP(max(MIN_QP,min(MAX_QP, m_iQP+ m_aiTLayerQPOffset[m_cSeqIter.getFrameDescriptor().getTEncSeqStructureLayer(m_uiViewId)] + iQpChangeOffset )) );
   pcPic->setViewIdx( m_uiViewId );
+#if SONY_COLPIC_AVAILABILITY
+  pcPic->setViewOrderIdx(m_iViewOrderIdx);
+#endif
 #if 0
   pcPic->setNumRefs(0, REF_PIC_LIST_0);
