Index: branches/0.3-poznan-univ/source/Lib/TLibCommon/CommonDef.h
===================================================================
--- branches/0.3-poznan-univ/source/Lib/TLibCommon/CommonDef.h	(revision 30)
+++ branches/0.3-poznan-univ/source/Lib/TLibCommon/CommonDef.h	(revision 41)
@@ -144,10 +144,4 @@
 #endif
 
-#if POZNAN_NONLINEAR_DEPTH
-#define POZNAN_LUT_INCREASED_PRECISION 0 // 1 //to do
-#else
-#define POZNAN_LUT_INCREASED_PRECISION 0
-#endif
-
 //>>>>> generation and usage of virtual prediction depth maps >>>>>
 #define PDM_ONE_DEPTH_PER_PU              1         // use only a single depth for a prediction unit (in update)
@@ -192,19 +186,4 @@
 #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
-
 // ====================================================================================================================
 // Macro functions
@@ -218,11 +197,5 @@
 #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
@@ -665,4 +638,68 @@
 
 
+#if POZNAN_NONLINEAR_DEPTH
+struct TComNonlinearDepthModel // // OS: cannot be stdarray, due to memcpy done on SlicePilot
+{
+  Int m_aiPoints[257];
+  Int m_iNum;
+
+  Int m_aiX[257];
+  Int m_aiY[257];
+
+  Void Clear() { m_iNum=0; m_aiPoints[0]=0; m_aiPoints[1]=0; };
+  Void Init() 
+  { 
+    for (Int k=m_iNum+1; k>=0; --k)
+    {
+      int q = 255*k/(m_iNum+1);
+      m_aiX[k] = q + m_aiPoints[k];
+      m_aiY[k] = q - m_aiPoints[k];
+    }
+  };
+
+  Double xInterpolateD(Int *aiX,Int *aiY, Double x, Double dScale)
+  {
+    Int x1 = 0;
+    Int x2 = m_iNum+1;
+
+    for (;;)
+    {
+      if (x1+1>=x2)
+        return ((x-aiX[x1])*(aiY[x2]-aiY[x1])/(aiX[x2]-aiX[x1]) + aiY[x1])*dScale;
+      Int xm = (x1+x2)>>1;
+      if (x >= aiX[xm]) x1 = xm;
+      else              x2 = xm;
+    }
+  }
+
+  inline Double ForwardD(Double x,  Double dScale) { return xInterpolateD(m_aiX, m_aiY, x, dScale); }
+  inline Double BackwardD(Double x, Double dScale) { return xInterpolateD(m_aiY, m_aiX, x, dScale); }
+
+  Int64 xInterpolateI(Int *aiX,Int *aiY, Int x, Int64 iScale)
+  {
+    Int x1 = 0;
+    Int x2 = m_iNum+1;
+
+    for (;;)
+    {
+      if (x1+1>=x2)
+      {         
+        Int aiXx2x1 = (aiX[x2]-aiX[x1]);
+        Int64 res = (x-aiX[x1])*(aiY[x2]-aiY[x1])*iScale;
+        if (res>0) return (res + (aiXx2x1>>1) )/aiXx2x1 + aiY[x1]*iScale;
+        else       return (res - (aiXx2x1>>1) )/aiXx2x1 + aiY[x1]*iScale; 
+      }
+      Int xm = (x1+x2)>>1;
+      if (x >= aiX[xm]) x1 = xm;
+      else              x2 = xm;
+    }
+  }
+
+  inline Int64  ForwardI (Int x, Int64 iScale) { return xInterpolateI(m_aiX, m_aiY, x, iScale); }
+  inline Int64  BackwardI(Int x, Int64 iScale) { return xInterpolateI(m_aiY, m_aiX, x, iScale); }
+
+};
+#endif
+
 #endif // end of #ifndef  __COMMONDEF__
 
Index: branches/0.3-poznan-univ/source/Lib/TLibCommon/TComDataCU.cpp
===================================================================
--- branches/0.3-poznan-univ/source/Lib/TLibCommon/TComDataCU.cpp	(revision 30)
+++ branches/0.3-poznan-univ/source/Lib/TLibCommon/TComDataCU.cpp	(revision 41)
@@ -5004,12 +5004,12 @@
     exit(333);
   }
-  Float fVal = (Float)((255 - (uiBlockMax >> g_uiBitIncrement)) >> 4);
+  Double fVal = (Double)((255 - (uiBlockMax >> g_uiBitIncrement)) >> 4); //Owieczka ?? ToDo Convert Double to Int
   fVal = (fVal * fVal);
 #if POZNAN_TEXTURE_TU_DELTA_QP_PARAM_IN_CFG_FOR_ENC
