Index: branches/0.2-poznan-univ/build/HM_vc8.sln
===================================================================
--- branches/0.2-poznan-univ/build/HM_vc8.sln	(revision 11)
+++ branches/0.2-poznan-univ/build/HM_vc8.sln	(revision 12)
@@ -9,4 +9,11 @@
 		{5280C25A-D316-4BE7-AE50-29D72108624F} = {5280C25A-D316-4BE7-AE50-29D72108624F}
 		{8783AD3A-A5CA-42B7-AAC4-A07EB845A684} = {8783AD3A-A5CA-42B7-AAC4-A07EB845A684}
+<<<<<<< .mine
+		{5E87AD84-AC4F-4336-B4EE-549CA210EE4A} = {5E87AD84-AC4F-4336-B4EE-549CA210EE4A}
+		{78018D78-F890-47E3-A0B7-09D273F0B11D} = {78018D78-F890-47E3-A0B7-09D273F0B11D}
+		{F8B77A48-AF6C-4746-A89F-B706ABA6AD94} = {F8B77A48-AF6C-4746-A89F-B706ABA6AD94}
+		{5280C25A-D316-4BE7-AE50-29D72108624F} = {5280C25A-D316-4BE7-AE50-29D72108624F}
+=======
+>>>>>>> .r11
 	EndProjectSection
 EndProject
Index: branches/0.2-poznan-univ/build/HM_vc9.sln
===================================================================
--- branches/0.2-poznan-univ/build/HM_vc9.sln	(revision 11)
+++ branches/0.2-poznan-univ/build/HM_vc9.sln	(revision 12)
@@ -7,6 +7,8 @@
 		{78018D78-F890-47E3-A0B7-09D273F0B11D} = {78018D78-F890-47E3-A0B7-09D273F0B11D}
 		{F8B77A48-AF6C-4746-A89F-B706ABA6AD94} = {F8B77A48-AF6C-4746-A89F-B706ABA6AD94}
+		{ABF5855A-69D4-4579-AC8E-7109DEEFA7F0} = {ABF5855A-69D4-4579-AC8E-7109DEEFA7F0}
 		{5280C25A-D316-4BE7-AE50-29D72108624F} = {5280C25A-D316-4BE7-AE50-29D72108624F}
 		{8783AD3A-A5CA-42B7-AAC4-A07EB845A684} = {8783AD3A-A5CA-42B7-AAC4-A07EB845A684}
+		{457993C6-AE2C-4B9B-B5F9-71033279A0B9} = {457993C6-AE2C-4B9B-B5F9-71033279A0B9}
 	EndProjectSection
 EndProject
Index: branches/0.2-poznan-univ/build/vc8/TAppDecoder_vc8.vcproj
===================================================================
--- branches/0.2-poznan-univ/build/vc8/TAppDecoder_vc8.vcproj	(revision 11)
+++ branches/0.2-poznan-univ/build/vc8/TAppDecoder_vc8.vcproj	(revision 12)
@@ -44,6 +44,6 @@
 				Name="VCCLCompilerTool"
 				Optimization="0"
+				AdditionalIncludeDirectories="&quot;..\..\compat\msvc&quot;"
 				PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS"
-				AdditionalIncludeDirectories="&quot;..\..\compat\msvc&quot;"
 				MinimalRebuild="true"
 				BasicRuntimeChecks="3"
@@ -119,6 +119,6 @@
 				Name="VCCLCompilerTool"
 				Optimization="0"
+				AdditionalIncludeDirectories="&quot;..\..\compat\msvc&quot;"
 				PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS"
-				AdditionalIncludeDirectories="&quot;..\..\compat\msvc&quot;"
 				MinimalRebuild="true"
 				BasicRuntimeChecks="3"
@@ -197,6 +197,6 @@
 				EnableIntrinsicFunctions="false"
 				FavorSizeOrSpeed="1"
+				AdditionalIncludeDirectories="&quot;..\..\compat\msvc&quot;"
 				PreprocessorDefinitions="WIN32;_CONSOLE;_CRT_SECURE_NO_WARNINGS"
-				AdditionalIncludeDirectories="&quot;..\..\compat\msvc&quot;"
 				StringPooling="true"
 				RuntimeLibrary="0"
@@ -275,6 +275,6 @@
 				EnableIntrinsicFunctions="false"
 				FavorSizeOrSpeed="1"
+				AdditionalIncludeDirectories="&quot;..\..\compat\msvc&quot;"
 				PreprocessorDefinitions="WIN32;_CONSOLE;_CRT_SECURE_NO_WARNINGS"
-				AdditionalIncludeDirectories="&quot;..\..\compat\msvc&quot;"
 				StringPooling="true"
 				RuntimeLibrary="0"
Index: branches/0.2-poznan-univ/source/App/TAppCommon/TAppComCamPara.cpp
===================================================================
--- branches/0.2-poznan-univ/source/App/TAppCommon/TAppComCamPara.cpp	(revision 11)
+++ branches/0.2-poznan-univ/source/App/TAppCommon/TAppComCamPara.cpp	(revision 12)
@@ -76,10 +76,10 @@
 
       radLUT        [ uiSourceView ][ uiTargetView ]      = new Double*[ 2 ];
-      radLUT        [ uiSourceView ][ uiTargetView ][ 0 ] = new Double [ 257 ];
-      radLUT        [ uiSourceView ][ uiTargetView ][ 1 ] = new Double [ 257 ];
+      radLUT        [ uiSourceView ][ uiTargetView ][ 0 ] = new Double [ SizeOfLUT+1 ];
+      radLUT        [ uiSourceView ][ uiTargetView ][ 1 ] = new Double [ SizeOfLUT+1 ];
 
       raiLUT        [ uiSourceView ][ uiTargetView ]      = new Int*   [ 2 ];
-      raiLUT        [ uiSourceView ][ uiTargetView ][ 0 ] = new Int    [ 257 ];
-      raiLUT        [ uiSourceView ][ uiTargetView ][ 1 ] = new Int    [ 257 ];
+      raiLUT        [ uiSourceView ][ uiTargetView ][ 0 ] = new Int    [ SizeOfLUT+1 ];
+      raiLUT        [ uiSourceView ][ uiTargetView ][ 1 ] = new Int    [ SizeOfLUT+1 ];
     }
   }
@@ -877,8 +877,22 @@
       radShiftParams[ uiSourceView][ uiTargetView ][ 1 ] = dOffset;
 
-      for( UInt uiDepthValue = 0; uiDepthValue < 256; uiDepthValue++ )
-      {
+#if POZNAN_NONLINEAR_DEPTH
+      TComPowerConverter power(m_fDepthPower, (POZNAN_LUT_INCREASED_PRECISION) ? g_uiBitIncrement : 0, (POZNAN_LUT_INCREASED_PRECISION) ? g_uiBitIncrement : 0);
+#endif
+
+      for( UInt uiDepthValue = 0; uiDepthValue < SizeOfLUT; uiDepthValue++ )
+      {
+        Double  dDepthValue = (Double)uiDepthValue;
+        Int64   iDepthValue = (Int64)uiDepthValue;
+#if POZNAN_NONLINEAR_DEPTH
+        dDepthValue = power(dDepthValue);
+        iDepthValue = (Int64)(dDepthValue+0.5);
+#endif
+#if POZNAN_LUT_INCREASED_PRECISION
+        dDepthValue /= (1<<g_uiBitIncrement);
+#endif
         // real-valued look-up tables
-        Double  dShiftLuma      = ( (Double)uiDepthValue * dScale + dOffset ) * Double( 1 << m_iLog2Precision );
+
+        Double  dShiftLuma      = ( dDepthValue * dScale + dOffset ) * Double( 1 << m_iLog2Precision );
         Double  dShiftChroma    = dShiftLuma / 2;
         radLUT[ uiSourceView ][ uiTargetView ][ 0 ][ uiDepthValue ] = dShiftLuma;
@@ -886,5 +900,9 @@
 
         // integer-valued look-up tables
-        Int64   iTempScale      = (Int64)uiDepthValue * iScale;
+        //Int64   iDepthValue = (Int64)uiDepthValue;
+        Int64   iTempScale      = iDepthValue * iScale;
+#if POZNAN_LUT_INCREASED_PRECISION
+        iTempScale >>= g_uiBitIncrement;
+#endif
         Int64   iTestScale      = ( iTempScale + iOffset       );   // for checking accuracy of camera parameters
         Int64   iShiftLuma      = ( iTempScale + iOffsetLuma   ) >> iLog2DivLuma;
@@ -899,8 +917,8 @@
       }
 
-      radLUT[ uiSourceView ][ uiTargetView ][ 0 ][ 256 ] = radLUT[ uiSourceView ][ uiTargetView ][ 0 ][ 255 ];
-      radLUT[ uiSourceView ][ uiTargetView ][ 1 ][ 256 ] = radLUT[ uiSourceView ][ uiTargetView ][ 1 ][ 255 ];
-      raiLUT[ uiSourceView ][ uiTargetView ][ 0 ][ 256 ] = raiLUT[ uiSourceView ][ uiTargetView ][ 0 ][ 255 ];
-      raiLUT[ uiSourceView ][ uiTargetView ][ 1 ][ 256 ] = raiLUT[ uiSourceView ][ uiTargetView ][ 1 ][ 255 ];
+      radLUT[ uiSourceView ][ uiTargetView ][ 0 ][ SizeOfLUT ] = radLUT[ uiSourceView ][ uiTargetView ][ 0 ][ SizeOfLUT-1 ];
+      radLUT[ uiSourceView ][ uiTargetView ][ 1 ][ SizeOfLUT ] = radLUT[ uiSourceView ][ uiTargetView ][ 1 ][ SizeOfLUT-1 ];
+      raiLUT[ uiSourceView ][ uiTargetView ][ 0 ][ SizeOfLUT ] = raiLUT[ uiSourceView ][ uiTargetView ][ 0 ][ SizeOfLUT-1 ];
+      raiLUT[ uiSourceView ][ uiTargetView ][ 1 ][ SizeOfLUT ] = raiLUT[ uiSourceView ][ uiTargetView ][ 1 ][ SizeOfLUT-1 ];
     }
   }
@@ -1232,5 +1250,9 @@
                       Char*  pchSynthViewNumbers,
                       std::vector<Int>* paiSynthViewNumbers,
-                      Int    iLog2Precision )
+                      Int    iLog2Precision
+#if POZNAN_NONLINEAR_DEPTH
+                      ,Float fDepthPower
+#endif
+                      )
 {
   //===== set miscellaneous variables =====
@@ -1240,4 +1262,8 @@
   m_uiCamParsCodedPrecision = uiCodedCamParsPrecision;
   m_iLog2Precision          = iLog2Precision;
+
+#if POZNAN_NONLINEAR_DEPTH
+  m_fDepthPower             = fDepthPower;
+#endif
 
   xReadCameraParameterFile( pchCfgFileName );
@@ -1339,4 +1365,42 @@
 }
 
+  xReadCameraParameterFile( pchCfgFileName );
+
+  m_bSetupFromCoded         = ( m_aadCameraParameters[ 0 ].size() == 2 );
+
+  if ( m_bSetupFromCoded )
+  {
+    std::cout << "Detected decoded camera parameter file. Overwriting base view settings from cfg file. " << std::endl;
+    xSetupBaseViewsFromCoded();
+  }
+  else
+  {
+    xSetupBaseViews( pchBaseViewNumbers, uiNumBaseViews );
+  }
+
+  //===== set derived parameters =====
+  xGetViewOrderIndices( m_aiBaseId2SortedId, m_aiViewOrderIndex );
+  m_bCamParsVaryOverTime = xGetCamParsChangeFlag();
+
+
+  //===== create arrays =====
+  xCreateLUTs   ( (UInt)m_iNumberOfBaseViews, (UInt)m_iNumberOfBaseViews,  m_adBaseViewShiftLUT,  m_aiBaseViewShiftLUT,  m_adBaseViewShiftParameter,  m_aiBaseViewShiftParameter  );
+  xCreateLUTs   ( (UInt)m_iNumberOfBaseViews, (UInt)m_iNumberOfSynthViews, m_adSynthViewShiftLUT, m_aiSynthViewShiftLUT, m_adSynthViewShiftParameter, m_aiSynthViewShiftParameter );
+  xCreate2dArray( (UInt)m_iNumberOfBaseViews, (UInt)m_iNumberOfBaseViews,  m_aaiCodedScale           );
+  xCreate2dArray( (UInt)m_iNumberOfBaseViews, (UInt)m_iNumberOfBaseViews,  m_aaiCodedOffset          );
+  xCreate2dArray( (UInt)m_iNumberOfBaseViews, (UInt)m_iNumberOfBaseViews,  m_aaiScaleAndOffsetSet    );
+  xInit2dArray  ( (UInt)m_iNumberOfBaseViews, (UInt)m_iNumberOfBaseViews,  m_aaiScaleAndOffsetSet, 0 );
+
+  xCreate2dArray( (UInt)m_iNumberOfBaseViews, (UInt)m_iNumberOfBaseViews,  m_aaiPdmScaleNomDelta     );
+  xCreate2dArray( (UInt)m_iNumberOfBaseViews, (UInt)m_iNumberOfBaseViews,  m_aaiPdmOffset            );
+
+  //===== init disparity to virtual depth conversion parameters =====
+  xSetPdmConversionParams();
+
+  //===== init arrays for first frame =====
+  xSetShiftParametersAndLUT( m_uiFirstFrameId );
+}
+#endif//*/
+
 Void
 TAppComCamPara::check( Bool bCheckViewRange, Bool bCheckFrameRange )
@@ -1456,5 +1520,5 @@
 }
 
-#if POZNAN_SYNTH
+#if POZNAN_CU_SYNTH||POZNAN_CU_SKIP
 Bool
 TAppComCamPara::getNearestBaseView( Int iSynthViewIdx, Int &riNearestViewIdx, Int &riRelDistToLeft, Bool& rbRenderFromLeft)
Index: branches/0.2-poznan-univ/source/App/TAppCommon/TAppComCamPara.h
===================================================================
--- branches/0.2-poznan-univ/source/App/TAppCommon/TAppComCamPara.h	(revision 11)
+++ branches/0.2-poznan-univ/source/App/TAppCommon/TAppComCamPara.h	(revision 12)
@@ -104,4 +104,7 @@
   Int****             m_aiSynthViewShiftLUT;									///< Disparity LUT
 
+#if POZNAN_NONLINEAR_DEPTH
+  Float               m_fDepthPower;
+#endif
 
 protected:
@@ -161,5 +164,9 @@
                 Char*   pchSynthViewNumbers,
                 std::vector<Int>* paiSynthViewNumbers,
-                Int     iLog2Precision );
+                Int     iLog2Precision 
+#if POZNAN_NONLINEAR_DEPTH
+                ,Float  fDepthPower
+#endif
+                );
 
   Void init   ( UInt    uiInputBitDepth,
@@ -170,4 +177,7 @@
                 std::vector<Int>* paiSynthViewNumbers,
                 Int     iLog2Precision
+#if POZNAN_NONLINEAR_DEPTH
+                ,Float  fDepthPower
+#endif
               );
 
@@ -182,5 +192,5 @@
   Int                 synthRelNum2Idx           ( Int iRelNum );
   Bool getLeftRightBaseView( Int iSynthViewIdx, Int &riLeftViewIdx, Int &riRightViewIdx, Int &riRelDistToLeft, Bool& rbIsBaseView );
-#if POZNAN_SYNTH
+#if POZNAN_CU_SYNTH||POZNAN_CU_SKIP
   Bool getNearestBaseView( Int iSynthViewIdx, Int &riNearestViewIdx, Int &riRelDistToLeft, Bool& rbRenderFromLeft);
 #endif
@@ -189,4 +199,8 @@
   UInt                getCurFrameId             ()  { return m_iCurrentFrameId;   }
   static Void         convertNumberString       ( Char* pchViewNumberString, std::vector<Int>& raiViewNumbers, Double dViewNumPrec );
+
+#if POZNAN_MP
+  Bool isLeftView( Int iSynthViewIdx, Int iNearestViewIdx);
+#endif
 
   // function for getting parameters and parameter arrays
Index: branches/0.2-poznan-univ/source/App/TAppDecoder/TAppDecTop.cpp
===================================================================
--- branches/0.2-poznan-univ/source/App/TAppDecoder/TAppDecTop.cpp	(revision 11)
+++ branches/0.2-poznan-univ/source/App/TAppDecoder/TAppDecTop.cpp	(revision 12)
@@ -64,4 +64,8 @@
 //  m_iPOCLastDisplay  = -1;
   m_pScaleOffsetFile  = 0;
+
+#if POZNAN_MP
+  m_pcMP = NULL;
+#endif
 }
 
@@ -71,4 +75,8 @@
   
   m_apcBitstream->create( BITS_BUF_SIZE );
+
+#if POZNAN_MP
+  m_pcMP = new TComMP();
+#endif
 }
 
@@ -89,4 +97,8 @@
     free(m_pchReconFile);
   }
+
+#if POZNAN_MP
+  if(m_pcMP) { delete m_pcMP; m_pcMP = NULL; };
+#endif
 }
 
@@ -163,5 +175,5 @@
     if( eNalUnitType == NAL_UNIT_SPS )
     {
-#if POZNAN_SYNTH
+#if POZNAN_CU_SKIP||POZNAN_CU_SYNTH
       if(cComSPS.getViewId()==0 && !cComSPS.isDepth()) // it should be called at first view at the begining of the stream
         initRenderer(cComSPS);
@@ -416,5 +428,19 @@
         if ( m_pchReconFile )
         {
+
+#if POZNAN_NONLINEAR_DEPTH
+          TComSPS* pcSPS = pcPic->getSlice(0)->getSPS();
+          TComPicYuv cPicPower;
+
+          //pcPic->getPicYuvRec()
+          cPicPower.create(pcSPS->getWidth(), pcSPS->getHeight(), pcSPS->getMaxCUWidth(), pcSPS->getMaxCUHeight(), pcSPS->getMaxCUDepth() ); 
+
+          pcPic->getPicYuvRec()->power(&cPicPower, 1.0f/pcSPS->getDepthPower());
+
+          m_acTVideoIOYuvDepthReconFileList[iViewIdx]->write(&cPicPower, pcSPS->getPad());
+          cPicPower.destroy();		  
+#else
           m_acTVideoIOYuvDepthReconFileList[iViewIdx]->write( pcPic->getPicYuvRec(), pcPic->getSlice(0)->getSPS()->getPad() );
+#endif
         }
 
@@ -544,5 +570,5 @@
 }
 
-#if POZNAN_SYNTH
+#if POZNAN_CU_SYNTH || POZNAN_CU_SKIP
 Void TAppDecTop::initRenderer(TComSPS &cComSPS)
 {
@@ -566,5 +592,4 @@
   iNearestViewIdx = 0;
   bRenderFromLeft = iCoddedViewOrderIdx>0?true:false;
-  //m_cCamParsCollector.getNearestBaseView(iCoddedViewIdx, iNearestViewIdx, iRelDistToLeft, bRenderFromLeft);
 
   m_cAvailabilityRenderer.setShiftLUTs(
@@ -592,8 +617,23 @@
     pcPicYuvAvailView = pcPic->getPicYuvAvail();
   }
+#if POZNAN_TEXTURE_TU_DELTA_QP_ACCORDING_TO_DEPTH
+  TComPicYuv* pcPicYuvSynthDepthView = pcPic->getPicYuvSynthDepth();
+  if(!pcPicYuvSynthDepthView)
+  {
+    pcPic->addSynthesisDepthBuffer();
+    pcPicYuvSynthDepthView = pcPic->getPicYuvSynthDepth();
+  }
+  m_cAvailabilityRenderer.extrapolateAvailabilityView( getPicFromView( iNearestViewIdx, iCurPoc, true )->getPicYuvRec(), getPicFromView( iNearestViewIdx, iCurPoc, true )->getPicYuvRec(), pcPicYuvSynthDepthView, pcPicYuvAvailView, bRenderFromLeft );
+  
+#if POZNAN_OUTPUT_SYNTH
+      Char acFilenameBaseD[1024];
+      ::sprintf( acFilenameBaseD,  "SynthDepth_%s_V%d.yuv", ( true ? "Dec" : "Enc" ),iCoddedViewIdx );
+      pcPicYuvSynthDepthView->dump(acFilenameBaseD, iCurPoc!=0);
+#endif
+#endif
 
   //m_cAvailabilityRenderer.extrapolateAvailabilityView( xGetPicFromView( iNearestViewIdx, iCurPoc, false )->getPicYuvRec(), xGetPicFromView( iNearestViewIdx, iCurPoc, true )->getPicYuvRec(), pcPicYuvERView, pcPicYuvAvailView, bRenderFromLeft );
   m_cAvailabilityRenderer.extrapolateAvailabilityView( getPicFromView( iNearestViewIdx, iCurPoc, false )->getPicYuvRec(), getPicFromView( iNearestViewIdx, iCurPoc, true )->getPicYuvRec(), pcPicYuvSynthView, pcPicYuvAvailView, bRenderFromLeft );
-
+      
   pcPicYuvAvailView->setBorderExtension( false );//Needed??
   pcPicYuvAvailView->extendPicBorder();//Needed??
@@ -613,5 +653,5 @@
   }
 #endif
-  
-}
-#endif
+
+}//*/
+#endif
Index: branches/0.2-poznan-univ/source/App/TAppDecoder/TAppDecTop.h
===================================================================
--- branches/0.2-poznan-univ/source/App/TAppDecoder/TAppDecTop.h	(revision 11)
+++ branches/0.2-poznan-univ/source/App/TAppDecoder/TAppDecTop.h	(revision 12)
@@ -52,8 +52,12 @@
 #include "../../Lib/TLibCommon/TComDepthMapGenerator.h"
 #include "../../Lib/TLibDecoder/TDecTop.h"
-#if POZNAN_SYNTH
+#if POZNAN_CU_SKIP || POZNAN_CU_SYNTH
 #include "../../Lib/TLibRenderer/TRenTop.h"
 #endif
 #include "TAppDecCfg.h"
+
+#if POZNAN_MP
+#include "../../Lib/TLibCommon/TComMP.h"
+#endif
 
 // ====================================================================================================================
@@ -90,8 +94,11 @@
 #endif
 
-#if POZNAN_SYNTH
+#if POZNAN_CU_SKIP || POZNAN_CU_SYNTH
   TRenTop                         m_cAvailabilityRenderer;
 #endif
 
+#if POZNAN_MP
+  TComMP*						  m_pcMP;
+#endif
 
 public:
@@ -105,5 +112,5 @@
   Void  startUsingDepth() ;
 
-#if POZNAN_SYNTH
+#if POZNAN_CU_SKIP || POZNAN_CU_SYNTH
   Void  initRenderer(TComSPS &cComSPS);
   Void  storeSynthPicsInBuffer(Int iCoddedViewIdx,Int iCoddedViewOrderIdx,Int iCurPoc,Bool bDepth);
@@ -120,4 +127,8 @@
 #endif
 
+#if POZNAN_MP
+  TComMP* getMP() { return m_pcMP; }
+#endif
+
 protected:
   Void  xCreateDecLib     (); ///< create internal classes
Index: branches/0.2-poznan-univ/source/App/TAppEncoder/TAppEncCfg.cpp
===================================================================
--- branches/0.2-poznan-univ/source/App/TAppEncoder/TAppEncCfg.cpp	(revision 11)
+++ branches/0.2-poznan-univ/source/App/TAppEncoder/TAppEncCfg.cpp	(revision 12)
@@ -127,4 +127,18 @@
 #endif
 
+#if POZNAN_STAT_JK
+  for(Int i = 0; i< m_pchStatFileList.size(); i++ )
+  {
+    if ( m_pchStatFileList[i] != NULL )
+      free (m_pchStatFileList[i]);
+  }
+
+  for(Int i = 0; i< m_pchDepthStatFileList.size(); i++ )
+  {
+    if ( m_pchDepthStatFileList[i] != NULL )
+      free (m_pchDepthStatFileList[i]);
+  }
+#endif
+
 }
 
@@ -346,8 +360,22 @@
 #endif
 #endif
+#if POZNAN_TEXTURE_TU_DELTA_QP_PARAM_IN_CFG_FOR_ENC
+  ("textureCuDeltaQpOffset",              m_dTextureCuDeltaQpOffset,       (Double)(-2.6), "texture block QP changing tool based on coresponding depth block values - offset parameter" )
+  ("textureCuDeltaQpMul",                 m_dTextureCuDeltaQpMul,          (Double)(1),    "texture block QP changing tool based on coresponding depth block values - multiplicative parameter" )
+  ("textureCuDeltaQpOffsetTopBottomRow",  m_iTextureCuDeltaQpTopBottomRow, (Int)2,         "texture block QP changing tool - top and bottom CU rows delta QP parameter" )
+#endif
+#if POZNAN_NONLINEAR_DEPTH
+  ("DepthPower,-dpow",    m_fDepthPower,      1.0, "Depth power value (for non-linear processing)")
+#endif
+
 
   /* Compatability with old style -1 FOO or -0 FOO options. */
   ("1", doOldStyleCmdlineOn, "turn option <name> on")
   ("0", doOldStyleCmdlineOff, "turn option <name> off")
+
+#if POZNAN_STAT_JK
+  ("StatFile_%d,sf_%d",       m_pchStatFileList,       (char *) 0 , MAX_INPUT_VIEW_NUM , "Mode selection staticstics file name for view %d")
+  ("DepthStatFile_%d,sf_%d",  m_pchDepthStatFileList,  (char *) 0 , MAX_INPUT_VIEW_NUM , "Mode selection staticstics file name for depth view %d")
+#endif
   ;
 
@@ -396,4 +424,24 @@
 // GT FIX END
 
+#if POZNAN_STAT_JK
+  if ( m_bUsingDepthMaps )
+  {
+    for(Int i = 0; i < m_pchDepthStatFileList.size() ; i++)
+    {
+      if ((m_pchDepthInputFileList[i] != NULL) && (m_pchStatFileList[i] != NULL) && (i < m_iNumberOfViews) )
+      {
+        if (m_pchDepthStatFileList[i] == NULL )
+        {
+          xAppendToFileNameEnd( m_pchStatFileList[i], "_depth", m_pchDepthStatFileList[i] );
+        }
+      }
+      else
+      {
+        m_pchDepthStatFileList[i] = NULL;
+      }
+    };
+  }
+#endif  
+
   if (m_iRateGOPSize == -1)
   {
@@ -431,4 +479,21 @@
 #if HHI_VSO
   m_bUseVSO = m_bUseVSO && m_bUsingDepthMaps && (m_uiVSOMode != 0);
+#endif
+
+#if POZNAN_NONLINEAR_DEPTH
+if (m_fDepthPower<=0) 
+  {
+    Float fDepthQP = m_adQP[ m_adQP.size()  < 2 ? 0 : 1];
+    m_fDepthPower = (fDepthQP-30) *0.25/20.0 + 1.25;
+    if (m_fDepthPower<=1.0) m_fDepthPower = 1.0;
+    // QP = 30 = 1.25
+    // QP = 50 = 1.5
+    if (m_fDepthPower>=1.66) m_fDepthPower = 1.66;
+  };
+
+#if POZNAN_NONLINEAR_DEPTH_SEND_AS_BYTE
+  m_fDepthPower = dequantizeDepthPower(quantizeDepthPower((Float)m_fDepthPower));
+#endif
+
 #endif
 
@@ -498,5 +563,9 @@
                                       NULL,
                                       m_cRenModStrParser.getSynthViews(),
-                                      LOG2_DISP_PREC_LUT );
+                                      LOG2_DISP_PREC_LUT 
+#if POZNAN_NONLINEAR_DEPTH                                      
+                                      ,m_fDepthPower
+#endif
+                                      );
 }
 else if ( m_bUseVSO && m_uiVSOMode != 4 )
@@ -511,5 +580,9 @@
                                       m_pchVSOConfig,
                                       NULL,
-                                      LOG2_DISP_PREC_LUT );
+                                      LOG2_DISP_PREC_LUT 
+#if POZNAN_NONLINEAR_DEPTH                                      
+                                      ,m_fDepthPower
+#endif                                      
+                                      );
 }
 else
@@ -524,5 +597,9 @@
     NULL,
     NULL,
-    LOG2_DISP_PREC_LUT );
+    LOG2_DISP_PREC_LUT 
+#if POZNAN_NONLINEAR_DEPTH                                      
+    ,m_fDepthPower
+#endif    
+    );
 }
 #else
@@ -536,5 +613,9 @@
     NULL,
     NULL,
-    LOG2_DISP_PREC_LUT );
+    LOG2_DISP_PREC_LUT 
+#if POZNAN_NONLINEAR_DEPTH                                      
+    ,m_fDepthPower
+#endif    
+    );
 #endif
 
@@ -668,4 +749,7 @@
     }
 #endif
+#if POZNAN_NONLINEAR_DEPTH
+    printf("Depth map power              : %f\n", m_fDepthPower );
+#endif
   }
 
@@ -820,4 +904,14 @@
     printf("Reconstruction Depth File %i  : %s\n", iCounter, m_pchDepthReconFileList[iCounter]);
   }
+#if POZNAN_STAT_JK
+  for( Int iCounter = 0; iCounter<m_iNumberOfViews; iCounter++)
+  {
+    printf("Statistics File %i        : %s\n", iCounter, m_pchStatFileList[iCounter]);
+  }
+  for( Int iCounter = 0; iCounter<m_iNumberOfViews; iCounter++)
+  {
+    printf("Statistics Depth File %i  : %s\n", iCounter, m_pchDepthStatFileList[iCounter]);
+  }
+#endif
   printf("Real     Format              : %dx%d %dHz\n", m_iSourceWidth - m_aiPad[0], m_iSourceHeight-m_aiPad[1], m_iFrameRate );
   printf("Internal Format              : %dx%d %dHz\n", m_iSourceWidth, m_iSourceHeight, m_iFrameRate );
@@ -912,4 +1006,46 @@
 #if MTK_SAO
 #endif
+
+#if POZNAN_MP
+  printf("POZNAN_MP(1){ ");
+
+#if POZNAN_MP_USE_DEPTH_MAP_GENERATION
+  printf("dmg=1 ");
+#else
+  printf("dmg=0 ");
+#endif
+
+#if POZNAN_MP_FILL
+  printf("fill=%d ",POZNAN_MP_FILL_TYPE);
+#else
+  printf("fill=- ");
+#endif
+
+#if POZNAN_EIVD
+  printf("EIVD(1): ");
+  printf("cand=%d ",POZNAN_EIVD_MERGE_POS);
+#if POZNAN_EIVD_CALC_PRED_DATA
+  printf("pr=1 ");
+#else
+  printf("pr=0 ");
+#endif
+#if POZNAN_EIVD_COMPRESS_ME_DATA
+  printf("comp=1 ");
+#else
+  printf("comp=0 ");
+#endif
+#if POZNAN_EIVD_USE_IN_NONANCHOR_PIC_ONLY
+  printf("na=1 ");
+#else
+  printf("na=0 ");
+#endif
+#else
+  printf("EIVD(0) ");
+#endif
+  printf("}");
+#else
+  printf("POZNAN_MP(0) ");
+#endif
+
   printf("\n");
   printf("TOOL CFG VIDEO  : ");
