Ignore:
Timestamp:
1 Sep 2013, 22:47:26 (12 years ago)
Author:
tech
Message:

Merged DEV-2.0-dev0@604.

File:
1 edited

Legend:

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

    r443 r608  
    44 * granted under this license. 
    55 *
    6  * Copyright (c) 2010-2012, ITU/ISO/IEC
     6 * Copyright (c) 2010-2013, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
     
    6262TComSampleAdaptiveOffset::TComSampleAdaptiveOffset()
    6363{
    64 #if !LGE_SAO_MIGRATION_D0091
    65   m_pcPic = NULL;
    66 #endif
    67   m_iOffsetBo = NULL;
    6864  m_pClipTable = NULL;
    6965  m_pClipTableBase = NULL;
     66  m_pChromaClipTable = NULL;
     67  m_pChromaClipTableBase = NULL;
     68  m_iOffsetBo = NULL;
     69  m_iChromaOffsetBo = NULL;
    7070  m_lumaTableBo = NULL;
     71  m_chromaTableBo = NULL;
    7172  m_iUpBuff1 = NULL;
    7273  m_iUpBuff2 = NULL;
    7374  m_iUpBufft = NULL;
    7475  ipSwap = NULL;
    75 #if !LGE_SAO_MIGRATION_D0091
    76   m_pcYuvTmp = NULL;
    77 #endif
    7876
    7977  m_pTmpU1 = NULL;
     
    8179  m_pTmpL1 = NULL;
    8280  m_pTmpL2 = NULL;
    83   m_iLcuPartIdx = NULL;
    8481}
    8582
     
    8885
    8986}
    90 
    91 #if !LGE_SAO_MIGRATION_D0091
    92 const Int TComSampleAdaptiveOffset::m_aiNumPartsInRow[5] =
    93 {
    94   1,   //level 0
    95   2,   //level 1
    96   4,   //level 2
    97   8,   //level 3
    98   16   //level 4
    99 };
    100 
    101 const Int TComSampleAdaptiveOffset::m_aiNumPartsLevel[5] =
    102 {
    103   1,   //level 0
    104   4,   //level 1
    105   16,  //level 2
    106   64,  //level 3
    107   256  //level 4
    108 };
    109 #endif
    11087
    11188const Int TComSampleAdaptiveOffset::m_aiNumCulPartsLevel[5] =
     
    130107  0
    131108};
    132 #if !LGE_SAO_MIGRATION_D0091
    133 const UInt TComSampleAdaptiveOffset::m_iWeightSao[MAX_NUM_SAO_TYPE] =
    134 {
    135   2,
    136   2,
    137   2,
    138   2,
    139   1
    140 };
    141 
    142 const UInt TComSampleAdaptiveOffset::m_auiEoTable2D[9] =
    143 {
    144   1, //0   
    145   2, //1   
    146   3, //2
    147   0, //3
    148   0, //4
    149   0, //5 
    150   4, //6 
    151   5, //7
    152   6
    153 };
    154 #endif
    155 
    156 Int TComSampleAdaptiveOffset::m_iNumClass[MAX_NUM_SAO_TYPE] =
     109
     110const Int TComSampleAdaptiveOffset::m_iNumClass[MAX_NUM_SAO_TYPE] =
    157111{
    158112  SAO_EO_LEN,
     
    163117};
    164118
    165 UInt TComSampleAdaptiveOffset::m_uiMaxDepth = SAO_MAX_DEPTH;
     119const UInt TComSampleAdaptiveOffset::m_uiMaxDepth = SAO_MAX_DEPTH;
    166120
    167121
     
    169123 * \param   level,  row,  col
    170124 */
    171 Int  TComSampleAdaptiveOffset::convertLevelRowCol2Idx(int level, int row, int col)
     125Int  TComSampleAdaptiveOffset::convertLevelRowCol2Idx(Int level, Int row, Int col)
    172126{
    173127  Int idx;
     
    194148  return idx;
    195149}
    196 #if !LGE_SAO_MIGRATION_D0091
    197 /** convert quadtree Idx to Level, Row, and Col
    198  * \param  idx,  *level,  *row,  *col
    199  */
    200 void TComSampleAdaptiveOffset::convertIdx2LevelRowCol(int idx, int *level, int *row, int *col)
    201 {
    202   if (idx == 0)
    203   {
    204     *level = 0;
    205     *row = 0;
    206     *col = 0;
    207   }
    208   else if (idx>=1 && idx<=4)
    209   {
    210     *level = 1;
    211     *row = (idx-1) / 2;
    212     *col = (idx-1) % 2;
    213   }
    214   else if (idx>=5 && idx<=20)
    215   {
    216     *level = 2;
    217     *row = (idx-5) / 4;
    218     *col = (idx-5) % 4;
    219   }
    220   else if (idx>=21 && idx<=84)
    221   {
    222     *level = 3;
    223     *row = (idx-21) / 8;
    224     *col = (idx-21) % 8;
    225   }
    226   else // (idx>=85 && idx<=340)
    227   {
    228     *level = 4;
    229     *row = (idx-85) / 16;
    230     *col = (idx-85) % 16;
    231   }
    232 }
    233 #endif
     150
    234151/** create SampleAdaptiveOffset memory.
    235152 * \param
    236153 */
    237 Void TComSampleAdaptiveOffset::create( UInt uiSourceWidth, UInt uiSourceHeight, UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uiMaxCUDepth)
     154Void TComSampleAdaptiveOffset::create( UInt uiSourceWidth, UInt uiSourceHeight, UInt uiMaxCUWidth, UInt uiMaxCUHeight )
    238155{
    239156  m_iPicWidth  = uiSourceWidth;
     
    249166  m_iNumCuInHeight += ( m_iPicHeight % m_uiMaxCUHeight ) ? 1 : 0;
    250167
    251   Int iMaxSplitLevelHeight = (Int)(logf((float)m_iNumCuInHeight)/logf(2.0));
    252   Int iMaxSplitLevelWidth  = (Int)(logf((float)m_iNumCuInWidth )/logf(2.0));
     168  Int iMaxSplitLevelHeight = (Int)(logf((Float)m_iNumCuInHeight)/logf(2.0));
     169  Int iMaxSplitLevelWidth  = (Int)(logf((Float)m_iNumCuInWidth )/logf(2.0));
    253170
    254171  m_uiMaxSplitLevel = (iMaxSplitLevelHeight < iMaxSplitLevelWidth)?(iMaxSplitLevelHeight):(iMaxSplitLevelWidth);
     
    258175  m_iNumTotalParts  = max(3,m_aiNumCulPartsLevel[m_uiMaxSplitLevel]);
    259176
    260   UInt uiInternalBitDepth = g_uiBitDepth+g_uiBitIncrement;
    261   UInt uiPixelRange = 1<<uiInternalBitDepth;
    262   UInt uiBoRangeShift = uiInternalBitDepth - SAO_BO_BITS;
    263 
    264   m_lumaTableBo = new Pel [uiPixelRange];
    265   for (Int k2=0; k2<uiPixelRange; k2++)
    266   {
    267     m_lumaTableBo[k2] = 1 + (k2>>uiBoRangeShift);
    268   }
     177  UInt uiPixelRangeY = 1 << g_bitDepthY;
     178  UInt uiBoRangeShiftY = g_bitDepthY - SAO_BO_BITS;
     179
     180  m_lumaTableBo = new Pel [uiPixelRangeY];
     181  for (Int k2=0; k2<uiPixelRangeY; k2++)
     182  {
     183    m_lumaTableBo[k2] = 1 + (k2>>uiBoRangeShiftY);
     184  }
     185
     186  UInt uiPixelRangeC = 1 << g_bitDepthC;
     187  UInt uiBoRangeShiftC = g_bitDepthC - SAO_BO_BITS;
     188
     189  m_chromaTableBo = new Pel [uiPixelRangeC];
     190  for (Int k2=0; k2<uiPixelRangeC; k2++)
     191  {
     192    m_chromaTableBo[k2] = 1 + (k2>>uiBoRangeShiftC);
     193  }
     194
    269195  m_iUpBuff1 = new Int[m_iPicWidth+2];
    270196  m_iUpBuff2 = new Int[m_iPicWidth+2];
     
    276202  Pel i;
    277203
    278   UInt uiMaxY  = g_uiIBDI_MAX;
     204  UInt uiMaxY  = (1 << g_bitDepthY) - 1;;
    279205  UInt uiMinY  = 0;
    280206
     
    301227  m_pClipTable = &(m_pClipTableBase[iCRangeExt]);
    302228
    303   m_iLcuPartIdx = new Int [m_iNumCuInHeight*m_iNumCuInWidth];
     229  UInt uiMaxC  = (1 << g_bitDepthC) - 1;
     230  UInt uiMinC  = 0;
     231
     232  Int iCRangeExtC = uiMaxC>>1;
     233
     234  m_pChromaClipTableBase = new Pel[uiMaxC+2*iCRangeExtC];
     235  m_iChromaOffsetBo      = new Int[uiMaxC+2*iCRangeExtC];
     236
     237  for(i=0;i<(uiMinC+iCRangeExtC);i++)
     238  {
     239    m_pChromaClipTableBase[i] = uiMinC;
     240  }
     241
     242  for(i=uiMinC+iCRangeExtC;i<(uiMaxC+  iCRangeExtC);i++)
     243  {
     244    m_pChromaClipTableBase[i] = i-iCRangeExtC;
     245  }
     246
     247  for(i=uiMaxC+iCRangeExtC;i<(uiMaxC+2*iCRangeExtC);i++)
     248  {
     249    m_pChromaClipTableBase[i] = uiMaxC;
     250  }
     251
     252  m_pChromaClipTable = &(m_pChromaClipTableBase[iCRangeExtC]);
     253
    304254  m_pTmpL1 = new Pel [m_uiMaxCUHeight+1];
    305255  m_pTmpL2 = new Pel [m_uiMaxCUHeight+1];
     
    326276  }
    327277
    328 #if LGE_SAO_MIGRATION_D0091
     278  if (m_pChromaClipTableBase)
     279  {
     280    delete [] m_pChromaClipTableBase; m_pChromaClipTableBase = NULL;
     281  }
     282  if (m_iChromaOffsetBo)
     283  {
     284    delete [] m_iChromaOffsetBo; m_iChromaOffsetBo = NULL;
     285  }
     286  if (m_chromaTableBo)
     287  {
     288    delete[] m_chromaTableBo; m_chromaTableBo = NULL;
     289  }
     290
    329291  if (m_iUpBuff1)
    330292  {
    331       m_iUpBuff1--;
    332       delete [] m_iUpBuff1; m_iUpBuff1 = NULL;
     293    m_iUpBuff1--;
     294    delete [] m_iUpBuff1; m_iUpBuff1 = NULL;
    333295  }
    334296  if (m_iUpBuff2)
    335297  {
    336       m_iUpBuff2--;
    337       delete [] m_iUpBuff2; m_iUpBuff2 = NULL;
     298    m_iUpBuff2--;
     299    delete [] m_iUpBuff2; m_iUpBuff2 = NULL;
    338300  }
    339301  if (m_iUpBufft)
    340302  {
    341       m_iUpBufft--;
    342       delete [] m_iUpBufft; m_iUpBufft = NULL;
    343   }
    344 #else
    345   m_iUpBuff1--;
    346   m_iUpBuff2--;
    347   m_iUpBufft--;
    348 
    349   if (m_iUpBuff1)
    350   {
    351     delete [] m_iUpBuff1; m_iUpBuff1 = NULL;
    352   }
    353   if (m_iUpBuff2)
    354   {
    355     delete [] m_iUpBuff2; m_iUpBuff2 = NULL;
    356   }
    357   if (m_iUpBufft)
    358   {
     303    m_iUpBufft--;
    359304    delete [] m_iUpBufft; m_iUpBufft = NULL;
    360305  }
    361 #endif
    362306  if (m_pTmpL1)
    363307  {
     
    375319  {
    376320    delete [] m_pTmpU2; m_pTmpU2 = NULL;
    377   }
    378   if(m_iLcuPartIdx)
    379   {
    380     delete []m_iLcuPartIdx; m_iLcuPartIdx = NULL;
    381321  }
    382322}
     
    394334  initSAOParam(pcSaoParam, 0, 0, 0, -1, 0, m_iNumCuInWidth-1,  0, m_iNumCuInHeight-1,1);
    395335  initSAOParam(pcSaoParam, 0, 0, 0, -1, 0, m_iNumCuInWidth-1,  0, m_iNumCuInHeight-1,2);
    396 #if !LGE_SAO_MIGRATION_D0091
    397   for(Int j=0;j<MAX_NUM_SAO_TYPE;j++)
    398   {
    399     pcSaoParam->iNumClass[j] = m_iNumClass[j];
    400   }
    401 #endif
    402336  pcSaoParam->numCuInWidth  = m_iNumCuInWidth;
    403337  pcSaoParam->numCuInHeight = m_iNumCuInHeight;
     
    433367  pSaoPart->iLength     =  0;
    434368
    435 #if LGE_SAO_MIGRATION_D0091
    436369  pSaoPart->subTypeIdx = 0;
    437 #else
    438   pSaoPart->bandPosition = 0;
    439 #endif
    440370
    441371  for (j=0;j<MAX_NUM_SAO_OFFSETS;j++)
     
    546476  for(Int c=0; c<iNumComponet; c++)
    547477  {
    548 #if LGE_SAO_MIGRATION_D0091
    549     if (c<2)
    550     {
     478if (c<2)
     479  {
    551480    pcSaoParam->bSaoFlag[c] = 0;
    552     }
    553 #else
    554     pcSaoParam->bSaoFlag[c] = 0;
    555 #endif
     481  }
    556482    for(Int i=0; i< m_aiNumCulPartsLevel[m_uiMaxSplitLevel]; i++)
    557483    {
     
    563489      pcSaoParam->psSaoPart[c][i].iMinDist      = MAX_INT;
    564490      pcSaoParam->psSaoPart[c][i].iMinRate      = MAX_INT;
    565 #if LGE_SAO_MIGRATION_D0091
    566491      pcSaoParam->psSaoPart[c][i].subTypeIdx    = 0;
    567 #else
    568       pcSaoParam->psSaoPart[c][i].bandPosition = 0;
    569 #endif
    570492      for (Int j=0;j<MAX_NUM_SAO_OFFSETS;j++)
    571493      {
     
    587509 * \param   x
    588510 */
    589 inline int xSign(int x)
    590 {
    591   return ((x >> 31) | ((int)( (((unsigned int) -x)) >> 31)));
     511inline Int xSign(Int x)
     512{
     513  return ((x >> 31) | ((Int)( (((UInt) -x)) >> 31)));
    592514}
    593515
    594516/** initialize variables for SAO process
    595517 * \param  pcPic picture data pointer
    596  * \param  numSlicesInPic number of slices in picture
    597  */
    598 Void TComSampleAdaptiveOffset::createPicSaoInfo(TComPic* pcPic, Int numSlicesInPic)
     518 */
     519Void TComSampleAdaptiveOffset::createPicSaoInfo(TComPic* pcPic)
    599520{
    600521  m_pcPic   = pcPic;
    601   m_uiNumSlicesInPic = numSlicesInPic;
    602 #if LGE_SAO_MIGRATION_D0091
    603   m_iSGDepth         = 0;
    604 #else
    605   m_iSGDepth         = pcPic->getSliceGranularityForNDBFilter();
    606 #endif
    607522  m_bUseNIF = ( pcPic->getIndependentSliceBoundaryForNDBFilter() || pcPic->getIndependentTileBoundaryForNDBFilter() );
    608523  if(m_bUseNIF)
     
    650565      posOffset = (yPos* stride) + xPos;
    651566
    652       processSaoBlock(pPicDec+ posOffset, pPicRest+ posOffset, stride, iSaoType, xPos, yPos, width, height, pbBorderAvail);
     567      processSaoBlock(pPicDec+ posOffset, pPicRest+ posOffset, stride, iSaoType, width, height, pbBorderAvail, iYCbCr);
    653568    }
    654569  }
     
    666581 * \param  pbBorderAvail availabilities of block border pixels
    667582 */
    668 Void TComSampleAdaptiveOffset::processSaoBlock(Pel* pDec, Pel* pRest, Int stride, Int saoType, UInt xPos, UInt yPos, UInt width, UInt height, Bool* pbBorderAvail)
     583Void TComSampleAdaptiveOffset::processSaoBlock(Pel* pDec, Pel* pRest, Int stride, Int saoType, UInt width, UInt height, Bool* pbBorderAvail, Int iYCbCr)
    669584{
    670585  //variables
     
    672587  Int signLeft,signRight,signDown,signDown1;
    673588  UInt edgeType;
     589  Pel *pClipTbl = (iYCbCr==0)?m_pClipTable:m_pChromaClipTable;
     590  Int *pOffsetBo = (iYCbCr==0)?m_iOffsetBo: m_iChromaOffsetBo;
    674591
    675592  switch (saoType)
     
    689606          signLeft  = -signRight;
    690607
    691           pRest[x] = m_pClipTable[pDec[x] + m_iOffsetEo[edgeType]];
     608          pRest[x] = pClipTbl[pDec[x] + m_iOffsetEo[edgeType]];
    692609        }
    693610        pDec  += stride;
     
    717634          m_iUpBuff1[x]= -signDown;
    718635
    719           pRest[x] = m_pClipTable[pDec[x] + m_iOffsetEo[edgeType]];
     636          pRest[x] = pClipTbl[pDec[x] + m_iOffsetEo[edgeType]];
    720637        }
    721638        pDec  += stride;
     
    744661        x= 0;
    745662        edgeType      =  xSign(pDec[x] - pDec[x- posShift]) - m_iUpBuff1[x+1] + 2;
    746         pRest[x] = m_pClipTable[pDec[x] + m_iOffsetEo[edgeType]];
     663        pRest[x] = pClipTbl[pDec[x] + m_iOffsetEo[edgeType]];
    747664
    748665      }
     
    752669        {
    753670          edgeType      =  xSign(pDec[x] - pDec[x- posShift]) - m_iUpBuff1[x+1] + 2;
    754           pRest[x] = m_pClipTable[pDec[x] + m_iOffsetEo[edgeType]];
     671          pRest[x] = pClipTbl[pDec[x] + m_iOffsetEo[edgeType]];
    755672        }
    756673      }
     
    766683          signDown1      =  xSign(pDec[x] - pDec[x+ posShift]) ;
    767684          edgeType      =  signDown1 + m_iUpBuff1[x] + 2;
    768           pRest[x] = m_pClipTable[pDec[x] + m_iOffsetEo[edgeType]];
     685          pRest[x] = pClipTbl[pDec[x] + m_iOffsetEo[edgeType]];
    769686
    770687          m_iUpBufft[x+1] = -signDown1;
     
    786703        {
    787704          edgeType =  xSign(pDec[x] - pDec[x+ posShift]) + m_iUpBuff1[x] + 2;
    788           pRest[x] = m_pClipTable[pDec[x] + m_iOffsetEo[edgeType]];
     705          pRest[x] = pClipTbl[pDec[x] + m_iOffsetEo[edgeType]];
    789706        }
    790707      }
     
    793710        x= width -1;
    794711        edgeType =  xSign(pDec[x] - pDec[x+ posShift]) + m_iUpBuff1[x] + 2;
    795         pRest[x] = m_pClipTable[pDec[x] + m_iOffsetEo[edgeType]];
     712        pRest[x] = pClipTbl[pDec[x] + m_iOffsetEo[edgeType]];
    796713      }
    797714      break;
     
    818735        {
    819736          edgeType = xSign(pDec[x] - pDec[x- posShift]) -m_iUpBuff1[x-1] + 2;
    820           pRest[x] = m_pClipTable[pDec[x] + m_iOffsetEo[edgeType]];
     737          pRest[x] = pClipTbl[pDec[x] + m_iOffsetEo[edgeType]];
    821738        }
    822739      }
     
    825742        x= width-1;
    826743        edgeType = xSign(pDec[x] - pDec[x- posShift]) -m_iUpBuff1[x-1] + 2;
    827         pRest[x] = m_pClipTable[pDec[x] + m_iOffsetEo[edgeType]];
     744        pRest[x] = pClipTbl[pDec[x] + m_iOffsetEo[edgeType]];
    828745      }
    829746      pDec  += stride;
     
    838755          edgeType      =  signDown1 + m_iUpBuff1[x] + 2;
    839756
    840           pRest[x] = m_pClipTable[pDec[x] + m_iOffsetEo[edgeType]];
     757          pRest[x] = pClipTbl[pDec[x] + m_iOffsetEo[edgeType]];
    841758          m_iUpBuff1[x-1] = -signDown1;
    842759        }
     
    852769        x= 0;
    853770        edgeType = xSign(pDec[x] - pDec[x+ posShift]) + m_iUpBuff1[x] + 2;
    854         pRest[x] = m_pClipTable[pDec[x] + m_iOffsetEo[edgeType]];
     771        pRest[x] = pClipTbl[pDec[x] + m_iOffsetEo[edgeType]];
    855772
    856773      }
     
    860777        {
    861778          edgeType = xSign(pDec[x] - pDec[x+ posShift]) + m_iUpBuff1[x] + 2;
    862           pRest[x] = m_pClipTable[pDec[x] + m_iOffsetEo[edgeType]];
     779          pRest[x] = pClipTbl[pDec[x] + m_iOffsetEo[edgeType]];
    863780        }
    864781      }
     
    871788        for (x=0; x< width; x++)
    872789        {
    873           pRest[x] = m_iOffsetBo[pDec[x]];
     790          pRest[x] = pOffsetBo[pDec[x]];
    874791        }
    875792        pRest += stride;
     
    916833  Pel *pTmpL;
    917834  Pel *pTmpU;
     835  Pel *pClipTbl = NULL;
     836  Int *pOffsetBo = NULL;
    918837
    919838  iPicWidthTmp  = m_iPicWidth  >> iIsChroma;
     
    965884  }
    966885
     886  pClipTbl = (iYCbCr==0)? m_pClipTable:m_pChromaClipTable;
     887  pOffsetBo = (iYCbCr==0)? m_iOffsetBo:m_iChromaOffsetBo;
     888
    967889  switch (iSaoType)
    968890  {
     
    980902          iSignLeft  = -iSignRight;
    981903
    982           pRec[x] = m_pClipTable[pRec[x] + m_iOffsetEo[uiEdgeType]];
     904          pRec[x] = pClipTbl[pRec[x] + m_iOffsetEo[uiEdgeType]];
    983905        }
    984906        pRec += iStride;
     
    1005927          uiEdgeType = iSignDown + m_iUpBuff1[x] + 2;
    1006928          m_iUpBuff1[x]= -iSignDown;
    1007           pRec[x] = m_pClipTable[pRec[x] + m_iOffsetEo[uiEdgeType]];
     929
     930          pRec[x] = pClipTbl[pRec[x] + m_iOffsetEo[uiEdgeType]];
    1008931        }
    1009932        pRec += iStride;
     
    1036959          uiEdgeType      =  iSignDown1 + m_iUpBuff1[x] + 2;
    1037960          m_iUpBufft[x+1] = -iSignDown1;
    1038           pRec[x] = m_pClipTable[pRec[x] + m_iOffsetEo[uiEdgeType]];
     961          pRec[x] = pClipTbl[pRec[x] + m_iOffsetEo[uiEdgeType]];
    1039962        }
    1040963        m_iUpBufft[iStartX] = iSignDown2;
     
    1071994        uiEdgeType      =  iSignDown1 + m_iUpBuff1[x] + 2;
    1072995        m_iUpBuff1[x-1] = -iSignDown1;
    1073         pRec[x] = m_pClipTable[pRec[x] + m_iOffsetEo[uiEdgeType]];
     996        pRec[x] = pClipTbl[pRec[x] + m_iOffsetEo[uiEdgeType]];
    1074997        for (x=iStartX+1; x<iEndX; x++)
    1075998        {
     
    10771000          uiEdgeType      =  iSignDown1 + m_iUpBuff1[x] + 2;
    10781001          m_iUpBuff1[x-1] = -iSignDown1;
    1079           pRec[x] = m_pClipTable[pRec[x] + m_iOffsetEo[uiEdgeType]];
     1002          pRec[x] = pClipTbl[pRec[x] + m_iOffsetEo[uiEdgeType]];
    10801003        }
    10811004        m_iUpBuff1[iEndX-1] = xSign(pRec[iEndX-1 + iStride] - pRec[iEndX]);
     
    10911014        for (x=0; x<iLcuWidth; x++)
    10921015        {
    1093           pRec[x] = m_iOffsetBo[pRec[x]];
     1016          pRec[x] = pOffsetBo[pRec[x]];
    10941017        }
    10951018        pRec += iStride;
     
    11091032 * \param pcPic, pcSaoParam 
    11101033 */
    1111 Void TComSampleAdaptiveOffset::SAOProcess(TComPic* pcPic, SAOParam* pcSaoParam)
    1112 {
    1113 #if LGE_SAO_MIGRATION_D0091
    1114   if (pcSaoParam->bSaoFlag[0] || pcSaoParam->bSaoFlag[1])
    1115 #else
    1116   if (pcSaoParam->bSaoFlag[0])
    1117 #endif
    1118   {
    1119 #if FULL_NBIT
    1120     m_uiSaoBitIncrease = g_uiBitDepth + (g_uiBitDepth-8) - min((Int)(g_uiBitDepth + (g_uiBitDepth-8)), 10);
    1121 #else
    1122     m_uiSaoBitIncrease = g_uiBitDepth + g_uiBitIncrement - min((Int)(g_uiBitDepth + g_uiBitIncrement), 10);
    1123 #endif
     1034Void TComSampleAdaptiveOffset::SAOProcess(SAOParam* pcSaoParam)
     1035{
     1036  {
     1037    m_uiSaoBitIncreaseY = max(g_bitDepthY - 10, 0);
     1038    m_uiSaoBitIncreaseC = max(g_bitDepthC - 10, 0);
    11241039
    11251040    if(m_bUseNIF)
     
    11271042      m_pcPic->getPicYuvRec()->copyToPic(m_pcYuvTmp);
    11281043    }
    1129 #if LGE_SAO_MIGRATION_D0091
    11301044    if (m_saoLcuBasedOptimization)
    1131 #else
    1132     if (m_saoInterleavingFlag)
    1133 #endif
    11341045    {
    11351046      pcSaoParam->oneUnitFlag[0] = 0; 
     
    11381049    }
    11391050    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
    1151     processSaoUnitAll( pcSaoParam->saoLcuParam[iY], pcSaoParam->oneUnitFlag[iY], iY);
    1152 
    1153     Int iCb = 1;
    1154     Int iCr = 2;
    1155     if (pcSaoParam->bSaoFlag[iCb])
    1156     {
    1157       processSaoUnitAll( pcSaoParam->saoLcuParam[iCb], pcSaoParam->oneUnitFlag[iCb], iCb);
    1158     }
    1159     if (pcSaoParam->bSaoFlag[iCr])
    1160     {
    1161       processSaoUnitAll( pcSaoParam->saoLcuParam[iCr], pcSaoParam->oneUnitFlag[iCr], iCr);
    1162     }
    1163 #endif
     1051    {
     1052      processSaoUnitAll( pcSaoParam->saoLcuParam[iY], pcSaoParam->oneUnitFlag[iY], iY);
     1053    }
     1054    {
     1055       processSaoUnitAll( pcSaoParam->saoLcuParam[1], pcSaoParam->oneUnitFlag[1], 1);//Cb
     1056       processSaoUnitAll( pcSaoParam->saoLcuParam[2], pcSaoParam->oneUnitFlag[2], 2);//Cr
     1057    }
    11641058    m_pcPic = NULL;
    11651059  }
     
    12121106  memcpy(m_pTmpU1, pRec, sizeof(Pel)*picWidthTmp);
    12131107
    1214   int  i;
     1108  Int  i;
    12151109  UInt edgeType;
    12161110  Pel* ppLumaTable = NULL;
     1111  Pel* pClipTable = NULL;
     1112  Int* pOffsetBo = NULL;
    12171113  Int  typeIdx;
    12181114
    1219 #if LGE_SAO_MIGRATION_D0091
    12201115  Int offset[LUMA_GROUP_NUM+1];
    1221 #else
    1222   static Int offset[LUMA_GROUP_NUM+1];
    1223 #endif
    12241116  Int idxX;
    12251117  Int idxY;
     
    12311123  Int isChroma = (yCbCr == 0) ? 0:1;
    12321124  Bool mergeLeftFlag;
    1233 #if LGE_SAO_MIGRATION_D0091
     1125  Int saoBitIncrease = (yCbCr == 0) ? m_uiSaoBitIncreaseY : m_uiSaoBitIncreaseC;
     1126
     1127  pOffsetBo = (yCbCr==0) ? m_iOffsetBo : m_iChromaOffsetBo;
     1128
    12341129  offset[0] = 0;
    1235 #endif
    12361130  for (idxY = 0; idxY< frameHeightInCU; idxY++)
    12371131  {
     
    12691163    {
    12701164      addr = idxY * frameWidthInCU + idxX;
     1165
    12711166      if (oneUnitFlag)
    12721167      {
     
    12921187            for (i=0; i<saoLcuParam[addr].length; i++)
    12931188            {
    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
    1297               offset[ (saoLcuParam[addr].bandPosition +i)%SAO_MAX_BO_CLASSES  +1] = saoLcuParam[addr].offset[i] << m_uiSaoBitIncrease;
    1298 #endif
     1189              offset[ (saoLcuParam[addr].subTypeIdx +i)%SAO_MAX_BO_CLASSES  +1] = saoLcuParam[addr].offset[i] << saoBitIncrease;
    12991190            }
    13001191
    1301             ppLumaTable = m_lumaTableBo;
    1302 
    1303 #if FULL_NBIT
    1304             for (i=0;i<(1<<(g_uiBitDepth));i++)
    1305 #else
    1306             for (i=0;i<(1<<(g_uiBitIncrement+8));i++)
    1307 #endif
     1192            ppLumaTable = (yCbCr==0)?m_lumaTableBo:m_chromaTableBo;
     1193            pClipTable = (yCbCr==0)?m_pClipTable:m_pChromaClipTable;
     1194
     1195            Int bitDepth = (yCbCr==0) ? g_bitDepthY : g_bitDepthC;
     1196            for (i=0;i<(1<<bitDepth);i++)
    13081197            {
    1309               m_iOffsetBo[i] = m_pClipTable[i + offset[ppLumaTable[i]]];
     1198              pOffsetBo[i] = pClipTable[i + offset[ppLumaTable[i]]];
    13101199            }
    13111200
     
    13151204            for (i=0;i<saoLcuParam[addr].length;i++)
    13161205            {
    1317               offset[i+1] = saoLcuParam[addr].offset[i] << m_uiSaoBitIncrease;
     1206              offset[i+1] = saoLcuParam[addr].offset[i] << saoBitIncrease;
    13181207            }
    13191208            for (edgeType=0;edgeType<6;edgeType++)
     
    13751264      saoLcuParam[i].offset[j] = 0;
    13761265    }
    1377 #if LGE_SAO_MIGRATION_D0091
    1378     saoLcuParam[i].subTypeIdx   = 0;
    1379 #else
    1380     saoLcuParam[i].bandPosition = 0;
    1381 #endif
     1266    saoLcuParam[i].subTypeIdx = 0;
    13821267  }
    13831268}
     
    14281313      saoLcuParam[addr].partIdxTmp = (Int)partIdx;
    14291314      saoLcuParam[addr].typeIdx    = saoQTPart[partIdx].iBestType;
    1430 #if LGE_SAO_MIGRATION_D0091
    1431       saoLcuParam[addr].subTypeIdx   = saoQTPart[partIdx].subTypeIdx;
    1432 #else
    1433       saoLcuParam[addr].bandPosition = saoQTPart[partIdx].bandPosition;
    1434 #endif
     1315      saoLcuParam[addr].subTypeIdx = saoQTPart[partIdx].subTypeIdx;
    14351316      if (saoLcuParam[addr].typeIdx!=-1)
    14361317      {
     
    14441325      {
    14451326        saoLcuParam[addr].length    = 0;
    1446 #if LGE_SAO_MIGRATION_D0091
    14471327        saoLcuParam[addr].subTypeIdx = saoQTPart[partIdx].subTypeIdx;
    1448 #else
    1449         saoLcuParam[addr].bandPosition = saoQTPart[partIdx].bandPosition;
    1450 #endif
    14511328        for (j=0;j<MAX_NUM_SAO_OFFSETS;j++)
    14521329        {
     
    14581335}
    14591336
    1460 #if LGE_SAO_MIGRATION_D0091
    14611337Void TComSampleAdaptiveOffset::resetSaoUnit(SaoLcuParam* saoUnit)
    14621338{
     
    15071383{
    15081384  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       }
     1385
     1386  if(bPCMFilter || pcPic->getSlice(0)->getPPS()->getTransquantBypassEnableFlag())
     1387  {
     1388    for( UInt uiCUAddr = 0; uiCUAddr < pcPic->getNumCUsInFrame() ; uiCUAddr++ )
     1389    {
     1390      TComDataCU* pcCU = pcPic->getCU(uiCUAddr);
     1391
     1392      xPCMCURestoration(pcCU, 0, 0);
     1393    }
    15201394  }
    15211395}
     
    15831457    uiWidth  = (g_uiMaxCUWidth >> uiDepth);
    15841458    uiHeight = (g_uiMaxCUHeight >> uiDepth);
    1585     if ( pcCU->isLosslessCoded(uiAbsZorderIdx) )
     1459    if ( pcCU->isLosslessCoded(uiAbsZorderIdx) && !pcCU->getIPCMFlag(uiAbsZorderIdx) )
    15861460    {
    15871461      uiPcmLeftShiftBit = 0;
     
    15891463    else
    15901464    {
    1591         uiPcmLeftShiftBit = g_uiBitDepth + g_uiBitIncrement - pcCU->getSlice()->getSPS()->getPCMBitDepthLuma();
     1465      uiPcmLeftShiftBit = g_bitDepthY - pcCU->getSlice()->getSPS()->getPCMBitDepthLuma();
    15921466    }
    15931467  }
     
    16081482    uiWidth  = ((g_uiMaxCUWidth >> uiDepth)/2);
    16091483    uiHeight = ((g_uiMaxCUWidth >> uiDepth)/2);
    1610     if ( pcCU->isLosslessCoded(uiAbsZorderIdx) )
     1484    if ( pcCU->isLosslessCoded(uiAbsZorderIdx) && !pcCU->getIPCMFlag(uiAbsZorderIdx) )
    16111485    {
    16121486      uiPcmLeftShiftBit = 0;
     
    16141488    else
    16151489    {
    1616       uiPcmLeftShiftBit = g_uiBitDepth + g_uiBitIncrement - pcCU->getSlice()->getSPS()->getPCMBitDepthChroma();
     1490      uiPcmLeftShiftBit = g_bitDepthC - pcCU->getSlice()->getSPS()->getPCMBitDepthChroma();
    16171491    }
    16181492  }
     
    16281502  }
    16291503}
    1630 #endif
     1504
    16311505//! \}
Note: See TracChangeset for help on using the changeset viewer.