-  fVal = (Float)( fVal + getPic()->getTexDqpAccordingToDepthOffset() * 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()->getTexDqpAccordingToDepthMul()); // 
+  fVal = (Double)( fVal + getPic()->getTexDqpAccordingToDepthOffset() * 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 = (Double)( fVal * getPic()->getTexDqpAccordingToDepthMul()); // 
 #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); // 
+  fVal = (Double)( 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 = (Double)( fVal * POZNAN_TEXTURE_TU_DELTA_QP_MUL); // 
 #endif
   return (Int)fVal >> 5;
@@ -5034,5 +5034,18 @@
    UInt iCuAddr = getAddr();
    //TComPic * pcDepthPic = getPic()->getDepthPic();
+#if FLEX_CODING_ORDER
+   TComPicYuv * pcDepthPicYUV = NULL;
+   // if depth map reconstruction picture is available use it Use synthesis picture otherwise.
+   if(getPic()->getSlice(0)->getDepthPic() != NULL && getPic()->getSlice(0)->getDepthPic()->getReconMark())
+   {
+     pcDepthPicYUV = getPic()->getSlice(0)->getDepthPic()->getPicYuvRec();
+   }
+   else
+   {
+      pcDepthPicYUV = getPic()->getPicYuvSynthDepth();
+   }
+#else
    TComPicYuv * pcDepthPicYUV = getPic()->getPicYuvSynthDepth();
+#endif
    if(pcDepthPicYUV /*pcDepthPic*/ == NULL)
    {
@@ -5055,6 +5068,6 @@
    }
 #if POZNAN_NONLINEAR_DEPTH
-   TComNonlinearDepthBackward cNonlinearDepthBwd(getSlice()->getSPS()->getDepthPower(), g_uiBitIncrement, g_uiBitIncrement); 
-   uiDepthLumaTransformBlockMax = (Pel)( cNonlinearDepthBwd(uiDepthLumaTransformBlockMax) + 0.5);
+   if( getSlice()->getSPS()->getUseNonlinearDepth() )
+    uiDepthLumaTransformBlockMax = (Pel)( getSlice()->getSPS()->getNonlinearDepthModel().BackwardI(RemoveBitIncrement(uiDepthLumaTransformBlockMax), 1<<g_uiBitIncrement ) ) ;
 #endif
    Int iDeltaQP = CuQpIncrementFunction(uiDepthLumaTransformBlockMax);
Index: branches/0.3-poznan-univ/source/Lib/TLibCommon/TComMP.cpp
===================================================================
--- branches/0.3-poznan-univ/source/Lib/TLibCommon/TComMP.cpp	(revision 30)
+++ branches/0.3-poznan-univ/source/Lib/TLibCommon/TComMP.cpp	(revision 41)
@@ -44,4 +44,9 @@
 	//m_pcCameraData = NULL;
 	m_aiBaseViewShiftLUT = NULL;
+#if POZNAN_MP_USE_CURRENT_VIEW_DEPTH_MAP_IF_AVAILABLE
+  m_ppiTempMvPtCorrX = NULL;
+  m_ppiTempMvPtCorrY = NULL;
+  m_ppiTempMvPtCorrZ = NULL;
+#endif
 #endif
 
@@ -96,22 +101,4 @@
 #endif
 
-/*
-	m_ppiMvPtCorrX = new Short*[m_uiHeight];
-	m_ppiMvPtCorrY = new Short*[m_uiHeight];
-	m_ppiMvPtCorrZ = new Short*[m_uiHeight];
-	m_ppiMvPtCorrRefViewIdx = new Short*[m_uiHeight];
-	m_pppcRefCU = new TComDataCU**[m_uiHeight];
-	m_ppuicRefPartAddr = new UShort*[m_uiHeight];	
-	for(Int i=0;i<m_uiHeight;i++)
-	{
-		m_ppiMvPtCorrX[i] = new Short[m_uiWidth];
-		m_ppiMvPtCorrY[i] = new Short[m_uiWidth];
-		m_ppiMvPtCorrZ[i] = new Short[m_uiWidth];
-		m_ppiMvPtCorrRefViewIdx[i] = new Short[m_uiWidth];
-		m_pppcRefCU[i] = new TComDataCU*[m_uiWidth];
-		m_ppuicRefPartAddr[i]  = new UShort[m_uiWidth];
-	}
-//*/
-///*
 	Short* piPtr;
 	UShort* puiPtr;
@@ -141,5 +128,19 @@
 	puiPtr = (UShort*)malloc(sizeof(UShort)*m_uiHeight*m_uiWidth);
 	for(UInt i=0,addr=0;i<m_uiHeight;i++,addr+=m_uiWidth) m_ppuicRefPartAddr[i] = &(puiPtr[addr]);
-//*/
+
+#if !POZNAN_MP_USE_DEPTH_MAP_GENERATION && POZNAN_MP_USE_CURRENT_VIEW_DEPTH_MAP_IF_AVAILABLE
+	m_ppiTempMvPtCorrX = (Short**)malloc(sizeof(Short*)*m_uiHeight);
+	piPtr = (Short*)malloc(sizeof(Short)*m_uiHeight*m_uiWidth);
+	for(UInt i=0,addr=0;i<m_uiHeight;i++,addr+=m_uiWidth) m_ppiTempMvPtCorrX[i] = &(piPtr[addr]);
+
+	m_ppiTempMvPtCorrY = (Short**)malloc(sizeof(Short*)*m_uiHeight);
+	piPtr = (Short*)malloc(sizeof(Short)*m_uiHeight*m_uiWidth);
+	for(UInt i=0,addr=0;i<m_uiHeight;i++,addr+=m_uiWidth) m_ppiTempMvPtCorrY[i] = &(piPtr[addr]);
+
+	m_ppiTempMvPtCorrZ = (Short**)malloc(sizeof(Short*)*m_uiHeight);
+	piPtr = (Short*)malloc(sizeof(Short)*m_uiHeight*m_uiWidth);
+	for(UInt i=0,addr=0;i<m_uiHeight;i++,addr+=m_uiWidth) m_ppiTempMvPtCorrZ[i] = &(piPtr[addr]);
+#endif
+
 #if POZNAN_DBMP & !POZNAN_DBMP_COMPRESS_ME_DATA
 	m_ppiL0RefPOC.clear();
@@ -303,4 +304,34 @@
 	}
 
+#if !POZNAN_MP_USE_DEPTH_MAP_GENERATION && POZNAN_MP_USE_CURRENT_VIEW_DEPTH_MAP_IF_AVAILABLE
+	if(m_ppiTempMvPtCorrX!=NULL)
+	{
+		//for(Int i=0;i<m_uiHeight;i++) delete [] m_ppiTempMvPtCorrX[i];
+		//delete [] m_ppiTempMvPtCorrX;
+		free(m_ppiTempMvPtCorrX[0]);
+		free(m_ppiTempMvPtCorrX);
+		m_ppiTempMvPtCorrX = NULL;
+	}
+
+	if(m_ppiTempMvPtCorrY!=NULL)
+	{
+		//for(Int i=0;i<m_uiHeight;i++) delete [] m_ppiTempMvPtCorrY[i];
+		//delete [] m_ppiTempMvPtCorrY;
+		free(m_ppiTempMvPtCorrY[0]);
+		free(m_ppiTempMvPtCorrY);
+		m_ppiTempMvPtCorrY = NULL;
+	}
+
+	if(m_ppiTempMvPtCorrZ!=NULL)
+	{
+		//for(Int i=0;i<m_uiHeight;i++) delete [] m_ppiTempMvPtCorrZ[i];
+		//delete [] m_ppiTempMvPtCorrZ;
+		free(m_ppiTempMvPtCorrZ[0]);
+		free(m_ppiTempMvPtCorrZ);
+		m_ppiTempMvPtCorrZ = NULL;
+	}
+
+#endif
+
 #if POZNAN_DBMP & !POZNAN_DBMP_COMPRESS_ME_DATA
 	PUT_MP_ARRAY_TYPE** ppiTemp;
@@ -439,4 +470,20 @@
 }
 