@@ -933,4 +1069,12 @@
 #endif
   printf("\n");
+
+  
+printf("POZNAN_TEXTURE_TU_DELTA_QP_ACCORDING_TO_DEPTH(");
+#if POZNAN_TEXTURE_TU_DELTA_QP_ACCORDING_TO_DEPTH
+printf("1), ");
+#else
+printf("0), ");
+#endif
 
   fflush(stdout);
Index: branches/0.2-poznan-univ/source/App/TAppEncoder/TAppEncCfg.h
===================================================================
--- branches/0.2-poznan-univ/source/App/TAppEncoder/TAppEncCfg.h	(revision 11)
+++ branches/0.2-poznan-univ/source/App/TAppEncoder/TAppEncCfg.h	(revision 12)
@@ -271,4 +271,20 @@
   TRenModSetupStrParser       m_cRenModStrParser;
 #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
+  Double    m_fDepthPower;									  ///< Depth power value
+#endif
+
+#if POZNAN_STAT_JK
+  std::vector<char*>	   m_pchStatFileList;					///< texure statistics file names
+  std::vector<char*>	   m_pchDepthStatFileList;				///< depth statistics file names
+#endif
+
 public:
 
Index: branches/0.2-poznan-univ/source/App/TAppEncoder/TAppEncTop.cpp
===================================================================
--- branches/0.2-poznan-univ/source/App/TAppEncoder/TAppEncTop.cpp	(revision 11)
+++ branches/0.2-poznan-univ/source/App/TAppEncoder/TAppEncTop.cpp	(revision 12)
@@ -141,4 +141,8 @@
     m_acTEncTopList[iViewIdx]->setUseFastEnc                   ( m_bUseFastEnc  );
 
+#if POZNAN_NONLINEAR_DEPTH
+    m_acTEncTopList[iViewIdx]->setDepthPower                   ( (Float)m_fDepthPower );
+#endif
+
 #if HHI_VSO
     m_acTEncTopList[iViewIdx]->setUseVSO                       ( false ); //GT: might be enabled later for VSO Mode 4
@@ -222,4 +226,11 @@
     m_acTEncTopList[iViewIdx]->setQpChangeOffsetVideo( m_iQpChangeOffsetVideo );
     m_acTEncTopList[iViewIdx]->setQpChangeOffsetDepth( m_iQpChangeOffsetDepth );
+
+    
+ #if POZNAN_TEXTURE_TU_DELTA_QP_PARAM_IN_CFG_FOR_ENC
+    m_acTEncTopList[iViewIdx]->setTextureCuDeltaQpOffset( m_dTextureCuDeltaQpOffset );
+    m_acTEncTopList[iViewIdx]->setTextureCuDeltaQpMul( m_dTextureCuDeltaQpMul );
+    m_acTEncTopList[iViewIdx]->setTextureCuDeltaQpTopBottomRow( m_iTextureCuDeltaQpTopBottomRow );  
+#endif
   }
   if( m_bUsingDepthMaps )
@@ -382,4 +393,7 @@
       m_acTEncDepthTopList[iViewIdx]->setUseMVI( m_bUseMVI );
 #endif
+#if POZNAN_NONLINEAR_DEPTH
+      m_acTEncDepthTopList[iViewIdx]->setDepthPower                   ( (Float)m_fDepthPower );
+#endif
 
       m_acTEncDepthTopList[iViewIdx]->setPictureDigestEnabled(m_pictureDigestEnabled);
@@ -435,5 +449,5 @@
 #endif
 
-#if POZNAN_SYNTH
+#if POZNAN_CU_SYNTH||POZNAN_CU_SKIP
   //m_cAvailabilityRenderer.init(m_iSourceWidth, m_iSourceHeight,true,0,0,true, 0,0,0,0,0,0,0,1,0,0 );  //GT: simplest configuration
   m_cAvailabilityRenderer.init(m_iSourceWidth, m_iSourceHeight,true,0,LOG2_DISP_PREC_LUT,true, 0,0,0,0,0,6,4,1,0,6 );  //GT: simplest configuration
@@ -443,4 +457,14 @@
   m_cUsedPelsRenderer.init(m_iSourceWidth, m_iSourceHeight, true, 0, LOG2_DISP_PREC_LUT, true, 0, 0, 0, 0, 0, 6, 4, 1, 0, 6 );
 #endif
+
+#if POZNAN_MP
+#if POZNAN_MP_USE_DEPTH_MAP_GENERATION
+  m_pcMP = new TComMP(m_iSourceHeight, m_iSourceWidth);
+#else
+  //m_pcMP = new TComMP(m_iSourceHeight, m_iSourceWidth, &m_cCameraData);
+  m_pcMP = new TComMP(m_iSourceHeight, m_iSourceWidth, m_cCameraData.getBaseViewShiftLUTI());
+#endif
+#endif
+
 }
 
@@ -484,4 +508,16 @@
   }
 #endif
+
+#if POZNAN_STAT_JK
+  for(Int iViewIdx=0; iViewIdx < m_iNumberOfViews; iViewIdx++)
+  {
+	if(m_pchStatFileList[iViewIdx] != NULL) m_cStatFileList.push_back(fopen(m_pchStatFileList[iViewIdx],"w"));
+	else m_cStatFileList.push_back(NULL);
+
+	if ( m_bUsingDepthMaps && m_pchDepthStatFileList[iViewIdx] != NULL) m_cDepthStatFileList.push_back(fopen(m_pchDepthStatFileList[iViewIdx],"w"));
+	else m_cDepthStatFileList.push_back(NULL);
+  }
+#endif  
+
 }
 
@@ -490,4 +526,16 @@
 
   m_cTVideoIOBitsFile.closeBits();
+
+#if POZNAN_MP
+  if (m_pcMP) { delete m_pcMP; m_pcMP=NULL; };
+#endif
+
+#if POZNAN_STAT_JK
+  for ( Int iViewIdx = 0; iViewIdx < m_iNumberOfExternalRefs; iViewIdx++ )
+  {
+	  if(m_cStatFileList[iViewIdx]) {fclose(m_cStatFileList[iViewIdx]); m_cStatFileList[iViewIdx]=NULL;}
+	  if(m_cDepthStatFileList[iViewIdx]) {fclose(m_cDepthStatFileList[iViewIdx]); m_cDepthStatFileList[iViewIdx]=NULL;}
+  }
+#endif
 
 #if HHI_VSO
@@ -545,4 +593,10 @@
     m_acTEncTopList[iViewIdx]->setTEncTopList( &m_acTEncTopList  );
   }
+#if POZNAN_STAT_JK
+  for(Int iViewIdx=0; iViewIdx<m_iNumberOfViews; iViewIdx++)
+  {
+    m_acTEncTopList[iViewIdx]->setStatFile(m_cStatFileList[iViewIdx]);//JK
+  }
+#endif
   if ( m_bUsingDepthMaps )
   {
@@ -555,4 +609,10 @@
       m_acTEncDepthTopList[iViewIdx]->setTEncTopList( &m_acTEncDepthTopList  );
     }
+#if POZNAN_STAT_JK
+  for(Int iViewIdx=0; iViewIdx<m_iNumberOfViews; iViewIdx++)
+  {
+    m_acTEncDepthTopList[iViewIdx]->setStatFile(m_cDepthStatFileList[iViewIdx]);//JK
+  }
+#endif
   }
 }
@@ -645,4 +705,7 @@
         {
           m_acTVideoIOYuvDepthInputFileList[iViewIdx]->read( pcPdmDepthOrg, m_aiPad, m_bUsingDepthMaps );
+#if POZNAN_NONLINEAR_DEPTH
+          pcPdmDepthOrg->power(pcPdmDepthOrg, m_fDepthPower);		  
+#endif
         }
 #endif
@@ -666,4 +729,7 @@
           // read input YUV file
           m_acTVideoIOYuvDepthInputFileList[iViewIdx]->read( pcDepthPicYuvOrg, m_aiPad  ) ;
+#if POZNAN_NONLINEAR_DEPTH
+          pcDepthPicYuvOrg->power(pcDepthPicYuvOrg, m_fDepthPower);		  
+#endif
           bDepthEos[iViewIdx] = ( m_acTVideoIOYuvDepthInputFileList[iViewIdx]->isEof() == 1 ?   true : false  );
           bDepthEos[iViewIdx] = ( m_iDepthFrameRcvdVector[iViewIdx] == (m_iFrameToBeEncoded - 1) ?    true : bDepthEos[iViewIdx]   );
@@ -697,5 +763,5 @@
     for(Int iViewIdx=0; iViewIdx < m_iNumberOfViews; iViewIdx++ )     // Start encoding
     {
-#if POZNAN_SYNTH
+#if POZNAN_CU_SYNTH||POZNAN_CU_SKIP
       xStoreSynthPicsInBuffer(iViewIdx,false);
 #endif
@@ -716,5 +782,5 @@
       if( m_bUsingDepthMaps )
       {
-#if POZNAN_SYNTH
+#if POZNAN_CU_SYNTH||POZNAN_CU_SKIP
         xStoreSynthPicsInBuffer(iViewIdx,true);
 #endif
@@ -939,4 +1005,16 @@
   {
     riNextPocToDump++;
+#if POZNAN_NONLINEAR_DEPTH
+    if(isDepth)
+    {
+      TComPicYuv *pcPicOrg = i->second;
+      TComPicYuv *pcPicPow = new TComPicYuv; 
+      //pcPicYuvRec->createCompatibleAs(*iterPicYuvRec);
+      pcPicPow->create( pcPicOrg->getWidth(), pcPicOrg->getHeight(), pcPicOrg->getMaxCuWidth(), pcPicOrg->getMaxCuHeight(), pcPicOrg->getMaxCuDepth() );
+      //cPicPower.create(pcSPS->getWidth(), pcSPS->getHeight(), pcSPS->getMaxCUWidth(), pcSPS->getMaxCUHeight(), pcSPS->getMaxCUDepth() ); 
+      pcPicOrg->power(pcPicPow, (Float)(1.0/m_fDepthPower));		
+      rpcTVideoIOYuvReconFile->write( pcPicPow, m_aiPad );
+    } else
+#endif
     rpcTVideoIOYuvReconFile->write( i->second, m_aiPad );
     rcMap.erase( i );
@@ -1188,6 +1266,6 @@
 #endif
 
-#if POZNAN_SYNTH
-Void TAppEncTop::xStoreSynthPicsInBuffer(Int iCoddedViewIdx,Bool bDepth)
+#if POZNAN_CU_SYNTH||POZNAN_CU_SKIP
+Void TAppEncTop::xStoreSynthPicsInBuffer(Int iCoddedViewIdx, Bool bDepth)
 {
   Int iCurPoc;
@@ -1200,7 +1278,6 @@
   {
     iCurPoc = m_acTEncTopList[ iCoddedViewIdx ]->getNextFrameId();
-    if (!(m_acTEncTopList[ iCoddedViewIdx ]->currentPocWillBeCoded())) return;
-  }
-  
+  if (!(m_acTEncTopList[ iCoddedViewIdx ]->currentPocWillBeCoded())) return;
+
   Int iNumberOfReferenceViews = 0;
   UInt iSynthViewIdx;
@@ -1221,23 +1298,30 @@
 
   m_cAvailabilityRenderer.setShiftLUTs(
-    m_cCameraData.getBaseViewShiftLUTD()[iNearestViewIdx][iCoddedViewIdx],
-    m_cCameraData.getBaseViewShiftLUTI()[iNearestViewIdx][iCoddedViewIdx],
-    m_cCameraData.getBaseViewShiftLUTI()[iNearestViewIdx][iCoddedViewIdx],
-    m_cCameraData.getBaseViewShiftLUTD()[iNearestViewIdx][iCoddedViewIdx],//right
-    m_cCameraData.getBaseViewShiftLUTI()[iNearestViewIdx][iCoddedViewIdx],
-    m_cCameraData.getBaseViewShiftLUTI()[iNearestViewIdx][iCoddedViewIdx],
-    iRelDistToLeft
-  );
-    
+        m_cCameraData.getBaseViewShiftLUTD()[iNearestViewIdx][iCoddedViewIdx],
+        m_cCameraData.getBaseViewShiftLUTI()[iNearestViewIdx][iCoddedViewIdx],
+        m_cCameraData.getBaseViewShiftLUTI()[iNearestViewIdx][iCoddedViewIdx],
+        m_cCameraData.getBaseViewShiftLUTD()[iNearestViewIdx][iCoddedViewIdx],//right
+        m_cCameraData.getBaseViewShiftLUTI()[iNearestViewIdx][iCoddedViewIdx],
+        m_cCameraData.getBaseViewShiftLUTI()[iNearestViewIdx][iCoddedViewIdx],
+        iRelDistToLeft
+      );
 
   TComPicYuv* pcPicYuvERView = new TComPicYuv;
   pcPicYuvERView->create( m_iSourceWidth, m_iSourceHeight, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth );
-
   TComPic* pcPic = xGetPicFromView( iCoddedViewIdx, iCurPoc, bDepth );
   pcPic->addSynthesisBuffer();
   pcPic->addAvailabilityBuffer();
+#if POZNAN_TEXTURE_TU_DELTA_QP_ACCORDING_TO_DEPTH
+      pcPic->addSynthesisDepthBuffer();
+      TComPicYuv* pcPicYuvSynthDepthView = pcPic->getPicYuvSynthDepth();
+      m_cAvailabilityRenderer.extrapolateAvailabilityView( xGetPicFromView( iNearestViewIdx, iCurPoc, true )->getPicYuvRec(), xGetPicFromView( iNearestViewIdx, iCurPoc, true )->getPicYuvRec(), pcPicYuvSynthDepthView, pcPic->getPicYuvAvail(), bRenderFromLeft );
+#if POZNAN_OUTPUT_SYNTH
+      Char acFilenameBaseD[1024];
+      ::sprintf( acFilenameBaseD,  "SynthDepth_%s_V%d.yuv", ( false ? "Dec" : "Enc" ),iCoddedViewIdx );
+      pcPicYuvSynthDepthView->dump(acFilenameBaseD, iCurPoc!=0);
+#endif
+#endif
   TComPicYuv* pcPicYuvSynthView = pcPic->getPicYuvSynth();
   TComPicYuv* pcPicYuvAvailView = pcPic->getPicYuvAvail();
-  
   //m_cAvailabilityRenderer.extrapolateAvailabilityView( xGetPicFromView( iNearestViewIdx, iCurPoc, false )->getPicYuvRec(), xGetPicFromView( iNearestViewIdx, iCurPoc, true )->getPicYuvRec(), pcPicYuvERView, pcPicYuvAvailView, bRenderFromLeft );
   m_cAvailabilityRenderer.extrapolateAvailabilityView( xGetPicFromView( iNearestViewIdx, iCurPoc, bDepth )->getPicYuvRec(), xGetPicFromView( iNearestViewIdx, iCurPoc, true )->getPicYuvRec(), pcPicYuvSynthView, pcPicYuvAvailView, bRenderFromLeft );
@@ -1256,7 +1340,7 @@
 #if POZNAN_OUTPUT_AVAILABLE_MAP
   {
-  Char acFilenameBase[1024];
-  ::sprintf( acFilenameBase,  "Available_%s_%s_V%d.yuv", (bDepth?"Depth":"Tex"),( false ? "Dec" : "Enc" ),iCoddedViewIdx );
-  pcPicYuvAvailView->dump(acFilenameBase, iCurPoc!=0);
+    Char acFilenameBase[1024];
+    ::sprintf( acFilenameBase,  "Available_%s_%s_V%d.yuv", (bDepth?"Depth":"Tex"),( false ? "Dec" : "Enc" ),iCoddedViewIdx );
+    pcPicYuvAvailView->dump(acFilenameBase, iCurPoc!=0);
   }
 #endif
@@ -1268,6 +1352,4 @@
   }
 #endif
-
-      //Usun pcPicYuvERView i inne bufforki
 }
 #endif
Index: branches/0.2-poznan-univ/source/App/TAppEncoder/TAppEncTop.h
===================================================================
--- branches/0.2-poznan-univ/source/App/TAppEncoder/TAppEncTop.h	(revision 11)
+++ branches/0.2-poznan-univ/source/App/TAppEncoder/TAppEncTop.h	(revision 12)
@@ -51,4 +51,8 @@
 //GT VSO end
 
+#if POZNAN_MP
+#include "../../Lib/TLibCommon/TComMP.h"
+#endif	
+
 // ====================================================================================================================
 // Class definition
@@ -92,6 +96,15 @@
 #endif
 
-#if POZNAN_SYNTH
+#if POZNAN_CU_SKIP||POZNAN_CU_SYNTH
   TRenTop                     m_cAvailabilityRenderer;
+#endif
+
+#if POZNAN_MP
+  TComMP*				  m_pcMP;
+#endif
+
+#if POZNAN_STAT_JK
+  std::vector<FILE*>       m_cStatFileList;					    ///< texure statistics file handles
+  std::vector<FILE*>       m_cDepthStatFileList;				///< depth statistics file handles
 #endif
 
@@ -149,4 +162,8 @@
 #endif
 
+#if POZNAN_MP
+  TComMP* getMP() {return m_pcMP;}
+#endif
+
 #if HHI_VSO
 private:
@@ -160,5 +177,5 @@
 
 
-#if POZNAN_SYNTH
+#if POZNAN_CU_SYNTH
 private:
   Void  xStoreSynthPicsInBuffer(Int iCoddedViewIdx, Bool bDepth);
Index: branches/0.2-poznan-univ/source/App/TAppRenderer/TAppRendererCfg.cpp
===================================================================
--- branches/0.2-poznan-univ/source/App/TAppRenderer/TAppRendererCfg.cpp	(revision 11)
+++ branches/0.2-poznan-univ/source/App/TAppRenderer/TAppRendererCfg.cpp	(revision 12)
@@ -186,5 +186,9 @@
   {
     m_cCameraData.init( MAX_INPUT_VIEW_NUM, uiInputBitDepth, uiCamParPrecision, (UInt)m_iFrameSkip, (UInt)m_iFramesToBeRendered,
-      m_pchCameraParameterFile, m_pchBaseViewCameraNumbers, NULL, NULL, m_iLog2SamplingFactor+m_iShiftPrecision );
+      m_pchCameraParameterFile, m_pchBaseViewCameraNumbers, NULL, NULL, m_iLog2SamplingFactor+m_iShiftPrecision
+#if POZNAN_NONLINEAR_DEPTH      
+      ,1.0f 
+#endif
+      );
     m_iNumberOfInputViews  = (Int) m_cCameraData.getBaseViewNumbers() .size();
     m_iNumberOfOutputViews = m_iNumberOfInputViews - 1;
@@ -205,10 +209,18 @@
 
   m_cCameraData.init( MAX_INPUT_VIEW_NUM, uiInputBitDepth, uiCamParPrecision, (UInt)m_iFrameSkip, (UInt)m_iFramesToBeRendered,
-      m_pchCameraParameterFile, m_pchBaseViewCameraNumbers, NULL, piaTempViews, m_iLog2SamplingFactor+m_iShiftPrecision );
+      m_pchCameraParameterFile, m_pchBaseViewCameraNumbers, NULL, piaTempViews, m_iLog2SamplingFactor+m_iShiftPrecision
+#if POZNAN_NONLINEAR_DEPTH
+      , 1.0f 
+#endif
+      );
   }
   else
   {
   m_cCameraData.init( MAX_INPUT_VIEW_NUM, uiInputBitDepth, uiCamParPrecision, (UInt)m_iFrameSkip, (UInt)m_iFramesToBeRendered,
-      m_pchCameraParameterFile, m_pchBaseViewCameraNumbers, m_pchSynthViewCameraNumbers, NULL, m_iLog2SamplingFactor+m_iShiftPrecision );
+      m_pchCameraParameterFile, m_pchBaseViewCameraNumbers, m_pchSynthViewCameraNumbers, NULL, m_iLog2SamplingFactor+m_iShiftPrecision
+#if POZNAN_NONLINEAR_DEPTH
+      ,1.0f 
+#endif
+      );
   m_iNumberOfOutputViews = (Int) m_cCameraData.getSynthViewNumbers().size();
   m_iNumberOfInputViews  = (Int) m_cCameraData.getBaseViewNumbers() .size();
Index: branches/0.2-poznan-univ/source/Lib/TLibCommon/CommonDef.h
===================================================================
--- branches/0.2-poznan-univ/source/Lib/TLibCommon/CommonDef.h	(revision 11)
+++ branches/0.2-poznan-univ/source/Lib/TLibCommon/CommonDef.h	(revision 12)
@@ -137,5 +137,5 @@
 #define LOG2_DISP_PREC_LUT   				2		  		///< log2 of disparity precision used in integer disparity LUTs
 
-#if ( HHI_INTER_VIEW_MOTION_PRED || HHI_INTER_VIEW_RESIDUAL_PRED )
+#if ( HHI_INTER_VIEW_MOTION_PRED || HHI_INTER_VIEW_RESIDUAL_PRED || POZNAN_MP_USE_DEPTH_MAP_GENERATION)
 #define DEPTH_MAP_GENERATION        1
 #else
@@ -178,4 +178,29 @@
 #define POZNAN_OUTPUT_SYNTH               0           // output synthesised view (for debugging)
 
+#if POZNAN_NONLINEAR_DEPTH
+#define POZNAN_LUT_INCREASED_PRECISION 0 // 1
+#else
+#define POZNAN_LUT_INCREASED_PRECISION 0
+#endif
+
+#if POZNAN_NONLINEAR_DEPTH
+inline UChar quantizeDepthPower(Float fDepthPower)
+{
+  Int r = (Int) ( (fDepthPower-1.0f)*128.0f + 0.5f);
+  if (r<=0) return 0;
+  if (r>255) r=255;  
+  return r;
+};
+
+inline Float dequantizeDepthPower(Int iDepthQuant)
+{
+  return iDepthQuant/128.0f + 1.0f;  
+};
+#endif
+
+#if POZNAN_EIVD
+#define POZNAN_EIVD_MERGE_POS                     0         // position of EIVD candidate in merge list for coding (0..6) - overwrites PDM_MERGE_POS settings, is overwritten by HHI_MPI_MERGE_POS settings!!!
+#endif
+
 // ====================================================================================================================
 // Macro functions
@@ -187,5 +212,13 @@
 #define Clip(x)                     ( Min(g_uiIBDI_MAX, Max( 0, (x)) ) )                              ///< clip with bit-depth range
 #define Clip3( MinVal, MaxVal, a)   ( ((a)<(MinVal)) ? (MinVal) : (((a)>(MaxVal)) ? (MaxVal) :(a)) )  ///< general min/max clip
-#define RemoveBitIncrement(x)       ( (x + ( (1 << g_uiBitIncrement) >> 1 )) >> g_uiBitIncrement )     ///< Remove Bit increment
+#define RemoveBitIncrement(x)       ( ((x) + ( (1 << g_uiBitIncrement) >> 1 )) >> g_uiBitIncrement )     ///< Remove Bit increment
+
+#if POZNAN_LUT_INCREASED_PRECISION
+#define RemoveBitIncrementLUT(x)       (x)     ///< Remove Bit increment
+#define SizeOfLUT                      (256 << g_uiBitIncrement)  
+#else
+#define SizeOfLUT                      256
+#define RemoveBitIncrementLUT(x)       ( ((x) + ( (1 << g_uiBitIncrement) >> 1 )) >> g_uiBitIncrement )     ///< Remove Bit increment
+#endif
 
 #define DATA_ALIGN                  1                                                                 ///< use 32-bit aligned malloc/free
@@ -217,5 +250,10 @@
 #define AMVP_MAX_NUM_CANDS          6           ///< max number of final candidates
 // MERGE
+#if POZNAN_EIVD
+#define MRG_MAX_NUM_CANDS           7
+#define POZNAN_EIVD_MRG_CAND	MRG_MAX_NUM_CANDS-1			// position of EIVD candidate in merge list (0..6)
+#else
 #define MRG_MAX_NUM_CANDS           6
+#endif
 
 // Reference memory management
Index: branches/0.2-poznan-univ/source/Lib/TLibCommon/ContextTables.h
===================================================================
--- branches/0.2-poznan-univ/source/Lib/TLibCommon/ContextTables.h	(revision 11)
+++ branches/0.2-poznan-univ/source/Lib/TLibCommon/ContextTables.h	(revision 12)
@@ -53,5 +53,5 @@
 #define NUM_MERGE_FLAG_EXT_CTX        3       ///< number of context models for merge flag of merge extended
 #define NUM_MERGE_IDX_EXT_CTX         4       ///< number of context models for merge index of merge extended
-#define NUM_MV_MERGE_IDX_EXT_CTX      5       ///< number of context models for merge index of merge extended
+#define NUM_MV_MERGE_IDX_EXT_CTX      6       ///< number of context models for merge index of merge extended
 #define NUM_RES_PRED_FLAG_CTX         3       ///< number of context for residual prediction flag     
 
Index: branches/0.2-poznan-univ/source/Lib/TLibCommon/TComDataCU.cpp
===================================================================
--- branches/0.2-poznan-univ/source/Lib/TLibCommon/TComDataCU.cpp	(revision 11)
+++ branches/0.2-poznan-univ/source/Lib/TLibCommon/TComDataCU.cpp	(revision 12)
@@ -187,4 +187,9 @@
     m_acCUMvField[1].create( uiNumPartition );
     
+#if POZNAN_EIVD_CALC_PRED_DATA
+    m_acCUMvField2nd[0].create( uiNumPartition );
+    m_acCUMvField2nd[1].create( uiNumPartition );
+#endif
+    
 #if HHI_DMM_WEDGE_INTRA
     m_puiWedgeFullTabIdx       = (UInt*)xMalloc(UInt, uiNumPartition);
@@ -210,4 +215,9 @@
     m_acCUMvField[0].setNumPartition(uiNumPartition );
     m_acCUMvField[1].setNumPartition(uiNumPartition );
+
+#if POZNAN_EIVD_CALC_PRED_DATA
+    m_acCUMvField2nd[0].setNumPartition(uiNumPartition );
+    m_acCUMvField2nd[1].setNumPartition(uiNumPartition );
+#endif
   }
   
@@ -296,4 +306,10 @@
     if ( m_piContourPredTexDeltaDC2  ) { xFree(m_piContourPredTexDeltaDC2);  m_piContourPredTexDeltaDC2  = NULL; }
 #endif    
+    
+#if POZNAN_EIVD_CALC_PRED_DATA
+    m_acCUMvField2nd[0].destroy();
+    m_acCUMvField2nd[1].destroy();
+#endif
+
   }
   
@@ -388,4 +404,9 @@
   m_acCUMvField[0].clearMvField();
   m_acCUMvField[1].clearMvField();
+  
+#if POZNAN_EIVD_CALC_PRED_DATA
+  m_acCUMvField2nd[0].clearMvField();
+  m_acCUMvField2nd[1].clearMvField();
+#endif
   
   UInt uiTmp = m_puhWidth[0]*m_puhHeight[0];
@@ -508,4 +529,9 @@
   m_acCUMvField[1].clearMvField();
 
+#if POZNAN_EIVD_CALC_PRED_DATA
+  m_acCUMvField2nd[0].clearMvField();
+  m_acCUMvField2nd[1].clearMvField();
+#endif
+
 #if HHI_DMM_WEDGE_INTRA
   memset( m_puiWedgeFullTabIdx,  0, iSizeInUInt   );
@@ -617,4 +643,9 @@
   m_uiEntropySliceStartCU   = pcCU->getEntropySliceStartCU();
 
+#if POZNAN_EIVD_CALC_PRED_DATA
+  m_acCUMvField2nd[0].clearMvField();
+  m_acCUMvField2nd[1].clearMvField();
+#endif
+
 #if HHI_DMM_WEDGE_INTRA
   memset( m_puiWedgeFullTabIdx,  0, iSizeInUInt   );
@@ -719,4 +750,14 @@
   m_acCUMvField[1].setMvdPtr(pcCU->getCUMvField(REF_PIC_LIST_1)->getMvd()    + uiPart);
   m_acCUMvField[1].setRefIdxPtr(pcCU->getCUMvField(REF_PIC_LIST_1)->getRefIdx() + uiPart);
+
+#if POZNAN_EIVD_CALC_PRED_DATA
+  m_acCUMvField2nd[0].setMvPtr(pcCU->getCUMvField2nd(REF_PIC_LIST_0)->getMv()     + uiPart);
+  m_acCUMvField2nd[0].setMvdPtr(pcCU->getCUMvField2nd(REF_PIC_LIST_0)->getMvd()    + uiPart);
+  m_acCUMvField2nd[0].setRefIdxPtr(pcCU->getCUMvField2nd(REF_PIC_LIST_0)->getRefIdx() + uiPart);
+  m_acCUMvField2nd[1].setMvPtr(pcCU->getCUMvField2nd(REF_PIC_LIST_1)->getMv()     + uiPart);
+  m_acCUMvField2nd[1].setMvdPtr(pcCU->getCUMvField2nd(REF_PIC_LIST_1)->getMvd()    + uiPart);
+  m_acCUMvField2nd[1].setRefIdxPtr(pcCU->getCUMvField2nd(REF_PIC_LIST_1)->getRefIdx() + uiPart);
+#endif
+
   m_uiSliceStartCU        = pcCU->getSliceStartCU();
   m_uiEntropySliceStartCU = pcCU->getEntropySliceStartCU();
@@ -787,4 +828,11 @@
   m_acCUMvField[eRefPicList].setMvdPtr(pcCU->getCUMvField(eRefPicList)->getMvd()    + uiAbsPartIdx);
   m_acCUMvField[eRefPicList].setRefIdxPtr(pcCU->getCUMvField(eRefPicList)->getRefIdx() + uiAbsPartIdx);
+
+#if POZNAN_EIVD_CALC_PRED_DATA
+  m_acCUMvField2nd[eRefPicList].setMvPtr(pcCU->getCUMvField2nd(eRefPicList)->getMv()     + uiAbsPartIdx);
+  m_acCUMvField2nd[eRefPicList].setMvdPtr(pcCU->getCUMvField2nd(eRefPicList)->getMvd()    + uiAbsPartIdx);
+  m_acCUMvField2nd[eRefPicList].setRefIdxPtr(pcCU->getCUMvField2nd(eRefPicList)->getRefIdx() + uiAbsPartIdx);
+#endif
+
 #if HHI_MPI
   m_piTextureModeDepth = pcCU->getTextureModeDepth() + uiAbsPartIdx;
@@ -857,4 +905,9 @@
   m_acCUMvField[1].copyFrom( pcCU->getCUMvField( REF_PIC_LIST_1 ), pcCU->getTotalNumPart(), uiOffset );
   
