Index: branches/0.2-poznan-univ/source/Lib/TLibEncoder/TEncCavlc.cpp
===================================================================
--- branches/0.2-poznan-univ/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 11)
+++ branches/0.2-poznan-univ/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 12)
@@ -341,4 +341,16 @@
       xWriteFlag( pcSPS->getUseMVI() ? 1 : 0 );
 #endif
+#if POZNAN_NONLINEAR_DEPTH
+      // Depth power coefficient
+#if POZNAN_NONLINEAR_DEPTH_SEND_AS_BYTE
+      UInt  uiCode = quantizeDepthPower(pcSPS->getDepthPower());  
+      xWriteCode(uiCode, 8); 
+#else
+      float fCode  = pcSPS->getDepthPower();
+      UInt  uiCode = *((UInt*)&fCode);
+      //uiCode &= ~0x80000000;
+      xWriteCode(uiCode, sizeof(float)*8); // we do not send sign?;
+#endif
+#endif
     }
     else
@@ -353,7 +365,6 @@
         for( UInt uiId = 0; uiId < pcSPS->getViewId(); uiId++ )
         {
-          //printf("From ViewID %d To ViewID: %d\n",pcSPS->getViewId(),uiId);
-          xWriteSvlc( pcSPS->getCodedScale    ()[ uiId ] ); //printf("SPS Scale: %d\n",pcSPS->getCodedScale    ()[ uiId ]);
-          xWriteSvlc( pcSPS->getCodedOffset   ()[ uiId ] ); //printf("SPS Offset: %d\n", pcSPS->getCodedOffset   ()[ uiId ]);
+          xWriteSvlc( pcSPS->getCodedScale    ()[ uiId ] );
+          xWriteSvlc( pcSPS->getCodedOffset   ()[ uiId ] );
           xWriteSvlc( pcSPS->getInvCodedScale ()[ uiId ] + pcSPS->getCodedScale ()[ uiId ] );
           xWriteSvlc( pcSPS->getInvCodedOffset()[ uiId ] + pcSPS->getCodedOffset()[ uiId ] );
@@ -532,7 +543,6 @@
       for( UInt uiId = 0; uiId < pcSlice->getSPS()->getViewId(); uiId++ )
       {
-        printf("From ViewID %d To ViewID: %d\n",pcSlice->getSPS()->getViewId(),uiId);
-        xWriteSvlc( pcSlice->getCodedScale    ()[ uiId ] ); printf("Slice Scale: %d\n",pcSlice->getCodedScale    ()[ uiId ]);
-        xWriteSvlc( pcSlice->getCodedOffset   ()[ uiId ] ); printf("Slice Offset: %d\n", pcSlice->getCodedOffset   ()[ uiId ]);
+        xWriteSvlc( pcSlice->getCodedScale    ()[ uiId ] );
+        xWriteSvlc( pcSlice->getCodedOffset   ()[ uiId ] );
         xWriteSvlc( pcSlice->getInvCodedScale ()[ uiId ] + pcSlice->getCodedScale ()[ uiId ] );
         xWriteSvlc( pcSlice->getInvCodedOffset()[ uiId ] + pcSlice->getCodedOffset()[ uiId ] );
@@ -729,5 +739,5 @@
 
 
-#if HHI_INTER_VIEW_MOTION_PRED || HHI_MPI
+#if HHI_INTER_VIEW_MOTION_PRED || HHI_MPI || POZNAN_EIVD
 Void 
 TEncCavlc::codeMergeIndexMV( TComDataCU* pcCU, UInt uiAbsPartIdx )
@@ -735,4 +745,14 @@
   UInt uiNumCand  = 0;
   UInt uiMergeIdx = pcCU->getMergeIndex( uiAbsPartIdx );
+
+#if POZNAN_EIVD
+  UInt uiModIdx;
+  const Bool bEIVDAvailable = pcCU->getSlice()->getMP()->isEIVDEnabled();
+  if(bEIVDAvailable)
+  {	  
+	  if(uiMergeIdx==POZNAN_EIVD_MRG_CAND) uiMergeIdx = POZNAN_EIVD_MERGE_POS;
+	  else if(uiMergeIdx>=POZNAN_EIVD_MERGE_POS) uiMergeIdx++;
+  }
+#endif
 #if HHI_MPI
   const Bool bMVIAvailable = pcCU->getSlice()->getSPS()->getUseMVI() && pcCU->getSlice()->getSliceType() != I_SLICE;
@@ -752,4 +772,21 @@
     if( uiIdx < uiMviMergePos )
     {
+#if POZNAN_EIVD
+	  if(bEIVDAvailable)
+	  {
+		  if(uiIdx==POZNAN_EIVD_MERGE_POS) uiModIdx = POZNAN_EIVD_MRG_CAND;
+		  else if(uiIdx>POZNAN_EIVD_MERGE_POS) uiModIdx = uiIdx--;
+		  else uiModIdx = uiIdx;
+	  }
+	  else uiModIdx = uiIdx;
+	  if( pcCU->getNeighbourCandIdx( uiModIdx, uiAbsPartIdx ) == uiModIdx + 1 )
+	  {
+        uiNumCand++;
+      }
+      else if( uiIdx < uiMergeIdx )
+      {
+        uiUnaryIdx--;
+      }
+#else
       if( pcCU->getNeighbourCandIdx( uiIdx, uiAbsPartIdx ) == uiIdx + 1 )
       {
@@ -760,7 +797,25 @@
         uiUnaryIdx--;
       }
+#endif
     }
     else if( uiIdx > uiMviMergePos )
     {
+#if POZNAN_EIVD
+	  if(bEIVDAvailable)
+	  {
+		  if(uiIdx==POZNAN_EIVD_MERGE_POS) uiModIdx = POZNAN_EIVD_MRG_CAND;
+		  else if(uiIdx>POZNAN_EIVD_MERGE_POS) uiModIdx = uiIdx--;
+		  else uiModIdx = uiIdx;
+	  }
+	  else uiModIdx = uiIdx;
+	  if( pcCU->getNeighbourCandIdx( uiModIdx-1, uiAbsPartIdx ) == uiModIdx )
+	  {
+        uiNumCand++;
+      }
+      else if( uiIdx < uiMergeIdx )
+      {
+        uiUnaryIdx--;
+      }
+#else
       if( pcCU->getNeighbourCandIdx( uiIdx - 1, uiAbsPartIdx ) == uiIdx )
       {
@@ -771,4 +826,5 @@
         uiUnaryIdx--;
       }
+#endif
     }
   }
@@ -777,4 +833,21 @@
   for( UInt uiIdx = 0; uiIdx < MRG_MAX_NUM_CANDS; uiIdx++ )
   {
+#if POZNAN_EIVD
+	if(bEIVDAvailable)
+	{
+	  if(uiIdx==POZNAN_EIVD_MERGE_POS) uiModIdx = POZNAN_EIVD_MRG_CAND;
+	  else if(uiIdx>POZNAN_EIVD_MERGE_POS) uiModIdx = uiIdx--;
+	  else uiModIdx = uiIdx;
+	}
+	else uiModIdx = uiIdx;
+	if( pcCU->getNeighbourCandIdx( uiModIdx, uiAbsPartIdx ) == uiModIdx + 1 )
+	{
+	  uiNumCand++;
+	}
+	else if( uiIdx < uiMergeIdx )
+	{
+	  uiUnaryIdx--;
+	}
+#else
     if( pcCU->getNeighbourCandIdx( uiIdx, uiAbsPartIdx ) == uiIdx + 1 )
     {
@@ -785,4 +858,5 @@
       uiUnaryIdx--;
     }
+#endif
   }
 #endif
@@ -808,13 +882,17 @@
 Void TEncCavlc::codeMergeIndex    ( TComDataCU* pcCU, UInt uiAbsPartIdx )
 {
-#if HHI_INTER_VIEW_MOTION_PRED || HHI_MPI
-#if HHI_INTER_VIEW_MOTION_PRED && HHI_MPI
-  if( ( pcCU->getSlice()->getSPS()->getViewId() > 0 && ( pcCU->getSlice()->getSPS()->getMultiviewMvPredMode() & PDM_USE_FOR_MERGE ) == PDM_USE_FOR_MERGE ) ||
-      ( pcCU->getSlice()->getSPS()->getUseMVI() && pcCU->getSlice()->getSliceType() != I_SLICE && pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_2Nx2N ) )
-#elif HHI_MPI
-  if( pcCU->getSlice()->getSPS()->getUseMVI() && pcCU->getSlice()->getSliceType() != I_SLICE && pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_2Nx2N )
-#else
-  if( pcCU->getSlice()->getSPS()->getViewId() > 0 && ( pcCU->getSlice()->getSPS()->getMultiviewMvPredMode() & PDM_USE_FOR_MERGE ) == PDM_USE_FOR_MERGE )
-#endif
+#if HHI_INTER_VIEW_MOTION_PRED || HHI_MPI || POZNAN_EIVD
+  if( 
+#if HHI_INTER_VIEW_MOTION_PRED
+	  ( pcCU->getSlice()->getSPS()->getViewId() > 0 && ( pcCU->getSlice()->getSPS()->getMultiviewMvPredMode() & PDM_USE_FOR_MERGE ) == PDM_USE_FOR_MERGE ) ||
+#endif
+#if HHI_MPI
+	  ( pcCU->getSlice()->getSPS()->getUseMVI() && pcCU->getSlice()->getSliceType() != I_SLICE && pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_2Nx2N ) ||
+#endif
+#if	POZNAN_EIVD  
+	  ( pcCU->getSlice()->getMP()->isEIVDEnabled() ) ||
+#endif
+	  0
+    )
   {
     codeMergeIndexMV( pcCU, uiAbsPartIdx );
Index: branches/0.2-poznan-univ/source/Lib/TLibEncoder/TEncCavlc.h
===================================================================
--- branches/0.2-poznan-univ/source/Lib/TLibEncoder/TEncCavlc.h	(revision 11)
+++ branches/0.2-poznan-univ/source/Lib/TLibEncoder/TEncCavlc.h	(revision 12)
@@ -228,5 +228,5 @@
   Void codeMergeFlag     ( TComDataCU* pcCU, UInt uiAbsPartIdx );
   Void codeMergeIndex    ( TComDataCU* pcCU, UInt uiAbsPartIdx );
-#if HHI_INTER_VIEW_MOTION_PRED || HHI_MPI
+#if HHI_INTER_VIEW_MOTION_PRED || HHI_MPI || POZNAN_EIVD
   Void codeMergeIndexMV  ( TComDataCU* pcCU, UInt uiAbsPartIdx );
 #endif
Index: branches/0.2-poznan-univ/source/Lib/TLibEncoder/TEncCfg.h
===================================================================
--- branches/0.2-poznan-univ/source/Lib/TLibEncoder/TEncCfg.h	(revision 11)
+++ branches/0.2-poznan-univ/source/Lib/TLibEncoder/TEncCfg.h	(revision 12)
@@ -217,4 +217,13 @@
 #endif
 
+#if POZNAN_TEXTURE_TU_DELTA_QP_PARAM_IN_CFG_FOR_ENC 
+  Double      m_dTextureCuDeltaQpOffset;
+  Double      m_dTextureCuDeltaQpMul;
+  Int         m_iTextureCuDeltaQpTopBottomRow; 
+#endif
+#if POZNAN_NONLINEAR_DEPTH
+  Float 	m_fDepthPower;
+#endif
+
 public:
   TEncCfg()          {}
@@ -226,4 +235,9 @@
   Void      setSourceHeight                 ( Int   i )      { m_iSourceHeight = i; }
   Void      setFrameToBeEncoded             ( Int   i )      { m_iFrameToBeEncoded = i; }
+
+#if POZNAN_STAT_JK
+  FILE* m_pcStatFile;
+  Void setStatFile(FILE* a) {m_pcStatFile = a;}
+#endif
 
   //====== Coding Structure ========
@@ -306,4 +320,11 @@
   Void      setAllowNegDist                 ( Bool b  )     { m_bAllowNegDist     = b; };
 #endif
+#endif
+
+#if POZNAN_NONLINEAR_DEPTH
+  inline Float   getDepthPower()               { return m_fDepthPower; }
+  inline Void    setDepthPower(Float p)        { m_fDepthPower = p; }
+#else
+ inline Float    getDepthPower()               { return 1.0f; }
 #endif
 
Index: branches/0.2-poznan-univ/source/Lib/TLibEncoder/TEncCu.cpp
===================================================================
--- branches/0.2-poznan-univ/source/Lib/TLibEncoder/TEncCu.cpp	(revision 11)
+++ branches/0.2-poznan-univ/source/Lib/TLibEncoder/TEncCu.cpp	(revision 12)
@@ -67,8 +67,8 @@
   m_ppcOrigYuv     = new TComYuv*[m_uhTotalDepth-1];
   m_ppcResPredTmp  = new TComYuv*[m_uhTotalDepth-1];
-#if POZNAN_AVAIL_MAP
+#if POZNAN_CU_SKIP
   m_ppcAvailYuv    = new TComYuv*[m_uhTotalDepth-1];
 #endif
-#if POZNAN_SYNTH_VIEW
+#if POZNAN_CU_SYNTH
   m_ppcSynthYuv    = new TComYuv*[m_uhTotalDepth-1];
 #endif
@@ -100,8 +100,8 @@
     m_ppcOrigYuv    [i] = new TComYuv; m_ppcOrigYuv    [i]->create(uiWidth, uiHeight);
 
-#if POZNAN_AVAIL_MAP
+#if POZNAN_CU_SKIP
     m_ppcAvailYuv   [i] = new TComYuv; m_ppcAvailYuv    [i]->create(uiWidth, uiHeight);
 #endif
-#if POZNAN_SYNTH_VIEW
+#if POZNAN_CU_SYNTH
     m_ppcSynthYuv   [i] = new TComYuv; m_ppcSynthYuv    [i]->create(uiWidth, uiHeight);
 #endif
@@ -165,16 +165,16 @@
     if(m_ppcOrigYuv[i])
     {
-      m_ppcOrigYuv[i]->destroy();     delete m_ppcOrigYuv[i];     m_ppcOrigYuv[i]     = NULL;
-    }
-#if POZNAN_AVAIL_MAP
+      m_ppcOrigYuv[i]->destroy();     delete m_ppcOrigYuv[i];     m_ppcOrigYuv[i] = NULL;
+    }
+#if POZNAN_CU_SKIP
     if(m_ppcAvailYuv[i])
     {
-      m_ppcAvailYuv[i]->destroy();    delete m_ppcAvailYuv[i];    m_ppcAvailYuv[i]    = NULL;
-    }
-#endif
-#if POZNAN_SYNTH_VIEW
+      m_ppcAvailYuv[i]->destroy();     delete m_ppcAvailYuv[i];   m_ppcAvailYuv[i] = NULL;
+    }
+#endif
+#if POZNAN_CU_SYNTH
     if(m_ppcSynthYuv[i])
     {
-      m_ppcSynthYuv[i]->destroy();    delete m_ppcSynthYuv[i];    m_ppcSynthYuv[i]    = NULL;
+      m_ppcSynthYuv[i]->destroy();     delete m_ppcSynthYuv[i];   m_ppcSynthYuv[i] = NULL;
     }
 #endif
@@ -230,5 +230,5 @@
     m_ppcOrigYuv = NULL;
   }
