Index: branches/0.2-poznan-univ/source/Lib/TLibEncoder/TEncCavlc.cpp
===================================================================
--- branches/0.2-poznan-univ/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 10)
+++ branches/0.2-poznan-univ/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 11)
@@ -353,6 +353,7 @@
         for( UInt uiId = 0; uiId < pcSPS->getViewId(); uiId++ )
         {
-          xWriteSvlc( pcSPS->getCodedScale    ()[ uiId ] );
-          xWriteSvlc( pcSPS->getCodedOffset   ()[ 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->getInvCodedScale ()[ uiId ] + pcSPS->getCodedScale ()[ uiId ] );
           xWriteSvlc( pcSPS->getInvCodedOffset()[ uiId ] + pcSPS->getCodedOffset()[ uiId ] );
@@ -531,6 +532,7 @@
       for( UInt uiId = 0; uiId < pcSlice->getSPS()->getViewId(); uiId++ )
       {
-        xWriteSvlc( pcSlice->getCodedScale    ()[ uiId ] );
-        xWriteSvlc( pcSlice->getCodedOffset   ()[ 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->getInvCodedScale ()[ uiId ] + pcSlice->getCodedScale ()[ uiId ] );
         xWriteSvlc( pcSlice->getInvCodedOffset()[ uiId ] + pcSlice->getCodedOffset()[ uiId ] );
Index: branches/0.2-poznan-univ/source/Lib/TLibEncoder/TEncCu.cpp
===================================================================
--- branches/0.2-poznan-univ/source/Lib/TLibEncoder/TEncCu.cpp	(revision 10)
+++ branches/0.2-poznan-univ/source/Lib/TLibEncoder/TEncCu.cpp	(revision 11)
@@ -67,4 +67,11 @@
   m_ppcOrigYuv     = new TComYuv*[m_uhTotalDepth-1];
   m_ppcResPredTmp  = new TComYuv*[m_uhTotalDepth-1];
+#if POZNAN_AVAIL_MAP
+  m_ppcAvailYuv    = new TComYuv*[m_uhTotalDepth-1];
+#endif
+#if POZNAN_SYNTH_VIEW
+  m_ppcSynthYuv    = new TComYuv*[m_uhTotalDepth-1];
+#endif
+  
 
 #if HHI_MPI
@@ -93,4 +100,12 @@
     m_ppcOrigYuv    [i] = new TComYuv; m_ppcOrigYuv    [i]->create(uiWidth, uiHeight);
 
+#if POZNAN_AVAIL_MAP
+    m_ppcAvailYuv   [i] = new TComYuv; m_ppcAvailYuv    [i]->create(uiWidth, uiHeight);
+#endif
+#if POZNAN_SYNTH_VIEW
+    m_ppcSynthYuv   [i] = new TComYuv; m_ppcSynthYuv    [i]->create(uiWidth, uiHeight);
+#endif
+
+
     m_ppcResPredTmp [i] = new TComYuv; m_ppcResPredTmp [i]->create(uiWidth, uiHeight);
   }
@@ -150,6 +165,18 @@
     if(m_ppcOrigYuv[i])
     {
-      m_ppcOrigYuv[i]->destroy();     delete m_ppcOrigYuv[i];     m_ppcOrigYuv[i] = NULL;
-    }
+      m_ppcOrigYuv[i]->destroy();     delete m_ppcOrigYuv[i];     m_ppcOrigYuv[i]     = NULL;
+    }
+#if POZNAN_AVAIL_MAP
+    if(m_ppcAvailYuv[i])
+    {
+      m_ppcAvailYuv[i]->destroy();    delete m_ppcAvailYuv[i];    m_ppcAvailYuv[i]    = NULL;
+    }
+#endif
+#if POZNAN_SYNTH_VIEW
+    if(m_ppcSynthYuv[i])
+    {
+      m_ppcSynthYuv[i]->destroy();    delete m_ppcSynthYuv[i];    m_ppcSynthYuv[i]    = NULL;
+    }
+#endif
     if(m_ppcResPredTmp[i])
     {
@@ -203,4 +230,18 @@
     m_ppcOrigYuv = NULL;
   }
+#if POZNAN_AVAIL_MAP
+  if(m_ppcAvailYuv)
+  {
+    delete [] m_ppcAvailYuv;
+    m_ppcAvailYuv = NULL;
+  }
+#endif
+#if POZNAN_SYNTH_VIEW
+  if(m_ppcSynthYuv)
+  {
+    delete [] m_ppcSynthYuv;
+    m_ppcSynthYuv = NULL;
+  }
+#endif
   if(m_ppcResPredTmp)
   {
@@ -426,5 +467,39 @@
   // get Original YUV data from picture
   m_ppcOrigYuv[uiDepth]->copyFromPicYuv( pcPic->getPicYuvOrg(), rpcBestCU->getAddr(), rpcBestCU->getZorderIdxInCU() );
-
+#if POZNAN_AVAIL_MAP
+  if (pcPic->getPicYuvAvail())  m_ppcAvailYuv[uiDepth]->copyFromPicYuv( pcPic->getPicYuvAvail(), rpcBestCU->getAddr(), rpcBestCU->getZorderIdxInCU() );
+#endif  
+#if POZNAN_SYNTH_VIEW
+  if (pcPic->getPicYuvSynth())  m_ppcSynthYuv[uiDepth]->copyFromPicYuv( pcPic->getPicYuvSynth(), rpcBestCU->getAddr(), rpcBestCU->getZorderIdxInCU() );
+#endif
+
+#if POZNAN_ENCODE_ONLY_DISOCCLUDED_CU
+  Bool bWholeCUCanBeSynthesized = false;
+  Bool bOneSubCUCanNotBeSynthesied = false;
+  Bool bSubCUCanBeSynthesized[4];
+  Bool * pbSubCUCanBeSynthesized = bSubCUCanBeSynthesized;
+  pcPic->checkSynthesisAvailability(rpcBestCU, rpcBestCU->getAddr(), rpcBestCU->getZorderIdxInCU(), uiDepth, pbSubCUCanBeSynthesized); //KUBA SYNTH
+  Int  iSubCUCanNotBeSynthesized = 0;
+  Int  iSubCUCanBeSynthesizedCnt = 0;
+  for(Int i = 0; i < 4; i++)
+  {
+    if (!bSubCUCanBeSynthesized[i])
+    {
+      iSubCUCanNotBeSynthesized = i;
+    }
+    else
+    {
+      iSubCUCanBeSynthesizedCnt ++;
+    }
+  }
+  if(iSubCUCanBeSynthesizedCnt == 4)
+  {
+    bWholeCUCanBeSynthesized = true;
+  }
+  else if(iSubCUCanBeSynthesizedCnt == 3)
+  {
+    bOneSubCUCanNotBeSynthesied = true;
+  }
+#endif
   // variables for fast encoder decision
   TComDataCU* pcTempCU;
@@ -493,4 +568,158 @@
   if( ( uiRPelX < rpcBestCU->getSlice()->getSPS()->getWidth() ) && ( uiBPelY < rpcBestCU->getSlice()->getSPS()->getHeight() ) )
   {
+    // do CU Skip
+#if POZNAN_ENCODE_ONLY_DISOCCLUDED_CU
+    if(bWholeCUCanBeSynthesized)
+    {
+      rpcBestCU->getTotalCost() = 0;       // Cost of synthesised CU is zero
+      rpcBestCU->getTotalBits() = 0;       // Cost of synthesised CU is zero
+      rpcBestCU->getTotalDistortion() = 0; // Distortion of synthesised CU is zero
+      rpcBestCU->setPredModeSubParts( MODE_SYNTH,      0, uiDepth );
+      rpcBestCU->setPartSizeSubParts( SIZE_2Nx2N,      0, uiDepth );
+#if POZNAN_FILL_OCCLUDED_CU_WITH_SYNTHESIS
+      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
+#endif
+      UInt uiInitTrDepth  = rpcBestCU->getPartitionSize(0) == SIZE_2Nx2N ? 0 : 1;
+      rpcBestCU->copyToPic(uiDepth, 0, uiInitTrDepth); 
+      xCopyYuv2Pic( rpcBestCU->getPic(), rpcBestCU->getAddr(), rpcBestCU->getZorderIdxInCU(), uiDepth );   // Next copy it to reconstruction YUV buffer in coded picture
+      assert( rpcBestCU->getPartitionSize ( 0 ) != SIZE_NONE  ); //Not needed any more ??
+      assert( rpcBestCU->getPredictionMode( 0 ) != MODE_NONE  );
+      assert( rpcBestCU->getTotalCost     (   ) != MAX_DOUBLE );
+
+      #if HHI_VSO//??
+      if( m_pcRdCost->getUseRenModel() )
+      {
+        UInt  uiWidth     = rpcBestCU->getWidth ( 0 );
+        UInt  uiHeight    = rpcBestCU->getHeight( 0 );
+        Pel*  piSrc       = m_ppcRecoYuvBest[uiDepth]->getLumaAddr( 0 );
+        UInt  uiSrcStride = m_ppcRecoYuvBest[uiDepth]->getStride();
+        m_pcRdCost->setRenModelData( rpcBestCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight );
+      }
+      #endif
+      return;
+    }
+    else if (bOneSubCUCanNotBeSynthesied && (uiDepth < g_uiMaxCUDepth - g_uiAddCUDepth )) // If only one from subCU can not be synthesised than force NxN split but donot signal it in the stream
+    {
+      //printf("CUSkip - OneCanNotBe %d %d %d\n",rpcBestCU->getCUPelX(),rpcBestCU->getCUPelY(),rpcBestCU->getWidth());
+      // further split !!!!go to line 866!!!
+#if HHI_VSO
+    // reset Model
+    if( m_pcRdCost->getUseRenModel() )
+    {
+      UInt  uiWidth     = m_ppcBestCU[uiDepth]->getWidth ( 0 );
+      UInt  uiHeight    = m_ppcBestCU[uiDepth]->getHeight( 0 );
+      Pel*  piSrc       = m_ppcOrigYuv[uiDepth]->getLumaAddr( 0 );
+      UInt  uiSrcStride = m_ppcOrigYuv[uiDepth]->getStride();
+      m_pcRdCost->setRenModelData( m_ppcBestCU[uiDepth], 0, piSrc, uiSrcStride, uiWidth, uiHeight );
+    }
+#endif
+
+      UChar       uhNextDepth         = uiDepth + 1;
+      TComDataCU* pcSubBestPartCU     = m_ppcBestCU[uhNextDepth];
+      TComDataCU* pcSubTempPartCU     = m_ppcTempCU[uhNextDepth];
+      
+      for ( UInt uiPartUnitIdx = 0; uiPartUnitIdx < 4; uiPartUnitIdx++ ) //UInt uiPartUnitIdx = iSubCUNotSynthesied;
+      {
+        pcSubBestPartCU->initSubCU( rpcBestCU, uiPartUnitIdx, uhNextDepth );           // clear sub partition datas or init.
+        pcSubTempPartCU->initSubCU( rpcBestCU, uiPartUnitIdx, uhNextDepth );           // clear sub partition datas or init.
+//        pcSubBestPartCU->setLastCodedQP( rpcBestCU->getLastCodedQP() );
+//        pcSubTempPartCU->setLastCodedQP( rpcBestCU->getLastCodedQP() );
+        
+        if( ( pcSubBestPartCU->getCUPelX() < pcSubBestPartCU->getSlice()->getSPS()->getWidth() ) && ( pcSubBestPartCU->getCUPelY() < pcSubBestPartCU->getSlice()->getSPS()->getHeight() ) )
+        {
+          if( m_bUseSBACRD )
+          {
+            if ( 0 == uiPartUnitIdx) //initialize RD with previous depth buffer
+            {
+              m_pppcRDSbacCoder[uhNextDepth][CI_CURR_BEST]->load(m_pppcRDSbacCoder[uiDepth][CI_CURR_BEST]);
+            }
+            else
+            {
+              m_pppcRDSbacCoder[uhNextDepth][CI_CURR_BEST]->load(m_pppcRDSbacCoder[uhNextDepth][CI_NEXT_BEST]);
+            }
+          }
+          
+          xCompressCU( pcSubBestPartCU, pcSubTempPartCU, uhNextDepth ); //Compress SubCU's
+          
+#if HHI_VSO
+          if( m_pcRdCost->getUseRenModel() )
+          {
+            UInt  uiWidth     = pcSubBestPartCU->getWidth ( 0 );
+            UInt  uiHeight    = pcSubBestPartCU->getHeight( 0 );
+            Pel*  piSrc       = m_ppcRecoYuvBest[pcSubBestPartCU->getDepth(0)]->getLumaAddr( 0 );
+            UInt  uiSrcStride = m_ppcRecoYuvBest[pcSubBestPartCU->getDepth(0)]->getStride();
+            m_pcRdCost->setRenModelData( pcSubBestPartCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight );
+          }
+#endif
+          rpcTempCU->copyPartFrom( pcSubBestPartCU, uiPartUnitIdx, uhNextDepth );         // Keep best part data to current temporary data.
+          xCopyYuv2Tmp( pcSubBestPartCU->getTotalNumPart()*uiPartUnitIdx, uhNextDepth );
+        }
+      }
+
+      if( !bBoundary )
+      {
+        m_pcEntropyCoder->resetBits();
+        m_pcEntropyCoder->encodeSplitFlag( rpcTempCU, 0, uiDepth, true );
+
+        rpcTempCU->getTotalBits() += m_pcEntropyCoder->getNumberOfWrittenBits(); // split bits
+      }
+
+#if HHI_INTERVIEW_SKIP_LAMBDA_SCALE
+      if( bFullyRenderedSec )
+      {
+        m_pcRdCost->setLambdaScale( m_pcEncCfg->getInterViewSkipLambdaScale() );
+      }
+      else
+      {
+        m_pcRdCost->setLambdaScale( 1 );
+      }
+#endif
+#if HHI_VSO
+      if ( m_pcRdCost->getUseLambdaScaleVSO())
+      {
+        rpcTempCU->getTotalCost()  = m_pcRdCost->calcRdCostVSO( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() );
+      }
+      else
+#endif
+      {
+        rpcTempCU->getTotalCost()  = m_pcRdCost->calcRdCost( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() );
+      }    
+
+      if( m_bUseSBACRD )
+      {
+        m_pppcRDSbacCoder[uhNextDepth][CI_NEXT_BEST]->store(m_pppcRDSbacCoder[uiDepth][CI_TEMP_BEST]);
+      }
+      //Copy Tmp to Best
+      xCheckBestMode( rpcBestCU, rpcTempCU, uiDepth );  //Roznica z naszym koder                                          // RD compare current larger prediction
+
+#if HHI_VSO
+      if( m_pcRdCost->getUseRenModel() )
+      {
+        UInt  uiWidth     = rpcBestCU->getWidth ( 0 );
+        UInt  uiHeight    = rpcBestCU->getHeight( 0 );
+        Pel*  piSrc       = m_ppcRecoYuvBest[uiDepth]->getLumaAddr( 0 );
+        UInt  uiSrcStride = m_ppcRecoYuvBest[uiDepth]->getStride();
+        m_pcRdCost->setRenModelData( rpcBestCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight );
+      }
+#endif
+      //Copy result to pic
+      rpcBestCU->copyToPic(uiDepth);                                                     // Copy Best data to Picture for next partition prediction.
+      
+      if( bBoundary )
+        return;
+
+      xCopyYuv2Pic( rpcBestCU->getPic(), rpcBestCU->getAddr(), rpcBestCU->getZorderIdxInCU(), uiDepth );   // Copy Yuv data to picture Yuv
+      
+      // Assert if Best prediction mode is NONE
+      // Selected mode's RD-cost must be not MAX_DOUBLE.
+      assert( rpcBestCU->getPartitionSize ( 0 ) != SIZE_NONE  ); //Not needed any more?
+      assert( rpcBestCU->getPredictionMode( 0 ) != MODE_NONE  );
+      assert( rpcBestCU->getTotalCost     (   ) != MAX_DOUBLE );
+      return;
+    }
+#endif
+
     // do inter modes
     if( rpcBestCU->getSlice()->getSliceType() != I_SLICE )
@@ -836,4 +1065,9 @@
   TComPic* pcPic = pcCU->getPic();
 
+#if POZNAN_ENCODE_ONLY_DISOCCLUDED_CU
+  if( pcCU->isCUSkiped( uiAbsPartIdx ) && uiDepth == pcCU->getDepth( uiAbsPartIdx )) //If CU Skiped no information is coded into stream
+    return;
+#endif
+
   Bool bBoundary = false;
   UInt uiLPelX   = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ];
@@ -842,6 +1076,30 @@
   UInt uiBPelY   = uiTPelY + (g_uiMaxCUHeight>>uiDepth) - 1;
 
+#if POZNAN_ENCODE_ONLY_DISOCCLUDED_CU
+  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
+  {
+    UInt uiQNumParts = ( pcPic->getNumPartInCU() >> (uiDepth<<1) )>>2;
+    Int iCUSkipCounter = 0;
+    UInt uiAbsPartIdxTmp = uiAbsPartIdx;
+    for ( UInt uiPartUnitIdx = 0; uiPartUnitIdx < 4; uiPartUnitIdx++, uiAbsPartIdxTmp+=uiQNumParts )
+    {
+      if(pcCU->isCUSkiped(uiAbsPartIdxTmp) && (pcCU->getDepth( uiAbsPartIdxTmp ) == uiDepth + 1) )
+      {
+        iCUSkipCounter++;
+      }
+    } 
+    if(iCUSkipCounter == 3)
+    {
+      bDontSendSplitFlag = true;
+    }
+  }
+#endif
+
   if( ( uiRPelX < pcCU->getSlice()->getSPS()->getWidth() ) && ( uiBPelY < pcCU->getSlice()->getSPS()->getHeight() ) )
   {
+#if POZNAN_ENCODE_ONLY_DISOCCLUDED_CU
+    if(!bDontSendSplitFlag)
+#endif
 #if HHI_MPI
     if( pcCU->getTextureModeDepth( uiAbsPartIdx ) == -1 || uiDepth < pcCU->getTextureModeDepth( uiAbsPartIdx ) )
@@ -1412,5 +1670,9 @@
     for( UInt ui = 0; ui < rpcTempCU->getTotalNumPart(); ui++ )
     {
-      if( pcTextureCU->isIntra( rpcTempCU->getZorderIdxInCU() + ui ) )
+      if( pcTextureCU->isIntra( rpcTempCU->getZorderIdxInCU() + ui ) 
+#if POZNAN_ENCODE_ONLY_DISOCCLUDED_CU
+        || pcTextureCU->isCUSkiped( rpcTempCU->getZorderIdxInCU() + ui )
+#endif
+      )
       {
         return;
Index: branches/0.2-poznan-univ/source/Lib/TLibEncoder/TEncCu.h
===================================================================
--- branches/0.2-poznan-univ/source/Lib/TLibEncoder/TEncCu.h	(revision 10)
+++ branches/0.2-poznan-univ/source/Lib/TLibEncoder/TEncCu.h	(revision 11)
@@ -78,5 +78,11 @@
   TComYuv**               m_ppcOrigYuv;     ///< Original Yuv for each depth
   TComYuv**               m_ppcResPredTmp;  ///< Temporary residual prediction for each depth
-  
+#if POZNAN_AVAIL_MAP
+  TComYuv**               m_ppcAvailYuv;    ///< Avaiability map for each depth  
+#endif
+#if POZNAN_SYNTH_VIEW
+  TComYuv**               m_ppcSynthYuv;    ///< Synthetized Yuv for each depth
+#endif
+
   //  Data : encoder control
   Int                     m_iQp;            ///< Last QP
Index: branches/0.2-poznan-univ/source/Lib/TLibEncoder/TEncGOP.cpp
===================================================================
--- branches/0.2-poznan-univ/source/Lib/TLibEncoder/TEncGOP.cpp	(revision 10)
+++ branches/0.2-poznan-univ/source/Lib/TLibEncoder/TEncGOP.cpp	(revision 11)
@@ -799,4 +799,10 @@
   Pel*  pOrg    = pcPic ->getPicYuvOrg()->getLumaAddr();
   Pel*  pRec    = pcPicD->getLumaAddr();
+#if POZNAN_CU_SKIP_PSNR
+  Pel*  pAvail  = NULL;
+  if(pcPic ->getPicYuvAvail())
+    pAvail  = pcPic ->getPicYuvAvail()->getLumaAddr();
+  UInt64 iPixelsCnt = 0;
+#endif
   Int   iStride = pcPicD->getStride();
 
@@ -813,13 +819,38 @@
   Double fRefValueC = fRefValueY / 4.0;
 
-  for( y = 0; y < iHeight; y++ )
-  {
-    for( x = 0; x < iWidth; x++ )
-    {
-      Int iDiff = (Int)( pOrg[x] - pRec[x] );
-      uiSSDY   += iDiff * iDiff;
-    }
-    pOrg += iStride;
-    pRec += iStride;
+#if POZNAN_CU_SKIP_PSNR
+  if(pAvail)
+  {
+    for( y = 0; y < iHeight; y++ )
+    {
+      for( x = 0; x < iWidth; x++ )
+      {
+        if(pAvail[x]==0) //If pixel was codded
+        {
+          Int iDiff = (Int)( pOrg[x] - pRec[x] );
+          uiSSDY   += iDiff * iDiff;
+          iPixelsCnt++;
+        }
+      }
+      pOrg += iStride;
+      pRec += iStride;
+      pAvail+=iStride;
+    }
+    
+    fRefValueY = (double) maxval * maxval * iPixelsCnt;
+  }
+  else
+#endif
+  {
+    for( y = 0; y < iHeight; y++ )
+    {
+      for( x = 0; x < iWidth; x++ )
+      {
+        Int iDiff = (Int)( pOrg[x] - pRec[x] );
+        uiSSDY   += iDiff * iDiff;
+      }
+      pOrg += iStride;
+      pRec += iStride;
+    }
   }
 
@@ -837,37 +868,93 @@
 #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 );
+#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++ )
+        {
+          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/TEncTop.cpp
===================================================================
--- branches/0.2-poznan-univ/source/Lib/TLibEncoder/TEncTop.cpp	(revision 10)
+++ branches/0.2-poznan-univ/source/Lib/TLibEncoder/TEncTop.cpp	(revision 11)
@@ -416,4 +416,10 @@
   {
     pcPic->removeOriginalBuffer   ();
+#if POZNAN_AVAIL_MAP
+    pcPic->removeAvailabilityBuffer();
+#endif
+#if POZNAN_SYNTH_VIEW
+    pcPic->removeSynthesisBuffer();
+#endif
 #if HHI_INTER_VIEW_MOTION_PRED
     pcPic->removeOrgDepthMapBuffer();