+#if POZNAN_EIVD_CALC_PRED_DATA
+  m_acCUMvField2nd[0].copyFrom( pcCU->getCUMvField2nd( REF_PIC_LIST_0 ), pcCU->getTotalNumPart(), uiOffset );
+  m_acCUMvField2nd[1].copyFrom( pcCU->getCUMvField2nd( REF_PIC_LIST_1 ), pcCU->getTotalNumPart(), uiOffset );
+#endif
+
   UInt uiTmp  = g_uiMaxCUWidth*g_uiMaxCUHeight >> (uiDepth<<1);
   UInt uiTmp2 = uiPartUnitIdx*uiTmp;
@@ -943,4 +996,9 @@
   m_acCUMvField[0].copyTo( rpcCU->getCUMvField( REF_PIC_LIST_0 ), m_uiAbsIdxInLCU );
   m_acCUMvField[1].copyTo( rpcCU->getCUMvField( REF_PIC_LIST_1 ), m_uiAbsIdxInLCU );
+  
+#if POZNAN_EIVD_CALC_PRED_DATA
+  m_acCUMvField2nd[0].copyTo( rpcCU->getCUMvField2nd( REF_PIC_LIST_0 ), m_uiAbsIdxInLCU );
+  m_acCUMvField2nd[1].copyTo( rpcCU->getCUMvField2nd( REF_PIC_LIST_1 ), m_uiAbsIdxInLCU );
+#endif
   
   UInt uiTmp  = (g_uiMaxCUWidth*g_uiMaxCUHeight)>>(uhDepth<<1);
@@ -1030,4 +1088,9 @@
   m_acCUMvField[0].copyTo( rpcCU->getCUMvField( REF_PIC_LIST_0 ), m_uiAbsIdxInLCU, uiPartStart, uiQNumPart );
   m_acCUMvField[1].copyTo( rpcCU->getCUMvField( REF_PIC_LIST_1 ), m_uiAbsIdxInLCU, uiPartStart, uiQNumPart );
+  
+#if POZNAN_EIVD_CALC_PRED_DATA
+  m_acCUMvField2nd[0].copyTo( rpcCU->getCUMvField2nd( REF_PIC_LIST_0 ), m_uiAbsIdxInLCU, uiPartStart, uiQNumPart );
+  m_acCUMvField2nd[1].copyTo( rpcCU->getCUMvField2nd( REF_PIC_LIST_1 ), m_uiAbsIdxInLCU, uiPartStart, uiQNumPart );
+#endif
   
   UInt uiTmp  = (g_uiMaxCUWidth*g_uiMaxCUHeight)>>((uhDepth+uiPartDepth)<<1);
@@ -2697,4 +2760,9 @@
 #endif
   
+#if POZNAN_EIVD
+  Bool bEIVDMerge = getSlice()->getMP()->isEIVDEnabled();
+  UInt uiEIVDAddr = POZNAN_EIVD_MRG_CAND;
+#endif
+  
   bool abCandIsInter[ MRG_MAX_NUM_CANDS ];
   for( UInt ui = 0; ui < MRG_MAX_NUM_CANDS; ++ui )
@@ -2712,5 +2780,5 @@
   }
   if( pcCULeft && !pcCULeft->isIntra( uiLeftPartIdx ) 
-#if POZNAN_ENCODE_ONLY_DISOCCLUDED_CU
+#if POZNAN_CU_SKIP
     && !pcCULeft->isCUSkiped( uiLeftPartIdx )
 #endif
@@ -2742,5 +2810,5 @@
   }
   if ( pcCUAbove && !pcCUAbove->isIntra( uiAbovePartIdx ) 
-#if POZNAN_ENCODE_ONLY_DISOCCLUDED_CU
+#if POZNAN_CU_SKIP
     && !pcCUAbove->isCUSkiped( uiAbovePartIdx )
 #endif
@@ -3191,12 +3259,63 @@
 #endif
 
+#if POZNAN_EIVD
+  //===== add point-to-point merge with depth maps =====
+  if ( bEIVDMerge )
+  {
+    //prediction of motion data for points with disocclusion:
+	UInt uiRefArrayAddr = uiEIVDAddr;
+	for(UInt ui=0; ui<MRG_MAX_NUM_CANDS; ui++) if ( ui!=uiEIVDAddr && abCandIsInter[ui] ) {uiRefArrayAddr = ui; break;}	
+	if(uiRefArrayAddr != uiEIVDAddr)
+	{
+		puhInterDirNeighbours[uiEIVDAddr] = puhInterDirNeighbours[uiRefArrayAddr];
+		pcMvFieldNeighbours[uiEIVDAddr << 1].setMvField(pcMvFieldNeighbours[uiRefArrayAddr << 1].getMv(),pcMvFieldNeighbours[uiRefArrayAddr << 1].getRefIdx());
+		pcMvFieldNeighbours[(uiEIVDAddr << 1)+1].setMvField(pcMvFieldNeighbours[(uiRefArrayAddr << 1)+1].getMv(),pcMvFieldNeighbours[(uiRefArrayAddr << 1)+1].getRefIdx());
+	}
+	else
+	{
+		TComMv cMVzero; cMVzero.setZero();
+		if( getSlice()->isInterB() ) 
+		{
+			puhInterDirNeighbours[uiEIVDAddr] = 3;
+			pcMvFieldNeighbours[uiEIVDAddr << 1].setMvField(cMVzero,0);
+			pcMvFieldNeighbours[(uiEIVDAddr << 1)+1].setMvField(cMVzero,0);
+		}
+		else 
+		{
+			if(getSlice()->getNumRefIdx(REF_PIC_LIST_0)>0) 
+			{
+				puhInterDirNeighbours[uiEIVDAddr] = 1;
+				pcMvFieldNeighbours[uiEIVDAddr << 1].setMvField(cMVzero,0);
+			}
+			else if(getSlice()->getNumRefIdx(REF_PIC_LIST_1)>0) 
+			{
+				puhInterDirNeighbours[uiEIVDAddr] = 2;
+				pcMvFieldNeighbours[(uiEIVDAddr << 1)+1].setMvField(cMVzero,0);
+			}
+			else puhInterDirNeighbours[uiEIVDAddr] = 0;
+		}
+	}	
+	if(puhInterDirNeighbours[uiEIVDAddr])
+	{		
+		abCandIsInter[uiEIVDAddr] = true;
+		puiNeighbourCandIdx[uiEIVDAddr] = uiEIVDAddr + 1;
+	}
+  }
+#endif
+
 
   //===== remove duplicates =====
   for( UInt uiOuter = 0; uiOuter < MRG_MAX_NUM_CANDS; uiOuter++ )
   {
+#if POZNAN_EIVD
+    if(uiOuter==POZNAN_EIVD_MRG_CAND) continue;
+#endif
     if( abCandIsInter[ uiOuter ] && ( puiNeighbourCandIdx[uiOuter] == uiOuter + 1 ) )
     {
       for( UInt uiIter = uiOuter + 1; uiIter < MRG_MAX_NUM_CANDS; uiIter++ )
       {
+#if POZNAN_EIVD
+        if(uiIter==POZNAN_EIVD_MRG_CAND) continue;
+#endif
         if( abCandIsInter[ uiIter ] )
         {
@@ -3280,5 +3399,5 @@
   {
     if( pcCorner && !pcCorner->isIntra( uiCornerPUIdx ) 
-#if POZNAN_ENCODE_ONLY_DISOCCLUDED_CU
+#if POZNAN_CU_SKIP
        && !pcCorner->isCUSkiped( uiCornerPUIdx )
 #endif
@@ -3319,5 +3438,5 @@
   {
     if( pcCorner && !pcCorner->isIntra( uiCornerPUIdx ) 
-#if POZNAN_ENCODE_ONLY_DISOCCLUDED_CU
+#if POZNAN_CU_SKIP
        && !pcCorner->isCUSkiped( uiCornerPUIdx )
 #endif
@@ -4441,6 +4560,6 @@
   if (pColCU->isIntra(uiPartIdxCenter))
     return false;
-
-#if POZNAN_ENCODE_ONLY_DISOCCLUDED_CU
+  
+#if POZNAN_CU_SKIP
   if (pColCU->isSkipped(uiPartIdxCenter))
     return false;
@@ -4804,4 +4923,25 @@
   }
 #endif
+
+#if POZNAN_EIVD_CALC_PRED_DATA
+  pcCU->getCUMvField2nd( REF_PIC_LIST_0 )->copyTo( &m_acCUMvField2nd[0], -Int(uiAbsPartIdxSrc) + uiAbsPartIdxDst, uiAbsPartIdxSrc, uiNumPartition );
+  pcCU->getCUMvField2nd( REF_PIC_LIST_1 )->copyTo( &m_acCUMvField2nd[1], -Int(uiAbsPartIdxSrc) + uiAbsPartIdxDst, uiAbsPartIdxSrc, uiNumPartition );
+#if HHI_FULL_PEL_DEPTH_MAP_MV_ACC
+  for( UInt ui = 0; ui < uiNumPartition; ui++ )
+  {
+    m_acCUMvField2nd[0].getMv( uiAbsPartIdxDst + ui ) += TComMv( 2, 2 );
+    m_acCUMvField2nd[0].getMv( uiAbsPartIdxDst + ui ) >>= 2;
+
+    m_acCUMvField2nd[1].getMv( uiAbsPartIdxDst + ui ) += TComMv( 2, 2 );
+    m_acCUMvField2nd[1].getMv( uiAbsPartIdxDst + ui ) >>= 2;
+
+    m_acCUMvField2nd[0].getMvd( uiAbsPartIdxDst + ui ) += TComMv( 2, 2 );
+    m_acCUMvField2nd[0].getMvd( uiAbsPartIdxDst + ui ) >>= 2;
+
+    m_acCUMvField2nd[1].getMvd( uiAbsPartIdxDst + ui ) += TComMv( 2, 2 );
+    m_acCUMvField2nd[1].getMvd( uiAbsPartIdxDst + ui ) >>= 2;
+  }
+#endif
+#endif
 }
 #endif
@@ -4812,2 +4952,314 @@
   riPosY = g_auiRasterToPelY[g_auiZscanToRaster[uiAbsPartIndex]] + getCUPelY();  
 }
+#if POZNAN_TEXTURE_TU_DELTA_QP_ACCORDING_TO_DEPTH
+Int TComDataCU::CuQpIncrementFunction(Pel uiBlockMax)
+{
+  if((uiBlockMax >> g_uiBitIncrement) >= 256 || (uiBlockMax >> g_uiBitIncrement) <0)
+  {
+    fprintf(stderr, "Bitincrement = %d, uiBlockMax = %d\n", g_uiBitIncrement, uiBlockMax);
+    exit(333);
+  }
+  Float fVal = (Float)((255 - (uiBlockMax >> g_uiBitIncrement)) >> 4);
+  fVal = (fVal * fVal);
+#if POZNAN_TEXTURE_TU_DELTA_QP_PARAM_IN_CFG_FOR_ENC
+  fVal = (Float)( fVal + getPic()->getTextureCuDeltaQpOffset() * 32); // add offset, if offset is negative than objects in front will have smaller QP than originaly - quality in front will be increased and in bacground will be decreased
+  fVal = (Float)( fVal * getPic()->getTextureCuDeltaQpMul()); // 
+#else 
+  fVal = (Float)( fVal + POZNAN_TEXTURE_TU_DELTA_QP_OFFSET * 32); // add offset, if offset is negative objects in front will have smaller QP than in original approach - quality in front will be increased and in bacground will be decreased
+  fVal = (Float)( fVal * POZNAN_TEXTURE_TU_DELTA_QP_MUL); // 
+#endif
+  return (Int)fVal >> 5;
+}
+ Int  TComDataCU::getQpOffsetForTextCU(UInt uiPartIdx, Bool bIsIntra)
+ {
+   //if(!isTexture(getSlice()->getViewId()))
+   if(this->getPic()->getSlice(0)->getSPS()->isDepth())
+   {
+     return 0;
+   }
+#if POZNAN_TEXTURE_TU_DELTA_QP_NOT_IN_BASE_VIEW
+   //if(!getPic()->getIsSideView())
+   if(this->getPic()->getViewIdx() == 0)//KUBA czy indeksy na pewno s¹ od zera?
+   {
+     return 0;
+   }
+#endif
+   UInt iCuAddr = getAddr();
+   //TComPic * pcDepthPic = getPic()->getDepthPic();
+   TComPicYuv * pcDepthPicYUV = getPic()->getPicYuvSynthDepth();
+   if(pcDepthPicYUV /*pcDepthPic*/ == NULL)
+   {
+    char errortext[200];
+    sprintf(errortext, "depth map expected");
+    fprintf(stderr, "%s\n", errortext);
+    exit(123);
+   }
+   //TComDataCU* rpcCUDepth = pcDepthPic->getCU(iCuAddr);
+   Pel uiDepthLumaTransformBlockMax;
+   if(bIsIntra)
+   {
+     // in intra block CU each TU block has QP chosen separatly so dQP is calculated for TU
+     uiDepthLumaTransformBlockMax = getDepthLumaTransformBlockMax( pcDepthPicYUV /*rpcCUDepth*/, iCuAddr, uiPartIdx );
+   }
+   else
+   {
+     // in inter block CU all TU block has the same QP so dQP is calculated for CU
+     uiDepthLumaTransformBlockMax = getDepthLumaCodingBlockMax( pcDepthPicYUV /*rpcCUDepth*/, iCuAddr, uiPartIdx );
+   }
+#if POZNAN_NONLINEAR_DEPTH
+   //Pel liczby_w[256];
+   //Pel liczby_t[256];
+   //Pel liczby_o[256];
+   //Float p = 1.9;
+   //TComPowerConverter powconv_t(p, g_uiBitIncrement, g_uiBitIncrement); 
+   //TComPowerConverter powconv_o(1.0f/p, g_uiBitIncrement, g_uiBitIncrement); 
+   //for(UInt i = 0; i <256; i++)
+   //{
+   //  liczby_w[i] = i<<2;
+   //  liczby_t[i] = (Pel)( powconv_t(liczby_w[i]) + 0.5);
+   //  liczby_o[i] = (Pel)( powconv_o(liczby_t[i]) + 0.5)>>2;
+   //}
+   //printf("\n");
+   //if(bIsIntra)printf("intra ");
+   //else        printf("inter ");
+   //printf("in:%d, ", uiDepthLumaTransformBlockMax);
+   Float p = 1.0f / getSlice()->getSPS()->getDepthPower();
+   //printf("p:%f, ", p);
+   TComPowerConverter powconv(p, g_uiBitIncrement, g_uiBitIncrement); 
+   uiDepthLumaTransformBlockMax = (Pel)( powconv(uiDepthLumaTransformBlockMax) + 0.5);
+   //printf("out:%d, ", uiDepthLumaTransformBlockMax);
+#endif
+   Int iDeltaQP = CuQpIncrementFunction(uiDepthLumaTransformBlockMax);
+   //printf("dQP:%d ", iDeltaQP);
+#if POZNAN_TEXTURE_TU_DELTA_QP_TOP_BOTTOM_CU_ROW
+   Int iMaxCUHeight = this->getPic()->getPicSym()->getMaxCUHeight();
+   Int iPicHeight   = this->getPic()->getPicSym()->getPicHeight();
+   Int iLastPelYInFirstCURow = 0 + iMaxCUHeight;
+   Int iFirstPelYInLastCURow = iPicHeight - iMaxCUHeight;
+   Int iCUStartPelY = getCUPelY();
+   if((iCUStartPelY <= iLastPelYInFirstCURow) || (iCUStartPelY >= iFirstPelYInLastCURow))
+   {
+#if POZNAN_TEXTURE_TU_DELTA_QP_PARAM_IN_CFG_FOR_ENC
+     iDeltaQP += getPic()->getTextureCuDeltaQpTopBottomRow();// POZNAN_TEXTURE_TU_DELTA_QP_TOP_BOTTOM_CU_ROW;
+#else
+     iDeltaQP += POZNAN_TEXTURE_TU_DELTA_QP_TOP_BOTTOM_ROW_VAL;// POZNAN_TEXTURE_TU_DELTA_QP_TOP_BOTTOM_CU_ROW;
+#endif
+   }
+#endif
+   return iDeltaQP;
+ }
+
+Int cmpProc(const Void *arg1, const Void *arg2)
+{
+    return *((Pel*)arg2) - *((Pel*)arg1);
+}
+
+// Function gets median value of depth block that has the same size and position as texture block that calls this function
+Pel  TComDataCU::getDepthLumaCodingBlockMedian( TComPicYuv * pcDepthPicYUV/*TComDataCU* rpcCUDepth*/, UInt iCuAddr, UInt uiPartIdx )
+{  
+  static Pel pSortTable [64 * 64];
+  Int CUWidth, CUHeight;
+  sortDepthLumaCodingBlock( pcDepthPicYUV /*rpcCUDepth*/, iCuAddr, uiPartIdx, pSortTable, CUWidth, CUHeight );
+  return pSortTable[(CUHeight * CUWidth) / 2];
+}
+
+// Function gets maximal value of depth block that has the same size and position as texture block that calls this function
+Pel TComDataCU::getDepthLumaCodingBlockMax( TComPicYuv * pcDepthPicYUV/*TComDataCU* rpcCUDepth*/, UInt iCuAddr, UInt uiPartIdx )
+{  
+  return maxDepthLumaCodingBlock( pcDepthPicYUV /*rpcCUDepth*/, iCuAddr, uiPartIdx);  
+}
+Void TComDataCU::sortDepthLumaCodingBlock ( TComPicYuv * pcDepthPicYUV/*TComDataCU* rpcCUDepth*/, UInt iCuAddr, UInt uiPartIdx, Pel * pSortTable, Int& CUWidth, Int& CUHeight )
+{
+  Int x, y;
+  UInt uiAbsZorderIdx  = getZorderIdxInCU() + uiPartIdx;
+  // CU size: 
+  CUHeight = getHeight(uiPartIdx); // Size is based on coded texture block size not on depth picture size
+  CUWidth  = getWidth(uiPartIdx); 
+  // uiAbsZorderIdx is z order idx of one particular base block (4x4 pix) in block that we process
+  // What we need is z-order idx of first Base block (4x4 pix) in this block
+  Int iNumBase4x4InBlock = (CUWidth >> 2) * (CUHeight >> 2);
+
+  UInt uiAbsZorderIdxBlockStart = (uiAbsZorderIdx / iNumBase4x4InBlock) * iNumBase4x4InBlock;
+  // Address of block
+  Pel* pPel   = pcDepthPicYUV/*rpcCUDepth->getPic()->getPicYuvRec()*/->getLumaAddr ( iCuAddr, uiAbsZorderIdxBlockStart );
+
+  Int p =0;
+  Int iStride  = getPic()->getPicYuvRec()->getStride();
+  for ( y = CUHeight - 1; y >= 0; y-- )
+  {
+    for ( x = CUWidth - 1; x >= 0; x-- )
+    {
+      pSortTable[p] = pPel[x]; ++p;
+    }
+    pPel += iStride;
+  }
+  // sort elements
+  qsort(pSortTable, CUHeight * CUWidth, sizeof(Pel), cmpProc);
+}
+
+Pel TComDataCU::maxDepthLumaCodingBlock ( TComPicYuv * pcDepthPicYUV/*TComDataCU* rpcCUDepth*/, UInt iCuAddr, UInt uiPartIdx)
+{
+  Int x, y;
+  UInt uiAbsZorderIdx  = getZorderIdxInCU() + uiPartIdx;
+  // CU size: 
+  Int CUHeight = getHeight(uiPartIdx); // Size is based on coded texture block size not on depth picture size
+  Int CUWidth  = getWidth(uiPartIdx); 
+  // uiAbsZorderIdx is z order idx of one particular base block (4x4 pix) in block that we process
+  // What we need is z-order idx of first Base block (4x4 pix) in this block
+  Int iNumBase4x4InBlock = (CUWidth >> 2) * (CUHeight >> 2);
+
+  UInt uiAbsZorderIdxBlockStart = (uiAbsZorderIdx / iNumBase4x4InBlock) * iNumBase4x4InBlock;
+  // Address of block
+  Pel* pPel   = pcDepthPicYUV/*rpcCUDepth->getPic()->getPicYuvRec()*/->getLumaAddr ( iCuAddr, uiAbsZorderIdxBlockStart );
+
+  Pel  pValue = 0;
+  Int  iStride = getPic()->getPicYuvRec()->getStride();
+  for ( y = CUHeight - 1; y >= 0; y-- )
+  {
+    for ( x = CUWidth - 1; x >= 0; x-- )
+    {
+      if (pPel[x]>pValue) pValue = pPel[x];
+    }
+    pPel += iStride;
+  }
+  return pValue;
+}
+
+// Function gets median value of depth block that has the same size and position as texture block that calls this function
+Pel  TComDataCU::getDepthLumaTransformBlockMedian( TComPicYuv * pcDepthPicYUV/*TComDataCU* rpcCUDepth*/, UInt iCuAddr, UInt uiPartIdx )
+{  
+  static Pel pSortTable [64 * 64];
+  Int TUWidth, TUHeight;
+  sortDepthLumaTransformBlock( pcDepthPicYUV/*rpcCUDepth*/, iCuAddr, uiPartIdx, pSortTable, TUWidth, TUHeight );
+  return pSortTable[(TUHeight * TUWidth) / 2];
+}
+
+// Function gets maximal value of depth block that has the same size and position as texture block that calls this function
+Pel TComDataCU::getDepthLumaTransformBlockMax( TComPicYuv * pcDepthPicYUV/*TComDataCU* rpcCUDepth*/, UInt iCuAddr, UInt uiPartIdx )
+{  
+  return maxDepthLumaTransformBlock( pcDepthPicYUV/*rpcCUDepth*/, iCuAddr, uiPartIdx );
+}
+Void TComDataCU::sortDepthLumaTransformBlock ( TComPicYuv * pcDepthPicYUV/*TComDataCU* rpcCUDepth*/, UInt iCuAddr, UInt uiPartIdx, Pel * pSortTable, Int& TUWidth, Int& TUHeight )
+{
+  Int x, y;
+  UInt uiAbsZorderIdx  = getZorderIdxInCU() + uiPartIdx;
+  // CU size: 
+  TUHeight = getHeight(uiPartIdx); // Size is based on coded texture block size not on depth picture size
+  TUWidth  = getWidth(uiPartIdx); 
+  // correct CU size to trnsform size:
+  if( getTransformIdx(uiPartIdx) )
+  {
+    TUWidth  = TUWidth >> 1;
+    TUHeight = TUHeight >> 1;
+  }
+  // uiAbsZorderIdx is z order idx of one particular base block (4x4 pix) in block that we process
+  // What we need is z-order idx of first Base block (4x4 pix) in this block
+  Int iNumBase4x4InBlock = (TUWidth >> 2) * (TUHeight >> 2);
+
+  UInt uiAbsZorderIdxBlockStart = (uiAbsZorderIdx / iNumBase4x4InBlock) * iNumBase4x4InBlock;
+  // Address of block
+  Pel* pPel   = pcDepthPicYUV/*rpcCUDepth->getPic()->getPicYuvRec()*/->getLumaAddr ( iCuAddr, uiAbsZorderIdxBlockStart );
+
+  int p = 0;
+  Int  iStride  = getPic()->getPicYuvRec()->getStride();
+  for ( y = TUHeight - 1; y >= 0; y-- )
+  {
+    for ( x = TUWidth - 1; x >= 0; x-- )
+    {
+      pSortTable[p] = pPel[x];
+    }
+    pPel += iStride;
+  }
+  // sort elements
+  qsort(pSortTable, TUHeight * TUWidth, sizeof(Pel), cmpProc);
+}
+Pel TComDataCU::maxDepthLumaTransformBlock ( TComPicYuv * pcDepthPicYUV/*TComDataCU* rpcCUDepth*/, UInt iCuAddr, UInt uiPartIdx)
+{
+  Int x, y;
+  UInt uiAbsZorderIdx  = getZorderIdxInCU() + uiPartIdx;
+  // CU size: 
+  Int TUHeight = getHeight(uiPartIdx); // Size is based on coded texture block size not on depth picture size
+  Int TUWidth  = getWidth(uiPartIdx); 
+  // correct CU size to trnsform size:
+  if( getTransformIdx(uiPartIdx) )
+  {
+    TUWidth  = TUWidth >> 1;
+    TUHeight = TUHeight >> 1;
+  }
+  // uiAbsZorderIdx is z order idx of one particular base block (4x4 pix) in block that we process
+  // What we need is z-order idx of first Base block (4x4 pix) in this block
+  Int iNumBase4x4InBlock = (TUWidth >> 2) * (TUHeight >> 2);
+
+  UInt uiAbsZorderIdxBlockStart = (uiAbsZorderIdx / iNumBase4x4InBlock) * iNumBase4x4InBlock;
+  // Address of block
+  Pel* pPel   = pcDepthPicYUV/*rpcCUDepth->getPic()->getPicYuvRec()*/->getLumaAddr ( iCuAddr, uiAbsZorderIdxBlockStart );
+
+  Pel pValue = 0;
+  Int iStride  = getPic()->getPicYuvRec()->getStride();
+  for ( y = TUHeight - 1; y >= 0; y-- )
+  {
+    for ( x = TUWidth - 1; x >= 0; x-- )
+    {
+      if (pPel[x]>pValue) pValue = pPel[x];
+    }
+    pPel += iStride;
+  }
+  return pValue;
+}
+// Function gets median value of depth block that has the same size and position as texture block that calls this function
+Pel  TComDataCU::getDepthLumaPredictionBlockMedian( TComPicYuv * pcDepthPicYUV/*TComDataCU* rpcCUDepth*/, UInt iCuAddr, UInt uiPartIdx )
+{  
+  static Pel pSortTable [64 * 64];
+  Int PUWidth, PUHeight;
+  sortDepthLumaPredictionBlock( pcDepthPicYUV/*rpcCUDepth*/, iCuAddr, uiPartIdx, pSortTable, PUWidth, PUHeight );
+  return pSortTable[(PUHeight * PUWidth) / 2];
+}
+
+// Function gets maximal value of depth block that has the same size and position as texture block that calls this function
+Pel  TComDataCU::getDepthLumaPredictionBlockMax( TComPicYuv * pcDepthPicYUV/*TComDataCU* rpcCUDepth*/, UInt iCuAddr, UInt uiPartIdx )
+{  
+  static Pel pSortTable [64 * 64];
+  Int PUWidth, PUHeight;
+  sortDepthLumaPredictionBlock( pcDepthPicYUV/*rpcCUDepth*/, iCuAddr, uiPartIdx, pSortTable, PUWidth, PUHeight );
+  return pSortTable[0];
+}
+Void TComDataCU::sortDepthLumaPredictionBlock ( TComPicYuv * pcDepthPicYUV/*TComDataCU* rpcCUDepth*/, UInt iCuAddr, UInt uiPartIdx, Pel * pSortTable, Int& PUWidth, Int& PUHeight )
+{
+  Int x, y;
+  UInt uiAbsZorderIdx  = getZorderIdxInCU() + uiPartIdx;
+  // CU size: 
+  PUHeight = getHeight(uiPartIdx); // Size is based on coded texture block size not on depth picture size
+  PUWidth  = getWidth(uiPartIdx); 
+  // correct CU size to partition size:
+  if( getPartitionSize(uiPartIdx) == SIZE_Nx2N || getPartitionSize(uiPartIdx) == SIZE_NxN )
+  {
+    PUWidth = PUWidth >> 1;
+  }
+  if( getPartitionSize(uiPartIdx) == SIZE_2NxN || getPartitionSize(uiPartIdx) == SIZE_NxN )
+  {
+    PUHeight = PUHeight >> 1;
+  }
+  
+  // uiAbsZorderIdx is z order idx of one particular base block (4x4 pix) in block that we process
+  // What we need is z-order idx of first Base block (4x4 pix) in this block
+  Int iNumBase4x4InBlock = (PUWidth >> 2) * (PUHeight >> 2);
+  if(getPartitionSize(uiPartIdx) == SIZE_Nx2N)
+  {
+    iNumBase4x4InBlock = iNumBase4x4InBlock << 1; // KUBA if PU is Nx2N than to count start z-order idx we need to make such trick
+  }
+  UInt uiAbsZorderIdxBlockStart = (uiAbsZorderIdx / iNumBase4x4InBlock) * iNumBase4x4InBlock;
+  // Address of block
+  Pel* pPel   = pcDepthPicYUV/*rpcCUDepth->getPic()->getPicYuvRec()*/->getLumaAddr ( iCuAddr, uiAbsZorderIdxBlockStart );
+
+  UInt  uiStride  = getPic()->getPicYuvRec()->getStride();
+  for ( y = PUHeight - 1; y >= 0; y-- )
+  {
+    for ( x = PUWidth - 1; x >= 0; x-- )
+    {
+      pSortTable[y*PUWidth + x] = pPel[y*uiStride + x];
+    }
+  }
+  // sort elements
+  qsort(pSortTable, PUHeight * PUWidth, sizeof(Pel), cmpProc);
+}
+#endif
Index: branches/0.2-poznan-univ/source/Lib/TLibCommon/TComDataCU.h
===================================================================
--- branches/0.2-poznan-univ/source/Lib/TLibCommon/TComDataCU.h	(revision 11)
+++ branches/0.2-poznan-univ/source/Lib/TLibCommon/TComDataCU.h	(revision 12)
@@ -105,4 +105,8 @@
 #endif//SNY_DQP
   
+#if POZNAN_EIVD_CALC_PRED_DATA
+  TComCUMvField m_acCUMvField2nd[2];              ///< array of motion vectors selected for points with no MP prediction available
+#endif
+  
   // -------------------------------------------------------------------------------------------------------------------
   // neighbour access variables
@@ -310,4 +314,8 @@
 #endif
   
+#if POZNAN_EIVD_CALC_PRED_DATA
+  TComCUMvField* getCUMvField2nd         ( RefPicList e )          { return  &m_acCUMvField2nd[e];  }
+#endif
+  
   // -------------------------------------------------------------------------------------------------------------------
   // member functions for coding tool information
@@ -529,5 +537,5 @@
   Bool          isIntra   ( UInt uiPartIdx )  { return m_pePredMode[ uiPartIdx ] == MODE_INTRA; }
   Bool          isSkipped ( UInt uiPartIdx );                                                     ///< SKIP (no residual)
-#if POZNAN_ENCODE_ONLY_DISOCCLUDED_CU
+#if POZNAN_CU_SKIP
   Bool          isCUSkiped( UInt uiPartIdx )  { return m_pePredMode[ uiPartIdx ] == MODE_SYNTH; }
 #endif
@@ -588,4 +596,19 @@
 #endif //QC_MDCS
 
+#if POZNAN_TEXTURE_TU_DELTA_QP_ACCORDING_TO_DEPTH
+ Int            CuQpIncrementFunction  ( Pel uiBlockMax );
+ Int            getQpOffsetForTextCU   ( UInt uiPartIdx, Bool bIsIntra );
+ Pel            getDepthLumaCodingBlockMedian    ( TComPicYuv * pcDepthPicYUV/*TComDataCU* rpcCUDepth*/, UInt iCuAddr, UInt uiPartIdx );
+ Pel            getDepthLumaCodingBlockMax       ( TComPicYuv * pcDepthPicYUV/*TComDataCU* rpcCUDepth*/, UInt iCuAddr, UInt uiPartIdx );
+ Void           sortDepthLumaCodingBlock         ( TComPicYuv * pcDepthPicYUV/*TComDataCU* rpcCUDepth*/, UInt iCuAddr, UInt uiPartIdx, Pel * pSortTable, Int& TUWidth, Int& TUHeight);
+ Pel            maxDepthLumaCodingBlock          ( TComPicYuv * pcDepthPicYUV/*TComDataCU* rpcCUDepth*/, UInt iCuAddr, UInt uiPartIdx );
+ Pel            getDepthLumaTransformBlockMedian ( TComPicYuv * pcDepthPicYUV/*TComDataCU* rpcCUDepth*/, UInt iCuAddr, UInt uiPartIdx );
+ Pel            getDepthLumaTransformBlockMax    ( TComPicYuv * pcDepthPicYUV/*TComDataCU* rpcCUDepth*/, UInt iCuAddr, UInt uiPartIdx );
+ Void           sortDepthLumaTransformBlock      ( TComPicYuv * pcDepthPicYUV/*TComDataCU* rpcCUDepth*/, UInt iCuAddr, UInt uiPartIdx , Pel * pSortTable, Int& TUWidth, Int& TUHeight);
+ Pel            maxDepthLumaTransformBlock       ( TComPicYuv * pcDepthPicYUV/*TComDataCU* rpcCUDepth*/, UInt iCuAddr, UInt uiPartIdx );
+ Pel            getDepthLumaPredictionBlockMedian( TComPicYuv * pcDepthPicYUV/*TComDataCU* rpcCUDepth*/, UInt iCuAddr, UInt uiPartIdx );
+ Pel            getDepthLumaPredictionBlockMax   ( TComPicYuv * pcDepthPicYUV/*TComDataCU* rpcCUDepth*/, UInt iCuAddr, UInt uiPartIdx );
+ Void           sortDepthLumaPredictionBlock     ( TComPicYuv * pcDepthPicYUV/*TComDataCU* rpcCUDepth*/, UInt iCuAddr, UInt uiPartIdx , Pel * pSortTable, Int& PUWidth, Int& PUHeight);
+#endif
 };
 
Index: branches/0.2-poznan-univ/source/Lib/TLibCommon/TComDepthMapGenerator.cpp
===================================================================
--- branches/0.2-poznan-univ/source/Lib/TLibCommon/TComDepthMapGenerator.cpp	(revision 11)
+++ branches/0.2-poznan-univ/source/Lib/TLibCommon/TComDepthMapGenerator.cpp	(revision 12)
@@ -478,4 +478,7 @@
   Pel*        pSrcSamples = pcPicYuv->getLumaAddr ( 0 );
   Pel*        pDstSamples = m_cTmpPic.getLumaAddr ( 0 );
+  Int         iDstStrideC  = m_cTmpPic.getCStride ( );
+  Pel*        pDstSamplesCb = m_cTmpPic.getCbAddr ( 0 );
+  Pel*        pDstSamplesCr = m_cTmpPic.getCrAddr ( 0 );
   Int         iMidOrgDpth = ( 1 << m_uiOrgDepthBitDepth ) >> 1;
   AOF( m_cTmpPic.getWidth () == iWidth  );
@@ -483,6 +486,16 @@
   for( Int iY = 0; iY < iHeight; iY++, pSrcSamples += iSrcStride, pDstSamples += iDstStride )
   {
+    if((iY%2) == 0 && iY != 0)
+    {
+      pDstSamplesCb += iDstStrideC; 
+      pDstSamplesCr += iDstStrideC;
+    }
     for( Int iX = 0; iX < iWidth; iX++ )
     {
+      if(pSrcSamples[ iX ] < 0)//== PDM_UNDEFINED_DEPTH)
+      {
+        pDstSamplesCb[ iX>>1 ] = 0;
+        pDstSamplesCr[ iX>>1 ] = 0;
+      }
       Int iOrgDepth     = ( pSrcSamples[ iX ] != PDM_UNDEFINED_DEPTH ? xGetOrigDepthFromVirtDepth( uiViewId, pSrcSamples[ iX ] ) : iMidOrgDpth );
       pDstSamples[ iX ] = Max( 0, Min( iMax, iOrgDepth ) );
@@ -494,4 +507,15 @@
   ::sprintf     ( acFilename, "%s_V%d.yuv", pFilenameBase, uiViewId );
   m_cTmpPic.dump( acFilename, ( pcPic->getPOC() != 0 )  );
+
+  pDstSamplesCb = m_cTmpPic.getCbAddr ( 0 );
+  pDstSamplesCr = m_cTmpPic.getCrAddr ( 0 );
+  for( Int iY = 0; iY < iHeight>>1; iY++, pDstSamplesCb += iDstStrideC, pDstSamplesCr += iDstStrideC)
+  {
+    for( Int iX = 0; iX < iWidth>>1; iX++ )
+    {
+      pDstSamplesCb[ iX ] = iMidOrgDpth;
+      pDstSamplesCr[ iX ] = iMidOrgDpth;
+    }
+  }
 }
 
@@ -971,7 +995,7 @@
     xInterPredictCUDepthMap( pcSubCU, pcSubDM );
     break;
-#if POZNAN_ENCODE_ONLY_DISOCCLUDED_CU
+#if POZNAN_CU_SKIP
   case MODE_SYNTH:
-    //What to do? Need Fix!
+    //What to do? Need Fix?
     xIntraPredictCUDepthMap( pcSubCU, pcSubDM );
     break;
Index: branches/0.2-poznan-univ/source/Lib/TLibCommon/TComLoopFilter.cpp
===================================================================
--- branches/0.2-poznan-univ/source/Lib/TLibCommon/TComLoopFilter.cpp	(revision 11)
+++ branches/0.2-poznan-univ/source/Lib/TLibCommon/TComLoopFilter.cpp	(revision 12)
@@ -445,5 +445,5 @@
   //-- Set BS for Intra MB : BS = 4 or 3
   if ( pcCUP->isIntra(uiPartP) || pcCUQ->isIntra(uiPartQ) 
-#if POZNAN_ENCODE_ONLY_DISOCCLUDED_CU
+#if POZNAN_CU_SKIP && POZNAN_CU_SYNTH
      || pcCUP->isCUSkiped(uiPartP) || pcCUQ->isCUSkiped(uiPartQ) 
 #endif
@@ -455,5 +455,5 @@
   //-- Set BS for not Intra MB : BS = 2 or 1 or 0
   if ( !pcCUP->isIntra(uiPartP) && !pcCUQ->isIntra(uiPartQ) 
-#if POZNAN_ENCODE_ONLY_DISOCCLUDED_CU
+#if POZNAN_CU_SKIP && POZNAN_CU_SYNTH
      && !pcCUP->isCUSkiped(uiPartP) && !pcCUQ->isCUSkiped(uiPartQ) 
 #endif
@@ -536,5 +536,5 @@
   }   // enf of "if( not Intra )"
 
-#if POZNAN_ENCODE_ONLY_DISOCCLUDED_CU //if one of the block is CUSkipped dont use loop filter
+#if POZNAN_CU_SKIP //if one of the block is CUSkipped dont use loop filter
   if ( pcCUP->isCUSkiped(uiPartP) || pcCUQ->isCUSkiped(uiPartQ))
   {
Index: branches/0.2-poznan-univ/source/Lib/TLibCommon/TComPic.cpp
===================================================================
--- branches/0.2-poznan-univ/source/Lib/TLibCommon/TComPic.cpp	(revision 11)
+++ branches/0.2-poznan-univ/source/Lib/TLibCommon/TComPic.cpp	(revision 12)
@@ -50,9 +50,12 @@
   m_apcPicYuv[0]      = NULL;
   m_apcPicYuv[1]      = NULL;
-#if POZNAN_AVAIL_MAP
+#if POZNAN_CU_SYNTH || POZNAN_CU_SKIP || POZNAN_TEXTURE_TU_DELTA_QP_ACCORDING_TO_DEPTH
   m_apcPicYuvAvail     = NULL;
 #endif
-#if POZNAN_SYNTH_VIEW
+#if POZNAN_CU_SYNTH
   m_apcPicYuvSynth     = NULL;
+#if POZNAN_TEXTURE_TU_DELTA_QP_ACCORDING_TO_DEPTH
+  m_apcPicYuvSynthDepth= NULL; 
+#endif
 #endif
 #if DEPTH_MAP_GENERATION
@@ -122,5 +125,5 @@
     m_apcPicYuv[1]  = NULL;
   }
-#if POZNAN_AVAIL_MAP
+#if POZNAN_CU_SYNTH || POZNAN_CU_SKIP || POZNAN_TEXTURE_TU_DELTA_QP_ACCORDING_TO_DEPTH
   if (m_apcPicYuvAvail)
   {
@@ -131,5 +134,5 @@
 #endif
 
-#if POZNAN_SYNTH_VIEW
+#if POZNAN_CU_SYNTH
   if (m_apcPicYuvSynth)
   {
@@ -138,4 +141,12 @@
     m_apcPicYuvSynth  = NULL;
   }
+#if POZNAN_TEXTURE_TU_DELTA_QP_ACCORDING_TO_DEPTH
+  if (m_apcPicYuvSynthDepth)
+  {
+    m_apcPicYuvSynthDepth->destroy();
+    delete m_apcPicYuvSynthDepth;
+    m_apcPicYuvSynthDepth  = NULL;
+  }
+#endif
 #endif
   
@@ -216,5 +227,5 @@
 }
 
-#if POZNAN_AVAIL_MAP
+#if POZNAN_CU_SYNTH || POZNAN_CU_SKIP || POZNAN_TEXTURE_TU_DELTA_QP_ACCORDING_TO_DEPTH
 Void
 TComPic::addAvailabilityBuffer()
@@ -232,5 +243,5 @@
 #endif
 
-#if POZNAN_SYNTH_VIEW
+#if POZNAN_CU_SYNTH
 Void
 TComPic::addSynthesisBuffer()
@@ -246,4 +257,19 @@
   m_apcPicYuvSynth      ->create( iWidth, iHeight, uiMaxCuWidth, uiMaxCuHeight, uiMaxCuDepth );
 }
+#if POZNAN_TEXTURE_TU_DELTA_QP_ACCORDING_TO_DEPTH
+Void
+TComPic::addSynthesisDepthBuffer()
+{
+  AOT( m_apcPicYuvSynthDepth );
+  AOF( m_apcPicYuv[1] );
+  Int   iWidth        = m_apcPicYuv[1]->getWidth      ();
+  Int   iHeight       = m_apcPicYuv[1]->getHeight     ();
+  UInt  uiMaxCuWidth  = m_apcPicYuv[1]->getMaxCuWidth ();
+  UInt  uiMaxCuHeight = m_apcPicYuv[1]->getMaxCuHeight();
+  UInt  uiMaxCuDepth  = m_apcPicYuv[1]->getMaxCuDepth ();
+  m_apcPicYuvSynthDepth      = new TComPicYuv;
+  m_apcPicYuvSynthDepth      ->create( iWidth, iHeight, uiMaxCuWidth, uiMaxCuHeight, uiMaxCuDepth );
+}
+#endif
 #endif
 
@@ -339,5 +365,5 @@
 }
 
-#if POZNAN_AVAIL_MAP
+#if POZNAN_CU_SYNTH || POZNAN_CU_SKIP || POZNAN_TEXTURE_TU_DELTA_QP_ACCORDING_TO_DEPTH
 Void
 TComPic::removeAvailabilityBuffer()
@@ -352,5 +378,5 @@
 #endif
 
-#if POZNAN_SYNTH_VIEW
+#if POZNAN_CU_SYNTH
 Void
 TComPic::removeSynthesisBuffer()
@@ -363,4 +389,16 @@
   }
 }
+#if POZNAN_TEXTURE_TU_DELTA_QP_ACCORDING_TO_DEPTH
+Void
+TComPic::removeSynthesisDepthBuffer()
+{
+  if( m_apcPicYuvSynthDepth )
+  {
+    m_apcPicYuvSynthDepth->destroy();
+    delete m_apcPicYuvSynthDepth;
+    m_apcPicYuvSynthDepth  = NULL;
+  }
+}
+#endif
 #endif
 
@@ -430,5 +468,5 @@
 #endif
 
-#if POZNAN_AVAIL_MAP
+#if POZNAN_CU_SYNTH || POZNAN_CU_SKIP
 Void TComPic::checkSynthesisAvailability( TComDataCU*& rpcCU, UInt iCuAddr, UInt uiAbsZorderIdx, UInt uiPartDepth, Bool *&rpbCUSynthesied )
 { 
Index: branches/0.2-poznan-univ/source/Lib/TLibCommon/TComPic.h
===================================================================
--- branches/0.2-poznan-univ/source/Lib/TLibCommon/TComPic.h	(revision 11)
+++ branches/0.2-poznan-univ/source/Lib/TLibCommon/TComPic.h	(revision 12)
@@ -62,10 +62,13 @@
   TComPicYuv*           m_apcPicYuv[2];           //  Texture,  0:org / 1:rec
 
-#if POZNAN_AVAIL_MAP
+#if POZNAN_CU_SYNTH || POZNAN_CU_SKIP || POZNAN_TEXTURE_TU_DELTA_QP_ACCORDING_TO_DEPTH
   TComPicYuv*           m_apcPicYuvAvail;         //  Availability Map - Does the given pixel can be synthesised in receiver
 #endif
 
-#if POZNAN_SYNTH_VIEW
+#if POZNAN_CU_SYNTH
   TComPicYuv*           m_apcPicYuvSynth;         //  Sythesied image
+#if POZNAN_TEXTURE_TU_DELTA_QP_ACCORDING_TO_DEPTH
+  TComPicYuv*           m_apcPicYuvSynthDepth;         //  Sythesied depth image
+#endif
 #endif
 
@@ -107,4 +110,9 @@
 #if HHI_INTERVIEW_SKIP
   TComPicYuv*           m_pcUsedPelsMap;
+#endif
+#if POZNAN_TEXTURE_TU_DELTA_QP_PARAM_IN_CFG_FOR_ENC 
+  Double                m_dTextureCuDeltaQpOffset;
+  Double                m_dTextureCuDeltaQpMul;
+  Int                   m_iTextureCuDeltaQpTopBottomRow; 
 #endif
 
@@ -136,10 +144,13 @@
   TComPicYuv*   getPicYuvRec()        { return  m_apcPicYuv[1]; }
 
-#if POZNAN_AVAIL_MAP
+#if POZNAN_CU_SYNTH || POZNAN_CU_SKIP || POZNAN_TEXTURE_TU_DELTA_QP_ACCORDING_TO_DEPTH
   TComPicYuv*   getPicYuvAvail()      { return  m_apcPicYuvAvail; } //Owieczka - returns available map from other pic image
 #endif
 
-#if POZNAN_SYNTH_VIEW
+#if POZNAN_CU_SYNTH
   TComPicYuv*   getPicYuvSynth()      { return  m_apcPicYuvSynth; } //Owieczka - returns synth form other pic in image
+#if POZNAN_TEXTURE_TU_DELTA_QP_ACCORDING_TO_DEPTH
+  TComPicYuv*   getPicYuvSynthDepth() { return  m_apcPicYuvSynthDepth; };    //  Sythesied depth image
+#endif
 #endif
 
@@ -213,9 +224,12 @@
 
   Void          addOriginalBuffer       ();
-#if POZNAN_AVAIL_MAP
+#if POZNAN_CU_SYNTH || POZNAN_CU_SKIP || POZNAN_TEXTURE_TU_DELTA_QP_ACCORDING_TO_DEPTH
   Void          addAvailabilityBuffer   ();
 #endif
-#if POZNAN_SYNTH_VIEW
+#if POZNAN_CU_SYNTH
   Void          addSynthesisBuffer      ();
+#if POZNAN_TEXTURE_TU_DELTA_QP_ACCORDING_TO_DEPTH
+  Void          addSynthesisDepthBuffer ();
+#endif
 #endif
 #if PARALLEL_MERGED_DEBLK
@@ -237,8 +251,11 @@
 
   Void          removeOriginalBuffer    ();
-#if POZNAN_SYNTH_VIEW
+#if POZNAN_CU_SYNTH
   Void          removeSynthesisBuffer   ();
-#endif
-#if POZNAN_AVAIL_MAP
+#if POZNAN_TEXTURE_TU_DELTA_QP_ACCORDING_TO_DEPTH
+  Void          removeSynthesisDepthBuffer ();
+#endif
+#endif
+#if POZNAN_CU_SYNTH || POZNAN_CU_SKIP || POZNAN_TEXTURE_TU_DELTA_QP_ACCORDING_TO_DEPTH
   Void          removeAvailabilityBuffer();
 #endif
@@ -259,5 +276,5 @@
 #endif
 
-#if POZNAN_AVAIL_MAP
+#if POZNAN_CU_SYNTH || POZNAN_CU_SKIP
   Void          checkSynthesisAvailability(  TComDataCU*& rpcBestCU, UInt iCuAddr, UInt uiAbsZorderIdx, UInt uiPartDepth, Bool *&rpbCUSynthesied);
 #endif
@@ -280,4 +297,12 @@
   const SEImessages* getSEIs() const { return m_SEIs; }
 
+#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 
 };// END CLASS DEFINITION TComPic
 
Index: branches/0.2-poznan-univ/source/Lib/TLibCommon/TComPicSym.cpp
===================================================================
--- branches/0.2-poznan-univ/source/Lib/TLibCommon/TComPicSym.cpp	(revision 11)
+++ branches/0.2-poznan-univ/source/Lib/TLibCommon/TComPicSym.cpp	(revision 12)
@@ -18,4 +18,7 @@
   m_uiNumPartitions   = 1<<(m_uhTotalDepth<<1);
   
+  m_iPicWidth         = iPicWidth;
+  m_iPicHeight        = iPicHeight;
+
   m_uiMaxCUWidth      = uiMaxWidth;
   m_uiMaxCUHeight     = uiMaxHeight;
Index: branches/0.2-poznan-univ/source/Lib/TLibCommon/TComPicSym.h
===================================================================
--- branches/0.2-poznan-univ/source/Lib/TLibCommon/TComPicSym.h	(revision 11)
+++ branches/0.2-poznan-univ/source/Lib/TLibCommon/TComPicSym.h	(revision 12)
@@ -43,4 +43,8 @@
 
 // Include files
+#if POZNAN_MP
+#include "../TLibCommon/TComMP.h"
+#endif
+
 #include "CommonDef.h"
 #include "TComSlice.h"
@@ -58,4 +62,6 @@
   UInt          m_uiHeightInCU;
   
+  Int           m_iPicWidth;
+  Int           m_iPicHeight;
   UInt          m_uiMaxCUWidth;
   UInt          m_uiMaxCUHeight;
@@ -93,4 +99,9 @@
   UInt        getNumPartInWidth()       { return m_uiNumPartInWidth;            }
   UInt        getNumPartInHeight()      { return m_uiNumPartInHeight;           }
+  Int   getPicWidth    () {return m_iPicWidth;}
+  Int   getPicHeight   () {return m_iPicHeight;}
+  UInt  getMaxCUWidth  () {return m_uiMaxCUWidth;}
+  UInt  getMaxCUHeight () {return m_uiMaxCUHeight;}
+  UChar getTotalDepth  () {return m_uhTotalDepth;}
 };// END CLASS DEFINITION TComPicSym
 
Index: branches/0.2-poznan-univ/source/Lib/TLibCommon/TComPicYuv.cpp
===================================================================
--- branches/0.2-poznan-univ/source/Lib/TLibCommon/TComPicYuv.cpp	(revision 11)
+++ branches/0.2-poznan-univ/source/Lib/TLibCommon/TComPicYuv.cpp	(revision 12)
@@ -8,4 +8,5 @@
 #include <assert.h>
 #include <memory.h>
+#include <math.h>
 
 #ifdef __APPLE__
@@ -16,4 +17,5 @@
 
 #include "TComPicYuv.h"
+
 
 TComPicYuv::TComPicYuv()
@@ -455,2 +457,26 @@
   }
 }
