Changeset 872 in 3DVCSoftware for trunk/source/Lib/TLibCommon/TComPic.cpp


Ignore:
Timestamp:
27 Mar 2014, 10:11:29 (11 years ago)
Author:
tech
Message:

Merged HTM-10.0-dev0@871. (MV-HEVC 7 HLS)

File:
1 edited

Legend:

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

    r738 r872  
    44 * granted under this license. 
    55 *
    6  * Copyright (c) 2010-2013, ITU/ISO/IEC
     6* Copyright (c) 2010-2014, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
     
    5656, m_bNeededForOutput                      (false)
    5757, m_uiCurrSliceIdx                        (0)
    58 , m_pSliceSUMap                           (NULL)
    59 , m_pbValidSlice                          (NULL)
    60 , m_sliceGranularityForNDBFilter          (0)
    61 , m_bIndependentSliceBoundaryForNDBFilter (false)
    62 , m_bIndependentTileBoundaryForNDBFilter  (false)
    63 , m_pNDBFilterYuvTmp                      (NULL)
    6458, m_bCheckLTMSB                           (false)
    6559#if H_MV
     
    117111  memcpy(m_numReorderPics, numReorderPics, MAX_TLAYER*sizeof(Int));
    118112
    119   /* initialize the texture to depth reference status */
    120113#if H_3D_FCO
     114/* initialize the texture to depth reference status */
    121115  for (int j=0; j<2; j++)
    122116  {
     
    174168}
    175169
    176 /** Create non-deblocked filter information
    177  * \param pSliceStartAddress array for storing slice start addresses
    178  * \param numSlices number of slices in picture
    179  * \param sliceGranularityDepth slice granularity
    180  * \param bNDBFilterCrossSliceBoundary cross-slice-boundary in-loop filtering; true for "cross".
    181  * \param numTiles number of tiles in picture
    182  * \param bNDBFilterCrossTileBoundary cross-tile-boundary in-loop filtering; true for "cross".
    183  */
    184 Void TComPic::createNonDBFilterInfo(std::vector<Int> sliceStartAddress, Int sliceGranularityDepth
    185                                     ,std::vector<Bool>* LFCrossSliceBoundary
    186                                     ,Int numTiles
    187                                     ,Bool bNDBFilterCrossTileBoundary)
    188 {
    189   UInt maxNumSUInLCU = getNumPartInCU();
    190   UInt numLCUInPic   = getNumCUsInFrame();
    191   UInt picWidth      = getSlice(0)->getSPS()->getPicWidthInLumaSamples();
    192   UInt picHeight     = getSlice(0)->getSPS()->getPicHeightInLumaSamples();
    193   Int  numLCUsInPicWidth = getFrameWidthInCU();
    194   Int  numLCUsInPicHeight= getFrameHeightInCU();
    195   UInt maxNumSUInLCUWidth = getNumPartInWidth();
    196   UInt maxNumSUInLCUHeight= getNumPartInHeight();
    197   Int  numSlices = (Int) sliceStartAddress.size() - 1;
    198   m_bIndependentSliceBoundaryForNDBFilter = false;
    199   if(numSlices > 1)
    200   {
    201     for(Int s=0; s< numSlices; s++)
    202     {
    203       if((*LFCrossSliceBoundary)[s] == false)
    204       {
    205         m_bIndependentSliceBoundaryForNDBFilter = true;
    206       }
    207     }
    208   }
    209   m_sliceGranularityForNDBFilter = sliceGranularityDepth;
    210   m_bIndependentTileBoundaryForNDBFilter  = (bNDBFilterCrossTileBoundary)?(false) :((numTiles > 1)?(true):(false));
    211 
    212   m_pbValidSlice = new Bool[numSlices];
    213   for(Int s=0; s< numSlices; s++)
    214   {
    215     m_pbValidSlice[s] = true;
    216   }
    217   m_pSliceSUMap = new Int[maxNumSUInLCU * numLCUInPic];
    218 
    219   //initialization
    220   for(UInt i=0; i< (maxNumSUInLCU * numLCUInPic); i++ )
    221   {
    222     m_pSliceSUMap[i] = -1;
    223   }
    224   for( UInt CUAddr = 0; CUAddr < numLCUInPic ; CUAddr++ )
    225   {
    226     TComDataCU* pcCU = getCU( CUAddr );
    227     pcCU->setSliceSUMap(m_pSliceSUMap + (CUAddr* maxNumSUInLCU));
    228     pcCU->getNDBFilterBlocks()->clear();
    229   }
    230   m_vSliceCUDataLink.clear();
    231 
    232   m_vSliceCUDataLink.resize(numSlices);
    233 
    234   UInt startAddr, endAddr, firstCUInStartLCU, startLCU, endLCU, lastCUInEndLCU, uiAddr;
    235   UInt LPelX, TPelY, LCUX, LCUY;
    236   UInt currSU;
    237   UInt startSU, endSU;
    238 
    239   for(Int s=0; s< numSlices; s++)
    240   {
    241     //1st step: decide the real start address
    242     startAddr = sliceStartAddress[s];
    243     endAddr   = sliceStartAddress[s+1] -1;
    244 
    245     startLCU            = startAddr / maxNumSUInLCU;
    246     firstCUInStartLCU   = startAddr % maxNumSUInLCU;
    247 
    248     endLCU              = endAddr   / maxNumSUInLCU;
    249     lastCUInEndLCU      = endAddr   % maxNumSUInLCU;   
    250 
    251     uiAddr = m_apcPicSym->getCUOrderMap(startLCU);
    252 
    253     LCUX      = getCU(uiAddr)->getCUPelX();
    254     LCUY      = getCU(uiAddr)->getCUPelY();
    255     LPelX     = LCUX + g_auiRasterToPelX[ g_auiZscanToRaster[firstCUInStartLCU] ];
    256     TPelY     = LCUY + g_auiRasterToPelY[ g_auiZscanToRaster[firstCUInStartLCU] ];
    257     currSU    = firstCUInStartLCU;
    258 
    259     Bool bMoveToNextLCU = false;
    260     Bool bSliceInOneLCU = (startLCU == endLCU);
    261 
    262     while(!( LPelX < picWidth ) || !( TPelY < picHeight ))
    263     {
    264       currSU ++;
    265 
    266       if(bSliceInOneLCU)
    267       {
    268         if(currSU > lastCUInEndLCU)
    269         {
    270           m_pbValidSlice[s] = false;
    271           break;
    272         }
    273       }
    274 
    275       if(currSU >= maxNumSUInLCU )
    276       {
    277         bMoveToNextLCU = true;
    278         break;
    279       }
    280 
    281       LPelX = LCUX + g_auiRasterToPelX[ g_auiZscanToRaster[currSU] ];
    282       TPelY = LCUY + g_auiRasterToPelY[ g_auiZscanToRaster[currSU] ];
    283 
    284     }
    285 
    286 
    287     if(!m_pbValidSlice[s])
    288     {
    289       continue;
    290     }
    291 
    292     if(currSU != firstCUInStartLCU)
    293     {
    294       if(!bMoveToNextLCU)
    295       {
    296         firstCUInStartLCU = currSU;
    297       }
    298       else
    299       {
    300         startLCU++;
    301         firstCUInStartLCU = 0;
    302         assert( startLCU < getNumCUsInFrame());
    303       }
    304       assert(startLCU*maxNumSUInLCU + firstCUInStartLCU < endAddr);
    305     }
    306 
    307 
    308     //2nd step: assign NonDBFilterInfo to each processing block
    309     for(UInt i= startLCU; i <= endLCU; i++)
    310     {
    311       startSU = (i == startLCU)?(firstCUInStartLCU):(0);
    312       endSU   = (i == endLCU  )?(lastCUInEndLCU   ):(maxNumSUInLCU -1);
    313 
    314       uiAddr = m_apcPicSym->getCUOrderMap(i);
    315       Int iTileID= m_apcPicSym->getTileIdxMap(uiAddr);
    316 
    317       TComDataCU* pcCU = getCU(uiAddr);
    318       m_vSliceCUDataLink[s].push_back(pcCU);
    319 
    320       createNonDBFilterInfoLCU(iTileID, s, pcCU, startSU, endSU, m_sliceGranularityForNDBFilter, picWidth, picHeight);
    321     }
    322   }
    323 
    324   //step 3: border availability
    325   for(Int s=0; s< numSlices; s++)
    326   {
    327     if(!m_pbValidSlice[s])
    328     {
    329       continue;
    330     }
    331 
    332     for(Int i=0; i< m_vSliceCUDataLink[s].size(); i++)
    333     {
    334       TComDataCU* pcCU = m_vSliceCUDataLink[s][i];
    335       uiAddr = pcCU->getAddr();
    336 
    337       if(pcCU->getPic()==0)
    338       {
    339         continue;
    340       }
    341       Int iTileID= m_apcPicSym->getTileIdxMap(uiAddr);
    342       Bool bTopTileBoundary = false, bDownTileBoundary= false, bLeftTileBoundary= false, bRightTileBoundary= false;
    343 
    344       if(m_bIndependentTileBoundaryForNDBFilter)
    345       {
    346         //left
    347         if( uiAddr % numLCUsInPicWidth != 0)
    348         {
    349           bLeftTileBoundary = ( m_apcPicSym->getTileIdxMap(uiAddr -1) != iTileID )?true:false;
    350         }
    351         //right
    352         if( (uiAddr % numLCUsInPicWidth) != (numLCUsInPicWidth -1) )
    353         {
    354           bRightTileBoundary = ( m_apcPicSym->getTileIdxMap(uiAddr +1) != iTileID)?true:false;
    355         }
    356         //top
    357         if( uiAddr >= numLCUsInPicWidth)
    358         {
    359           bTopTileBoundary = (m_apcPicSym->getTileIdxMap(uiAddr - numLCUsInPicWidth) !=  iTileID )?true:false;
    360         }
    361         //down
    362         if( uiAddr + numLCUsInPicWidth < numLCUInPic )
    363         {
    364           bDownTileBoundary = (m_apcPicSym->getTileIdxMap(uiAddr + numLCUsInPicWidth) != iTileID)?true:false;
    365         }
    366 
    367       }
    368 
    369       pcCU->setNDBFilterBlockBorderAvailability(numLCUsInPicWidth, numLCUsInPicHeight, maxNumSUInLCUWidth, maxNumSUInLCUHeight,picWidth, picHeight
    370         , *LFCrossSliceBoundary
    371         ,bTopTileBoundary, bDownTileBoundary, bLeftTileBoundary, bRightTileBoundary
    372         ,m_bIndependentTileBoundaryForNDBFilter);
    373 
    374     }
    375 
    376   }
    377 
    378   if( m_bIndependentSliceBoundaryForNDBFilter || m_bIndependentTileBoundaryForNDBFilter)
    379   {
    380     m_pNDBFilterYuvTmp = new TComPicYuv();
    381     m_pNDBFilterYuvTmp->create(picWidth, picHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth);
    382   }
    383 
    384 }
    385 
    386 /** Create non-deblocked filter information for LCU
    387  * \param tileID tile index
    388  * \param sliceID slice index
    389  * \param pcCU CU data pointer
    390  * \param startSU start SU index in LCU
    391  * \param endSU end SU index in LCU
    392  * \param sliceGranularyDepth slice granularity
    393  * \param picWidth picture width
    394  * \param picHeight picture height
    395  */
    396 Void TComPic::createNonDBFilterInfoLCU(Int tileID, Int sliceID, TComDataCU* pcCU, UInt startSU, UInt endSU, Int sliceGranularyDepth, UInt picWidth, UInt picHeight)
    397 {
    398   UInt LCUX          = pcCU->getCUPelX();
    399   UInt LCUY          = pcCU->getCUPelY();
    400   Int* pCUSliceMap    = pcCU->getSliceSUMap();
    401   UInt maxNumSUInLCU = getNumPartInCU();
    402   UInt maxNumSUInSGU = maxNumSUInLCU >> (sliceGranularyDepth << 1);
    403   UInt maxNumSUInLCUWidth = getNumPartInWidth();
    404   UInt LPelX, TPelY;
    405   UInt currSU;
    406 
    407 
    408   //get the number of valid NBFilterBLock
    409   currSU   = startSU;
    410   while(currSU <= endSU)
    411   {
    412     LPelX = LCUX + g_auiRasterToPelX[ g_auiZscanToRaster[currSU] ];
    413     TPelY = LCUY + g_auiRasterToPelY[ g_auiZscanToRaster[currSU] ];
    414 
    415     while(!( LPelX < picWidth ) || !( TPelY < picHeight ))
    416     {
    417       currSU += maxNumSUInSGU;
    418       if(currSU >= maxNumSUInLCU || currSU > endSU)
    419       {
    420         break;
    421       }
    422       LPelX = LCUX + g_auiRasterToPelX[ g_auiZscanToRaster[currSU] ];
    423       TPelY = LCUY + g_auiRasterToPelY[ g_auiZscanToRaster[currSU] ];
    424     }
    425 
    426     if(currSU >= maxNumSUInLCU || currSU > endSU)
    427     {
    428       break;
    429     }
    430 
    431     NDBFBlockInfo NDBFBlock;
    432 
    433     NDBFBlock.tileID  = tileID;
    434     NDBFBlock.sliceID = sliceID;
    435     NDBFBlock.posY    = TPelY;
    436     NDBFBlock.posX    = LPelX;
    437     NDBFBlock.startSU = currSU;
    438 
    439     UInt uiLastValidSU  = currSU;
    440     UInt uiIdx, uiLPelX_su, uiTPelY_su;
    441     for(uiIdx = currSU; uiIdx < currSU + maxNumSUInSGU; uiIdx++)
    442     {
    443       if(uiIdx > endSU)
    444       {
    445         break;       
    446       }
    447       uiLPelX_su   = LCUX + g_auiRasterToPelX[ g_auiZscanToRaster[uiIdx] ];
    448       uiTPelY_su   = LCUY + g_auiRasterToPelY[ g_auiZscanToRaster[uiIdx] ];
    449       if( !(uiLPelX_su < picWidth ) || !( uiTPelY_su < picHeight ))
    450       {
    451         continue;
    452       }
    453       pCUSliceMap[uiIdx] = sliceID;
    454       uiLastValidSU = uiIdx;
    455     }
    456     NDBFBlock.endSU = uiLastValidSU;
    457 
    458     UInt rTLSU = g_auiZscanToRaster[ NDBFBlock.startSU ];
    459     UInt rBRSU = g_auiZscanToRaster[ NDBFBlock.endSU   ];
    460     NDBFBlock.widthSU  = (rBRSU % maxNumSUInLCUWidth) - (rTLSU % maxNumSUInLCUWidth)+ 1;
    461     NDBFBlock.heightSU = (UInt)(rBRSU / maxNumSUInLCUWidth) - (UInt)(rTLSU / maxNumSUInLCUWidth)+ 1;
    462     NDBFBlock.width    = NDBFBlock.widthSU  * getMinCUWidth();
    463     NDBFBlock.height   = NDBFBlock.heightSU * getMinCUHeight();
    464 
    465     pcCU->getNDBFilterBlocks()->push_back(NDBFBlock);
    466 
    467     currSU += maxNumSUInSGU;
    468   }
    469 
    470 }
    471 
    472 /** destroy non-deblocked filter information for LCU
    473  */
    474 Void TComPic::destroyNonDBFilterInfo()
    475 {
    476   if(m_pbValidSlice != NULL)
    477   {
    478     delete[] m_pbValidSlice;
    479     m_pbValidSlice = NULL;
    480   }
    481 
    482   if(m_pSliceSUMap != NULL)
    483   {
    484     delete[] m_pSliceSUMap;
    485     m_pSliceSUMap = NULL;
    486   }
    487   for( UInt CUAddr = 0; CUAddr < getNumCUsInFrame() ; CUAddr++ )
    488   {
    489     TComDataCU* pcCU = getCU( CUAddr );
    490     pcCU->getNDBFilterBlocks()->clear();
    491   }
    492 
    493   if( m_bIndependentSliceBoundaryForNDBFilter || m_bIndependentTileBoundaryForNDBFilter)
    494   {
    495     m_pNDBFilterYuvTmp->destroy();
    496     delete m_pNDBFilterYuvTmp;
    497     m_pNDBFilterYuvTmp = NULL;
    498   }
    499 
    500 }
     170Bool  TComPic::getSAOMergeAvailability(Int currAddr, Int mergeAddr)
     171{
     172  Bool mergeCtbInSliceSeg = (mergeAddr >= getPicSym()->getCUOrderMap(getCU(currAddr)->getSlice()->getSliceCurStartCUAddr()/getNumPartInCU()));
     173  Bool mergeCtbInTile     = (getPicSym()->getTileIdxMap(mergeAddr) == getPicSym()->getTileIdxMap(currAddr));
     174  return (mergeCtbInSliceSeg && mergeCtbInTile);
     175}
     176
    501177#if H_MV
    502178Void TComPic::print( Bool legend )
Note: See TracChangeset for help on using the changeset viewer.