+#if !POZNAN_MP_USE_DEPTH_MAP_GENERATION && POZNAN_MP_USE_CURRENT_VIEW_DEPTH_MAP_IF_AVAILABLE
+Void TComMP::clearTemp()
+{
+	if(!isInit()) return;
+
+	for(Int i=0;i<m_uiHeight;i++)
+		for(Int j=0;j<m_uiWidth;j++)
+		{
+			m_ppiTempMvPtCorrX[i][j] = TComMP::OCCLUSION;
+			m_ppiTempMvPtCorrY[i][j] = TComMP::OCCLUSION;
+			//m_ppiTempMvPtCorrZ[i][j] = 0x7FFF; //Depth
+			m_ppiTempMvPtCorrZ[i][j] = TComMP::OCCLUSION; //Disparity
+		}
+}
+#endif
+
 Bool TComMP::isInit()
 {
@@ -498,4 +545,7 @@
 	//Bool bIsLeft;
 	Int  iDepth;
+#if POZNAN_MP_USE_CURRENT_VIEW_DEPTH_MAP_IF_AVAILABLE
+	Int iSrcX, iSrcY;
+#endif	
 #endif	
 
@@ -547,4 +597,113 @@
 	}
 #else
+
+#if POZNAN_MP_USE_CURRENT_VIEW_DEPTH_MAP_IF_AVAILABLE
+	//pcDepthPic = GetPicFromList(m_pcDepthRefPicsList, uiPOC, uiViewId);
+	if(pcPic->getSlice(0)->getDepthPic()!=NULL && pcPic->getSlice(0)->getDepthPic()->getReconMark())
+		pcDepthPic = pcPic->getSlice(0)->getDepthPic();
+	else
+		pcDepthPic = NULL;
+
+	if(pcDepthPic!=NULL)
+	{
+	  pDepth = pcDepthPic->getPicYuvRec()->getLumaAddr();
+	  iStride = pcDepthPic->getPicYuvRec()->getStride();
+
+	  for( UInt uiIdx = 0; uiIdx < uiViewId; uiIdx++ )
+	  //for( UInt uiIdx = uiViewId-1; uiIdx >= uiViewId; uiIdx-- )
+	  {
+	    uiRefViewId = uiIdx;
+
+		pcRefPic = GetPicFromList(m_pcRefPicsList, uiPOC, uiRefViewId);
+		assert(pcRefPic!=NULL);//test
+		if(pcRefPic==NULL) return false; //No ref pic with current POC and RefView found in ref list!!!
+
+		if(!pcRefPic->getSlice(0)->isIntra()) bIsRefNoISliceAvailable = true;
+		else bIsAnchorPicture = true;
+
+		//ppiShiftLUTLeft = m_pcCameraData->getBaseViewShiftLUTI()[uiViewId][uiRefViewId];
+		ppiShiftLUTLeft = m_aiBaseViewShiftLUT[uiViewId][uiRefViewId];
+
+		clearTemp();
+
+		for(iCurY=0; iCurY<(Int)m_uiHeight; iCurY++)
+			for(iCurX=0; iCurX<(Int)m_uiWidth; iCurX++)
+			{
+				//Check if point already has its reference:
+				if(m_ppiMvPtCorrX[iCurY][iCurX]!=TComMP::OCCLUSION && m_ppiMvPtCorrY[iCurY][iCurX]!=TComMP::OCCLUSION) continue;
+
+				iDepth = pDepth[ iCurX + iCurY * iStride ];
+				iDepth = RemoveBitIncrement(iDepth);
+				assert( iDepth >= 0 && iDepth <= 256 );					
+				
+				//if(bIsLeft) iDisparity = ppiShiftLUTLeft[0][iDepth];
+				//else iDisparity = -ppiShiftLUTLeft[0][iDepth];
+				iDisparity = ppiShiftLUTLeft[0][iDepth]; //!!!
+
+				iRefX = iCurX - ( ( iDisparity + 2 ) >> 2 );
+				iRefY = iCurY;
+
+				if(iRefX>=0 && iRefX<m_uiWidth && iRefY>=0 && iRefY<m_uiHeight)
+				{
+					iSrcX = m_ppiTempMvPtCorrX[iRefY][iRefX];
+					iSrcY = m_ppiTempMvPtCorrY[iRefY][iRefX];
+
+					if(iSrcX==TComMP::OCCLUSION || iSrcY==TComMP::OCCLUSION)
+					{
+						m_ppiMvPtCorrRefViewIdx[iCurY][iCurX] = (Short)uiRefViewId;
+						m_ppiMvPtCorrX[iCurY][iCurX] = (Short)iRefX;
+						m_ppiMvPtCorrY[iCurY][iCurX] = (Short)iRefY;
+
+						m_ppiMvPtCorrZ[iCurY][iCurX] = (Short)iDepth;
+						//m_ppiMvPtCorrZ[iCurY][iCurX] = (Short)iDisparity;						
+
+						pcRefCU = pcRefPic->getCU((UInt)(iRefY/pcRefPic->getSlice(0)->getSPS()->getMaxCUHeight()*pcRefPic->getFrameWidthInCU() + iRefX/pcRefPic->getSlice(0)->getSPS()->getMaxCUWidth()));
+
+						m_pppcRefCU[iCurY][iCurX] = pcRefCU;
+						m_ppuicRefPartAddr[iCurY][iCurX] = (UShort)g_auiRasterToZscan[(iRefY-pcRefCU->getCUPelY())/pcRefPic->getMinCUHeight()*pcRefPic->getNumPartInWidth()+(iRefX-pcRefCU->getCUPelX())/pcRefPic->getMinCUWidth()];
+
+						m_ppiTempMvPtCorrX[iRefY][iRefX] = iCurX;
+						m_ppiTempMvPtCorrY[iRefY][iRefX] = iCurY;
+						m_ppiTempMvPtCorrZ[iRefY][iRefX] = (Short)iDepth;
+						//m_ppiTempMvPtCorrZ[iRefY][iRefX] = (Short)iDisparity;
+					}
+					else if((Short)iDepth>m_ppiTempMvPtCorrZ[iRefY][iRefX]) //Point assigned earlier to this location is occluded
+					//else if((Short)iDisparity>m_ppiTempMvPtCorrZ[iRefY][iRefX]) //Point assigned earlier to this location is occluded
+					{
+						m_ppiMvPtCorrRefViewIdx[iCurY][iCurX] = (Short)uiRefViewId;
+						m_ppiMvPtCorrX[iCurY][iCurX] = (Short)iRefX;
+						m_ppiMvPtCorrY[iCurY][iCurX] = (Short)iRefY;
+
+						m_ppiMvPtCorrZ[iCurY][iCurX] = (Short)iDepth;
+						//m_ppiMvPtCorrZ[iCurY][iCurX] = (Short)iDisparity;						
+
+						pcRefCU = pcRefPic->getCU((UInt)(iRefY/pcRefPic->getSlice(0)->getSPS()->getMaxCUHeight()*pcRefPic->getFrameWidthInCU() + iRefX/pcRefPic->getSlice(0)->getSPS()->getMaxCUWidth()));
+
+						m_pppcRefCU[iCurY][iCurX] = pcRefCU;
+						m_ppuicRefPartAddr[iCurY][iCurX] = (UShort)g_auiRasterToZscan[(iRefY-pcRefCU->getCUPelY())/pcRefPic->getMinCUHeight()*pcRefPic->getNumPartInWidth()+(iRefX-pcRefCU->getCUPelX())/pcRefPic->getMinCUWidth()];
+
+						m_ppiTempMvPtCorrX[iRefY][iRefX] = iCurX;
+						m_ppiTempMvPtCorrY[iRefY][iRefX] = iCurY;
+						m_ppiTempMvPtCorrZ[iRefY][iRefX] = (Short)iDepth;
+						//m_ppiTempMvPtCorrZ[iRefY][iRefX] = (Short)iDisparity;
+						
+						//Mark point assigned earlier to this location as occluded:
+						m_ppiMvPtCorrRefViewIdx[iSrcY][iSrcX] = TComMP::OCCLUSION;
+						m_ppiMvPtCorrX[iSrcY][iSrcX] = TComMP::OCCLUSION;
+						m_ppiMvPtCorrY[iSrcY][iSrcX] = TComMP::OCCLUSION;
+
+						//m_ppiMvPtCorrZ[iSrcY][iSrcX] = 0x7FFF;
+						m_ppiMvPtCorrZ[iSrcY][iSrcX] = TComMP::OCCLUSION;						
+
+						m_pppcRefCU[iSrcY][iSrcX] = NULL;
+						m_ppuicRefPartAddr[iSrcY][iSrcX] = 0;						
+					}
+				}
+			}
+	  }
+	}
+	else
+#endif
+	{
 	iSynthViewIdx = uiViewId;
 
@@ -605,4 +764,5 @@
 			}
 	}