+
+#if POZNAN_NONLINEAR_DEPTH
+Void TComPicYuv::power(TComPicYuv *pcPicDst, Float p)
+{
+  Int		x,y;
+  TComPowerConverter powconv(p, g_uiBitIncrement, g_uiBitIncrement);
+
+  // Luma
+  Pel* pPelSrc = getLumaAddr();
+  Pel* pPelDst = pcPicDst->getLumaAddr();
+  for(y=0; y<m_iPicHeight; y++)
+	{
+    for(x=0; x<m_iPicWidth; x++)
+    {
+      pPelDst[x] = (Pel)( powconv(pPelSrc[x]) + 0.5);
+    }
+    pPelDst += pcPicDst->getStride();
+    pPelSrc += getStride();
+  }
+  // Chroma
+  copyToPicCb(pcPicDst);
+  copyToPicCr(pcPicDst);
+}
+#endif
Index: branches/0.2-poznan-univ/source/Lib/TLibCommon/TComPicYuv.h
===================================================================
--- branches/0.2-poznan-univ/source/Lib/TLibCommon/TComPicYuv.h	(revision 11)
+++ branches/0.2-poznan-univ/source/Lib/TLibCommon/TComPicYuv.h	(revision 12)
@@ -44,4 +44,42 @@
 #include "CommonDef.h"
 
+#if POZNAN_NONLINEAR_DEPTH
+
+#include <math.h>
+
+class TComPowerConverter // OLGIERD - Z-NL-Power conversion
+{
+private:
+  Double m_fMul;
+  Float m_fPower;
+
+public:
+
+  TComPowerConverter(Float fPower, Int iInputBitIncrement, Int iOutputBitIncrement)
+  :m_fPower(fPower)
+  {
+    Double fPostMul = (1<<(8+iOutputBitIncrement))-1; // OLGIERD ToDo - should be or not?
+    Double fPreMul  = 1.0/((1<<(8+iInputBitIncrement))-1);
+    m_fMul = fPostMul*pow(fPreMul,(Double)fPower);
+  };
+
+  inline Double operator() (Double Value)
+  {    
+    if (Value<0) return -pow( -Value,(Double)m_fPower)*m_fMul;
+    return pow(Value,(Double)m_fPower)*m_fMul;
+  };
+};
+#else
+class TComPowerConverter // OLGIERD - Z-NL-Power conversion
+{
+public:
+
+  TComPowerConverter(Float fPower, Int iInputBitIncrement, Int iOutputBitIncrement)
+  {
+  };
+
+  inline Double operator() (Double Value) { return Value; };
+};
+#endif
 // ====================================================================================================================
 // Class definition
@@ -175,4 +213,7 @@
   Void  setChromaTo  ( Pel pVal );  
 
+#if POZNAN_NONLINEAR_DEPTH
+  Void power(TComPicYuv *pcPicDst, Float p);
+#endif
 };// END CLASS DEFINITION TComPicYuv
 