-#if POZNAN_AVAIL_MAP
+#if POZNAN_CU_SKIP
   if(m_ppcAvailYuv)
   {
@@ -237,5 +237,5 @@
   }
 #endif
-#if POZNAN_SYNTH_VIEW
+#if POZNAN_CU_SYNTH
   if(m_ppcSynthYuv)
   {
@@ -395,4 +395,10 @@
     }
   }
+
+#if POZNAN_EIVD & !POZNAN_EIVD_COMPRESS_ME_DATA
+  //save motion data for every CU point
+  xSaveEIVDData(m_ppcBestCU[0]);
+#endif
+
 }
 
@@ -467,12 +473,12 @@
   // get Original YUV data from picture
   m_ppcOrigYuv[uiDepth]->copyFromPicYuv( pcPic->getPicYuvOrg(), rpcBestCU->getAddr(), rpcBestCU->getZorderIdxInCU() );
-#if POZNAN_AVAIL_MAP
+#if POZNAN_CU_SKIP
   if (pcPic->getPicYuvAvail())  m_ppcAvailYuv[uiDepth]->copyFromPicYuv( pcPic->getPicYuvAvail(), rpcBestCU->getAddr(), rpcBestCU->getZorderIdxInCU() );
 #endif  
-#if POZNAN_SYNTH_VIEW
+#if POZNAN_CU_SYNTH
   if (pcPic->getPicYuvSynth())  m_ppcSynthYuv[uiDepth]->copyFromPicYuv( pcPic->getPicYuvSynth(), rpcBestCU->getAddr(), rpcBestCU->getZorderIdxInCU() );
 #endif
 