+      }
 #endif
 
Index: branches/0.3-poznan-univ/source/Lib/TLibCommon/TComMP.h
===================================================================
--- branches/0.3-poznan-univ/source/Lib/TLibCommon/TComMP.h	(revision 30)
+++ branches/0.3-poznan-univ/source/Lib/TLibCommon/TComMP.h	(revision 41)
@@ -69,4 +69,10 @@
   Short** m_ppiMvPtCorrZ;
   Short** m_ppiMvPtCorrRefViewIdx;
+
+#if !POZNAN_MP_USE_DEPTH_MAP_GENERATION && POZNAN_MP_USE_CURRENT_VIEW_DEPTH_MAP_IF_AVAILABLE
+  Short** m_ppiTempMvPtCorrX;
+  Short** m_ppiTempMvPtCorrY;
+  Short** m_ppiTempMvPtCorrZ;
+#endif
 
   TComDataCU*** m_pppcRefCU; //XY array of pointers to reference CU for each point of picture
@@ -117,4 +123,7 @@
   //Void			init(UInt uiHeight, UInt uiWidth, TAppComCamPara* pcCameraData);
   Void			init(UInt uiHeight, UInt uiWidth, Int**** aiBaseViewShiftLUT);
+#if POZNAN_MP_USE_CURRENT_VIEW_DEPTH_MAP_IF_AVAILABLE
+  Void			clearTemp();
+#endif
 #endif
   Void			uninit();