Index: branches/0.2-poznan-univ/source/Lib/TLibCommon/TComPrediction.cpp
===================================================================
--- branches/0.2-poznan-univ/source/Lib/TLibCommon/TComPrediction.cpp	(revision 11)
+++ branches/0.2-poznan-univ/source/Lib/TLibCommon/TComPrediction.cpp	(revision 12)
@@ -1516,4 +1516,13 @@
   {
     pcCU->getPartIndexAndSize( iPartIdx, uiPartAddr, iWidth, iHeight );
+
+#if POZNAN_EIVD
+	if(pcCU->getMergeIndex(uiPartAddr)==POZNAN_EIVD_MRG_CAND) 
+	{
+		motionCompensation_EIVD( pcCU, pcYuvPred, eRefPicList, iPartIdx, bPrdDepthMap );
+		return;
+	}
+#endif
+
     if ( eRefPicList != REF_PIC_LIST_X )
     {
@@ -1538,4 +1547,12 @@
     pcCU->getPartIndexAndSize( iPartIdx, uiPartAddr, iWidth, iHeight );
 
+#if POZNAN_EIVD
+	if(pcCU->getMergeIndex(uiPartAddr)==POZNAN_EIVD_MRG_CAND) 
+	{
+		motionCompensation_EIVD( pcCU, pcYuvPred, eRefPicList, iPartIdx, bPrdDepthMap );
+		continue;
+	}
+#endif
+
     if ( eRefPicList != REF_PIC_LIST_X )
     {
@@ -1555,4 +1572,182 @@
   return;
 }
+
+#if POZNAN_EIVD
+Void TComPrediction::motionCompensation_EIVD ( TComDataCU* pcCU, TComYuv* pcYuvPred, RefPicList eRefPicList, Int iPartIdx, Bool bPrdDepthMap )
+{
+  if(!pcCU->getSlice()->getMP()->isEIVDEnabled()) return;
+
+  Int         iPartIdxOrg = iPartIdx;
+  Int         iWidth;
+  Int         iHeight;
+  UInt        uiPartAddr;
+
+  Int		  x,y;
+  Int		  px,py,iCUBaseX,iCUBaseY;
+  Int		  ref_frame0, ref_frame1;
+  Int		  ref_frame0_idx, ref_frame1_idx;
+  TComMv	  mv0,mv1;
+  
+  Int		  ref_frame0_idx_2nd, ref_frame1_idx_2nd;
+  TComMv	  mv0_2nd,mv1_2nd;
+
+  Pel* piDstCb;
+  Pel* piDstCr;
+  Pel aiUTab[MAX_CU_SIZE];
+  Pel aiVTab[MAX_CU_SIZE];
+  Pel iULast;
+  Pel iVLast;
+  Pel iTemp;
+
+  TComMP* pcMP = pcCU->getSlice()->getMP();
+  UInt uiViewId = pcCU->getSlice()->getSPS()->getViewId();
+  Bool bIsDepth = pcCU->getSlice()->getSPS()->isDepth();
+
+#if POZNAN_EIVD_CALC_PRED_DATA
+  UInt uiPointCnt;
+#endif
+    
+  for ( iPartIdx = 0; iPartIdx < pcCU->getNumPartInter(); iPartIdx++ )
+  {
+	if ( iPartIdxOrg >= 0 ) iPartIdx = iPartIdxOrg;
+
+    pcCU->getPartIndexAndSize( iPartIdx, uiPartAddr, iWidth, iHeight );
+
+	//get motion data used for no-MP predicted points
+#if POZNAN_EIVD_CALC_PRED_DATA
+	ref_frame0_idx_2nd = pcCU->getCUMvField2nd(REF_PIC_LIST_0)->getRefIdx(uiPartAddr);
+	mv0_2nd = pcCU->getCUMvField2nd( REF_PIC_LIST_0 )->getMv( uiPartAddr );
+
+	ref_frame1_idx_2nd = pcCU->getCUMvField2nd(REF_PIC_LIST_1)->getRefIdx(uiPartAddr);
+	mv1_2nd = pcCU->getCUMvField2nd( REF_PIC_LIST_1 )->getMv( uiPartAddr );
+#else
+	ref_frame0_idx_2nd = pcCU->getCUMvField(REF_PIC_LIST_0)->getRefIdx(uiPartAddr);
+	mv0_2nd = pcCU->getCUMvField( REF_PIC_LIST_0 )->getMv( uiPartAddr );
+
+	ref_frame1_idx_2nd = pcCU->getCUMvField(REF_PIC_LIST_1)->getRefIdx(uiPartAddr);
+	mv1_2nd = pcCU->getCUMvField( REF_PIC_LIST_1 )->getMv( uiPartAddr );
+#endif
+
+	iCUBaseX = pcCU->getCUPelX()+g_auiRasterToPelX[ g_auiZscanToRaster[uiPartAddr] ];
+	iCUBaseY = pcCU->getCUPelY()+g_auiRasterToPelY[ g_auiZscanToRaster[uiPartAddr] ];
+
+#if POZNAN_EIVD_CALC_PRED_DATA
+	uiPointCnt = 0;
+#endif
+
+	for( py = 0; py < iHeight; py++)
+	{
+		for( px = 0; px < iWidth; px++)
+		{
+			x = iCUBaseX+px;
+			y = iCUBaseY+py;
+
+			pcMP->getEIVDPredData(pcCU, x, y, ref_frame0, ref_frame0_idx, mv0, ref_frame0_idx_2nd, mv0_2nd, 
+										ref_frame1, ref_frame1_idx, mv1, ref_frame1_idx_2nd, mv1_2nd);
+
+			pcCU->getCUMvField(REF_PIC_LIST_0)->setRefIdx(ref_frame0_idx, uiPartAddr);
+			pcCU->getCUMvField( REF_PIC_LIST_0 )->setMv( mv0, uiPartAddr );
+
+			pcCU->getCUMvField(REF_PIC_LIST_1)->setRefIdx(ref_frame1_idx, uiPartAddr);
+			pcCU->getCUMvField( REF_PIC_LIST_1 )->setMv( mv1, uiPartAddr );
+
+			if ( eRefPicList != REF_PIC_LIST_X )
+			{
+			  xPredInterUni_EIVD (pcCU, uiPartAddr, px, py, eRefPicList, pcYuvPred, iPartIdx, bPrdDepthMap );
+#ifdef WEIGHT_PRED
+			  if ( pcCU->getSlice()->getPPS()->getUseWP() )
+			  {
+				xWeightedPredictionUni_EIVD( pcCU, pcYuvPred, uiPartAddr, px, py, eRefPicList, pcYuvPred, iPartIdx );
+			  }
+#endif  
+			}
+			else
+			{
+			  xPredInterBi_EIVD  (pcCU, uiPartAddr, px, py, pcYuvPred, iPartIdx, bPrdDepthMap );
+			}			
+
+			if(!pcCU->getSlice()->getSPS()->isDepth()) // Chroma check only for non depth 
+			{
+			piDstCb = pcYuvPred->getCbAddr( uiPartAddr ) + (py>>1)*pcYuvPred->getCStride();
+			piDstCr = pcYuvPred->getCrAddr( uiPartAddr ) + (py>>1)*pcYuvPred->getCStride();
+
+			//Chroma decimation 16x16 -> 8x8:
+			if(py%2 && px%2)
+			{
+				iTemp = (aiUTab[px-1] + aiUTab[px] + iULast + piDstCb[px>>1] + 2)>>2;
+				aiUTab[px-1] = iULast;
+				iULast = piDstCb[px>>1];
+				piDstCb[px>>1] = iTemp;
+
+				iTemp = (aiVTab[px-1] + aiVTab[px] + iVLast + piDstCr[px>>1] + 2)>>2;
+				aiVTab[px-1] = iVLast;
+				iVLast = piDstCr[px>>1];
+				piDstCr[px>>1] = iTemp;
+			}
+			else
+			{
+				aiUTab[(px==0)? iWidth-1 : (px-1)] = iULast;	
+				iULast = piDstCb[px>>1];
+
+				aiVTab[(px==0)? iWidth-1 : (px-1)] = iVLast;				
+				iVLast = piDstCr[px>>1];
+			}	
+			}
+
+#if !POZNAN_EIVD_COMPRESS_ME_DATA
+			//save motion data for every CU point
+			pcMP->setL0RefPOC(uiViewId,bIsDepth,x,y,ref_frame0);
+			pcMP->setL0MvX(uiViewId,bIsDepth,x,y,mv0.getHor());
+			pcMP->setL0MvY(uiViewId,bIsDepth,x,y,mv0.getVer());
+
+			pcMP->setL1RefPOC(uiViewId,bIsDepth,x,y,ref_frame1);
+			pcMP->setL1MvX(uiViewId,bIsDepth,x,y,mv1.getHor());
+			pcMP->setL1MvY(uiViewId,bIsDepth,x,y,mv1.getVer());
+#endif
+
+#if POZNAN_EIVD_CALC_PRED_DATA
+			pcMP->getTempL0RefIdx()[uiPointCnt] = ref_frame0_idx;
+			pcMP->getTempL0MvX()[uiPointCnt] = mv0.getHor();
+			pcMP->getTempL0MvY()[uiPointCnt] = mv0.getVer();
+
+			pcMP->getTempL1RefIdx()[uiPointCnt] = ref_frame1_idx;
+			pcMP->getTempL1MvX()[uiPointCnt] = mv1.getHor();
+			pcMP->getTempL1MvY()[uiPointCnt] = mv1.getVer();			
+			
+			uiPointCnt++;
+#endif
+
+		}
+	}
+
+	//set motion data representing CU with EIVD 
+	PartSize ePartSize = pcCU->getPartitionSize( uiPartAddr ); //PartSize ePartSize = pcCU->getPartitionSize( 0 );
+#if POZNAN_EIVD_CALC_PRED_DATA
+	pcMP->xCalcEIVDPredData(uiPointCnt, ref_frame0_idx, mv0, ref_frame1_idx, mv1);
+	
+	pcCU->getCUMvField( REF_PIC_LIST_0 )->setAllMvField( mv0, ref_frame0_idx, ePartSize, uiPartAddr, iPartIdx, 0 );
+	//pcCU->getCUMvField(REF_PIC_LIST_0)->setRefIdx(ref_frame0_idx,uiPartAddr);
+	//pcCU->getCUMvField( REF_PIC_LIST_0 )->setMv(mv0, uiPartAddr);
+	
+	pcCU->getCUMvField( REF_PIC_LIST_1 )->setAllMvField( mv1, ref_frame1_idx, ePartSize, uiPartAddr, iPartIdx, 0 );
+	//pcCU->getCUMvField(REF_PIC_LIST_1)->setRefIdx(ref_frame1_idx,uiPartAddr);
+	//pcCU->getCUMvField( REF_PIC_LIST_1 )->setMv(mv1, uiPartAddr);
+#else
+	pcCU->getCUMvField( REF_PIC_LIST_0 )->setAllMvField( mv0_2nd, ref_frame0_idx_2nd, ePartSize, uiPartAddr, iPartIdx, 0 );
+	//pcCU->getCUMvField(REF_PIC_LIST_0)->setRefIdx(ref_frame0_idx_2nd,uiPartAddr);
+	//pcCU->getCUMvField( REF_PIC_LIST_0 )->setMv(mv0_2nd, uiPartAddr);
+	//pcCU->getCUMvField( REF_PIC_LIST_0 )->setMv(mv0.setZero(), uiPartAddr);
+
+	pcCU->getCUMvField( REF_PIC_LIST_1 )->setAllMvField( mv1_2nd, ref_frame1_idx_2nd, ePartSize, uiPartAddr, iPartIdx, 0 );
+	//pcCU->getCUMvField(REF_PIC_LIST_1)->setRefIdx(ref_frame1_idx_2nd,uiPartAddr);
+	//pcCU->getCUMvField( REF_PIC_LIST_1 )->setMv(mv1_2nd, uiPartAddr);
+	//pcCU->getCUMvField( REF_PIC_LIST_1 )->setMv(mv1.setZero(), uiPartAddr);
+#endif
+
+	if ( iPartIdxOrg >= 0 ) break;
+  }
+  return;
+}
+#endif
 
 #if HIGH_ACCURACY_BI
@@ -2090,4 +2285,525 @@
 }
 
+
+
+#if POZNAN_EIVD
+
+#if HIGH_ACCURACY_BI
+Void TComPrediction::xPredInterUni_EIVD ( TComDataCU* pcCU, UInt uiPartAddr, Int iPosX, Int iPosY, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Int iPartIdx, Bool bPrdDepthMap, Bool bi )
+#else
+Void TComPrediction::xPredInterUni_EIVD ( TComDataCU* pcCU, UInt uiPartAddr, Int iPosX, Int iPosY, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Int iPartIdx, Bool bPrdDepthMap )
+#endif
+{
+  Int         iRefIdx     = pcCU->getCUMvField( eRefPicList )->getRefIdx( uiPartAddr );           assert (iRefIdx >= 0);
+  TComMv      cMv         = pcCU->getCUMvField( eRefPicList )->getMv( uiPartAddr );
+  pcCU->clipMv(cMv);
+
+#if DEPTH_MAP_GENERATION
+  if( bPrdDepthMap )
+  {
+#if HIGH_ACCURACY_BI
+    UInt uiRShift = ( bi ? 14-g_uiBitDepth-g_uiBitIncrement : 0 );
+#else
+    UInt uiRShift = 0;
+#endif
+    xPredInterPrdDepthMap_EIVD( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPredDepthMap(), uiPartAddr, &cMv, iPosX, iPosY, 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 );
+#else
+    UInt uiRShift = 0;
+#endif
+    xPredInterPrdDepthMap_EIVD( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iPosX, iPosY, rpcYuvPred, uiRShift, 2 );
+  }
+  else
+  {
+#endif
+#if HIGH_ACCURACY_BI
+  if(!bi)
+  {
+    xPredInterLumaBlk_EIVD ( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iPosX, iPosY, rpcYuvPred );
+  }
+  else
+  {
+    xPredInterLumaBlk_EIVD_ha  ( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iPosX, iPosY, rpcYuvPred );
+  }
+#else
+  xPredInterLumaBlk_EIVD       ( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iPosX, iPosY, rpcYuvPred );
+#endif
+#if HHI_FULL_PEL_DEPTH_MAP_MV_ACC
+  }
+#endif
+
+#if HIGH_ACCURACY_BI
+  if (!bi)
+  {
+	xPredInterChromaBlk_EIVD     ( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iPosX, iPosY, rpcYuvPred );
+  }
+  else
+  {
+	xPredInterChromaBlk_EIVD_ha ( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec()    , uiPartAddr, &cMv, iPosX, iPosY, rpcYuvPred );
+  }
+#else
+  xPredInterChromaBlk_EIVD     ( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iPosX, iPosY, rpcYuvPred );
+#endif
+}
+
+Void TComPrediction::xPredInterBi_EIVD ( TComDataCU* pcCU, UInt uiPartAddr, Int iPosX, Int iPosY, TComYuv*& rpcYuvPred, Int iPartIdx, Bool bPrdDepthMap )
+{
+  TComYuv* pcMbYuv;
+  Int      iRefIdx[2] = {-1, -1};
+
+  for ( Int iRefList = 0; iRefList < 2; iRefList++ )
+  {
+    RefPicList eRefPicList = (iRefList ? REF_PIC_LIST_1 : REF_PIC_LIST_0);
+    iRefIdx[iRefList] = pcCU->getCUMvField( eRefPicList )->getRefIdx( uiPartAddr );
+
+    if ( iRefIdx[iRefList] < 0 )
+    {
+      continue;
+    }
+
+    assert( iRefIdx[iRefList] < pcCU->getSlice()->getNumRefIdx(eRefPicList) );
+
+    pcMbYuv = &m_acYuvPred[iRefList];
+#if HIGH_ACCURACY_BI
+    if( pcCU->getCUMvField( REF_PIC_LIST_0 )->getRefIdx( uiPartAddr ) >= 0 && pcCU->getCUMvField( REF_PIC_LIST_1 )->getRefIdx( uiPartAddr ) >= 0 )
+      xPredInterUni_EIVD ( pcCU, uiPartAddr, iPosX, iPosY, eRefPicList, pcMbYuv, iPartIdx, bPrdDepthMap, true );
+    else
+      xPredInterUni_EIVD ( pcCU, uiPartAddr, iPosX, iPosY, eRefPicList, pcMbYuv, iPartIdx, bPrdDepthMap );
+#else
+    xPredInterUni_EIVD ( pcCU, uiPartAddr, iPosX, iPosY, eRefPicList, pcMbYuv, iPartIdx, bPrdDepthMap );
+#endif
+  }
+
+#ifdef WEIGHT_PRED
+  if ( pcCU->getSlice()->getPPS()->getWPBiPredIdc() )
+  {
+    xWeightedPredictionBi_EIVD( pcCU, &m_acYuvPred[0], &m_acYuvPred[1], iRefIdx[0], iRefIdx[1], uiPartAddr, iPosX, iPosY, rpcYuvPred );
+  }
+  else
+#endif
+    xWeightedAverage_EIVD( pcCU, &m_acYuvPred[0], &m_acYuvPred[1], iRefIdx[0], iRefIdx[1], uiPartAddr, iPosX, iPosY, rpcYuvPred );
+}
+
+Void TComPrediction::xPredInterPrdDepthMap_EIVD( TComDataCU* pcCU, TComPicYuv* pcPicYuvRef, UInt uiPartAddr, TComMv* pcMv, Int iPosX, Int iPosY, TComYuv*& rpcYuv, UInt uiRShift, UInt uiFilterMode ) // 0:std, 1:bilin, 2:nearest neighbour
+{
+  AOF( uiFilterMode <= 2 );
+
+  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() );
+#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;
+  Pel*    piRefY      = pcPicYuvRef->getLumaAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() + uiPartAddr ) + iRefOffset;
+  Pel*    piDstY      = rpcYuv->getLumaAddr( uiPartAddr );
+
+  piRefY += iPosY*iRefStride+iPosX;
+  piDstY += iPosY*iDstStride+iPosX;
+
+  //  Integer position
+  if( ixFrac == 0 && iyFrac == 0 )
+  {
+    piDstY[ 0 ] = piRefY[ 0 ] << uiRShift;
+    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;
+    Int iSV     = iW00 * piRefY [ 0 ] + iW01 * piRefY [ 1 ]
+                + iW10 * piRefY1[ 0 ] + iW11 * piRefY1[ 1 ];
+    iSV       <<= uiRShift;
+    piDstY[ 0 ] = ( iSV + 8 ) >> 4;
+    return;
+  }
+
+  xPredInterLumaBlk_EIVD( pcCU, pcPicYuvRef, uiPartAddr, pcMv, iPosX, iPosY, rpcYuv );
+  return;
+}
+
+
+#if HIGH_ACCURACY_BI
+
+Void  TComPrediction::xPredInterLumaBlk_EIVD_ha( TComDataCU* pcCU, TComPicYuv* pcPicYuvRef, UInt uiPartAddr, TComMv* pcMv, Int iPosX, Int iPosY, TComYuv*& rpcYuv )
+{
+  Int     iRefStride = pcPicYuvRef->getStride();
+  Int     iDstStride = rpcYuv->getStride();
+
+  Int     iRefOffset = ( pcMv->getHor() >> 2 ) + ( pcMv->getVer() >> 2 ) * iRefStride;
+  Pel*    piRefY     = pcPicYuvRef->getLumaAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() + uiPartAddr ) + iRefOffset;
+
+  Int     ixFrac  = pcMv->getHor() & 0x3;
+  Int     iyFrac  = pcMv->getVer() & 0x3;
+
+  Pel* piDstY = rpcYuv->getLumaAddr( uiPartAddr );
+  UInt shiftNum = 14-g_uiBitDepth-g_uiBitIncrement;
+
+  piDstY += iPosY*iDstStride+iPosX;
+  piRefY += iPosY*iRefStride+iPosX;
+
+  //  Integer point
+  if ( ixFrac == 0 && iyFrac == 0 )
+  {
+    *piDstY = (*piRefY)<<shiftNum;
+    return;
+  }
+
+  Int iWidth = 1;
+  Int iHeight = 1;
+
+  //  Half-pel horizontal
+  if ( ixFrac == 2 && iyFrac == 0 )
+  {
+    xCTI_FilterHalfHor_ha ( piRefY, iRefStride, 1, iWidth, iHeight, iDstStride, 1, piDstY );
+    return;
+  }
+
+  //  Half-pel vertical
+  if ( ixFrac == 0 && iyFrac == 2 )
+  {
+    xCTI_FilterHalfVer_ha ( piRefY, iRefStride, 1, iWidth, iHeight, iDstStride, 1, piDstY );
+    return;
+  }
+
+  Int   iExtStride = m_iYuvExtStride;//m_cYuvExt.getStride();
+  Int*  piExtY     = m_piYuvExt;//m_cYuvExt.getLumaAddr();
+
+  //  Half-pel center
+  if ( ixFrac == 2 && iyFrac == 2 )
+  {
+    xCTI_FilterHalfVer (piRefY - 3,  iRefStride, 1, iWidth +7, iHeight, iExtStride, 1, piExtY );
+    xCTI_FilterHalfHor_ha (piExtY + 3,  iExtStride, 1, iWidth    , iHeight, iDstStride, 1, piDstY );
+    return;
+  }
+
+  //  Quater-pel horizontal
+  if ( iyFrac == 0)
+  {
+    if ( ixFrac == 1)
+    {
+      xCTI_FilterQuarter0Hor_ha( piRefY, iRefStride, 1, iWidth, iHeight, iDstStride, 1, piDstY );
+      return;
+    }
+    if ( ixFrac == 3)
+    {
+      xCTI_FilterQuarter1Hor_ha( piRefY, iRefStride, 1, iWidth, iHeight, iDstStride, 1, piDstY );
+      return;
+    }
+  }
+  if ( iyFrac == 2 )
+  {
+    if ( ixFrac == 1)
+    {
+      xCTI_FilterHalfVer (piRefY -3,  iRefStride, 1, iWidth +7, iHeight, iExtStride, 1, piExtY );
+      xCTI_FilterQuarter0Hor_ha (piExtY + 3,  iExtStride, 1, iWidth, iHeight, iDstStride, 1, piDstY );
+      return;
+    }
+    if ( ixFrac == 3)
+    {
+      xCTI_FilterHalfVer (piRefY - 3,  iRefStride, 1, iWidth + 7, iHeight, iExtStride, 1, piExtY );
+      xCTI_FilterQuarter1Hor_ha (piExtY + 3,  iExtStride, 1, iWidth, iHeight, iDstStride, 1, piDstY );
+      return;
+    }
+  }
+
+  //  Quater-pel vertical
+  if( ixFrac == 0 )
+  {
+    if( iyFrac == 1 )
+    {
+      xCTI_FilterQuarter0Ver_ha( piRefY, iRefStride, 1, iWidth, iHeight, iDstStride, 1, piDstY );
+      return;
+    }
+    if( iyFrac == 3 )
+    {
+      xCTI_FilterQuarter1Ver_ha( piRefY, iRefStride, 1, iWidth, iHeight, iDstStride, 1, piDstY );
+      return;
+    }
+  }
+
+  if( ixFrac == 2 )
+  {
+    if( iyFrac == 1 )
+    {
+      xCTI_FilterQuarter0Ver (piRefY - 3,  iRefStride, 1, iWidth + 7, iHeight, iExtStride, 1, piExtY );
+      xCTI_FilterHalfHor_ha (piExtY + 3,  iExtStride, 1, iWidth    , iHeight, iDstStride, 1, piDstY );
+
+      return;
+    }
+    if( iyFrac == 3 )
+    {
+      xCTI_FilterQuarter1Ver (piRefY -3,  iRefStride, 1, iWidth + 7, iHeight, iExtStride, 1, piExtY );
+      xCTI_FilterHalfHor_ha (piExtY + 3,  iExtStride, 1, iWidth    , iHeight, iDstStride, 1, piDstY );
+      return;
+    }
+  }
+
+  /// Quarter-pel center
+  if ( iyFrac == 1)
+  {
+    if ( ixFrac == 1)
+    {
+      xCTI_FilterQuarter0Ver (piRefY - 3,  iRefStride, 1, iWidth + 7, iHeight, iExtStride, 1, piExtY );
+      xCTI_FilterQuarter0Hor_ha (piExtY + 3,  iExtStride, 1, iWidth    , iHeight, iDstStride, 1, piDstY );
+      return;
+    }
+    if ( ixFrac == 3)
+    {
+      xCTI_FilterQuarter0Ver (piRefY - 3,  iRefStride, 1, iWidth +7, iHeight, iExtStride, 1, piExtY );
+      xCTI_FilterQuarter1Hor_ha (piExtY + 3,  iExtStride, 1, iWidth    , iHeight, iDstStride, 1, piDstY );
+
+      return;
+    }
+  }
+  if ( iyFrac == 3 )
+  {
+    if ( ixFrac == 1)
+    {
+      xCTI_FilterQuarter1Ver (piRefY - 3,  iRefStride, 1, iWidth + 7, iHeight, iExtStride, 1, piExtY );
+      xCTI_FilterQuarter0Hor_ha (piExtY + 3,  iExtStride, 1, iWidth    , iHeight, iDstStride, 1, piDstY );
+      return;
+    }
+    if ( ixFrac == 3)
+    {
+      xCTI_FilterQuarter1Ver (piRefY - 3,  iRefStride, 1, iWidth + 7, iHeight, iExtStride, 1, piExtY );
+      xCTI_FilterQuarter1Hor_ha (piExtY + 3,  iExtStride, 1, iWidth    , iHeight, iDstStride, 1, piDstY );
+      return;
+    }
+  }
+}
+
+#endif
+
+Void  TComPrediction::xPredInterLumaBlk_EIVD( TComDataCU* pcCU, TComPicYuv* pcPicYuvRef, UInt uiPartAddr, TComMv* pcMv, Int iPosX, Int iPosY, TComYuv*& rpcYuv )
+{
+  Int     iRefStride = pcPicYuvRef->getStride();
+  Int     iDstStride = rpcYuv->getStride();
+
+  Int     iRefOffset = ( pcMv->getHor() >> 2 ) + ( pcMv->getVer() >> 2 ) * iRefStride;
+  Pel*    piRefY     = pcPicYuvRef->getLumaAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() + uiPartAddr ) + iRefOffset;
+
+  Int     ixFrac  = pcMv->getHor() & 0x3;
+  Int     iyFrac  = pcMv->getVer() & 0x3;
+
+  Pel* piDstY = rpcYuv->getLumaAddr( uiPartAddr );
+  
+  piDstY += iPosY*iDstStride+iPosX;
+  piRefY += iPosY*iRefStride+iPosX;
+
+  //  Integer point
+  if ( ixFrac == 0 && iyFrac == 0 )
+  {
+    ::memcpy(piDstY, piRefY, sizeof(Pel));
+    return;
+  }
+
+  Int iWidth = 1;
+  Int iHeight = 1;
+
+  //  Half-pel horizontal
+  if ( ixFrac == 2 && iyFrac == 0 )
+  {
+    xCTI_FilterHalfHor ( piRefY, iRefStride, 1, iWidth, iHeight, iDstStride, 1, piDstY );
+    return;
+  }
+
+  //  Half-pel vertical
+  if ( ixFrac == 0 && iyFrac == 2 )
+  {
+    xCTI_FilterHalfVer ( piRefY, iRefStride, 1, iWidth, iHeight, iDstStride, 1, piDstY );
+    return;
+  }
+
+  Int   iExtStride = m_iYuvExtStride;//m_cYuvExt.getStride();
+  Int*  piExtY     = m_piYuvExt;//m_cYuvExt.getLumaAddr();
+
+  //  Half-pel center
+  if ( ixFrac == 2 && iyFrac == 2 )
+  {
+
+    xCTI_FilterHalfVer (piRefY - 3,  iRefStride, 1, iWidth +7, iHeight, iExtStride, 1, piExtY );
+    xCTI_FilterHalfHor (piExtY + 3,  iExtStride, 1, iWidth    , iHeight, iDstStride, 1, piDstY );
+    return;
+  }
+
+  //  Quater-pel horizontal
+  if ( iyFrac == 0)
+  {
+    if ( ixFrac == 1)
+    {
+      xCTI_FilterQuarter0Hor( piRefY, iRefStride, 1, iWidth, iHeight, iDstStride, 1, piDstY );
+      return;
+    }
+    if ( ixFrac == 3)
+    {
+      xCTI_FilterQuarter1Hor( piRefY, iRefStride, 1, iWidth, iHeight, iDstStride, 1, piDstY );
+      return;
+    }
+  }
+  if ( iyFrac == 2 )
+  {
+    if ( ixFrac == 1)
+    {
+      xCTI_FilterHalfVer (piRefY -3,  iRefStride, 1, iWidth +7, iHeight, iExtStride, 1, piExtY );
+      xCTI_FilterQuarter0Hor (piExtY + 3,  iExtStride, 1, iWidth, iHeight, iDstStride, 1, piDstY );
+      return;
+    }
+    if ( ixFrac == 3)
+    {
+      xCTI_FilterHalfVer (piRefY - 3,  iRefStride, 1, iWidth + 7, iHeight, iExtStride, 1, piExtY );
+      xCTI_FilterQuarter1Hor (piExtY + 3,  iExtStride, 1, iWidth, iHeight, iDstStride, 1, piDstY );
+      return;
+    }
+  }
+
+  //  Quater-pel vertical
+  if( ixFrac == 0 )
+  {
+    if( iyFrac == 1 )
+    {
+      xCTI_FilterQuarter0Ver( piRefY, iRefStride, 1, iWidth, iHeight, iDstStride, 1, piDstY );
+      return;
+    }
+    if( iyFrac == 3 )
+    {
+      xCTI_FilterQuarter1Ver( piRefY, iRefStride, 1, iWidth, iHeight, iDstStride, 1, piDstY );
+      return;
+    }
+  }
+
+  if( ixFrac == 2 )
+  {
+    if( iyFrac == 1 )
+    {
+      xCTI_FilterQuarter0Ver (piRefY - 3,  iRefStride, 1, iWidth + 7, iHeight, iExtStride, 1, piExtY );
+      xCTI_FilterHalfHor (piExtY + 3,  iExtStride, 1, iWidth    , iHeight, iDstStride, 1, piDstY );
+      return;
+    }
+    if( iyFrac == 3 )
+    {
+      xCTI_FilterQuarter1Ver (piRefY -3,  iRefStride, 1, iWidth + 7, iHeight, iExtStride, 1, piExtY );
+      xCTI_FilterHalfHor (piExtY + 3,  iExtStride, 1, iWidth    , iHeight, iDstStride, 1, piDstY );
+      return;
+    }
+  }
+
+  /// Quarter-pel center
+  if ( iyFrac == 1)
+  {
+    if ( ixFrac == 1)
+    {
+      xCTI_FilterQuarter0Ver (piRefY - 3,  iRefStride, 1, iWidth + 7, iHeight, iExtStride, 1, piExtY );
+      xCTI_FilterQuarter0Hor (piExtY + 3,  iExtStride, 1, iWidth    , iHeight, iDstStride, 1, piDstY );
+      return;
+    }
+    if ( ixFrac == 3)
+    {
+      xCTI_FilterQuarter0Ver (piRefY - 3,  iRefStride, 1, iWidth +7, iHeight, iExtStride, 1, piExtY );
+      xCTI_FilterQuarter1Hor (piExtY + 3,  iExtStride, 1, iWidth    , iHeight, iDstStride, 1, piDstY );
+      return;
+    }
+  }
+  if ( iyFrac == 3 )
+  {
+    if ( ixFrac == 1)
+    {
+      xCTI_FilterQuarter1Ver (piRefY - 3,  iRefStride, 1, iWidth + 7, iHeight, iExtStride, 1, piExtY );
+      xCTI_FilterQuarter0Hor (piExtY + 3,  iExtStride, 1, iWidth    , iHeight, iDstStride, 1, piDstY );
+      return;
+    }
+    if ( ixFrac == 3)
+    {
+      xCTI_FilterQuarter1Ver (piRefY - 3,  iRefStride, 1, iWidth + 7, iHeight, iExtStride, 1, piExtY );
+      xCTI_FilterQuarter1Hor (piExtY + 3,  iExtStride, 1, iWidth    , iHeight, iDstStride, 1, piDstY );
+      return;
+    }
+  }
+}
+
+#if HIGH_ACCURACY_BI
+Void TComPrediction::xPredInterChromaBlk_EIVD_ha( TComDataCU* pcCU, TComPicYuv* pcPicYuvRef, UInt uiPartAddr, TComMv* pcMv, Int iPosX, Int iPosY, TComYuv*& rpcYuv )
+{
+  Int     iRefStride  = pcPicYuvRef->getCStride();
+  Int     iDstStride  = rpcYuv->getCStride();
+
+  Int     iRefOffset  = (pcMv->getHor() >> 3) + (pcMv->getVer() >> 3) * iRefStride;
+
+  Pel*    piRefCb     = pcPicYuvRef->getCbAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() + uiPartAddr ) + iRefOffset;
+  Pel*    piRefCr     = pcPicYuvRef->getCrAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() + uiPartAddr ) + iRefOffset;
+
+  Pel* piDstCb = rpcYuv->getCbAddr( uiPartAddr );
+  Pel* piDstCr = rpcYuv->getCrAddr( uiPartAddr );
+
+  Int     ixFrac  = pcMv->getHor() & 0x7;
+  Int     iyFrac  = pcMv->getVer() & 0x7;
+  UInt    uiCWidth  = 1;
+  UInt    uiCHeight = 1;
+
+  piDstCb += (iPosY>>1)*iDstStride+(iPosX>>1);
+  piDstCr += (iPosY>>1)*iDstStride+(iPosX>>1);
+  piRefCb += (iPosY>>1)*iRefStride+(iPosX>>1);
+  piRefCr += (iPosY>>1)*iRefStride+(iPosX>>1);
+
+  xDCTIF_FilterC_ha(piRefCb, iRefStride,piDstCb,iDstStride,uiCWidth,uiCHeight, iyFrac, ixFrac);
+  xDCTIF_FilterC_ha(piRefCr, iRefStride,piDstCr,iDstStride,uiCWidth,uiCHeight, iyFrac, ixFrac);
+  return;
+}
+#endif
+
+//--
+Void TComPrediction::xPredInterChromaBlk_EIVD( TComDataCU* pcCU, TComPicYuv* pcPicYuvRef, UInt uiPartAddr, TComMv* pcMv, Int iPosX, Int iPosY, TComYuv*& rpcYuv )
+{
+  Int     iRefStride  = pcPicYuvRef->getCStride();
+  Int     iDstStride  = rpcYuv->getCStride();
+
+  Int     iRefOffset  = (pcMv->getHor() >> 3) + (pcMv->getVer() >> 3) * iRefStride;
+
+  Pel*    piRefCb     = pcPicYuvRef->getCbAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() + uiPartAddr ) + iRefOffset;
+  Pel*    piRefCr     = pcPicYuvRef->getCrAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() + uiPartAddr ) + iRefOffset;
+
+  Pel* piDstCb = rpcYuv->getCbAddr( uiPartAddr );
+  Pel* piDstCr = rpcYuv->getCrAddr( uiPartAddr );
+
+  Int     ixFrac  = pcMv->getHor() & 0x7;
+  Int     iyFrac  = pcMv->getVer() & 0x7;
+  UInt    uiCWidth  = 1;
+  UInt    uiCHeight = 1;
+
+  piDstCb += (iPosY>>1)*iDstStride+(iPosX>>1);
+  piDstCr += (iPosY>>1)*iDstStride+(iPosX>>1);
+  piRefCb += (iPosY>>1)*iRefStride+(iPosX>>1);
+  piRefCr += (iPosY>>1)*iRefStride+(iPosX>>1);
+
+  xDCTIF_FilterC(piRefCb, iRefStride,piDstCb,iDstStride,uiCWidth,uiCHeight, iyFrac, ixFrac);
+  xDCTIF_FilterC(piRefCr, iRefStride,piDstCr,iDstStride,uiCWidth,uiCHeight, iyFrac, ixFrac);
+  return;
+}
+
+#endif
+
+
 Void  TComPrediction::xDCTIF_FilterC ( Pel*  piRefC, Int iRefStride,Pel*  piDstC,Int iDstStride,
                                        Int iWidth, Int iHeight,Int iMVyFrac,Int iMVxFrac)
@@ -2193,4 +2909,30 @@
   }
 }
+
+#if POZNAN_EIVD
+Void TComPrediction::xWeightedAverage_EIVD( TComDataCU* pcCU, TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, Int iRefIdx0, Int iRefIdx1, UInt uiPartIdx, Int iPosX, Int iPosY, TComYuv*& rpcYuvDst )
+{
+  if( iRefIdx0 >= 0 && iRefIdx1 >= 0 )
+  {
+#ifdef ROUNDING_CONTROL_BIPRED
+    rpcYuvDst->addAvg_EIVD( pcYuvSrc0, pcYuvSrc1, uiPartIdx, iPosX, iPosY, pcCU->getSlice()->isRounding());
+#else
+    rpcYuvDst->addAvg_EIVD( pcYuvSrc0, pcYuvSrc1, uiPartIdx, iPosX, iPosY );
+#endif
+  }
+  else if ( iRefIdx0 >= 0 && iRefIdx1 <  0 )
+  {
+    pcYuvSrc0->copyPartToPartYuv_EIVD( rpcYuvDst, uiPartIdx, iPosX, iPosY );
+  }
+  else if ( iRefIdx0 <  0 && iRefIdx1 >= 0 )
+  {
+    pcYuvSrc1->copyPartToPartYuv_EIVD( rpcYuvDst, uiPartIdx, iPosX, iPosY );
+  }
+  else
+  {
+    assert (0);
+  }
+}
+#endif
 
 // AMVP
Index: branches/0.2-poznan-univ/source/Lib/TLibCommon/TComPrediction.h
===================================================================
--- branches/0.2-poznan-univ/source/Lib/TLibCommon/TComPrediction.h	(revision 11)
+++ branches/0.2-poznan-univ/source/Lib/TLibCommon/TComPrediction.h	(revision 12)
@@ -52,4 +52,8 @@
 #endif
 
+#if POZNAN_MP
+#include "../TLibCommon/TComMP.h"
+#endif
+
 // ====================================================================================================================
 // Class definition
@@ -113,4 +117,22 @@
 #endif
 