-#if POZNAN_ENCODE_ONLY_DISOCCLUDED_CU
+#if POZNAN_CU_SKIP
   Bool bWholeCUCanBeSynthesized = false;
   Bool bOneSubCUCanNotBeSynthesied = false;
@@ -569,7 +575,8 @@
   {
     // do CU Skip
-#if POZNAN_ENCODE_ONLY_DISOCCLUDED_CU
+#if POZNAN_CU_SKIP
     if(bWholeCUCanBeSynthesized)
     {
+//      printf("CUSkip %d %d %d\n",rpcBestCU->getCUPelX(),rpcBestCU->getCUPelY(),rpcBestCU->getWidth());
       rpcBestCU->getTotalCost() = 0;       // Cost of synthesised CU is zero
       rpcBestCU->getTotalBits() = 0;       // Cost of synthesised CU is zero
@@ -577,8 +584,7 @@
       rpcBestCU->setPredModeSubParts( MODE_SYNTH,      0, uiDepth );
       rpcBestCU->setPartSizeSubParts( SIZE_2Nx2N,      0, uiDepth );
-#if POZNAN_FILL_OCCLUDED_CU_WITH_SYNTHESIS
+#if POZNAN_CU_SYNTH
       m_ppcRecoYuvBest[uiDepth]->copyFromPicYuv(pcPic->getPicYuvSynth(), rpcBestCU->getAddr(), rpcBestCU->getZorderIdxInCU()); // First copy synthesis YUV part to CU encoder reconstruction YUV structure
-#else
-      m_ppcRecoYuvBest[uiDepth]->copyFromPicYuv(pcPic->getPicYuvAvail(), rpcBestCU->getAddr(), rpcBestCU->getZorderIdxInCU()); // First copy synthesis YUV part to CU encoder reconstruction YUV structure
+      //m_ppcRecoYuvBest[uiDepth]->copyFromPicYuv(pcPic->getPicYuvAvail(), rpcBestCU->getAddr(), rpcBestCU->getZorderIdxInCU()); // First copy synthesis YUV part to CU encoder reconstruction YUV structure
 #endif
       UInt uiInitTrDepth  = rpcBestCU->getPartitionSize(0) == SIZE_2Nx2N ? 0 : 1;
@@ -1065,5 +1071,5 @@
   TComPic* pcPic = pcCU->getPic();
 
-#if POZNAN_ENCODE_ONLY_DISOCCLUDED_CU
+#if POZNAN_CU_SKIP
   if( pcCU->isCUSkiped( uiAbsPartIdx ) && uiDepth == pcCU->getDepth( uiAbsPartIdx )) //If CU Skiped no information is coded into stream
     return;
@@ -1076,5 +1082,5 @@
   UInt uiBPelY   = uiTPelY + (g_uiMaxCUHeight>>uiDepth) - 1;
 
-#if POZNAN_ENCODE_ONLY_DISOCCLUDED_CU
+#if POZNAN_CU_SKIP
   Bool bDontSendSplitFlag = false;
   if( ( ( uiDepth < pcCU->getDepth( uiAbsPartIdx ) ) && ( uiDepth < (g_uiMaxCUDepth-g_uiAddCUDepth) ) ) || bBoundary ) //check if CU has 3 synthesied subCU - no split flag is send in that case
@@ -1099,5 +1105,5 @@
   if( ( uiRPelX < pcCU->getSlice()->getSPS()->getWidth() ) && ( uiBPelY < pcCU->getSlice()->getSPS()->getHeight() ) )
   {
-#if POZNAN_ENCODE_ONLY_DISOCCLUDED_CU
+#if POZNAN_CU_SKIP
     if(!bDontSendSplitFlag)
 #endif
@@ -1141,4 +1147,9 @@
 #endif
       xRestoreDepthWidthHeight( pcCU );
+
+#if POZNAN_STAT_JK
+	  if(m_bStatFileEnabled) xStatFile(pcCU, uiAbsPartIdx, uiDepth);
+#endif
+
       return;
     }
@@ -1167,4 +1178,8 @@
     return;
   }
+
+#if POZNAN_STAT_JK
+  if(m_bStatFileEnabled) xStatFile(pcCU, uiAbsPartIdx, uiDepth);
+#endif
 
 #if TSB_ALF_HEADER
@@ -1277,4 +1292,7 @@
   UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS];
   UInt uiNeighbourCandIdx[MRG_MAX_NUM_CANDS]; //MVs with same idx => same cand
+#if POZNAN_EIVD_CALC_PRED_DATA
+  TComMP* pcMP = rpcTempCU->getSlice()->getMP();
+#endif
 
 #if HHI_INTER_VIEW_RESIDUAL_PRED
@@ -1333,6 +1351,16 @@
         rpcTempCU->setNeighbourCandIdxSubParts( uiInner, uiNeighbourCandIdx[uiInner], 0, 0,uhDepth );
       }
+#if POZNAN_EIVD_CALC_PRED_DATA
+	  if(uiMergeCand==POZNAN_EIVD_MRG_CAND)
+	  {
+		rpcTempCU->getCUMvField2nd( REF_PIC_LIST_0 )->setAllMvField( cMvFieldNeighbours[0 + 2*uiMergeCand].getMv(), cMvFieldNeighbours[0 + 2*uiMergeCand].getRefIdx(), SIZE_2Nx2N, 0, 0, 0 ); // interprets depth relative to rpcTempCU level
+		rpcTempCU->getCUMvField2nd( REF_PIC_LIST_1 )->setAllMvField( cMvFieldNeighbours[1 + 2*uiMergeCand].getMv(), cMvFieldNeighbours[1 + 2*uiMergeCand].getRefIdx(), SIZE_2Nx2N, 0, 0, 0 ); // interprets depth relative to rpcTempCU level
+	  }
+	  else
+#endif
+	  {
       rpcTempCU->getCUMvField( REF_PIC_LIST_0 )->setAllMvField( cMvFieldNeighbours[0 + 2*uiMergeCand].getMv(), cMvFieldNeighbours[0 + 2*uiMergeCand].getRefIdx(), SIZE_2Nx2N, 0, 0, 0 ); // interprets depth relative to rpcTempCU level
       rpcTempCU->getCUMvField( REF_PIC_LIST_1 )->setAllMvField( cMvFieldNeighbours[1 + 2*uiMergeCand].getMv(), cMvFieldNeighbours[1 + 2*uiMergeCand].getRefIdx(), SIZE_2Nx2N, 0, 0, 0 ); // interprets depth relative to rpcTempCU level
+	  }
 
 #if HHI_INTER_VIEW_RESIDUAL_PRED
@@ -1348,5 +1376,18 @@
       if ( uiNoResidual == 0 ){
 #endif
+
+#if POZNAN_EIVD
+		if(uiMergeCand==POZNAN_EIVD_MRG_CAND){
+			m_pcPredSearch->motionCompensation_EIVD ( rpcTempCU, m_ppcPredYuvTemp[uhDepth] );
+#if POZNAN_EIVD_CALC_PRED_DATA		
+		  pcMP->setEIVDPredMVField(REF_PIC_LIST_0, rpcTempCU);
+		  pcMP->setEIVDPredMVField(REF_PIC_LIST_1, rpcTempCU);
+#endif
+		}
+		else
         m_pcPredSearch->motionCompensation ( rpcTempCU, m_ppcPredYuvTemp[uhDepth] );
+#else 
+        m_pcPredSearch->motionCompensation ( rpcTempCU, m_ppcPredYuvTemp[uhDepth] );
+#endif
         // save pred adress
         pcPredYuvTemp = m_ppcPredYuvTemp[uhDepth];
@@ -1358,4 +1399,12 @@
           pcPredYuvTemp = m_ppcPredYuvBest[uhDepth];
         }
