Changeset 852 in 3DVCSoftware for branches/HTM-10.0-dev0/source/Lib/TLibCommon


Ignore:
Timestamp:
13 Feb 2014, 22:34:17 (11 years ago)
Author:
tech
Message:

Update HM-12.0 -> HM-13.0.

Location:
branches/HTM-10.0-dev0/source/Lib/TLibCommon
Files:
53 edited

Legend:

Unmodified
Added
Removed
  • branches/HTM-10.0-dev0/source/Lib/TLibCommon/AccessUnit.h

    r608 r852  
    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 *
  • branches/HTM-10.0-dev0/source/Lib/TLibCommon/CommonDef.h

    r849 r852  
    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 *
     
    6161#if H_MV
    6262#define NV_VERSION        "10.0"                ///< Current software version
    63 #define HM_VERSION        "12.0"                ///<
     63#define HM_VERSION        "13.0"                ///<
    6464#else
    65 #define NV_VERSION        "12.0"                 ///< Current software version
     65#define NV_VERSION        "13.0"                 ///< Current software version
    6666#endif
    6767
     
    247247 
    248248  NAL_UNIT_CODED_SLICE_TSA_N,     // 2
    249   NAL_UNIT_CODED_SLICE_TLA_R,       // 3
     249  NAL_UNIT_CODED_SLICE_TSA_R,       // 3
    250250 
    251251  NAL_UNIT_CODED_SLICE_STSA_N,    // 4
  • branches/HTM-10.0-dev0/source/Lib/TLibCommon/ContextModel.cpp

    r608 r852  
    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 *
  • branches/HTM-10.0-dev0/source/Lib/TLibCommon/ContextModel.h

    r608 r852  
    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 *
  • branches/HTM-10.0-dev0/source/Lib/TLibCommon/ContextModel3DBuffer.cpp

    r608 r852  
    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 *
  • branches/HTM-10.0-dev0/source/Lib/TLibCommon/ContextModel3DBuffer.h

    r608 r852  
    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 *
  • branches/HTM-10.0-dev0/source/Lib/TLibCommon/ContextTables.h

    r833 r852  
    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 *
     
    4242//! \ingroup TLibCommon
    4343//! \{
    44 #define FIX827 1 ///< Fix for issue #827: CABAC init tables
    45 #define FIX712 1 ///< Fix for issue #712: CABAC init tables
    4644
    4745// ====================================================================================================================
     
    5856
    5957#define NUM_PART_SIZE_CTX             4       ///< number of context models for partition size
    60 #define NUM_CU_AMP_CTX                1       ///< number of context models for partition size (AMP)
    6158#define NUM_PRED_MODE_CTX             1       ///< number of context models for prediction mode
    6259
     
    6966#define NUM_REF_NO_CTX                2       ///< number of context models for reference index
    7067#define NUM_TRANS_SUBDIV_FLAG_CTX     3       ///< number of context models for transform subdivision flags
    71 #define NUM_QT_CBF_CTX                5       ///< number of context models for QT CBF
     68#define NUM_QT_CBF_CTX                4       ///< number of context models for QT CBF
    7269#define NUM_QT_ROOT_CBF_CTX           1       ///< number of context models for QT ROOT CBF
    7370#define NUM_DELTA_QP_CTX              3       ///< number of context models for dQP
     
    8885#define NUM_ABS_FLAG_CTX_CHROMA        2      ///< number of context models for greater than 2 flag of chroma
    8986
    90 #define NUM_MVP_IDX_CTX               2       ///< number of context models for MVP index
     87#define NUM_MVP_IDX_CTX               1       ///< number of context models for MVP index
    9188
    9289#define NUM_SAO_MERGE_FLAG_CTX        1       ///< number of context models for SAO merge flags
     
    199196INIT_PART_SIZE[3][NUM_PART_SIZE_CTX] = 
    200197{
    201   { 154,  139,  CNU,  CNU, },
    202   { 154,  139,  CNU,  CNU, },
    203   { 184,  CNU,  CNU,  CNU, },
    204 };
    205 
    206 static const UChar
    207 INIT_CU_AMP_POS[3][NUM_CU_AMP_CTX] = 
    208 {
    209   { 154, },
    210   { 154, },
    211   { CNU, },
     198  { 154,  139,  154,  154 },
     199  { 154,  139,  154,  154 },
     200  { 184,  CNU,  CNU,  CNU },
    212201};
    213202
     
    271260INIT_QT_CBF[3][2*NUM_QT_CBF_CTX] = 
    272261{
    273   { 153,  111,  CNU,  CNU,  CNU,  149,   92,  167,  CNU,  CNU, },
    274   { 153,  111,  CNU,  CNU,  CNU,  149,  107,  167,  CNU,  CNU, },
    275   { 111,  141,  CNU,  CNU,  CNU,   94,  138,  182,  CNU,  CNU, },
     262  { 153,  111,  CNU,  CNU,   149,   92,  167,  154 },
     263  { 153,  111,  CNU,  CNU,   149,  107,  167,  154 },
     264  { 111,  141,  CNU,  CNU,    94,  138,  182,  154 },
    276265};
    277266
     
    339328INIT_MVP_IDX[3][NUM_MVP_IDX_CTX] = 
    340329{
    341   { 168,  CNU, },
    342   { 168,  CNU, },
    343   { CNU,  CNU, },
     330  { 168 },
     331  { 168 },
     332  { CNU },
    344333};
    345334
     
    355344INIT_SAO_TYPE_IDX[3][NUM_SAO_TYPE_IDX_CTX] =
    356345{
    357 #if FIX827
    358346  { 160, },
    359347  { 185, },
    360348  { 200, },
    361 #else
    362   { 200, },
    363   { 185, },
    364   { 160, },
    365 #endif
    366349};
    367350
     
    369352INIT_TRANS_SUBDIV_FLAG[3][NUM_TRANS_SUBDIV_FLAG_CTX] =
    370353{
    371 #if FIX712
    372354  { 224,  167,  122, },
    373355  { 124,  138,   94, },
    374356  { 153,  138,  138, },
    375 #else
    376   { 153,  138,  138, },
    377   { 124,  138,   94, },
    378   { 224,  167,  122, },
    379 #endif
    380357};
    381358
  • branches/HTM-10.0-dev0/source/Lib/TLibCommon/NAL.h

    r608 r852  
    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 *
     
    7979    return m_nalUnitType == NAL_UNIT_CODED_SLICE_TRAIL_R
    8080        || m_nalUnitType == NAL_UNIT_CODED_SLICE_TRAIL_N
    81         || m_nalUnitType == NAL_UNIT_CODED_SLICE_TLA_R
     81        || m_nalUnitType == NAL_UNIT_CODED_SLICE_TSA_R
    8282        || m_nalUnitType == NAL_UNIT_CODED_SLICE_TSA_N
    8383        || m_nalUnitType == NAL_UNIT_CODED_SLICE_STSA_R
  • branches/HTM-10.0-dev0/source/Lib/TLibCommon/SEI.cpp

    r608 r852  
    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 *
  • branches/HTM-10.0-dev0/source/Lib/TLibCommon/SEI.h

    r608 r852  
    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 *
  • branches/HTM-10.0-dev0/source/Lib/TLibCommon/TComBitCounter.h

    r608 r852  
    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 *
  • branches/HTM-10.0-dev0/source/Lib/TLibCommon/TComBitStream.cpp

    r608 r852  
    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 *
  • branches/HTM-10.0-dev0/source/Lib/TLibCommon/TComBitStream.h

    r608 r852  
    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 *
  • branches/HTM-10.0-dev0/source/Lib/TLibCommon/TComCABACTables.cpp

    r608 r852  
    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 *
  • branches/HTM-10.0-dev0/source/Lib/TLibCommon/TComCABACTables.h

    r608 r852  
    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 *
  • branches/HTM-10.0-dev0/source/Lib/TLibCommon/TComDataCU.cpp

    r833 r852  
    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 *
     
    488488}
    489489
    490 const NDBFBlockInfo& NDBFBlockInfo::operator= (const NDBFBlockInfo& src)
    491 {
    492   this->tileID = src.tileID;
    493   this->sliceID= src.sliceID;
    494   this->startSU= src.startSU;
    495   this->endSU  = src.endSU;
    496   this->widthSU= src.widthSU;
    497   this->heightSU=src.heightSU;
    498   this->posX   = src.posX;
    499   this->posY   = src.posY;
    500   this->width  = src.width;
    501   this->height = src.height;
    502   ::memcpy(this->isBorderAvailable, src.isBorderAvailable, sizeof(Bool)*((Int)NUM_SGU_BORDER));
    503   this->allBordersAvailable = src.allBordersAvailable;
    504 
    505   return *this;
    506 }
    507 
    508 
    509490// ====================================================================================================================
    510491// Public member functions
     
    801782*- set last-coded qp value according to input last-coded qp
    802783*/
    803 Void TComDataCU::initEstData( UInt uiDepth, Int qp )
     784Void TComDataCU::initEstData( UInt uiDepth, Int qp, Bool bTransquantBypass )
    804785{
    805786  m_dTotalCost         = MAX_DOUBLE;
     
    829810      m_pePartSize[ui] = SIZE_NONE;
    830811      m_pePredMode[ui] = MODE_NONE;
    831       m_CUTransquantBypass[ui] = false;
     812      m_CUTransquantBypass[ui] = bTransquantBypass;
    832813      m_pbIPCMFlag[ui] = 0;
    833814      m_phQP[ui] = qp;
     
    59805961    xAddMVPCand( pInfo, eRefPicList, iRefIdx, uiPartIdxLT, MD_ABOVE_LEFT);
    59815962  }
    5982   bAdded = bAddedSmvp;
    5983   if (pInfo->iN==2) bAdded = true;
    5984 
    5985   if(!bAdded)
     5963
     5964  if (!bAddedSmvp)
    59865965  {
    59875966    bAdded = xAddMVPCandOrder( pInfo, eRefPicList, iRefIdx, uiPartIdxRT, MD_ABOVE_RIGHT);
     
    66416620{
    66426621  return getPic()->getPicSym()->getInverseCUOrderMap(m_uiCUAddr)*(1<<(m_pcSlice->getSPS()->getMaxCUDepth()<<1))+m_uiAbsIdxInLCU;
    6643 }
    6644 
    6645 /** Set neighboring blocks availabilities for non-deblocked filtering
    6646  * \param numLCUInPicWidth number of LCUs in picture width
    6647  * \param numLCUInPicHeight number of LCUs in picture height
    6648  * \param numSUInLCUWidth number of SUs in LCU width
    6649  * \param numSUInLCUHeight number of SUs in LCU height
    6650  * \param picWidth picture width
    6651  * \param picHeight picture height
    6652  * \param bIndependentSliceBoundaryEnabled true for independent slice boundary enabled
    6653  * \param bTopTileBoundary true means that top boundary coincides tile boundary
    6654  * \param bDownTileBoundary true means that bottom boundary coincides tile boundary
    6655  * \param bLeftTileBoundary true means that left boundary coincides tile boundary
    6656  * \param bRightTileBoundary true means that right boundary coincides tile boundary
    6657  * \param bIndependentTileBoundaryEnabled true for independent tile boundary enabled
    6658  */
    6659 Void TComDataCU::setNDBFilterBlockBorderAvailability(UInt numLCUInPicWidth, UInt /*numLCUInPicHeight*/, UInt numSUInLCUWidth, UInt numSUInLCUHeight, UInt picWidth, UInt picHeight
    6660                                                     ,std::vector<Bool>& LFCrossSliceBoundary
    6661                                                     ,Bool bTopTileBoundary, Bool bDownTileBoundary, Bool bLeftTileBoundary, Bool bRightTileBoundary
    6662                                                     ,Bool bIndependentTileBoundaryEnabled)
    6663 {
    6664   UInt numSUInLCU = numSUInLCUWidth*numSUInLCUHeight;
    6665   Int* pSliceIDMapLCU = m_piSliceSUMap;
    6666   Bool onlyOneSliceInPic = ((Int)LFCrossSliceBoundary.size() == 1);
    6667   UInt uiLPelX, uiTPelY;
    6668   UInt width, height;
    6669   Bool bPicRBoundary, bPicBBoundary, bPicTBoundary, bPicLBoundary;
    6670   Bool bLCURBoundary= false, bLCUBBoundary= false, bLCUTBoundary= false, bLCULBoundary= false;
    6671   Bool* pbAvailBorder;
    6672   Bool* pbAvail;
    6673   UInt rTLSU, rBRSU, widthSU, heightSU;
    6674   UInt zRefSU;
    6675   Int* pRefID;
    6676   Int* pRefMapLCU;
    6677   UInt rTRefSU= 0, rBRefSU= 0, rLRefSU= 0, rRRefSU= 0;
    6678   Int* pRRefMapLCU= NULL;
    6679   Int* pLRefMapLCU= NULL;
    6680   Int* pTRefMapLCU= NULL;
    6681   Int* pBRefMapLCU= NULL;
    6682   Int  sliceID;
    6683   UInt numSGU = (UInt)m_vNDFBlock.size();
    6684 
    6685   for(Int i=0; i< numSGU; i++)
    6686   {
    6687     NDBFBlockInfo& rSGU = m_vNDFBlock[i];
    6688 
    6689     sliceID = rSGU.sliceID;
    6690     uiLPelX = rSGU.posX;
    6691     uiTPelY = rSGU.posY;
    6692     width   = rSGU.width;
    6693     height  = rSGU.height;
    6694     rTLSU     = g_auiZscanToRaster[ rSGU.startSU ];
    6695     rBRSU     = g_auiZscanToRaster[ rSGU.endSU   ];
    6696     widthSU   = rSGU.widthSU;
    6697     heightSU  = rSGU.heightSU;
    6698 
    6699     pbAvailBorder = rSGU.isBorderAvailable;
    6700 
    6701     bPicTBoundary= (uiTPelY == 0                       )?(true):(false);
    6702     bPicLBoundary= (uiLPelX == 0                       )?(true):(false);
    6703     bPicRBoundary= (!(uiLPelX+ width < picWidth )  )?(true):(false);
    6704     bPicBBoundary= (!(uiTPelY + height < picHeight))?(true):(false);
    6705 
    6706     bLCULBoundary = (rTLSU % numSUInLCUWidth == 0)?(true):(false);
    6707     bLCURBoundary = ( (rTLSU+ widthSU) % numSUInLCUWidth == 0)?(true):(false);
    6708     bLCUTBoundary = ( (UInt)(rTLSU / numSUInLCUWidth)== 0)?(true):(false);
    6709     bLCUBBoundary = ( (UInt)(rBRSU / numSUInLCUWidth) == (numSUInLCUHeight-1) )?(true):(false);
    6710 
    6711     //       SGU_L
    6712     pbAvail = &(pbAvailBorder[SGU_L]);
    6713     if(bPicLBoundary)
    6714     {
    6715       *pbAvail = false;
    6716     }
    6717     else if (onlyOneSliceInPic)
    6718     {
    6719       *pbAvail = true;
    6720     }
    6721     else
    6722     {
    6723       //      bLCULBoundary = (rTLSU % uiNumSUInLCUWidth == 0)?(true):(false);
    6724       if(bLCULBoundary)
    6725       {
    6726         rLRefSU     = rTLSU + numSUInLCUWidth -1;
    6727         zRefSU      = g_auiRasterToZscan[rLRefSU];
    6728         pRefMapLCU = pLRefMapLCU= (pSliceIDMapLCU - numSUInLCU);
    6729       }
    6730       else
    6731       {
    6732         zRefSU   = g_auiRasterToZscan[rTLSU - 1];
    6733         pRefMapLCU  = pSliceIDMapLCU;
    6734       }
    6735       pRefID = pRefMapLCU + zRefSU;
    6736       *pbAvail = (*pRefID == sliceID)?(true):((*pRefID > sliceID)?(LFCrossSliceBoundary[*pRefID]):(LFCrossSliceBoundary[sliceID]));
    6737     }
    6738 
    6739     //       SGU_R
    6740     pbAvail = &(pbAvailBorder[SGU_R]);
    6741     if(bPicRBoundary)
    6742     {
    6743       *pbAvail = false;
    6744     }
    6745     else if (onlyOneSliceInPic)
    6746     {
    6747       *pbAvail = true;
    6748     }
    6749     else
    6750     {
    6751       //       bLCURBoundary = ( (rTLSU+ uiWidthSU) % uiNumSUInLCUWidth == 0)?(true):(false);
    6752       if(bLCURBoundary)
    6753       {
    6754         rRRefSU      = rTLSU + widthSU - numSUInLCUWidth;
    6755         zRefSU       = g_auiRasterToZscan[rRRefSU];
    6756         pRefMapLCU  = pRRefMapLCU= (pSliceIDMapLCU + numSUInLCU);
    6757       }
    6758       else
    6759       {
    6760         zRefSU       = g_auiRasterToZscan[rTLSU + widthSU];
    6761         pRefMapLCU  = pSliceIDMapLCU;
    6762       }
    6763       pRefID = pRefMapLCU + zRefSU;
    6764       *pbAvail = (*pRefID == sliceID)?(true):((*pRefID > sliceID)?(LFCrossSliceBoundary[*pRefID]):(LFCrossSliceBoundary[sliceID]));
    6765     }
    6766 
    6767     //       SGU_T
    6768     pbAvail = &(pbAvailBorder[SGU_T]);
    6769     if(bPicTBoundary)
    6770     {
    6771       *pbAvail = false;
    6772     }
    6773     else if (onlyOneSliceInPic)
    6774     {
    6775       *pbAvail = true;
    6776     }
    6777     else
    6778     {
    6779       //      bLCUTBoundary = ( (UInt)(rTLSU / uiNumSUInLCUWidth)== 0)?(true):(false);
    6780       if(bLCUTBoundary)
    6781       {
    6782         rTRefSU      = numSUInLCU - (numSUInLCUWidth - rTLSU);
    6783         zRefSU       = g_auiRasterToZscan[rTRefSU];
    6784         pRefMapLCU  = pTRefMapLCU= (pSliceIDMapLCU - (numLCUInPicWidth*numSUInLCU));
    6785       }
    6786       else
    6787       {
    6788         zRefSU       = g_auiRasterToZscan[rTLSU - numSUInLCUWidth];
    6789         pRefMapLCU  = pSliceIDMapLCU;
    6790       }
    6791       pRefID = pRefMapLCU + zRefSU;
    6792       *pbAvail = (*pRefID == sliceID)?(true):((*pRefID > sliceID)?(LFCrossSliceBoundary[*pRefID]):(LFCrossSliceBoundary[sliceID]));
    6793     }
    6794 
    6795     //       SGU_B
    6796     pbAvail = &(pbAvailBorder[SGU_B]);
    6797     if(bPicBBoundary)
    6798     {
    6799       *pbAvail = false;
    6800     }
    6801     else if (onlyOneSliceInPic)
    6802     {
    6803       *pbAvail = true;
    6804     }
    6805     else
    6806     {
    6807       //      bLCUBBoundary = ( (UInt)(rBRSU / uiNumSUInLCUWidth) == (uiNumSUInLCUHeight-1) )?(true):(false);
    6808       if(bLCUBBoundary)
    6809       {
    6810         rBRefSU      = rTLSU % numSUInLCUWidth;
    6811         zRefSU       = g_auiRasterToZscan[rBRefSU];
    6812         pRefMapLCU  = pBRefMapLCU= (pSliceIDMapLCU + (numLCUInPicWidth*numSUInLCU));
    6813       }
    6814       else
    6815       {
    6816         zRefSU       = g_auiRasterToZscan[rTLSU + (heightSU*numSUInLCUWidth)];
    6817         pRefMapLCU  = pSliceIDMapLCU;
    6818       }
    6819       pRefID = pRefMapLCU + zRefSU;
    6820       *pbAvail = (*pRefID == sliceID)?(true):((*pRefID > sliceID)?(LFCrossSliceBoundary[*pRefID]):(LFCrossSliceBoundary[sliceID]));
    6821     }
    6822 
    6823     //       SGU_TL
    6824     pbAvail = &(pbAvailBorder[SGU_TL]);
    6825     if(bPicTBoundary || bPicLBoundary)
    6826     {
    6827       *pbAvail = false;
    6828     }
    6829     else if (onlyOneSliceInPic)
    6830     {
    6831       *pbAvail = true;
    6832     }
    6833     else
    6834     {
    6835       if(bLCUTBoundary && bLCULBoundary)
    6836       {
    6837         zRefSU       = numSUInLCU -1;
    6838         pRefMapLCU  = pSliceIDMapLCU - ( (numLCUInPicWidth+1)*numSUInLCU);
    6839       }
    6840       else if(bLCUTBoundary)
    6841       {
    6842         zRefSU       = g_auiRasterToZscan[ rTRefSU- 1];
    6843         pRefMapLCU  = pTRefMapLCU;
    6844       }
    6845       else if(bLCULBoundary)
    6846       {
    6847         zRefSU       = g_auiRasterToZscan[ rLRefSU- numSUInLCUWidth ];
    6848         pRefMapLCU  = pLRefMapLCU;
    6849       }
    6850       else //inside LCU
    6851       {
    6852         zRefSU       = g_auiRasterToZscan[ rTLSU - numSUInLCUWidth -1];
    6853         pRefMapLCU  = pSliceIDMapLCU;
    6854       }
    6855       pRefID = pRefMapLCU + zRefSU;
    6856       *pbAvail = (*pRefID == sliceID)?(true):((*pRefID > sliceID)?(LFCrossSliceBoundary[*pRefID]):(LFCrossSliceBoundary[sliceID]));
    6857     }
    6858 
    6859     //       SGU_TR
    6860     pbAvail = &(pbAvailBorder[SGU_TR]);
    6861     if(bPicTBoundary || bPicRBoundary)
    6862     {
    6863       *pbAvail = false;
    6864     }
    6865     else if (onlyOneSliceInPic)
    6866     {
    6867       *pbAvail = true;
    6868     }
    6869     else
    6870     {
    6871       if(bLCUTBoundary && bLCURBoundary)
    6872       {
    6873         zRefSU      = g_auiRasterToZscan[numSUInLCU - numSUInLCUWidth];
    6874         pRefMapLCU  = pSliceIDMapLCU - ( (numLCUInPicWidth-1)*numSUInLCU);       
    6875       }
    6876       else if(bLCUTBoundary)
    6877       {
    6878         zRefSU       = g_auiRasterToZscan[ rTRefSU+ widthSU];
    6879         pRefMapLCU  = pTRefMapLCU;
    6880       }
    6881       else if(bLCURBoundary)
    6882       {
    6883         zRefSU       = g_auiRasterToZscan[ rRRefSU- numSUInLCUWidth ];
    6884         pRefMapLCU  = pRRefMapLCU;
    6885       }
    6886       else //inside LCU
    6887       {
    6888         zRefSU       = g_auiRasterToZscan[ rTLSU - numSUInLCUWidth +widthSU];
    6889         pRefMapLCU  = pSliceIDMapLCU;
    6890       }
    6891       pRefID = pRefMapLCU + zRefSU;
    6892       *pbAvail = (*pRefID == sliceID)?(true):((*pRefID > sliceID)?(LFCrossSliceBoundary[*pRefID]):(LFCrossSliceBoundary[sliceID]));
    6893     }
    6894 
    6895     //       SGU_BL
    6896     pbAvail = &(pbAvailBorder[SGU_BL]);
    6897     if(bPicBBoundary || bPicLBoundary)
    6898     {
    6899       *pbAvail = false;
    6900     }
    6901     else if (onlyOneSliceInPic)
    6902     {
    6903       *pbAvail = true;
    6904     }
    6905     else
    6906     {
    6907       if(bLCUBBoundary && bLCULBoundary)
    6908       {
    6909         zRefSU      = g_auiRasterToZscan[numSUInLCUWidth - 1];
    6910         pRefMapLCU  = pSliceIDMapLCU + ( (numLCUInPicWidth-1)*numSUInLCU);       
    6911       }
    6912       else if(bLCUBBoundary)
    6913       {
    6914         zRefSU       = g_auiRasterToZscan[ rBRefSU - 1];
    6915         pRefMapLCU  = pBRefMapLCU;
    6916       }
    6917       else if(bLCULBoundary)
    6918       {
    6919         zRefSU       = g_auiRasterToZscan[ rLRefSU+ heightSU*numSUInLCUWidth ];
    6920         pRefMapLCU  = pLRefMapLCU;
    6921       }
    6922       else //inside LCU
    6923       {
    6924         zRefSU       = g_auiRasterToZscan[ rTLSU + heightSU*numSUInLCUWidth -1];
    6925         pRefMapLCU  = pSliceIDMapLCU;
    6926       }
    6927       pRefID = pRefMapLCU + zRefSU;
    6928       *pbAvail = (*pRefID == sliceID)?(true):((*pRefID > sliceID)?(LFCrossSliceBoundary[*pRefID]):(LFCrossSliceBoundary[sliceID]));
    6929     }
    6930 
    6931     //       SGU_BR
    6932     pbAvail = &(pbAvailBorder[SGU_BR]);
    6933     if(bPicBBoundary || bPicRBoundary)
    6934     {
    6935       *pbAvail = false;
    6936     }
    6937     else if (onlyOneSliceInPic)
    6938     {
    6939       *pbAvail = true;
    6940     }
    6941     else
    6942     {
    6943       if(bLCUBBoundary && bLCURBoundary)
    6944       {
    6945         zRefSU = 0;
    6946         pRefMapLCU = pSliceIDMapLCU+ ( (numLCUInPicWidth+1)*numSUInLCU);
    6947       }
    6948       else if(bLCUBBoundary)
    6949       {
    6950         zRefSU      = g_auiRasterToZscan[ rBRefSU + widthSU];
    6951         pRefMapLCU = pBRefMapLCU;
    6952       }
    6953       else if(bLCURBoundary)
    6954       {
    6955         zRefSU      = g_auiRasterToZscan[ rRRefSU + (heightSU*numSUInLCUWidth)];
    6956         pRefMapLCU = pRRefMapLCU;
    6957       }
    6958       else //inside LCU
    6959       {
    6960         zRefSU      = g_auiRasterToZscan[ rTLSU + (heightSU*numSUInLCUWidth)+ widthSU];
    6961         pRefMapLCU = pSliceIDMapLCU;
    6962       }
    6963       pRefID = pRefMapLCU + zRefSU;
    6964       *pbAvail = (*pRefID == sliceID)?(true):((*pRefID > sliceID)?(LFCrossSliceBoundary[*pRefID]):(LFCrossSliceBoundary[sliceID]));
    6965     }
    6966 
    6967     if(bIndependentTileBoundaryEnabled)
    6968     {
    6969       //left LCU boundary
    6970       if(!bPicLBoundary && bLCULBoundary)
    6971       {
    6972         if(bLeftTileBoundary)
    6973         {
    6974           pbAvailBorder[SGU_L] = pbAvailBorder[SGU_TL] = pbAvailBorder[SGU_BL] = false;
    6975         }
    6976       }
    6977       //right LCU boundary
    6978       if(!bPicRBoundary && bLCURBoundary)
    6979       {
    6980         if(bRightTileBoundary)
    6981         {
    6982           pbAvailBorder[SGU_R] = pbAvailBorder[SGU_TR] = pbAvailBorder[SGU_BR] = false;
    6983         }
    6984       }
    6985       //top LCU boundary
    6986       if(!bPicTBoundary && bLCUTBoundary)
    6987       {
    6988         if(bTopTileBoundary)
    6989         {
    6990           pbAvailBorder[SGU_T] = pbAvailBorder[SGU_TL] = pbAvailBorder[SGU_TR] = false;
    6991         }
    6992       }
    6993       //down LCU boundary
    6994       if(!bPicBBoundary && bLCUBBoundary)
    6995       {
    6996         if(bDownTileBoundary)
    6997         {
    6998           pbAvailBorder[SGU_B] = pbAvailBorder[SGU_BL] = pbAvailBorder[SGU_BR] = false;
    6999         }
    7000       }
    7001     }
    7002     rSGU.allBordersAvailable = true;
    7003     for(Int b=0; b< NUM_SGU_BORDER; b++)
    7004     {
    7005       if(pbAvailBorder[b] == false)
    7006       {
    7007         rSGU.allBordersAvailable = false;
    7008         break;
    7009       }
    7010     }
    7011   }
    70126622}
    70136623
  • branches/HTM-10.0-dev0/source/Lib/TLibCommon/TComDataCU.h

    r833 r852  
    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 *
     
    5959//! \{
    6060
    61 // ====================================================================================================================
    62 // Non-deblocking in-loop filter processing block data structure
    63 // ====================================================================================================================
    64 
    65 /// Non-deblocking filter processing block border tag
    66 enum NDBFBlockBorderTag
    67 {
    68   SGU_L = 0,
    69   SGU_R,
    70   SGU_T,
    71   SGU_B,
    72   SGU_TL,
    73   SGU_TR,
    74   SGU_BL,
    75   SGU_BR,
    76   NUM_SGU_BORDER
    77 };
    78 
    79 /// Non-deblocking filter processing block information
    80 struct NDBFBlockInfo
    81 {
    82   Int   tileID;   //!< tile ID
    83   Int   sliceID;  //!< slice ID
    84   UInt  startSU;  //!< starting SU z-scan address in LCU
    85   UInt  endSU;    //!< ending SU z-scan address in LCU
    86   UInt  widthSU;  //!< number of SUs in width
    87   UInt  heightSU; //!< number of SUs in height
    88   UInt  posX;     //!< top-left X coordinate in picture
    89   UInt  posY;     //!< top-left Y coordinate in picture
    90   UInt  width;    //!< number of pixels in width
    91   UInt  height;   //!< number of pixels in height
    92   Bool  isBorderAvailable[NUM_SGU_BORDER];  //!< the border availabilities
    93   Bool  allBordersAvailable;
    94 
    95   NDBFBlockInfo():tileID(0), sliceID(0), startSU(0), endSU(0) {} //!< constructor
    96   const NDBFBlockInfo& operator= (const NDBFBlockInfo& src);  //!< "=" operator
    97 };
    9861
    9962#if H_3D_DBBP
     
    176139  Pel*          m_pcIPCMSampleCr;     ///< PCM sample buffer (Cr)
    177140
    178   Int*          m_piSliceSUMap;       ///< pointer of slice ID map
    179   std::vector<NDBFBlockInfo> m_vNDFBlock;
    180 
    181141  // -------------------------------------------------------------------------------------------------------------------
    182142  // neighbour access variables
     
    342302 
    343303  Void          initCU                ( TComPic* pcPic, UInt uiCUAddr );
    344   Void          initEstData           ( UInt uiDepth, Int qp );
     304  Void          initEstData           ( UInt uiDepth, Int qp, Bool bTransquantBypass );
    345305  Void          initSubCU             ( TComDataCU* pcCU, UInt uiPartUnitIdx, UInt uiDepth, Int qp );
    346306  Void          setOutsideCUPart      ( UInt uiAbsPartIdx, UInt uiDepth );
     
    522482  DisInfo       getDvInfo             (UInt uiIdx)              { return m_pDvInfo[uiIdx];          }
    523483#endif
    524   /// get slice ID for SU
    525   Int           getSUSliceID          (UInt uiIdx)              {return m_piSliceSUMap[uiIdx];      }
    526 
    527   /// get the pointer of slice ID map
    528   Int*          getSliceSUMap         ()                        {return m_piSliceSUMap;             }
    529 
    530   /// set the pointer of slice ID map
    531   Void          setSliceSUMap         (Int *pi)                 {m_piSliceSUMap = pi;               }
    532 
    533   std::vector<NDBFBlockInfo>* getNDBFilterBlocks()      {return &m_vNDFBlock;}
    534   Void setNDBFilterBlockBorderAvailability(UInt numLCUInPicWidth, UInt numLCUInPicHeight, UInt numSUInLCUWidth, UInt numSUInLCUHeight, UInt picWidth, UInt picHeight
    535                                           ,std::vector<Bool>& LFCrossSliceBoundary
    536                                           ,Bool bTopTileBoundary, Bool bDownTileBoundary, Bool bLeftTileBoundary, Bool bRightTileBoundary
    537                                           ,Bool bIndependentTileBoundaryEnabled );
    538484#if H_3D_NBDV
    539485  Void          xDeriveRightBottomNbIdx(Int &uiLCUIdxRBNb, Int &uiPartIdxRBNb );
  • branches/HTM-10.0-dev0/source/Lib/TLibCommon/TComInterpolationFilter.cpp

    r608 r852  
    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 *
  • branches/HTM-10.0-dev0/source/Lib/TLibCommon/TComInterpolationFilter.h

    r608 r852  
    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 *
  • branches/HTM-10.0-dev0/source/Lib/TLibCommon/TComList.h

    r608 r852  
    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 *
  • branches/HTM-10.0-dev0/source/Lib/TLibCommon/TComLoopFilter.cpp

    r608 r852  
    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 *
  • branches/HTM-10.0-dev0/source/Lib/TLibCommon/TComLoopFilter.h

    r608 r852  
    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 *
  • branches/HTM-10.0-dev0/source/Lib/TLibCommon/TComMotionInfo.cpp

    r773 r852  
    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 *
  • branches/HTM-10.0-dev0/source/Lib/TLibCommon/TComMotionInfo.h

    r833 r852  
    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 *
  • branches/HTM-10.0-dev0/source/Lib/TLibCommon/TComMv.h

    r655 r852  
    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 *
  • branches/HTM-10.0-dev0/source/Lib/TLibCommon/TComPattern.cpp

    r608 r852  
    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 *
  • branches/HTM-10.0-dev0/source/Lib/TLibCommon/TComPattern.h

    r655 r852  
    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 *
  • branches/HTM-10.0-dev0/source/Lib/TLibCommon/TComPic.cpp

    r738 r852  
    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 )
  • branches/HTM-10.0-dev0/source/Lib/TLibCommon/TComPic.h

    r655 r852  
    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 *
     
    7070  Bool                  m_bNeededForOutput;
    7171  UInt                  m_uiCurrSliceIdx;         // Index of current slice
    72   Int*                  m_pSliceSUMap;
    73   Bool*                 m_pbValidSlice;
    74   Int                   m_sliceGranularityForNDBFilter;
    75   Bool                  m_bIndependentSliceBoundaryForNDBFilter;
    76   Bool                  m_bIndependentTileBoundaryForNDBFilter;
    77   TComPicYuv*           m_pNDBFilterYuvTmp;    //!< temporary picture buffer when non-cross slice/tile boundary in-loop filtering is enabled
    7872  Bool                  m_bCheckLTMSB;
    7973 
     
    198192  Window&       getDefDisplayWindow()   { return m_defaultDisplayWindow; }
    199193
    200   Void          createNonDBFilterInfo   (std::vector<Int> sliceStartAddress, Int sliceGranularityDepth
    201                                         ,std::vector<Bool>* LFCrossSliceBoundary
    202                                         ,Int  numTiles = 1
    203                                         ,Bool bNDBFilterCrossTileBoundary = true);
    204   Void          createNonDBFilterInfoLCU(Int tileID, Int sliceID, TComDataCU* pcCU, UInt startSU, UInt endSU, Int sliceGranularyDepth, UInt picWidth, UInt picHeight);
    205   Void          destroyNonDBFilterInfo();
    206 
    207   Bool          getValidSlice                                  (Int sliceID)  {return m_pbValidSlice[sliceID];}
    208   Bool          getIndependentSliceBoundaryForNDBFilter        ()             {return m_bIndependentSliceBoundaryForNDBFilter;}
    209   Bool          getIndependentTileBoundaryForNDBFilter         ()             {return m_bIndependentTileBoundaryForNDBFilter; }
    210   TComPicYuv*   getYuvPicBufferForIndependentBoundaryProcessing()             {return m_pNDBFilterYuvTmp;}
    211   std::vector<TComDataCU*>& getOneSliceCUDataForNDBFilter      (Int sliceID) { return m_vSliceCUDataLink[sliceID];}
    212 
     194  Bool          getSAOMergeAvailability(Int currAddr, Int mergeAddr);
    213195
    214196  /* field coding parameters*/
  • branches/HTM-10.0-dev0/source/Lib/TLibCommon/TComPicSym.cpp

    r655 r852  
    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 *
     
    6767,m_puiTileIdxMap(NULL)
    6868,m_puiInverseCUOrderMap(NULL)
     69,m_saoBlkParams(NULL)
    6970{};
    7071
     
    122123    m_puiInverseCUOrderMap[i] = i;
    123124  }
    124   m_saoParam = NULL;
     125
     126  m_saoBlkParams = new SAOBlkParam[m_uiNumCUsInFrame];
    125127}
    126128
     
    163165  m_puiInverseCUOrderMap = NULL;
    164166 
    165   if (m_saoParam)
    166   {
    167     TComSampleAdaptiveOffset::freeSaoParam(m_saoParam);
    168     delete m_saoParam;
    169     m_saoParam = NULL;
     167  if(m_saoBlkParams)
     168  {
     169    delete[] m_saoBlkParams; m_saoBlkParams = NULL;
    170170  }
    171171}
     
    308308}
    309309
    310 Void TComPicSym::allocSaoParam(TComSampleAdaptiveOffset *sao)
    311 {
    312   m_saoParam = new SAOParam;
    313   sao->allocSaoParam(m_saoParam);
     310Void TComPicSym::deriveLoopFilterBoundaryAvailibility(Int ctu,
     311                                                      Bool& isLeftAvail,
     312                                                      Bool& isRightAvail,
     313                                                      Bool& isAboveAvail,
     314                                                      Bool& isBelowAvail,
     315                                                      Bool& isAboveLeftAvail,
     316                                                      Bool& isAboveRightAvail,
     317                                                      Bool& isBelowLeftAvail,
     318                                                      Bool& isBelowRightAvail
     319                                                      )
     320{
     321
     322  isLeftAvail      = (ctu % m_uiWidthInCU != 0);
     323  isRightAvail     = (ctu % m_uiWidthInCU != m_uiWidthInCU-1);
     324  isAboveAvail     = (ctu >= m_uiWidthInCU );
     325  isBelowAvail     = (ctu <  m_uiNumCUsInFrame - m_uiWidthInCU);
     326  isAboveLeftAvail = (isAboveAvail && isLeftAvail);
     327  isAboveRightAvail= (isAboveAvail && isRightAvail);
     328  isBelowLeftAvail = (isBelowAvail && isLeftAvail);
     329  isBelowRightAvail= (isBelowAvail && isRightAvail);
     330
     331  Bool isLoopFiltAcrossTilePPS = getCU(ctu)->getSlice()->getPPS()->getLoopFilterAcrossTilesEnabledFlag();
     332
     333  {
     334    TComDataCU* ctuCurr  = getCU(ctu);
     335    TComDataCU* ctuLeft  = isLeftAvail ?getCU(ctu-1):NULL;
     336    TComDataCU* ctuRight = isRightAvail?getCU(ctu+1):NULL;
     337    TComDataCU* ctuAbove = isAboveAvail?getCU(ctu-m_uiWidthInCU):NULL;
     338    TComDataCU* ctuBelow = isBelowAvail?getCU(ctu+m_uiWidthInCU):NULL;
     339    TComDataCU* ctuAboveLeft  = isAboveLeftAvail ? getCU(ctu-m_uiWidthInCU-1):NULL;
     340    TComDataCU* ctuAboveRigtht= isAboveRightAvail? getCU(ctu-m_uiWidthInCU+1):NULL;
     341    TComDataCU* ctuBelowLeft  = isBelowLeftAvail ? getCU(ctu+m_uiWidthInCU-1):NULL;
     342    TComDataCU* ctuBelowRight = isBelowRightAvail? getCU(ctu+m_uiWidthInCU+1):NULL;
     343
     344    {
     345      //left
     346      if(ctuLeft != NULL)
     347      {
     348        isLeftAvail = (ctuCurr->getSlice()->getSliceCurStartCUAddr() != ctuLeft->getSlice()->getSliceCurStartCUAddr())?ctuCurr->getSlice()->getLFCrossSliceBoundaryFlag():true;
     349      }
     350      //above
     351      if(ctuAbove != NULL)
     352      {
     353        isAboveAvail = (ctuCurr->getSlice()->getSliceCurStartCUAddr() != ctuAbove->getSlice()->getSliceCurStartCUAddr())?ctuCurr->getSlice()->getLFCrossSliceBoundaryFlag():true;
     354      }
     355      //right
     356      if(ctuRight != NULL)
     357      {
     358        isRightAvail = (ctuCurr->getSlice()->getSliceCurStartCUAddr() != ctuRight->getSlice()->getSliceCurStartCUAddr())?ctuRight->getSlice()->getLFCrossSliceBoundaryFlag():true;
     359      }
     360      //below
     361      if(ctuBelow != NULL)
     362      {
     363        isBelowAvail = (ctuCurr->getSlice()->getSliceCurStartCUAddr() != ctuBelow->getSlice()->getSliceCurStartCUAddr())?ctuBelow->getSlice()->getLFCrossSliceBoundaryFlag():true;
     364      }
     365      //above-left
     366      if(ctuAboveLeft != NULL)
     367      {
     368        isAboveLeftAvail = (ctuCurr->getSlice()->getSliceCurStartCUAddr() != ctuAboveLeft->getSlice()->getSliceCurStartCUAddr())?ctuCurr->getSlice()->getLFCrossSliceBoundaryFlag():true;
     369      }
     370      //below-right
     371      if(ctuBelowRight != NULL)
     372{
     373        isBelowRightAvail = (ctuCurr->getSlice()->getSliceCurStartCUAddr() != ctuBelowRight->getSlice()->getSliceCurStartCUAddr())?ctuBelowRight->getSlice()->getLFCrossSliceBoundaryFlag():true;
     374      }
     375
     376
     377      //above-right
     378      if(ctuAboveRigtht != NULL)
     379      {
     380        Int curSliceStartEncOrder  = ctuCurr->getSlice()->getSliceCurStartCUAddr();
     381        Int aboveRigthtSliceStartEncOrder = ctuAboveRigtht->getSlice()->getSliceCurStartCUAddr();
     382
     383        isAboveRightAvail = (curSliceStartEncOrder == aboveRigthtSliceStartEncOrder)?(true):
     384          (
     385          (curSliceStartEncOrder > aboveRigthtSliceStartEncOrder)?(ctuCurr->getSlice()->getLFCrossSliceBoundaryFlag())
     386          :(ctuAboveRigtht->getSlice()->getLFCrossSliceBoundaryFlag())
     387          );         
     388      }
     389      //below-left
     390      if(ctuBelowLeft != NULL)
     391      {
     392        Int curSliceStartEncOrder  = ctuCurr->getSlice()->getSliceCurStartCUAddr();
     393        Int belowLeftSliceStartEncOrder = ctuBelowLeft->getSlice()->getSliceCurStartCUAddr();
     394
     395        isBelowLeftAvail = (curSliceStartEncOrder == belowLeftSliceStartEncOrder)?(true):
     396          (
     397          (curSliceStartEncOrder > belowLeftSliceStartEncOrder)?(ctuCurr->getSlice()->getLFCrossSliceBoundaryFlag())
     398          :(ctuBelowLeft->getSlice()->getLFCrossSliceBoundaryFlag())
     399          );
     400      }       
     401    }
     402
     403    if(!isLoopFiltAcrossTilePPS)
     404    {     
     405      isLeftAvail      = (!isLeftAvail      ) ?false:(getTileIdxMap( ctuLeft->getAddr()         ) == getTileIdxMap( ctu ));
     406      isAboveAvail     = (!isAboveAvail     ) ?false:(getTileIdxMap( ctuAbove->getAddr()        ) == getTileIdxMap( ctu ));
     407      isRightAvail     = (!isRightAvail     ) ?false:(getTileIdxMap( ctuRight->getAddr()        ) == getTileIdxMap( ctu ));
     408      isBelowAvail     = (!isBelowAvail     ) ?false:(getTileIdxMap( ctuBelow->getAddr()        ) == getTileIdxMap( ctu ));
     409      isAboveLeftAvail = (!isAboveLeftAvail ) ?false:(getTileIdxMap( ctuAboveLeft->getAddr()    ) == getTileIdxMap( ctu ));
     410      isAboveRightAvail= (!isAboveRightAvail) ?false:(getTileIdxMap( ctuAboveRigtht->getAddr()  ) == getTileIdxMap( ctu ));
     411      isBelowLeftAvail = (!isBelowLeftAvail ) ?false:(getTileIdxMap( ctuBelowLeft->getAddr()    ) == getTileIdxMap( ctu ));
     412      isBelowRightAvail= (!isBelowRightAvail) ?false:(getTileIdxMap( ctuBelowRight->getAddr()   ) == getTileIdxMap( ctu ));
     413    }
     414  }
     415
    314416}
    315417
  • branches/HTM-10.0-dev0/source/Lib/TLibCommon/TComPicSym.h

    r655 r852  
    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 *
     
    107107  UInt*         m_puiInverseCUOrderMap;
    108108
    109   SAOParam *m_saoParam;
     109  SAOBlkParam *m_saoBlkParams;
    110110public:
    111111  Void        create  ( Int iPicWidth, Int iPicHeight, UInt uiMaxWidth, UInt uiMaxHeight, UInt uiMaxDepth );
     
    144144  Void         xInitTiles();
    145145  UInt         xCalculateNxtCUAddr( UInt uiCurrCUAddr );
    146   Void allocSaoParam(TComSampleAdaptiveOffset *sao);
    147   SAOParam *getSaoParam() { return m_saoParam; }
     146  SAOBlkParam* getSAOBlkParam() { return m_saoBlkParams;}
     147  Void deriveLoopFilterBoundaryAvailibility(Int ctu, Bool& isLeftAvail,Bool& isRightAvail,Bool& isAboveAvail,Bool& isBelowAvail,Bool& isAboveLeftAvail,Bool& isAboveRightAvail,Bool& isBelowLeftAvail,Bool& isBelowRightAvail);
     148
     149
    148150};// END CLASS DEFINITION TComPicSym
    149151
  • branches/HTM-10.0-dev0/source/Lib/TLibCommon/TComPicYuv.cpp

    r608 r852  
    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 *
  • branches/HTM-10.0-dev0/source/Lib/TLibCommon/TComPicYuv.h

    r608 r852  
    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 *
  • branches/HTM-10.0-dev0/source/Lib/TLibCommon/TComPicYuvMD5.cpp

    r608 r852  
    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 *
  • branches/HTM-10.0-dev0/source/Lib/TLibCommon/TComPrediction.cpp

    r833 r852  
    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 *
  • branches/HTM-10.0-dev0/source/Lib/TLibCommon/TComPrediction.h

    r833 r852  
    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 *
  • branches/HTM-10.0-dev0/source/Lib/TLibCommon/TComRdCost.cpp

    r833 r852  
    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 *
     
    5151Double TComRdCost::m_dDisparityCoeff = 1.0;
    5252#endif
    53 
    5453TComRdCost::TComRdCost()
    5554{
     
    354353  }
    355354#endif
    356  
    357355  // initialize
    358356  rcDistParam.iSubShift  = 0;
     
    395393  }
    396394#endif
    397 
    398395  // initialize
    399396  rcDistParam.iSubShift  = 0;
     
    401398
    402399// Setting the Distortion Parameter for Inter (subpel ME with step)
    403 #if NS_HAD
    404 Void TComRdCost::setDistParam( TComPattern* pcPatternKey, Pel* piRefY, Int iRefStride, Int iStep, DistParam& rcDistParam, Bool bHADME, Bool bUseNSHAD )
    405 #else
    406400Void TComRdCost::setDistParam( TComPattern* pcPatternKey, Pel* piRefY, Int iRefStride, Int iStep, DistParam& rcDistParam, Bool bHADME )
    407 #endif
    408401{
    409402  // set Original & Curr Pointer / Stride
     
    420413  rcDistParam.iCols    = pcPatternKey->getROIYWidth();
    421414  rcDistParam.iRows    = pcPatternKey->getROIYHeight();
    422 #if NS_HAD
    423   rcDistParam.bUseNSHAD = bUseNSHAD;
    424 #endif
    425415 
    426416  // set distortion function
     
    454444  }
    455445#endif
    456  
    457446  // initialize
    458447  rcDistParam.iSubShift  = 0;
     
    460449
    461450Void
    462 #if NS_HAD
    463 TComRdCost::setDistParam( DistParam& rcDP, Pel* p1, Int iStride1, Pel* p2, Int iStride2, Int iWidth, Int iHeight, Bool bHadamard, Bool bUseNSHAD )
    464 #else
    465451TComRdCost::setDistParam( DistParam& rcDP, Int bitDepth, Pel* p1, Int iStride1, Pel* p2, Int iStride2, Int iWidth, Int iHeight, Bool bHadamard )
    466 #endif
    467452{
    468453  rcDP.pOrg       = p1;
     
    476461  rcDP.bitDepth   = bitDepth;
    477462  rcDP.DistFunc   = m_afpDistortFunc[ ( bHadamard ? DF_HADS : DF_SADS ) + g_aucConvertToBit[ iWidth ] + 1 ];
    478  
    479463#if H_3D_DBBP
    480464  if( m_bUseMask )
     
    482466    rcDP.DistFunc = (bHadamard)?TComRdCost::xGetMaskedHADs:TComRdCost::xGetMaskedSAD;
    483467  }
    484 #endif
    485  
    486 #if NS_HAD
    487   rcDP.bUseNSHAD  = bUseNSHAD;
    488468#endif
    489469}
     
    506486    }
    507487  }
    508   else if ( ( (iWidth % 4) == 0 ) && ( (iHeight % 4) == 0 ) )
    509   {
     488  else
     489  {
     490    assert(iWidth % 4 == 0 && iHeight % 4 == 0);
     491   
    510492    for ( y=0; y<iHeight; y+= 4 )
    511493    {
     
    518500    }
    519501  }
    520   else
    521   {
    522     for ( y=0; y<iHeight; y+= 2 )
    523     {
    524       for ( x=0; x<iWidth; x+= 2 )
    525       {
    526         uiSum += xCalcHADs8x8( &pi0[x], &pi1[x], iStride0, iStride1, 1 );
    527       }
    528       pi0 += iStride0*2;
    529       pi1 += iStride1*2;
    530     }
    531   }
    532502 
    533503  return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(bitDepth-8);
     
    572542
    573543
    574 #if WEIGHTED_CHROMA_DISTORTION
    575544UInt TComRdCost::getDistPart(Int bitDepth, Pel* piCur, Int iCurStride,  Pel* piOrg, Int iOrgStride, UInt uiBlkWidth, UInt uiBlkHeight, TextType eText, DFunc eDFunc)
    576 #else
    577 UInt TComRdCost::getDistPart(Int bitDepth, Pel* piCur, Int iCurStride,  Pel* piOrg, Int iOrgStride, UInt uiBlkWidth, UInt uiBlkHeight, DFunc eDFunc )
    578 #endif
    579545{
    580546  DistParam cDtParam;
     
    596562  cDtParam.bUseSDCMRSAD = false;
    597563#endif
    598 #if WEIGHTED_CHROMA_DISTORTION
    599564  if (eText == TEXT_CHROMA_U)
    600565  {
     
    609574    return cDtParam.DistFunc( &cDtParam );
    610575  }
    611 #else
    612   return cDtParam.DistFunc( &cDtParam );
    613 #endif
    614576}
    615577#if H_3D_VSO
     
    664626#endif
    665627
    666 #if (RATE_CONTROL_LAMBDA_DOMAIN && !M0036_RC_IMPROVEMENT) || KWU_RC_MADPRED_E0227
     628#if KWU_RC_MADPRED_E0227
    667629UInt TComRdCost::getSADPart ( Int bitDepth, Pel* pelCur, Int curStride,  Pel* pelOrg, Int orgStride, UInt width, UInt height )
    668630{
     
    908870}
    909871#endif
    910 
    911872// --------------------------------------------------------------------------------------------------------------------
    912873// SAD
     
    34673428}
    34683429
    3469 #if NS_HAD
    3470 UInt TComRdCost::xCalcHADs16x4( Pel *piOrg, Pel *piCur, Int iStrideOrg, Int iStrideCur, Int iStep )
    3471 {
    3472   Int k, i, j, jj, sad=0;
    3473   Int diff[64], m1[4][16], m2[4][16];
    3474   assert( iStep == 1 );
    3475   for( k = 0; k < 64; k += 16 )
    3476   {
    3477     diff[k+0] = piOrg[0] - piCur[0];
    3478     diff[k+1] = piOrg[1] - piCur[1];
    3479     diff[k+2] = piOrg[2] - piCur[2];
    3480     diff[k+3] = piOrg[3] - piCur[3];
    3481     diff[k+4] = piOrg[4] - piCur[4];
    3482     diff[k+5] = piOrg[5] - piCur[5];
    3483     diff[k+6] = piOrg[6] - piCur[6];
    3484     diff[k+7] = piOrg[7] - piCur[7];
    3485 
    3486     diff[k+8]  = piOrg[8]  - piCur[8] ;
    3487     diff[k+9]  = piOrg[9]  - piCur[9] ;
    3488     diff[k+10] = piOrg[10] - piCur[10];
    3489     diff[k+11] = piOrg[11] - piCur[11];
    3490     diff[k+12] = piOrg[12] - piCur[12];
    3491     diff[k+13] = piOrg[13] - piCur[13];
    3492     diff[k+14] = piOrg[14] - piCur[14];
    3493     diff[k+15] = piOrg[15] - piCur[15];
    3494 
    3495     piCur += iStrideCur;
    3496     piOrg += iStrideOrg;
    3497   }
    3498 
    3499   //horizontal
    3500   for (j=0; j < 4; j++)
    3501   {
    3502     jj = j << 4;
    3503 
    3504     m2[j][0]  = diff[jj  ] + diff[jj+8];
    3505     m2[j][1]  = diff[jj+1] + diff[jj+9];
    3506     m2[j][2]  = diff[jj+2] + diff[jj+10];
    3507     m2[j][3]  = diff[jj+3] + diff[jj+11];
    3508     m2[j][4]  = diff[jj+4] + diff[jj+12];
    3509     m2[j][5]  = diff[jj+5] + diff[jj+13];
    3510     m2[j][6]  = diff[jj+6] + diff[jj+14];
    3511     m2[j][7]  = diff[jj+7] + diff[jj+15];
    3512     m2[j][8]  = diff[jj  ] - diff[jj+8];
    3513     m2[j][9]  = diff[jj+1] - diff[jj+9];
    3514     m2[j][10] = diff[jj+2] - diff[jj+10];
    3515     m2[j][11] = diff[jj+3] - diff[jj+11];
    3516     m2[j][12] = diff[jj+4] - diff[jj+12];
    3517     m2[j][13] = diff[jj+5] - diff[jj+13];
    3518     m2[j][14] = diff[jj+6] - diff[jj+14];
    3519     m2[j][15] = diff[jj+7] - diff[jj+15];
    3520 
    3521     m1[j][0]  = m2[j][0]  + m2[j][4];
    3522     m1[j][1]  = m2[j][1]  + m2[j][5];
    3523     m1[j][2]  = m2[j][2]  + m2[j][6];
    3524     m1[j][3]  = m2[j][3]  + m2[j][7];
    3525     m1[j][4]  = m2[j][0]  - m2[j][4];
    3526     m1[j][5]  = m2[j][1]  - m2[j][5];
    3527     m1[j][6]  = m2[j][2]  - m2[j][6];
    3528     m1[j][7]  = m2[j][3]  - m2[j][7];
    3529     m1[j][8]  = m2[j][8]  + m2[j][12];
    3530     m1[j][9]  = m2[j][9]  + m2[j][13];
    3531     m1[j][10] = m2[j][10] + m2[j][14];
    3532     m1[j][11] = m2[j][11] + m2[j][15];
    3533     m1[j][12] = m2[j][8]  - m2[j][12];
    3534     m1[j][13] = m2[j][9]  - m2[j][13];
    3535     m1[j][14] = m2[j][10] - m2[j][14];
    3536     m1[j][15] = m2[j][11] - m2[j][15];
    3537 
    3538     m2[j][0]  = m1[j][0]  + m1[j][2];
    3539     m2[j][1]  = m1[j][1]  + m1[j][3];
    3540     m2[j][2]  = m1[j][0]  - m1[j][2];
    3541     m2[j][3]  = m1[j][1]  - m1[j][3];
    3542     m2[j][4]  = m1[j][4]  + m1[j][6];
    3543     m2[j][5]  = m1[j][5]  + m1[j][7];
    3544     m2[j][6]  = m1[j][4]  - m1[j][6];
    3545     m2[j][7]  = m1[j][5]  - m1[j][7];
    3546     m2[j][8]  = m1[j][8]  + m1[j][10];
    3547     m2[j][9]  = m1[j][9]  + m1[j][11];
    3548     m2[j][10] = m1[j][8]  - m1[j][10];
    3549     m2[j][11] = m1[j][9]  - m1[j][11];
    3550     m2[j][12] = m1[j][12] + m1[j][14];
    3551     m2[j][13] = m1[j][13] + m1[j][15];
    3552     m2[j][14] = m1[j][12] - m1[j][14];
    3553     m2[j][15] = m1[j][13] - m1[j][15];
    3554 
    3555     m1[j][0]  = m2[j][0]  + m2[j][1];
    3556     m1[j][1]  = m2[j][0]  - m2[j][1];
    3557     m1[j][2]  = m2[j][2]  + m2[j][3];
    3558     m1[j][3]  = m2[j][2]  - m2[j][3];
    3559     m1[j][4]  = m2[j][4]  + m2[j][5];
    3560     m1[j][5]  = m2[j][4]  - m2[j][5];
    3561     m1[j][6]  = m2[j][6]  + m2[j][7];
    3562     m1[j][7]  = m2[j][6]  - m2[j][7];
    3563     m1[j][8]  = m2[j][8]  + m2[j][9];
    3564     m1[j][9]  = m2[j][8]  - m2[j][9];
    3565     m1[j][10] = m2[j][10] + m2[j][11];
    3566     m1[j][11] = m2[j][10] - m2[j][11];
    3567     m1[j][12] = m2[j][12] + m2[j][13];
    3568     m1[j][13] = m2[j][12] - m2[j][13];
    3569     m1[j][14] = m2[j][14] + m2[j][15];
    3570     m1[j][15] = m2[j][14] - m2[j][15];
    3571   }
    3572 
    3573   //vertical
    3574   for (i=0; i < 16; i++)
    3575   {   
    3576     m2[0][i] = m1[0][i] + m1[2][i];
    3577     m2[1][i] = m1[1][i] + m1[3][i];
    3578     m2[2][i] = m1[0][i] - m1[2][i];
    3579     m2[3][i] = m1[1][i] - m1[3][i];
    3580 
    3581     m1[0][i] = m2[0][i] + m2[1][i];
    3582     m1[1][i] = m2[0][i] - m2[1][i];
    3583     m1[2][i] = m2[2][i] + m2[3][i];
    3584     m1[3][i] = m2[2][i] - m2[3][i];
    3585   }
    3586 
    3587   for (i = 0; i < 4; i++)
    3588   {
    3589     for (j = 0; j < 16; j++)
    3590     {
    3591       sad += abs(m1[i][j]);
    3592     }
    3593   }
    3594 
    3595   sad=((sad+2)>>2);
    3596 
    3597   return sad;
    3598 }
    3599 
    3600 UInt TComRdCost::xCalcHADs4x16( Pel *piOrg, Pel *piCur, Int iStrideOrg, Int iStrideCur, Int iStep )
    3601 {
    3602   Int k, i, j, jj, sad=0;
    3603   Int diff[64], m1[16][4], m2[16][4], m3[16][4];
    3604   assert( iStep == 1 );
    3605   for( k = 0; k < 64; k += 4 )
    3606   {
    3607     diff[k+0] = piOrg[0] - piCur[0];
    3608     diff[k+1] = piOrg[1] - piCur[1];
    3609     diff[k+2] = piOrg[2] - piCur[2];
    3610     diff[k+3] = piOrg[3] - piCur[3];
    3611 
    3612     piCur += iStrideCur;
    3613     piOrg += iStrideOrg;
    3614   }
    3615 
    3616   //horizontal
    3617   for (j=0; j < 16; j++)
    3618   {
    3619     jj = j << 2;
    3620     m2[j][0] = diff[jj  ] + diff[jj+2];
    3621     m2[j][1] = diff[jj+1] + diff[jj+3];
    3622     m2[j][2] = diff[jj  ] - diff[jj+2];
    3623     m2[j][3] = diff[jj+1] - diff[jj+3];
    3624 
    3625     m1[j][0] = m2[j][0] + m2[j][1];
    3626     m1[j][1] = m2[j][0] - m2[j][1];
    3627     m1[j][2] = m2[j][2] + m2[j][3];
    3628     m1[j][3] = m2[j][2] - m2[j][3];
    3629   }
    3630 
    3631   //vertical
    3632   for (i=0; i < 4; i++)
    3633   {
    3634     m2[0][i]  = m1[0][i] + m1[8][i];
    3635     m2[1][i]  = m1[1][i] + m1[9][i];
    3636     m2[2][i]  = m1[2][i] + m1[10][i];
    3637     m2[3][i]  = m1[3][i] + m1[11][i];
    3638     m2[4][i]  = m1[4][i] + m1[12][i];
    3639     m2[5][i]  = m1[5][i] + m1[13][i];
    3640     m2[6][i]  = m1[6][i] + m1[14][i];
    3641     m2[7][i]  = m1[7][i] + m1[15][i];
    3642     m2[8][i]  = m1[0][i] - m1[8][i];
    3643     m2[9][i]  = m1[1][i] - m1[9][i];
    3644     m2[10][i] = m1[2][i] - m1[10][i];
    3645     m2[11][i] = m1[3][i] - m1[11][i];
    3646     m2[12][i] = m1[4][i] - m1[12][i];
    3647     m2[13][i] = m1[5][i] - m1[13][i];
    3648     m2[14][i] = m1[6][i] - m1[14][i];
    3649     m2[15][i] = m1[7][i] - m1[15][i];
    3650 
    3651     m3[0][i]  = m2[0][i]  + m2[4][i];
    3652     m3[1][i]  = m2[1][i]  + m2[5][i];
    3653     m3[2][i]  = m2[2][i]  + m2[6][i];
    3654     m3[3][i]  = m2[3][i]  + m2[7][i];
    3655     m3[4][i]  = m2[0][i]  - m2[4][i];
    3656     m3[5][i]  = m2[1][i]  - m2[5][i];
    3657     m3[6][i]  = m2[2][i]  - m2[6][i];
    3658     m3[7][i]  = m2[3][i]  - m2[7][i];
    3659     m3[8][i]  = m2[8][i]  + m2[12][i];
    3660     m3[9][i]  = m2[9][i]  + m2[13][i];
    3661     m3[10][i] = m2[10][i] + m2[14][i];
    3662     m3[11][i] = m2[11][i] + m2[15][i];
    3663     m3[12][i] = m2[8][i]  - m2[12][i];
    3664     m3[13][i] = m2[9][i]  - m2[13][i];
    3665     m3[14][i] = m2[10][i] - m2[14][i];
    3666     m3[15][i] = m2[11][i] - m2[15][i];
    3667 
    3668     m1[0][i]  = m3[0][i]  + m3[2][i];
    3669     m1[1][i]  = m3[1][i]  + m3[3][i];
    3670     m1[2][i]  = m3[0][i]  - m3[2][i];
    3671     m1[3][i]  = m3[1][i]  - m3[3][i];
    3672     m1[4][i]  = m3[4][i]  + m3[6][i];
    3673     m1[5][i]  = m3[5][i]  + m3[7][i];
    3674     m1[6][i]  = m3[4][i]  - m3[6][i];
    3675     m1[7][i]  = m3[5][i]  - m3[7][i];
    3676     m1[8][i]  = m3[8][i]  + m3[10][i];
    3677     m1[9][i]  = m3[9][i]  + m3[11][i];
    3678     m1[10][i] = m3[8][i]  - m3[10][i];
    3679     m1[11][i] = m3[9][i]  - m3[11][i];
    3680     m1[12][i] = m3[12][i] + m3[14][i];
    3681     m1[13][i] = m3[13][i] + m3[15][i];
    3682     m1[14][i] = m3[12][i] - m3[14][i];
    3683     m1[15][i] = m3[13][i] - m3[15][i];
    3684 
    3685     m2[0][i]  = m1[0][i]  + m1[1][i];
    3686     m2[1][i]  = m1[0][i]  - m1[1][i];
    3687     m2[2][i]  = m1[2][i]  + m1[3][i];
    3688     m2[3][i]  = m1[2][i]  - m1[3][i];
    3689     m2[4][i]  = m1[4][i]  + m1[5][i];
    3690     m2[5][i]  = m1[4][i]  - m1[5][i];
    3691     m2[6][i]  = m1[6][i]  + m1[7][i];
    3692     m2[7][i]  = m1[6][i]  - m1[7][i];
    3693     m2[8][i]  = m1[8][i]  + m1[9][i];
    3694     m2[9][i]  = m1[8][i]  - m1[9][i];
    3695     m2[10][i] = m1[10][i] + m1[11][i];
    3696     m2[11][i] = m1[10][i] - m1[11][i];
    3697     m2[12][i] = m1[12][i] + m1[13][i];
    3698     m2[13][i] = m1[12][i] - m1[13][i];
    3699     m2[14][i] = m1[14][i] + m1[15][i];
    3700     m2[15][i] = m1[14][i] - m1[15][i];
    3701   }
    3702 
    3703   for (i = 0; i < 16; i++)
    3704   {
    3705     for (j = 0; j < 4; j++)
    3706     {
    3707       sad += abs(m2[i][j]);
    3708     }
    3709   }
    3710 
    3711   sad=((sad+2)>>2);
    3712 
    3713   return sad;
    3714 }
    3715 #endif
    3716 
    37173430UInt TComRdCost::xGetHADs4( DistParam* pcDtParam )
    37183431{
     
    38093522  UInt uiSum = 0;
    38103523 
    3811 #if NS_HAD
    3812   if( ( ( iRows % 8 == 0) && (iCols % 8 == 0) && ( iRows == iCols ) ) || ( ( iRows % 8 == 0 ) && (iCols % 8 == 0) && !pcDtParam->bUseNSHAD ) )
    3813 #else
    38143524  if( ( iRows % 8 == 0) && (iCols % 8 == 0) )
    3815 #endif
    38163525  {
    38173526    Int  iOffsetOrg = iStrideOrg<<3;
     
    38273536    }
    38283537  }
    3829 #if NS_HAD
    3830   else if ( ( iCols > 8 ) && ( iCols > iRows ) && pcDtParam->bUseNSHAD )
    3831   {
    3832     Int  iOffsetOrg = iStrideOrg<<2;
    3833     Int  iOffsetCur = iStrideCur<<2;
    3834     for ( y=0; y<iRows; y+= 4 )
    3835     {
    3836       for ( x=0; x<iCols; x+= 16 )
    3837       {
    3838         uiSum += xCalcHADs16x4( &piOrg[x], &piCur[x*iStep], iStrideOrg, iStrideCur, iStep );
    3839       }
    3840       piOrg += iOffsetOrg;
    3841       piCur += iOffsetCur;
    3842     }
    3843   }
    3844   else if ( ( iRows > 8 ) && ( iCols < iRows ) && pcDtParam->bUseNSHAD )
    3845   {
    3846     Int  iOffsetOrg = iStrideOrg<<4;
    3847     Int  iOffsetCur = iStrideCur<<4;
    3848     for ( y=0; y<iRows; y+= 16 )
    3849     {
    3850       for ( x=0; x<iCols; x+= 4 )
    3851       {
    3852         uiSum += xCalcHADs4x16( &piOrg[x], &piCur[x*iStep], iStrideOrg, iStrideCur, iStep );
    3853       }
    3854       piOrg += iOffsetOrg;
    3855       piCur += iOffsetCur;
    3856     }
    3857   }
    3858 #endif
    38593538  else if( ( iRows % 4 == 0) && (iCols % 4 == 0) )
    38603539  {
  • branches/HTM-10.0-dev0/source/Lib/TLibCommon/TComRdCost.h

    r833 r852  
    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 *
     
    107107  UInt            uiComp;           // uiComp = 0 (luma Y), 1 (chroma U), 2 (chroma V)
    108108
    109 #if NS_HAD
    110   Bool            bUseNSHAD;
    111 #endif
    112 
    113109  // (vertical) subsampling shift (for reducing complexity)
    114110  // - 0 = no subsampling, 1 = even rows, 2 = every 4th, etc.
     
    127123    iSubShift = 0;
    128124    bitDepth = 0;
    129 #if NS_HAD
    130     bUseNSHAD = false;
    131 #endif
    132125#if H_3D_VSO
    133126    // SAIT_VSO_EST_A0033
     
    155148#endif 
    156149 
    157 #if WEIGHTED_CHROMA_DISTORTION
    158150  Double                  m_cbDistortionWeight;
    159151  Double                  m_crDistortionWeight;
    160 #endif
    161152  Double                  m_dLambda;
    162153  Double                  m_sqrtLambda;
     
    201192
    202193 
    203 #if WEIGHTED_CHROMA_DISTORTION
    204194  Void    setCbDistortionWeight      ( Double cbDistortionWeight) { m_cbDistortionWeight = cbDistortionWeight; };
    205195  Void    setCrDistortionWeight      ( Double crDistortionWeight) { m_crDistortionWeight = crDistortionWeight; };
    206 #endif
    207196  Void    setLambda      ( Double dLambda );
    208197  Void    setFrameLambda ( Double dLambda ) { m_dFrameLambda = dLambda; }
     
    215204#endif
    216205
    217 #if RATE_CONTROL_LAMBDA_DOMAIN
    218206  Double  getLambda() { return m_dLambda; }
    219 #if M0036_RC_IMPROVEMENT
    220207  Double  getChromaWeight () {return((m_cbDistortionWeight+m_crDistortionWeight)/2.0);}
    221 #endif
    222 #endif
    223208 
    224209  // Distortion Functions
     
    227212  Void    setDistParam( UInt uiBlkWidth, UInt uiBlkHeight, DFunc eDFunc, DistParam& rcDistParam );
    228213  Void    setDistParam( TComPattern* pcPatternKey, Pel* piRefY, Int iRefStride,            DistParam& rcDistParam );
    229 #if NS_HAD
    230   Void    setDistParam( TComPattern* pcPatternKey, Pel* piRefY, Int iRefStride, Int iStep, DistParam& rcDistParam, Bool bHADME=false, Bool bUseNSHAD=false );
    231   Void    setDistParam( DistParam& rcDP, Int bitDepth, Pel* p1, Int iStride1, Pel* p2, Int iStride2, Int iWidth, Int iHeight, Bool bHadamard = false, Bool bUseNSHAD=false );
    232 #else
    233214  Void    setDistParam( TComPattern* pcPatternKey, Pel* piRefY, Int iRefStride, Int iStep, DistParam& rcDistParam, Bool bHADME=false );
    234215  Void    setDistParam( DistParam& rcDP, Int bitDepth, Pel* p1, Int iStride1, Pel* p2, Int iStride2, Int iWidth, Int iHeight, Bool bHadamard = false );
    235 #endif
    236216 
    237217#if H_3D_DBBP
     
    337317  static UInt xCalcHADs4x4      ( Pel *piOrg, Pel *piCurr, Int iStrideOrg, Int iStrideCur, Int iStep );
    338318  static UInt xCalcHADs8x8      ( Pel *piOrg, Pel *piCurr, Int iStrideOrg, Int iStrideCur, Int iStep );
    339 #if NS_HAD
    340   static UInt xCalcHADs16x4     ( Pel *piOrg, Pel *piCurr, Int iStrideOrg, Int iStrideCur, Int iStep );
    341   static UInt xCalcHADs4x16     ( Pel *piOrg, Pel *piCurr, Int iStrideOrg, Int iStrideCur, Int iStep );
    342 #endif
    343  
    344319#if H_3D_DBBP
    345320  static UInt xGetMaskedSSE     ( DistParam* pcDtParam );
     
    350325 
    351326public:
    352 #if WEIGHTED_CHROMA_DISTORTION
    353327  UInt   getDistPart(Int bitDepth, Pel* piCur, Int iCurStride,  Pel* piOrg, Int iOrgStride, UInt uiBlkWidth, UInt uiBlkHeight, TextType eText = TEXT_LUMA, DFunc eDFunc = DF_SSE );
    354 #else
    355   UInt   getDistPart(Int bitDepth, Pel* piCur, Int iCurStride,  Pel* piOrg, Int iOrgStride, UInt uiBlkWidth, UInt uiBlkHeight, DFunc eDFunc = DF_SSE );
    356 #endif
    357 
    358 #if (RATE_CONTROL_LAMBDA_DOMAIN && !M0036_RC_IMPROVEMENT) || KWU_RC_MADPRED_E0227
     328
     329#if KWU_RC_MADPRED_E0227
    359330  UInt   getSADPart ( Int bitDepth, Pel* pelCur, Int curStride,  Pel* pelOrg, Int orgStride, UInt width, UInt height );
    360331#endif
  • branches/HTM-10.0-dev0/source/Lib/TLibCommon/TComRdCostWeightPrediction.cpp

    r608 r852  
    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 *
  • branches/HTM-10.0-dev0/source/Lib/TLibCommon/TComRdCostWeightPrediction.h

    r608 r852  
    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 *
  • branches/HTM-10.0-dev0/source/Lib/TLibCommon/TComRom.cpp

    r773 r852  
    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 *
     
    327327UInt g_uiPCMBitDepthChroma   = 8;    // PCM bit-depth
    328328
     329#if H_3D_DIM_DMM
    329330// ====================================================================================================================
    330331// Depth coding modes
    331332// ====================================================================================================================
    332 #if H_3D_DIM_DMM
    333333const WedgeResolution g_dmmWedgeResolution[6] =
    334334{
     
    372372Bool g_traceTU = true;
    373373Bool g_disableHLSTrace = false;
    374 UInt64 g_stopAtCounter       = 48;
     374UInt64 g_stopAtCounter       = 0;
    375375Bool g_traceCopyBack         = false;
    376376Bool g_decTraceDispDer       = false;
    377377Bool g_decTraceMvFromMerge   = false;
     378Bool g_stopAtPos             = false;
     379Bool g_outputPos             = false;
    378380#endif
    379381#endif
     
    395397const UInt g_uiMinInGroup[ 10 ] = {0,1,2,3,4,6,8,12,16,24};
    396398const UInt g_uiGroupIdx[ 32 ]   = {0,1,2,3,4,4,5,5,6,6,6,6,7,7,7,7,8,8,8,8,8,8,8,8,9,9,9,9,9,9,9,9};
    397 
    398 // Rice parameters for absolute transform levels
    399 const UInt g_auiGoRiceRange[5] =
    400 {
    401   7, 14, 26, 46, 78
    402 };
    403 
    404 const UInt g_auiGoRicePrefixLen[5] =
    405 {
    406   8, 7, 6, 5, 4
    407 };
    408399
    409400Void initSigLastScan(UInt* pBuffD, UInt* pBuffH, UInt* pBuffV, Int iWidth, Int iHeight)
     
    573564#if H_MV_ENC_DEC_TRAC
    574565#if ENC_DEC_TRACE
     566Void stopAtPos( Int poc, Int layerId, Int cuPelX, Int cuPelY, Int cuWidth, Int cuHeight )
     567{
     568
     569  if ( g_outputPos )
     570  {
     571    std::cout << "POC\t"        << poc
     572              << "\tLayerId\t"  << layerId
     573              << "\tCuPelX\t"   << cuPelX 
     574              << "\tCuPelY\t"   << cuPelY
     575              << "\tCuWidth\t"  << cuWidth
     576              << "\tCuHeight\t" << cuHeight
     577              << std::endl;
     578  }
     579
     580  Bool stopFlag = false;
     581  if ( g_stopAtPos && poc == 0 && layerId == 1 )
     582  {
     583    Bool stopAtCU = true;
     584    if ( stopAtCU )        // Stop at CU with specific size
     585    {   
     586      stopFlag = ( cuPelX  == 888 ) && ( cuPelY  == 248 ) && ( cuWidth == 8 ) && ( cuHeight == 8);
     587    }
     588    else
     589    {                     // Stop at specific position
     590      Int xPos = 888;
     591      Int yPos = 248;
     592
     593      Int cuPelXEnd = cuPelX + cuWidth  - 1;
     594      Int cuPelYEnd = cuPelY + cuHeight - 1;
     595
     596      stopFlag = (cuPelX <= xPos ) && (cuPelXEnd >= xPos ) && (cuPelY <= yPos ) && (cuPelYEnd >= yPos );
     597    }
     598  }
     599 
     600  if ( stopFlag )
     601  { // Set breakpoint here.
     602    std::cout << "Stop position. Break point here." << std::endl;
     603  } 
     604}
     605
    575606Void writeToTraceFile( const Char* symbolName, Int val, Bool doIt )
    576607{
  • branches/HTM-10.0-dev0/source/Lib/TLibCommon/TComRom.h

    r773 r852  
    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 *
     
    126126extern const UInt   g_uiMinInGroup[ 10 ];
    127127
    128 extern const UInt   g_auiGoRiceRange[5];                  //!< maximum value coded with Rice codes
    129 extern const UInt   g_auiGoRicePrefixLen[5];              //!< prefix length for each maximum value
    130  
    131128extern const UInt   g_sigLastScan8x8[ 3 ][ 4 ];           //!< coefficient group scan order for 8x8 TUs
    132129extern       UInt   g_sigLastScanCG32x32[ 64 ];
     
    222219 extern UInt64 g_stopAtCounter;         // Counter to set breakpoint.
    223220 extern Bool   g_traceCopyBack;         // Output samples on copy back 
    224  extern Bool   g_decTraceDispDer; // Trace derived disparity vectors (decoder only)
     221 extern Bool   g_decTraceDispDer;       // Trace derived disparity vectors (decoder only)
    225222 extern Bool   g_decTraceMvFromMerge;   // Trace motion vectors obtained from merge (decoder only)
     223 extern Bool   g_stopAtPos;             // Stop at position
     224 extern Bool   g_outputPos;             // Output position
    226225
    227226#define DTRACE_CU(x,y)             writeToTraceFile( x,y, g_traceCU );
     
    232231#define DTRACE_TU_S(x)             writeToTraceFile( x,   g_traceTU );
    233232
    234 
    235233 Void           writeToTraceFile( const Char* symbolName, Int val, Bool doIt );
    236234 Void           writeToTraceFile( const Char* symbolName, Bool doIt );
     235 Void           stopAtPos       ( Int poc, Int layerId, Int cuPelX, Int cuPelY, Int cuWidth, Int cuHeight );
    237236#endif
    238237#else
  • branches/HTM-10.0-dev0/source/Lib/TLibCommon/TComSampleAdaptiveOffset.cpp

    r608 r852  
    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 *
     
    4141#include <stdio.h>
    4242#include <math.h>
    43 
    4443//! \ingroup TLibCommon
    4544//! \{
    46 
    47 SAOParam::~SAOParam()
    48 {
    49   for (Int i = 0 ; i<3; i++)
    50   {
    51     if (psSaoPart[i])
    52     {
    53       delete [] psSaoPart[i];
    54     }
    55   }
    56 }
    57 
    58 // ====================================================================================================================
    59 // Tables
    60 // ====================================================================================================================
     45UInt g_saoMaxOffsetQVal[NUM_SAO_COMPONENTS];
     46
     47SAOOffset::SAOOffset()
     48{
     49  reset();
     50}
     51
     52SAOOffset::~SAOOffset()
     53{
     54
     55}
     56
     57Void SAOOffset::reset()
     58{
     59  modeIdc = SAO_MODE_OFF;
     60  typeIdc = -1;
     61  typeAuxInfo = -1;
     62  ::memset(offset, 0, sizeof(Int)* MAX_NUM_SAO_CLASSES);
     63}
     64
     65const SAOOffset& SAOOffset::operator= (const SAOOffset& src)
     66{
     67  modeIdc = src.modeIdc;
     68  typeIdc = src.typeIdc;
     69  typeAuxInfo = src.typeAuxInfo;
     70  ::memcpy(offset, src.offset, sizeof(Int)* MAX_NUM_SAO_CLASSES);
     71
     72  return *this;
     73}
     74
     75
     76SAOBlkParam::SAOBlkParam()
     77{
     78  reset();
     79}
     80
     81SAOBlkParam::~SAOBlkParam()
     82{
     83
     84}
     85
     86Void SAOBlkParam::reset()
     87{
     88  for(Int compIdx=0; compIdx< 3; compIdx++)
     89  {
     90    offsetParam[compIdx].reset();
     91  }
     92}
     93
     94const SAOBlkParam& SAOBlkParam::operator= (const SAOBlkParam& src)
     95{
     96  for(Int compIdx=0; compIdx< 3; compIdx++)
     97  {
     98    offsetParam[compIdx] = src.offsetParam[compIdx];
     99  }
     100  return *this;
     101
     102}
    61103
    62104TComSampleAdaptiveOffset::TComSampleAdaptiveOffset()
    63105{
    64   m_pClipTable = NULL;
    65   m_pClipTableBase = NULL;
    66   m_pChromaClipTable = NULL;
    67   m_pChromaClipTableBase = NULL;
    68   m_iOffsetBo = NULL;
    69   m_iChromaOffsetBo = NULL;
    70   m_lumaTableBo = NULL;
    71   m_chromaTableBo = NULL;
    72   m_iUpBuff1 = NULL;
    73   m_iUpBuff2 = NULL;
    74   m_iUpBufft = NULL;
    75   ipSwap = NULL;
    76 
    77   m_pTmpU1 = NULL;
    78   m_pTmpU2 = NULL;
    79   m_pTmpL1 = NULL;
    80   m_pTmpL2 = NULL;
    81 }
     106  m_tempPicYuv = NULL;
     107  for(Int compIdx=0; compIdx < NUM_SAO_COMPONENTS; compIdx++)
     108  {
     109    m_offsetClipTable[compIdx] = NULL;
     110  }
     111  m_signTable = NULL;
     112
     113 
     114  m_lineBufWidth = 0;
     115  m_signLineBuf1 = NULL;
     116  m_signLineBuf2 = NULL;
     117}
     118
    82119
    83120TComSampleAdaptiveOffset::~TComSampleAdaptiveOffset()
    84121{
    85 
    86 }
    87 
    88 const Int TComSampleAdaptiveOffset::m_aiNumCulPartsLevel[5] =
    89 {
    90   1,   //level 0
    91   5,   //level 1
    92   21,  //level 2
    93   85,  //level 3
    94   341, //level 4
    95 };
    96 
    97 const UInt TComSampleAdaptiveOffset::m_auiEoTable[9] =
    98 {
    99   1, //0   
    100   2, //1   
    101   0, //2
    102   3, //3
    103   4, //4
    104   0, //5 
    105   0, //6 
    106   0, //7
    107   0
    108 };
    109 
    110 const Int TComSampleAdaptiveOffset::m_iNumClass[MAX_NUM_SAO_TYPE] =
    111 {
    112   SAO_EO_LEN,
    113   SAO_EO_LEN,
    114   SAO_EO_LEN,
    115   SAO_EO_LEN,
    116   SAO_BO_LEN
    117 };
    118 
    119 const UInt TComSampleAdaptiveOffset::m_uiMaxDepth = SAO_MAX_DEPTH;
    120 
    121 
    122 /** convert Level Row Col to Idx
    123  * \param   level,  row,  col
    124  */
    125 Int  TComSampleAdaptiveOffset::convertLevelRowCol2Idx(Int level, Int row, Int col)
    126 {
    127   Int idx;
    128   if (level == 0)
    129   {
    130     idx = 0;
    131   }
    132   else if (level == 1)
    133   {
    134     idx = 1 + row*2 + col;
    135   }
    136   else if (level == 2)
    137   {
    138     idx = 5 + row*4 + col;
    139   }
    140   else if (level == 3)
    141   {
    142     idx = 21 + row*8 + col;
    143   }
    144   else // (level == 4)
    145   {
    146     idx = 85 + row*16 + col;
    147   }
    148   return idx;
    149 }
    150 
    151 /** create SampleAdaptiveOffset memory.
    152  * \param
    153  */
    154 Void TComSampleAdaptiveOffset::create( UInt uiSourceWidth, UInt uiSourceHeight, UInt uiMaxCUWidth, UInt uiMaxCUHeight )
    155 {
    156   m_iPicWidth  = uiSourceWidth;
    157   m_iPicHeight = uiSourceHeight;
    158 
    159   m_uiMaxCUWidth  = uiMaxCUWidth;
    160   m_uiMaxCUHeight = uiMaxCUHeight;
    161 
    162   m_iNumCuInWidth  = m_iPicWidth / m_uiMaxCUWidth;
    163   m_iNumCuInWidth += ( m_iPicWidth % m_uiMaxCUWidth ) ? 1 : 0;
    164 
    165   m_iNumCuInHeight  = m_iPicHeight / m_uiMaxCUHeight;
    166   m_iNumCuInHeight += ( m_iPicHeight % m_uiMaxCUHeight ) ? 1 : 0;
    167 
    168   Int iMaxSplitLevelHeight = (Int)(logf((Float)m_iNumCuInHeight)/logf(2.0));
    169   Int iMaxSplitLevelWidth  = (Int)(logf((Float)m_iNumCuInWidth )/logf(2.0));
    170 
    171   m_uiMaxSplitLevel = (iMaxSplitLevelHeight < iMaxSplitLevelWidth)?(iMaxSplitLevelHeight):(iMaxSplitLevelWidth);
    172   m_uiMaxSplitLevel = (m_uiMaxSplitLevel< m_uiMaxDepth)?(m_uiMaxSplitLevel):(m_uiMaxDepth);
    173   /* various structures are overloaded to store per component data.
    174    * m_iNumTotalParts must allow for sufficient storage in any allocated arrays */
    175   m_iNumTotalParts  = max(3,m_aiNumCulPartsLevel[m_uiMaxSplitLevel]);
    176 
    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 
    195   m_iUpBuff1 = new Int[m_iPicWidth+2];
    196   m_iUpBuff2 = new Int[m_iPicWidth+2];
    197   m_iUpBufft = new Int[m_iPicWidth+2];
    198 
    199   m_iUpBuff1++;
    200   m_iUpBuff2++;
    201   m_iUpBufft++;
    202   Pel i;
    203 
    204   UInt uiMaxY  = (1 << g_bitDepthY) - 1;;
    205   UInt uiMinY  = 0;
    206 
    207   Int iCRangeExt = uiMaxY>>1;
    208 
    209   m_pClipTableBase = new Pel[uiMaxY+2*iCRangeExt];
    210   m_iOffsetBo      = new Int[uiMaxY+2*iCRangeExt];
    211 
    212   for(i=0;i<(uiMinY+iCRangeExt);i++)
    213   {
    214     m_pClipTableBase[i] = uiMinY;
    215   }
    216 
    217   for(i=uiMinY+iCRangeExt;i<(uiMaxY+  iCRangeExt);i++)
    218   {
    219     m_pClipTableBase[i] = i-iCRangeExt;
    220   }
    221 
    222   for(i=uiMaxY+iCRangeExt;i<(uiMaxY+2*iCRangeExt);i++)
    223   {
    224     m_pClipTableBase[i] = uiMaxY;
    225   }
    226 
    227   m_pClipTable = &(m_pClipTableBase[iCRangeExt]);
    228 
    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 
    254   m_pTmpL1 = new Pel [m_uiMaxCUHeight+1];
    255   m_pTmpL2 = new Pel [m_uiMaxCUHeight+1];
    256   m_pTmpU1 = new Pel [m_iPicWidth];
    257   m_pTmpU2 = new Pel [m_iPicWidth];
    258 }
    259 
    260 /** destroy SampleAdaptiveOffset memory.
    261  * \param
    262  */
     122  destroy();
     123 
     124  if (m_signLineBuf1) delete[] m_signLineBuf1; m_signLineBuf1 = NULL;
     125  if (m_signLineBuf2) delete[] m_signLineBuf2; m_signLineBuf2 = NULL;
     126}
     127
     128Void TComSampleAdaptiveOffset::create( Int picWidth, Int picHeight, UInt maxCUWidth, UInt maxCUHeight, UInt maxCUDepth )
     129{
     130  destroy();
     131
     132  m_picWidth = picWidth;   
     133  m_picHeight= picHeight;
     134  m_maxCUWidth= maxCUWidth;
     135  m_maxCUHeight= maxCUHeight;
     136
     137  m_numCTUInWidth = (m_picWidth/m_maxCUWidth) + ((m_picWidth % m_maxCUWidth)?1:0);
     138  m_numCTUInHeight= (m_picHeight/m_maxCUHeight) + ((m_picHeight % m_maxCUHeight)?1:0);
     139  m_numCTUsPic = m_numCTUInHeight*m_numCTUInWidth;
     140
     141  //temporary picture buffer
     142  if ( !m_tempPicYuv )
     143  {
     144    m_tempPicYuv = new TComPicYuv;
     145    m_tempPicYuv->create( m_picWidth, m_picHeight, m_maxCUWidth, m_maxCUHeight, maxCUDepth );
     146  }
     147
     148  //bit-depth related
     149  for(Int compIdx =0; compIdx < NUM_SAO_COMPONENTS; compIdx++)
     150  {
     151    Int bitDepthSample = (compIdx == SAO_Y)?g_bitDepthY:g_bitDepthC;
     152    m_offsetStepLog2  [compIdx] = max(bitDepthSample - MAX_SAO_TRUNCATED_BITDEPTH, 0);
     153    g_saoMaxOffsetQVal[compIdx] = (1<<(min(bitDepthSample,MAX_SAO_TRUNCATED_BITDEPTH)-5))-1; //Table 9-32, inclusive
     154  }
     155
     156  //look-up table for clipping
     157  for(Int compIdx =0; compIdx < NUM_SAO_COMPONENTS; compIdx++)
     158  {
     159    Int bitDepthSample = (compIdx == SAO_Y)?g_bitDepthY:g_bitDepthC; //exclusive
     160    Int maxSampleValue = (1<< bitDepthSample); //exclusive
     161    Int maxOffsetValue = (g_saoMaxOffsetQVal[compIdx] << m_offsetStepLog2[compIdx]);
     162
     163    m_offsetClipTable[compIdx] = new Int[(maxSampleValue + maxOffsetValue -1)+ (maxOffsetValue)+1 ]; //positive & negative range plus 0
     164    m_offsetClip[compIdx] = &(m_offsetClipTable[compIdx][maxOffsetValue]);
     165
     166    //assign clipped values
     167    Int* offsetClipPtr = m_offsetClip[compIdx];
     168    for(Int k=0; k< maxSampleValue; k++)
     169    {
     170      *(offsetClipPtr + k) = k;
     171    }
     172    for(Int k=0; k< maxOffsetValue; k++ )
     173    {
     174      *(offsetClipPtr + maxSampleValue+ k) = maxSampleValue-1;
     175      *(offsetClipPtr -k -1 )              = 0;
     176    }
     177    if(compIdx == SAO_Y) //g_bitDepthY is always larger than or equal to g_bitDepthC
     178    {
     179      m_signTable = new Short[ 2*(maxSampleValue-1) + 1 ];
     180      m_sign = &(m_signTable[maxSampleValue-1]);
     181
     182      m_sign[0] = 0;
     183      for(Int k=1; k< maxSampleValue; k++)
     184      {
     185        m_sign[k] = 1;
     186        m_sign[-k]= -1;
     187      }
     188    }
     189  } 
     190
     191}
     192
    263193Void TComSampleAdaptiveOffset::destroy()
    264194{
    265   if (m_pClipTableBase)
    266   {
    267     delete [] m_pClipTableBase; m_pClipTableBase = NULL;
    268   }
    269   if (m_iOffsetBo)
    270   {
    271     delete [] m_iOffsetBo; m_iOffsetBo = NULL;
    272   }
    273   if (m_lumaTableBo)
    274   {
    275     delete[] m_lumaTableBo; m_lumaTableBo = NULL;
    276   }
    277 
    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 
    291   if (m_iUpBuff1)
    292   {
    293     m_iUpBuff1--;
    294     delete [] m_iUpBuff1; m_iUpBuff1 = NULL;
    295   }
    296   if (m_iUpBuff2)
    297   {
    298     m_iUpBuff2--;
    299     delete [] m_iUpBuff2; m_iUpBuff2 = NULL;
    300   }
    301   if (m_iUpBufft)
    302   {
    303     m_iUpBufft--;
    304     delete [] m_iUpBufft; m_iUpBufft = NULL;
    305   }
    306   if (m_pTmpL1)
    307   {
    308     delete [] m_pTmpL1; m_pTmpL1 = NULL;
    309   }
    310   if (m_pTmpL2)
    311   {
    312     delete [] m_pTmpL2; m_pTmpL2 = NULL;
    313   }
    314   if (m_pTmpU1)
    315   {
    316     delete [] m_pTmpU1; m_pTmpU1 = NULL;
    317   }
    318   if (m_pTmpU2)
    319   {
    320     delete [] m_pTmpU2; m_pTmpU2 = NULL;
    321   }
    322 }
    323 
    324 /** allocate memory for SAO parameters
    325  * \param    *pcSaoParam
    326  */
    327 Void TComSampleAdaptiveOffset::allocSaoParam(SAOParam *pcSaoParam)
    328 {
    329   pcSaoParam->iMaxSplitLevel = m_uiMaxSplitLevel;
    330   pcSaoParam->psSaoPart[0] = new SAOQTPart[ m_aiNumCulPartsLevel[pcSaoParam->iMaxSplitLevel] ];
    331   initSAOParam(pcSaoParam, 0, 0, 0, -1, 0, m_iNumCuInWidth-1,  0, m_iNumCuInHeight-1,0);
    332   pcSaoParam->psSaoPart[1] = new SAOQTPart[ m_aiNumCulPartsLevel[pcSaoParam->iMaxSplitLevel] ];
    333   pcSaoParam->psSaoPart[2] = new SAOQTPart[ m_aiNumCulPartsLevel[pcSaoParam->iMaxSplitLevel] ];
    334   initSAOParam(pcSaoParam, 0, 0, 0, -1, 0, m_iNumCuInWidth-1,  0, m_iNumCuInHeight-1,1);
    335   initSAOParam(pcSaoParam, 0, 0, 0, -1, 0, m_iNumCuInWidth-1,  0, m_iNumCuInHeight-1,2);
    336   pcSaoParam->numCuInWidth  = m_iNumCuInWidth;
    337   pcSaoParam->numCuInHeight = m_iNumCuInHeight;
    338   pcSaoParam->saoLcuParam[0] = new SaoLcuParam [m_iNumCuInHeight*m_iNumCuInWidth];
    339   pcSaoParam->saoLcuParam[1] = new SaoLcuParam [m_iNumCuInHeight*m_iNumCuInWidth];
    340   pcSaoParam->saoLcuParam[2] = new SaoLcuParam [m_iNumCuInHeight*m_iNumCuInWidth];
    341 }
    342 
    343 /** initialize SAO parameters
    344  * \param    *pcSaoParam,  iPartLevel,  iPartRow,  iPartCol,  iParentPartIdx,  StartCUX,  EndCUX,  StartCUY,  EndCUY,  iYCbCr
    345  */
    346 Void TComSampleAdaptiveOffset::initSAOParam(SAOParam *pcSaoParam, Int iPartLevel, Int iPartRow, Int iPartCol, Int iParentPartIdx, Int StartCUX, Int EndCUX, Int StartCUY, Int EndCUY, Int iYCbCr)
    347 {
    348   Int j;
    349   Int iPartIdx = convertLevelRowCol2Idx(iPartLevel, iPartRow, iPartCol);
    350 
    351   SAOQTPart* pSaoPart;
    352 
    353   pSaoPart = &(pcSaoParam->psSaoPart[iYCbCr][iPartIdx]);
    354 
    355   pSaoPart->PartIdx   = iPartIdx;
    356   pSaoPart->PartLevel = iPartLevel;
    357   pSaoPart->PartRow   = iPartRow;
    358   pSaoPart->PartCol   = iPartCol;
    359 
    360   pSaoPart->StartCUX  = StartCUX;
    361   pSaoPart->EndCUX    = EndCUX;
    362   pSaoPart->StartCUY  = StartCUY;
    363   pSaoPart->EndCUY    = EndCUY;
    364 
    365   pSaoPart->UpPartIdx = iParentPartIdx;
    366   pSaoPart->iBestType   = -1;
    367   pSaoPart->iLength     =  0;
    368 
    369   pSaoPart->subTypeIdx = 0;
    370 
    371   for (j=0;j<MAX_NUM_SAO_OFFSETS;j++)
    372   {
    373     pSaoPart->iOffset[j] = 0;
    374   }
    375 
    376   if(pSaoPart->PartLevel != m_uiMaxSplitLevel)
    377   {
    378     Int DownLevel    = (iPartLevel+1 );
    379     Int DownRowStart = (iPartRow << 1);
    380     Int DownColStart = (iPartCol << 1);
    381 
    382     Int iDownRowIdx, iDownColIdx;
    383     Int NumCUWidth,  NumCUHeight;
    384     Int NumCULeft;
    385     Int NumCUTop;
    386 
    387     Int DownStartCUX, DownStartCUY;
    388     Int DownEndCUX, DownEndCUY;
    389 
    390     NumCUWidth  = EndCUX - StartCUX +1;
    391     NumCUHeight = EndCUY - StartCUY +1;
    392     NumCULeft   = (NumCUWidth  >> 1);
    393     NumCUTop    = (NumCUHeight >> 1);
    394 
    395     DownStartCUX= StartCUX;
    396     DownEndCUX  = DownStartCUX + NumCULeft - 1;
    397     DownStartCUY= StartCUY;
    398     DownEndCUY  = DownStartCUY + NumCUTop  - 1;
    399     iDownRowIdx = DownRowStart + 0;
    400     iDownColIdx = DownColStart + 0;
    401 
    402     pSaoPart->DownPartsIdx[0]= convertLevelRowCol2Idx(DownLevel, iDownRowIdx, iDownColIdx);
    403 
    404     initSAOParam(pcSaoParam, DownLevel, iDownRowIdx, iDownColIdx, iPartIdx, DownStartCUX, DownEndCUX, DownStartCUY, DownEndCUY, iYCbCr);
    405 
    406     DownStartCUX = StartCUX + NumCULeft;
    407     DownEndCUX   = EndCUX;
    408     DownStartCUY = StartCUY;
    409     DownEndCUY   = DownStartCUY + NumCUTop -1;
    410     iDownRowIdx  = DownRowStart + 0;
    411     iDownColIdx  = DownColStart + 1;
    412 
    413     pSaoPart->DownPartsIdx[1] = convertLevelRowCol2Idx(DownLevel, iDownRowIdx, iDownColIdx);
    414 
    415     initSAOParam(pcSaoParam, DownLevel, iDownRowIdx, iDownColIdx, iPartIdx,  DownStartCUX, DownEndCUX, DownStartCUY, DownEndCUY, iYCbCr);
    416 
    417     DownStartCUX = StartCUX;
    418     DownEndCUX   = DownStartCUX + NumCULeft -1;
    419     DownStartCUY = StartCUY + NumCUTop;
    420     DownEndCUY   = EndCUY;
    421     iDownRowIdx  = DownRowStart + 1;
    422     iDownColIdx  = DownColStart + 0;
    423 
    424     pSaoPart->DownPartsIdx[2] = convertLevelRowCol2Idx(DownLevel, iDownRowIdx, iDownColIdx);
    425 
    426     initSAOParam(pcSaoParam, DownLevel, iDownRowIdx, iDownColIdx, iPartIdx, DownStartCUX, DownEndCUX, DownStartCUY, DownEndCUY, iYCbCr);
    427 
    428     DownStartCUX = StartCUX+ NumCULeft;
    429     DownEndCUX   = EndCUX;
    430     DownStartCUY = StartCUY + NumCUTop;
    431     DownEndCUY   = EndCUY;
    432     iDownRowIdx  = DownRowStart + 1;
    433     iDownColIdx  = DownColStart + 1;
    434 
    435     pSaoPart->DownPartsIdx[3] = convertLevelRowCol2Idx(DownLevel, iDownRowIdx, iDownColIdx);
    436 
    437     initSAOParam(pcSaoParam, DownLevel, iDownRowIdx, iDownColIdx, iPartIdx,DownStartCUX, DownEndCUX, DownStartCUY, DownEndCUY, iYCbCr);
    438   }
    439   else
    440   {
    441     pSaoPart->DownPartsIdx[0]=pSaoPart->DownPartsIdx[1]= pSaoPart->DownPartsIdx[2]= pSaoPart->DownPartsIdx[3]= -1;
    442   }
    443 }
    444 
    445 /** free memory of SAO parameters
    446  * \param   pcSaoParam
    447  */
    448 Void TComSampleAdaptiveOffset::freeSaoParam(SAOParam *pcSaoParam)
    449 {
    450   delete [] pcSaoParam->psSaoPart[0];
    451   delete [] pcSaoParam->psSaoPart[1];
    452   delete [] pcSaoParam->psSaoPart[2];
    453   pcSaoParam->psSaoPart[0] = 0;
    454   pcSaoParam->psSaoPart[1] = 0;
    455   pcSaoParam->psSaoPart[2] = 0;
    456   if( pcSaoParam->saoLcuParam[0])
    457   {
    458     delete [] pcSaoParam->saoLcuParam[0]; pcSaoParam->saoLcuParam[0] = NULL;
    459   }
    460   if( pcSaoParam->saoLcuParam[1])
    461   {
    462     delete [] pcSaoParam->saoLcuParam[1]; pcSaoParam->saoLcuParam[1] = NULL;
    463   }
    464   if( pcSaoParam->saoLcuParam[2])
    465   {
    466     delete [] pcSaoParam->saoLcuParam[2]; pcSaoParam->saoLcuParam[2] = NULL;
    467   }
    468 }
    469 
    470 /** reset SAO parameters
    471  * \param   pcSaoParam
    472  */
    473 Void TComSampleAdaptiveOffset::resetSAOParam(SAOParam *pcSaoParam)
    474 {
    475   Int iNumComponet = 3;
    476   for(Int c=0; c<iNumComponet; c++)
    477   {
    478 if (c<2)
    479   {
    480     pcSaoParam->bSaoFlag[c] = 0;
    481   }
    482     for(Int i=0; i< m_aiNumCulPartsLevel[m_uiMaxSplitLevel]; i++)
    483     {
    484       pcSaoParam->psSaoPart[c][i].iBestType     = -1;
    485       pcSaoParam->psSaoPart[c][i].iLength       =  0;
    486       pcSaoParam->psSaoPart[c][i].bSplit        = false;
    487       pcSaoParam->psSaoPart[c][i].bProcessed    = false;
    488       pcSaoParam->psSaoPart[c][i].dMinCost      = MAX_DOUBLE;
    489       pcSaoParam->psSaoPart[c][i].iMinDist      = MAX_INT;
    490       pcSaoParam->psSaoPart[c][i].iMinRate      = MAX_INT;
    491       pcSaoParam->psSaoPart[c][i].subTypeIdx    = 0;
    492       for (Int j=0;j<MAX_NUM_SAO_OFFSETS;j++)
    493       {
    494         pcSaoParam->psSaoPart[c][i].iOffset[j] = 0;
    495         pcSaoParam->psSaoPart[c][i].iOffset[j] = 0;
    496         pcSaoParam->psSaoPart[c][i].iOffset[j] = 0;
    497       }
    498     }
    499     pcSaoParam->oneUnitFlag[0]   = 0;
    500     pcSaoParam->oneUnitFlag[1]   = 0;
    501     pcSaoParam->oneUnitFlag[2]   = 0;
    502     resetLcuPart(pcSaoParam->saoLcuParam[0]);
    503     resetLcuPart(pcSaoParam->saoLcuParam[1]);
    504     resetLcuPart(pcSaoParam->saoLcuParam[2]);
    505   }
    506 }
    507 
    508 /** get the sign of input variable
    509  * \param   x
    510  */
    511 inline Int xSign(Int x)
    512 {
    513   return ((x >> 31) | ((Int)( (((UInt) -x)) >> 31)));
    514 }
    515 
    516 /** initialize variables for SAO process
    517  * \param  pcPic picture data pointer
    518  */
    519 Void TComSampleAdaptiveOffset::createPicSaoInfo(TComPic* pcPic)
    520 {
    521   m_pcPic   = pcPic;
    522   m_bUseNIF = ( pcPic->getIndependentSliceBoundaryForNDBFilter() || pcPic->getIndependentTileBoundaryForNDBFilter() );
    523   if(m_bUseNIF)
    524   {
    525     m_pcYuvTmp = pcPic->getYuvPicBufferForIndependentBoundaryProcessing();
    526   }
    527 }
    528 
    529 Void TComSampleAdaptiveOffset::destroyPicSaoInfo()
    530 {
    531 
    532 }
    533 
    534 /** sample adaptive offset process for one LCU
    535  * \param   iAddr, iSaoType, iYCbCr
    536  */
    537 Void TComSampleAdaptiveOffset::processSaoCu(Int iAddr, Int iSaoType, Int iYCbCr)
    538 {
    539   if(!m_bUseNIF)
    540   {
    541     processSaoCuOrg( iAddr, iSaoType, iYCbCr);
    542   }
    543   else
    544   { 
    545     Int  isChroma = (iYCbCr != 0)? 1:0;
    546     Int  stride   = (iYCbCr != 0)?(m_pcPic->getCStride()):(m_pcPic->getStride());
    547     Pel* pPicRest = getPicYuvAddr(m_pcPic->getPicYuvRec(), iYCbCr);
    548     Pel* pPicDec  = getPicYuvAddr(m_pcYuvTmp, iYCbCr);
    549 
    550     std::vector<NDBFBlockInfo>& vFilterBlocks = *(m_pcPic->getCU(iAddr)->getNDBFilterBlocks());
    551 
    552     //variables
    553     UInt  xPos, yPos, width, height;
    554     Bool* pbBorderAvail;
    555     UInt  posOffset;
    556 
    557     for(Int i=0; i< vFilterBlocks.size(); i++)
    558     {
    559       xPos        = vFilterBlocks[i].posX   >> isChroma;
    560       yPos        = vFilterBlocks[i].posY   >> isChroma;
    561       width       = vFilterBlocks[i].width  >> isChroma;
    562       height      = vFilterBlocks[i].height >> isChroma;
    563       pbBorderAvail = vFilterBlocks[i].isBorderAvailable;
    564 
    565       posOffset = (yPos* stride) + xPos;
    566 
    567       processSaoBlock(pPicDec+ posOffset, pPicRest+ posOffset, stride, iSaoType, width, height, pbBorderAvail, iYCbCr);
    568     }
    569   }
    570 }
    571 
    572 /** Perform SAO for non-cross-slice or non-cross-tile process
    573  * \param  pDec to-be-filtered block buffer pointer
    574  * \param  pRest filtered block buffer pointer
    575  * \param  stride picture buffer stride
    576  * \param  saoType SAO offset type
    577  * \param  xPos x coordinate
    578  * \param  yPos y coordinate
    579  * \param  width block width
    580  * \param  height block height
    581  * \param  pbBorderAvail availabilities of block border pixels
    582  */
    583 Void TComSampleAdaptiveOffset::processSaoBlock(Pel* pDec, Pel* pRest, Int stride, Int saoType, UInt width, UInt height, Bool* pbBorderAvail, Int iYCbCr)
    584 {
    585   //variables
    586   Int startX, startY, endX, endY, x, y;
    587   Int signLeft,signRight,signDown,signDown1;
    588   UInt edgeType;
    589   Pel *pClipTbl = (iYCbCr==0)?m_pClipTable:m_pChromaClipTable;
    590   Int *pOffsetBo = (iYCbCr==0)?m_iOffsetBo: m_iChromaOffsetBo;
    591 
    592   switch (saoType)
    593   {
    594   case SAO_EO_0: // dir: -
    595     {
    596 
    597       startX = (pbBorderAvail[SGU_L]) ? 0 : 1;
    598       endX   = (pbBorderAvail[SGU_R]) ? width : (width -1);
     195  if ( m_tempPicYuv )
     196  {
     197    m_tempPicYuv->destroy();
     198    delete m_tempPicYuv;
     199    m_tempPicYuv = NULL;
     200  }
     201
     202  for(Int compIdx=0; compIdx < NUM_SAO_COMPONENTS; compIdx++)
     203  {
     204    if(m_offsetClipTable[compIdx])
     205    {
     206      delete[] m_offsetClipTable[compIdx]; m_offsetClipTable[compIdx] = NULL;
     207    }
     208  }
     209  if( m_signTable )
     210  {
     211    delete[] m_signTable; m_signTable = NULL;
     212  }
     213}
     214
     215Void TComSampleAdaptiveOffset::invertQuantOffsets(Int compIdx, Int typeIdc, Int typeAuxInfo, Int* dstOffsets, Int* srcOffsets)
     216{
     217  Int codedOffset[MAX_NUM_SAO_CLASSES];
     218
     219  ::memcpy(codedOffset, srcOffsets, sizeof(Int)*MAX_NUM_SAO_CLASSES);
     220  ::memset(dstOffsets, 0, sizeof(Int)*MAX_NUM_SAO_CLASSES);
     221
     222  if(typeIdc == SAO_TYPE_START_BO)
     223  {
     224    for(Int i=0; i< 4; i++)
     225    {
     226      dstOffsets[(typeAuxInfo+ i)%NUM_SAO_BO_CLASSES] = codedOffset[(typeAuxInfo+ i)%NUM_SAO_BO_CLASSES]*(1<<m_offsetStepLog2[compIdx]);
     227    }
     228  }
     229  else //EO
     230  {
     231    for(Int i=0; i< NUM_SAO_EO_CLASSES; i++)
     232    {
     233      dstOffsets[i] = codedOffset[i] *(1<<m_offsetStepLog2[compIdx]);
     234    }
     235    assert(dstOffsets[SAO_CLASS_EO_PLAIN] == 0); //keep EO plain offset as zero
     236  }
     237
     238}
     239
     240Int TComSampleAdaptiveOffset::getMergeList(TComPic* pic, Int ctu, SAOBlkParam* blkParams, std::vector<SAOBlkParam*>& mergeList)
     241{
     242  Int ctuX = ctu % m_numCTUInWidth;
     243  Int ctuY = ctu / m_numCTUInWidth;
     244  Int mergedCTUPos;
     245  Int numValidMergeCandidates = 0;
     246
     247  for(Int mergeType=0; mergeType< NUM_SAO_MERGE_TYPES; mergeType++)
     248  {
     249    SAOBlkParam* mergeCandidate = NULL;
     250
     251    switch(mergeType)
     252    {
     253    case SAO_MERGE_ABOVE:
     254      {
     255        if(ctuY > 0)
     256        {
     257          mergedCTUPos = ctu- m_numCTUInWidth;
     258          if( pic->getSAOMergeAvailability(ctu, mergedCTUPos) )
     259          {
     260            mergeCandidate = &(blkParams[mergedCTUPos]);
     261          }
     262        }
     263      }
     264      break;
     265    case SAO_MERGE_LEFT:
     266      {
     267        if(ctuX > 0)
     268        {
     269          mergedCTUPos = ctu- 1;
     270          if( pic->getSAOMergeAvailability(ctu, mergedCTUPos) )
     271          {
     272            mergeCandidate = &(blkParams[mergedCTUPos]);
     273          }
     274        }
     275      }
     276      break;
     277    default:
     278      {
     279        printf("not a supported merge type");
     280        assert(0);
     281        exit(-1);
     282      }
     283    }
     284
     285    mergeList.push_back(mergeCandidate);
     286    if (mergeCandidate != NULL)
     287    {
     288      numValidMergeCandidates++;
     289    }
     290  }
     291
     292  return numValidMergeCandidates;
     293}
     294
     295
     296Void TComSampleAdaptiveOffset::reconstructBlkSAOParam(SAOBlkParam& recParam, std::vector<SAOBlkParam*>& mergeList)
     297{
     298  for(Int compIdx=0; compIdx< NUM_SAO_COMPONENTS; compIdx++)
     299  {
     300    SAOOffset& offsetParam = recParam[compIdx];
     301
     302    if(offsetParam.modeIdc == SAO_MODE_OFF)
     303    {
     304      continue;
     305    }
     306
     307    switch(offsetParam.modeIdc)
     308    {
     309    case SAO_MODE_NEW:
     310      {
     311        invertQuantOffsets(compIdx, offsetParam.typeIdc, offsetParam.typeAuxInfo, offsetParam.offset, offsetParam.offset);
     312      }
     313      break;
     314    case SAO_MODE_MERGE:
     315      {
     316        SAOBlkParam* mergeTarget = mergeList[offsetParam.typeIdc];
     317        assert(mergeTarget != NULL);
     318
     319        offsetParam = (*mergeTarget)[compIdx];
     320      }
     321      break;
     322    default:
     323      {
     324        printf("Not a supported mode");
     325        assert(0);
     326        exit(-1);
     327      }
     328    }
     329  }
     330}
     331
     332Void TComSampleAdaptiveOffset::reconstructBlkSAOParams(TComPic* pic, SAOBlkParam* saoBlkParams)
     333{
     334  m_picSAOEnabled[SAO_Y] = m_picSAOEnabled[SAO_Cb] = m_picSAOEnabled[SAO_Cr] = false;
     335
     336  for(Int ctu=0; ctu< m_numCTUsPic; ctu++)
     337  {
     338    std::vector<SAOBlkParam*> mergeList;
     339    getMergeList(pic, ctu, saoBlkParams, mergeList);
     340
     341    reconstructBlkSAOParam(saoBlkParams[ctu], mergeList);
     342
     343    for(Int compIdx=0; compIdx< NUM_SAO_COMPONENTS; compIdx++)
     344    {
     345      if(saoBlkParams[ctu][compIdx].modeIdc != SAO_MODE_OFF)
     346      {
     347        m_picSAOEnabled[compIdx] = true;
     348      }
     349    }
     350  }
     351
     352
     353}
     354
     355
     356Void TComSampleAdaptiveOffset::offsetBlock(Int compIdx, Int typeIdx, Int* offset 
     357                                          , Pel* srcBlk, Pel* resBlk, Int srcStride, Int resStride,  Int width, Int height
     358                                          , Bool isLeftAvail,  Bool isRightAvail, Bool isAboveAvail, Bool isBelowAvail, Bool isAboveLeftAvail, Bool isAboveRightAvail, Bool isBelowLeftAvail, Bool isBelowRightAvail)
     359{
     360  if(m_lineBufWidth != m_maxCUWidth)
     361  {
     362    m_lineBufWidth = m_maxCUWidth;
     363   
     364    if (m_signLineBuf1) delete[] m_signLineBuf1; m_signLineBuf1 = NULL;
     365    m_signLineBuf1 = new Char[m_lineBufWidth+1];
     366   
     367    if (m_signLineBuf2) delete[] m_signLineBuf2; m_signLineBuf2 = NULL;
     368    m_signLineBuf2 = new Char[m_lineBufWidth+1];
     369  }
     370
     371  Int* offsetClip = m_offsetClip[compIdx];
     372
     373  Int x,y, startX, startY, endX, endY, edgeType;
     374  Int firstLineStartX, firstLineEndX, lastLineStartX, lastLineEndX;
     375  Char signLeft, signRight, signDown;
     376
     377  Pel* srcLine = srcBlk;
     378  Pel* resLine = resBlk;
     379
     380  switch(typeIdx)
     381  {
     382  case SAO_TYPE_EO_0:
     383    {
     384      offset += 2;
     385      startX = isLeftAvail ? 0 : 1;
     386      endX   = isRightAvail ? width : (width -1);
    599387      for (y=0; y< height; y++)
    600388      {
    601         signLeft = xSign(pDec[startX] - pDec[startX-1]);
     389        signLeft = (Char)m_sign[srcLine[startX] - srcLine[startX-1]];
    602390        for (x=startX; x< endX; x++)
    603391        {
    604           signRight =  xSign(pDec[x] - pDec[x+1]);
    605           edgeType =  signRight + signLeft + 2;
     392          signRight = (Char)m_sign[srcLine[x] - srcLine[x+1]];
     393          edgeType =  signRight + signLeft;
    606394          signLeft  = -signRight;
    607395
    608           pRest[x] = pClipTbl[pDec[x] + m_iOffsetEo[edgeType]];
     396          resLine[x] = offsetClip[srcLine[x] + offset[edgeType]];
    609397        }
    610         pDec  += stride;
    611         pRest += stride;
    612       }
    613       break;
    614     }
    615   case SAO_EO_1: // dir: |
    616     {
    617       startY = (pbBorderAvail[SGU_T]) ? 0 : 1;
    618       endY   = (pbBorderAvail[SGU_B]) ? height : height-1;
    619       if (!pbBorderAvail[SGU_T])
    620       {
    621         pDec  += stride;
    622         pRest += stride;
    623       }
     398        srcLine  += srcStride;
     399        resLine += resStride;
     400      }
     401
     402    }
     403    break;
     404  case SAO_TYPE_EO_90:
     405    {
     406      offset += 2;
     407      Char *signUpLine = m_signLineBuf1;
     408
     409      startY = isAboveAvail ? 0 : 1;
     410      endY   = isBelowAvail ? height : height-1;
     411      if (!isAboveAvail)
     412      {
     413        srcLine += srcStride;
     414        resLine += resStride;
     415      }
     416
     417      Pel* srcLineAbove= srcLine- srcStride;
    624418      for (x=0; x< width; x++)
    625419      {
    626         m_iUpBuff1[x] = xSign(pDec[x] - pDec[x-stride]);
    627       }
     420        signUpLine[x] = (Char)m_sign[srcLine[x] - srcLineAbove[x]];
     421      }
     422
     423      Pel* srcLineBelow;
    628424      for (y=startY; y<endY; y++)
    629425      {
     426        srcLineBelow= srcLine+ srcStride;
     427
    630428        for (x=0; x< width; x++)
    631429        {
    632           signDown  = xSign(pDec[x] - pDec[x+stride]);
    633           edgeType = signDown + m_iUpBuff1[x] + 2;
    634           m_iUpBuff1[x]= -signDown;
    635 
    636           pRest[x] = pClipTbl[pDec[x] + m_iOffsetEo[edgeType]];
     430          signDown  = (Char)m_sign[srcLine[x] - srcLineBelow[x]];
     431          edgeType = signDown + signUpLine[x];
     432          signUpLine[x]= -signDown;
     433
     434          resLine[x] = offsetClip[srcLine[x] + offset[edgeType]];
    637435        }
    638         pDec  += stride;
    639         pRest += stride;
    640       }
    641       break;
    642     }
    643   case SAO_EO_2: // dir: 135
    644     {
    645       Int posShift= stride + 1;
    646 
    647       startX = (pbBorderAvail[SGU_L]) ? 0 : 1 ;
    648       endX   = (pbBorderAvail[SGU_R]) ? width : (width-1);
    649 
    650       //prepare 2nd line upper sign
    651       pDec += stride;
     436        srcLine += srcStride;
     437        resLine += resStride;
     438      }
     439
     440    }
     441    break;
     442  case SAO_TYPE_EO_135:
     443    {
     444      offset += 2;
     445      Char *signUpLine, *signDownLine, *signTmpLine;
     446
     447      signUpLine  = m_signLineBuf1;
     448      signDownLine= m_signLineBuf2;
     449
     450      startX = isLeftAvail ? 0 : 1 ;
     451      endX   = isRightAvail ? width : (width-1);
     452
     453      //prepare 2nd line's upper sign
     454      Pel* srcLineBelow= srcLine+ srcStride;
    652455      for (x=startX; x< endX+1; x++)
    653456      {
    654         m_iUpBuff1[x] = xSign(pDec[x] - pDec[x- posShift]);
     457        signUpLine[x] = (Char)m_sign[srcLineBelow[x] - srcLine[x- 1]];
    655458      }
    656459
    657460      //1st line
    658       pDec -= stride;
    659       if(pbBorderAvail[SGU_TL])
    660       {
    661         x= 0;
    662         edgeType      =  xSign(pDec[x] - pDec[x- posShift]) - m_iUpBuff1[x+1] + 2;
    663         pRest[x] = pClipTbl[pDec[x] + m_iOffsetEo[edgeType]];
    664 
    665       }
    666       if(pbBorderAvail[SGU_T])
    667       {
    668         for(x= 1; x< endX; x++)
    669         {
    670           edgeType      =  xSign(pDec[x] - pDec[x- posShift]) - m_iUpBuff1[x+1] + 2;
    671           pRest[x] = pClipTbl[pDec[x] + m_iOffsetEo[edgeType]];
    672         }
    673       }
    674       pDec   += stride;
    675       pRest  += stride;
     461      Pel* srcLineAbove= srcLine- srcStride;
     462      firstLineStartX = isAboveLeftAvail ? 0 : 1;
     463      firstLineEndX   = isAboveAvail? endX: 1;
     464      for(x= firstLineStartX; x< firstLineEndX; x++)
     465      {
     466        edgeType  =  m_sign[srcLine[x] - srcLineAbove[x- 1]] - signUpLine[x+1];
     467        resLine[x] = offsetClip[srcLine[x] + offset[edgeType]];
     468      }
     469      srcLine  += srcStride;
     470      resLine  += resStride;
    676471
    677472
     
    679474      for (y= 1; y< height-1; y++)
    680475      {
     476        srcLineBelow= srcLine+ srcStride;
     477
    681478        for (x=startX; x<endX; x++)
    682479        {
    683           signDown1      =  xSign(pDec[x] - pDec[x+ posShift]) ;
    684           edgeType      =  signDown1 + m_iUpBuff1[x] + 2;
    685           pRest[x] = pClipTbl[pDec[x] + m_iOffsetEo[edgeType]];
    686 
    687           m_iUpBufft[x+1] = -signDown1;
     480          signDown =  (Char)m_sign[srcLine[x] - srcLineBelow[x+ 1]] ;
     481          edgeType =  signDown + signUpLine[x];
     482          resLine[x] = offsetClip[srcLine[x] + offset[edgeType]];
     483
     484          signDownLine[x+1] = -signDown;
    688485        }
    689         m_iUpBufft[startX] = xSign(pDec[stride+startX] - pDec[startX-1]);
    690 
    691         ipSwap     = m_iUpBuff1;
    692         m_iUpBuff1 = m_iUpBufft;
    693         m_iUpBufft = ipSwap;
    694 
    695         pDec  += stride;
    696         pRest += stride;
     486        signDownLine[startX] = (Char)m_sign[srcLineBelow[startX] - srcLine[startX-1]];
     487
     488        signTmpLine  = signUpLine;
     489        signUpLine   = signDownLine;
     490        signDownLine = signTmpLine;
     491
     492        srcLine += srcStride;
     493        resLine += resStride;
    697494      }
    698495
    699496      //last line
    700       if(pbBorderAvail[SGU_B])
    701       {
    702         for(x= startX; x< width-1; x++)
    703         {
    704           edgeType =  xSign(pDec[x] - pDec[x+ posShift]) + m_iUpBuff1[x] + 2;
    705           pRest[x] = pClipTbl[pDec[x] + m_iOffsetEo[edgeType]];
    706         }
    707       }
    708       if(pbBorderAvail[SGU_BR])
    709       {
    710         x= width -1;
    711         edgeType =  xSign(pDec[x] - pDec[x+ posShift]) + m_iUpBuff1[x] + 2;
    712         pRest[x] = pClipTbl[pDec[x] + m_iOffsetEo[edgeType]];
    713       }
    714       break;
    715     }
    716   case SAO_EO_3: // dir: 45
    717     {
    718       Int  posShift     = stride - 1;
    719       startX = (pbBorderAvail[SGU_L]) ? 0 : 1;
    720       endX   = (pbBorderAvail[SGU_R]) ? width : (width -1);
     497      srcLineBelow= srcLine+ srcStride;
     498      lastLineStartX = isBelowAvail ? startX : (width -1);
     499      lastLineEndX   = isBelowRightAvail ? width : (width -1);
     500      for(x= lastLineStartX; x< lastLineEndX; x++)
     501      {
     502        edgeType =  m_sign[srcLine[x] - srcLineBelow[x+ 1]] + signUpLine[x];
     503        resLine[x] = offsetClip[srcLine[x] + offset[edgeType]];
     504
     505      }
     506    }
     507    break;
     508  case SAO_TYPE_EO_45:
     509    {
     510      offset += 2;
     511      Char *signUpLine = m_signLineBuf1+1;
     512
     513      startX = isLeftAvail ? 0 : 1;
     514      endX   = isRightAvail ? width : (width -1);
    721515
    722516      //prepare 2nd line upper sign
    723       pDec += stride;
     517      Pel* srcLineBelow= srcLine+ srcStride;
    724518      for (x=startX-1; x< endX; x++)
    725519      {
    726         m_iUpBuff1[x] = xSign(pDec[x] - pDec[x- posShift]);
     520        signUpLine[x] = (Char)m_sign[srcLineBelow[x] - srcLine[x+1]];
    727521      }
    728522
    729523
    730524      //first line
    731       pDec -= stride;
    732       if(pbBorderAvail[SGU_T])
    733       {
    734         for(x= startX; x< width -1; x++)
    735         {
    736           edgeType = xSign(pDec[x] - pDec[x- posShift]) -m_iUpBuff1[x-1] + 2;
    737           pRest[x] = pClipTbl[pDec[x] + m_iOffsetEo[edgeType]];
    738         }
    739       }
    740       if(pbBorderAvail[SGU_TR])
    741       {
    742         x= width-1;
    743         edgeType = xSign(pDec[x] - pDec[x- posShift]) -m_iUpBuff1[x-1] + 2;
    744         pRest[x] = pClipTbl[pDec[x] + m_iOffsetEo[edgeType]];
    745       }
    746       pDec  += stride;
    747       pRest += stride;
     525      Pel* srcLineAbove= srcLine- srcStride;
     526      firstLineStartX = isAboveAvail ? startX : (width -1 );
     527      firstLineEndX   = isAboveRightAvail ? width : (width-1);
     528      for(x= firstLineStartX; x< firstLineEndX; x++)
     529      {
     530        edgeType = m_sign[srcLine[x] - srcLineAbove[x+1]] -signUpLine[x-1];
     531        resLine[x] = offsetClip[srcLine[x] + offset[edgeType]];
     532      }
     533      srcLine += srcStride;
     534      resLine += resStride;
    748535
    749536      //middle lines
    750537      for (y= 1; y< height-1; y++)
    751538      {
     539        srcLineBelow= srcLine+ srcStride;
     540
    752541        for(x= startX; x< endX; x++)
    753542        {
    754           signDown1      =  xSign(pDec[x] - pDec[x+ posShift]) ;
    755           edgeType      =  signDown1 + m_iUpBuff1[x] + 2;
    756 
    757           pRest[x] = pClipTbl[pDec[x] + m_iOffsetEo[edgeType]];
    758           m_iUpBuff1[x-1] = -signDown1;
     543          signDown =  (Char)m_sign[srcLine[x] - srcLineBelow[x-1]] ;
     544          edgeType =  signDown + signUpLine[x];
     545          resLine[x] = offsetClip[srcLine[x] + offset[edgeType]];
     546          signUpLine[x-1] = -signDown;
    759547        }
    760         m_iUpBuff1[endX-1] = xSign(pDec[endX-1 + stride] - pDec[endX]);
    761 
    762         pDec  += stride;
    763         pRest += stride;
     548        signUpLine[endX-1] = (Char)m_sign[srcLineBelow[endX-1] - srcLine[endX]];
     549        srcLine  += srcStride;
     550        resLine += resStride;
    764551      }
    765552
    766553      //last line
    767       if(pbBorderAvail[SGU_BL])
    768       {
    769         x= 0;
    770         edgeType = xSign(pDec[x] - pDec[x+ posShift]) + m_iUpBuff1[x] + 2;
    771         pRest[x] = pClipTbl[pDec[x] + m_iOffsetEo[edgeType]];
    772 
    773       }
    774       if(pbBorderAvail[SGU_B])
    775       {
    776         for(x= 1; x< endX; x++)
    777         {
    778           edgeType = xSign(pDec[x] - pDec[x+ posShift]) + m_iUpBuff1[x] + 2;
    779           pRest[x] = pClipTbl[pDec[x] + m_iOffsetEo[edgeType]];
    780         }
    781       }
    782       break;
    783     }   
    784   case SAO_BO:
    785     {
     554      srcLineBelow= srcLine+ srcStride;
     555      lastLineStartX = isBelowLeftAvail ? 0 : 1;
     556      lastLineEndX   = isBelowAvail ? endX : 1;
     557      for(x= lastLineStartX; x< lastLineEndX; x++)
     558      {
     559        edgeType = m_sign[srcLine[x] - srcLineBelow[x-1]] + signUpLine[x];
     560        resLine[x] = offsetClip[srcLine[x] + offset[edgeType]];
     561
     562      }
     563    }
     564    break;
     565  case SAO_TYPE_BO:
     566    {
     567      Int shiftBits = ((compIdx == SAO_Y)?g_bitDepthY:g_bitDepthC)- NUM_SAO_BO_CLASSES_LOG2;
    786568      for (y=0; y< height; y++)
    787569      {
    788570        for (x=0; x< width; x++)
    789571        {
    790           pRest[x] = pOffsetBo[pDec[x]];
     572          resLine[x] = offsetClip[ srcLine[x] + offset[srcLine[x] >> shiftBits] ];
    791573        }
    792         pRest += stride;
    793         pDec  += stride;
    794       }
    795       break;
    796     }
    797   default: break;
    798   }
    799 
    800 }
    801 
    802 /** sample adaptive offset process for one LCU crossing LCU boundary
    803  * \param   iAddr, iSaoType, iYCbCr
    804  */
    805 Void TComSampleAdaptiveOffset::processSaoCuOrg(Int iAddr, Int iSaoType, Int iYCbCr)
    806 {
    807   Int x,y;
    808   TComDataCU *pTmpCu = m_pcPic->getCU(iAddr);
    809   Pel* pRec;
    810   Int  iStride;
    811   Int  iLcuWidth  = m_uiMaxCUWidth;
    812   Int  iLcuHeight = m_uiMaxCUHeight;
    813   UInt uiLPelX    = pTmpCu->getCUPelX();
    814   UInt uiTPelY    = pTmpCu->getCUPelY();
    815   UInt uiRPelX;
    816   UInt uiBPelY;
    817   Int  iSignLeft;
    818   Int  iSignRight;
    819   Int  iSignDown;
    820   Int  iSignDown1;
    821   Int  iSignDown2;
    822   UInt uiEdgeType;
    823   Int iPicWidthTmp;
    824   Int iPicHeightTmp;
    825   Int iStartX;
    826   Int iStartY;
    827   Int iEndX;
    828   Int iEndY;
    829   Int iIsChroma = (iYCbCr!=0)? 1:0;
    830   Int iShift;
    831   Int iCuHeightTmp;
    832   Pel *pTmpLSwap;
    833   Pel *pTmpL;
    834   Pel *pTmpU;
    835   Pel *pClipTbl = NULL;
    836   Int *pOffsetBo = NULL;
    837 
    838   iPicWidthTmp  = m_iPicWidth  >> iIsChroma;
    839   iPicHeightTmp = m_iPicHeight >> iIsChroma;
    840   iLcuWidth     = iLcuWidth    >> iIsChroma;
    841   iLcuHeight    = iLcuHeight   >> iIsChroma;
    842   uiLPelX       = uiLPelX      >> iIsChroma;
    843   uiTPelY       = uiTPelY      >> iIsChroma;
    844   uiRPelX       = uiLPelX + iLcuWidth  ;
    845   uiBPelY       = uiTPelY + iLcuHeight ;
    846   uiRPelX       = uiRPelX > iPicWidthTmp  ? iPicWidthTmp  : uiRPelX;
    847   uiBPelY       = uiBPelY > iPicHeightTmp ? iPicHeightTmp : uiBPelY;
    848   iLcuWidth     = uiRPelX - uiLPelX;
    849   iLcuHeight    = uiBPelY - uiTPelY;
    850 
    851   if(pTmpCu->getPic()==0)
    852   {
    853     return;
    854   }
    855   if (iYCbCr == 0)
    856   {
    857     pRec       = m_pcPic->getPicYuvRec()->getLumaAddr(iAddr);
    858     iStride    = m_pcPic->getStride();
    859   }
    860   else if (iYCbCr == 1)
    861   {
    862     pRec       = m_pcPic->getPicYuvRec()->getCbAddr(iAddr);
    863     iStride    = m_pcPic->getCStride();
    864   }
    865   else
    866   {
    867     pRec       = m_pcPic->getPicYuvRec()->getCrAddr(iAddr);
    868     iStride    = m_pcPic->getCStride();
    869   }
    870 
    871 //   if (iSaoType!=SAO_BO_0 || iSaoType!=SAO_BO_1)
    872   {
    873     iCuHeightTmp = (m_uiMaxCUHeight >> iIsChroma);
    874     iShift = (m_uiMaxCUWidth>> iIsChroma)-1;
    875     for (Int i=0;i<iCuHeightTmp+1;i++)
    876     {
    877       m_pTmpL2[i] = pRec[iShift];
    878       pRec += iStride;
    879     }
    880     pRec -= (iStride*(iCuHeightTmp+1));
    881 
    882     pTmpL = m_pTmpL1;
    883     pTmpU = &(m_pTmpU1[uiLPelX]);
    884   }
    885 
    886   pClipTbl = (iYCbCr==0)? m_pClipTable:m_pChromaClipTable;
    887   pOffsetBo = (iYCbCr==0)? m_iOffsetBo:m_iChromaOffsetBo;
    888 
    889   switch (iSaoType)
    890   {
    891   case SAO_EO_0: // dir: -
    892     {
    893       iStartX = (uiLPelX == 0) ? 1 : 0;
    894       iEndX   = (uiRPelX == iPicWidthTmp) ? iLcuWidth-1 : iLcuWidth;
    895       for (y=0; y<iLcuHeight; y++)
    896       {
    897         iSignLeft = xSign(pRec[iStartX] - pTmpL[y]);
    898         for (x=iStartX; x< iEndX; x++)
    899         {
    900           iSignRight =  xSign(pRec[x] - pRec[x+1]);
    901           uiEdgeType =  iSignRight + iSignLeft + 2;
    902           iSignLeft  = -iSignRight;
    903 
    904           pRec[x] = pClipTbl[pRec[x] + m_iOffsetEo[uiEdgeType]];
    905         }
    906         pRec += iStride;
    907       }
    908       break;
    909     }
    910   case SAO_EO_1: // dir: |
    911     {
    912       iStartY = (uiTPelY == 0) ? 1 : 0;
    913       iEndY   = (uiBPelY == iPicHeightTmp) ? iLcuHeight-1 : iLcuHeight;
    914       if (uiTPelY == 0)
    915       {
    916         pRec += iStride;
    917       }
    918       for (x=0; x< iLcuWidth; x++)
    919       {
    920         m_iUpBuff1[x] = xSign(pRec[x] - pTmpU[x]);
    921       }
    922       for (y=iStartY; y<iEndY; y++)
    923       {
    924         for (x=0; x<iLcuWidth; x++)
    925         {
    926           iSignDown  = xSign(pRec[x] - pRec[x+iStride]);
    927           uiEdgeType = iSignDown + m_iUpBuff1[x] + 2;
    928           m_iUpBuff1[x]= -iSignDown;
    929 
    930           pRec[x] = pClipTbl[pRec[x] + m_iOffsetEo[uiEdgeType]];
    931         }
    932         pRec += iStride;
    933       }
    934       break;
    935     }
    936   case SAO_EO_2: // dir: 135
    937     {
    938       iStartX = (uiLPelX == 0)            ? 1 : 0;
    939       iEndX   = (uiRPelX == iPicWidthTmp) ? iLcuWidth-1 : iLcuWidth;
    940 
    941       iStartY = (uiTPelY == 0) ?             1 : 0;
    942       iEndY   = (uiBPelY == iPicHeightTmp) ? iLcuHeight-1 : iLcuHeight;
    943 
    944       if (uiTPelY == 0)
    945       {
    946         pRec += iStride;
    947       }
    948 
    949       for (x=iStartX; x<iEndX; x++)
    950       {
    951         m_iUpBuff1[x] = xSign(pRec[x] - pTmpU[x-1]);
    952       }
    953       for (y=iStartY; y<iEndY; y++)
    954       {
    955         iSignDown2 = xSign(pRec[iStride+iStartX] - pTmpL[y]);
    956         for (x=iStartX; x<iEndX; x++)
    957         {
    958           iSignDown1      =  xSign(pRec[x] - pRec[x+iStride+1]) ;
    959           uiEdgeType      =  iSignDown1 + m_iUpBuff1[x] + 2;
    960           m_iUpBufft[x+1] = -iSignDown1;
    961           pRec[x] = pClipTbl[pRec[x] + m_iOffsetEo[uiEdgeType]];
    962         }
    963         m_iUpBufft[iStartX] = iSignDown2;
    964 
    965         ipSwap     = m_iUpBuff1;
    966         m_iUpBuff1 = m_iUpBufft;
    967         m_iUpBufft = ipSwap;
    968 
    969         pRec += iStride;
    970       }
    971       break;
    972     }
    973   case SAO_EO_3: // dir: 45
    974     {
    975       iStartX = (uiLPelX == 0) ? 1 : 0;
    976       iEndX   = (uiRPelX == iPicWidthTmp) ? iLcuWidth-1 : iLcuWidth;
    977 
    978       iStartY = (uiTPelY == 0) ? 1 : 0;
    979       iEndY   = (uiBPelY == iPicHeightTmp) ? iLcuHeight-1 : iLcuHeight;
    980 
    981       if (iStartY == 1)
    982       {
    983         pRec += iStride;
    984       }
    985 
    986       for (x=iStartX-1; x<iEndX; x++)
    987       {
    988         m_iUpBuff1[x] = xSign(pRec[x] - pTmpU[x+1]);
    989       }
    990       for (y=iStartY; y<iEndY; y++)
    991       {
    992         x=iStartX;
    993         iSignDown1      =  xSign(pRec[x] - pTmpL[y+1]) ;
    994         uiEdgeType      =  iSignDown1 + m_iUpBuff1[x] + 2;
    995         m_iUpBuff1[x-1] = -iSignDown1;
    996         pRec[x] = pClipTbl[pRec[x] + m_iOffsetEo[uiEdgeType]];
    997         for (x=iStartX+1; x<iEndX; x++)
    998         {
    999           iSignDown1      =  xSign(pRec[x] - pRec[x+iStride-1]) ;
    1000           uiEdgeType      =  iSignDown1 + m_iUpBuff1[x] + 2;
    1001           m_iUpBuff1[x-1] = -iSignDown1;
    1002           pRec[x] = pClipTbl[pRec[x] + m_iOffsetEo[uiEdgeType]];
    1003         }
    1004         m_iUpBuff1[iEndX-1] = xSign(pRec[iEndX-1 + iStride] - pRec[iEndX]);
    1005 
    1006         pRec += iStride;
    1007       }
    1008       break;
    1009     }   
    1010   case SAO_BO:
    1011     {
    1012       for (y=0; y<iLcuHeight; y++)
    1013       {
    1014         for (x=0; x<iLcuWidth; x++)
    1015         {
    1016           pRec[x] = pOffsetBo[pRec[x]];
    1017         }
    1018         pRec += iStride;
    1019       }
    1020       break;
    1021     }
    1022   default: break;
    1023   }
    1024 //   if (iSaoType!=SAO_BO_0 || iSaoType!=SAO_BO_1)
    1025   {
    1026     pTmpLSwap = m_pTmpL1;
    1027     m_pTmpL1  = m_pTmpL2;
    1028     m_pTmpL2  = pTmpLSwap;
    1029   }
    1030 }
    1031 /** Sample adaptive offset process
    1032  * \param pcPic, pcSaoParam 
    1033  */
    1034 Void TComSampleAdaptiveOffset::SAOProcess(SAOParam* pcSaoParam)
    1035 {
    1036   {
    1037     m_uiSaoBitIncreaseY = max(g_bitDepthY - 10, 0);
    1038     m_uiSaoBitIncreaseC = max(g_bitDepthC - 10, 0);
    1039 
    1040     if(m_bUseNIF)
    1041     {
    1042       m_pcPic->getPicYuvRec()->copyToPic(m_pcYuvTmp);
    1043     }
    1044     if (m_saoLcuBasedOptimization)
    1045     {
    1046       pcSaoParam->oneUnitFlag[0] = 0; 
    1047       pcSaoParam->oneUnitFlag[1] = 0; 
    1048       pcSaoParam->oneUnitFlag[2] = 0; 
    1049     }
    1050     Int iY  = 0;
    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     }
    1058     m_pcPic = NULL;
    1059   }
    1060 }
    1061 
    1062 Pel* TComSampleAdaptiveOffset::getPicYuvAddr(TComPicYuv* pcPicYuv, Int iYCbCr, Int iAddr)
    1063 {
    1064   switch (iYCbCr)
    1065   {
    1066   case 0:
    1067     return pcPicYuv->getLumaAddr(iAddr);
    1068     break;
    1069   case 1:
    1070     return pcPicYuv->getCbAddr(iAddr);
    1071     break;
    1072   case 2:
    1073     return pcPicYuv->getCrAddr(iAddr);
     574        srcLine += srcStride;
     575        resLine += resStride;
     576      }
     577    }
    1074578    break;
    1075579  default:
    1076     return NULL;
     580    {
     581      printf("Not a supported SAO types\n");
     582      assert(0);
     583      exit(-1);
     584    }
     585  }
     586
     587
     588}
     589
     590Void TComSampleAdaptiveOffset::offsetCTU(Int ctu, TComPicYuv* srcYuv, TComPicYuv* resYuv, SAOBlkParam& saoblkParam, TComPic* pPic)
     591{
     592  Bool isLeftAvail,isRightAvail,isAboveAvail,isBelowAvail,isAboveLeftAvail,isAboveRightAvail,isBelowLeftAvail,isBelowRightAvail;
     593
     594  if(
     595    (saoblkParam[SAO_Y ].modeIdc == SAO_MODE_OFF) &&
     596    (saoblkParam[SAO_Cb].modeIdc == SAO_MODE_OFF) &&
     597    (saoblkParam[SAO_Cr].modeIdc == SAO_MODE_OFF)
     598    )
     599  {
     600    return;
     601  }
     602
     603  //block boundary availability
     604  pPic->getPicSym()->deriveLoopFilterBoundaryAvailibility(ctu, isLeftAvail,isRightAvail,isAboveAvail,isBelowAvail,isAboveLeftAvail,isAboveRightAvail,isBelowLeftAvail,isBelowRightAvail);
     605
     606  Int yPos   = (ctu / m_numCTUInWidth)*m_maxCUHeight;
     607  Int xPos   = (ctu % m_numCTUInWidth)*m_maxCUWidth;
     608  Int height = (yPos + m_maxCUHeight > m_picHeight)?(m_picHeight- yPos):m_maxCUHeight;
     609  Int width  = (xPos + m_maxCUWidth  > m_picWidth )?(m_picWidth - xPos):m_maxCUWidth;
     610
     611  for(Int compIdx= 0; compIdx < NUM_SAO_COMPONENTS; compIdx++)
     612  {
     613    SAOOffset& ctbOffset = saoblkParam[compIdx];
     614
     615    if(ctbOffset.modeIdc != SAO_MODE_OFF)
     616    {
     617      Bool isLuma     = (compIdx == SAO_Y);
     618      Int  formatShift= isLuma?0:1;
     619
     620      Int  blkWidth   = (width  >> formatShift);
     621      Int  blkHeight  = (height >> formatShift);
     622      Int  blkYPos    = (yPos   >> formatShift);
     623      Int  blkXPos    = (xPos   >> formatShift);
     624
     625      Int  srcStride = isLuma?srcYuv->getStride():srcYuv->getCStride();
     626      Pel* srcBlk    = getPicBuf(srcYuv, compIdx)+ (yPos >> formatShift)*srcStride+ (xPos >> formatShift);
     627
     628      Int  resStride  = isLuma?resYuv->getStride():resYuv->getCStride();
     629      Pel* resBlk     = getPicBuf(resYuv, compIdx)+ blkYPos*resStride+ blkXPos;
     630
     631      offsetBlock( compIdx, ctbOffset.typeIdc, ctbOffset.offset
     632                  , srcBlk, resBlk, srcStride, resStride, blkWidth, blkHeight
     633                  , isLeftAvail, isRightAvail
     634                  , isAboveAvail, isBelowAvail
     635                  , isAboveLeftAvail, isAboveRightAvail
     636                  , isBelowLeftAvail, isBelowRightAvail
     637                  );
     638    }
     639  } //compIdx
     640
     641}
     642
     643
     644Void TComSampleAdaptiveOffset::SAOProcess(TComPic* pDecPic)
     645{
     646  if(!m_picSAOEnabled[SAO_Y] && !m_picSAOEnabled[SAO_Cb] && !m_picSAOEnabled[SAO_Cr])
     647  {
     648    return;
     649  }
     650  TComPicYuv* resYuv = pDecPic->getPicYuvRec();
     651  TComPicYuv* srcYuv = m_tempPicYuv;
     652  resYuv->copyToPic(srcYuv);
     653  for(Int ctu= 0; ctu < m_numCTUsPic; ctu++)
     654  {
     655    offsetCTU(ctu, srcYuv, resYuv, (pDecPic->getPicSym()->getSAOBlkParam())[ctu], pDecPic);
     656  } //ctu
     657}
     658
     659
     660Pel* TComSampleAdaptiveOffset::getPicBuf(TComPicYuv* pPicYuv, Int compIdx)
     661{
     662  Pel* pBuf = NULL;
     663  switch(compIdx)
     664  {
     665  case SAO_Y:
     666    {
     667      pBuf = pPicYuv->getLumaAddr();
     668    }
    1077669    break;
    1078   }
    1079 }
    1080 /** Process SAO all units
    1081  * \param saoLcuParam SAO LCU parameters
    1082  * \param oneUnitFlag one unit flag
    1083  * \param yCbCr color componet index
    1084  */
    1085 Void TComSampleAdaptiveOffset::processSaoUnitAll(SaoLcuParam* saoLcuParam, Bool oneUnitFlag, Int yCbCr)
    1086 {
    1087   Pel *pRec;
    1088   Int picWidthTmp;
    1089 
    1090   if (yCbCr == 0)
    1091   {
    1092     pRec        = m_pcPic->getPicYuvRec()->getLumaAddr();
    1093     picWidthTmp = m_iPicWidth;
    1094   }
    1095   else if (yCbCr == 1)
    1096   {
    1097     pRec        = m_pcPic->getPicYuvRec()->getCbAddr();
    1098     picWidthTmp = m_iPicWidth>>1;
    1099   }
    1100   else
    1101   {
    1102     pRec        = m_pcPic->getPicYuvRec()->getCrAddr();
    1103     picWidthTmp = m_iPicWidth>>1;
    1104   }
    1105 
    1106   memcpy(m_pTmpU1, pRec, sizeof(Pel)*picWidthTmp);
    1107 
    1108   Int  i;
    1109   UInt edgeType;
    1110   Pel* ppLumaTable = NULL;
    1111   Pel* pClipTable = NULL;
    1112   Int* pOffsetBo = NULL;
    1113   Int  typeIdx;
    1114 
    1115   Int offset[LUMA_GROUP_NUM+1];
    1116   Int idxX;
    1117   Int idxY;
    1118   Int addr;
    1119   Int frameWidthInCU = m_pcPic->getFrameWidthInCU();
    1120   Int frameHeightInCU = m_pcPic->getFrameHeightInCU();
    1121   Int stride;
    1122   Pel *tmpUSwap;
    1123   Int isChroma = (yCbCr == 0) ? 0:1;
    1124   Bool mergeLeftFlag;
    1125   Int saoBitIncrease = (yCbCr == 0) ? m_uiSaoBitIncreaseY : m_uiSaoBitIncreaseC;
    1126 
    1127   pOffsetBo = (yCbCr==0) ? m_iOffsetBo : m_iChromaOffsetBo;
    1128 
    1129   offset[0] = 0;
    1130   for (idxY = 0; idxY< frameHeightInCU; idxY++)
    1131   {
    1132     addr = idxY * frameWidthInCU;
    1133     if (yCbCr == 0)
    1134     {
    1135       pRec  = m_pcPic->getPicYuvRec()->getLumaAddr(addr);
    1136       stride = m_pcPic->getStride();
    1137       picWidthTmp = m_iPicWidth;
    1138     }
    1139     else if (yCbCr == 1)
    1140     {
    1141       pRec  = m_pcPic->getPicYuvRec()->getCbAddr(addr);
    1142       stride = m_pcPic->getCStride();
    1143       picWidthTmp = m_iPicWidth>>1;
    1144     }
    1145     else
    1146     {
    1147       pRec  = m_pcPic->getPicYuvRec()->getCrAddr(addr);
    1148       stride = m_pcPic->getCStride();
    1149       picWidthTmp = m_iPicWidth>>1;
    1150     }
    1151 
    1152     //     pRec += iStride*(m_uiMaxCUHeight-1);
    1153     for (i=0;i<(m_uiMaxCUHeight>>isChroma)+1;i++)
    1154     {
    1155       m_pTmpL1[i] = pRec[0];
    1156       pRec+=stride;
    1157     }
    1158     pRec-=(stride<<1);
    1159 
    1160     memcpy(m_pTmpU2, pRec, sizeof(Pel)*picWidthTmp);
    1161 
    1162     for (idxX = 0; idxX < frameWidthInCU; idxX++)
    1163     {
    1164       addr = idxY * frameWidthInCU + idxX;
    1165 
    1166       if (oneUnitFlag)
    1167       {
    1168         typeIdx = saoLcuParam[0].typeIdx;
    1169         mergeLeftFlag = (addr == 0)? 0:1;
    1170       }
    1171       else
    1172       {
    1173         typeIdx = saoLcuParam[addr].typeIdx;
    1174         mergeLeftFlag = saoLcuParam[addr].mergeLeftFlag;
    1175       }
    1176       if (typeIdx>=0)
    1177       {
    1178         if (!mergeLeftFlag)
    1179         {
    1180 
    1181           if (typeIdx == SAO_BO)
    1182           {
    1183             for (i=0; i<SAO_MAX_BO_CLASSES+1;i++)
    1184             {
    1185               offset[i] = 0;
    1186             }
    1187             for (i=0; i<saoLcuParam[addr].length; i++)
    1188             {
    1189               offset[ (saoLcuParam[addr].subTypeIdx +i)%SAO_MAX_BO_CLASSES  +1] = saoLcuParam[addr].offset[i] << saoBitIncrease;
    1190             }
    1191 
    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++)
    1197             {
    1198               pOffsetBo[i] = pClipTable[i + offset[ppLumaTable[i]]];
    1199             }
    1200 
    1201           }
    1202           if (typeIdx == SAO_EO_0 || typeIdx == SAO_EO_1 || typeIdx == SAO_EO_2 || typeIdx == SAO_EO_3)
    1203           {
    1204             for (i=0;i<saoLcuParam[addr].length;i++)
    1205             {
    1206               offset[i+1] = saoLcuParam[addr].offset[i] << saoBitIncrease;
    1207             }
    1208             for (edgeType=0;edgeType<6;edgeType++)
    1209             {
    1210               m_iOffsetEo[edgeType]= offset[m_auiEoTable[edgeType]];
    1211             }
    1212           }
    1213         }
    1214         processSaoCu(addr, typeIdx, yCbCr);
    1215       }
    1216       else
    1217       {
    1218         if (idxX != (frameWidthInCU-1))
    1219         {
    1220           if (yCbCr == 0)
    1221           {
    1222             pRec  = m_pcPic->getPicYuvRec()->getLumaAddr(addr);
    1223             stride = m_pcPic->getStride();
    1224           }
    1225           else if (yCbCr == 1)
    1226           {
    1227             pRec  = m_pcPic->getPicYuvRec()->getCbAddr(addr);
    1228             stride = m_pcPic->getCStride();
    1229           }
    1230           else
    1231           {
    1232             pRec  = m_pcPic->getPicYuvRec()->getCrAddr(addr);
    1233             stride = m_pcPic->getCStride();
    1234           }
    1235           Int widthShift = m_uiMaxCUWidth>>isChroma;
    1236           for (i=0;i<(m_uiMaxCUHeight>>isChroma)+1;i++)
    1237           {
    1238             m_pTmpL1[i] = pRec[widthShift-1];
    1239             pRec+=stride;
    1240           }
    1241         }
    1242       }
    1243     }
    1244     tmpUSwap = m_pTmpU1;
    1245     m_pTmpU1 = m_pTmpU2;
    1246     m_pTmpU2 = tmpUSwap;
    1247   }
    1248 
    1249 }
    1250 /** Reset SAO LCU part
    1251  * \param saoLcuParam
    1252  */
    1253 Void TComSampleAdaptiveOffset::resetLcuPart(SaoLcuParam* saoLcuParam)
    1254 {
    1255   Int i,j;
    1256   for (i=0;i<m_iNumCuInWidth*m_iNumCuInHeight;i++)
    1257   {
    1258     saoLcuParam[i].mergeUpFlag     =  1;
    1259     saoLcuParam[i].mergeLeftFlag =  0;
    1260     saoLcuParam[i].partIdx   =  0;
    1261     saoLcuParam[i].typeIdx      = -1;
    1262     for (j=0;j<MAX_NUM_SAO_OFFSETS;j++)
    1263     {
    1264       saoLcuParam[i].offset[j] = 0;
    1265     }
    1266     saoLcuParam[i].subTypeIdx = 0;
    1267   }
    1268 }
    1269 
    1270 /** convert QP part to SAO unit
    1271 * \param saoParam SAO parameter
    1272 * \param partIdx SAO part index
    1273 * \param yCbCr color component index
    1274  */
    1275 Void TComSampleAdaptiveOffset::convertQT2SaoUnit(SAOParam *saoParam, UInt partIdx, Int yCbCr)
    1276 {
    1277 
    1278   SAOQTPart*  saoPart= &(saoParam->psSaoPart[yCbCr][partIdx]);
    1279   if (!saoPart->bSplit)
    1280   {
    1281     convertOnePart2SaoUnit(saoParam, partIdx, yCbCr);
    1282     return;
    1283   }
    1284 
    1285   if (saoPart->PartLevel < m_uiMaxSplitLevel)
    1286   {
    1287     convertQT2SaoUnit(saoParam, saoPart->DownPartsIdx[0], yCbCr);
    1288     convertQT2SaoUnit(saoParam, saoPart->DownPartsIdx[1], yCbCr);
    1289     convertQT2SaoUnit(saoParam, saoPart->DownPartsIdx[2], yCbCr);
    1290     convertQT2SaoUnit(saoParam, saoPart->DownPartsIdx[3], yCbCr);
    1291   }
    1292 }
    1293 /** convert one SAO part to SAO unit
    1294 * \param saoParam SAO parameter
    1295 * \param partIdx SAO part index
    1296 * \param yCbCr color component index
    1297  */
    1298 Void TComSampleAdaptiveOffset::convertOnePart2SaoUnit(SAOParam *saoParam, UInt partIdx, Int yCbCr)
    1299 {
    1300   Int j;
    1301   Int idxX;
    1302   Int idxY;
    1303   Int addr;
    1304   Int frameWidthInCU = m_pcPic->getFrameWidthInCU();
    1305   SAOQTPart* saoQTPart = saoParam->psSaoPart[yCbCr];
    1306   SaoLcuParam* saoLcuParam = saoParam->saoLcuParam[yCbCr];
    1307 
    1308   for (idxY = saoQTPart[partIdx].StartCUY; idxY<= saoQTPart[partIdx].EndCUY; idxY++)
    1309   {
    1310     for (idxX = saoQTPart[partIdx].StartCUX; idxX<= saoQTPart[partIdx].EndCUX; idxX++)
    1311     {
    1312       addr = idxY * frameWidthInCU + idxX;
    1313       saoLcuParam[addr].partIdxTmp = (Int)partIdx;
    1314       saoLcuParam[addr].typeIdx    = saoQTPart[partIdx].iBestType;
    1315       saoLcuParam[addr].subTypeIdx = saoQTPart[partIdx].subTypeIdx;
    1316       if (saoLcuParam[addr].typeIdx!=-1)
    1317       {
    1318         saoLcuParam[addr].length    = saoQTPart[partIdx].iLength;
    1319         for (j=0;j<MAX_NUM_SAO_OFFSETS;j++)
    1320         {
    1321           saoLcuParam[addr].offset[j] = saoQTPart[partIdx].iOffset[j];
    1322         }
    1323       }
    1324       else
    1325       {
    1326         saoLcuParam[addr].length    = 0;
    1327         saoLcuParam[addr].subTypeIdx = saoQTPart[partIdx].subTypeIdx;
    1328         for (j=0;j<MAX_NUM_SAO_OFFSETS;j++)
    1329         {
    1330           saoLcuParam[addr].offset[j] = 0;
    1331         }
    1332       }
    1333     }
    1334   }
    1335 }
    1336 
    1337 Void TComSampleAdaptiveOffset::resetSaoUnit(SaoLcuParam* saoUnit)
    1338 {
    1339   saoUnit->partIdx       = 0;
    1340   saoUnit->partIdxTmp    = 0;
    1341   saoUnit->mergeLeftFlag = 0;
    1342   saoUnit->mergeUpFlag   = 0;
    1343   saoUnit->typeIdx       = -1;
    1344   saoUnit->length        = 0;
    1345   saoUnit->subTypeIdx    = 0;
    1346 
    1347   for (Int i=0;i<4;i++)
    1348   {
    1349     saoUnit->offset[i] = 0;
    1350   }
    1351 }
    1352 
    1353 Void TComSampleAdaptiveOffset::copySaoUnit(SaoLcuParam* saoUnitDst, SaoLcuParam* saoUnitSrc )
    1354 {
    1355   saoUnitDst->mergeLeftFlag = saoUnitSrc->mergeLeftFlag;
    1356   saoUnitDst->mergeUpFlag   = saoUnitSrc->mergeUpFlag;
    1357   saoUnitDst->typeIdx       = saoUnitSrc->typeIdx;
    1358   saoUnitDst->length        = saoUnitSrc->length;
    1359 
    1360   saoUnitDst->subTypeIdx  = saoUnitSrc->subTypeIdx;
    1361   for (Int i=0;i<4;i++)
    1362   {
    1363     saoUnitDst->offset[i] = saoUnitSrc->offset[i];
    1364   }
    1365 }
    1366 
    1367 /** PCM LF disable process.
     670  case SAO_Cb:
     671    {
     672      pBuf = pPicYuv->getCbAddr();
     673    }
     674    break;
     675  case SAO_Cr:
     676    {
     677      pBuf = pPicYuv->getCrAddr();
     678    }
     679    break;
     680  default:
     681    {
     682      printf("Not a legal component ID for SAO\n");
     683      assert(0);
     684      exit(-1);
     685    }
     686  }
     687
     688  return pBuf;
     689}
     690
     691/** PCM LF disable process.
    1368692 * \param pcPic picture (TComPic) pointer
    1369693 * \returns Void
  • branches/HTM-10.0-dev0/source/Lib/TLibCommon/TComSampleAdaptiveOffset.h

    r608 r852  
    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 *
     
    4949// ====================================================================================================================
    5050
    51 #define SAO_MAX_DEPTH                 4
    52 #define SAO_BO_BITS                   5
    53 #define LUMA_GROUP_NUM                (1<<SAO_BO_BITS)
    54 #define MAX_NUM_SAO_OFFSETS           4
    55 #define MAX_NUM_SAO_CLASS             33
     51#define MAX_SAO_TRUNCATED_BITDEPTH     10
    5652// ====================================================================================================================
    5753// Class definition
    5854// ====================================================================================================================
     55extern UInt g_saoMaxOffsetQVal[NUM_SAO_COMPONENTS];
    5956
    60 /// Sample Adaptive Offset class
    6157class TComSampleAdaptiveOffset
    6258{
     59public:
     60  TComSampleAdaptiveOffset();
     61  virtual ~TComSampleAdaptiveOffset();
     62  Void SAOProcess(TComPic* pDecPic);
     63  Void create( Int picWidth, Int picHeight, UInt maxCUWidth, UInt maxCUHeight, UInt maxCUDepth );
     64  Void destroy();
     65  Void reconstructBlkSAOParams(TComPic* pic, SAOBlkParam* saoBlkParams);
     66  Void PCMLFDisableProcess (TComPic* pcPic);
    6367protected:
    64   TComPic*          m_pcPic;
     68  Void offsetBlock(Int compIdx, Int typeIdx, Int* offset, Pel* srcBlk, Pel* resBlk, Int srcStride, Int resStride,  Int width, Int height
     69                  , Bool isLeftAvail, Bool isRightAvail, Bool isAboveAvail, Bool isBelowAvail, Bool isAboveLeftAvail, Bool isAboveRightAvail, Bool isBelowLeftAvail, Bool isBelowRightAvail);
     70  Pel* getPicBuf(TComPicYuv* pPicYuv, Int compIdx);
     71  Void invertQuantOffsets(Int compIdx, Int typeIdc, Int typeAuxInfo, Int* dstOffsets, Int* srcOffsets);
     72  Void reconstructBlkSAOParam(SAOBlkParam& recParam, std::vector<SAOBlkParam*>& mergeList);
     73  Int  getMergeList(TComPic* pic, Int ctu, SAOBlkParam* blkParams, std::vector<SAOBlkParam*>& mergeList);
     74  Void offsetCTU(Int ctu, TComPicYuv* srcYuv, TComPicYuv* resYuv, SAOBlkParam& saoblkParam, TComPic* pPic);
     75  Void xPCMRestoration(TComPic* pcPic);
     76  Void xPCMCURestoration ( TComDataCU* pcCU, UInt uiAbsZorderIdx, UInt uiDepth );
     77  Void xPCMSampleRestoration (TComDataCU* pcCU, UInt uiAbsZorderIdx, UInt uiDepth, TextType ttText);
     78protected:
     79  UInt m_offsetStepLog2[NUM_SAO_COMPONENTS]; //offset step 
     80  Int* m_offsetClip[NUM_SAO_COMPONENTS]; //clip table for fast operation
     81  Short* m_sign; //sign table for fast operation
     82  TComPicYuv*   m_tempPicYuv; //temporary buffer
     83  Int m_picWidth;
     84  Int m_picHeight;
     85  Int m_maxCUWidth;
     86  Int m_maxCUHeight;
     87  Int m_numCTUInWidth;
     88  Int m_numCTUInHeight;
     89  Int m_numCTUsPic;
     90 
     91 
     92  Int m_lineBufWidth;
     93  Char* m_signLineBuf1;
     94  Char* m_signLineBuf2;
     95private:
     96  Bool m_picSAOEnabled[NUM_SAO_COMPONENTS];
     97  Int*   m_offsetClipTable[NUM_SAO_COMPONENTS];
     98  Short* m_signTable;
    6599
    66   static const UInt m_uiMaxDepth;
    67   static const Int m_aiNumCulPartsLevel[5];
    68   static const UInt m_auiEoTable[9];
    69   Int *m_iOffsetBo;
    70   Int *m_iChromaOffsetBo;
    71   Int m_iOffsetEo[LUMA_GROUP_NUM];
    72 
    73   Int  m_iPicWidth;
    74   Int  m_iPicHeight;
    75   UInt m_uiMaxSplitLevel;
    76   UInt m_uiMaxCUWidth;
    77   UInt m_uiMaxCUHeight;
    78   Int  m_iNumCuInWidth;
    79   Int  m_iNumCuInHeight;
    80   Int  m_iNumTotalParts;
    81   static const Int m_iNumClass[MAX_NUM_SAO_TYPE];
    82 
    83   UInt m_uiSaoBitIncreaseY;
    84   UInt m_uiSaoBitIncreaseC;  //for chroma
    85   UInt m_uiQP;
    86 
    87   Pel   *m_pClipTable;
    88   Pel   *m_pClipTableBase;
    89   Pel   *m_lumaTableBo;
    90   Pel   *m_pChromaClipTable;
    91   Pel   *m_pChromaClipTableBase;
    92   Pel   *m_chromaTableBo;
    93   Int   *m_iUpBuff1;
    94   Int   *m_iUpBuff2;
    95   Int   *m_iUpBufft;
    96   Int   *ipSwap;
    97   Bool  m_bUseNIF;       //!< true for performing non-cross slice boundary ALF
    98   TComPicYuv* m_pcYuvTmp;    //!< temporary picture buffer pointer when non-across slice/tile boundary SAO is enabled
    99 
    100   Pel* m_pTmpU1;
    101   Pel* m_pTmpU2;
    102   Pel* m_pTmpL1;
    103   Pel* m_pTmpL2;
    104   Int     m_maxNumOffsetsPerPic;
    105   Bool    m_saoLcuBoundary;
    106   Bool    m_saoLcuBasedOptimization;
    107 
    108   Void xPCMRestoration        (TComPic* pcPic);
    109   Void xPCMCURestoration      (TComDataCU* pcCU, UInt uiAbsZorderIdx, UInt uiDepth);
    110   Void xPCMSampleRestoration  (TComDataCU* pcCU, UInt uiAbsZorderIdx, UInt uiDepth, TextType ttText);
    111 public:
    112   TComSampleAdaptiveOffset         ();
    113   virtual ~TComSampleAdaptiveOffset();
    114 
    115   Void create( UInt uiSourceWidth, UInt uiSourceHeight, UInt uiMaxCUWidth, UInt uiMaxCUHeight );
    116   Void destroy ();
    117 
    118   Int  convertLevelRowCol2Idx(Int level, Int row, Int col);
    119 
    120   Void initSAOParam   (SAOParam *pcSaoParam, Int iPartLevel, Int iPartRow, Int iPartCol, Int iParentPartIdx, Int StartCUX, Int EndCUX, Int StartCUY, Int EndCUY, Int iYCbCr);
    121   Void allocSaoParam  (SAOParam* pcSaoParam);
    122   Void resetSAOParam  (SAOParam *pcSaoParam);
    123   static Void freeSaoParam   (SAOParam *pcSaoParam);
    124  
    125   Void SAOProcess(SAOParam* pcSaoParam);
    126   Void processSaoCu(Int iAddr, Int iSaoType, Int iYCbCr);
    127   Pel* getPicYuvAddr(TComPicYuv* pcPicYuv, Int iYCbCr,Int iAddr = 0);
    128 
    129   Void processSaoCuOrg(Int iAddr, Int iPartIdx, Int iYCbCr);  //!< LCU-basd SAO process without slice granularity
    130   Void createPicSaoInfo(TComPic* pcPic);
    131   Void destroyPicSaoInfo();
    132   Void processSaoBlock(Pel* pDec, Pel* pRest, Int stride, Int iSaoType, UInt width, UInt height, Bool* pbBorderAvail, Int iYCbCr);
    133 
    134   Void resetLcuPart(SaoLcuParam* saoLcuParam);
    135   Void convertQT2SaoUnit(SAOParam* saoParam, UInt partIdx, Int yCbCr);
    136   Void convertOnePart2SaoUnit(SAOParam *saoParam, UInt partIdx, Int yCbCr);
    137   Void processSaoUnitAll(SaoLcuParam* saoLcuParam, Bool oneUnitFlag, Int yCbCr);
    138   Void setSaoLcuBoundary (Bool bVal)  {m_saoLcuBoundary = bVal;}
    139   Bool getSaoLcuBoundary ()           {return m_saoLcuBoundary;}
    140   Void setSaoLcuBasedOptimization (Bool bVal)  {m_saoLcuBasedOptimization = bVal;}
    141   Bool getSaoLcuBasedOptimization ()           {return m_saoLcuBasedOptimization;}
    142   Void resetSaoUnit(SaoLcuParam* saoUnit);
    143   Void copySaoUnit(SaoLcuParam* saoUnitDst, SaoLcuParam* saoUnitSrc );
    144   Void PCMLFDisableProcess    ( TComPic* pcPic);                        ///< interface function for ALF process
    145100};
    146101
  • branches/HTM-10.0-dev0/source/Lib/TLibCommon/TComSlice.cpp

    r833 r852  
    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 *
     
    7171, m_colFromL0Flag                 ( 1 )
    7272, m_colRefIdx                     ( 0 )
    73 #if SAO_CHROMA_LAMBDA
    74 , m_dLambdaLuma( 0.0 )
    75 , m_dLambdaChroma( 0.0 )
    76 #else
    77 , m_dLambda                       ( 0.0 )
    78 #endif
    7973, m_uiTLayer                      ( 0 )
    8074, m_bTLayerSwitchingFlag          ( false )
     
    130124  initEqualRef();
    131125 
     126  for (Int component = 0; component < 3; component++)
     127  {
     128    m_lambdas[component] = 0.0;
     129  }
     130 
    132131  for ( Int idx = 0; idx < MAX_NUM_REF; idx++ )
    133132  {
     
    148147  initWpAcDcParam();
    149148  m_saoEnabledFlag = false;
     149  m_saoEnabledFlagChroma = false;
    150150#if H_MV
    151151  for (Int i = 0; i < MAX_NUM_LAYERS; i++ )
     
    370370  }
    371371}
     372
    372373#if !H_MV
    373 #if FIX1071
    374374Void TComSlice::setRefPicList( TComList<TComPic*>& rcListPic, Bool checkNumPocTotalCurr )
    375 #else
    376 Void TComSlice::setRefPicList( TComList<TComPic*>& rcListPic )
    377 #endif
    378 {
    379 #if FIX1071
     375{
    380376  if (!checkNumPocTotalCurr)
    381 #endif
    382377  {
    383378    if (m_eSliceType == I_SLICE)
     
    449444  TComPic*  rpsCurrList1[MAX_NUM_REF+1];
    450445  Int numPocTotalCurr = NumPocStCurr0 + NumPocStCurr1 + NumPocLtCurr;
    451 
    452 #if FIX1071
    453446  if (checkNumPocTotalCurr)
    454447  {
     
    474467    m_aiNumRefIdx[1] = getNumRefIdx(REF_PIC_LIST_1);
    475468  }
    476 #endif
    477469
    478470  Int cIdx = 0;
     
    873865{
    874866  TComPic*                 rpcPic;
     867#if !FIX1172
    875868  setAssociatedIRAPPOC(pocCRA);
     869#endif
    876870  Int pocCurr = getPOC();
    877871
     
    993987  m_colFromL0Flag        = pSrc->m_colFromL0Flag;
    994988  m_colRefIdx            = pSrc->m_colRefIdx;
    995 #if SAO_CHROMA_LAMBDA
    996   m_dLambdaLuma          = pSrc->m_dLambdaLuma;
    997   m_dLambdaChroma        = pSrc->m_dLambdaChroma;
    998 #else
    999   m_dLambda              = pSrc->m_dLambda;
    1000 #endif
     989  setLambdas(pSrc->getLambdas());
    1001990  for (i = 0; i < 2; i++)
    1002991  {
     
    11771166  {
    11781167    rpcPic = *(iterPic++);
     1168#if BUGFIX_INTRAPERIOD
     1169    if(!rpcPic->getReconMark())
     1170    {
     1171      continue;
     1172    }
     1173#endif
    11791174    if (rpcPic->getPOC() == this->getPOC())
    11801175    {
     
    13421337    assert(rpcPic->getSlice( 0 )->isReferenced()==0||rpcPic->getUsedByCurr()==0||rpcPic->getTLayer()<=this->getTLayer());
    13431338    //check that pictures of higher or equal temporal layer are not in the RPS if the current picture is a TSA picture
    1344     if(this->getNalUnitType() == NAL_UNIT_CODED_SLICE_TLA_R || this->getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_N)
     1339    if(this->getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_R || this->getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_N)
    13451340    {
    13461341      assert(rpcPic->getSlice( 0 )->isReferenced()==0||rpcPic->getTLayer()<this->getTLayer());
     
    15011496/** Function for constructing an explicit Reference Picture Set out of the available pictures in a referenced Reference Picture Set
    15021497*/
    1503 #if FIX1071
    15041498Void TComSlice::createExplicitReferencePictureSetFromReference( TComList<TComPic*>& rcListPic, TComReferencePictureSet *pReferencePictureSet, Bool isRAP)
    1505 #else
    1506 Void TComSlice::createExplicitReferencePictureSetFromReference( TComList<TComPic*>& rcListPic, TComReferencePictureSet *pReferencePictureSet)
    1507 #endif
    15081499{
    15091500  TComPic* rpcPic;
     
    15301521        // and should be added to the explicit Reference Picture Set
    15311522        pcRPS->setDeltaPOC(k, pReferencePictureSet->getDeltaPOC(i));
    1532 #if FIX1071
    15331523        pcRPS->setUsed(k, pReferencePictureSet->getUsed(i) && (!isRAP));
    1534 #else
    1535         pcRPS->setUsed(k, pReferencePictureSet->getUsed(i));
    1536 #endif
    15371524        if(pcRPS->getDeltaPOC(k) < 0)
    15381525        {
     
    19551942  for ( i = 0; i < iNumViews ; i++ )
    19561943  {
     1944    m_bCamParInSliceHeader[i] = false;
    19571945    m_aaaiCodedScale[i] = new Int*[ 2 ];
    19581946    m_aaaiCodedOffset[i] = new Int*[ 2 ];
     
    21812169, m_qpBDOffsetY               (  0)
    21822170, m_qpBDOffsetC               (  0)
    2183 , m_useLossless               (false)
    21842171, m_uiPCMBitDepthLuma         (  8)
    21852172, m_uiPCMBitDepthChroma       (  8)
     
    28612848    for(UInt listId=0;listId<g_scalingListNum[sizeId];listId++)
    28622849    {
    2863       getScalingList()->processDefaultMarix(sizeId, listId);
     2850      getScalingList()->processDefaultMatrix(sizeId, listId);
    28642851    }
    28652852  }
     
    35843571 * \param Index of input matrix
    35853572 */
    3586 Void TComScalingList::processDefaultMarix(UInt sizeId, UInt listId)
     3573Void TComScalingList::processDefaultMatrix(UInt sizeId, UInt listId)
    35873574{
    35883575  ::memcpy(getScalingListAddress(sizeId, listId),getScalingListDefaultAddress(sizeId,listId),sizeof(Int)*min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId]));
     
    36013588      if(getScalingListDC(sizeId,listId) == 0)
    36023589      {
    3603         processDefaultMarix(sizeId, listId);
     3590        processDefaultMatrix(sizeId, listId);
    36043591      }
    36053592    }
  • branches/HTM-10.0-dev0/source/Lib/TLibCommon/TComSlice.h

    r833 r852  
    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 *
     
    161161  UInt     getRefMatrixId                 (UInt sizeId, UInt listId)           { return m_refMatrixId[sizeId][listId]; }     //!< get reference matrix ID
    162162  Int*     getScalingListDefaultAddress   (UInt sizeId, UInt listId);                                                        //!< get default matrix coefficient
    163   Void     processDefaultMarix            (UInt sizeId, UInt listId);
     163  Void     processDefaultMatrix            (UInt sizeId, UInt listId);
    164164  Void     setScalingListDC               (UInt sizeId, UInt listId, UInt u)   { m_scalingListDC[sizeId][listId] = u; }      //!< set DC value
    165165
     
    851851  UInt    getNumReorderPics(UInt tLayer)                        { return m_numReorderPics[tLayer]; }
    852852 
    853   Void    setMaxDecPicBuffering(UInt v, UInt tLayer)            { m_uiMaxDecPicBuffering[tLayer] = v;    }
     853  Void    setMaxDecPicBuffering(UInt v, UInt tLayer)            { assert(tLayer < MAX_TLAYER); m_uiMaxDecPicBuffering[tLayer] = v;    }
    854854  UInt    getMaxDecPicBuffering(UInt tLayer)                    { return m_uiMaxDecPicBuffering[tLayer]; }
    855855 
     
    14191419  Int         m_qpBDOffsetY;
    14201420  Int         m_qpBDOffsetC;
    1421 
    1422   Bool        m_useLossless;
    14231421
    14241422  UInt        m_uiPCMBitDepthLuma;
     
    15531551  UInt getMaxTrSize   ()         { return  m_uiMaxTrSize;   }
    15541552 
    1555   // Tool list
    1556   Bool getUseLossless ()         { return m_useLossless; }
    1557   Void setUseLossless ( Bool b ) { m_useLossless  = b; }
    1558  
    15591553  // AMP accuracy
    15601554  Int       getAMPAcc   ( UInt uiDepth ) { return m_iAMPAcc[uiDepth]; }
     
    15921586  TComScalingList* getScalingList ()       { return m_scalingList; }               //!< get ScalingList class pointer in SPS
    15931587  UInt getMaxDecPicBuffering  (UInt tlayer)            { return m_uiMaxDecPicBuffering[tlayer]; }
    1594   Void setMaxDecPicBuffering  ( UInt ui, UInt tlayer ) { m_uiMaxDecPicBuffering[tlayer] = ui;   }
     1588  Void setMaxDecPicBuffering  ( UInt ui, UInt tlayer ) { assert(tlayer < MAX_TLAYER);  m_uiMaxDecPicBuffering[tlayer] = ui;   }
    15951589  UInt getMaxLatencyIncrease  (UInt tlayer)            { return m_uiMaxLatencyIncrease[tlayer];   }
    15961590  Void setMaxLatencyIncrease  ( UInt ui , UInt tlayer) { m_uiMaxLatencyIncrease[tlayer] = ui;      }
     
    19881982  UInt        m_maxNumMergeCand;
    19891983
    1990 
    1991 #if SAO_CHROMA_LAMBDA
    1992   Double      m_dLambdaLuma;
    1993   Double      m_dLambdaChroma;
    1994 #else
    1995   Double      m_dLambda;
    1996 #endif
     1984  Double      m_lambdas[3];
    19971985
    19981986  Bool        m_abEqualRef  [2][MAX_NUM_REF][MAX_NUM_REF];
     
    22052193  Void      setRefPicList        ( std::vector<TComPic*> rpsCurrList[2], std::vector<Bool> usedAsLongTerm[2], Int numPocTotalCurr, Bool checkNumPocTotalCurr = false );
    22062194#else
    2207 #if FIX1071
    22082195  Void      setRefPicList       ( TComList<TComPic*>& rcListPic, Bool checkNumPocTotalCurr = false );
    2209 #else
    2210   Void      setRefPicList       ( TComList<TComPic*>& rcListPic );
    2211 #endif
    22122196#endif
    22132197  Void      setRefPOCList       ();
     
    22212205  Bool      isInterP        ()                          { return  m_eSliceType == P_SLICE;  }
    22222206 
    2223 #if SAO_CHROMA_LAMBDA 
    2224   Void      setLambda( Double d, Double e ) { m_dLambdaLuma = d; m_dLambdaChroma = e;}
    2225   Double    getLambdaLuma() { return m_dLambdaLuma;        }
    2226   Double    getLambdaChroma() { return m_dLambdaChroma;        }
    2227 #else
    2228   Void      setLambda( Double d ) { m_dLambda = d; }
    2229   Double    getLambda() { return m_dLambda;        }
    2230 #endif
     2207  Void      setLambdas ( const Double lambdas[3] ) { for (Int component = 0; component < 3; component++) m_lambdas[component] = lambdas[component]; }
     2208  const Double* getLambdas() const { return m_lambdas; }
    22312209 
    22322210  Void      initEqualRef();
     
    22622240  Bool isStepwiseTemporalLayerSwitchingPointCandidate( TComList<TComPic*>& rcListPic );
    22632241  Int       checkThatAllRefPicsAreAvailable( TComList<TComPic*>& rcListPic, TComReferencePictureSet *pReferencePictureSet, Bool printErrors, Int pocRandomAccess = 0);
    2264 #if FIX1071
    22652242  Void      createExplicitReferencePictureSetFromReference( TComList<TComPic*>& rcListPic, TComReferencePictureSet *pReferencePictureSet, Bool isRAP);
    2266 #else
    2267   Void      createExplicitReferencePictureSetFromReference( TComList<TComPic*>& rcListPic, TComReferencePictureSet *pReferencePictureSet);
    2268 #endif
    22692243
    22702244  Void setMaxNumMergeCand               (UInt val )         { m_maxNumMergeCand = val;                    }
  • branches/HTM-10.0-dev0/source/Lib/TLibCommon/TComTrQuant.cpp

    r608 r852  
    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 *
     
    10681068    UInt uiLog2TrSize = g_aucConvertToBit[ iWidth ] + 2;
    10691069    Int scalingListType = (pcCU->isIntra(uiAbsPartIdx) ? 0 : 3) + g_eTTable[(Int)eTType];
    1070     assert(scalingListType < 6);
     1070    assert(scalingListType < SCALING_LIST_NUM);
    10711071    Int *piQuantCoeff = 0;
    10721072    piQuantCoeff = getQuantCoeff(scalingListType,m_cQP.m_iRem,uiLog2TrSize-2);
     
    13071307    Pel* pResi = rpcResidual + uiAddr;
    13081308    Int scalingListType = (pcCU->isIntra(uiAbsPartIdx) ? 0 : 3) + g_eTTable[(Int)eTxt];
    1309     assert(scalingListType < 6);
     1309    assert(scalingListType < SCALING_LIST_NUM);
    13101310    invtransformNxN( pcCU->getCUTransquantBypass(uiAbsPartIdx), eTxt, REG_DCT, pResi, uiStride, rpcCoeff, uiWidth, uiHeight, scalingListType, pcCU->getTransformSkip(uiAbsPartIdx, eTxt) );
    13111311  }
     
    15081508  const UInt uiMaxNumCoeff       = uiWidth * uiHeight;
    15091509  Int scalingListType = (pcCU->isIntra(uiAbsPartIdx) ? 0 : 3) + g_eTTable[(Int)eTType];
    1510   assert(scalingListType < 6);
     1510  assert(scalingListType < SCALING_LIST_NUM);
    15111511 
    15121512  Int iQBits = QUANT_SHIFT + m_cQP.m_iPer + iTransformShift;                   // Right shift of non-RDOQ quantizer;  level = (coeff*uiQ + offset)>>q_bits
     
    19271927              Int64 costUp   = rdFactor * ( - deltaU[uiBlkPos] ) + rateIncUp[uiBlkPos] ;
    19281928              Int64 costDown = rdFactor * (   deltaU[uiBlkPos] ) + rateIncDown[uiBlkPos]
    1929               -   ( abs(piDstCoeff[uiBlkPos])==1?((1<<15)+sigRateDelta[uiBlkPos]):0 );
     1929              -   ((abs(piDstCoeff[uiBlkPos]) == 1) ? sigRateDelta[uiBlkPos] : 0);
    19301930             
    19311931              if(lastCG==1 && lastNZPosInCG==n && abs(piDstCoeff[uiBlkPos])==1)
     
    21462146  {
    21472147    Double dErr         = Double( lLevelDouble  - ( uiAbsLevel << iQBits ) );
    2148     Double dCurrCost    = dErr * dErr * dTemp + xGetICRateCost( uiAbsLevel, ui16CtxNumOne, ui16CtxNumAbs, ui16AbsGoRice, c1Idx, c2Idx );
     2148    Double dCurrCost    = dErr * dErr * dTemp + xGetICost(xGetICRate( uiAbsLevel, ui16CtxNumOne, ui16CtxNumAbs, ui16AbsGoRice, c1Idx, c2Idx ));
    21492149    dCurrCost          += dCurrCostSig;
    21502150
     
    21672167 * \returns cost of given absolute transform level
    21682168 */
    2169 __inline Double TComTrQuant::xGetICRateCost  ( UInt                            uiAbsLevel,
     2169__inline Int TComTrQuant::xGetICRate  ( UInt                            uiAbsLevel,
    21702170                                               UShort                          ui16CtxNumOne,
    21712171                                               UShort                          ui16CtxNumAbs,
     
    21752175                                               ) const
    21762176{
    2177   Double iRate = xGetIEPRate();
     2177  Int iRate = Int(xGetIEPRate());
    21782178  UInt baseLevel  =  (c1Idx < C1FLAG_NUMBER)? (2 + (c2Idx < C2FLAG_NUMBER)) : 1;
    21792179
     
    22192219  else
    22202220  {
    2221     assert (0);
    2222   }
    2223   return xGetICost( iRate );
    2224 }
    2225 
    2226 __inline Int TComTrQuant::xGetICRate  ( UInt                            uiAbsLevel,
    2227                                        UShort                          ui16CtxNumOne,
    2228                                        UShort                          ui16CtxNumAbs,
    2229                                        UShort                          ui16AbsGoRice
    2230                                      , UInt                            c1Idx,
    2231                                        UInt                            c2Idx
    2232                                        ) const
    2233 {
    2234   Int iRate = 0;
    2235   UInt baseLevel  =  (c1Idx < C1FLAG_NUMBER)? (2 + (c2Idx < C2FLAG_NUMBER)) : 1;
    2236 
    2237   if ( uiAbsLevel >= baseLevel )
    2238   {
    2239     UInt uiSymbol     = uiAbsLevel - baseLevel;
    2240     UInt uiMaxVlc     = g_auiGoRiceRange[ ui16AbsGoRice ];
    2241     Bool bExpGolomb   = ( uiSymbol > uiMaxVlc );
    2242 
    2243     if( bExpGolomb )
    2244     {
    2245       uiAbsLevel  = uiSymbol - uiMaxVlc;
    2246       Int iEGS    = 1;  for( UInt uiMax = 2; uiAbsLevel >= uiMax; uiMax <<= 1, iEGS += 2 );
    2247       iRate      += iEGS << 15;
    2248       uiSymbol    = min<UInt>( uiSymbol, ( uiMaxVlc + 1 ) );
    2249     }
    2250 
    2251     UShort ui16PrefLen = UShort( uiSymbol >> ui16AbsGoRice ) + 1;
    2252     UShort ui16NumBins = min<UInt>( ui16PrefLen, g_auiGoRicePrefixLen[ ui16AbsGoRice ] ) + ui16AbsGoRice;
    2253 
    2254     iRate += ui16NumBins << 15;
    2255 
    2256     if (c1Idx < C1FLAG_NUMBER)
    2257     {
    2258       iRate += m_pcEstBitsSbac->m_greaterOneBits[ ui16CtxNumOne ][ 1 ];
    2259 
    2260       if (c2Idx < C2FLAG_NUMBER)
    2261       {
    2262         iRate += m_pcEstBitsSbac->m_levelAbsBits[ ui16CtxNumAbs ][ 1 ];
    2263       }
    2264     }
    2265   }
    2266   else
    2267   if( uiAbsLevel == 0 )
    2268   {
    2269     return 0;
    2270   }
    2271   else if( uiAbsLevel == 1 )
    2272   {
    2273     iRate += m_pcEstBitsSbac->m_greaterOneBits[ ui16CtxNumOne ][ 0 ];
    2274   }
    2275   else if( uiAbsLevel == 2 )
    2276   {
    2277     iRate += m_pcEstBitsSbac->m_greaterOneBits[ ui16CtxNumOne ][ 1 ];
    2278     iRate += m_pcEstBitsSbac->m_levelAbsBits[ ui16CtxNumAbs ][ 0 ];
    2279   }
    2280   else
    2281   {
    2282     assert(0);
     2221    iRate = 0;
    22832222  }
    22842223  return iRate;
  • branches/HTM-10.0-dev0/source/Lib/TLibCommon/TComTrQuant.h

    r608 r852  
    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 *
     
    150150
    151151#if RDOQ_CHROMA_LAMBDA
    152   Void setLambda(Double dLambdaLuma, Double dLambdaChroma) { m_dLambdaLuma = dLambdaLuma; m_dLambdaChroma = dLambdaChroma; }
    153   Void selectLambda(TextType eTType) { m_dLambda = (eTType == TEXT_LUMA) ? m_dLambdaLuma : m_dLambdaChroma; }
     152  Void setLambdas ( const Double lambdas[3] ) { for (Int component = 0; component < 3; component++) m_lambdas[component] = lambdas[component]; }
     153  Void selectLambda(TextType eTType) { m_dLambda = (eTType == TEXT_LUMA) ? m_lambdas[0] : ((eTType == TEXT_CHROMA_U) ? m_lambdas[1] : m_lambdas[2]); }
    154154#else
    155155  Void setLambda(Double dLambda) { m_dLambda = dLambda;}
     
    207207  QpParam  m_cQP;
    208208#if RDOQ_CHROMA_LAMBDA
    209   Double   m_dLambdaLuma;
    210   Double   m_dLambdaChroma;
     209  Double   m_lambdas[3];
    211210#endif
    212211  Double   m_dLambda;
     
    273272                                             Double                          dTemp,
    274273                                             Bool                            bLast        ) const;
    275   __inline Double xGetICRateCost   ( UInt                            uiAbsLevel,
    276                                      UShort                          ui16CtxNumOne,
    277                                      UShort                          ui16CtxNumAbs,
    278                                      UShort                          ui16AbsGoRice
    279                                    , UInt                            c1Idx,
    280                                      UInt                            c2Idx
    281                                      ) const;
    282274__inline Int xGetICRate  ( UInt                            uiAbsLevel,
    283275                           UShort                          ui16CtxNumOne,
  • branches/HTM-10.0-dev0/source/Lib/TLibCommon/TComWeightPrediction.cpp

    r608 r852  
    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 *
  • branches/HTM-10.0-dev0/source/Lib/TLibCommon/TComWeightPrediction.h

    r655 r852  
    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 *
  • branches/HTM-10.0-dev0/source/Lib/TLibCommon/TComYuv.cpp

    r622 r852  
    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 *
     
    110110  {
    111111    ::memcpy( pDst, pSrc, sizeof(Pel)*iWidth);
    112 
    113112#if ENC_DEC_TRACE && H_MV_ENC_DEC_TRAC
    114113    if ( g_traceCopyBack && g_nSymbolCounter >= g_stopAtCounter )
     
    121120    }
    122121#endif
    123 
    124122    pDst += iDstStride;
    125123    pSrc += iSrcStride;
     
    616614    {
    617615#if DISABLING_CLIP_FOR_BIPREDME
    618       pDst[x ] = (pDst[x ]<<1) - pSrc[x ] ;
     616      pDst[x ] = 2 * pDst[x] - pSrc[x];
    619617#else
    620       pDst[x ] = Clip( (pDst[x ]<<1) - pSrc[x ] );
     618      pDst[x ] = ClipY(2 * pDst[x] - pSrc[x]);
    621619#endif
    622620    }
     
    636634    {
    637635#if DISABLING_CLIP_FOR_BIPREDME
    638       pDstU[x ] = (pDstU[x ]<<1) - pSrcU[x ] ;
    639       pDstV[x ] = (pDstV[x ]<<1) - pSrcV[x ] ;
     636      pDstU[x ] = 2 * pDstU[x] - pSrcU[x];
     637      pDstV[x ] = 2 * pDstV[x] - pSrcV[x];
    640638#else
    641       pDstU[x ] = Clip( (pDstU[x ]<<1) - pSrcU[x ] );
    642       pDstV[x ] = Clip( (pDstV[x ]<<1) - pSrcV[x ] );
     639      pDstU[x ] = ClipC(2 * pDstU[x] - pSrcU[x]);
     640      pDstV[x ] = ClipC(2 * pDstV[x] - pSrcV[x]);
    643641#endif
    644642    }
     
    649647  }
    650648}
    651 
    652649#if H_3D
    653650Void TComYuv::addClipPartLuma( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiTrUnitIdx, UInt uiPartSize )
     
    843840#endif
    844841#endif
     842
    845843//! \}
  • branches/HTM-10.0-dev0/source/Lib/TLibCommon/TComYuv.h

    r608 r852  
    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 *
  • branches/HTM-10.0-dev0/source/Lib/TLibCommon/TypeDef.h

    r833 r852  
    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 *
     
    323323#define MTK_NBDV_IVREF_FIX_G0067          1   // Disable IvMC, VSP when IVREF is not available, JCT3V-G0067
    324324#endif
     325
     326/////////////////////////////////////////////////////////////////////////////////////////
     327///////////////////////////////////   HTM-10.1 Integrations //////////////////////////////
     328/////////////////////////////////////////////////////////////////////////////////////////
     329#define UPDATE_HM13                       1
     330#if H_3D
     331#define H_3D_FIX_G0148_BRACE              1
     332#endif
    325333/////////////////////////////////////////////////////////////////////////////////////////
    326334///////////////////////////////////   HM RELATED DEFINES ////////////////////////////////
    327335/////////////////////////////////////////////////////////////////////////////////////////
    328 
    329 #define FIX1071 1 ///< fix for issue #1071
     336#define BUGFIX_INTRAPERIOD 1
     337#define SAO_ENCODE_ALLOW_USE_PREDEBLOCK 1
     338
     339#define FIX1172 1 ///< fix ticket #1172
    330340
    331341#define MAX_NUM_PICS_IN_SOP           1024
     
    342352#else
    343353#define MAX_VPS_NUH_RESERVED_ZERO_LAYER_ID_PLUS1  1
    344 #endif
    345 
    346 #define RATE_CONTROL_LAMBDA_DOMAIN                  1  ///< JCTVC-K0103, rate control by R-lambda model
    347 #define M0036_RC_IMPROVEMENT                        1  ///< JCTVC-M0036, improvement for R-lambda model based rate control
    348 #define TICKET_1090_FIX                             1
    349 
    350 #if KWU_FIX_URQ
    351 #if RATE_CONTROL_LAMBDA_DOMAIN
    352 #define RC_FIX                                      1  /// suggested fix for M0036
    353 #define RATE_CONTROL_INTRA                          1  ///< JCTVC-M0257, rate control for intra
    354 #endif
    355 #else
    356 #define RC_FIX                                      1  /// suggested fix for M0036
    357 #define RATE_CONTROL_INTRA                          1  ///< JCTVC-M0257, rate control for intra
    358354#endif
    359355
     
    389385#define C1FLAG_NUMBER               8 // maximum number of largerThan1 flag coded in one chunk :  16 in HM5
    390386#define C2FLAG_NUMBER               1 // maximum number of largerThan2 flag coded in one chunk:  16 in HM5
    391 
    392 #define REMOVE_SAO_LCU_ENC_CONSTRAINTS_3 1  ///< disable the encoder constraint that conditionally disable SAO for chroma for entire slice in interleaved mode
    393 
    394387#define SAO_ENCODING_CHOICE              1  ///< I0184: picture early termination
    395388#if SAO_ENCODING_CHOICE
     
    405398#define MAX_NUM_PPS                64
    406399
    407 
    408 
    409 #define WEIGHTED_CHROMA_DISTORTION  1   ///< F386: weighting of chroma for RDO
    410400#define RDOQ_CHROMA_LAMBDA          1   ///< F386: weighting of chroma for RDOQ
    411 #define SAO_CHROMA_LAMBDA           1   ///< F386: weighting of chroma for SAO
    412401
    413402#define MIN_SCAN_POS_CROSS          4
     
    423412#define LEVEL_RANGE                         30     ///< G382: max coefficient level in statistics collection
    424413#endif
    425 
    426 #define NS_HAD                               0
    427414
    428415#define HHI_RQT_INTRA_SPEEDUP             1           ///< tests one best mode with full rqt
     
    492479#endif
    493480
    494 #define SCALING_LIST_OUTPUT_RESULT    0 //JCTVC-G880/JCTVC-G1016 quantization matrices
    495 
    496481#define CABAC_INIT_PRESENT_FLAG     1
    497482
     
    503488typedef       bool                Bool;
    504489
     490#ifdef __arm__
     491typedef       signed char         Char;
     492#else
    505493typedef       char                Char;
     494#endif
    506495typedef       unsigned char       UChar;
    507496typedef       short               Short;
     
    570559};
    571560
    572 #define NUM_DOWN_PART 4
    573 
    574 enum SAOTypeLen
    575 {
    576   SAO_EO_LEN    = 4,
    577   SAO_BO_LEN    = 4,
    578   SAO_MAX_BO_CLASSES = 32
    579 };
    580 
    581 enum SAOType
    582 {
    583   SAO_EO_0 = 0,
    584   SAO_EO_1,
    585   SAO_EO_2,
    586   SAO_EO_3,
    587   SAO_BO,
    588   MAX_NUM_SAO_TYPE
    589 };
    590 
    591 typedef struct _SaoQTPart
    592 {
    593   Int         iBestType;
    594   Int         iLength;
    595   Int         subTypeIdx ;                 ///< indicates EO class or BO band position
    596   Int         iOffset[4];
    597   Int         StartCUX;
    598   Int         StartCUY;
    599   Int         EndCUX;
    600   Int         EndCUY;
    601 
    602   Int         PartIdx;
    603   Int         PartLevel;
    604   Int         PartCol;
    605   Int         PartRow;
    606 
    607   Int         DownPartsIdx[NUM_DOWN_PART];
    608   Int         UpPartIdx;
    609 
    610   Bool        bSplit;
    611 
    612   //---- encoder only start -----//
    613   Bool        bProcessed;
    614   Double      dMinCost;
    615   Int64       iMinDist;
    616   Int         iMinRate;
    617   //---- encoder only end -----//
    618 } SAOQTPart;
    619 
    620 typedef struct _SaoLcuParam
    621 {
    622   Bool       mergeUpFlag;
    623   Bool       mergeLeftFlag;
    624   Int        typeIdx;
    625   Int        subTypeIdx;                  ///< indicates EO class or BO band position
    626   Int        offset[4];
    627   Int        partIdx;
    628   Int        partIdxTmp;
    629   Int        length;
    630 } SaoLcuParam;
    631 
    632 struct SAOParam
    633 {
    634   Bool       bSaoFlag[2];
    635   SAOQTPart* psSaoPart[3];
    636   Int        iMaxSplitLevel;
    637   Bool         oneUnitFlag[3];
    638   SaoLcuParam* saoLcuParam[3];
    639   Int          numCuInHeight;
    640   Int          numCuInWidth;
    641   ~SAOParam();
     561enum SAOComponentIdx
     562{
     563  SAO_Y =0,
     564  SAO_Cb,
     565  SAO_Cr,
     566  NUM_SAO_COMPONENTS
     567};
     568
     569enum SAOMode //mode
     570{
     571  SAO_MODE_OFF = 0,
     572  SAO_MODE_NEW,
     573  SAO_MODE_MERGE,
     574  NUM_SAO_MODES
     575};
     576
     577enum SAOModeMergeTypes
     578{
     579  SAO_MERGE_LEFT =0,
     580  SAO_MERGE_ABOVE,
     581  NUM_SAO_MERGE_TYPES
     582};
     583
     584
     585enum SAOModeNewTypes
     586{
     587  SAO_TYPE_START_EO =0,
     588  SAO_TYPE_EO_0 = SAO_TYPE_START_EO,
     589  SAO_TYPE_EO_90,
     590  SAO_TYPE_EO_135,
     591  SAO_TYPE_EO_45,
     592
     593  SAO_TYPE_START_BO,
     594  SAO_TYPE_BO = SAO_TYPE_START_BO,
     595
     596  NUM_SAO_NEW_TYPES
     597};
     598#define NUM_SAO_EO_TYPES_LOG2 2
     599
     600enum SAOEOClasses
     601{
     602  SAO_CLASS_EO_FULL_VALLEY = 0,
     603  SAO_CLASS_EO_HALF_VALLEY = 1,
     604  SAO_CLASS_EO_PLAIN       = 2,
     605  SAO_CLASS_EO_HALF_PEAK   = 3,
     606  SAO_CLASS_EO_FULL_PEAK   = 4,
     607  NUM_SAO_EO_CLASSES,
     608};
     609
     610
     611#define NUM_SAO_BO_CLASSES_LOG2  5
     612enum SAOBOClasses
     613{
     614  //SAO_CLASS_BO_BAND0 = 0,
     615  //SAO_CLASS_BO_BAND1,
     616  //SAO_CLASS_BO_BAND2,
     617  //...
     618  //SAO_CLASS_BO_BAND31,
     619
     620  NUM_SAO_BO_CLASSES = (1<<NUM_SAO_BO_CLASSES_LOG2),
     621};
     622#define MAX_NUM_SAO_CLASSES  32  //(NUM_SAO_EO_GROUPS > NUM_SAO_BO_GROUPS)?NUM_SAO_EO_GROUPS:NUM_SAO_BO_GROUPS
     623
     624struct SAOOffset
     625{
     626  Int modeIdc; //NEW, MERGE, OFF
     627  Int typeIdc; //NEW: EO_0, EO_90, EO_135, EO_45, BO. MERGE: left, above
     628  Int typeAuxInfo; //BO: starting band index
     629  Int offset[MAX_NUM_SAO_CLASSES];
     630
     631  SAOOffset();
     632  ~SAOOffset();
     633  Void reset();
     634
     635  const SAOOffset& operator= (const SAOOffset& src);
     636};
     637
     638struct SAOBlkParam
     639{
     640
     641  SAOBlkParam();
     642  ~SAOBlkParam();
     643  Void reset();
     644  const SAOBlkParam& operator= (const SAOBlkParam& src);
     645  SAOOffset& operator[](Int compIdx){ return offsetParam[compIdx];}
     646private:
     647  SAOOffset offsetParam[NUM_SAO_COMPONENTS];
     648
    642649};
    643650
Note: See TracChangeset for help on using the changeset viewer.