+#if POZNAN_EIVD
+#if HIGH_ACCURACY_BI
+  Void xPredInterUni_EIVD       ( TComDataCU* pcCU,                          UInt uiPartAddr,               Int iPosX, Int iPosY, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Int iPartIdx, Bool bPrdDepthMap, Bool bi=false          );
+#else
+  Void xPredInterUni_EIVD       ( TComDataCU* pcCU,                          UInt uiPartAddr,               Int iPosX, Int iPosY, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Int iPartIdx, Bool bPrdDepthMap          );
+#endif
+  Void xPredInterBi_EIVD        ( TComDataCU* pcCU,                          UInt uiPartAddr,               Int iPosX, Int iPosY,                         TComYuv*& rpcYuvPred, Int iPartIdx, Bool bPrdDepthMap          );
+  Void xPredInterPrdDepthMap_EIVD( TComDataCU* pcCU, TComPicYuv* pcPicYuvRef, UInt uiPartAddr, TComMv* pcMv, Int iPosX, Int iPosY,                     TComYuv*& rpcYuv, UInt uiRShift, UInt uiFilterMode ); // 0:std, 1:bilin, 2:nearest neighbour
+  Void xPredInterLumaBlk_EIVD   ( TComDataCU* pcCU, TComPicYuv* pcPicYuvRef, UInt uiPartAddr, TComMv* pcMv, Int iPosX, Int iPosY,                         TComYuv*& rpcYuv );
+  Void xPredInterChromaBlk_EIVD ( TComDataCU* pcCU, TComPicYuv* pcPicYuvRef, UInt uiPartAddr, TComMv* pcMv, Int iPosX, Int iPosY,                         TComYuv*& rpcYuv                            );
+  Void xWeightedAverage_EIVD    ( TComDataCU* pcCU, TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, Int iRefIdx0, Int iRefIdx1, UInt uiPartAddr, Int iPosX, Int iPosY, TComYuv*& rpcYuvDst );
+  
+#if HIGH_ACCURACY_BI
+  Void xPredInterLumaBlk_EIVD_ha( TComDataCU* pcCU, TComPicYuv* pcPicYuvRef, UInt uiPartAddr, TComMv* pcMv, Int iPosX, Int iPosY,                         TComYuv*& rpcYuv );
+  Void xPredInterChromaBlk_EIVD_ha( TComDataCU* pcCU, TComPicYuv* pcPicYuvRef, UInt uiPartAddr, TComMv* pcMv, Int iPosX, Int iPosY,                         TComYuv*& rpcYuv                            );
+#endif
+#endif
+
 #if HHI_DMM_WEDGE_INTRA
   Void xPredIntraWedgeFull       ( TComDataCU* pcCU, UInt uiAbsPartIdx, Pel* piPred, UInt uiStride, Int iWidth, Int iHeight, Bool bAbove, Bool bLeft, Bool bEncoder, Bool bDelta, UInt uiTabIdx, Int iDeltaDC1 = 0, Int iDeltaDC2 = 0 );
@@ -147,4 +169,8 @@
   Void motionCompensation         ( TComDataCU*  pcCU, TComYuv* pcYuvPred, RefPicList eRefPicList = REF_PIC_LIST_X, Int iPartIdx = -1, Bool bPrdDepthMap = false );
   
+#if POZNAN_EIVD
+  Void motionCompensation_EIVD         ( TComDataCU*  pcCU, TComYuv* pcYuvPred, RefPicList eRefPicList = REF_PIC_LIST_X, Int iPartIdx = -1, Bool bPrdDepthMap = false );
+#endif
+
   // motion vector prediction
   Void getMvPredAMVP              ( TComDataCU* pcCU, UInt uiPartIdx, UInt uiPartAddr, RefPicList eRefPicList, Int iRefIdx, TComMv& rcMvPred );
Index: branches/0.2-poznan-univ/source/Lib/TLibCommon/TComResidualGenerator.cpp
===================================================================
--- branches/0.2-poznan-univ/source/Lib/TLibCommon/TComResidualGenerator.cpp	(revision 11)
+++ branches/0.2-poznan-univ/source/Lib/TLibCommon/TComResidualGenerator.cpp	(revision 12)
@@ -306,5 +306,5 @@
     xSetRecResidualInterCU( pcSubCU, pcSubRes );
     break;
-#if POZNAN_ENCODE_ONLY_DISOCCLUDED_CU
+#if POZNAN_CU_SKIP
   case MODE_SYNTH:
     xSetRecResidualIntraCU( pcSubCU, pcSubRes ); //MayBe it should be seperate function
@@ -341,5 +341,10 @@
   UInt    uiLumaTrMode, uiChromaTrMode;
   pcCU->convertTransIdx             ( 0, pcCU->getTransformIdx( 0 ), uiLumaTrMode, uiChromaTrMode );
+#if POZNAN_TEXTURE_TU_DELTA_QP_ACCORDING_TO_DEPTH
+  m_pcTrQuant->setQPforQuant        ( pcCU->getQP( 0 ) + pcCU->getQpOffsetForTextCU(0/*uiAbsPartIdx*/, false), !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->setQPforQuant        ( pcCU->getQP( 0 ), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), TEXT_LUMA );
   m_pcTrQuant->invRecurTransformNxN ( pcCU, 0, TEXT_LUMA, pRes, 0, pcCUResidual->getStride(), uiWidth, uiHeight, uiLumaTrMode, 0, piCoeff );
   // chroma Cb
@@ -348,5 +353,10 @@
   piCoeff     = pcCU->getCoeffCb();
   pRes        = pcCUResidual->getCbAddr();
+#if POZNAN_TEXTURE_TU_DELTA_QP_ACCORDING_TO_DEPTH
+  m_pcTrQuant->setQPforQuant        ( pcCU->getQP( 0 ) + pcCU->getQpOffsetForTextCU(0/*uiAbsPartIdx*/, false), !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->setQPforQuant        ( pcCU->getQP( 0 ), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), TEXT_CHROMA );
   m_pcTrQuant->invRecurTransformNxN ( pcCU, 0, TEXT_CHROMA_U, pRes, 0, pcCUResidual->getCStride(), uiWidth, uiHeight, uiChromaTrMode, 0, piCoeff );
   // chroma Cr
Index: branches/0.2-poznan-univ/source/Lib/TLibCommon/TComSlice.cpp
===================================================================
--- branches/0.2-poznan-univ/source/Lib/TLibCommon/TComSlice.cpp	(revision 11)
+++ branches/0.2-poznan-univ/source/Lib/TLibCommon/TComSlice.cpp	(revision 12)
@@ -85,8 +85,15 @@
   initWpAcDcParam();
 #endif
+
+#if POZNAN_MP
+  m_pcMP = NULL;
+#endif
 }
 
 TComSlice::~TComSlice()
 {
+#if POZNAN_MP
+  m_pcMP = NULL;
+#endif
 }
 
@@ -722,4 +729,7 @@
     }
   }
+#if POZNAN_NONLINEAR_DEPTH
+  m_fDepthPower = 1.0;
+#endif
 }
 
@@ -737,4 +747,7 @@
   ::memset( m_aaiCodedScale,  0x00, sizeof( m_aaiCodedScale  ) );
   ::memset( m_aaiCodedOffset, 0x00, sizeof( m_aaiCodedOffset ) );
+#if POZNAN_NONLINEAR_DEPTH
+  m_fDepthPower = 1.0;
+#endif
 }
 
Index: branches/0.2-poznan-univ/source/Lib/TLibCommon/TComSlice.h
===================================================================
--- branches/0.2-poznan-univ/source/Lib/TLibCommon/TComSlice.h	(revision 11)
+++ branches/0.2-poznan-univ/source/Lib/TLibCommon/TComSlice.h	(revision 12)
@@ -57,4 +57,9 @@
 #endif
 
+#if POZNAN_MP
+//#include "../TLibCommon/TComMP.h"
+class TComMP;
+#endif
+
 // ====================================================================================================================
 // Class definition
@@ -153,4 +158,16 @@
 #if HHI_INTER_VIEW_RESIDUAL_PRED
   TComResidualGenerator* m_pcResidualGenerator;
+#endif
+
+#if POZNAN_NONLINEAR_DEPTH
+  Float  m_fDepthPower;
+#endif
+
+#if POZNAN_MP
+  TComMP* m_pcMP;
+#endif
+
+#if POZNAN_STAT_JK
+  FILE* m_pcStatFile[MAX_INPUT_VIEW_NUM];
 #endif
 
@@ -305,4 +322,10 @@
   TComResidualGenerator*  getResidualGenerator()                                              { return m_pcResidualGenerator; }
 #endif
+#if POZNAN_NONLINEAR_DEPTH
+  inline Void    setDepthPower(Float p)   {m_fDepthPower = p;}
+  inline Float	 getDepthPower()          {return m_fDepthPower;}
+#else
+  inline Float	 getDepthPower()          {return 1.0f;}
+#endif
 };
 
@@ -445,7 +468,19 @@
 #endif
 
+#if POZNAN_MP
+  TComMP* m_pcMP;
+#endif
+
+#if POZNAN_STAT_JK
+  FILE* m_pcStatFile;
+#endif
+
 public:
   TComSlice();
+#if POZNAN_MP
+  ~TComSlice();
+#else
   virtual ~TComSlice();
+#endif
 
   Void      initSlice       ();
@@ -605,4 +640,14 @@
 #endif
 
+#if POZNAN_MP
+  Void setMP(TComMP* pcMP) { m_pcMP = pcMP; }
+  TComMP* getMP() { return m_pcMP; }
+#endif
+
+#if POZNAN_STAT_JK
+  Void setStatFile(FILE* pcStatFile) { m_pcStatFile = pcStatFile; }
+  FILE* getStatFile() { return m_pcStatFile; }
+#endif
+
 protected:
 #if 0
Index: branches/0.2-poznan-univ/source/Lib/TLibCommon/TComWeightPrediction.cpp
===================================================================
--- branches/0.2-poznan-univ/source/Lib/TLibCommon/TComWeightPrediction.cpp	(revision 11)
+++ branches/0.2-poznan-univ/source/Lib/TLibCommon/TComWeightPrediction.cpp	(revision 12)
@@ -393,4 +393,160 @@
 }
 
+#if POZNAN_EIVD
+
+Void TComWeightPrediction::addWeightBi_EIVD( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt iPartUnitIdx, UInt iPosX, Int iPosY, wpScalingParam *wp0, wpScalingParam *wp1, TComYuv* rpcYuvDst, Bool bRound )
+{
+  Pel* pSrcY0  = pcYuvSrc0->getLumaAddr( iPartUnitIdx );
+  Pel* pSrcU0  = pcYuvSrc0->getCbAddr  ( iPartUnitIdx );
+  Pel* pSrcV0  = pcYuvSrc0->getCrAddr  ( iPartUnitIdx );
+  
+  Pel* pSrcY1  = pcYuvSrc1->getLumaAddr( iPartUnitIdx );
+  Pel* pSrcU1  = pcYuvSrc1->getCbAddr  ( iPartUnitIdx );
+  Pel* pSrcV1  = pcYuvSrc1->getCrAddr  ( iPartUnitIdx );
+  
+  Pel* pDstY   = rpcYuvDst->getLumaAddr( iPartUnitIdx );
+  Pel* pDstU   = rpcYuvDst->getCbAddr  ( iPartUnitIdx );
+  Pel* pDstV   = rpcYuvDst->getCrAddr  ( iPartUnitIdx );
+  
+  // Luma : --------------------------------------------
+  Int w0      = wp0[0].w;
+  Int o0      = wp0[0].o;
+  Int offset  = wp0[0].offset;
+  Int shiftNum = 14 - (g_uiBitDepth + g_uiBitIncrement);
+  Int shift   = wp0[0].shift + shiftNum;
+  Int round   = (1<<(shift-1)) * bRound;
+  Int w1      = wp1[0].w;
+  Int o1      = wp1[0].o;
+
+  UInt  iSrc0Stride = pcYuvSrc0->getStride();
+  UInt  iSrc1Stride = pcYuvSrc1->getStride();
+  UInt  iDstStride  = rpcYuvDst->getStride();
+  
+  pDstY[iPosY*iDstStride+iPosX] = weightBidir(w0,pSrcY0[iPosY*iSrc0Stride+iPosX], w1,pSrcY1[iPosY*iSrc1Stride+iPosX], round, shift, offset);
+   
+  // Chromas : --------------------------------------------
+  iSrc0Stride = pcYuvSrc0->getCStride();
+  iSrc1Stride = pcYuvSrc1->getCStride();
+  iDstStride  = rpcYuvDst->getCStride();
+  
+  iPosX = iPosX>>1;
+  iPosY = iPosY>>1;
+
+  // Chroma U : --------------------------------------------
+  w0      = wp0[1].w;
+  o0      = wp0[1].o;
+  offset  = wp0[1].offset;
+  shift   = wp0[1].shift + shiftNum;
+  round   = (1<<(shift-1));
+  w1      = wp1[1].w;
+  o1      = wp1[1].o;
+  
+  pDstU[iPosY*iDstStride+iPosX] = weightBidir(w0,pSrcU0[iPosY*iSrc0Stride+iPosX], w1,pSrcU1[iPosY*iSrc1Stride+iPosX], round, shift, offset);
+
+  // Chroma V : --------------------------------------------
+  w0      = wp0[2].w;
+  o0      = wp0[2].o;
+  offset  = wp0[2].offset;
+  shift   = wp0[2].shift + shiftNum;
+  round   = (1<<(shift-1));
+  w1      = wp1[2].w;
+  o1      = wp1[2].o;
+
+  pDstV[iPosY*iDstStride+iPosX] = weightBidir(w0,pSrcV0[iPosY*iSrc0Stride+iPosX], w1,pSrcV1[iPosY*iSrc1Stride+iPosX], round, shift, offset);
+}
+
+Void TComWeightPrediction::addWeightUni_EIVD( TComYuv* pcYuvSrc0, UInt iPartUnitIdx, UInt iPosX, Int iPosY, wpScalingParam *wp0, TComYuv* rpcYuvDst )
+{
+  Pel* pSrcY0  = pcYuvSrc0->getLumaAddr( iPartUnitIdx );
+  Pel* pSrcU0  = pcYuvSrc0->getCbAddr  ( iPartUnitIdx );
+  Pel* pSrcV0  = pcYuvSrc0->getCrAddr  ( iPartUnitIdx );
+  
+  Pel* pDstY   = rpcYuvDst->getLumaAddr( iPartUnitIdx );
+  Pel* pDstU   = rpcYuvDst->getCbAddr  ( iPartUnitIdx );
+  Pel* pDstV   = rpcYuvDst->getCrAddr  ( iPartUnitIdx );
+  
+  // Luma : --------------------------------------------
+  Int w0      = wp0[0].w;
+  Int offset  = wp0[0].offset;
+  Int shift   = wp0[0].shift;
+  Int round   = wp0[0].round;
+
+  UInt  iSrc0Stride = pcYuvSrc0->getStride();
+  UInt  iDstStride  = rpcYuvDst->getStride();
+  
+  pDstY[iPosY*iDstStride+iPosX] = weightUnidir(w0,pSrcY0[iPosY*iSrc0Stride+iPosX], round, shift, offset);
+   
+  // Chromas : --------------------------------------------
+  iSrc0Stride = pcYuvSrc0->getCStride();
+  iDstStride  = rpcYuvDst->getCStride();
+  
+  iPosX = iPosX>>1;
+  iPosY = iPosY>>1;
+
+  // Chroma U : --------------------------------------------
+  w0      = wp0[1].w;
+  offset  = wp0[1].offset;
+  shift   = wp0[1].shift;
+  round   = wp0[1].round;
+  
+  pDstU[iPosY*iDstStride+iPosX] = weightUnidir(w0,pSrcU0[iPosY*iSrc0Stride+iPosX], round, shift, offset);
+
+  // Chroma V : --------------------------------------------
+  w0      = wp0[2].w;
+  offset  = wp0[2].offset;
+  shift   = wp0[2].shift;
+  round   = wp0[2].round;
+
+  pDstV[iPosY*iDstStride+iPosX] = weightUnidir(w0,pSrcV0[iPosY*iSrc0Stride+iPosX], round, shift, offset);
+}
+
+Void TComWeightPrediction::xWeightedPredictionUni_EIVD( TComDataCU* pcCU, TComYuv* pcYuvSrc, UInt uiPartAddr, Int iPosX, Int iPosY, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Int iPartIdx )
+{ 
+  wpScalingParam  *pwp, *pwpTmp;
+  Int             iRefIdx   = pcCU->getCUMvField( eRefPicList )->getRefIdx( uiPartAddr );           assert (iRefIdx >= 0);
+  Int             ibdi = (g_uiBitDepth+g_uiBitIncrement);
+
+  if ( eRefPicList == REF_PIC_LIST_0 )
+  {
+    getWpScaling(pcCU, iRefIdx, -1, pwp, pwpTmp, ibdi);
+  }
+  else
+  {
+    getWpScaling(pcCU, -1, iRefIdx, pwpTmp, pwp, ibdi);
+  }
+  addWeightUni_EIVD( pcYuvSrc, uiPartAddr, iPosX, iPosY, pwp, rpcYuvPred );
+}
+
+Void TComWeightPrediction::xWeightedPredictionBi_EIVD( TComDataCU* pcCU, TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, Int iRefIdx0, Int iRefIdx1, UInt uiPartIdx, Int iPosX, Int iPosY, TComYuv* rpcYuvDst )
+{
+  wpScalingParam  *pwp0, *pwp1;
+  TComPPS         *pps = pcCU->getSlice()->getPPS();
+
+  if ( !pps->getUseWP() ) {
+    printf("TComWeightPrediction::xWeightedPredictionBi():\tassert failed: useWP is false.\n");
+    exit(0);
+  }
+
+  Int ibdi = (g_uiBitDepth+g_uiBitIncrement);
+  getWpScaling(pcCU, iRefIdx0, iRefIdx1, pwp0, pwp1, ibdi);
+
+  if( iRefIdx0 >= 0 && iRefIdx1 >= 0 )
+  {
+    addWeightBi_EIVD(pcYuvSrc0, pcYuvSrc1, uiPartIdx, iPosX, iPosY, pwp0, pwp1, rpcYuvDst );
+  }
+  else if ( iRefIdx0 >= 0 && iRefIdx1 <  0 )
+  {
+    addWeightUni_EIVD( pcYuvSrc0, uiPartIdx, iPosX, iPosY, pwp0, rpcYuvDst );
+  }
+  else if ( iRefIdx0 <  0 && iRefIdx1 >= 0 )
+  {
+    addWeightUni_EIVD( pcYuvSrc1, uiPartIdx, iPosX, iPosY, pwp1, rpcYuvDst );
+  }
+  else
+    assert (0);
+
+}
+#endif
+
 #endif  // WEIGHT_PRED
 
Index: branches/0.2-poznan-univ/source/Lib/TLibCommon/TComWeightPrediction.h
===================================================================
--- branches/0.2-poznan-univ/source/Lib/TLibCommon/TComWeightPrediction.h	(revision 11)
+++ branches/0.2-poznan-univ/source/Lib/TLibCommon/TComWeightPrediction.h	(revision 12)
@@ -37,4 +37,12 @@
   Void  xWeightedPredictionBi( TComDataCU* pcCU, TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, Int iRefIdx0, Int iRefIdx1, UInt uiPartIdx, Int iWidth, Int iHeight, TComYuv* rpcYuvDst );
 
+#if POZNAN_EIVD
+  Void  addWeightBi_EIVD( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt iPartUnitIdx, UInt iPosX, Int iPosY, wpScalingParam *wp0, wpScalingParam *wp1, TComYuv* rpcYuvDst, Bool bRound=true );
+  Void  addWeightUni_EIVD( TComYuv* pcYuvSrc0, UInt iPartUnitIdx, UInt iPosX, Int iPosY, wpScalingParam *wp0, TComYuv* rpcYuvDst );
+
+  Void  xWeightedPredictionUni_EIVD( TComDataCU* pcCU, TComYuv* pcYuvSrc, UInt uiPartAddr, Int iPosX, Int iPosY, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Int iPartIdx );
+  Void  xWeightedPredictionBi_EIVD( TComDataCU* pcCU, TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, Int iRefIdx0, Int iRefIdx1, UInt uiPartIdx, Int iPosX, Int iPosY, TComYuv* rpcYuvDst );
+#endif
+
   __inline  Pel   xClip  ( Int x );
   __inline  Pel   weightBidir( Int w0, Pel P0, Int w1, Pel P1, Int round, Int shift, Int offset);
Index: branches/0.2-poznan-univ/source/Lib/TLibCommon/TComYuv.cpp
===================================================================
--- branches/0.2-poznan-univ/source/Lib/TLibCommon/TComYuv.cpp	(revision 11)
+++ branches/0.2-poznan-univ/source/Lib/TLibCommon/TComYuv.cpp	(revision 12)
@@ -354,4 +354,56 @@
 }
 
+#if POZNAN_EIVD
+
+Void TComYuv::copyPartToPartYuv_EIVD   ( TComYuv* pcYuvDst, UInt uiPartIdx, UInt uiPosX, UInt uiPosY )
+{
+  copyPartToPartLuma_EIVD   (pcYuvDst, uiPartIdx, uiPosX, uiPosY );
+  copyPartToPartChroma_EIVD (pcYuvDst, uiPartIdx, uiPosX>>1, uiPosY>>1 );
+}
+
+Void TComYuv::copyPartToPartLuma_EIVD  ( TComYuv* pcYuvDst, UInt uiPartIdx, UInt uiPosX, UInt uiPosY )
+{
+  Pel* pSrc =           getLumaAddr(uiPartIdx);
+  Pel* pDst = pcYuvDst->getLumaAddr(uiPartIdx);
+  if( pSrc == pDst )
+  {
+    //th not a good idea
+    //th best would be to fix the caller 
+    return ;
+  }
+  
+  UInt  iSrcStride = getStride();
+  UInt  iDstStride = pcYuvDst->getStride();
+
+  ::memcpy( pDst+uiPosY*iDstStride+uiPosX, pSrc+uiPosY*iSrcStride+uiPosX, sizeof(Pel) );
+}
+
+Void TComYuv::copyPartToPartChroma_EIVD( TComYuv* pcYuvDst, UInt uiPartIdx, UInt uiPosX, UInt uiPosY )
+{
+  Pel*  pSrcU =           getCbAddr(uiPartIdx);
+  Pel*  pSrcV =           getCrAddr(uiPartIdx);
+  Pel*  pDstU = pcYuvDst->getCbAddr(uiPartIdx);
+  Pel*  pDstV = pcYuvDst->getCrAddr(uiPartIdx);
+  
+  if( getCbAddr() == NULL || getCrAddr() == NULL || pcYuvDst->getCbAddr() == NULL || pcYuvDst->getCrAddr() == NULL ) //KUBA CHROMA
+  {
+    return ;
+  }
+  if( pSrcU == pDstU && pSrcV == pDstV)
+  {
+    //th not a good idea
+    //th best would be to fix the caller 
+    return ;
+  }
+  
+  UInt   iSrcStride = getCStride();
+  UInt   iDstStride = pcYuvDst->getCStride();
+
+  ::memcpy( pDstU+uiPosY*iDstStride+uiPosX, pSrcU+uiPosY*iSrcStride+uiPosX, sizeof(Pel) );
+  ::memcpy( pDstV+uiPosY*iDstStride+uiPosX, pSrcV+uiPosY*iSrcStride+uiPosX, sizeof(Pel) );
+}
+
+#endif
+
 Void TComYuv::addClipPartLuma( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiTrUnitIdx, UInt uiPartSize )
 {
@@ -801,4 +853,106 @@
 }
 
+#if POZNAN_EIVD
+
+#ifdef ROUNDING_CONTROL_BIPRED
+
+Void TComYuv::addAvg_EIVD( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt iPartUnitIdx, UInt iPosX, UInt iPosY, Bool bRound )
+{
+  Pel* pSrcY0  = pcYuvSrc0->getLumaAddr( iPartUnitIdx );
+  Pel* pSrcU0  = pcYuvSrc0->getCbAddr  ( iPartUnitIdx );
+  Pel* pSrcV0  = pcYuvSrc0->getCrAddr  ( iPartUnitIdx );
+  
+  Pel* pSrcY1  = pcYuvSrc1->getLumaAddr( iPartUnitIdx );
+  Pel* pSrcU1  = pcYuvSrc1->getCbAddr  ( iPartUnitIdx );
+  Pel* pSrcV1  = pcYuvSrc1->getCrAddr  ( iPartUnitIdx );
+  
+  Pel* pDstY   = getLumaAddr( iPartUnitIdx );
+  Pel* pDstU   = getCbAddr  ( iPartUnitIdx );
+  Pel* pDstV   = getCrAddr  ( iPartUnitIdx );
+  
+  UInt  iSrc0Stride = pcYuvSrc0->getStride();
+  UInt  iSrc1Stride = pcYuvSrc1->getStride();
+  UInt  iDstStride  = getStride();
+
+#if HIGH_ACCURACY_BI
+  Int shiftNum = 15 - (g_uiBitDepth + g_uiBitIncrement);
+  Int offset = (1<<(shiftNum - 1));
+  
+  //Luma
+  (pDstY+iPosY*iDstStride)[iPosX] = Clip(((pSrcY0+iPosY*iSrc0Stride)[iPosX] + (pSrcY1+iPosY*iSrc1Stride)[iPosX] + offset) >> shiftNum );
+   
+  iSrc0Stride = pcYuvSrc0->getCStride();
+  iSrc1Stride = pcYuvSrc1->getCStride();
+  iDstStride  = getCStride();
+
+  //Chroma
+  (pDstU+(iPosY>>1)*iDstStride)[(iPosX>>1)] = Clip(((pSrcU0+(iPosY>>1)*iSrc0Stride)[(iPosX>>1)] + (pSrcU1+(iPosY>>1)*iSrc1Stride)[(iPosX>>1)] + offset) >> shiftNum );
+  (pDstV+(iPosY>>1)*iDstStride)[(iPosX>>1)] = Clip(((pSrcV0+(iPosY>>1)*iSrc0Stride)[(iPosX>>1)] + (pSrcV1+(iPosY>>1)*iSrc1Stride)[(iPosX>>1)] + offset) >> shiftNum );
+  
+#else
+
+  //Luma
+  (pDstY+iPosY*iDstStride)[iPosX] = ((pSrcY0+iPosY*iSrc0Stride)[iPosX] + (pSrcY1+iPosY*iSrc1Stride)[iPosX] + bRound) >> 1;
+   
+  iSrc0Stride = pcYuvSrc0->getCStride();
+  iSrc1Stride = pcYuvSrc1->getCStride();
+  iDstStride  = getCStride();
+  
+  //Chroma
+  (pDstU+(iPosY>>1)*iDstStride)[(iPosX>>1)] = ((pSrcU0+(iPosY>>1)*iSrc0Stride)[(iPosX>>1)] + (pSrcU1+(iPosY>>1)*iSrc1Stride)[(iPosX>>1)] + bRound) >> 1;
+  (pDstV+(iPosY>>1)*iDstStride)[(iPosX>>1)] = ((pSrcV0+(iPosY>>1)*iSrc0Stride)[(iPosX>>1)] + (pSrcV1+(iPosY>>1)*iSrc1Stride)[(iPosX>>1)] + bRound) >> 1;
+#endif
+}
+
+#endif
+
+Void TComYuv::addAvg_EIVD( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt iPartUnitIdx, UInt iPosX, UInt iPosY )
+{
+  Pel* pSrcY0  = pcYuvSrc0->getLumaAddr( iPartUnitIdx );
+  Pel* pSrcU0  = pcYuvSrc0->getCbAddr  ( iPartUnitIdx );
+  Pel* pSrcV0  = pcYuvSrc0->getCrAddr  ( iPartUnitIdx );
+  
+  Pel* pSrcY1  = pcYuvSrc1->getLumaAddr( iPartUnitIdx );
+  Pel* pSrcU1  = pcYuvSrc1->getCbAddr  ( iPartUnitIdx );
+  Pel* pSrcV1  = pcYuvSrc1->getCrAddr  ( iPartUnitIdx );
+  
+  Pel* pDstY   = getLumaAddr( iPartUnitIdx );
+  Pel* pDstU   = getCbAddr  ( iPartUnitIdx );
+  Pel* pDstV   = getCrAddr  ( iPartUnitIdx );
+  
+  UInt  iSrc0Stride = pcYuvSrc0->getStride();
+  UInt  iSrc1Stride = pcYuvSrc1->getStride();
+  UInt  iDstStride  = getStride();
+#if HIGH_ACCURACY_BI
+  Int shiftNum = 15 - (g_uiBitDepth + g_uiBitIncrement);
+  Int offset = (1<<(shiftNum - 1));
+  
+  //Luma
+  (pDstY+iPosY*iDstStride)[iPosX] = Clip(((pSrcY0+iPosY*iSrc0Stride)[iPosX] + (pSrcY1+iPosY*iSrc1Stride)[iPosX] + offset) >> shiftNum );
+
+  iSrc0Stride = pcYuvSrc0->getCStride();
+  iSrc1Stride = pcYuvSrc1->getCStride();
+  iDstStride  = getCStride();
+  
+  //Chroma
+  (pDstU+(iPosY>>1)*iDstStride)[(iPosX>>1)] = Clip(((pSrcU0+(iPosY>>1)*iSrc0Stride)[(iPosX>>1)] + (pSrcU1+(iPosY>>1)*iSrc1Stride)[(iPosX>>1)] + offset) >> shiftNum );
+  (pDstV+(iPosY>>1)*iDstStride)[(iPosX>>1)] = Clip(((pSrcV0+(iPosY>>1)*iSrc0Stride)[(iPosX>>1)] + (pSrcV1+(iPosY>>1)*iSrc1Stride)[(iPosX>>1)] + offset) >> shiftNum );
+
+#else  
+  //Luma
+  (pDstY+iPosY*iDstStride)[iPosX] = ((pSrcY0+iPosY*iSrc0Stride)[iPosX] + (pSrcY1+iPosY*iSrc1Stride)[iPosX] + 1) >> 1;
+   
+  iSrc0Stride = pcYuvSrc0->getCStride();
+  iSrc1Stride = pcYuvSrc1->getCStride();
+  iDstStride  = getCStride();
+  
+  //Chroma
+  (pDstU+(iPosY>>1)*iDstStride)[(iPosX>>1)] = ((pSrcU0+(iPosY>>1)*iSrc0Stride)[(iPosX>>1)] + (pSrcU1+(iPosY>>1)*iSrc1Stride)[(iPosX>>1)] + 1) >> 1;
+  (pDstV+(iPosY>>1)*iDstStride)[(iPosX>>1)] = ((pSrcV0+(iPosY>>1)*iSrc0Stride)[(iPosX>>1)] + (pSrcV1+(iPosY>>1)*iSrc1Stride)[(iPosX>>1)] + 1) >> 1;
+#endif
+}
+
+#endif
+
 Void TComYuv::removeHighFreq( TComYuv* pcYuvSrc, UInt uiWidht, UInt uiHeight )
 {
Index: branches/0.2-poznan-univ/source/Lib/TLibCommon/TComYuv.h
===================================================================
--- branches/0.2-poznan-univ/source/Lib/TLibCommon/TComYuv.h	(revision 11)
+++ branches/0.2-poznan-univ/source/Lib/TLibCommon/TComYuv.h	(revision 12)
@@ -114,4 +114,10 @@
   Void    copyPartToPartChroma  ( TComYuv*    pcYuvDst, UInt uiPartIdx, UInt uiWidth, UInt uiHeight );
   
+#if POZNAN_EIVD
+  Void	  copyPartToPartYuv_EIVD	( TComYuv* pcYuvDst, UInt uiPartIdx, UInt uiPosX, UInt uiPosY );  
+  Void    copyPartToPartLuma_EIVD   ( TComYuv* pcYuvDst, UInt uiPartIdx, UInt uiPosX, UInt uiPosY );
+  Void    copyPartToPartChroma_EIVD ( TComYuv* pcYuvDst, UInt uiPartIdx, UInt uiPosX, UInt uiPosY );
+#endif
+
   // ------------------------------------------------------------------------------------------------------------------
   //  Algebraic operation for YUV buffer
@@ -136,4 +142,11 @@
   Void    addAvg            ( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt iPartUnitIdx, UInt iWidth, UInt iHeight );
 
+#if POZNAN_EIVD
+#ifdef ROUNDING_CONTROL_BIPRED
+  Void    addAvg_EIVD            ( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt iPartUnitIdx, UInt iPosX, UInt iPosY, Bool bRound );
+#endif
+  Void    addAvg_EIVD            ( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt iPartUnitIdx, UInt iPosX, UInt iPosY );
+#endif
+
   //   Remove High frequency
   Void    removeHighFreq    ( TComYuv* pcYuvSrc, UInt uiWidht, UInt uiHeight );
Index: branches/0.2-poznan-univ/source/Lib/TLibCommon/TypeDef.h
===================================================================
--- branches/0.2-poznan-univ/source/Lib/TLibCommon/TypeDef.h	(revision 11)
+++ branches/0.2-poznan-univ/source/Lib/TLibCommon/TypeDef.h	(revision 12)
@@ -65,16 +65,44 @@
 #define POZNAN_CU_SYNTH             1 //Poznan Cu Synth
 
-#define POZNAN_AVAIL_MAP            1 //Creates Availibity buffers in all needed classes
-
-#define POZNAN_SYNTH_VIEW           1 //Creates view synthesis buffers in all needed classes
-#define POZNAN_SYNTH_DEPTH          1
-
-#define POZNAN_SYNTH                1 //Creates aligned synthesis classes in encoder and decoder
-
-#define POZNAN_ENCODE_ONLY_DISOCCLUDED_CU          1 //Poznan CU Skip
-#define POZNAN_FILL_OCCLUDED_CU_WITH_SYNTHESIS     1 //Fills not sended CUs with synthesized data
-
-#define POZNAN_CU_SKIP_PSNR         1 //Poznan Cu Skip Display psnr of the codded CU only
+#define POZNAN_NONLINEAR_DEPTH              0	 /// Non-linear depth processing (Maciej Kurc)
+#define POZNAN_NONLINEAR_DEPTH_SEND_AS_BYTE 1	 /// Send DepthPower as byte instead of float
+
+#if POZNAN_CU_SYNTH 
+#define POZNAN_TEXTURE_TU_DELTA_QP_ACCORDING_TO_DEPTH 0 /// increase QP for texture CUs that are in the background (according to proper depth map). This QP change is not encoded in a bitstream
+#endif
+#if POZNAN_TEXTURE_TU_DELTA_QP_ACCORDING_TO_DEPTH     
+ #define POZNAN_TEXTURE_TU_DELTA_QP_NOT_IN_BASE_VIEW 1     /// should not be disabled in current software version - no depth synthesis map is available for base view anyway  
+ #define POZNAN_TEXTURE_TU_DELTA_QP_TOP_BOTTOM_CU_ROW 1    /// increase of QP param for top and bottom LCU row in frame 
+ #define POZNAN_TEXTURE_TU_DELTA_QP_PARAM_IN_CFG_FOR_ENC 0 /// used for optimization of function calculating dQP from depth block max value. Standard values set if disabled. If enabled params are set in cfg file for encoder (no decoder is supported in that case).
+  #if !POZNAN_TEXTURE_TU_DELTA_QP_PARAM_IN_CFG_FOR_ENC
+    #define POZNAN_TEXTURE_TU_DELTA_QP_OFFSET (-2.6)
+    #define POZNAN_TEXTURE_TU_DELTA_QP_MUL (1)
+    #define POZNAN_TEXTURE_TU_DELTA_QP_TOP_BOTTOM_ROW_VAL (2)
+  #endif
+#endif
+
+#define POZNAN_EIVD                                0    // Depth Based Vector Prediction prediction for MERGE
+#if POZNAN_EIVD
+#define POZNAN_EIVD_USE_FOR_TEXTURE                  1    //use Depth Based Vector Prediction in texture pictures (0 - no, 1 -yes)
+#define POZNAN_EIVD_USE_FOR_DEPTH                  1    // use Depth Based Vector Prediction in depth pictures (0 - no, 1 -yes)
+
+#define POZNAN_EIVD_CALC_PRED_DATA 	        1    // Depth Based Vector Prediction motion data used for prediction in other CUs is calculated based on all CU points (otherwise motion data for none-MP points is used for prediction)
+#define POZNAN_EIVD_COMPRESS_ME_DATA	        0    // Depth Based Vector Prediction derives representative motion data from reference CUs even if they are EIVD-based predicted (otherwise motion data is derived with per-point resolution for EIVD-based predicted reference CUs)
+#define POZNAN_EIVD_USE_IN_NONANCHOR_PIC_ONLY     	1    // determines if Depth Based Vector Prediction is used in non-anchor pictures only
+#endif
+
+#endif
+
+// ---------------------------------------
+
+#define POZNAN_STAT_JK	0 // save CU statistics to file
+
+#if POZNAN_STAT_JK
+#define POZNAN_STAT_JK_FLUSH 1 // flush CU statistics to file after each CU
+#endif
+
+#define POZNAN_CU_SKIP_PSNR         1
 //<<<<< Poznan 3DV tools <<<<<<
+
 
 ////////////////////////////
@@ -356,4 +384,5 @@
 typedef       unsigned long       ULong;
 typedef       double              Double;
+typedef       float               Float;
 
 // ====================================================================================================================
Index: branches/0.2-poznan-univ/source/Lib/TLibDecoder/TDecCAVLC.cpp
===================================================================
--- branches/0.2-poznan-univ/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 11)
+++ branches/0.2-poznan-univ/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 12)
@@ -271,4 +271,17 @@
       pcSPS->setUseMVI( uiCode ? true : false );
 #endif