+#if POZNAN_EIVD_CALC_PRED_DATA
+	    if(uiMergeCand==POZNAN_EIVD_MRG_CAND)
+	    {
+	      //copy motion data representing CU with EIVD for uiNoResidual==0 case		
+	      rpcTempCU->getCUMvField( REF_PIC_LIST_0 )->copyFrom(pcMP->getEIVDPredMVField(REF_PIC_LIST_0),rpcTempCU->getTotalNumPart(),0);
+	      rpcTempCU->getCUMvField( REF_PIC_LIST_1 )->copyFrom(pcMP->getEIVDPredMVField(REF_PIC_LIST_1),rpcTempCU->getTotalNumPart(),0);
+	    }
+#endif
       }
 #if HHI_VSO
@@ -1381,6 +1430,17 @@
       Bool bQtRootCbf = rpcTempCU->getQtRootCbf(0) == 1;
 #else
+#if POZNAN_EIVD
       // do MC
+	  if(uiMergeCand==POZNAN_EIVD_MRG_CAND){
+		 m_pcPredSearch->motionCompensation_EIVD ( rpcTempCU, m_ppcPredYuvTemp[uhDepth] );
+#if POZNAN_EIVD_CALC_PRED_DATA		
+		 pcMP->setEIVDPredMVField(REF_PIC_LIST_0, rpcTempCU);
+		 pcMP->setEIVDPredMVField(REF_PIC_LIST_1, rpcTempCU);
+#endif		
+	  }
+	  else
       m_pcPredSearch->motionCompensation ( rpcTempCU, m_ppcPredYuvTemp[uhDepth] );
+
+#endif
 
       // estimate residual and encode everything