Index: branches/0.3-poznan-univ/source/Lib/TLibCommon/TComPicYuv.cpp
===================================================================
--- branches/0.3-poznan-univ/source/Lib/TLibCommon/TComPicYuv.cpp	(revision 30)
+++ branches/0.3-poznan-univ/source/Lib/TLibCommon/TComPicYuv.cpp	(revision 41)
@@ -457,8 +457,11 @@
 }
 #if POZNAN_NONLINEAR_DEPTH
-Void TComPicYuv::nonlinearDepthForward(TComPicYuv *pcPicDst, Float p)
-{
-  Int		x,y;
-  TComNonlinearDepthForward cNonlinearDepthFwd(p, g_uiBitIncrement, g_uiBitIncrement);
+Void TComPicYuv::nonlinearDepthForward(TComPicYuv *pcPicDst, TComNonlinearDepthModel &rcNonlinearDepthModel)
+{
+  Int		x,y,i;
+  Int   LUT[256];
+
+  for (i=0; i<256; ++i)
+    LUT[i] = (Int)rcNonlinearDepthModel.ForwardI(i, 1<<g_uiBitIncrement);
 
   // Luma
@@ -469,5 +472,5 @@
     for(x=0; x<m_iPicWidth; x++)
     {
-      pPelDst[x] = (Pel)( cNonlinearDepthFwd(pPelSrc[x]) + 0.5);
+      pPelDst[x] = LUT[RemoveBitIncrement(pPelSrc[x])];
     }
     pPelDst += pcPicDst->getStride();
@@ -478,8 +481,12 @@
   copyToPicCr(pcPicDst);
 }
-Void TComPicYuv::nonlinearDepthBackward(TComPicYuv *pcPicDst, Float p)
-{
-  Int		x,y;
-  TComNonlinearDepthBackward cNonlinearDepthBwd(p, g_uiBitIncrement, g_uiBitIncrement);
+
+Void TComPicYuv::nonlinearDepthBackward(TComPicYuv *pcPicDst, TComNonlinearDepthModel &rcNonlinearDepthModel)
+{
+  Int   x,y,i;
+  Int   LUT[256];
+
+  for (i=255; i>=0; --i)
+    LUT[i] = (Int)rcNonlinearDepthModel.BackwardI(i, 1<<g_uiBitIncrement ); // +0.5;
 
   // Luma
@@ -490,5 +497,5 @@
     for(x=0; x<m_iPicWidth; x++)
     {
-      pPelDst[x] = (Pel)( cNonlinearDepthBwd(pPelSrc[x]) + 0.5);
+      pPelDst[x] = LUT[RemoveBitIncrement(pPelSrc[x])];
     }
     pPelDst += pcPicDst->getStride();
Index: branches/0.3-poznan-univ/source/Lib/TLibCommon/TComPicYuv.h
===================================================================
--- branches/0.3-poznan-univ/source/Lib/TLibCommon/TComPicYuv.h	(revision 30)
+++ branches/0.3-poznan-univ/source/Lib/TLibCommon/TComPicYuv.h	(revision 41)
@@ -44,54 +44,4 @@
 #include "CommonDef.h"
 
-#if POZNAN_NONLINEAR_DEPTH
-
-#include <math.h>
-
-class TComNonlinearDepthForward // OLGIERD - Z-NL-Power conversion
-{
-private:
-  Double m_fMul;
-  Float m_fPower;
-
-public:
-
-  TComNonlinearDepthForward(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;
-  };
-};
-
-class TComNonlinearDepthBackward // OLGIERD - Z-NL-Power conversion
-{
-private:
-  Double m_fMul;
-  Float m_fPower;
-
-public:
-
-  TComNonlinearDepthBackward(Float fPower, Int iInputBitIncrement, Int iOutputBitIncrement) 
-  {     
-    m_fPower = fPower = 1.0/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;
-  };
-};
-#endif
 // ====================================================================================================================
 // Class definition
@@ -226,6 +176,6 @@
 
 #if POZNAN_NONLINEAR_DEPTH
-  Void nonlinearDepthForward(TComPicYuv *pcPicDst, Float p);
-  Void nonlinearDepthBackward(TComPicYuv *pcPicDst, Float p);
+  Void nonlinearDepthForward(TComPicYuv *pcPicDst, TComNonlinearDepthModel &rcNonlinearDepthModel);
+  Void nonlinearDepthBackward(TComPicYuv *pcPicDst, TComNonlinearDepthModel &rcNonlinearDepthModel);
 #endif
 };// END CLASS DEFINITION TComPicYuv
Index: branches/0.3-poznan-univ/source/Lib/TLibCommon/TComPrediction.cpp
===================================================================
--- branches/0.3-poznan-univ/source/Lib/TLibCommon/TComPrediction.cpp	(revision 30)
+++ branches/0.3-poznan-univ/source/Lib/TLibCommon/TComPrediction.cpp	(revision 41)
@@ -1639,4 +1639,9 @@
   TComMv	  mv0_2nd,mv1_2nd;
 
+#if DEPTH_MAP_GENERATION
+  Int		  ref_frame0_idx_1st, ref_frame1_idx_1st;
+  TComMv	  mv0_1st,mv1_1st;
+#endif
+
   Pel* piDstCb;
   Pel* piDstCr;
@@ -1684,4 +1689,11 @@
       iWidth  >>= uiSubSampExpX;
       iHeight >>= uiSubSampExpY;
+
+      //save orginal motion field of CU (it will be overwritten during the motion compensation)
+      ref_frame0_idx_1st = pcCU->getCUMvField(REF_PIC_LIST_0)->getRefIdx(uiPartAddr);
+      mv0_1st = pcCU->getCUMvField( REF_PIC_LIST_0 )->getMv( uiPartAddr );
+
+      ref_frame1_idx_1st = pcCU->getCUMvField(REF_PIC_LIST_1)->getRefIdx(uiPartAddr);
+      mv1_1st = pcCU->getCUMvField( REF_PIC_LIST_1 )->getMv( uiPartAddr );
     }
 #endif
@@ -1804,9 +1816,9 @@
 
 	//set motion data representing CU with DBMP 
+	PartSize ePartSize = pcCU->getPartitionSize( uiPartAddr ); //PartSize ePartSize = pcCU->getPartitionSize( 0 );
 #if DEPTH_MAP_GENERATION
 	if( !bPrdDepthMap )
 #endif
 	{
-		PartSize ePartSize = pcCU->getPartitionSize( uiPartAddr ); //PartSize ePartSize = pcCU->getPartitionSize( 0 );
 #if POZNAN_DBMP_CALC_PRED_DATA
 		pcMP->xCalcDBMPPredData(uiPointCnt, ref_frame0_idx, mv0, ref_frame1_idx, mv1);
@@ -1819,4 +1831,12 @@
 #endif
 	}
+
+#if DEPTH_MAP_GENERATION
+	if( bPrdDepthMap )
+	{
+		pcCU->getCUMvField( REF_PIC_LIST_0 )->setAllMvField( mv0_1st, ref_frame0_idx_1st, ePartSize, uiPartAddr, iPartIdx, 0 );
+		pcCU->getCUMvField( REF_PIC_LIST_1 )->setAllMvField( mv1_1st, ref_frame1_idx_1st, ePartSize, uiPartAddr, iPartIdx, 0 );
+	}
+#endif
 
 	if ( iPartIdxOrg >= 0 ) break;
Index: branches/0.3-poznan-univ/source/Lib/TLibCommon/TComSlice.cpp
===================================================================
--- branches/0.3-poznan-univ/source/Lib/TLibCommon/TComSlice.cpp	(revision 30)
+++ branches/0.3-poznan-univ/source/Lib/TLibCommon/TComSlice.cpp	(revision 41)
@@ -85,4 +85,5 @@
   ::memset( m_aaiCodedOffset, 0x00, sizeof( m_aaiCodedOffset ) );
   m_pcTexturePic = NULL;
+  m_pcDepthPic = NULL; 
 #ifdef WEIGHT_PRED
   resetWpScaling(m_weightPredTable);
@@ -113,4 +114,5 @@
   ::memset( m_aiNumRefIdx,   0, sizeof ( m_aiNumRefIdx ));
   m_pcTexturePic = NULL;
+  m_pcDepthPic = NULL; 
   
   initEqualRef();
@@ -703,4 +705,7 @@
   m_bUseDMM = false;
 #endif
+#if HHI_DMM_PRED_TEX && FLEX_CODING_ORDER
+  m_bUseDMM34 = false;
+#endif
 }
 