+#if POZNAN_NONLINEAR_DEPTH
+#if POZNAN_NONLINEAR_DEPTH_SEND_AS_BYTE
+      uiCode = 0;
+      xReadCode(8, uiCode);
+      pcSPS->setDepthPower(dequantizeDepthPower(uiCode));
+#else
+      uiCode = 0;
+      xReadCode(sizeof(float)*8, uiCode); // We do not send seign
+      //uiCode &= ~0x80000000;
+      pcSPS->setDepthPower(*((float*)&uiCode));  
+#endif
+      printf("\nfDepthPower = %f", pcSPS->getDepthPower());
+#endif
     }
     else
@@ -331,5 +344,4 @@
     }
   }
-
   return;
 }
@@ -2621,5 +2633,5 @@
 
 
-#if HHI_INTER_VIEW_MOTION_PRED || HHI_MPI
+#if HHI_INTER_VIEW_MOTION_PRED || HHI_MPI || POZNAN_EIVD
 Void 
 TDecCavlc::parseMergeIndexMV( TComDataCU* pcCU, UInt& ruiMergeIndex, UInt uiAbsPartIdx, UInt uiDepth )
@@ -2632,4 +2644,8 @@
     uiNumCand++;
 #endif
+#if POZNAN_EIVD
+  UInt uiModIdx;
+  const Bool bEIVDAvailable = pcCU->getSlice()->getMP()->isEIVDEnabled();
+#endif
   for( UInt uiIdx = 0; uiIdx < MRG_MAX_NUM_CANDS; uiIdx++ )
   {
@@ -2656,15 +2672,43 @@
     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 )
+	  {
+        ruiMergeIndex++;
+      }
+#else
       if( pcCU->getNeighbourCandIdx( uiIdx - 1, uiAbsPartIdx ) != uiIdx )
       {
         ruiMergeIndex++;
       }
+#endif
     }
     else if( uiIdx < uiMviMergePos )
 #endif
+#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 )
+	{
+	  ruiMergeIndex++;
+	}
+#else
     if( pcCU->getNeighbourCandIdx( uiIdx, uiAbsPartIdx ) != uiIdx + 1 )
     {
       ruiMergeIndex++;
     }
+#endif
   }
 #if HHI_MPI
@@ -2676,4 +2720,11 @@
   {
     pcCU->setTextureModeDepthSubParts( uiDepth, uiAbsPartIdx, uiDepth );
+  }
+#endif
+#if POZNAN_EIVD
+  if(bEIVDAvailable)
+  {	  
+	if(ruiMergeIndex==POZNAN_EIVD_MERGE_POS) ruiMergeIndex = POZNAN_EIVD_MRG_CAND;
+	else if(ruiMergeIndex>POZNAN_EIVD_MERGE_POS) ruiMergeIndex--;
   }
 #endif
@@ -2691,5 +2742,5 @@
 Void TDecCavlc::parseMergeIndex ( TComDataCU* pcCU, UInt& ruiMergeIndex, UInt uiAbsPartIdx, UInt uiDepth )
 {
-#if HHI_INTER_VIEW_MOTION_PRED || HHI_MPI
+#if HHI_INTER_VIEW_MOTION_PRED || HHI_MPI || POZNAN_EIVD
   if(
 #if HHI_INTER_VIEW_MOTION_PRED
@@ -2698,4 +2749,7 @@
 #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
Index: branches/0.2-poznan-univ/source/Lib/TLibDecoder/TDecCAVLC.h
===================================================================
--- branches/0.2-poznan-univ/source/Lib/TLibDecoder/TDecCAVLC.h	(revision 11)
+++ branches/0.2-poznan-univ/source/Lib/TLibDecoder/TDecCAVLC.h	(revision 12)
@@ -195,5 +195,5 @@
   Void parseMergeFlag       ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPUIdx );
   Void parseMergeIndex      ( TComDataCU* pcCU, UInt& ruiMergeIndex, UInt uiAbsPartIdx, UInt uiDepth );
-#if HHI_INTER_VIEW_MOTION_PRED || HHI_MPI
+#if HHI_INTER_VIEW_MOTION_PRED || HHI_MPI || POZNAN_EIVD
   Void parseMergeIndexMV    ( TComDataCU* pcCU, UInt& ruiMergeIndex, UInt uiAbsPartIdx, UInt uiDepth );
 #endif
Index: branches/0.2-poznan-univ/source/Lib/TLibDecoder/TDecCu.cpp
===================================================================
--- branches/0.2-poznan-univ/source/Lib/TLibDecoder/TDecCu.cpp	(revision 11)
+++ branches/0.2-poznan-univ/source/Lib/TLibDecoder/TDecCu.cpp	(revision 12)
@@ -49,8 +49,8 @@
   m_ppcYuvReco    = NULL;
   m_ppcYuvResPred = NULL;
-#if POZNAN_AVAIL_MAP
+#if POZNAN_CU_SKIP
   m_ppcYuvAvail   = NULL;
 #endif
-#if POZNAN_SYNTH_VIEW
+#if POZNAN_CU_SYNTH
   m_ppcYuvSynth   = NULL;
 #endif
@@ -81,8 +81,8 @@
   m_ppcYuvReco    = new TComYuv*    [m_uiMaxDepth-1];
   m_ppcYuvResPred = new TComYuv*    [m_uiMaxDepth-1];
-#if POZNAN_AVAIL_MAP
+#if POZNAN_CU_SKIP
   m_ppcYuvAvail   = new TComYuv*    [m_uiMaxDepth-1];
 #endif
-#if POZNAN_SYNTH_VIEW
+#if POZNAN_CU_SYNTH
   m_ppcYuvSynth   = new TComYuv*    [m_uiMaxDepth-1];
 #endif
@@ -99,8 +99,8 @@
     m_ppcYuvReco   [ui] = new TComYuv;    m_ppcYuvReco   [ui]->create( uiWidth, uiHeight );
     m_ppcYuvResPred[ui] = new TComYuv;    m_ppcYuvResPred[ui]->create( uiWidth, uiHeight );
-#if POZNAN_AVAIL_MAP
+#if POZNAN_CU_SKIP
     m_ppcYuvAvail  [ui] = new TComYuv;    m_ppcYuvAvail  [ui]->create( uiWidth, uiHeight );
 #endif
-#if POZNAN_SYNTH_VIEW
+#if POZNAN_CU_SYNTH
     m_ppcYuvSynth  [ui] = new TComYuv;    m_ppcYuvSynth  [ui]->create( uiWidth, uiHeight );
 #endif
@@ -125,8 +125,8 @@
     m_ppcYuvReco   [ui]->destroy(); delete m_ppcYuvReco   [ui]; m_ppcYuvReco   [ui] = NULL;
     m_ppcYuvResPred[ui]->destroy(); delete m_ppcYuvResPred[ui]; m_ppcYuvResPred[ui] = NULL;
-#if POZNAN_AVAIL_MAP
+#if POZNAN_CU_SKIP
     m_ppcYuvAvail  [ui]->destroy(); delete m_ppcYuvAvail  [ui]; m_ppcYuvAvail  [ui] = NULL;
 #endif
-#if POZNAN_SYNTH_VIEW
+#if POZNAN_CU_SYNTH
     m_ppcYuvSynth  [ui]->destroy(); delete m_ppcYuvSynth  [ui]; m_ppcYuvSynth  [ui] = NULL;
 #endif
@@ -137,8 +137,8 @@
   delete [] m_ppcYuvReco;    m_ppcYuvReco    = NULL;
   delete [] m_ppcYuvResPred; m_ppcYuvResPred = NULL;
-#if POZNAN_AVAIL_MAP
+#if POZNAN_CU_SKIP
   delete [] m_ppcYuvAvail;   m_ppcYuvAvail   = NULL;
 #endif
-#if POZNAN_SYNTH_VIEW
+#if POZNAN_CU_SYNTH
   delete [] m_ppcYuvSynth;   m_ppcYuvSynth   = NULL;
 #endif
@@ -217,5 +217,5 @@
   TComPic* pcPic = pcCU->getPic();
 
-#if POZNAN_ENCODE_ONLY_DISOCCLUDED_CU
+#if POZNAN_CU_SKIP
   Bool bWholeCUCanBeSynthesized = false;
   Bool bOneSubCUCanNotBeSynthesied = false;
@@ -267,5 +267,5 @@
   if( ( uiRPelX < pcCU->getSlice()->getSPS()->getWidth() ) && ( uiBPelY < pcCU->getSlice()->getSPS()->getHeight() ) )
   {
-#if POZNAN_ENCODE_ONLY_DISOCCLUDED_CU
+#if POZNAN_CU_SKIP
     if(bOneSubCUCanNotBeSynthesied && (uiDepth < g_uiMaxCUDepth - g_uiAddCUDepth )) // KUBA SYNTH check if CU has 3 synthesied subCU - no split flag is send in that case and CU split is assumed
     {
@@ -446,8 +446,8 @@
 {
   TComPic* pcPic = pcCU->getPic();
-#if POZNAN_SYNTH_VIEW
+#if POZNAN_CU_SYNTH
   if(pcPic->getPicYuvSynth())  m_ppcYuvSynth[uiDepth]->copyFromPicYuv( pcPic->getPicYuvSynth(), pcCU->getAddr(), uiAbsPartIdx );
 #endif
-#if POZNAN_AVAIL_MAP
+#if POZNAN_CU_SKIP
   if(pcPic->getPicYuvAvail())  m_ppcYuvAvail[uiDepth]->copyFromPicYuv( pcPic->getPicYuvAvail(), pcCU->getAddr(), uiAbsPartIdx );
 #endif
@@ -496,12 +496,9 @@
       xReconIntraQT( m_ppcCU[uiDepth], uiAbsPartIdx, uiDepth );
       break;
-#if POZNAN_ENCODE_ONLY_DISOCCLUDED_CU
+#if POZNAN_CU_SKIP
     case MODE_SYNTH:
     //  break;
-#if POZNAN_FILL_OCCLUDED_CU_WITH_SYNTHESIS
       m_ppcYuvReco[uiDepth]->copyFromPicYuv(pcPic->getPicYuvSynth(), pcCU->getAddr(), uiAbsPartIdx);
-#else
-      m_ppcYuvReco[uiDepth]->copyFromPicYuv(pcPic->getPicYuvAvail(), pcCU->getAddr(), uiAbsPartIdx); //Poprawiæ
-#endif
+      //m_ppcYuvReco[uiDepth]->copyFromPicYuv(pcPic->getPicYuvAvail(), pcCU->getAddr(), uiAbsPartIdx); //Poprawiæ
       //m_ppcYuvReco[uiDepth]->clear();
       break;
@@ -581,5 +578,9 @@
     m_pcPrediction->predIntraLumaAng( pcPattern, pcCU->getLumaIntraDir(uiPartIdx), pPred, uiStride, uiWidth, uiHeight, pcCU, bAboveAvail, bLeftAvail );
     
+#if POZNAN_TEXTURE_TU_DELTA_QP_ACCORDING_TO_DEPTH
+    m_pcTrQuant->setQPforQuant( pcCU->getQP(uiPartIdx) + pcCU->getQpOffsetForTextCU(uiPartIdx, true), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), TEXT_LUMA );
+#else
     m_pcTrQuant->setQPforQuant( pcCU->getQP(uiPartIdx), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), TEXT_LUMA );
+#endif
 #if INTRA_DST_TYPE_7
   m_pcTrQuant->invtransformNxN(TEXT_LUMA, pcCU->getLumaIntraDir(uiPartIdx), pResi, uiStride, pCoeff, uiWidth, uiHeight );
@@ -778,5 +779,9 @@
   }
   //===== inverse transform =====
+#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
 #if INTRA_DST_TYPE_7
   m_pcTrQuant->invtransformNxN( TEXT_LUMA, pcCU->getLumaIntraDir( uiAbsPartIdx ), piResi, uiStride, pcCoeff, uiWidth, uiHeight );
@@ -885,5 +890,9 @@
 
   //===== inverse transform =====
+#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(), eText );
+#else
   m_pcTrQuant->setQPforQuant  ( pcCU->getQP(0), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), eText );
+#endif
 #if INTRA_DST_TYPE_7 
   m_pcTrQuant->invtransformNxN( eText, REG_DCT, piResi, uiStride, pcCoeff, uiWidth, uiHeight );
@@ -1061,9 +1070,18 @@
   piCoeff = pcCU->getCoeffY();
   pResi = m_ppcYuvResi[uiDepth]->getLumaAddr();
+#if POZNAN_TEXTURE_TU_DELTA_QP_ACCORDING_TO_DEPTH
+  Int QPoffset = pcCU->getQpOffsetForTextCU(uiAbsPartIdx, false);
+  m_pcTrQuant->setQPforQuant  ( pcCU->getQP(uiAbsPartIdx) + QPoffset, !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), TEXT_LUMA );
+#else
   m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), TEXT_LUMA );
+#endif
   m_pcTrQuant->invRecurTransformNxN ( pcCU, 0, TEXT_LUMA, pResi, 0, m_ppcYuvResi[uiDepth]->getStride(), uiWidth, uiHeight, uiLumaTrMode, 0, piCoeff );
   
   // Cb and Cr
+#if POZNAN_TEXTURE_TU_DELTA_QP_ACCORDING_TO_DEPTH
+    m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ) + QPoffset, !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), TEXT_CHROMA );
+#else
   m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), TEXT_CHROMA );
+#endif
   
   uiWidth  >>= 1;
Index: branches/0.2-poznan-univ/source/Lib/TLibDecoder/TDecCu.h
===================================================================
--- branches/0.2-poznan-univ/source/Lib/TLibDecoder/TDecCu.h	(revision 11)
+++ branches/0.2-poznan-univ/source/Lib/TLibDecoder/TDecCu.h	(revision 12)
@@ -61,8 +61,8 @@
   TComYuv**           m_ppcYuvReco;       ///< array of prediction & reconstruction buffer
   TComYuv**           m_ppcYuvResPred;    ///< residual prediction buffer
-#if POZNAN_AVAIL_MAP
+#if POZNAN_CU_SKIP
   TComYuv**           m_ppcYuvAvail;      ///< array of available map buffer
 #endif
-#if POZNAN_SYNTH_VIEW
+#if POZNAN_CU_SYNTH
   TComYuv**           m_ppcYuvSynth;      ///< array of synth buffer
 #endif
Index: branches/0.2-poznan-univ/source/Lib/TLibDecoder/TDecEntropy.cpp
===================================================================
--- branches/0.2-poznan-univ/source/Lib/TLibDecoder/TDecEntropy.cpp	(revision 11)
+++ branches/0.2-poznan-univ/source/Lib/TLibDecoder/TDecEntropy.cpp	(revision 12)
@@ -430,4 +430,15 @@
   pcCU->setInterDirSubParts( puhInterDirNeighbours[uiMergeIndex], uiAbsPartIdx, uiPartIdx, uiDepth );
 
+#if POZNAN_EIVD_CALC_PRED_DATA
+  Int ref_idx0_EIVD,ref_idx1_EIVD;
+  TComMv cMv0_EIVD( 0, 0 ),cMv1_EIVD( 0, 0 );
+  if(uiMergeIndex==POZNAN_EIVD_MRG_CAND)
+  {	
+    pcCU->getCUMvField2nd( REF_PIC_LIST_0 )->setAllMvField( pcMvFieldNeighbours[ 2*uiMergeIndex ].getMv(), pcMvFieldNeighbours[ 2*uiMergeIndex ].getRefIdx(), eCUMode, uiAbsPartIdx, uiPartIdx, uiDepth );
+    pcCU->getCUMvField2nd( REF_PIC_LIST_1 )->setAllMvField( pcMvFieldNeighbours[ 2*uiMergeIndex + 1 ].getMv(), pcMvFieldNeighbours[ 2*uiMergeIndex + 1 ].getRefIdx(), eCUMode, uiAbsPartIdx, uiPartIdx, uiDepth );	
+    pcCU->getSlice()->getMP()->calcEIVDPredData(pcCU, uiAbsPartIdx, ref_idx0_EIVD, cMv0_EIVD, ref_idx1_EIVD, cMv1_EIVD);
+  }
+#endif
+
   TComMv cTmpMv( 0, 0 );
   if ( pcCU->getSlice()->getNumRefIdx( REF_PIC_LIST_0 ) > 0  ) //if ( ref. frame list0 has at least 1 entry )
@@ -436,4 +447,9 @@
     pcCU->setMVPNumSubParts( 0, REF_PIC_LIST_0, uiAbsPartIdx, uiPartIdx, uiDepth);
     pcCU->getCUMvField( REF_PIC_LIST_0 )->setAllMvd( cTmpMv, eCUMode, uiAbsPartIdx, uiPartIdx, uiDepth );
+#if POZNAN_EIVD_CALC_PRED_DATA
+    if(uiMergeIndex==POZNAN_EIVD_MRG_CAND) 
+       pcCU->getCUMvField( REF_PIC_LIST_0 )->setAllMvField( cMv0_EIVD, ref_idx0_EIVD, eCUMode, uiAbsPartIdx, uiPartIdx, uiDepth );
+    else
+#endif
     pcCU->getCUMvField( REF_PIC_LIST_0 )->setAllMvField( pcMvFieldNeighbours[ 2*uiMergeIndex ].getMv(), pcMvFieldNeighbours[ 2*uiMergeIndex ].getRefIdx(), eCUMode, uiAbsPartIdx, uiPartIdx, uiDepth );
 
@@ -444,4 +460,9 @@
     pcCU->setMVPNumSubParts( 0, REF_PIC_LIST_1, uiAbsPartIdx, uiPartIdx, uiDepth);
     pcCU->getCUMvField( REF_PIC_LIST_1 )->setAllMvd( cTmpMv, eCUMode, uiAbsPartIdx, uiPartIdx, uiDepth );
+#if POZNAN_EIVD_CALC_PRED_DATA
+    if(uiMergeIndex==POZNAN_EIVD_MRG_CAND)
+       pcCU->getCUMvField( REF_PIC_LIST_1 )->setAllMvField( cMv1_EIVD, ref_idx1_EIVD, eCUMode, uiAbsPartIdx, uiPartIdx, uiDepth );
+    else
+#endif
     pcCU->getCUMvField( REF_PIC_LIST_1 )->setAllMvField( pcMvFieldNeighbours[ 2*uiMergeIndex + 1 ].getMv(), pcMvFieldNeighbours[ 2*uiMergeIndex + 1 ].getRefIdx(), eCUMode, uiAbsPartIdx, uiPartIdx, uiDepth );
   }
Index: branches/0.2-poznan-univ/source/Lib/TLibDecoder/TDecGop.cpp
===================================================================
--- branches/0.2-poznan-univ/source/Lib/TLibDecoder/TDecGop.cpp	(revision 11)
+++ branches/0.2-poznan-univ/source/Lib/TLibDecoder/TDecGop.cpp	(revision 12)
@@ -199,4 +199,14 @@
 #endif
 
+#if POZNAN_MP
+	if( uiStartCUAddr == 0 )
+    {
+#if POZNAN_MP_USE_DEPTH_MAP_GENERATION
+	  pcSlice->getMP()->setDepthMapGenerator(m_pcDepthMapGenerator);
+#endif
+      pcSlice->getMP()->pairMultiview(rpcPic);
+	}
+#endif
+
     // decode slice
     m_pcSliceDecoder->decompressSlice(pcBitstream, rpcPic);
Index: branches/0.2-poznan-univ/source/Lib/TLibDecoder/TDecSbac.cpp
===================================================================
--- branches/0.2-poznan-univ/source/Lib/TLibDecoder/TDecSbac.cpp	(revision 11)
+++ branches/0.2-poznan-univ/source/Lib/TLibDecoder/TDecSbac.cpp	(revision 12)
@@ -579,5 +579,5 @@
 
 
-#if HHI_INTER_VIEW_MOTION_PRED || HHI_MPI
+#if HHI_INTER_VIEW_MOTION_PRED || HHI_MPI || POZNAN_EIVD
 Void TDecSbac::parseMergeIndexMV( TComDataCU* pcCU, UInt& ruiMergeIndex, UInt uiAbsPartIdx, UInt uiDepth )
 {
@@ -585,4 +585,8 @@
   const Bool bMVIAvailable = pcCU->getSlice()->getSPS()->getUseMVI() && pcCU->getSlice()->getSliceType() != I_SLICE;
   const UInt uiMviMergePos = bMVIAvailable ? HHI_MPI_MERGE_POS : MRG_MAX_NUM_CANDS;
+#endif
+#if POZNAN_EIVD
+  const Bool bEIVDAvailable = pcCU->getSlice()->getMP()->isEIVDEnabled();
+  Bool bEIVDModifyMergeIdx = true;
 #endif
   //--- set number of candidates and availability ---
@@ -611,4 +615,32 @@
     }
   }
+
+#if POZNAN_EIVD
+  if(bEIVDAvailable)
+  {
+    UInt uiEIVDMergePos = POZNAN_EIVD_MERGE_POS;
+#if HHI_MPI
+	if(bMVIAvailable && uiEIVDMergePos>=uiMviMergePos) uiEIVDMergePos++;
+#endif
+	for( Int iIdx = MRG_MAX_NUM_CANDS-2; iIdx >= (Int)uiEIVDMergePos; iIdx-- )
+	{
+		Int iWrIdx = iIdx+1;
+#if HHI_MPI
+		if(bMVIAvailable) 
+		{
+			if(iIdx==(Int)uiMviMergePos) continue;
+			if(iWrIdx==(Int)uiMviMergePos) iWrIdx++;
+		}
+#endif
+		if(iWrIdx>=MRG_MAX_NUM_CANDS) continue;
+
+		abAvailable[ iWrIdx ] = abAvailable[ iIdx ];
+	}
+	abAvailable[ uiEIVDMergePos ] = ( pcCU->getNeighbourCandIdx( POZNAN_EIVD_MRG_CAND, uiAbsPartIdx ) == POZNAN_EIVD_MRG_CAND + 1 );
+	
+	uiNumCand = 0; for( UInt uiIdx = 0; uiIdx < MRG_MAX_NUM_CANDS; uiIdx++ ) if(abAvailable[ uiIdx ]) uiNumCand++;
+  }
+#endif
+
   AOF( uiNumCand > 1 );
 
@@ -665,4 +697,15 @@
   {
     pcCU->setTextureModeDepthSubParts( uiDepth, uiAbsPartIdx, uiDepth );
+#if POZNAN_EIVD
+	bEIVDModifyMergeIdx = false;
+#endif
+  }
+#endif
+
+#if POZNAN_EIVD
+  if(bEIVDAvailable && bEIVDModifyMergeIdx)
+  {
+	if(ruiMergeIndex==POZNAN_EIVD_MERGE_POS) ruiMergeIndex = POZNAN_EIVD_MRG_CAND;
+	else if(ruiMergeIndex>POZNAN_EIVD_MERGE_POS) ruiMergeIndex--;
   }
 #endif