@@ -1671,5 +1731,5 @@
     {
       if( pcTextureCU->isIntra( rpcTempCU->getZorderIdxInCU() + ui ) 
-#if POZNAN_ENCODE_ONLY_DISOCCLUDED_CU
+#if POZNAN_CU_SKIP
         || pcTextureCU->isCUSkiped( rpcTempCU->getZorderIdxInCU() + ui )
 #endif
Index: branches/0.2-poznan-univ/source/Lib/TLibEncoder/TEncCu.h
===================================================================
--- branches/0.2-poznan-univ/source/Lib/TLibEncoder/TEncCu.h	(revision 11)
+++ branches/0.2-poznan-univ/source/Lib/TLibEncoder/TEncCu.h	(revision 12)
@@ -78,11 +78,11 @@
   TComYuv**               m_ppcOrigYuv;     ///< Original Yuv for each depth
   TComYuv**               m_ppcResPredTmp;  ///< Temporary residual prediction for each depth
-#if POZNAN_AVAIL_MAP
+#if POZNAN_CU_SKIP
   TComYuv**               m_ppcAvailYuv;    ///< Avaiability map for each depth  
 #endif
-#if POZNAN_SYNTH_VIEW
+#if POZNAN_CU_SYNTH
   TComYuv**               m_ppcSynthYuv;    ///< Synthetized Yuv for each depth
 #endif
-
+  
   //  Data : encoder control
   Int                     m_iQp;            ///< Last QP
@@ -113,4 +113,8 @@
 #endif
 
+#if POZNAN_STAT_JK
+  Bool m_bStatFileEnabled;
+#endif
+
 public:
   /// copy parameters from encoder class
@@ -131,4 +135,8 @@
   /// set QP value
   Void  setQpLast           ( Int iQp ) { m_iQp = iQp; }
+  
+#if POZNAN_STAT_JK
+  Void setStatFileEnabled(Bool bStatFileEnabled){m_bStatFileEnabled = bStatFileEnabled;}
+#endif
   
 protected:
@@ -162,4 +170,12 @@
   Void  xRestoreDepthWidthHeight( TComDataCU* pcCU );
 #endif
+
+#if POZNAN_EIVD & !POZNAN_EIVD_COMPRESS_ME_DATA
+  Void  xSaveEIVDData(TComDataCU* pcCU) { pcCU->getSlice()->getMP()->saveEIVDData(pcCU);}
+#endif
+
+#if POZNAN_STAT_JK
+  Void	xStatFile			( TComDataCU*  pcCU, UInt uiAbsPartIdx,           UInt uiDepth        );
+#endif
 };
 
Index: branches/0.2-poznan-univ/source/Lib/TLibEncoder/TEncGOP.cpp
===================================================================
--- branches/0.2-poznan-univ/source/Lib/TLibEncoder/TEncGOP.cpp	(revision 11)
+++ branches/0.2-poznan-univ/source/Lib/TLibEncoder/TEncGOP.cpp	(revision 12)
@@ -293,4 +293,16 @@
 #endif
 
+#if POZNAN_MP    
+#if POZNAN_MP_USE_DEPTH_MAP_GENERATION
+	  pcSlice->getMP()->setDepthMapGenerator(m_pcDepthMapGenerator);
+#else
+      std::vector<TComPic*> apcSpatDepthRefPics = m_pcEncTop->getEncTop()->getSpatialRefPics( pcPic->getViewIdx(), pcSlice->getPOC(), true );
+	  pcSlice->getMP()->setDepthRefPicsList(&apcSpatDepthRefPics);
+#endif
+	  std::vector<TComPic*> apcSpatDataRefPics = m_pcEncTop->getEncTop()->getSpatialRefPics( pcPic->getViewIdx(), pcSlice->getPOC(), m_pcEncTop->isDepthCoder() );
+	  pcSlice->getMP()->setRefPicsList(&apcSpatDataRefPics);
+	  pcSlice->getMP()->pairMultiview(pcPic);
+#endif
+
       while(uiNextCUAddr<pcPic->getPicSym()->getNumberOfCUsInFrame()) // determine slice boundaries
       {
@@ -615,4 +627,8 @@
       pcBitstreamOut->convertRBSPToPayload(0);
 
+#if POZNAN_MP
+	  pcSlice->getMP()->disable();
+#endif
+
 /*#if AMVP_BUFFERCOMPRESS
       pcPic->compressMotion(); // moved to end of access unit
@@ -822,8 +838,8 @@
   if(pAvail)
   {
-    for( y = 0; y < iHeight; y++ )
-    {
-      for( x = 0; x < iWidth; x++ )
-      {
+  for( y = 0; y < iHeight; y++ )
+  {
+    for( x = 0; x < iWidth; x++ )
+    {
         if(pAvail[x]==0) //If pixel was codded
         {
@@ -847,10 +863,10 @@
       for( x = 0; x < iWidth; x++ )
       {
-        Int iDiff = (Int)( pOrg[x] - pRec[x] );
-        uiSSDY   += iDiff * iDiff;
-      }
-      pOrg += iStride;
-      pRec += iStride;
-    }
+      Int iDiff = (Int)( pOrg[x] - pRec[x] );
+      uiSSDY   += iDiff * iDiff;
+    }
+    pOrg += iStride;
+    pRec += iStride;
+  }
   }
 
@@ -869,92 +885,92 @@
   {
 #if POZNAN_CU_SKIP_PSNR
-    if(pAvail)
-    {
-      iHeight >>= 1;
-      iWidth  >>= 1;
-      iStride >>= 1;
-    
-      pOrg  = pcPic ->getPicYuvOrg()->getCbAddr();
-      pRec  = pcPicD->getCbAddr();
-      pAvail  = pcPic ->getPicYuvAvail()->getLumaAddr();
-      iPixelsCnt = 0;
-
-      for( y = 0; y < iHeight; y++ )
-      {
-        for( x = 0; x < iWidth; x++ )
-        {
-          if(pAvail[x<<1]==0||pAvail[(x<<1)+1]==0||
-             pAvail[(x+iStride)<<1]==0||pAvail[((x+iStride)<<1)+1]==0) //If pixel was codded
-          {
-            Int iDiff = (Int)( pOrg[x] - pRec[x] );
-            uiSSDU   += iDiff * iDiff;
-            iPixelsCnt++;
-          }
-        }
-        pOrg += iStride;
-        pRec += iStride;
-        pAvail+= (iStride<<2);
-      }
-      
-      fRefValueC = (double) maxval * maxval * iPixelsCnt;
-
-      pOrg  = pcPic ->getPicYuvOrg()->getCrAddr();
-      pRec  = pcPicD->getCrAddr();
-      pAvail  = pcPic ->getPicYuvAvail()->getLumaAddr();
-      for( y = 0; y < iHeight; y++ )
-      {
-        for( x = 0; x < iWidth; x++ )
-        {
-          if(pAvail[x<<1]==0||pAvail[(x<<1)+1]==0||
-             pAvail[(x+iStride)<<1]==0||pAvail[((x+iStride)<<1)+1]==0) //If pixel was codded
-          {
-            Int iDiff = (Int)( pOrg[x] - pRec[x] );
-            uiSSDV   += iDiff * iDiff;
-          }
-        }
-        pOrg += iStride;
-        pRec += iStride;
-        pAvail+= iStride<<2;
-      }
-    }
-    else
-#endif
-    {
-      iHeight >>= 1;
-      iWidth  >>= 1;
-      iStride >>= 1;
-
-      pOrg  = pcPic ->getPicYuvOrg()->getCbAddr();
-      pRec  = pcPicD->getCbAddr();
-
-      for( y = 0; y < iHeight; y++ )
-      {
-        for( x = 0; x < iWidth; x++ )
+  if(pAvail)
+  {
+    iHeight >>= 1;
+    iWidth  >>= 1;
+    iStride >>= 1;
+  
+    pOrg  = pcPic ->getPicYuvOrg()->getCbAddr();
+    pRec  = pcPicD->getCbAddr();
+    pAvail  = pcPic ->getPicYuvAvail()->getLumaAddr();
+    iPixelsCnt = 0;
+
+    for( y = 0; y < iHeight; y++ )
+    {
+      for( x = 0; x < iWidth; x++ )
+      {
+        if(pAvail[x<<1]==0||pAvail[(x<<1)+1]==0||
+           pAvail[(x+iStride)<<1]==0||pAvail[((x+iStride)<<1)+1]==0) //If pixel was codded
         {
           Int iDiff = (Int)( pOrg[x] - pRec[x] );
           uiSSDU   += iDiff * iDiff;
-        }
-        pOrg += iStride;
-        pRec += iStride;
-      }
-
-      pOrg  = pcPic ->getPicYuvOrg()->getCrAddr();
-      pRec  = pcPicD->getCrAddr();
-
-      for( y = 0; y < iHeight; y++ )
-      {
-        for( x = 0; x < iWidth; x++ )
+          iPixelsCnt++;
+        }
+      }
+      pOrg += iStride;
+      pRec += iStride;
+        pAvail+= (iStride<<2);
+    }
+
+    fRefValueC = (double) maxval * maxval * iPixelsCnt;
+
+    pOrg  = pcPic ->getPicYuvOrg()->getCrAddr();
+    pRec  = pcPicD->getCrAddr();
+    pAvail  = pcPic ->getPicYuvAvail()->getLumaAddr();
+    for( y = 0; y < iHeight; y++ )
+    {
+      for( x = 0; x < iWidth; x++ )
+      {
+        if(pAvail[x<<1]==0||pAvail[(x<<1)+1]==0||
+           pAvail[(x+iStride)<<1]==0||pAvail[((x+iStride)<<1)+1]==0) //If pixel was codded
         {
           Int iDiff = (Int)( pOrg[x] - pRec[x] );
           uiSSDV   += iDiff * iDiff;
         }
-        pOrg += iStride;
-        pRec += iStride;
-      }
-    }
-
-    dYPSNR            = ( uiSSDY ? 10.0 * log10( fRefValueY / (Double)uiSSDY ) : 99.99 );
-    dUPSNR            = ( uiSSDU ? 10.0 * log10( fRefValueC / (Double)uiSSDU ) : 99.99 );
-    dVPSNR            = ( uiSSDV ? 10.0 * log10( fRefValueC / (Double)uiSSDV ) : 99.99 );
+      }
+      pOrg += iStride;
+      pRec += iStride;
+        pAvail+= iStride<<2;
+    }
+  }
+  else
+#endif
+  {
+  iHeight >>= 1;
+  iWidth  >>= 1;
+  iStride >>= 1;
+
+  pOrg  = pcPic ->getPicYuvOrg()->getCbAddr();
+  pRec  = pcPicD->getCbAddr();
+
+  for( y = 0; y < iHeight; y++ )
+  {
+    for( x = 0; x < iWidth; x++ )
+    {
+      Int iDiff = (Int)( pOrg[x] - pRec[x] );
+      uiSSDU   += iDiff * iDiff;
+    }
+    pOrg += iStride;
+    pRec += iStride;
+  }
+
+  pOrg  = pcPic ->getPicYuvOrg()->getCrAddr();
+  pRec  = pcPicD->getCrAddr();
+
+  for( y = 0; y < iHeight; y++ )
+  {
+    for( x = 0; x < iWidth; x++ )
+    {
+      Int iDiff = (Int)( pOrg[x] - pRec[x] );
+      uiSSDV   += iDiff * iDiff;
+    }
+    pOrg += iStride;
+    pRec += iStride;
+  }
+  }
+
+  dYPSNR            = ( uiSSDY ? 10.0 * log10( fRefValueY / (Double)uiSSDY ) : 99.99 );
+  dUPSNR            = ( uiSSDU ? 10.0 * log10( fRefValueC / (Double)uiSSDU ) : 99.99 );
+  dVPSNR            = ( uiSSDV ? 10.0 * log10( fRefValueC / (Double)uiSSDV ) : 99.99 );
   }
   // fix: total bits should consider slice size bits (32bit)
Index: branches/0.2-poznan-univ/source/Lib/TLibEncoder/TEncSbac.h
===================================================================
--- branches/0.2-poznan-univ/source/Lib/TLibEncoder/TEncSbac.h	(revision 11)
+++ branches/0.2-poznan-univ/source/Lib/TLibEncoder/TEncSbac.h	(revision 12)
@@ -166,5 +166,5 @@
   Void codeMergeFlag     ( TComDataCU* pcCU, UInt uiAbsPartIdx );
   Void codeMergeIndex    ( TComDataCU* pcCU, UInt uiAbsPartIdx );
-#if HHI_INTER_VIEW_MOTION_PRED || HHI_MPI
+#if HHI_INTER_VIEW_MOTION_PRED || HHI_MPI || POZNAN_EIVD
   Void codeMergeIndexMV  ( TComDataCU* pcCU, UInt uiAbsPartIdx );
 #endif
Index: branches/0.2-poznan-univ/source/Lib/TLibEncoder/TEncSearch.cpp
===================================================================
--- branches/0.2-poznan-univ/source/Lib/TLibEncoder/TEncSearch.cpp	(revision 11)
+++ branches/0.2-poznan-univ/source/Lib/TLibEncoder/TEncSearch.cpp	(revision 12)
@@ -1042,5 +1042,9 @@
   UInt uiAbsSum = 0;
   pcCU       ->setTrIdxSubParts ( uiTrDepth, uiAbsPartIdx, uiFullDepth );
+#if POZNAN_TEXTURE_TU_DELTA_QP_ACCORDING_TO_DEPTH
+  m_pcTrQuant->setQPforQuant    ( pcCU->getQP( 0 ) + pcCU->getQpOffsetForTextCU(uiAbsPartIdx, true), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), TEXT_LUMA );
+#else
   m_pcTrQuant->setQPforQuant    ( pcCU->getQP( 0 ), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), TEXT_LUMA );
+#endif
   m_pcTrQuant->transformNxN     ( pcCU, piResi, uiStride, pcCoeff, uiWidth, uiHeight, uiAbsSum, TEXT_LUMA, uiAbsPartIdx );
 
@@ -1208,5 +1212,9 @@
     //--- transform and quantization ---
     UInt uiAbsSum = 0;
+#if POZNAN_TEXTURE_TU_DELTA_QP_ACCORDING_TO_DEPTH
+  m_pcTrQuant->setQPforQuant       ( pcCU->getQP( 0 ) + pcCU->getQpOffsetForTextCU(uiAbsPartIdx, true), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), TEXT_CHROMA );
+#else
     m_pcTrQuant->setQPforQuant     ( pcCU->getQP( 0 ), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), TEXT_CHROMA );
+#endif
     m_pcTrQuant->transformNxN      ( pcCU, piResi, uiStride, pcCoeff, uiWidth, uiHeight, uiAbsSum, eText, uiAbsPartIdx );
     //--- set coded block flag ---
@@ -2814,4 +2822,50 @@
 }
 
+#if POZNAN_EIVD
+Void TEncSearch::xGetInterPredictionError_EIVD( TComDataCU* pcCU, TComYuv* pcYuvOrg, Int iPartIdx, UInt& ruiErr, Bool bHadamard )
+{
+  TComYuv cYuvPred;
+  cYuvPred.create( pcYuvOrg->getWidth(), pcYuvOrg->getHeight() );
+
+#ifdef WEIGHT_PRED
+  UInt uiAbsPartIdx = 0;
+  Int iWidth = 0;
+  Int iHeight = 0;
+  //Int iRefIdx[2];
+  pcCU->getPartIndexAndSize( iPartIdx, uiAbsPartIdx, iWidth, iHeight );
+
+//???????????????????????????????????????????????????????????????????????????????????
+  //iRefIdx[0] = pcCU->getCUMvField( REF_PIC_LIST_0 )->getRefIdx( uiAbsPartIdx );
+  //iRefIdx[1] = pcCU->getCUMvField( REF_PIC_LIST_1 )->getRefIdx( uiAbsPartIdx );
+  //if ( iRefIdx[0]>=0 && iRefIdx[1]<1 )
+  //  setWpScalingDistParam( pcCU, iRefIdx[0], iRefIdx[1], REF_PIC_LIST_0);
+  //else
+  //  setWpScalingDistParam( pcCU, iRefIdx[0], iRefIdx[1], REF_PIC_LIST_1);
+  setWpScalingDistParam( pcCU, -1, -1, REF_PIC_LIST_X);//???
+//???????????????????????????????????????????????????????????????????????????????????
+  motionCompensation_EIVD( pcCU, &cYuvPred, REF_PIC_LIST_X, iPartIdx );
+#else
+  motionCompensation_EIVD( pcCU, &cYuvPred, REF_PIC_LIST_X, iPartIdx );
+
+  UInt uiAbsPartIdx = 0;
+  Int iWidth = 0;
+  Int iHeight = 0;
+  pcCU->getPartIndexAndSize( iPartIdx, uiAbsPartIdx, iWidth, iHeight );
+#endif
+
+  DistParam cDistParam;
+#ifdef WEIGHT_PRED
+  cDistParam.applyWeight = false;
+#endif
+  m_pcRdCost->setDistParam( cDistParam, 
+                            pcYuvOrg->getLumaAddr( uiAbsPartIdx ), pcYuvOrg->getStride(), 
+                            cYuvPred .getLumaAddr( uiAbsPartIdx ), cYuvPred .getStride(), 
+                            iWidth, iHeight, m_pcEncCfg->getUseHADME() );
+  ruiErr = cDistParam.DistFunc( &cDistParam );
+
+  cYuvPred.destroy();
+}
+#endif
+
 /** estimation of best merge coding
  * \param pcCU
@@ -2875,8 +2929,25 @@
       PartSize ePartSize = pcCU->getPartitionSize( 0 );
 
+#if POZNAN_EIVD_CALC_PRED_DATA
+	  if(uiMergeCand==POZNAN_EIVD_MRG_CAND)
+	  {
+		pcCU->getCUMvField2nd( REF_PIC_LIST_0 )->setAllMvField( cMvFieldNeighbours[0 + 2*uiMergeCand].getMv(), cMvFieldNeighbours[0 + 2*uiMergeCand].getRefIdx(), ePartSize, uiAbsPartIdx, iPUIdx, 0 );
+		pcCU->getCUMvField2nd( REF_PIC_LIST_1 )->setAllMvField( cMvFieldNeighbours[1 + 2*uiMergeCand].getMv(), cMvFieldNeighbours[1 + 2*uiMergeCand].getRefIdx(), ePartSize, uiAbsPartIdx, iPUIdx, 0 );
+	  }
+	  else
+#endif
+	  {
       pcCU->getCUMvField(REF_PIC_LIST_0)->setAllMvField( cMvFieldNeighbours[0 + 2*uiMergeCand].getMv(), cMvFieldNeighbours[0 + 2*uiMergeCand].getRefIdx(), ePartSize, uiAbsPartIdx, iPUIdx, 0 );
       pcCU->getCUMvField(REF_PIC_LIST_1)->setAllMvField( cMvFieldNeighbours[1 + 2*uiMergeCand].getMv(), cMvFieldNeighbours[1 + 2*uiMergeCand].getRefIdx(), ePartSize, uiAbsPartIdx, iPUIdx, 0 );
-
+	  }
+
+#if POZNAN_EIVD
+	  if(uiMergeCand==POZNAN_EIVD_MRG_CAND)
+		xGetInterPredictionError_EIVD( pcCU, pcYuvOrg, iPUIdx, uiCostCand, m_pcEncCfg->getUseHADME() );
+	  else
       xGetInterPredictionError( pcCU, pcYuvOrg, iPUIdx, uiCostCand, m_pcEncCfg->getUseHADME() );
+#else
+      xGetInterPredictionError( pcCU, pcYuvOrg, iPUIdx, uiCostCand, m_pcEncCfg->getUseHADME() );
+#endif
 
       if( uiNumCand == 1 )
@@ -2886,19 +2957,32 @@
       else
       {
-        if( uiMergeCand == 0 || uiNumCand == 2 )
+        UInt uiMergeCandIdx = uiMergeCand;
+#if POZNAN_EIVD
+		if(pcCU->getSlice()->getMP()->isEIVDEnabled())
+		{
+			if(uiMergeCand == POZNAN_EIVD_MRG_CAND) uiMergeCandIdx = POZNAN_EIVD_MERGE_POS;
+			else if(uiMergeCand >= POZNAN_EIVD_MERGE_POS) uiMergeCandIdx++;
+		}
+#endif
+
+        if( uiMergeCandIdx == 0 || uiNumCand == 2 )
         {
           uiBitsCand = 2;
         }
-        else if( uiMergeCand == 1 || uiNumCand == 3 )
+        else if( uiMergeCandIdx == 1 || uiNumCand == 3 )
         {
           uiBitsCand = 3;
         }
-        else if( uiMergeCand == 2 || uiNumCand == 4 )
+        else if( uiMergeCandIdx == 2 || uiNumCand == 4 )
         {
           uiBitsCand = 4;
         }
+		else if( uiMergeCandIdx == 3 || uiNumCand == 5 )
+        {
+          uiBitsCand = 5;
+        }
         else
         {
-          uiBitsCand = 5;
+          uiBitsCand = 6;
         }
       }
@@ -2910,4 +2994,20 @@
         pacMvField[0] = cMvFieldNeighbours[0 + 2*uiMergeCand];
         pacMvField[1] = cMvFieldNeighbours[1 + 2*uiMergeCand];
+
+#if POZNAN_EIVD_CALC_PRED_DATA
+		if(uiMergeCand==POZNAN_EIVD_MRG_CAND)
+		{
+			TComCUMvField* pcEIVDPredMvField;
+
+			pcEIVDPredMvField = pcCU->getSlice()->getMP()->getEIVDPredMVField(REF_PIC_LIST_0);
+			pcEIVDPredMvField->setMv(pcCU->getCUMvField(REF_PIC_LIST_0)->getMv(uiAbsPartIdx),0);
+			pcEIVDPredMvField->setRefIdx(pcCU->getCUMvField(REF_PIC_LIST_0)->getRefIdx(uiAbsPartIdx),0);
+
+			pcEIVDPredMvField = pcCU->getSlice()->getMP()->getEIVDPredMVField(REF_PIC_LIST_1);
+			pcEIVDPredMvField->setMv(pcCU->getCUMvField(REF_PIC_LIST_1)->getMv(uiAbsPartIdx),0);
+			pcEIVDPredMvField->setRefIdx(pcCU->getCUMvField(REF_PIC_LIST_1)->getRefIdx(uiAbsPartIdx),0);
+		}
+#endif
+
         uiInterDir = uhInterDirNeighbours[uiMergeCand];
         uiMergeIndex = uiMergeCand;
@@ -3604,4 +3704,19 @@
         pcCU->setMergeIndexSubParts( uiMRGIndex,    uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) );
         pcCU->setInterDirSubParts  ( uiMRGInterDir, uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) );
+
+#if POZNAN_EIVD_CALC_PRED_DATA
+		if(uiMRGIndex==POZNAN_EIVD_MRG_CAND)
+		{
+			TComCUMvField* pcEIVDPredMvField;
+			pcEIVDPredMvField = pcCU->getSlice()->getMP()->getEIVDPredMVField(REF_PIC_LIST_0);
+			pcCU->getCUMvField( REF_PIC_LIST_0 )->setAllMvField( pcEIVDPredMvField->getMv(0), pcEIVDPredMvField->getRefIdx(0), ePartSize, uiPartAddr, iPartIdx, 0 );			
+			pcEIVDPredMvField = pcCU->getSlice()->getMP()->getEIVDPredMVField(REF_PIC_LIST_1);
+			pcCU->getCUMvField( REF_PIC_LIST_1 )->setAllMvField( pcEIVDPredMvField->getMv(0), pcEIVDPredMvField->getRefIdx(0), ePartSize, uiPartAddr, iPartIdx, 0 );
+
+			pcCU->getCUMvField2nd( REF_PIC_LIST_0 )->setAllMvField( cMRGMvField[0].getMv(), cMRGMvField[0].getRefIdx(), ePartSize, uiPartAddr, iPartIdx, 0 );
+			pcCU->getCUMvField2nd( REF_PIC_LIST_1 )->setAllMvField( cMRGMvField[1].getMv(), cMRGMvField[1].getRefIdx(), ePartSize, uiPartAddr, iPartIdx, 0 );
+		}
+		else
+#endif
         {
           pcCU->getCUMvField( REF_PIC_LIST_0 )->setAllMvField( cMRGMvField[0].getMv(), cMRGMvField[0].getRefIdx(), ePartSize, uiPartAddr, iPartIdx, 0 );
@@ -4998,5 +5113,9 @@
       m_pcEntropyCoder->estimateBit(m_pcTrQuant->m_pcEstBitsSbac, 1<< uiLog2TrSize, TEXT_LUMA );
     }
+#if POZNAN_TEXTURE_TU_DELTA_QP_ACCORDING_TO_DEPTH
+    m_pcTrQuant->setQPforQuant( pcCU->getQP( 0 ) + pcCU->getQpOffsetForTextCU(uiAbsPartIdx, false), false, pcCU->getSlice()->getSliceType(), TEXT_LUMA );
+#else
     m_pcTrQuant->setQPforQuant( pcCU->getQP( 0 ), false, pcCU->getSlice()->getSliceType(), TEXT_LUMA );
+#endif
     m_pcTrQuant->transformNxN( pcCU, pcResi->getLumaAddr( uiAbsPartIdx ), pcResi->getStride (), pcCoeffCurrY, 1<< uiLog2TrSize,    1<< uiLog2TrSize,    uiAbsSumY, TEXT_LUMA,     uiAbsPartIdx );
 
@@ -5009,5 +5128,9 @@
         m_pcEntropyCoder->estimateBit(m_pcTrQuant->m_pcEstBitsSbac, 1<<uiLog2TrSizeC, TEXT_CHROMA );
       }
+#if POZNAN_TEXTURE_TU_DELTA_QP_ACCORDING_TO_DEPTH
+      m_pcTrQuant->setQPforQuant( pcCU->getQP( 0 ) + pcCU->getQpOffsetForTextCU(uiAbsPartIdx, false), false, pcCU->getSlice()->getSliceType(), TEXT_CHROMA );
+#else
       m_pcTrQuant->setQPforQuant( pcCU->getQP( 0 ), false, pcCU->getSlice()->getSliceType(), TEXT_CHROMA );
+#endif
       m_pcTrQuant->transformNxN( pcCU, pcResi->getCbAddr( uiAbsPartIdx ), pcResi->getCStride(), pcCoeffCurrU, 1<<uiLog2TrSizeC, 1<<uiLog2TrSizeC, uiAbsSumU, TEXT_CHROMA_U, uiAbsPartIdx );
       m_pcTrQuant->transformNxN( pcCU, pcResi->getCrAddr( uiAbsPartIdx ), pcResi->getCStride(), pcCoeffCurrV, 1<<uiLog2TrSizeC, 1<<uiLog2TrSizeC, uiAbsSumV, TEXT_CHROMA_V, uiAbsPartIdx );
@@ -5072,5 +5195,9 @@
     {
       Pel *pcResiCurrY = m_pcQTTempTComYuv[uiQTTempAccessLayer].getLumaAddr( uiAbsPartIdx );
+#if POZNAN_TEXTURE_TU_DELTA_QP_ACCORDING_TO_DEPTH
+      m_pcTrQuant->setQPforQuant( pcCU->getQP( 0 ) + pcCU->getQpOffsetForTextCU(uiAbsPartIdx, false),  false, pcCU->getSlice()->getSliceType(), TEXT_LUMA );
+#else
       m_pcTrQuant->setQPforQuant( pcCU->getQP( 0 ), false, pcCU->getSlice()->getSliceType(), TEXT_LUMA );
+#endif
 #if INTRA_DST_TYPE_7 // Inside Inter Encoder Search. So use conventional DCT.
     m_pcTrQuant->invtransformNxN( TEXT_LUMA,REG_DCT, pcResiCurrY, m_pcQTTempTComYuv[uiQTTempAccessLayer].getStride(),  pcCoeffCurrY, 1<< uiLog2TrSize,    1<< uiLog2TrSize );//this is for inter mode only
@@ -5150,5 +5277,9 @@
       {
         Pel *pcResiCurrU = m_pcQTTempTComYuv[uiQTTempAccessLayer].getCbAddr( uiAbsPartIdx );
+#if POZNAN_TEXTURE_TU_DELTA_QP_ACCORDING_TO_DEPTH
+        m_pcTrQuant->setQPforQuant( pcCU->getQP( 0 ) + pcCU->getQpOffsetForTextCU(uiAbsPartIdx, false), false, pcCU->getSlice()->getSliceType(), TEXT_CHROMA );
+#else
         m_pcTrQuant->setQPforQuant( pcCU->getQP( 0 ), false, pcCU->getSlice()->getSliceType(), TEXT_CHROMA );
+#endif
 #if INTRA_DST_TYPE_7  // Inside Inter Encoder Search. So use conventional DCT.
         m_pcTrQuant->invtransformNxN( TEXT_CHROMA,REG_DCT, pcResiCurrU, m_pcQTTempTComYuv[uiQTTempAccessLayer].getCStride(), pcCoeffCurrU, 1<<uiLog2TrSizeC, 1<<uiLog2TrSizeC);
@@ -5195,5 +5326,9 @@
         if( !uiAbsSumU )
         {
+#if POZNAN_TEXTURE_TU_DELTA_QP_ACCORDING_TO_DEPTH
+          m_pcTrQuant->setQPforQuant( pcCU->getQP( 0 ) + pcCU->getQpOffsetForTextCU(uiAbsPartIdx, false), false, pcCU->getSlice()->getSliceType(), TEXT_CHROMA );
+#else
           m_pcTrQuant->setQPforQuant( pcCU->getQP( 0 ), false, pcCU->getSlice()->getSliceType(), TEXT_CHROMA );
+#endif
         }
 #if INTRA_DST_TYPE_7   // Inside Inter Encoder Search. So use conventional DCT.
Index: branches/0.2-poznan-univ/source/Lib/TLibEncoder/TEncSearch.h
===================================================================
--- branches/0.2-poznan-univ/source/Lib/TLibEncoder/TEncSearch.h	(revision 11)
+++ branches/0.2-poznan-univ/source/Lib/TLibEncoder/TEncSearch.h	(revision 12)
@@ -185,4 +185,7 @@
   
   Void xGetInterPredictionError( TComDataCU* pcCU, TComYuv* pcYuvOrg, Int iPartIdx, UInt& ruiSAD, Bool Hadamard );
+#if POZNAN_EIVD
+  Void xGetInterPredictionError_EIVD( TComDataCU* pcCU, TComYuv* pcYuvOrg, Int iPartIdx, UInt& ruiSAD, Bool Hadamard );
+#endif
 
 public:
Index: branches/0.2-poznan-univ/source/Lib/TLibEncoder/TEncSlice.cpp
===================================================================
--- branches/0.2-poznan-univ/source/Lib/TLibEncoder/TEncSlice.cpp	(revision 11)
+++ branches/0.2-poznan-univ/source/Lib/TLibEncoder/TEncSlice.cpp	(revision 12)
@@ -475,4 +475,8 @@
   m_pcEntropyCoder->setMaxAlfCtrlDepth(0); //unnecessary
 
+#if POZNAN_STAT_JK
+  m_pcCuEncoder->setStatFileEnabled(false);
+#endif
+
   // for every CU in slice
   for(  uiCUAddr = uiStartCUAddr; uiCUAddr < uiBoundingCUAddr; uiCUAddr++  )
@@ -611,4 +615,8 @@
 #endif
 
+#if POZNAN_STAT_JK
+  m_pcCuEncoder->setStatFileEnabled(true);
+#endif
+
   for(  uiCUAddr = uiStartCUAddr; uiCUAddr<uiBoundingCUAddr; uiCUAddr++  )
   {
@@ -618,4 +626,12 @@
     g_bJustDoIt = g_bEncDecTraceEnable;
 #endif
+
+	// JK {
+	DTRACE_CABAC_V( g_nSymbolCounter++ );
+	DTRACE_CABAC_T( "\tCU: " );
+	DTRACE_CABAC_V( uiCUAddr );
+	DTRACE_CABAC_T( "\n" );
+	// JK }
+
     if ( (m_pcCfg->getSliceMode()!=0 || m_pcCfg->getEntropySliceMode()!=0) && uiCUAddr==uiBoundingCUAddr-1 )
     {
Index: branches/0.2-poznan-univ/source/Lib/TLibEncoder/TEncTop.cpp
===================================================================
--- branches/0.2-poznan-univ/source/Lib/TLibEncoder/TEncTop.cpp	(revision 11)
+++ branches/0.2-poznan-univ/source/Lib/TLibEncoder/TEncTop.cpp	(revision 12)
@@ -63,4 +63,9 @@
   m_bSeqFirst = true;
   m_iFrameNumInCodingOrder = 0;
+    
+#if POZNAN_MP
+  m_pcMP=NULL;
+#endif
+
 }
 
@@ -98,4 +103,8 @@
 #endif
 
+#if POZNAN_MP
+  m_pcMP				= NULL;
+#endif
+
 #if MQT_BA_RA && MQT_ALF_NPASS
   if(m_bUseALF)
@@ -163,4 +172,8 @@
 #endif
 
+#if POZNAN_MP
+  m_pcMP=NULL;
+#endif
+
   // SBAC RD
   if( m_bUseSBACRD )
@@ -205,4 +218,8 @@
   // initialize PPS
   xInitPPS();
+#endif
+
+#if POZNAN_MP
+  m_pcMP = pcTAppEncTop->getMP();
 #endif
 
@@ -416,9 +433,12 @@
   {
     pcPic->removeOriginalBuffer   ();
-#if POZNAN_AVAIL_MAP
+#if POZNAN_CU_SKIP
     pcPic->removeAvailabilityBuffer();
 #endif
-#if POZNAN_SYNTH_VIEW
+#if POZNAN_CU_SYNTH
     pcPic->removeSynthesisBuffer();
+#if POZNAN_TEXTURE_TU_DELTA_QP_ACCORDING_TO_DEPTH
+    pcPic->removeSynthesisDepthBuffer();
+#endif
 #endif
 #if HHI_INTER_VIEW_MOTION_PRED
@@ -514,4 +534,12 @@
   // mark it should be extended
   rpcPic->getPicYuvRec()->setBorderExtension(false);
+  
+#if POZNAN_MP
+	rpcPic->getSlice(0)->setMP(m_pcMP);
+#endif
+
+#if POZNAN_STAT_JK
+	rpcPic->getSlice(0)->setStatFile(m_pcStatFile);
+#endif
 }
 
@@ -624,4 +652,8 @@
 #if HHI_MPI
   m_cSPS.setUseMVI( m_bUseMVI );
+#endif
+
+#if POZNAN_NONLINEAR_DEPTH
+  m_cSPS.setDepthPower  ( m_fDepthPower );
 #endif
 
@@ -824,3 +856,9 @@
 
   pcPic->setScaleOffset( m_aaiCodedScale, m_aaiCodedOffset );
-}
+
+#if POZNAN_TEXTURE_TU_DELTA_QP_PARAM_IN_CFG_FOR_ENC 
+  pcPic->setTextureCuDeltaQpOffset( getTextureCuDeltaQpOffset() );
+  pcPic->setTextureCuDeltaQpMul   ( getTextureCuDeltaQpMul() );
+  pcPic->setTextureCuDeltaQpTopBottomRow( getTextureCuDeltaQpTopBottomRow() );  
+#endif
+}
Index: branches/0.2-poznan-univ/source/Lib/TLibEncoder/TEncTop.h
===================================================================
--- branches/0.2-poznan-univ/source/Lib/TLibEncoder/TEncTop.h	(revision 11)
+++ branches/0.2-poznan-univ/source/Lib/TLibEncoder/TEncTop.h	(revision 12)
@@ -64,4 +64,7 @@
 #include "TEncAnalyze.h"
 
+#if POZNAN_MP
+#include "../TLibCommon/TComMP.h"
+#endif		
 
 // ====================================================================================================================
@@ -131,4 +134,13 @@
 
   PicOrderCnt             m_iFrameNumInCodingOrder;
+#if POZNAN_TEXTURE_TU_DELTA_QP_PARAM_IN_CFG_FOR_ENC 
+  Double                  m_dTextureCuDeltaQpOffset;
+  Double                  m_dTextureCuDeltaQpMul;
+  Int                     m_iTextureCuDeltaQpTopBottomRow; 
+#endif
+
+#if POZNAN_MP
+  TComMP*				  m_pcMP;
+#endif
 
 protected:
@@ -217,4 +229,13 @@
   Void encode    ( bool bEos, std::map<PicOrderCnt, TComPicYuv*>& rcMapPicYuvRecOut, TComBitstream* pcBitstreamOut, Bool& bNewPicNeeded );
   Void receivePic( bool bEos, TComPicYuv* pcPicYuvOrg, TComPicYuv* pcPicYuvRec, TComPicYuv* pcOrgPdmDepth = 0 );
+
+#if POZNAN_TEXTURE_TU_DELTA_QP_PARAM_IN_CFG_FOR_ENC 
+  Double getTextureCuDeltaQpOffset( )      { return m_dTextureCuDeltaQpOffset;}
+  Double getTextureCuDeltaQpMul( )         { return m_dTextureCuDeltaQpMul;}
+  Int    getTextureCuDeltaQpTopBottomRow( ){ return m_iTextureCuDeltaQpTopBottomRow;}
+  Void   setTextureCuDeltaQpOffset      ( Double dTextureCuDeltaQpOffset    ){ m_dTextureCuDeltaQpOffset       = dTextureCuDeltaQpOffset; }
+  Void   setTextureCuDeltaQpMul         ( Double dTextureCuDeltaQpMul       ){ m_dTextureCuDeltaQpMul          = dTextureCuDeltaQpMul; }
+  Void   setTextureCuDeltaQpTopBottomRow( Int iTextureCuDeltaQpTopBottomRow ){ m_iTextureCuDeltaQpTopBottomRow = iTextureCuDeltaQpTopBottomRow; }  
+#endif
 };
 
