Ignore:
Timestamp:
26 May 2013, 15:41:34 (11 years ago)
Author:
tech
Message:
  • Reintegrated branch 6.2-dev0 rev. 442.
  • Changed version number.
  • Added coding results.
File:
1 edited

Legend:

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

    r296 r443  
    6262TComSampleAdaptiveOffset::TComSampleAdaptiveOffset()
    6363{
     64#if !LGE_SAO_MIGRATION_D0091
    6465  m_pcPic = NULL;
     66#endif
    6567  m_iOffsetBo = NULL;
    6668  m_pClipTable = NULL;
     
    7173  m_iUpBufft = NULL;
    7274  ipSwap = NULL;
     75#if !LGE_SAO_MIGRATION_D0091
    7376  m_pcYuvTmp = NULL;
     77#endif
    7478
    7579  m_pTmpU1 = NULL;
     
    8589}
    8690
     91#if !LGE_SAO_MIGRATION_D0091
    8792const Int TComSampleAdaptiveOffset::m_aiNumPartsInRow[5] =
    8893{
     
    102107  256  //level 4
    103108};
     109#endif
    104110
    105111const Int TComSampleAdaptiveOffset::m_aiNumCulPartsLevel[5] =
     
    124130  0
    125131};
    126 
     132#if !LGE_SAO_MIGRATION_D0091
    127133const UInt TComSampleAdaptiveOffset::m_iWeightSao[MAX_NUM_SAO_TYPE] =
    128134{
     
    146152  6
    147153};
     154#endif
    148155
    149156Int TComSampleAdaptiveOffset::m_iNumClass[MAX_NUM_SAO_TYPE] =
     
    187194  return idx;
    188195}
     196#if !LGE_SAO_MIGRATION_D0091
    189197/** convert quadtree Idx to Level, Row, and Col
    190198 * \param  idx,  *level,  *row,  *col
     
    223231  }
    224232}
     233#endif
    225234/** create SampleAdaptiveOffset memory.
    226235 * \param
     
    317326  }
    318327
    319 
     328#if LGE_SAO_MIGRATION_D0091
     329  if (m_iUpBuff1)
     330  {
     331      m_iUpBuff1--;
     332      delete [] m_iUpBuff1; m_iUpBuff1 = NULL;
     333  }
     334  if (m_iUpBuff2)
     335  {
     336      m_iUpBuff2--;
     337      delete [] m_iUpBuff2; m_iUpBuff2 = NULL;
     338  }
     339  if (m_iUpBufft)
     340  {
     341      m_iUpBufft--;
     342      delete [] m_iUpBufft; m_iUpBufft = NULL;
     343  }
     344#else
    320345  m_iUpBuff1--;
    321346  m_iUpBuff2--;
     
    334359    delete [] m_iUpBufft; m_iUpBufft = NULL;
    335360  }
     361#endif
    336362  if (m_pTmpL1)
    337363  {
     
    368394  initSAOParam(pcSaoParam, 0, 0, 0, -1, 0, m_iNumCuInWidth-1,  0, m_iNumCuInHeight-1,1);
    369395  initSAOParam(pcSaoParam, 0, 0, 0, -1, 0, m_iNumCuInWidth-1,  0, m_iNumCuInHeight-1,2);
     396#if !LGE_SAO_MIGRATION_D0091
    370397  for(Int j=0;j<MAX_NUM_SAO_TYPE;j++)
    371398  {
    372399    pcSaoParam->iNumClass[j] = m_iNumClass[j];
    373400  }
     401#endif
    374402  pcSaoParam->numCuInWidth  = m_iNumCuInWidth;
    375403  pcSaoParam->numCuInHeight = m_iNumCuInHeight;
     
    405433  pSaoPart->iLength     =  0;
    406434
     435#if LGE_SAO_MIGRATION_D0091
     436  pSaoPart->subTypeIdx = 0;
     437#else
    407438  pSaoPart->bandPosition = 0;
     439#endif
    408440
    409441  for (j=0;j<MAX_NUM_SAO_OFFSETS;j++)
     
    514546  for(Int c=0; c<iNumComponet; c++)
    515547  {
     548#if LGE_SAO_MIGRATION_D0091
     549    if (c<2)
     550    {
    516551    pcSaoParam->bSaoFlag[c] = 0;
     552    }
     553#else
     554    pcSaoParam->bSaoFlag[c] = 0;
     555#endif
    517556    for(Int i=0; i< m_aiNumCulPartsLevel[m_uiMaxSplitLevel]; i++)
    518557    {
     
    524563      pcSaoParam->psSaoPart[c][i].iMinDist      = MAX_INT;
    525564      pcSaoParam->psSaoPart[c][i].iMinRate      = MAX_INT;
     565#if LGE_SAO_MIGRATION_D0091
     566      pcSaoParam->psSaoPart[c][i].subTypeIdx    = 0;
     567#else
    526568      pcSaoParam->psSaoPart[c][i].bandPosition = 0;
     569#endif
    527570      for (Int j=0;j<MAX_NUM_SAO_OFFSETS;j++)
    528571      {
     
    557600  m_pcPic   = pcPic;
    558601  m_uiNumSlicesInPic = numSlicesInPic;
     602#if LGE_SAO_MIGRATION_D0091
     603  m_iSGDepth         = 0;
     604#else
    559605  m_iSGDepth         = pcPic->getSliceGranularityForNDBFilter();
     606#endif
    560607  m_bUseNIF = ( pcPic->getIndependentSliceBoundaryForNDBFilter() || pcPic->getIndependentTileBoundaryForNDBFilter() );
    561608  if(m_bUseNIF)
     
    9581005          uiEdgeType = iSignDown + m_iUpBuff1[x] + 2;
    9591006          m_iUpBuff1[x]= -iSignDown;
    960 
    9611007          pRec[x] = m_pClipTable[pRec[x] + m_iOffsetEo[uiEdgeType]];
    9621008        }
     
    10651111Void TComSampleAdaptiveOffset::SAOProcess(TComPic* pcPic, SAOParam* pcSaoParam)
    10661112{
     1113#if LGE_SAO_MIGRATION_D0091
     1114  if (pcSaoParam->bSaoFlag[0] || pcSaoParam->bSaoFlag[1])
     1115#else
    10671116  if (pcSaoParam->bSaoFlag[0])
     1117#endif
    10681118  {
    10691119#if FULL_NBIT
     
    10771127      m_pcPic->getPicYuvRec()->copyToPic(m_pcYuvTmp);
    10781128    }
    1079 
     1129#if LGE_SAO_MIGRATION_D0091
     1130    if (m_saoLcuBasedOptimization)
     1131#else
    10801132    if (m_saoInterleavingFlag)
     1133#endif
    10811134    {
    10821135      pcSaoParam->oneUnitFlag[0] = 0; 
     
    10851138    }
    10861139    Int iY  = 0;
     1140#if LGE_SAO_MIGRATION_D0091
     1141    if (pcSaoParam->bSaoFlag[0])
     1142    {
     1143        processSaoUnitAll( pcSaoParam->saoLcuParam[iY], pcSaoParam->oneUnitFlag[iY], iY);
     1144    }
     1145    if(pcSaoParam->bSaoFlag[1])
     1146    {
     1147        processSaoUnitAll( pcSaoParam->saoLcuParam[1], pcSaoParam->oneUnitFlag[1], 1);//Cb
     1148        processSaoUnitAll( pcSaoParam->saoLcuParam[2], pcSaoParam->oneUnitFlag[2], 2);//Cr
     1149    }
     1150#else
    10871151    processSaoUnitAll( pcSaoParam->saoLcuParam[iY], pcSaoParam->oneUnitFlag[iY], iY);
    10881152
     
    10971161      processSaoUnitAll( pcSaoParam->saoLcuParam[iCr], pcSaoParam->oneUnitFlag[iCr], iCr);
    10981162    }
    1099 
    1100 
     1163#endif
    11011164    m_pcPic = NULL;
    11021165  }
     
    11541217  Int  typeIdx;
    11551218
     1219#if LGE_SAO_MIGRATION_D0091
     1220  Int offset[LUMA_GROUP_NUM+1];
     1221#else
    11561222  static Int offset[LUMA_GROUP_NUM+1];
     1223#endif
    11571224  Int idxX;
    11581225  Int idxY;
     
    11641231  Int isChroma = (yCbCr == 0) ? 0:1;
    11651232  Bool mergeLeftFlag;
    1166 
    1167 
     1233#if LGE_SAO_MIGRATION_D0091
     1234  offset[0] = 0;
     1235#endif
    11681236  for (idxY = 0; idxY< frameHeightInCU; idxY++)
    11691237  {
     
    12011269    {
    12021270      addr = idxY * frameWidthInCU + idxX;
    1203 
    12041271      if (oneUnitFlag)
    12051272      {
     
    12251292            for (i=0; i<saoLcuParam[addr].length; i++)
    12261293            {
     1294#if LGE_SAO_MIGRATION_D0091
     1295              offset[ (saoLcuParam[addr].subTypeIdx +i)%SAO_MAX_BO_CLASSES  +1] = saoLcuParam[addr].offset[i] << m_uiSaoBitIncrease;
     1296#else
    12271297              offset[ (saoLcuParam[addr].bandPosition +i)%SAO_MAX_BO_CLASSES  +1] = saoLcuParam[addr].offset[i] << m_uiSaoBitIncrease;
     1298#endif
    12281299            }
    12291300
     
    13041375      saoLcuParam[i].offset[j] = 0;
    13051376    }
     1377#if LGE_SAO_MIGRATION_D0091
     1378    saoLcuParam[i].subTypeIdx   = 0;
     1379#else
    13061380    saoLcuParam[i].bandPosition = 0;
     1381#endif
    13071382  }
    13081383}
     
    13531428      saoLcuParam[addr].partIdxTmp = (Int)partIdx;
    13541429      saoLcuParam[addr].typeIdx    = saoQTPart[partIdx].iBestType;
     1430#if LGE_SAO_MIGRATION_D0091
     1431      saoLcuParam[addr].subTypeIdx   = saoQTPart[partIdx].subTypeIdx;
     1432#else
    13551433      saoLcuParam[addr].bandPosition = saoQTPart[partIdx].bandPosition;
     1434#endif
    13561435      if (saoLcuParam[addr].typeIdx!=-1)
    13571436      {
     
    13651444      {
    13661445        saoLcuParam[addr].length    = 0;
     1446#if LGE_SAO_MIGRATION_D0091
     1447        saoLcuParam[addr].subTypeIdx = saoQTPart[partIdx].subTypeIdx;
     1448#else
    13671449        saoLcuParam[addr].bandPosition = saoQTPart[partIdx].bandPosition;
     1450#endif
    13681451        for (j=0;j<MAX_NUM_SAO_OFFSETS;j++)
    13691452        {
     
    13751458}
    13761459
    1377 
    1378 
     1460#if LGE_SAO_MIGRATION_D0091
     1461Void TComSampleAdaptiveOffset::resetSaoUnit(SaoLcuParam* saoUnit)
     1462{
     1463  saoUnit->partIdx       = 0;
     1464  saoUnit->partIdxTmp    = 0;
     1465  saoUnit->mergeLeftFlag = 0;
     1466  saoUnit->mergeUpFlag   = 0;
     1467  saoUnit->typeIdx       = -1;
     1468  saoUnit->length        = 0;
     1469  saoUnit->subTypeIdx    = 0;
     1470
     1471  for (Int i=0;i<4;i++)
     1472  {
     1473    saoUnit->offset[i] = 0;
     1474  }
     1475}
     1476
     1477Void TComSampleAdaptiveOffset::copySaoUnit(SaoLcuParam* saoUnitDst, SaoLcuParam* saoUnitSrc )
     1478{
     1479  saoUnitDst->mergeLeftFlag = saoUnitSrc->mergeLeftFlag;
     1480  saoUnitDst->mergeUpFlag   = saoUnitSrc->mergeUpFlag;
     1481  saoUnitDst->typeIdx       = saoUnitSrc->typeIdx;
     1482  saoUnitDst->length        = saoUnitSrc->length;
     1483
     1484  saoUnitDst->subTypeIdx  = saoUnitSrc->subTypeIdx;
     1485  for (Int i=0;i<4;i++)
     1486  {
     1487    saoUnitDst->offset[i] = saoUnitSrc->offset[i];
     1488  }
     1489}
     1490
     1491/** PCM LF disable process.
     1492 * \param pcPic picture (TComPic) pointer
     1493 * \returns Void
     1494 *
     1495 * \note Replace filtered sample values of PCM mode blocks with the transmitted and reconstructed ones.
     1496 */
     1497Void TComSampleAdaptiveOffset::PCMLFDisableProcess (TComPic* pcPic)
     1498{
     1499  xPCMRestoration(pcPic);
     1500}
     1501
     1502/** Picture-level PCM restoration.
     1503 * \param pcPic picture (TComPic) pointer
     1504 * \returns Void
     1505 */
     1506Void TComSampleAdaptiveOffset::xPCMRestoration(TComPic* pcPic)
     1507{
     1508  Bool  bPCMFilter = (pcPic->getSlice(0)->getSPS()->getUsePCM() && pcPic->getSlice(0)->getSPS()->getPCMFilterDisableFlag())? true : false;
     1509#if LOSSLESS_CODING
     1510  if(bPCMFilter || pcPic->getSlice(0)->getSPS()->getUseLossless())
     1511#else
     1512  if(bPCMFilter)
     1513#endif
     1514  {
     1515      for( UInt uiCUAddr = 0; uiCUAddr < pcPic->getNumCUsInFrame() ; uiCUAddr++ )
     1516      {
     1517          TComDataCU* pcCU = pcPic->getCU(uiCUAddr);
     1518          xPCMCURestoration(pcCU, 0, 0);
     1519      }
     1520  }
     1521}
     1522
     1523/** PCM CU restoration.
     1524 * \param pcCU pointer to current CU
     1525 * \param uiAbsPartIdx part index
     1526 * \param uiDepth CU depth
     1527 * \returns Void
     1528 */
     1529Void TComSampleAdaptiveOffset::xPCMCURestoration ( TComDataCU* pcCU, UInt uiAbsZorderIdx, UInt uiDepth )
     1530{
     1531  TComPic* pcPic     = pcCU->getPic();
     1532  UInt uiCurNumParts = pcPic->getNumPartInCU() >> (uiDepth<<1);
     1533  UInt uiQNumParts   = uiCurNumParts>>2;
     1534
     1535  // go to sub-CU
     1536  if( pcCU->getDepth(uiAbsZorderIdx) > uiDepth )
     1537  {
     1538    for ( UInt uiPartIdx = 0; uiPartIdx < 4; uiPartIdx++, uiAbsZorderIdx+=uiQNumParts )
     1539    {
     1540      UInt uiLPelX   = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsZorderIdx] ];
     1541      UInt uiTPelY   = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsZorderIdx] ];
     1542      if( ( uiLPelX < pcCU->getSlice()->getSPS()->getPicWidthInLumaSamples() ) && ( uiTPelY < pcCU->getSlice()->getSPS()->getPicHeightInLumaSamples() ) )
     1543        xPCMCURestoration( pcCU, uiAbsZorderIdx, uiDepth+1 );
     1544    }
     1545    return;
     1546  }
     1547
     1548  // restore PCM samples
     1549  if ((pcCU->getIPCMFlag(uiAbsZorderIdx)&& pcPic->getSlice(0)->getSPS()->getPCMFilterDisableFlag()) || pcCU->isLosslessCoded( uiAbsZorderIdx))
     1550  {
     1551    xPCMSampleRestoration (pcCU, uiAbsZorderIdx, uiDepth, TEXT_LUMA    );
     1552    xPCMSampleRestoration (pcCU, uiAbsZorderIdx, uiDepth, TEXT_CHROMA_U);
     1553    xPCMSampleRestoration (pcCU, uiAbsZorderIdx, uiDepth, TEXT_CHROMA_V);
     1554  }
     1555}
     1556
     1557/** PCM sample restoration.
     1558 * \param pcCU pointer to current CU
     1559 * \param uiAbsPartIdx part index
     1560 * \param uiDepth CU depth
     1561 * \param ttText texture component type
     1562 * \returns Void
     1563 */
     1564Void TComSampleAdaptiveOffset::xPCMSampleRestoration (TComDataCU* pcCU, UInt uiAbsZorderIdx, UInt uiDepth, TextType ttText)
     1565{
     1566  TComPicYuv* pcPicYuvRec = pcCU->getPic()->getPicYuvRec();
     1567  Pel* piSrc;
     1568  Pel* piPcm;
     1569  UInt uiStride;
     1570  UInt uiWidth;
     1571  UInt uiHeight;
     1572  UInt uiPcmLeftShiftBit;
     1573  UInt uiX, uiY;
     1574  UInt uiMinCoeffSize = pcCU->getPic()->getMinCUWidth()*pcCU->getPic()->getMinCUHeight();
     1575  UInt uiLumaOffset   = uiMinCoeffSize*uiAbsZorderIdx;
     1576  UInt uiChromaOffset = uiLumaOffset>>2;
     1577
     1578  if( ttText == TEXT_LUMA )
     1579  {
     1580    piSrc = pcPicYuvRec->getLumaAddr( pcCU->getAddr(), uiAbsZorderIdx);
     1581    piPcm = pcCU->getPCMSampleY() + uiLumaOffset;
     1582    uiStride  = pcPicYuvRec->getStride();
     1583    uiWidth  = (g_uiMaxCUWidth >> uiDepth);
     1584    uiHeight = (g_uiMaxCUHeight >> uiDepth);
     1585    if ( pcCU->isLosslessCoded(uiAbsZorderIdx) )
     1586    {
     1587      uiPcmLeftShiftBit = 0;
     1588    }
     1589    else
     1590    {
     1591        uiPcmLeftShiftBit = g_uiBitDepth + g_uiBitIncrement - pcCU->getSlice()->getSPS()->getPCMBitDepthLuma();
     1592    }
     1593  }
     1594  else
     1595  {
     1596    if( ttText == TEXT_CHROMA_U )
     1597    {
     1598      piSrc = pcPicYuvRec->getCbAddr( pcCU->getAddr(), uiAbsZorderIdx );
     1599      piPcm = pcCU->getPCMSampleCb() + uiChromaOffset;
     1600    }
     1601    else
     1602    {
     1603      piSrc = pcPicYuvRec->getCrAddr( pcCU->getAddr(), uiAbsZorderIdx );
     1604      piPcm = pcCU->getPCMSampleCr() + uiChromaOffset;
     1605    }
     1606
     1607    uiStride = pcPicYuvRec->getCStride();
     1608    uiWidth  = ((g_uiMaxCUWidth >> uiDepth)/2);
     1609    uiHeight = ((g_uiMaxCUWidth >> uiDepth)/2);
     1610    if ( pcCU->isLosslessCoded(uiAbsZorderIdx) )
     1611    {
     1612      uiPcmLeftShiftBit = 0;
     1613    }
     1614    else
     1615    {
     1616      uiPcmLeftShiftBit = g_uiBitDepth + g_uiBitIncrement - pcCU->getSlice()->getSPS()->getPCMBitDepthChroma();
     1617    }
     1618  }
     1619
     1620  for( uiY = 0; uiY < uiHeight; uiY++ )
     1621  {
     1622    for( uiX = 0; uiX < uiWidth; uiX++ )
     1623    {
     1624      piSrc[uiX] = (piPcm[uiX] << uiPcmLeftShiftBit);
     1625    }
     1626    piPcm += uiWidth;
     1627    piSrc += uiStride;
     1628  }
     1629}
     1630#endif
    13791631//! \}
Note: See TracChangeset for help on using the changeset viewer.