@@ -694,5 +737,5 @@
 Void TDecSbac::parseMergeIndex ( TComDataCU* pcCU, UInt& ruiMergeIndex, UInt uiAbsPartIdx, UInt uiDepth )
 {
-#if HHI_INTER_VIEW_MOTION_PRED || HHI_MPI
+#if HHI_INTER_VIEW_MOTION_PRED || HHI_MPI || POZNAN_EIVD
   if(
 #if HHI_INTER_VIEW_MOTION_PRED
@@ -701,4 +744,7 @@
 #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
Index: branches/0.2-poznan-univ/source/Lib/TLibDecoder/TDecSbac.h
===================================================================
--- branches/0.2-poznan-univ/source/Lib/TLibDecoder/TDecSbac.h	(revision 11)
+++ branches/0.2-poznan-univ/source/Lib/TLibDecoder/TDecSbac.h	(revision 12)
@@ -144,5 +144,5 @@
   Void parseMergeFlag     ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPUIdx );
   Void parseMergeIndex    ( TComDataCU* pcCU, UInt& ruiMergeIndex, UInt uiAbsPartIdx, UInt uiDepth );
-#if HHI_INTER_VIEW_MOTION_PRED || HHI_MPI
+#if HHI_INTER_VIEW_MOTION_PRED || HHI_MPI || POZNAN_EIVD
   Void parseMergeIndexMV  ( TComDataCU* pcCU, UInt& ruiMergeIndex, UInt uiAbsPartIdx, UInt uiDepth );
 #endif
Index: branches/0.2-poznan-univ/source/Lib/TLibDecoder/TDecSlice.cpp
===================================================================
--- branches/0.2-poznan-univ/source/Lib/TLibDecoder/TDecSlice.cpp	(revision 11)
+++ branches/0.2-poznan-univ/source/Lib/TLibDecoder/TDecSlice.cpp	(revision 12)
@@ -98,4 +98,12 @@
     g_bJustDoIt = g_bEncDecTraceEnable;
 #endif
+
+	// JK {
+	DTRACE_CABAC_V( g_nSymbolCounter++ );
+	DTRACE_CABAC_T( "\tCU: " );
+	DTRACE_CABAC_V( iCUAddr );
+	DTRACE_CABAC_T( "\n" );
+	// JK }
+
     m_pcCuDecoder->decodeCU     ( pcCU, uiIsLast );
     m_pcCuDecoder->decompressCU ( pcCU );
Index: branches/0.2-poznan-univ/source/Lib/TLibDecoder/TDecTop.cpp
===================================================================
--- branches/0.2-poznan-univ/source/Lib/TLibDecoder/TDecTop.cpp	(revision 11)
+++ branches/0.2-poznan-univ/source/Lib/TLibDecoder/TDecTop.cpp	(revision 12)
@@ -53,5 +53,5 @@
     m_aaiCodedScale       [ uiId ] = new Int [ MAX_NUMBER_VIEWS ];
   }
-#if POZNAN_SYNTH
+#if POZNAN_CU_SKIP || POZNAN_CU_SYNTH || (POZNAN_MP && !POZNAN_MP_USE_DEPTH_MAP_GENERATION)
   xCreateLUTs   ( (UInt)MAX_NUMBER_VIEWS, (UInt)MAX_NUMBER_VIEWS,  m_adBaseViewShiftLUT,  m_aiBaseViewShiftLUT);
 
@@ -73,5 +73,5 @@
   delete [] m_aiViewReceived;
 
-#if POZNAN_SYNTH
+#if POZNAN_CU_SKIP || POZNAN_CU_SYNTH || (POZNAN_MP && !POZNAN_MP_USE_DEPTH_MAP_GENERATION)
   xDeleteArray( m_adBaseViewShiftLUT,        MAX_NUMBER_VIEWS, MAX_NUMBER_VIEWS,  2 );
   xDeleteArray( m_aiBaseViewShiftLUT,        MAX_NUMBER_VIEWS, MAX_NUMBER_VIEWS,  2 );
@@ -91,5 +91,5 @@
 }
 
-#if POZNAN_SYNTH
+#if POZNAN_CU_SKIP || POZNAN_CU_SYNTH || (POZNAN_MP && !POZNAN_MP_USE_DEPTH_MAP_GENERATION)
 /*
 Void
@@ -294,5 +294,5 @@
         m_aaiCodedScale [ uiViewId ][ uiBaseId ]  = pcSlice->getInvCodedScale () [ uiBaseId ];
         m_aaiCodedOffset[ uiViewId ][ uiBaseId ]  = pcSlice->getInvCodedOffset() [ uiBaseId ];
-#if POZNAN_SYNTH
+#if POZNAN_CU_SKIP || POZNAN_CU_SYNTH || (POZNAN_MP && !POZNAN_MP_USE_DEPTH_MAP_GENERATION)
         xInitLUTs(uiBaseId,uiViewId,m_aaiCodedScale [ uiBaseId ][ uiViewId ],m_aaiCodedOffset[ uiBaseId ][ uiViewId ],m_adBaseViewShiftLUT,m_aiBaseViewShiftLUT);
         xInitLUTs(uiViewId,uiBaseId,m_aaiCodedScale [ uiViewId ][ uiBaseId ],m_aaiCodedOffset[ uiViewId ][ uiBaseId ],m_adBaseViewShiftLUT,m_aiBaseViewShiftLUT);
@@ -305,5 +305,5 @@
         m_aaiCodedScale [ uiViewId ][ uiBaseId ]  = pcSlice->getSPS()->getInvCodedScale () [ uiBaseId ];
         m_aaiCodedOffset[ uiViewId ][ uiBaseId ]  = pcSlice->getSPS()->getInvCodedOffset() [ uiBaseId ];
-#if POZNAN_SYNTH
+#if POZNAN_CU_SKIP || POZNAN_CU_SYNTH || (POZNAN_MP && !POZNAN_MP_USE_DEPTH_MAP_GENERATION)
         xInitLUTs(uiBaseId,uiViewId,m_aaiCodedScale [ uiBaseId ][ uiViewId ],m_aaiCodedOffset[ uiBaseId ][ uiViewId ],m_adBaseViewShiftLUT,m_aiBaseViewShiftLUT);
         xInitLUTs(uiViewId,uiBaseId,m_aaiCodedScale [ uiViewId ][ uiBaseId ],m_aaiCodedOffset[ uiViewId ][ uiBaseId ],m_adBaseViewShiftLUT,m_aiBaseViewShiftLUT);
@@ -323,5 +323,5 @@
         m_aaiCodedScale [ uiViewId ][ uiBaseId ]  = pcSlice->getInvCodedScale () [ uiBaseId ];
         m_aaiCodedOffset[ uiViewId ][ uiBaseId ]  = pcSlice->getInvCodedOffset() [ uiBaseId ];
-#if POZNAN_SYNTH
+#if POZNAN_CU_SKIP || POZNAN_CU_SYNTH || (POZNAN_MP && !POZNAN_MP_USE_DEPTH_MAP_GENERATION)
         xInitLUTs(uiBaseId,uiViewId,m_aaiCodedScale [ uiBaseId ][ uiViewId ],m_aaiCodedOffset[ uiBaseId ][ uiViewId ],m_adBaseViewShiftLUT,m_aiBaseViewShiftLUT);
         xInitLUTs(uiViewId,uiBaseId,m_aaiCodedScale [ uiViewId ][ uiBaseId ],m_aaiCodedOffset[ uiViewId ][ uiBaseId ],m_adBaseViewShiftLUT,m_aiBaseViewShiftLUT);
@@ -411,4 +411,7 @@
   m_bFirstSliceInSequence   = true;
   m_pcCamParsCollector = 0;
+#if POZNAN_MP
+  m_pcMP = NULL;
+#endif
 }
 
@@ -441,4 +444,8 @@
 #if HHI_INTER_VIEW_RESIDUAL_PRED
   m_cResidualGenerator.destroy();
+#endif
+
+#if POZNAN_MP
+  m_pcMP = NULL;
 #endif
 }
@@ -478,4 +485,8 @@
   m_cResidualGenerator.init( &m_cTrQuant, &m_cDepthMapGenerator );
 #endif
+
+#if POZNAN_MP
+  m_pcMP = pcTAppDecTop->getMP();
+#endif
 }
 
@@ -604,9 +615,12 @@
     pcPic->removeUsedPelsMapBuffer();
 #endif
-#if POZNAN_AVAIL_MAP
+#if POZNAN_CU_SYNTH || POZNAN_CU_SKIP
     pcPic->removeAvailabilityBuffer();
 #endif
-#if POZNAN_SYNTH_VIEW
+#if POZNAN_CU_SYNTH
     pcPic->removeSynthesisBuffer();
+#endif
+#if POZNAN_TEXTURE_TU_DELTA_QP_ACCORDING_TO_DEPTH
+    pcPic->removeSynthesisDepthBuffer();
 #endif
   }
@@ -696,7 +710,16 @@
       else
       {
+#if POZNAN_NONLINEAR_DEPTH
+        // For texture complete depth power information. Depth power is sended, for example, for base view depth map and it should be available prior non-base texture decoding
+        if(!cTempSPS.isDepth() && cTempSPS.getViewId())
+        {
+          Float fDepthPower = getDecTop()->getPicFromView( 0, pcPic->getPOC(), true )->getSPS()->getDepthPower();
+          cTempSPS.setDepthPower(fDepthPower);
+        }
+#endif
         cComSPS = cTempSPS;
         return false;
       }
+      
 
       // create ALF temporary buffer
@@ -710,4 +733,12 @@
       }
       m_uiValidPS |= 1;
+
+#if POZNAN_MP
+#if POZNAN_MP_USE_DEPTH_MAP_GENERATION
+      m_pcMP->init( m_cSPS.getHeight(), m_cSPS.getWidth() );
+#else
+      m_pcMP->init( m_cSPS.getHeight(), m_cSPS.getWidth(), m_pcCamParsCollector->getBaseViewShiftLUTI());
+#endif 
+#endif 
 
       return false;
@@ -820,4 +851,8 @@
       m_apcSlicePilot = pcPic->getPicSym()->getSlice(m_uiSliceIdx);
       pcPic->getPicSym()->setSlice(pcSlice, m_uiSliceIdx);
+
+#if POZNAN_MP
+	  pcSlice->setMP(m_pcMP);
+#endif
 
       if (bNextSlice)
@@ -875,15 +910,28 @@
 #endif
 
-#if POZNAN_SYNTH
-      if( m_pcCamParsCollector)
+#if POZNAN_CU_SKIP || POZNAN_CU_SYNTH
+      if( m_pcCamParsCollector )
       {
         m_pcCamParsCollector->setSlice( pcSlice );
       }
       //if(!getIsDepth())
-      getDecTop()->storeSynthPicsInBuffer(pcSlice->getViewIdx(),pcSlice->getSPS()->getViewOrderIdx(),pcSlice->getPOC(),getIsDepth());
+        getDecTop()->storeSynthPicsInBuffer(pcSlice->getViewIdx(),pcSlice->getSPS()->getViewOrderIdx(),pcSlice->getPOC(),getIsDepth());
+#endif
+
+#if POZNAN_MP 
+	std::vector<TComPic*> apcSpatDataRefPics = getDecTop()->getSpatialRefPics( pcPic->getViewIdx(), pcSlice->getPOC(), m_cSPS.isDepth() );
+	pcSlice->getMP()->setRefPicsList(&apcSpatDataRefPics);  
+#if !POZNAN_MP_USE_DEPTH_MAP_GENERATION
+	std::vector<TComPic*> apcSpatDepthRefPics = getDecTop()->getSpatialRefPics( pcPic->getViewIdx(), pcSlice->getPOC(), true );
+	pcSlice->getMP()->setDepthRefPicsList(&apcSpatDepthRefPics);
+#endif
 #endif
 
       //  Decode a picture
       m_cGopDecoder.decompressGop ( bEos, pcBitstream, pcPic, false );
+
+#if POZNAN_MP
+	  pcSlice->getMP()->disable();
+#endif
 
       if( m_pcCamParsCollector )
Index: branches/0.2-poznan-univ/source/Lib/TLibDecoder/TDecTop.h
===================================================================
--- branches/0.2-poznan-univ/source/Lib/TLibDecoder/TDecTop.h	(revision 11)
+++ branches/0.2-poznan-univ/source/Lib/TLibDecoder/TDecTop.h	(revision 12)
@@ -55,4 +55,8 @@
 #include "TDecCAVLC.h"
 
+#if POZNAN_MP
+#include "../TLibCommon/TComMP.h"
+#endif
+
 // ====================================================================================================================
 // Class definition
@@ -71,5 +75,5 @@
   Void  uninit      ();
   Void  setSlice    ( TComSlice* pcSlice );
-#if POZNAN_SYNTH
+#if POZNAN_CU_SKIP || (POZNAN_MP && !POZNAN_MP_USE_DEPTH_MAP_GENERATION)
   Double****          getBaseViewShiftLUTD      ()  { return m_adBaseViewShiftLUT;   }
   Int****             getBaseViewShiftLUTI      ()  { return m_aiBaseViewShiftLUT;   }
@@ -99,5 +103,5 @@
   UInt    m_uiMaxViewId;
 
-#if POZNAN_SYNTH
+#if POZNAN_CU_SKIP || POZNAN_CU_SYNTH || (POZNAN_MP && !POZNAN_MP_USE_DEPTH_MAP_GENERATION)
 
   UInt    m_uiBitDepthForLUT;
@@ -118,5 +122,5 @@
 };
 
-#if POZNAN_SYNTH
+#if POZNAN_CU_SKIP || POZNAN_CU_SYNTH || (POZNAN_MP && !POZNAN_MP_USE_DEPTH_MAP_GENERATION)
   template <class T>
 Void CamParsCollector::xDeleteArray( T*& rpt, UInt uiSize1, UInt uiSize2, UInt uiSize3 )
@@ -223,4 +227,8 @@
 #endif
 
+#if POZNAN_MP
+  TComMP*				  m_pcMP;
+#endif
+
   Bool                    m_bIsDepth;
   Int                     m_iViewIdx;
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
 };
 
Index: branches/0.2-poznan-univ/source/Lib/TLibRenderer/TRenFilter.cpp
===================================================================
--- branches/0.2-poznan-univ/source/Lib/TLibRenderer/TRenFilter.cpp	(revision 11)
+++ branches/0.2-poznan-univ/source/Lib/TLibRenderer/TRenFilter.cpp	(revision 12)
@@ -66,5 +66,5 @@
   riBlendDistWeight = bBlendUseDistWeight ? iRelDistToLeft :  1 << (REN_VDWEIGHT_PREC - 1);
 
-  for (UInt uiDepthValue = 0; uiDepthValue <= 256; uiDepthValue++)
+  for (UInt uiDepthValue = 0; uiDepthValue <= SizeOfLUT; uiDepthValue++)
   {
     //GT: retrieve depth approx from shift
@@ -73,5 +73,5 @@
   }
   // Set Threshold
-  riBlendZThres  = ( max( abs(piInvZLUTLeft[0]- piInvZLUTLeft[255]), abs(piInvZLUTRight[0]- piInvZLUTRight[255]) ) * iBlendZThresPerc + 50)  / 100;
+  riBlendZThres  = ( max( abs(piInvZLUTLeft[0]- piInvZLUTLeft[SizeOfLUT-1]), abs(piInvZLUTRight[0]- piInvZLUTRight[SizeOfLUT-1]) ) * iBlendZThresPerc + 50)  / 100;
 }
 
Index: branches/0.2-poznan-univ/source/Lib/TLibRenderer/TRenSingleModel.cpp
===================================================================
--- branches/0.2-poznan-univ/source/Lib/TLibRenderer/TRenSingleModel.cpp	(revision 11)
+++ branches/0.2-poznan-univ/source/Lib/TLibRenderer/TRenSingleModel.cpp	(revision 12)
@@ -139,6 +139,6 @@
   if (m_iMode == 2)
   {
-    m_piInvZLUTLeft  = new Int[257];
-    m_piInvZLUTRight = new Int[257];
+    m_piInvZLUTLeft  = new Int[SizeOfLUT+1];
+    m_piInvZLUTRight = new Int[SizeOfLUT+1];
   }
 
@@ -448,5 +448,5 @@
       m_iLastOccludedSPosFP = xRangeLeftL( m_iLastOccludedSPos );
       xExtrapolateMarginL  ( iCurSPos, iEndChangePos, iError );
-      iMinChangedSPos       = Min( iMinChangedSPos, (iEndChangePos << m_iShiftPrec) - m_ppiCurLUT[0][ RemoveBitIncrement( Max(m_apiBaseDepthPelRow[m_iCurViewPos][iEndChangePos], m_piNewDepthData[iPosXinNewData] )) ]);
+      iMinChangedSPos       = Min( iMinChangedSPos, (iEndChangePos << m_iShiftPrec) - m_ppiCurLUT[0][ RemoveBitIncrementLUT( Max(m_apiBaseDepthPelRow[m_iCurViewPos][iEndChangePos], m_piNewDepthData[iPosXinNewData] )) ]);
       iLastSPos             = iCurSPos;
       m_iLastDepth          = m_iCurDepth;
@@ -466,5 +466,5 @@
     {
       // Get minimal changed sample position
-      iMinChangedSPos = Min( iMinChangedSPos, (iCurPosX << m_iShiftPrec) - m_ppiCurLUT[0][ RemoveBitIncrement( Max(m_apiBaseDepthPelRow[m_iCurViewPos][iCurPosX], m_piNewDepthData[iPosXinNewData] )) ]);
+      iMinChangedSPos = Min( iMinChangedSPos, (iCurPosX << m_iShiftPrec) - m_ppiCurLUT[0][ RemoveBitIncrementLUT( Max(m_apiBaseDepthPelRow[m_iCurViewPos][iCurPosX], m_piNewDepthData[iPosXinNewData] )) ]);
       Int iCurSPos    = xShiftNewData(iCurPosX,iPosXinNewData);
       m_iCurDepth     = m_piNewDepthData[iPosXinNewData];
@@ -541,5 +541,5 @@
       m_iLastOccludedSPosFP = xRangeRightR( m_iLastOccludedSPos );
       xExtrapolateMarginR     ( iCurSPos, iStartChangePos, iError );
-      iMaxChangedSPos       = Max( iMaxChangedSPos, (iStartChangePos << m_iShiftPrec) - m_ppiCurLUT[0][ RemoveBitIncrement( Max(m_apiBaseDepthPelRow[m_iCurViewPos][iStartChangePos], m_piNewDepthData[iPosXinNewData] )) ]);
+      iMaxChangedSPos       = Max( iMaxChangedSPos, (iStartChangePos << m_iShiftPrec) - m_ppiCurLUT[0][ RemoveBitIncrementLUT( Max(m_apiBaseDepthPelRow[m_iCurViewPos][iStartChangePos], m_piNewDepthData[iPosXinNewData] )) ]);
       iLastSPos             = iCurSPos;
       m_iLastDepth          = m_iCurDepth;
@@ -559,5 +559,5 @@
     {
       // Get minimal changed sample position
-      iMaxChangedSPos = Max( iMaxChangedSPos, (iCurPosX << m_iShiftPrec) - m_ppiCurLUT[0][ RemoveBitIncrement( Max(m_apiBaseDepthPelRow[m_iCurViewPos][iCurPosX], m_piNewDepthData[iPosXinNewData] )) ]);
+      iMaxChangedSPos = Max( iMaxChangedSPos, (iCurPosX << m_iShiftPrec) - m_ppiCurLUT[0][ RemoveBitIncrementLUT( Max(m_apiBaseDepthPelRow[m_iCurViewPos][iCurPosX], m_piNewDepthData[iPosXinNewData] )) ]);
       Int iCurSPos    = xShiftNewData(iCurPosX,iPosXinNewData);
       m_iCurDepth     = m_piNewDepthData[iPosXinNewData];
@@ -948,5 +948,5 @@
   AOF( iPosInNewData < m_iNewDataWidth );
 
-  return (iPosX << m_iShiftPrec) - m_ppiCurLUT[0][ RemoveBitIncrement( m_piNewDepthData[iPosInNewData] )];
+  return (iPosX << m_iShiftPrec) - m_ppiCurLUT[0][ RemoveBitIncrementLUT( m_piNewDepthData[iPosInNewData] )];
 }
 
@@ -956,5 +956,5 @@
  AOT( iPosX <        0);
  AOF( iPosX < m_iWidth);
- return (iPosX  << m_iShiftPrec) - m_ppiCurLUT[0][ RemoveBitIncrement( m_apiBaseDepthPelRow[m_iCurViewPos][iPosX] )];
+ return (iPosX  << m_iShiftPrec) - m_ppiCurLUT[0][ RemoveBitIncrementLUT( m_apiBaseDepthPelRow[m_iCurViewPos][iPosX] )];
 }
 
@@ -1149,6 +1149,6 @@
       m_aapiSynthVideoPelRow                                   [1][2][iTargetSPos]  ,
 #endif
-      m_piInvZLUTLeft [RemoveBitIncrement(m_iThisDepth)                            ],
-      m_piInvZLUTRight[RemoveBitIncrement(m_apiSynthDepthPelRow[1]   [iTargetSPos])],
+      m_piInvZLUTLeft [RemoveBitIncrementLUT(m_iThisDepth)                            ],
+      m_piInvZLUTRight[RemoveBitIncrementLUT(m_apiSynthDepthPelRow[1]   [iTargetSPos])],
       iFilled,
       m_apiFilledRow                                           [1]   [iTargetSPos]  ,
@@ -1171,6 +1171,6 @@
       m_aapiBaseVideoPelRow                                    [1][2][iSourcePos ],
 #endif
-      m_piInvZLUTLeft [RemoveBitIncrement(m_apiSynthDepthPelRow[0]   [iTargetSPos])],
-      m_piInvZLUTRight[RemoveBitIncrement(m_iThisDepth)                            ],
+      m_piInvZLUTLeft [RemoveBitIncrementLUT(m_apiSynthDepthPelRow[0]   [iTargetSPos])],
+      m_piInvZLUTRight[RemoveBitIncrementLUT(m_iThisDepth)                            ],
       m_apiFilledRow                                           [0]   [iTargetSPos],
       iFilled                                                                     ,
Index: branches/0.2-poznan-univ/source/Lib/TLibRenderer/TRenTop.cpp
===================================================================
--- branches/0.2-poznan-univ/source/Lib/TLibRenderer/TRenTop.cpp	(revision 11)
+++ branches/0.2-poznan-univ/source/Lib/TLibRenderer/TRenTop.cpp	(revision 12)
@@ -242,5 +242,5 @@
     for( UInt uiPlane = 0; uiPlane < 2; uiPlane++)
     {
-      for (UInt uiDepthValue = 0; uiDepthValue <= 256; uiDepthValue++)
+      for (UInt uiDepthValue = 0; uiDepthValue <= SizeOfLUT; uiDepthValue++)
       {
         m_ppdShiftLUTRightMirror[uiPlane][uiDepthValue] = - m_ppdShiftLUTRight[uiPlane][uiDepthValue];
@@ -266,7 +266,8 @@
   PelImage cInputDepth ( pcPicYuvDepth    , true);
   PelImage cOutputImage( pcPicYuvSynthOut );
-    
+
   m_pcOutputImage->init();
   m_pcFilled     ->assign(REN_IS_HOLE);
+
   xPreProcessDepth ( &cInputDepth,  &cInputDepth);
   xConvertInputData( &cInputImage, &cInputDepth, m_pcInputImage, m_pcInputDepth, !bRenderFromLeft );
@@ -279,5 +280,5 @@
 };
 
-#if POZNAN_SYNTH
+#if POZNAN_CU_SYNTH || POZNAN_CU_SKIP
 Void TRenTop::extrapolateAvailabilityView( TComPicYuv* pcPicYuvVideo, TComPicYuv* pcPicYuvDepth, TComPicYuv* pcPicYuvSynthOut, TComPicYuv* pcPicYuvAvailOut, Bool bRenderFromLeft )
 {
@@ -292,17 +293,26 @@
   PelImage cFillImage( pcPicYuvAvailOut );
     
+  printf("0");
   m_pcOutputImage->init();
   m_pcFilled     ->assign(REN_IS_HOLE);
-  
+  printf("1");
   xPreProcessDepth ( &cInputDepth,  &cInputDepth);
+  printf("2");
   xConvertInputData( &cInputImage, &cInputDepth, m_pcInputImage, m_pcInputDepth, !bRenderFromLeft );
+  printf("3");
   xShiftPixels(m_pcInputImage, m_pcInputDepth, m_pcOutputImage, &cFillImage, bRenderFromLeft);
+  printf("4");
   xRemBoundaryNoise ( m_pcOutputImage, &cFillImage, m_pcOutputImage, bRenderFromLeft); // Erode
+  printf("5");
   xFillHoles        ( m_pcOutputImage, &cFillImage, m_pcOutputImage, bRenderFromLeft);
+  printf("6");
   xConvertOutputData( m_pcOutputImage, &cOutputImage, !bRenderFromLeft );
   if (!bRenderFromLeft)  TRenFilter::mirrorHor( &cFillImage );
   //xConvertOutputData( m_pcFilled, &cFillImage, !bRenderFromLeft );
+  printf("7");
   xPostProcessImage (&cOutputImage, &cOutputImage);
+  printf("8");
   xCutMargin        ( &cOutputImage );
+  printf("9");
 };
 #endif
@@ -497,5 +507,5 @@
 
       // compute disparity and shift
-      iShiftedPos  = ( iPosX << m_iRelShiftLUTPrec ) - m_aiShiftLUTCur[RemoveBitIncrement( pcDepthData[iPosX])];
+      iShiftedPos  = ( iPosX << m_iRelShiftLUTPrec ) - m_aiShiftLUTCur[RemoveBitIncrementLUT( pcDepthData[iPosX])];
 
       if (iPosX == 0)
@@ -651,6 +661,6 @@
 
         // compute disparity and shift
-        assert( RemoveBitIncrement(pcDepthData[iPosX]) >= 0 && RemoveBitIncrement(pcDepthData[iPosX]) <= 256 );
-        dPrevShiftedPos  = (Double) iPosX - m_adShiftLUTCur[ RemoveBitIncrement(pcDepthData[iPosX])];
+        assert( RemoveBitIncrementLUT(pcDepthData[iPosX]) >= 0 && RemoveBitIncrementLUT(pcDepthData[iPosX]) <= SizeOfLUT );
+        dPrevShiftedPos  = (Double) iPosX - m_adShiftLUTCur[ RemoveBitIncrementLUT(pcDepthData[iPosX])];
 
         if (iPosX == 0)
@@ -832,6 +842,6 @@
     for(Int iPosX = 0; iPosX < iWidth; iPosX++)
     {
-      assert( RemoveBitIncrement(pcDepthData[iPosX]) >= 0 && RemoveBitIncrement(pcDepthData[iPosX]) <= 256 );
-      Int iShiftedPos = iPosX - m_aiShiftLUTCur[ RemoveBitIncrement(pcDepthData[iPosX])] ;
+      assert( RemoveBitIncrementLUT(pcDepthData[iPosX]) >= 0 && RemoveBitIncrementLUT(pcDepthData[iPosX]) <= SizeOfLUT );
+      Int iShiftedPos = iPosX - m_aiShiftLUTCur[ RemoveBitIncrementLUT(pcDepthData[iPosX])] ;
       if (iShiftedPos < iWidth && iShiftedPos >= 0)
       {
@@ -907,5 +917,5 @@
     for(Int iPosX = 0; iPosX < iOutputWidth; iPosX ++)
     {
-      Int iBackShiftedPos = (iPosX << m_iRelShiftLUTPrec) - m_aiShiftLUTCur[ RemoveBitIncrement( pcDepthData[iPosX] )];
+      Int iBackShiftedPos = (iPosX << m_iRelShiftLUTPrec) - m_aiShiftLUTCur[ RemoveBitIncrementLUT( pcDepthData[iPosX] )];
       if( ( pcFilledData[iPosX] == REN_IS_FILLED )  && (iBackShiftedPos >= 0 ) && ( iBackShiftedPos < iInputWidth ) )
       {
@@ -980,5 +990,5 @@
     {
       // compute disparity and shift
-      iShiftedPos  =  iPosX - m_aiShiftLUTCur[RemoveBitIncrement(pcDepthData[iPosX])];
+      iShiftedPos  =  iPosX - m_aiShiftLUTCur[RemoveBitIncrementLUT(pcDepthData[iPosX])];
 
       if ( iPosX == 0 )
@@ -1865,5 +1875,5 @@
         if      (  (pcFilledRightData[uiXPos] != REN_IS_HOLE ) && ( pcFilledLeftData[uiXPos] != REN_IS_HOLE) )
         {
-          Int iDepthDifference  = m_piInvZLUTLeft[RemoveBitIncrement(pcLeftDepthData[uiXPos])] - m_piInvZLUTRight[RemoveBitIncrement(pcRightDepthData[uiXPos])];
+          Int iDepthDifference  = m_piInvZLUTLeft[RemoveBitIncrementLUT(pcLeftDepthData[uiXPos])] - m_piInvZLUTRight[RemoveBitIncrementLUT(pcRightDepthData[uiXPos])];
 
           if ( abs ( iDepthDifference ) <= m_iBlendZThres )
@@ -1894,5 +1904,5 @@
         else if ( (pcFilledRightData[uiXPos] == REN_IS_HOLE) && (pcFilledLeftData[uiXPos] == REN_IS_HOLE))
         {
-          pcOutputData[uiXPos] = m_piInvZLUTLeft[RemoveBitIncrement( pcLeftDepthData[uiXPos])]  < m_piInvZLUTRight[RemoveBitIncrement(pcRightDepthData[uiXPos])] ? pcLeftVideoData[uiXPos] : pcRightVideoData[uiXPos];
+          pcOutputData[uiXPos] = m_piInvZLUTLeft[RemoveBitIncrementLUT( pcLeftDepthData[uiXPos])]  < m_piInvZLUTRight[RemoveBitIncrementLUT(pcRightDepthData[uiXPos])] ? pcLeftVideoData[uiXPos] : pcRightVideoData[uiXPos];
         }
         else
@@ -2058,6 +2068,6 @@
 
   m_ppdShiftLUTRightMirror    = new Double*[2];
-  m_ppdShiftLUTRightMirror[0] = new Double [257];
-  m_ppdShiftLUTRightMirror[1] = new Double [257];
+  m_ppdShiftLUTRightMirror[0] = new Double [SizeOfLUT+1];
+  m_ppdShiftLUTRightMirror[1] = new Double [SizeOfLUT+1];
 
   m_adShiftLUTCur    = 0;
@@ -2066,10 +2076,10 @@
   m_ppiShiftLUTRight = 0;
   m_ppiShiftLUTRightMirror    = new Int*[2];
-  m_ppiShiftLUTRightMirror[0] = new Int[257];
-  m_ppiShiftLUTRightMirror[1] = new Int[257];
+  m_ppiShiftLUTRightMirror[0] = new Int[SizeOfLUT+1];
+  m_ppiShiftLUTRightMirror[1] = new Int[SizeOfLUT+1];
 
   m_aiShiftLUTCur    = 0;
-  m_piInvZLUTLeft  = new Int[257];
-  m_piInvZLUTRight = new Int[257];
+  m_piInvZLUTLeft  = new Int[SizeOfLUT+1];
+  m_piInvZLUTRight = new Int[SizeOfLUT+1];
 
   // Buffers
Index: branches/0.2-poznan-univ/source/Lib/TLibRenderer/TRenTop.h
===================================================================
--- branches/0.2-poznan-univ/source/Lib/TLibRenderer/TRenTop.h	(revision 11)
+++ branches/0.2-poznan-univ/source/Lib/TLibRenderer/TRenTop.h	(revision 12)
@@ -110,5 +110,5 @@
                            Int         iSimEnhBaseView );
 
-#if POZNAN_SYNTH
+#if POZNAN_CU_SYNTH || POZNAN_CU_SKIP
   Void extrapolateAvailabilityView   
                          ( TComPicYuv* pcPicYuvVideo, 
