Ignore:
Timestamp:
4 May 2015, 17:47:40 (9 years ago)
Author:
tech
Message:

Merged 14.0-dev0@1187.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/Lib/TLibCommon/TComPrediction.cpp

    r1179 r1196  
    5454  m_pDepthBlock = (Int*) malloc(MAX_NUM_SPU_W*MAX_NUM_SPU_W*sizeof(Int));
    5555  if (m_pDepthBlock == NULL)
     56  {
    5657      printf("ERROR: UKTGHU, No memory allocated.\n");
     58  }
    5759#endif
    5860}
     
    6264#if H_3D_VSP
    6365  if (m_pDepthBlock != NULL)
    64       free(m_pDepthBlock);
     66  {
     67    free(m_pDepthBlock);
     68  }
    6569  m_cYuvDepthOnVsp.destroy();
    6670#endif
     
    513517
    514518#if H_3D_DIM_DMM
    515   if( dimType == DMM4_IDX && dmm4Segmentation == NULL ) { dmmSegmentation->destroy(); delete dmmSegmentation; }
     519  if( dimType == DMM4_IDX && dmm4Segmentation == NULL )
     520  {
     521    dmmSegmentation->destroy();
     522    delete dmmSegmentation;
     523  }
    516524#endif
    517525}
     
    630638
    631639#if H_3D_DBBP
    632 #if HS_DBBP_CLEAN_K0048
    633640PartSize TComPrediction::getPartitionSizeFromDepth(Pel* pDepthPels, UInt uiDepthStride, UInt uiSize, TComDataCU*& pcCU)
    634 #else
    635 PartSize TComPrediction::getPartitionSizeFromDepth(Pel* pDepthPels, UInt uiDepthStride, UInt uiSize)
    636 #endif
    637641{
    638642  // find virtual partitioning for this CU based on depth block
    639643  // segmentation of texture block --> mask IDs
    640644  Pel*  pDepthBlockStart      = pDepthPels;
    641  
     645
    642646  // first compute average of depth block for thresholding
    643647  Int iSumDepth = 0;
    644648  Int iSubSample = 4;
    645 #if HS_DBBP_CLEAN_K0048
    646649  Int iPictureWidth = pcCU->getSlice()->getIvPic (true, pcCU->getDvInfo(0).m_aVIdxCan)->getPicYuvRec()->getWidth();
    647650  Int iPictureHeight = pcCU->getSlice()->getIvPic (true, pcCU->getDvInfo(0).m_aVIdxCan)->getPicYuvRec()->getHeight();
     
    653656  Int iBlkX = ( pcCU->getAddr() % pcCU->getSlice()->getIvPic (true, pcCU->getDvInfo(0).m_aVIdxCan)->getFrameWidthInCU() ) * g_uiMaxCUWidth  + g_auiRasterToPelX[ g_auiZscanToRaster[ pcCU->getZorderIdxInCU() ] ]+ ((cDv.getHor()+2)>>2);
    654657  Int iBlkY = ( pcCU->getAddr() / pcCU->getSlice()->getIvPic (true, pcCU->getDvInfo(0).m_aVIdxCan)->getFrameWidthInCU() ) * g_uiMaxCUHeight + g_auiRasterToPelY[ g_auiZscanToRaster[ pcCU->getZorderIdxInCU() ] ]+ ((cDv.getVer()+2)>>2);
     658 
    655659  UInt t=0;
    656660
    657661  for (Int y=0; y<uiSize; y+=iSubSample)
    658    {
     662  {
    659663    for (Int x=0; x<uiSize; x+=iSubSample)
    660    {
    661 if (iBlkX+x>iPictureWidth)
    662 {
    663     Int depthPel = pDepthPels[t];
    664     iSumDepth += depthPel;
    665 }
    666 else
    667 {
    668     Int depthPel = pDepthPels[x];
    669     t=x;
    670     iSumDepth += depthPel;
    671 }
    672    }
    673    
     664    {
     665      if (iBlkX+x>iPictureWidth)
     666      {
     667        Int depthPel = pDepthPels[t];
     668        iSumDepth += depthPel;
     669      }
     670      else
     671      {
     672        Int depthPel = pDepthPels[x];
     673        t=x;
     674        iSumDepth += depthPel;
     675      }
     676    }
     677
    674678    // next row
    675679    if (!(iBlkY+y+4>iPictureHeight))
    676     pDepthPels += uiDepthStride*iSubSample;
    677 #else
    678   for (Int y=0; y<uiSize; y+=iSubSample)
    679   {
    680     for (Int x=0; x<uiSize; x+=iSubSample)
    681     {
    682       Int depthPel = pDepthPels[x];
    683      
    684       iSumDepth += depthPel;
    685     }
    686    
    687     // next row
    688     pDepthPels += uiDepthStride*iSubSample;
    689 #endif
    690   }
    691  
     680    {
     681      pDepthPels += uiDepthStride*iSubSample;
     682    }
     683  }
     684
    692685  Int iSizeInBits = g_aucConvertToBit[uiSize] - g_aucConvertToBit[iSubSample];  // respect sub-sampling factor
    693686  Int iMean = iSumDepth >> iSizeInBits*2;       // iMean /= (uiSize*uiSize);
    694  
     687
    695688  // start again for segmentation
    696689  pDepthPels = pDepthBlockStart;
    697  
     690
    698691  // start mapping process
    699692  Int matchedPartSum[2][2] = {{0,0},{0,0}}; // counter for each part size and boolean option
    700693  PartSize virtualPartSizes[2] = { SIZE_Nx2N, SIZE_2NxN};
    701  
     694
    702695  UInt uiHalfSize = uiSize>>1;
    703696  for (Int y=0; y<uiSize; y+=iSubSample)
     
    705698    for (Int x=0; x<uiSize; x+=iSubSample)
    706699    {
    707 #if HS_DBBP_CLEAN_K0048
    708700      Int depthPel = 0;
    709 if (iBlkX+x>iPictureWidth)
    710 {
    711     depthPel = pDepthPels[t];
    712 }
    713 else
    714 {
    715     depthPel = pDepthPels[x];
    716      t=x;
    717 }
    718 #else
    719       Int depthPel = pDepthPels[x];
    720 #endif
    721      
     701      if (iBlkX+x>iPictureWidth)
     702      {
     703        depthPel = pDepthPels[t];
     704      }
     705      else
     706      {
     707        depthPel = pDepthPels[x];
     708        t=x;
     709      }
     710
    722711      // decide which segment this pixel belongs to
    723712      Int ucSegment = (Int)(depthPel>iMean);
    724      
     713
    725714      // Matched Filter to find optimal (conventional) partitioning
    726      
     715
    727716      // SIZE_Nx2N
    728717      if(x<uiHalfSize)  // left
     
    734723        matchedPartSum[0][1-ucSegment]++;
    735724      }
    736      
     725
    737726      // SIZE_2NxN
    738727      if(y<uiHalfSize)  // top
     
    745734      }
    746735    }
    747    
     736
    748737    // next row
    749 #if HS_DBBP_CLEAN_K0048
    750738    if (!(iBlkY+y+4>iPictureHeight))
    751 #endif
    752     pDepthPels += uiDepthStride*iSubSample;
    753   }
    754  
     739    {
     740      pDepthPels += uiDepthStride*iSubSample;
     741    }
     742  }
     743
    755744  PartSize matchedPartSize = SIZE_NONE;
    756  
     745
    757746  Int iMaxMatchSum = 0;
    758747  for(Int p=0; p<2; p++)  // loop over partition
     
    767756    }
    768757  }
    769  
     758
    770759  AOF( matchedPartSize != SIZE_NONE );
    771  
     760
    772761  return matchedPartSize;
    773762}
    774763
    775 #if HS_DBBP_CLEAN_K0048
    776764Bool TComPrediction::getSegmentMaskFromDepth( Pel* pDepthPels, UInt uiDepthStride, UInt uiWidth, UInt uiHeight, Bool* pMask, TComDataCU*& pcCU)
    777 #else
    778 Bool TComPrediction::getSegmentMaskFromDepth( Pel* pDepthPels, UInt uiDepthStride, UInt uiWidth, UInt uiHeight, Bool* pMask )
    779 #endif
    780765{
    781766  // segmentation of texture block --> mask IDs
     
    786771  Int uiMinDepth = MAX_INT;
    787772  Int uiMaxDepth = 0;
    788 #if HS_DBBP_CLEAN_K0048
    789773  uiMinDepth = pDepthPels[ 0 ];
    790774  uiMaxDepth = pDepthPels[ 0 ];
    791775  iSumDepth  = pDepthPels[ 0 ];
    792   UInt t=0;
     776 
    793777  Int iPictureWidth = pcCU->getSlice()->getIvPic (true, pcCU->getDvInfo(0).m_aVIdxCan)->getPicYuvRec()->getWidth();
    794778  Int iPictureHeight = pcCU->getSlice()->getIvPic (true, pcCU->getDvInfo(0).m_aVIdxCan)->getPicYuvRec()->getHeight(); 
     
    848832    uiMaxDepth = std::max( uiMaxDepth, (Int)pDepthPels[ uiDepthStride * (uiHeight - 1) + uiWidth - 1 ]);
    849833  }
    850 #else
    851   iSumDepth  = pDepthPels[ 0 ];
    852   iSumDepth += pDepthPels[ uiWidth - 1 ];
    853   iSumDepth += pDepthPels[ uiDepthStride * (uiHeight - 1) ];
    854   iSumDepth += pDepthPels[ uiDepthStride * (uiHeight - 1) + uiWidth - 1 ];
    855 
    856   uiMinDepth = pDepthPels[ 0 ];
    857   uiMinDepth = std::min( uiMinDepth, (Int)pDepthPels[ uiWidth - 1 ]);
    858   uiMinDepth = std::min( uiMinDepth, (Int)pDepthPels[ uiDepthStride * (uiHeight - 1) ]);
    859   uiMinDepth = std::min( uiMinDepth, (Int)pDepthPels[ uiDepthStride * (uiHeight - 1) + uiWidth - 1 ]);
    860 
    861   uiMaxDepth = pDepthPels[ 0 ];
    862   uiMaxDepth = std::max( uiMaxDepth, (Int)pDepthPels[ uiWidth - 1 ]);
    863   uiMaxDepth = std::max( uiMaxDepth, (Int)pDepthPels[ uiDepthStride * (uiHeight - 1) ]);
    864   uiMaxDepth = std::max( uiMaxDepth, (Int)pDepthPels[ uiDepthStride * (uiHeight - 1) + uiWidth - 1 ]);
    865 #endif
    866834
    867835  // don't generate mask for blocks with small depth range (encoder decision)
     
    880848
    881849  // generate mask
     850  UInt t=0;
    882851  UInt uiSumPix[2] = {0,0};
    883852  for (Int y=0; y<uiHeight; y++)
     
    885854    for (Int x=0; x<uiHeight; x++)
    886855    {
    887 #if HS_DBBP_CLEAN_K0048
    888856      Int depthPel = 0;
    889857      if (iBlkX+x>iPictureWidth)
     
    896864        t=x;
    897865      }
    898 #else
    899       Int depthPel = pDepthPels[x];
    900 #endif
    901866
    902867      // decide which segment this pixel belongs to
     
    916881
    917882    // next row
    918 #if HS_DBBP_CLEAN_K0048
    919883    if (!(iBlkY+y+1>iPictureHeight))
    920 #endif
    921884      pDepthPels += uiDepthStride;
    922885    pMask += MAX_CU_SIZE;
     
    1003966  }
    1004967
    1005   if ( tmpTar    ) { xFree(tmpTar);             tmpTar        = NULL; }
     968  if ( tmpTar    )
     969  {
     970    xFree(tmpTar);             
     971    tmpTar        = NULL;
     972  }
    1006973 
    1007974  // now combine chroma
     
    11061073  }
    11071074
    1108   if ( tmpTarU    ) { xFree(tmpTarU);             tmpTarU        = NULL; }
    1109   if ( tmpTarV    ) { xFree(tmpTarV);             tmpTarV        = NULL; }
     1075  if( tmpTarU )
     1076  {
     1077    xFree(tmpTarU);
     1078    tmpTarU        = NULL;
     1079  }
     1080  if ( tmpTarV    )
     1081  {
     1082    xFree(tmpTarV);
     1083    tmpTarV        = NULL;
     1084  }
    11101085}
    11111086#endif
     
    12931268  TComMv      cMv         = pcCU->getCUMvField( eRefPicList )->getMv( uiPartAddr );
    12941269  pcCU->clipMv(cMv);
    1295 #if SONY_MV_V_CONST_C0078
    1296   pcCU->checkMV_V(cMv, eRefPicList, iRefIdx );
     1270#if H_MV
     1271  pcCU->checkMvVertRest(cMv, eRefPicList, iRefIdx );
    12971272#endif
    12981273#if H_3D_ARP
     
    13931368#if H_3D_NBDV
    13941369  DisInfo cDistparity;
    1395 #if SEC_ARP_REM_ENC_RESTRICT_K0035
    13961370  cDistparity.m_acNBDV = pcCU->getDvInfo(0).m_acNBDV;
    13971371  cDistparity.m_aVIdxCan = pcCU->getDvInfo(uiPartAddr).m_aVIdxCan;
    13981372#else
    1399   cDistparity.bDV           = pcCU->getDvInfo(uiPartAddr).bDV;
    1400   if( cDistparity.bDV )
    1401   {
    1402     cDistparity.m_acNBDV = pcCU->getDvInfo(0).m_acNBDV;
    1403     assert(pcCU->getDvInfo(uiPartAddr).bDV ==  pcCU->getDvInfo(0).bDV);
    1404     cDistparity.m_aVIdxCan = pcCU->getDvInfo(uiPartAddr).m_aVIdxCan;
    1405   }
    1406 #endif
    1407 #else
    14081373  assert(0); // ARP can be applied only when a DV is available
    14091374#endif
    1410 #if SEC_ARP_REM_ENC_RESTRICT_K0035
    14111375  UChar dW = pcCU->getARPW ( uiPartAddr );
    1412 #else
    1413   UChar dW = cDistparity.bDV ? pcCU->getARPW ( uiPartAddr ) : 0;
    1414 #endif
    1415 
    1416 #if !SEC_ARP_REM_ENC_RESTRICT_K0035
    1417   if( cDistparity.bDV )
    1418 #endif
     1376
    14191377  {
    14201378    Int arpRefIdx = pcCU->getSlice()->getFirstTRefIdx(eRefPicList);
     
    14681426      pYuvB0->clear(); pYuvB1->clear();
    14691427    }
    1470 #if !SEC_ARP_REM_ENC_RESTRICT_K0035
    1471     assert ( cDistparity.bDV );
    1472 #endif   
    14731428    TComMv cNBDV = cDistparity.m_acNBDV;
    14741429    pcCU->clipMv( cNBDV );
     
    24382393    for( UInt k = 0; k < (patternStride * patternStride); k++ )
    24392394    {
    2440       if( true == biSegPattern[k] ) { ptrDst[k] = valDC2; }
    2441       else                          { ptrDst[k] = valDC1; }
     2395      if( true == biSegPattern[k] )
     2396      {
     2397        ptrDst[k] = valDC2;
     2398      }
     2399      else                         
     2400      {
     2401        ptrDst[k] = valDC1;
     2402      }
    24422403    }
    24432404  }
     
    24492410      for( UInt uiX = 0; uiX < patternStride; uiX++ )
    24502411      {
    2451         if( true == biSegPattern[uiX] ) { piTemp[uiX] = valDC2; }
    2452         else                            { piTemp[uiX] = valDC1; }
     2412        if( true == biSegPattern[uiX] )
     2413        {
     2414          piTemp[uiX] = valDC2;
     2415        }
     2416        else                           
     2417        {
     2418          piTemp[uiX] = valDC1;
     2419        }
    24532420      }
    24542421      piTemp       += dstStride;
     
    25202487  Int iSumPix[2];
    25212488  memset(iSumPix, 0, sizeof(Int)*2);
     2489
    25222490  for( Int i = 0; i < uiNumSegments; i++ )
    25232491  {
    2524     rpSegMeans[i] = 0;
    2525   }
    2526   if (orgDC == false)
     2492    rpSegMeans[i] = 0; 
     2493  }
     2494
     2495  if ( !orgDC )
    25272496  {
    25282497    Pel* pLeftTop = pOrig;
     
    25442513    subSamplePix = 1;
    25452514  }
     2515
    25462516  for (Int y=0; y<uiSize; y+=subSamplePix)
    25472517  {
     
    25632533  {
    25642534    if( iSumPix[ucSeg] > 0 )
     2535    {
    25652536      rpSegMeans[ucSeg] = iSumDepth[ucSeg] / iSumPix[ucSeg];
     2537    }
    25662538    else
     2539    {
    25672540      rpSegMeans[ucSeg] = 0;  // this happens for zero-segments
     2541    }
    25682542  }
    25692543}
Note: See TracChangeset for help on using the changeset viewer.