@@ -747,5 +752,5 @@
   }
 #if POZNAN_NONLINEAR_DEPTH
-  m_fDepthPower = 1.0;
+  m_cNonlinearDepthModel.Clear();
 #endif
 #if POZNAN_TEXTURE_TU_DELTA_QP_ACCORDING_TO_DEPTH
@@ -768,5 +773,5 @@
   ::memset( m_aaiCodedOffset, 0x00, sizeof( m_aaiCodedOffset ) );
 #if POZNAN_NONLINEAR_DEPTH
-  m_fDepthPower = 1.0;
+  m_cNonlinearDepthModel.Clear();
 #endif
 }
Index: branches/0.3-poznan-univ/source/Lib/TLibCommon/TComSlice.h
===================================================================
--- branches/0.3-poznan-univ/source/Lib/TLibCommon/TComSlice.h	(revision 30)
+++ branches/0.3-poznan-univ/source/Lib/TLibCommon/TComSlice.h	(revision 41)
@@ -139,4 +139,7 @@
   Bool  m_bUseDMM;
 #endif
+#if HHI_DMM_PRED_TEX && FLEX_CODING_ORDER
+  Bool  m_bUseDMM34;
+#endif
 
 #if DEPTH_MAP_GENERATION
@@ -169,5 +172,6 @@
 
 #if POZNAN_NONLINEAR_DEPTH
