Changeset 41 in 3DVCSoftware for branches/0.3-poznan-univ/source/Lib/TLibCommon


Ignore:
Timestamp:
26 Mar 2012, 09:03:21 (13 years ago)
Author:
poznan-univ
Message:

Adjustment for FlexCO, and high-level syntax improvement.

Location:
branches/0.3-poznan-univ/source/Lib/TLibCommon
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • branches/0.3-poznan-univ/source/Lib/TLibCommon/CommonDef.h

    r28 r41  
    144144#endif
    145145
    146 #if POZNAN_NONLINEAR_DEPTH
    147 #define POZNAN_LUT_INCREASED_PRECISION 0 // 1 //to do
    148 #else
    149 #define POZNAN_LUT_INCREASED_PRECISION 0
    150 #endif
    151 
    152146//>>>>> generation and usage of virtual prediction depth maps >>>>>
    153147#define PDM_ONE_DEPTH_PER_PU              1         // use only a single depth for a prediction unit (in update)
     
    192186#endif
    193187
    194 #if POZNAN_NONLINEAR_DEPTH
    195 inline UChar quantizeDepthPower(Float fDepthPower)
    196 {
    197   Int r = (Int) ( (fDepthPower-1.0f)*128.0f + 0.5f);
    198   if (r<=0) return 0;
    199   if (r>255) r=255; 
    200   return r;
    201 };
    202 
    203 inline Float dequantizeDepthPower(Int iDepthQuant)
    204 {
    205   return iDepthQuant/128.0f + 1.0f; 
    206 };
    207 #endif
    208 
    209188// ====================================================================================================================
    210189// Macro functions
     
    218197#define RemoveBitIncrement(x)       ( ((x) + ( (1 << g_uiBitIncrement) >> 1 )) >> g_uiBitIncrement )     ///< Remove Bit increment
    219198
    220 #if POZNAN_LUT_INCREASED_PRECISION
    221 #define RemoveBitIncrementLUT(x)       (x)     ///< Remove Bit increment
    222 #define SizeOfLUT                      (256 << g_uiBitIncrement) 
    223 #else
    224199#define SizeOfLUT                      256
    225 #define RemoveBitIncrementLUT(x)       ( ((x) + ( (1 << g_uiBitIncrement) >> 1 )) >> g_uiBitIncrement )     ///< Remove Bit increment
    226 #endif
    227200
    228201#define DATA_ALIGN                  1                                                                 ///< use 32-bit aligned malloc/free
     
    665638
    666639
     640#if POZNAN_NONLINEAR_DEPTH
     641struct TComNonlinearDepthModel // // OS: cannot be stdarray, due to memcpy done on SlicePilot
     642{
     643  Int m_aiPoints[257];
     644  Int m_iNum;
     645
     646  Int m_aiX[257];
     647  Int m_aiY[257];
     648
     649  Void Clear() { m_iNum=0; m_aiPoints[0]=0; m_aiPoints[1]=0; };
     650  Void Init()
     651  {
     652    for (Int k=m_iNum+1; k>=0; --k)
     653    {
     654      int q = 255*k/(m_iNum+1);
     655      m_aiX[k] = q + m_aiPoints[k];
     656      m_aiY[k] = q - m_aiPoints[k];
     657    }
     658  };
     659
     660  Double xInterpolateD(Int *aiX,Int *aiY, Double x, Double dScale)
     661  {
     662    Int x1 = 0;
     663    Int x2 = m_iNum+1;
     664
     665    for (;;)
     666    {
     667      if (x1+1>=x2)
     668        return ((x-aiX[x1])*(aiY[x2]-aiY[x1])/(aiX[x2]-aiX[x1]) + aiY[x1])*dScale;
     669      Int xm = (x1+x2)>>1;
     670      if (x >= aiX[xm]) x1 = xm;
     671      else              x2 = xm;
     672    }
     673  }
     674
     675  inline Double ForwardD(Double x,  Double dScale) { return xInterpolateD(m_aiX, m_aiY, x, dScale); }
     676  inline Double BackwardD(Double x, Double dScale) { return xInterpolateD(m_aiY, m_aiX, x, dScale); }
     677
     678  Int64 xInterpolateI(Int *aiX,Int *aiY, Int x, Int64 iScale)
     679  {
     680    Int x1 = 0;
     681    Int x2 = m_iNum+1;
     682
     683    for (;;)
     684    {
     685      if (x1+1>=x2)
     686      {         
     687        Int aiXx2x1 = (aiX[x2]-aiX[x1]);
     688        Int64 res = (x-aiX[x1])*(aiY[x2]-aiY[x1])*iScale;
     689        if (res>0) return (res + (aiXx2x1>>1) )/aiXx2x1 + aiY[x1]*iScale;
     690        else       return (res - (aiXx2x1>>1) )/aiXx2x1 + aiY[x1]*iScale;
     691      }
     692      Int xm = (x1+x2)>>1;
     693      if (x >= aiX[xm]) x1 = xm;
     694      else              x2 = xm;
     695    }
     696  }
     697
     698  inline Int64  ForwardI (Int x, Int64 iScale) { return xInterpolateI(m_aiX, m_aiY, x, iScale); }
     699  inline Int64  BackwardI(Int x, Int64 iScale) { return xInterpolateI(m_aiY, m_aiX, x, iScale); }
     700
     701};
     702#endif
     703
    667704#endif // end of #ifndef  __COMMONDEF__
    668705
  • branches/0.3-poznan-univ/source/Lib/TLibCommon/TComDataCU.cpp

    r30 r41  
    50045004    exit(333);
    50055005  }
    5006   Float fVal = (Float)((255 - (uiBlockMax >> g_uiBitIncrement)) >> 4);
     5006  Double fVal = (Double)((255 - (uiBlockMax >> g_uiBitIncrement)) >> 4); //Owieczka ?? ToDo Convert Double to Int
    50075007  fVal = (fVal * fVal);
    50085008#if POZNAN_TEXTURE_TU_DELTA_QP_PARAM_IN_CFG_FOR_ENC
    5009   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
    5010   fVal = (Float)( fVal * getPic()->getTexDqpAccordingToDepthMul()); //
     5009  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
     5010  fVal = (Double)( fVal * getPic()->getTexDqpAccordingToDepthMul()); //
    50115011#else
    5012   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
    5013   fVal = (Float)( fVal * POZNAN_TEXTURE_TU_DELTA_QP_MUL); //
     5012  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
     5013  fVal = (Double)( fVal * POZNAN_TEXTURE_TU_DELTA_QP_MUL); //
    50145014#endif
    50155015  return (Int)fVal >> 5;
     
    50345034   UInt iCuAddr = getAddr();
    50355035   //TComPic * pcDepthPic = getPic()->getDepthPic();
     5036#if FLEX_CODING_ORDER
     5037   TComPicYuv * pcDepthPicYUV = NULL;
     5038   // if depth map reconstruction picture is available use it Use synthesis picture otherwise.
     5039   if(getPic()->getSlice(0)->getDepthPic() != NULL && getPic()->getSlice(0)->getDepthPic()->getReconMark())
     5040   {
     5041     pcDepthPicYUV = getPic()->getSlice(0)->getDepthPic()->getPicYuvRec();
     5042   }
     5043   else
     5044   {
     5045      pcDepthPicYUV = getPic()->getPicYuvSynthDepth();
     5046   }
     5047#else
    50365048   TComPicYuv * pcDepthPicYUV = getPic()->getPicYuvSynthDepth();
     5049#endif
    50375050   if(pcDepthPicYUV /*pcDepthPic*/ == NULL)
    50385051   {
     
    50555068   }
    50565069#if POZNAN_NONLINEAR_DEPTH
    5057    TComNonlinearDepthBackward cNonlinearDepthBwd(getSlice()->getSPS()->getDepthPower(), g_uiBitIncrement, g_uiBitIncrement);
    5058    uiDepthLumaTransformBlockMax = (Pel)( cNonlinearDepthBwd(uiDepthLumaTransformBlockMax) + 0.5);
     5070   if( getSlice()->getSPS()->getUseNonlinearDepth() )
     5071    uiDepthLumaTransformBlockMax = (Pel)( getSlice()->getSPS()->getNonlinearDepthModel().BackwardI(RemoveBitIncrement(uiDepthLumaTransformBlockMax), 1<<g_uiBitIncrement ) ) ;
    50595072#endif
    50605073   Int iDeltaQP = CuQpIncrementFunction(uiDepthLumaTransformBlockMax);
  • branches/0.3-poznan-univ/source/Lib/TLibCommon/TComMP.cpp

    r28 r41  
    4444        //m_pcCameraData = NULL;
    4545        m_aiBaseViewShiftLUT = NULL;
     46#if POZNAN_MP_USE_CURRENT_VIEW_DEPTH_MAP_IF_AVAILABLE
     47  m_ppiTempMvPtCorrX = NULL;
     48  m_ppiTempMvPtCorrY = NULL;
     49  m_ppiTempMvPtCorrZ = NULL;
     50#endif
    4651#endif
    4752
     
    96101#endif
    97102
    98 /*
    99         m_ppiMvPtCorrX = new Short*[m_uiHeight];
    100         m_ppiMvPtCorrY = new Short*[m_uiHeight];
    101         m_ppiMvPtCorrZ = new Short*[m_uiHeight];
    102         m_ppiMvPtCorrRefViewIdx = new Short*[m_uiHeight];
    103         m_pppcRefCU = new TComDataCU**[m_uiHeight];
    104         m_ppuicRefPartAddr = new UShort*[m_uiHeight];   
    105         for(Int i=0;i<m_uiHeight;i++)
    106         {
    107                 m_ppiMvPtCorrX[i] = new Short[m_uiWidth];
    108                 m_ppiMvPtCorrY[i] = new Short[m_uiWidth];
    109                 m_ppiMvPtCorrZ[i] = new Short[m_uiWidth];
    110                 m_ppiMvPtCorrRefViewIdx[i] = new Short[m_uiWidth];
    111                 m_pppcRefCU[i] = new TComDataCU*[m_uiWidth];
    112                 m_ppuicRefPartAddr[i]  = new UShort[m_uiWidth];
    113         }
    114 //*/
    115 ///*
    116103        Short* piPtr;
    117104        UShort* puiPtr;
     
    141128        puiPtr = (UShort*)malloc(sizeof(UShort)*m_uiHeight*m_uiWidth);
    142129        for(UInt i=0,addr=0;i<m_uiHeight;i++,addr+=m_uiWidth) m_ppuicRefPartAddr[i] = &(puiPtr[addr]);
    143 //*/
     130
     131#if !POZNAN_MP_USE_DEPTH_MAP_GENERATION && POZNAN_MP_USE_CURRENT_VIEW_DEPTH_MAP_IF_AVAILABLE
     132        m_ppiTempMvPtCorrX = (Short**)malloc(sizeof(Short*)*m_uiHeight);
     133        piPtr = (Short*)malloc(sizeof(Short)*m_uiHeight*m_uiWidth);
     134        for(UInt i=0,addr=0;i<m_uiHeight;i++,addr+=m_uiWidth) m_ppiTempMvPtCorrX[i] = &(piPtr[addr]);
     135
     136        m_ppiTempMvPtCorrY = (Short**)malloc(sizeof(Short*)*m_uiHeight);
     137        piPtr = (Short*)malloc(sizeof(Short)*m_uiHeight*m_uiWidth);
     138        for(UInt i=0,addr=0;i<m_uiHeight;i++,addr+=m_uiWidth) m_ppiTempMvPtCorrY[i] = &(piPtr[addr]);
     139
     140        m_ppiTempMvPtCorrZ = (Short**)malloc(sizeof(Short*)*m_uiHeight);
     141        piPtr = (Short*)malloc(sizeof(Short)*m_uiHeight*m_uiWidth);
     142        for(UInt i=0,addr=0;i<m_uiHeight;i++,addr+=m_uiWidth) m_ppiTempMvPtCorrZ[i] = &(piPtr[addr]);
     143#endif
     144
    144145#if POZNAN_DBMP & !POZNAN_DBMP_COMPRESS_ME_DATA
    145146        m_ppiL0RefPOC.clear();
     
    303304        }
    304305
     306#if !POZNAN_MP_USE_DEPTH_MAP_GENERATION && POZNAN_MP_USE_CURRENT_VIEW_DEPTH_MAP_IF_AVAILABLE
     307        if(m_ppiTempMvPtCorrX!=NULL)
     308        {
     309                //for(Int i=0;i<m_uiHeight;i++) delete [] m_ppiTempMvPtCorrX[i];
     310                //delete [] m_ppiTempMvPtCorrX;
     311                free(m_ppiTempMvPtCorrX[0]);
     312                free(m_ppiTempMvPtCorrX);
     313                m_ppiTempMvPtCorrX = NULL;
     314        }
     315
     316        if(m_ppiTempMvPtCorrY!=NULL)
     317        {
     318                //for(Int i=0;i<m_uiHeight;i++) delete [] m_ppiTempMvPtCorrY[i];
     319                //delete [] m_ppiTempMvPtCorrY;
     320                free(m_ppiTempMvPtCorrY[0]);
     321                free(m_ppiTempMvPtCorrY);
     322                m_ppiTempMvPtCorrY = NULL;
     323        }
     324
     325        if(m_ppiTempMvPtCorrZ!=NULL)
     326        {
     327                //for(Int i=0;i<m_uiHeight;i++) delete [] m_ppiTempMvPtCorrZ[i];
     328                //delete [] m_ppiTempMvPtCorrZ;
     329                free(m_ppiTempMvPtCorrZ[0]);
     330                free(m_ppiTempMvPtCorrZ);
     331                m_ppiTempMvPtCorrZ = NULL;
     332        }
     333
     334#endif
     335
    305336#if POZNAN_DBMP & !POZNAN_DBMP_COMPRESS_ME_DATA
    306337        PUT_MP_ARRAY_TYPE** ppiTemp;
     
    439470}
    440471
     472#if !POZNAN_MP_USE_DEPTH_MAP_GENERATION && POZNAN_MP_USE_CURRENT_VIEW_DEPTH_MAP_IF_AVAILABLE
     473Void TComMP::clearTemp()
     474{
     475        if(!isInit()) return;
     476
     477        for(Int i=0;i<m_uiHeight;i++)
     478                for(Int j=0;j<m_uiWidth;j++)
     479                {
     480                        m_ppiTempMvPtCorrX[i][j] = TComMP::OCCLUSION;
     481                        m_ppiTempMvPtCorrY[i][j] = TComMP::OCCLUSION;
     482                        //m_ppiTempMvPtCorrZ[i][j] = 0x7FFF; //Depth
     483                        m_ppiTempMvPtCorrZ[i][j] = TComMP::OCCLUSION; //Disparity
     484                }
     485}
     486#endif
     487
    441488Bool TComMP::isInit()
    442489{
     
    498545        //Bool bIsLeft;
    499546        Int  iDepth;
     547#if POZNAN_MP_USE_CURRENT_VIEW_DEPTH_MAP_IF_AVAILABLE
     548        Int iSrcX, iSrcY;
     549#endif 
    500550#endif 
    501551
     
    547597        }
    548598#else
     599
     600#if POZNAN_MP_USE_CURRENT_VIEW_DEPTH_MAP_IF_AVAILABLE
     601        //pcDepthPic = GetPicFromList(m_pcDepthRefPicsList, uiPOC, uiViewId);
     602        if(pcPic->getSlice(0)->getDepthPic()!=NULL && pcPic->getSlice(0)->getDepthPic()->getReconMark())
     603                pcDepthPic = pcPic->getSlice(0)->getDepthPic();
     604        else
     605                pcDepthPic = NULL;
     606
     607        if(pcDepthPic!=NULL)
     608        {
     609          pDepth = pcDepthPic->getPicYuvRec()->getLumaAddr();
     610          iStride = pcDepthPic->getPicYuvRec()->getStride();
     611
     612          for( UInt uiIdx = 0; uiIdx < uiViewId; uiIdx++ )
     613          //for( UInt uiIdx = uiViewId-1; uiIdx >= uiViewId; uiIdx-- )
     614          {
     615            uiRefViewId = uiIdx;
     616
     617                pcRefPic = GetPicFromList(m_pcRefPicsList, uiPOC, uiRefViewId);
     618                assert(pcRefPic!=NULL);//test
     619                if(pcRefPic==NULL) return false; //No ref pic with current POC and RefView found in ref list!!!
     620
     621                if(!pcRefPic->getSlice(0)->isIntra()) bIsRefNoISliceAvailable = true;
     622                else bIsAnchorPicture = true;
     623
     624                //ppiShiftLUTLeft = m_pcCameraData->getBaseViewShiftLUTI()[uiViewId][uiRefViewId];
     625                ppiShiftLUTLeft = m_aiBaseViewShiftLUT[uiViewId][uiRefViewId];
     626
     627                clearTemp();
     628
     629                for(iCurY=0; iCurY<(Int)m_uiHeight; iCurY++)
     630                        for(iCurX=0; iCurX<(Int)m_uiWidth; iCurX++)
     631                        {
     632                                //Check if point already has its reference:
     633                                if(m_ppiMvPtCorrX[iCurY][iCurX]!=TComMP::OCCLUSION && m_ppiMvPtCorrY[iCurY][iCurX]!=TComMP::OCCLUSION) continue;
     634
     635                                iDepth = pDepth[ iCurX + iCurY * iStride ];
     636                                iDepth = RemoveBitIncrement(iDepth);
     637                                assert( iDepth >= 0 && iDepth <= 256 );                                 
     638                               
     639                                //if(bIsLeft) iDisparity = ppiShiftLUTLeft[0][iDepth];
     640                                //else iDisparity = -ppiShiftLUTLeft[0][iDepth];
     641                                iDisparity = ppiShiftLUTLeft[0][iDepth]; //!!!
     642
     643                                iRefX = iCurX - ( ( iDisparity + 2 ) >> 2 );
     644                                iRefY = iCurY;
     645
     646                                if(iRefX>=0 && iRefX<m_uiWidth && iRefY>=0 && iRefY<m_uiHeight)
     647                                {
     648                                        iSrcX = m_ppiTempMvPtCorrX[iRefY][iRefX];
     649                                        iSrcY = m_ppiTempMvPtCorrY[iRefY][iRefX];
     650
     651                                        if(iSrcX==TComMP::OCCLUSION || iSrcY==TComMP::OCCLUSION)
     652                                        {
     653                                                m_ppiMvPtCorrRefViewIdx[iCurY][iCurX] = (Short)uiRefViewId;
     654                                                m_ppiMvPtCorrX[iCurY][iCurX] = (Short)iRefX;
     655                                                m_ppiMvPtCorrY[iCurY][iCurX] = (Short)iRefY;
     656
     657                                                m_ppiMvPtCorrZ[iCurY][iCurX] = (Short)iDepth;
     658                                                //m_ppiMvPtCorrZ[iCurY][iCurX] = (Short)iDisparity;                                             
     659
     660                                                pcRefCU = pcRefPic->getCU((UInt)(iRefY/pcRefPic->getSlice(0)->getSPS()->getMaxCUHeight()*pcRefPic->getFrameWidthInCU() + iRefX/pcRefPic->getSlice(0)->getSPS()->getMaxCUWidth()));
     661
     662                                                m_pppcRefCU[iCurY][iCurX] = pcRefCU;
     663                                                m_ppuicRefPartAddr[iCurY][iCurX] = (UShort)g_auiRasterToZscan[(iRefY-pcRefCU->getCUPelY())/pcRefPic->getMinCUHeight()*pcRefPic->getNumPartInWidth()+(iRefX-pcRefCU->getCUPelX())/pcRefPic->getMinCUWidth()];
     664
     665                                                m_ppiTempMvPtCorrX[iRefY][iRefX] = iCurX;
     666                                                m_ppiTempMvPtCorrY[iRefY][iRefX] = iCurY;
     667                                                m_ppiTempMvPtCorrZ[iRefY][iRefX] = (Short)iDepth;
     668                                                //m_ppiTempMvPtCorrZ[iRefY][iRefX] = (Short)iDisparity;
     669                                        }
     670                                        else if((Short)iDepth>m_ppiTempMvPtCorrZ[iRefY][iRefX]) //Point assigned earlier to this location is occluded
     671                                        //else if((Short)iDisparity>m_ppiTempMvPtCorrZ[iRefY][iRefX]) //Point assigned earlier to this location is occluded
     672                                        {
     673                                                m_ppiMvPtCorrRefViewIdx[iCurY][iCurX] = (Short)uiRefViewId;
     674                                                m_ppiMvPtCorrX[iCurY][iCurX] = (Short)iRefX;
     675                                                m_ppiMvPtCorrY[iCurY][iCurX] = (Short)iRefY;
     676
     677                                                m_ppiMvPtCorrZ[iCurY][iCurX] = (Short)iDepth;
     678                                                //m_ppiMvPtCorrZ[iCurY][iCurX] = (Short)iDisparity;                                             
     679
     680                                                pcRefCU = pcRefPic->getCU((UInt)(iRefY/pcRefPic->getSlice(0)->getSPS()->getMaxCUHeight()*pcRefPic->getFrameWidthInCU() + iRefX/pcRefPic->getSlice(0)->getSPS()->getMaxCUWidth()));
     681
     682                                                m_pppcRefCU[iCurY][iCurX] = pcRefCU;
     683                                                m_ppuicRefPartAddr[iCurY][iCurX] = (UShort)g_auiRasterToZscan[(iRefY-pcRefCU->getCUPelY())/pcRefPic->getMinCUHeight()*pcRefPic->getNumPartInWidth()+(iRefX-pcRefCU->getCUPelX())/pcRefPic->getMinCUWidth()];
     684
     685                                                m_ppiTempMvPtCorrX[iRefY][iRefX] = iCurX;
     686                                                m_ppiTempMvPtCorrY[iRefY][iRefX] = iCurY;
     687                                                m_ppiTempMvPtCorrZ[iRefY][iRefX] = (Short)iDepth;
     688                                                //m_ppiTempMvPtCorrZ[iRefY][iRefX] = (Short)iDisparity;
     689                                               
     690                                                //Mark point assigned earlier to this location as occluded:
     691                                                m_ppiMvPtCorrRefViewIdx[iSrcY][iSrcX] = TComMP::OCCLUSION;
     692                                                m_ppiMvPtCorrX[iSrcY][iSrcX] = TComMP::OCCLUSION;
     693                                                m_ppiMvPtCorrY[iSrcY][iSrcX] = TComMP::OCCLUSION;
     694
     695                                                //m_ppiMvPtCorrZ[iSrcY][iSrcX] = 0x7FFF;
     696                                                m_ppiMvPtCorrZ[iSrcY][iSrcX] = TComMP::OCCLUSION;                                               
     697
     698                                                m_pppcRefCU[iSrcY][iSrcX] = NULL;
     699                                                m_ppuicRefPartAddr[iSrcY][iSrcX] = 0;                                           
     700                                        }
     701                                }
     702                        }
     703          }
     704        }
     705        else
     706#endif
     707        {
    549708        iSynthViewIdx = uiViewId;
    550709
     
    605764                        }
    606765        }
     766      }
    607767#endif
    608768
  • branches/0.3-poznan-univ/source/Lib/TLibCommon/TComMP.h

    r28 r41  
    6969  Short** m_ppiMvPtCorrZ;
    7070  Short** m_ppiMvPtCorrRefViewIdx;
     71
     72#if !POZNAN_MP_USE_DEPTH_MAP_GENERATION && POZNAN_MP_USE_CURRENT_VIEW_DEPTH_MAP_IF_AVAILABLE
     73  Short** m_ppiTempMvPtCorrX;
     74  Short** m_ppiTempMvPtCorrY;
     75  Short** m_ppiTempMvPtCorrZ;
     76#endif
    7177
    7278  TComDataCU*** m_pppcRefCU; //XY array of pointers to reference CU for each point of picture
     
    117123  //Void                        init(UInt uiHeight, UInt uiWidth, TAppComCamPara* pcCameraData);
    118124  Void                  init(UInt uiHeight, UInt uiWidth, Int**** aiBaseViewShiftLUT);
     125#if POZNAN_MP_USE_CURRENT_VIEW_DEPTH_MAP_IF_AVAILABLE
     126  Void                  clearTemp();
     127#endif
    119128#endif
    120129  Void                  uninit();
  • branches/0.3-poznan-univ/source/Lib/TLibCommon/TComPicYuv.cpp

    r28 r41  
    457457}
    458458#if POZNAN_NONLINEAR_DEPTH
    459 Void TComPicYuv::nonlinearDepthForward(TComPicYuv *pcPicDst, Float p)
    460 {
    461   Int           x,y;
    462   TComNonlinearDepthForward cNonlinearDepthFwd(p, g_uiBitIncrement, g_uiBitIncrement);
     459Void TComPicYuv::nonlinearDepthForward(TComPicYuv *pcPicDst, TComNonlinearDepthModel &rcNonlinearDepthModel)
     460{
     461  Int           x,y,i;
     462  Int   LUT[256];
     463
     464  for (i=0; i<256; ++i)
     465    LUT[i] = (Int)rcNonlinearDepthModel.ForwardI(i, 1<<g_uiBitIncrement);
    463466
    464467  // Luma
     
    469472    for(x=0; x<m_iPicWidth; x++)
    470473    {
    471       pPelDst[x] = (Pel)( cNonlinearDepthFwd(pPelSrc[x]) + 0.5);
     474      pPelDst[x] = LUT[RemoveBitIncrement(pPelSrc[x])];
    472475    }
    473476    pPelDst += pcPicDst->getStride();
     
    478481  copyToPicCr(pcPicDst);
    479482}
    480 Void TComPicYuv::nonlinearDepthBackward(TComPicYuv *pcPicDst, Float p)
    481 {
    482   Int           x,y;
    483   TComNonlinearDepthBackward cNonlinearDepthBwd(p, g_uiBitIncrement, g_uiBitIncrement);
     483
     484Void TComPicYuv::nonlinearDepthBackward(TComPicYuv *pcPicDst, TComNonlinearDepthModel &rcNonlinearDepthModel)
     485{
     486  Int   x,y,i;
     487  Int   LUT[256];
     488
     489  for (i=255; i>=0; --i)
     490    LUT[i] = (Int)rcNonlinearDepthModel.BackwardI(i, 1<<g_uiBitIncrement ); // +0.5;
    484491
    485492  // Luma
     
    490497    for(x=0; x<m_iPicWidth; x++)
    491498    {
    492       pPelDst[x] = (Pel)( cNonlinearDepthBwd(pPelSrc[x]) + 0.5);
     499      pPelDst[x] = LUT[RemoveBitIncrement(pPelSrc[x])];
    493500    }
    494501    pPelDst += pcPicDst->getStride();
  • branches/0.3-poznan-univ/source/Lib/TLibCommon/TComPicYuv.h

    r28 r41  
    4444#include "CommonDef.h"
    4545
    46 #if POZNAN_NONLINEAR_DEPTH
    47 
    48 #include <math.h>
    49 
    50 class TComNonlinearDepthForward // OLGIERD - Z-NL-Power conversion
    51 {
    52 private:
    53   Double m_fMul;
    54   Float m_fPower;
    55 
    56 public:
    57 
    58   TComNonlinearDepthForward(Float fPower, Int iInputBitIncrement, Int iOutputBitIncrement)
    59   {
    60     m_fPower = fPower;
    61     Double fPostMul = (1<<(8+iOutputBitIncrement))-1; // OLGIERD ToDo - should be or not?
    62     Double fPreMul  = 1.0/((1<<(8+iInputBitIncrement))-1);
    63     m_fMul = fPostMul*pow(fPreMul,(Double)fPower);
    64   };
    65 
    66   inline Double operator() (Double Value)
    67   {   
    68     if (Value<0) return -pow( -Value,(Double)m_fPower)*m_fMul;
    69     return pow(Value,(Double)m_fPower)*m_fMul;
    70   };
    71 };
    72 
    73 class TComNonlinearDepthBackward // OLGIERD - Z-NL-Power conversion
    74 {
    75 private:
    76   Double m_fMul;
    77   Float m_fPower;
    78 
    79 public:
    80 
    81   TComNonlinearDepthBackward(Float fPower, Int iInputBitIncrement, Int iOutputBitIncrement)
    82   {     
    83     m_fPower = fPower = 1.0/fPower;
    84     Double fPostMul = (1<<(8+iOutputBitIncrement))-1; // OLGIERD ToDo - should be or not?
    85     Double fPreMul  = 1.0/((1<<(8+iInputBitIncrement))-1);
    86     m_fMul = fPostMul*pow(fPreMul,(Double)fPower);
    87   };
    88 
    89   inline Double operator() (Double Value)
    90   {   
    91     if (Value<0) return -pow( -Value,(Double)m_fPower)*m_fMul;
    92     return pow(Value,(Double)m_fPower)*m_fMul;
    93   };
    94 };
    95 #endif
    9646// ====================================================================================================================
    9747// Class definition
     
    226176
    227177#if POZNAN_NONLINEAR_DEPTH
    228   Void nonlinearDepthForward(TComPicYuv *pcPicDst, Float p);
    229   Void nonlinearDepthBackward(TComPicYuv *pcPicDst, Float p);
     178  Void nonlinearDepthForward(TComPicYuv *pcPicDst, TComNonlinearDepthModel &rcNonlinearDepthModel);
     179  Void nonlinearDepthBackward(TComPicYuv *pcPicDst, TComNonlinearDepthModel &rcNonlinearDepthModel);
    230180#endif
    231181};// END CLASS DEFINITION TComPicYuv
  • branches/0.3-poznan-univ/source/Lib/TLibCommon/TComPrediction.cpp

    r28 r41  
    16391639  TComMv          mv0_2nd,mv1_2nd;
    16401640
     1641#if DEPTH_MAP_GENERATION
     1642  Int             ref_frame0_idx_1st, ref_frame1_idx_1st;
     1643  TComMv          mv0_1st,mv1_1st;
     1644#endif
     1645
    16411646  Pel* piDstCb;
    16421647  Pel* piDstCr;
     
    16841689      iWidth  >>= uiSubSampExpX;
    16851690      iHeight >>= uiSubSampExpY;
     1691
     1692      //save orginal motion field of CU (it will be overwritten during the motion compensation)
     1693      ref_frame0_idx_1st = pcCU->getCUMvField(REF_PIC_LIST_0)->getRefIdx(uiPartAddr);
     1694      mv0_1st = pcCU->getCUMvField( REF_PIC_LIST_0 )->getMv( uiPartAddr );
     1695
     1696      ref_frame1_idx_1st = pcCU->getCUMvField(REF_PIC_LIST_1)->getRefIdx(uiPartAddr);
     1697      mv1_1st = pcCU->getCUMvField( REF_PIC_LIST_1 )->getMv( uiPartAddr );
    16861698    }
    16871699#endif
     
    18041816
    18051817        //set motion data representing CU with DBMP
     1818        PartSize ePartSize = pcCU->getPartitionSize( uiPartAddr ); //PartSize ePartSize = pcCU->getPartitionSize( 0 );
    18061819#if DEPTH_MAP_GENERATION
    18071820        if( !bPrdDepthMap )
    18081821#endif
    18091822        {
    1810                 PartSize ePartSize = pcCU->getPartitionSize( uiPartAddr ); //PartSize ePartSize = pcCU->getPartitionSize( 0 );
    18111823#if POZNAN_DBMP_CALC_PRED_DATA
    18121824                pcMP->xCalcDBMPPredData(uiPointCnt, ref_frame0_idx, mv0, ref_frame1_idx, mv1);
     
    18191831#endif
    18201832        }
     1833
     1834#if DEPTH_MAP_GENERATION
     1835        if( bPrdDepthMap )
     1836        {
     1837                pcCU->getCUMvField( REF_PIC_LIST_0 )->setAllMvField( mv0_1st, ref_frame0_idx_1st, ePartSize, uiPartAddr, iPartIdx, 0 );
     1838                pcCU->getCUMvField( REF_PIC_LIST_1 )->setAllMvField( mv1_1st, ref_frame1_idx_1st, ePartSize, uiPartAddr, iPartIdx, 0 );
     1839        }
     1840#endif
    18211841
    18221842        if ( iPartIdxOrg >= 0 ) break;
  • branches/0.3-poznan-univ/source/Lib/TLibCommon/TComSlice.cpp

    r28 r41  
    8585  ::memset( m_aaiCodedOffset, 0x00, sizeof( m_aaiCodedOffset ) );
    8686  m_pcTexturePic = NULL;
     87  m_pcDepthPic = NULL;
    8788#ifdef WEIGHT_PRED
    8889  resetWpScaling(m_weightPredTable);
     
    113114  ::memset( m_aiNumRefIdx,   0, sizeof ( m_aiNumRefIdx ));
    114115  m_pcTexturePic = NULL;
     116  m_pcDepthPic = NULL;
    115117 
    116118  initEqualRef();
     
    703705  m_bUseDMM = false;
    704706#endif
     707#if HHI_DMM_PRED_TEX && FLEX_CODING_ORDER
     708  m_bUseDMM34 = false;
     709#endif
    705710}
    706711
     
    747752  }
    748753#if POZNAN_NONLINEAR_DEPTH
    749   m_fDepthPower = 1.0;
     754  m_cNonlinearDepthModel.Clear();
    750755#endif
    751756#if POZNAN_TEXTURE_TU_DELTA_QP_ACCORDING_TO_DEPTH
     
    768773  ::memset( m_aaiCodedOffset, 0x00, sizeof( m_aaiCodedOffset ) );
    769774#if POZNAN_NONLINEAR_DEPTH
    770   m_fDepthPower = 1.0;
     775  m_cNonlinearDepthModel.Clear();
    771776#endif
    772777}
  • branches/0.3-poznan-univ/source/Lib/TLibCommon/TComSlice.h

    r28 r41  
    139139  Bool  m_bUseDMM;
    140140#endif
     141#if HHI_DMM_PRED_TEX && FLEX_CODING_ORDER
     142  Bool  m_bUseDMM34;
     143#endif
    141144
    142145#if DEPTH_MAP_GENERATION
     
    169172
    170173#if POZNAN_NONLINEAR_DEPTH
    171   Float  m_fDepthPower;
     174  TComNonlinearDepthModel m_cNonlinearDepthModel;   
     175  Bool  m_bUseNonlinearDepth;
    172176#endif
    173177
     
    258262  Void setUseDMM( Bool b ) { m_bUseDMM = b;    }
    259263#endif
    260 
     264#if HHI_DMM_PRED_TEX && FLEX_CODING_ORDER
     265  Bool getUseDMM34()         { return m_bUseDMM34; }
     266  Void setUseDMM34( Bool b ) { m_bUseDMM34 = b;    }
     267#endif
    261268
    262269#if DCM_COMB_LIST
     
    295302  Void setUseSAO                  (Bool bVal)  {m_bUseSAO = bVal;}
    296303#if POZNAN_ENCODE_ONLY_DISOCCLUDED_CU //todo fix SAO
    297   Bool getUseSAO     ()         { return (getViewId()>0)?false:m_bUseSAO;}
     304  Bool getUseSAO     ()           { return (getUseCUSkip() && getViewId()>0)?false:m_bUseSAO;}
    298305#else
    299306  Bool getUseSAO                  ()           {return m_bUseSAO;}
     
    354361#endif
    355362#if POZNAN_NONLINEAR_DEPTH
    356   inline Void    setDepthPower(Float p)   {m_fDepthPower = p;}
    357   inline Float   getDepthPower()          {return m_fDepthPower;}
    358 #else
    359   inline Float   getDepthPower()          {return 1.0f;}
     363  inline Void                            setNonlinearDepthModel( TComNonlinearDepthModel &rp ){ m_cNonlinearDepthModel = rp; }
     364  inline TComNonlinearDepthModel&        getNonlinearDepthModel()                             { return m_cNonlinearDepthModel; }
     365  Bool                    getUseNonlinearDepth()                                              { return m_bUseNonlinearDepth; }
     366  Void                    setUseNonlinearDepth( Bool bVal )                                   { m_bUseNonlinearDepth = bVal; }
    360367#endif
    361368#if POZNAN_TEXTURE_TU_DELTA_QP_ACCORDING_TO_DEPTH
     
    459466  Int         m_iDepth;
    460467  TComPic*    m_pcTexturePic;
     468  TComPic*    m_pcDepthPic;
    461469
    462470  // referenced slice?
     
    664672
    665673  Void setTexturePic( TComPic *pcTexturePic ) { m_pcTexturePic = pcTexturePic; }
     674  Void setDepthPic  ( TComPic *pcDepthPic   ) { m_pcDepthPic   = pcDepthPic;   }
    666675  TComPic *getTexturePic() const { return m_pcTexturePic; }
     676  TComPic *getDepthPic()   const { return m_pcDepthPic; }
    667677
    668678#ifdef WEIGHT_PRED
  • branches/0.3-poznan-univ/source/Lib/TLibCommon/TypeDef.h

    r28 r41  
    4040
    4141
    42 
    43 #define SONY_COLPIC_AVAILABILITY                  1
     42#define FLEX_CODING_ORDER               1
     43
     44#define SONY_COLPIC_AVAILABILITY        1
    4445
    4546//>>>>> HHI 3DV tools >>>>>
     
    8384#define POZNAN_CU_SKIP_PSNR         1 //Poznan Cu Skip Display psnr of the codded CUs only
    8485
    85 #define POZNAN_NONLINEAR_DEPTH              1    /// Non-linear depth processing (Maciej Kurc)
    86 #define POZNAN_NONLINEAR_DEPTH_SEND_AS_BYTE 1    /// Send DepthPower as byte instead of float
     86#define POZNAN_NONLINEAR_DEPTH              1    /// Non-linear depth processing
     87#define POZNAN_NONLINEAR_DEPTH_THRESHOLD    1  /// Non-linear depth thrasholding
    8788
    8889#if POZNAN_SYNTH
     
    106107                                                                                                                                        //                      POZNAN_MP_USE_DEPTH_MAP_GENERATION=1 - use DEPTH_MAP_GENERATION,
    107108                                                                                                                                        //                      POZNAN_MP_USE_DEPTH_MAP_GENERATION=0 - use reconstructed depth maps from neighboring views
     109
     110#if !POZNAN_MP_USE_DEPTH_MAP_GENERATION
     111#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
     112#endif
    108113
    109114#define POZNAN_MP_FILL                             1    // Depth-Based Multiview Prediction of CU parameters with fill option for occluded areas
     
    407412typedef       unsigned long       ULong;
    408413typedef       double              Double;
    409 typedef       float               Float;
    410414
    411415// ====================================================================================================================
Note: See TracChangeset for help on using the changeset viewer.