-  Float  m_fDepthPower;
+  TComNonlinearDepthModel m_cNonlinearDepthModel;   
+  Bool  m_bUseNonlinearDepth;
 #endif
 
@@ -258,5 +262,8 @@
   Void setUseDMM( Bool b ) { m_bUseDMM = b;    }
 #endif
-
+#if HHI_DMM_PRED_TEX && FLEX_CODING_ORDER
+  Bool getUseDMM34()         { return m_bUseDMM34; }
+  Void setUseDMM34( Bool b ) { m_bUseDMM34 = b;    }
+#endif
 
 #if DCM_COMB_LIST
@@ -295,5 +302,5 @@
   Void setUseSAO                  (Bool bVal)  {m_bUseSAO = bVal;}
 #if POZNAN_ENCODE_ONLY_DISOCCLUDED_CU //todo fix SAO
-  Bool getUseSAO     ()         { return (getViewId()>0)?false:m_bUseSAO;}
+  Bool getUseSAO     ()           { return (getUseCUSkip() && getViewId()>0)?false:m_bUseSAO;}
 #else
   Bool getUseSAO                  ()           {return m_bUseSAO;}
@@ -354,8 +361,8 @@
 #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;}
+  inline Void                            setNonlinearDepthModel( TComNonlinearDepthModel &rp ){ m_cNonlinearDepthModel = rp; }
+  inline TComNonlinearDepthModel&        getNonlinearDepthModel()                             { return m_cNonlinearDepthModel; }
+  Bool                    getUseNonlinearDepth()                                              { return m_bUseNonlinearDepth; }
+  Void                    setUseNonlinearDepth( Bool bVal )                                   { m_bUseNonlinearDepth = bVal; }
 #endif
 #if POZNAN_TEXTURE_TU_DELTA_QP_ACCORDING_TO_DEPTH
@@ -459,4 +466,5 @@
   Int         m_iDepth;
   TComPic*    m_pcTexturePic;
+  TComPic*    m_pcDepthPic;
 
   // referenced slice?
@@ -664,5 +672,7 @@
 
   Void setTexturePic( TComPic *pcTexturePic ) { m_pcTexturePic = pcTexturePic; }
+  Void setDepthPic  ( TComPic *pcDepthPic   ) { m_pcDepthPic   = pcDepthPic;   }
   TComPic *getTexturePic() const { return m_pcTexturePic; }
+  TComPic *getDepthPic()   const { return m_pcDepthPic; }
 
 #ifdef WEIGHT_PRED
Index: branches/0.3-poznan-univ/source/Lib/TLibCommon/TypeDef.h
===================================================================
--- branches/0.3-poznan-univ/source/Lib/TLibCommon/TypeDef.h	(revision 30)
+++ branches/0.3-poznan-univ/source/Lib/TLibCommon/TypeDef.h	(revision 41)
@@ -40,6 +40,7 @@
 
 
-
-#define SONY_COLPIC_AVAILABILITY  		  1
+#define FLEX_CODING_ORDER               1
+
+#define SONY_COLPIC_AVAILABILITY        1
 
 //>>>>> HHI 3DV tools >>>>>
@@ -83,6 +84,6 @@
 #define POZNAN_CU_SKIP_PSNR         1 //Poznan Cu Skip Display psnr of the codded CUs only
 
-#define POZNAN_NONLINEAR_DEPTH              1	 /// Non-linear depth processing (Maciej Kurc)
-#define POZNAN_NONLINEAR_DEPTH_SEND_AS_BYTE 1	 /// Send DepthPower as byte instead of float
+#define POZNAN_NONLINEAR_DEPTH              1	 /// Non-linear depth processing
+#define POZNAN_NONLINEAR_DEPTH_THRESHOLD    1  /// Non-linear depth thrasholding
 
 #if POZNAN_SYNTH 
@@ -106,4 +107,8 @@
 										                                                        //			POZNAN_MP_USE_DEPTH_MAP_GENERATION=1 - use DEPTH_MAP_GENERATION, 
 										                                                        //			POZNAN_MP_USE_DEPTH_MAP_GENERATION=0 - use reconstructed depth maps from neighboring views
+
+#if !POZNAN_MP_USE_DEPTH_MAP_GENERATION 
+#define POZNAN_MP_USE_CURRENT_VIEW_DEPTH_MAP_IF_AVAILABLE 1 // Depth-Based Multiview Prediction of CU parameters will use depth picture of current view if this picture is available, otherwise reference view depth is utilized
+#endif
 
 #define POZNAN_MP_FILL                             1    // Depth-Based Multiview Prediction of CU parameters with fill option for occluded areas
@@ -407,5 +412,4 @@
 typedef       unsigned long       ULong;
 typedef       double              Double;
-typedef       float               Float;
 
 // ====================================================================================================================
