Changeset 593 in SHVCSoftware for branches/SHM-5.0-dev/source/Lib/TLibCommon


Ignore:
Timestamp:
2 Feb 2014, 04:51:29 (11 years ago)
Author:
seregin
Message:

update to HM-13.0

Location:
branches/SHM-5.0-dev/source/Lib/TLibCommon
Files:
53 edited

Legend:

Unmodified
Added
Removed
  • branches/SHM-5.0-dev/source/Lib/TLibCommon/AccessUnit.h

    r313 r593  
    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/SHM-5.0-dev/source/Lib/TLibCommon/CommonDef.h

    r585 r593  
    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 *
     
    4040
    4141#include <algorithm>
     42
    4243#if _MSC_VER > 1000
    4344// disable "signed and unsigned mismatch"
     
    5758#if SVC_EXTENSION
    5859#include <vector>
    59 #define NV_VERSION        "5.0 (HM-12.1)"                 ///< Current software version
     60#define NV_VERSION        "5.0 (HM-13.0)"                 ///< Current software version
    6061#else
    61 #define NV_VERSION        "12.1"                ///< Current software version
     62#define NV_VERSION        "13.0"                ///< Current software version
    6263#endif
    6364
  • branches/SHM-5.0-dev/source/Lib/TLibCommon/ContextModel.cpp

    r313 r593  
    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/SHM-5.0-dev/source/Lib/TLibCommon/ContextModel.h

    r313 r593  
    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/SHM-5.0-dev/source/Lib/TLibCommon/ContextModel3DBuffer.cpp

    r313 r593  
    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/SHM-5.0-dev/source/Lib/TLibCommon/ContextModel3DBuffer.h

    r313 r593  
    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/SHM-5.0-dev/source/Lib/TLibCommon/ContextTables.h

    r345 r593  
    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
     
    146143INIT_PART_SIZE[3][NUM_PART_SIZE_CTX] = 
    147144{
    148   { 154,  139,  CNU,  CNU, },
    149   { 154,  139,  CNU,  CNU, },
    150   { 184,  CNU,  CNU,  CNU, },
    151 };
    152 
    153 static const UChar
    154 INIT_CU_AMP_POS[3][NUM_CU_AMP_CTX] = 
    155 {
    156   { 154, },
    157   { 154, },
    158   { CNU, },
     145  { 154,  139,  154,  154 },
     146  { 154,  139,  154,  154 },
     147  { 184,  CNU,  CNU,  CNU },
    159148};
    160149
     
    218207INIT_QT_CBF[3][2*NUM_QT_CBF_CTX] = 
    219208{
    220   { 153,  111,  CNU,  CNU,  CNU,  149,   92,  167,  CNU,  CNU, },
    221   { 153,  111,  CNU,  CNU,  CNU,  149,  107,  167,  CNU,  CNU, },
    222   { 111,  141,  CNU,  CNU,  CNU,   94,  138,  182,  CNU,  CNU, },
     209  { 153,  111,  CNU,  CNU,   149,   92,  167,  154 },
     210  { 153,  111,  CNU,  CNU,   149,  107,  167,  154 },
     211  { 111,  141,  CNU,  CNU,    94,  138,  182,  154 },
    223212};
    224213
     
    286275INIT_MVP_IDX[3][NUM_MVP_IDX_CTX] = 
    287276{
    288   { 168,  CNU, },
    289   { 168,  CNU, },
    290   { CNU,  CNU, },
     277  { 168 },
     278  { 168 },
     279  { CNU },
    291280};
    292281
     
    302291INIT_SAO_TYPE_IDX[3][NUM_SAO_TYPE_IDX_CTX] =
    303292{
    304 #if FIX827
    305293  { 160, },
    306294  { 185, },
    307295  { 200, },
    308 #else
    309   { 200, },
    310   { 185, },
    311   { 160, },
    312 #endif
    313296};
    314297
     
    316299INIT_TRANS_SUBDIV_FLAG[3][NUM_TRANS_SUBDIV_FLAG_CTX] =
    317300{
    318 #if FIX712
    319301  { 224,  167,  122, },
    320302  { 124,  138,   94, },
    321303  { 153,  138,  138, },
    322 #else
    323   { 153,  138,  138, },
    324   { 124,  138,   94, },
    325   { 224,  167,  122, },
    326 #endif
    327304};
    328305
  • branches/SHM-5.0-dev/source/Lib/TLibCommon/NAL.h

    r540 r593  
    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/SHM-5.0-dev/source/Lib/TLibCommon/SEI.cpp

    r583 r593  
    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/SHM-5.0-dev/source/Lib/TLibCommon/SEI.h

    r583 r593  
    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/SHM-5.0-dev/source/Lib/TLibCommon/TComBitCounter.h

    r313 r593  
    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/SHM-5.0-dev/source/Lib/TLibCommon/TComBitStream.cpp

    r313 r593  
    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/SHM-5.0-dev/source/Lib/TLibCommon/TComBitStream.h

    r313 r593  
    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/SHM-5.0-dev/source/Lib/TLibCommon/TComCABACTables.cpp

    r313 r593  
    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/SHM-5.0-dev/source/Lib/TLibCommon/TComCABACTables.h

    r313 r593  
    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/SHM-5.0-dev/source/Lib/TLibCommon/TComDataCU.cpp

    r562 r593  
    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 *
     
    309309  }
    310310}
    311 #if !HM_CLEANUP_SAO
    312 const NDBFBlockInfo& NDBFBlockInfo::operator= (const NDBFBlockInfo& src)
    313 {
    314   this->tileID = src.tileID;
    315   this->sliceID= src.sliceID;
    316   this->startSU= src.startSU;
    317   this->endSU  = src.endSU;
    318   this->widthSU= src.widthSU;
    319   this->heightSU=src.heightSU;
    320   this->posX   = src.posX;
    321   this->posY   = src.posY;
    322   this->width  = src.width;
    323   this->height = src.height;
    324   ::memcpy(this->isBorderAvailable, src.isBorderAvailable, sizeof(Bool)*((Int)NUM_SGU_BORDER));
    325   this->allBordersAvailable = src.allBordersAvailable;
    326 
    327   return *this;
    328 }
    329 
    330 #endif
     311
    331312// ====================================================================================================================
    332313// Public member functions
     
    547528*- set last-coded qp value according to input last-coded qp
    548529*/
    549 Void TComDataCU::initEstData( UInt uiDepth, Int qp )
     530Void TComDataCU::initEstData( UInt uiDepth, Int qp, Bool bTransquantBypass )
    550531{
    551532  m_dTotalCost         = MAX_DOUBLE;
     
    575556      m_pePartSize[ui] = SIZE_NONE;
    576557      m_pePredMode[ui] = MODE_NONE;
    577       m_CUTransquantBypass[ui] = false;
     558      m_CUTransquantBypass[ui] = bTransquantBypass;
    578559      m_pbIPCMFlag[ui] = 0;
    579560      m_phQP[ui] = qp;
     
    25502531  TComDataCU* pcCULeft = 0;
    25512532  pcCULeft = getPULeft( uiLeftPartIdx, uiPartIdxLB );
    2552 
    25532533  Bool isAvailableA1 = pcCULeft &&
    25542534  pcCULeft->isDiffMER(xP -1, yP+nPSH-1, xP, yP) &&
     
    25822562  TComDataCU* pcCUAbove = 0;
    25832563  pcCUAbove = getPUAbove( uiAbovePartIdx, uiPartIdxRT );
    2584 
    25852564  Bool isAvailableB1 = pcCUAbove &&
    25862565  pcCUAbove->isDiffMER(xP+nPSW-1, yP-1, xP, yP) &&
     
    26142593  TComDataCU* pcCUAboveRight = 0;
    26152594  pcCUAboveRight = getPUAboveRight( uiAboveRightPartIdx, uiPartIdxRT );
    2616 
    26172595  Bool isAvailableB0 = pcCUAboveRight &&
    26182596  pcCUAboveRight->isDiffMER(xP+nPSW, yP-1, xP, yP) &&
     
    26452623  TComDataCU* pcCULeftBottom = 0;
    26462624  pcCULeftBottom = this->getPUBelowLeft( uiLeftBottomPartIdx, uiPartIdxLB );
    2647 
    26482625  Bool isAvailableA0 = pcCULeftBottom &&
    26492626  pcCULeftBottom->isDiffMER(xP-1, yP+nPSH, xP, yP) &&
     
    26712648    return;
    26722649  }
    2673 
    26742650  // above left
    26752651  if( iCount < 4 )
     
    26782654    TComDataCU* pcCUAboveLeft = 0;
    26792655    pcCUAboveLeft = getPUAboveLeft( uiAboveLeftPartIdx, uiAbsPartAddr );
    2680 
    26812656    Bool isAvailableB2 = pcCUAboveLeft &&
    26822657    pcCUAboveLeft->isDiffMER(xP-1, yP-1, xP, yP) &&
     
    30132988    }
    30142989  }
     2990 
    30152991  // Above predictor search
    30162992  bAdded = xAddMVPCand( pInfo, eRefPicList, iRefIdx, uiPartIdxRT, MD_ABOVE_RIGHT);
     
    30253001    xAddMVPCand( pInfo, eRefPicList, iRefIdx, uiPartIdxLT, MD_ABOVE_LEFT);
    30263002  }
    3027   bAdded = bAddedSmvp;
    3028   if (pInfo->iN==2) bAdded = true;
    3029 
    3030   if(!bAdded)
     3003
     3004  if (!bAddedSmvp)
    30313005  {
    30323006    bAdded = xAddMVPCandOrder( pInfo, eRefPicList, iRefIdx, uiPartIdxRT, MD_ABOVE_RIGHT);
     
    36263600  return getPic()->getPicSym()->getInverseCUOrderMap(m_uiCUAddr)*(1<<(m_pcSlice->getSPS()->getMaxCUDepth()<<1))+m_uiAbsIdxInLCU;
    36273601}
    3628 #if !HM_CLEANUP_SAO
    3629 /** Set neighboring blocks availabilities for non-deblocked filtering
    3630  * \param numLCUInPicWidth number of LCUs in picture width
    3631  * \param numLCUInPicHeight number of LCUs in picture height
    3632  * \param numSUInLCUWidth number of SUs in LCU width
    3633  * \param numSUInLCUHeight number of SUs in LCU height
    3634  * \param picWidth picture width
    3635  * \param picHeight picture height
    3636  * \param bIndependentSliceBoundaryEnabled true for independent slice boundary enabled
    3637  * \param bTopTileBoundary true means that top boundary coincides tile boundary
    3638  * \param bDownTileBoundary true means that bottom boundary coincides tile boundary
    3639  * \param bLeftTileBoundary true means that left boundary coincides tile boundary
    3640  * \param bRightTileBoundary true means that right boundary coincides tile boundary
    3641  * \param bIndependentTileBoundaryEnabled true for independent tile boundary enabled
    3642  */
    3643 Void TComDataCU::setNDBFilterBlockBorderAvailability(UInt numLCUInPicWidth, UInt /*numLCUInPicHeight*/, UInt numSUInLCUWidth, UInt numSUInLCUHeight, UInt picWidth, UInt picHeight
    3644                                                     ,std::vector<Bool>& LFCrossSliceBoundary
    3645                                                     ,Bool bTopTileBoundary, Bool bDownTileBoundary, Bool bLeftTileBoundary, Bool bRightTileBoundary
    3646                                                     ,Bool bIndependentTileBoundaryEnabled)
    3647 {
    3648   UInt numSUInLCU = numSUInLCUWidth*numSUInLCUHeight;
    3649   Int* pSliceIDMapLCU = m_piSliceSUMap;
    3650   Bool onlyOneSliceInPic = ((Int)LFCrossSliceBoundary.size() == 1);
    3651   UInt uiLPelX, uiTPelY;
    3652   UInt width, height;
    3653   Bool bPicRBoundary, bPicBBoundary, bPicTBoundary, bPicLBoundary;
    3654   Bool bLCURBoundary= false, bLCUBBoundary= false, bLCUTBoundary= false, bLCULBoundary= false;
    3655   Bool* pbAvailBorder;
    3656   Bool* pbAvail;
    3657   UInt rTLSU, rBRSU, widthSU, heightSU;
    3658   UInt zRefSU;
    3659   Int* pRefID;
    3660   Int* pRefMapLCU;
    3661   UInt rTRefSU= 0, rBRefSU= 0, rLRefSU= 0, rRRefSU= 0;
    3662   Int* pRRefMapLCU= NULL;
    3663   Int* pLRefMapLCU= NULL;
    3664   Int* pTRefMapLCU= NULL;
    3665   Int* pBRefMapLCU= NULL;
    3666   Int  sliceID;
    3667   UInt numSGU = (UInt)m_vNDFBlock.size();
    3668 
    3669   for(Int i=0; i< numSGU; i++)
    3670   {
    3671     NDBFBlockInfo& rSGU = m_vNDFBlock[i];
    3672 
    3673     sliceID = rSGU.sliceID;
    3674     uiLPelX = rSGU.posX;
    3675     uiTPelY = rSGU.posY;
    3676     width   = rSGU.width;
    3677     height  = rSGU.height;
    3678     rTLSU     = g_auiZscanToRaster[ rSGU.startSU ];
    3679     rBRSU     = g_auiZscanToRaster[ rSGU.endSU   ];
    3680     widthSU   = rSGU.widthSU;
    3681     heightSU  = rSGU.heightSU;
    3682 
    3683     pbAvailBorder = rSGU.isBorderAvailable;
    3684 
    3685     bPicTBoundary= (uiTPelY == 0                       )?(true):(false);
    3686     bPicLBoundary= (uiLPelX == 0                       )?(true):(false);
    3687     bPicRBoundary= (!(uiLPelX+ width < picWidth )  )?(true):(false);
    3688     bPicBBoundary= (!(uiTPelY + height < picHeight))?(true):(false);
    3689 
    3690     bLCULBoundary = (rTLSU % numSUInLCUWidth == 0)?(true):(false);
    3691     bLCURBoundary = ( (rTLSU+ widthSU) % numSUInLCUWidth == 0)?(true):(false);
    3692     bLCUTBoundary = ( (UInt)(rTLSU / numSUInLCUWidth)== 0)?(true):(false);
    3693     bLCUBBoundary = ( (UInt)(rBRSU / numSUInLCUWidth) == (numSUInLCUHeight-1) )?(true):(false);
    3694 
    3695     //       SGU_L
    3696     pbAvail = &(pbAvailBorder[SGU_L]);
    3697     if(bPicLBoundary)
    3698     {
    3699       *pbAvail = false;
    3700     }
    3701     else if (onlyOneSliceInPic)
    3702     {
    3703       *pbAvail = true;
    3704     }
    3705     else
    3706     {
    3707       //      bLCULBoundary = (rTLSU % uiNumSUInLCUWidth == 0)?(true):(false);
    3708       if(bLCULBoundary)
    3709       {
    3710         rLRefSU     = rTLSU + numSUInLCUWidth -1;
    3711         zRefSU      = g_auiRasterToZscan[rLRefSU];
    3712         pRefMapLCU = pLRefMapLCU= (pSliceIDMapLCU - numSUInLCU);
    3713       }
    3714       else
    3715       {
    3716         zRefSU   = g_auiRasterToZscan[rTLSU - 1];
    3717         pRefMapLCU  = pSliceIDMapLCU;
    3718       }
    3719       pRefID = pRefMapLCU + zRefSU;
    3720       *pbAvail = (*pRefID == sliceID)?(true):((*pRefID > sliceID)?(LFCrossSliceBoundary[*pRefID]):(LFCrossSliceBoundary[sliceID]));
    3721     }
    3722 
    3723     //       SGU_R
    3724     pbAvail = &(pbAvailBorder[SGU_R]);
    3725     if(bPicRBoundary)
    3726     {
    3727       *pbAvail = false;
    3728     }
    3729     else if (onlyOneSliceInPic)
    3730     {
    3731       *pbAvail = true;
    3732     }
    3733     else
    3734     {
    3735       //       bLCURBoundary = ( (rTLSU+ uiWidthSU) % uiNumSUInLCUWidth == 0)?(true):(false);
    3736       if(bLCURBoundary)
    3737       {
    3738         rRRefSU      = rTLSU + widthSU - numSUInLCUWidth;
    3739         zRefSU       = g_auiRasterToZscan[rRRefSU];
    3740         pRefMapLCU  = pRRefMapLCU= (pSliceIDMapLCU + numSUInLCU);
    3741       }
    3742       else
    3743       {
    3744         zRefSU       = g_auiRasterToZscan[rTLSU + widthSU];
    3745         pRefMapLCU  = pSliceIDMapLCU;
    3746       }
    3747       pRefID = pRefMapLCU + zRefSU;
    3748       *pbAvail = (*pRefID == sliceID)?(true):((*pRefID > sliceID)?(LFCrossSliceBoundary[*pRefID]):(LFCrossSliceBoundary[sliceID]));
    3749     }
    3750 
    3751     //       SGU_T
    3752     pbAvail = &(pbAvailBorder[SGU_T]);
    3753     if(bPicTBoundary)
    3754     {
    3755       *pbAvail = false;
    3756     }
    3757     else if (onlyOneSliceInPic)
    3758     {
    3759       *pbAvail = true;
    3760     }
    3761     else
    3762     {
    3763       //      bLCUTBoundary = ( (UInt)(rTLSU / uiNumSUInLCUWidth)== 0)?(true):(false);
    3764       if(bLCUTBoundary)
    3765       {
    3766         rTRefSU      = numSUInLCU - (numSUInLCUWidth - rTLSU);
    3767         zRefSU       = g_auiRasterToZscan[rTRefSU];
    3768         pRefMapLCU  = pTRefMapLCU= (pSliceIDMapLCU - (numLCUInPicWidth*numSUInLCU));
    3769       }
    3770       else
    3771       {
    3772         zRefSU       = g_auiRasterToZscan[rTLSU - numSUInLCUWidth];
    3773         pRefMapLCU  = pSliceIDMapLCU;
    3774       }
    3775       pRefID = pRefMapLCU + zRefSU;
    3776       *pbAvail = (*pRefID == sliceID)?(true):((*pRefID > sliceID)?(LFCrossSliceBoundary[*pRefID]):(LFCrossSliceBoundary[sliceID]));
    3777     }
    3778 
    3779     //       SGU_B
    3780     pbAvail = &(pbAvailBorder[SGU_B]);
    3781     if(bPicBBoundary)
    3782     {
    3783       *pbAvail = false;
    3784     }
    3785     else if (onlyOneSliceInPic)
    3786     {
    3787       *pbAvail = true;
    3788     }
    3789     else
    3790     {
    3791       //      bLCUBBoundary = ( (UInt)(rBRSU / uiNumSUInLCUWidth) == (uiNumSUInLCUHeight-1) )?(true):(false);
    3792       if(bLCUBBoundary)
    3793       {
    3794         rBRefSU      = rTLSU % numSUInLCUWidth;
    3795         zRefSU       = g_auiRasterToZscan[rBRefSU];
    3796         pRefMapLCU  = pBRefMapLCU= (pSliceIDMapLCU + (numLCUInPicWidth*numSUInLCU));
    3797       }
    3798       else
    3799       {
    3800         zRefSU       = g_auiRasterToZscan[rTLSU + (heightSU*numSUInLCUWidth)];
    3801         pRefMapLCU  = pSliceIDMapLCU;
    3802       }
    3803       pRefID = pRefMapLCU + zRefSU;
    3804       *pbAvail = (*pRefID == sliceID)?(true):((*pRefID > sliceID)?(LFCrossSliceBoundary[*pRefID]):(LFCrossSliceBoundary[sliceID]));
    3805     }
    3806 
    3807     //       SGU_TL
    3808     pbAvail = &(pbAvailBorder[SGU_TL]);
    3809     if(bPicTBoundary || bPicLBoundary)
    3810     {
    3811       *pbAvail = false;
    3812     }
    3813     else if (onlyOneSliceInPic)
    3814     {
    3815       *pbAvail = true;
    3816     }
    3817     else
    3818     {
    3819       if(bLCUTBoundary && bLCULBoundary)
    3820       {
    3821         zRefSU       = numSUInLCU -1;
    3822         pRefMapLCU  = pSliceIDMapLCU - ( (numLCUInPicWidth+1)*numSUInLCU);
    3823       }
    3824       else if(bLCUTBoundary)
    3825       {
    3826         zRefSU       = g_auiRasterToZscan[ rTRefSU- 1];
    3827         pRefMapLCU  = pTRefMapLCU;
    3828       }
    3829       else if(bLCULBoundary)
    3830       {
    3831         zRefSU       = g_auiRasterToZscan[ rLRefSU- numSUInLCUWidth ];
    3832         pRefMapLCU  = pLRefMapLCU;
    3833       }
    3834       else //inside LCU
    3835       {
    3836         zRefSU       = g_auiRasterToZscan[ rTLSU - numSUInLCUWidth -1];
    3837         pRefMapLCU  = pSliceIDMapLCU;
    3838       }
    3839       pRefID = pRefMapLCU + zRefSU;
    3840       *pbAvail = (*pRefID == sliceID)?(true):((*pRefID > sliceID)?(LFCrossSliceBoundary[*pRefID]):(LFCrossSliceBoundary[sliceID]));
    3841     }
    3842 
    3843     //       SGU_TR
    3844     pbAvail = &(pbAvailBorder[SGU_TR]);
    3845     if(bPicTBoundary || bPicRBoundary)
    3846     {
    3847       *pbAvail = false;
    3848     }
    3849     else if (onlyOneSliceInPic)
    3850     {
    3851       *pbAvail = true;
    3852     }
    3853     else
    3854     {
    3855       if(bLCUTBoundary && bLCURBoundary)
    3856       {
    3857         zRefSU      = g_auiRasterToZscan[numSUInLCU - numSUInLCUWidth];
    3858         pRefMapLCU  = pSliceIDMapLCU - ( (numLCUInPicWidth-1)*numSUInLCU);       
    3859       }
    3860       else if(bLCUTBoundary)
    3861       {
    3862         zRefSU       = g_auiRasterToZscan[ rTRefSU+ widthSU];
    3863         pRefMapLCU  = pTRefMapLCU;
    3864       }
    3865       else if(bLCURBoundary)
    3866       {
    3867         zRefSU       = g_auiRasterToZscan[ rRRefSU- numSUInLCUWidth ];
    3868         pRefMapLCU  = pRRefMapLCU;
    3869       }
    3870       else //inside LCU
    3871       {
    3872         zRefSU       = g_auiRasterToZscan[ rTLSU - numSUInLCUWidth +widthSU];
    3873         pRefMapLCU  = pSliceIDMapLCU;
    3874       }
    3875       pRefID = pRefMapLCU + zRefSU;
    3876       *pbAvail = (*pRefID == sliceID)?(true):((*pRefID > sliceID)?(LFCrossSliceBoundary[*pRefID]):(LFCrossSliceBoundary[sliceID]));
    3877     }
    3878 
    3879     //       SGU_BL
    3880     pbAvail = &(pbAvailBorder[SGU_BL]);
    3881     if(bPicBBoundary || bPicLBoundary)
    3882     {
    3883       *pbAvail = false;
    3884     }
    3885     else if (onlyOneSliceInPic)
    3886     {
    3887       *pbAvail = true;
    3888     }
    3889     else
    3890     {
    3891       if(bLCUBBoundary && bLCULBoundary)
    3892       {
    3893         zRefSU      = g_auiRasterToZscan[numSUInLCUWidth - 1];
    3894         pRefMapLCU  = pSliceIDMapLCU + ( (numLCUInPicWidth-1)*numSUInLCU);       
    3895       }
    3896       else if(bLCUBBoundary)
    3897       {
    3898         zRefSU       = g_auiRasterToZscan[ rBRefSU - 1];
    3899         pRefMapLCU  = pBRefMapLCU;
    3900       }
    3901       else if(bLCULBoundary)
    3902       {
    3903         zRefSU       = g_auiRasterToZscan[ rLRefSU+ heightSU*numSUInLCUWidth ];
    3904         pRefMapLCU  = pLRefMapLCU;
    3905       }
    3906       else //inside LCU
    3907       {
    3908         zRefSU       = g_auiRasterToZscan[ rTLSU + heightSU*numSUInLCUWidth -1];
    3909         pRefMapLCU  = pSliceIDMapLCU;
    3910       }
    3911       pRefID = pRefMapLCU + zRefSU;
    3912       *pbAvail = (*pRefID == sliceID)?(true):((*pRefID > sliceID)?(LFCrossSliceBoundary[*pRefID]):(LFCrossSliceBoundary[sliceID]));
    3913     }
    3914 
    3915     //       SGU_BR
    3916     pbAvail = &(pbAvailBorder[SGU_BR]);
    3917     if(bPicBBoundary || bPicRBoundary)
    3918     {
    3919       *pbAvail = false;
    3920     }
    3921     else if (onlyOneSliceInPic)
    3922     {
    3923       *pbAvail = true;
    3924     }
    3925     else
    3926     {
    3927       if(bLCUBBoundary && bLCURBoundary)
    3928       {
    3929         zRefSU = 0;
    3930         pRefMapLCU = pSliceIDMapLCU+ ( (numLCUInPicWidth+1)*numSUInLCU);
    3931       }
    3932       else if(bLCUBBoundary)
    3933       {
    3934         zRefSU      = g_auiRasterToZscan[ rBRefSU + widthSU];
    3935         pRefMapLCU = pBRefMapLCU;
    3936       }
    3937       else if(bLCURBoundary)
    3938       {
    3939         zRefSU      = g_auiRasterToZscan[ rRRefSU + (heightSU*numSUInLCUWidth)];
    3940         pRefMapLCU = pRRefMapLCU;
    3941       }
    3942       else //inside LCU
    3943       {
    3944         zRefSU      = g_auiRasterToZscan[ rTLSU + (heightSU*numSUInLCUWidth)+ widthSU];
    3945         pRefMapLCU = pSliceIDMapLCU;
    3946       }
    3947       pRefID = pRefMapLCU + zRefSU;
    3948       *pbAvail = (*pRefID == sliceID)?(true):((*pRefID > sliceID)?(LFCrossSliceBoundary[*pRefID]):(LFCrossSliceBoundary[sliceID]));
    3949     }
    3950 
    3951     if(bIndependentTileBoundaryEnabled)
    3952     {
    3953       //left LCU boundary
    3954       if(!bPicLBoundary && bLCULBoundary)
    3955       {
    3956         if(bLeftTileBoundary)
    3957         {
    3958           pbAvailBorder[SGU_L] = pbAvailBorder[SGU_TL] = pbAvailBorder[SGU_BL] = false;
    3959         }
    3960       }
    3961       //right LCU boundary
    3962       if(!bPicRBoundary && bLCURBoundary)
    3963       {
    3964         if(bRightTileBoundary)
    3965         {
    3966           pbAvailBorder[SGU_R] = pbAvailBorder[SGU_TR] = pbAvailBorder[SGU_BR] = false;
    3967         }
    3968       }
    3969       //top LCU boundary
    3970       if(!bPicTBoundary && bLCUTBoundary)
    3971       {
    3972         if(bTopTileBoundary)
    3973         {
    3974           pbAvailBorder[SGU_T] = pbAvailBorder[SGU_TL] = pbAvailBorder[SGU_TR] = false;
    3975         }
    3976       }
    3977       //down LCU boundary
    3978       if(!bPicBBoundary && bLCUBBoundary)
    3979       {
    3980         if(bDownTileBoundary)
    3981         {
    3982           pbAvailBorder[SGU_B] = pbAvailBorder[SGU_BL] = pbAvailBorder[SGU_BR] = false;
    3983         }
    3984       }
    3985     }
    3986     rSGU.allBordersAvailable = true;
    3987     for(Int b=0; b< NUM_SGU_BORDER; b++)
    3988     {
    3989       if(pbAvailBorder[b] == false)
    3990       {
    3991         rSGU.allBordersAvailable = false;
    3992         break;
    3993       }
    3994     }
    3995   }
    3996 }
    3997 
    3998 #endif
    39993602
    40003603#if SVC_EXTENSION
     
    40773680  rcMvFieldEnhance.setMvField( cMv, rcMvFieldBase.getRefIdx() );
    40783681}
    4079 #endif
     3682#endif //SVC_EXTENSION
    40803683//! \}
  • branches/SHM-5.0-dev/source/Lib/TLibCommon/TComDataCU.h

    r540 r593  
    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 *
     
    5555//! \{
    5656
    57 #if !HM_CLEANUP_SAO
    58 // ====================================================================================================================
    59 // Non-deblocking in-loop filter processing block data structure
    60 // ====================================================================================================================
    61 
    62 /// Non-deblocking filter processing block border tag
    63 enum NDBFBlockBorderTag
    64 {
    65   SGU_L = 0,
    66   SGU_R,
    67   SGU_T,
    68   SGU_B,
    69   SGU_TL,
    70   SGU_TR,
    71   SGU_BL,
    72   SGU_BR,
    73   NUM_SGU_BORDER
    74 };
    75 
    76 /// Non-deblocking filter processing block information
    77 struct NDBFBlockInfo
    78 {
    79   Int   tileID;   //!< tile ID
    80   Int   sliceID;  //!< slice ID
    81   UInt  startSU;  //!< starting SU z-scan address in LCU
    82   UInt  endSU;    //!< ending SU z-scan address in LCU
    83   UInt  widthSU;  //!< number of SUs in width
    84   UInt  heightSU; //!< number of SUs in height
    85   UInt  posX;     //!< top-left X coordinate in picture
    86   UInt  posY;     //!< top-left Y coordinate in picture
    87   UInt  width;    //!< number of pixels in width
    88   UInt  height;   //!< number of pixels in height
    89   Bool  isBorderAvailable[NUM_SGU_BORDER];  //!< the border availabilities
    90   Bool  allBordersAvailable;
    91 
    92   NDBFBlockInfo():tileID(0), sliceID(0), startSU(0), endSU(0) {} //!< constructor
    93   const NDBFBlockInfo& operator= (const NDBFBlockInfo& src);  //!< "=" operator
    94 };
    95 #endif
    96 
    97 
    9857// ====================================================================================================================
    9958// Class definition
     
    161120  Pel*          m_pcIPCMSampleCr;     ///< PCM sample buffer (Cr)
    162121
    163 #if !HM_CLEANUP_SAO
    164   Int*          m_piSliceSUMap;       ///< pointer of slice ID map
    165   std::vector<NDBFBlockInfo> m_vNDFBlock;
    166 #endif
    167122  // -------------------------------------------------------------------------------------------------------------------
    168123  // neighbour access variables
     
    241196 
    242197  Void          initCU                ( TComPic* pcPic, UInt uiCUAddr );
    243   Void          initEstData           ( UInt uiDepth, Int qp );
     198  Void          initEstData           ( UInt uiDepth, Int qp, Bool bTransquantBypass );
    244199  Void          initSubCU             ( TComDataCU* pcCU, UInt uiPartUnitIdx, UInt uiDepth, Int qp );
    245200  Void          setOutsideCUPart      ( UInt uiAbsPartIdx, UInt uiDepth );
     
    392347  Void          setIPCMFlagSubParts   (Bool bIpcmFlag, UInt uiAbsPartIdx, UInt uiDepth);
    393348
    394 #if !HM_CLEANUP_SAO
    395   /// get slice ID for SU
    396   Int           getSUSliceID          (UInt uiIdx)              {return m_piSliceSUMap[uiIdx];      }
    397 
    398   /// get the pointer of slice ID map
    399   Int*          getSliceSUMap         ()                        {return m_piSliceSUMap;             }
    400 
    401   /// set the pointer of slice ID map
    402   Void          setSliceSUMap         (Int *pi)                 {m_piSliceSUMap = pi;               }
    403 
    404   std::vector<NDBFBlockInfo>* getNDBFilterBlocks()      {return &m_vNDFBlock;}
    405   Void setNDBFilterBlockBorderAvailability(UInt numLCUInPicWidth, UInt numLCUInPicHeight, UInt numSUInLCUWidth, UInt numSUInLCUHeight, UInt picWidth, UInt picHeight
    406                                           ,std::vector<Bool>& LFCrossSliceBoundary
    407                                           ,Bool bTopTileBoundary, Bool bDownTileBoundary, Bool bLeftTileBoundary, Bool bRightTileBoundary
    408                                           ,Bool bIndependentTileBoundaryEnabled );
    409 #endif
    410349  // -------------------------------------------------------------------------------------------------------------------
    411350  // member functions for accessing partition information
     
    442381 
    443382  Void          compressMV            ();
    444  
    445 #if SVC_EXTENSION
    446   Void          setLayerId (UInt layerId) { m_layerId = layerId; }
    447   UInt          getLayerId ()               { return m_layerId; }
    448 #endif
    449383 
    450384  // -------------------------------------------------------------------------------------------------------------------
     
    490424  Void          deriveLeftBottomIdxGeneral    ( UInt uiAbsPartIdx, UInt uiPartIdx, UInt& ruiPartIdxLB );
    491425 
     426 
    492427  // -------------------------------------------------------------------------------------------------------------------
    493428  // member functions for modes
     
    497432  Bool          isSkipped ( UInt uiPartIdx );                                                     ///< SKIP (no residual)
    498433  Bool          isBipredRestriction( UInt puIdx );
    499 #if N0383_IL_CONSTRAINED_TILE_SETS_SEI
    500   Bool          isInterLayerReference(UChar uhInterDir, TComMvField& cMvFieldL0, TComMvField& cMvFieldL1);
    501 #endif
    502434
    503435  // -------------------------------------------------------------------------------------------------------------------
     
    525457
    526458#if SVC_EXTENSION
     459  Void          setLayerId (UInt layerId) { m_layerId = layerId; }
     460  UInt          getLayerId ()               { return m_layerId; }
     461#if N0383_IL_CONSTRAINED_TILE_SETS_SEI
     462  Bool          isInterLayerReference(UChar uhInterDir, TComMvField& cMvFieldL0, TComMvField& cMvFieldL1);
     463#endif
    527464#if FAST_INTRA_SHVC
    528465  Int           reduceSetOfIntraModes              (  UInt   uiAbsPartIdx, Int* uiIntraDirPred, Int &fullSetOfModes );
    529466#endif
    530 
    531467#if REF_IDX_ME_ZEROMV
    532468  Bool xCheckZeroMVILRMerge(UChar uhInterDir, TComMvField& cMvFieldL0, TComMvField& cMvFieldL1);
    533469  Bool xCheckZeroMVILRMvdL1Zero(Int iRefList, Int iRefIdx, Int MvpIdx);
    534470#endif
     471  TComDataCU*   getBaseColCU( UInt refLayerIdc, UInt uiCuAbsPartIdx, UInt &uiCUAddrBase, UInt &uiAbsPartIdxBase, Int iMotionMapping = 0 );
     472  TComDataCU*   getBaseColCU( UInt refLayerIdc, UInt uiPelX, UInt uiPelY, UInt &uiCUAddrBase, UInt &uiAbsPartIdxBase, Int iMotionMapping = 0 );
     473  Void          scaleBaseMV( UInt refLayerIdc, TComMvField& rcMvFieldEnhance, TComMvField& rcMvFieldBase );
    535474#endif
    536475
     
    546485  UInt          getCoefScanIdx(UInt uiAbsPartIdx, UInt uiWidth, Bool bIsLuma, Bool bIsIntra);
    547486
    548 #if SVC_EXTENSION
    549   TComDataCU*   getBaseColCU( UInt refLayerIdc, UInt uiCuAbsPartIdx, UInt &uiCUAddrBase, UInt &uiAbsPartIdxBase, Int iMotionMapping = 0 );
    550   TComDataCU*   getBaseColCU( UInt refLayerIdc, UInt uiPelX, UInt uiPelY, UInt &uiCUAddrBase, UInt &uiAbsPartIdxBase, Int iMotionMapping = 0 );
    551   Void          scaleBaseMV( UInt refLayerIdc, TComMvField& rcMvFieldEnhance, TComMvField& rcMvFieldBase );
    552 #endif
    553487};
    554488
  • branches/SHM-5.0-dev/source/Lib/TLibCommon/TComInterpolationFilter.cpp

    r313 r593  
    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/SHM-5.0-dev/source/Lib/TLibCommon/TComInterpolationFilter.h

    r313 r593  
    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/SHM-5.0-dev/source/Lib/TLibCommon/TComList.h

    r313 r593  
    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/SHM-5.0-dev/source/Lib/TLibCommon/TComLoopFilter.cpp

    r442 r593  
    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/SHM-5.0-dev/source/Lib/TLibCommon/TComLoopFilter.h

    r313 r593  
    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/SHM-5.0-dev/source/Lib/TLibCommon/TComMotionInfo.cpp

    r345 r593  
    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/SHM-5.0-dev/source/Lib/TLibCommon/TComMotionInfo.h

    r345 r593  
    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/SHM-5.0-dev/source/Lib/TLibCommon/TComMv.h

    r442 r593  
    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/SHM-5.0-dev/source/Lib/TLibCommon/TComPattern.cpp

    r313 r593  
    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/SHM-5.0-dev/source/Lib/TLibCommon/TComPattern.h

    r313 r593  
    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/SHM-5.0-dev/source/Lib/TLibCommon/TComPic.cpp

    r540 r593  
    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 *
     
    4848TComPic::TComPic()
    4949: m_uiTLayer                              (0)
    50 #if SVC_EXTENSION
    51 , m_layerId( 0 )
    52 #endif
    5350, m_bUsedByCurr                           (false)
    5451, m_bIsLongTerm                           (false)
     
    5956, m_bNeededForOutput                      (false)
    6057, m_uiCurrSliceIdx                        (0)
    61 #if !HM_CLEANUP_SAO
    62 , m_pSliceSUMap                           (NULL)
    63 , m_pbValidSlice                          (NULL)
    64 , m_sliceGranularityForNDBFilter          (0)
    65 , m_bIndependentSliceBoundaryForNDBFilter (false)
    66 , m_bIndependentTileBoundaryForNDBFilter  (false)
    67 , m_pNDBFilterYuvTmp                      (NULL)
    68 #endif
    6958, m_bCheckLTMSB                           (false)
     59#if SVC_EXTENSION
     60, m_layerId( 0 )
     61#endif
    7062{
    7163#if SVC_EXTENSION
     
    214206  }
    215207}
    216 #if HM_CLEANUP_SAO
     208
    217209Bool  TComPic::getSAOMergeAvailability(Int currAddr, Int mergeAddr)
    218210{
     
    221213  return (mergeCtbInSliceSeg && mergeCtbInTile);
    222214}
    223 #else
    224 /** Create non-deblocked filter information
    225  * \param pSliceStartAddress array for storing slice start addresses
    226  * \param numSlices number of slices in picture
    227  * \param sliceGranularityDepth slice granularity
    228  * \param bNDBFilterCrossSliceBoundary cross-slice-boundary in-loop filtering; true for "cross".
    229  * \param numTiles number of tiles in picture
    230  * \param bNDBFilterCrossTileBoundary cross-tile-boundary in-loop filtering; true for "cross".
    231  */
    232 Void TComPic::createNonDBFilterInfo(std::vector<Int> sliceStartAddress, Int sliceGranularityDepth
    233                                     ,std::vector<Bool>* LFCrossSliceBoundary
    234                                     ,Int numTiles
    235                                     ,Bool bNDBFilterCrossTileBoundary)
    236 {
    237   UInt maxNumSUInLCU = getNumPartInCU();
    238   UInt numLCUInPic   = getNumCUsInFrame();
    239 #if REPN_FORMAT_IN_VPS
    240   UInt picWidth      = getSlice(0)->getPicWidthInLumaSamples();
    241   UInt picHeight     = getSlice(0)->getPicHeightInLumaSamples();
    242 #else
    243   UInt picWidth      = getSlice(0)->getSPS()->getPicWidthInLumaSamples();
    244   UInt picHeight     = getSlice(0)->getSPS()->getPicHeightInLumaSamples();
    245 #endif
    246   Int  numLCUsInPicWidth = getFrameWidthInCU();
    247   Int  numLCUsInPicHeight= getFrameHeightInCU();
    248   UInt maxNumSUInLCUWidth = getNumPartInWidth();
    249   UInt maxNumSUInLCUHeight= getNumPartInHeight();
    250   Int  numSlices = (Int) sliceStartAddress.size() - 1;
    251   m_bIndependentSliceBoundaryForNDBFilter = false;
    252   if(numSlices > 1)
    253   {
    254     for(Int s=0; s< numSlices; s++)
    255     {
    256       if((*LFCrossSliceBoundary)[s] == false)
    257       {
    258         m_bIndependentSliceBoundaryForNDBFilter = true;
    259       }
    260     }
    261   }
    262   m_sliceGranularityForNDBFilter = sliceGranularityDepth;
    263   m_bIndependentTileBoundaryForNDBFilter  = (bNDBFilterCrossTileBoundary)?(false) :((numTiles > 1)?(true):(false));
    264 
    265   m_pbValidSlice = new Bool[numSlices];
    266   for(Int s=0; s< numSlices; s++)
    267   {
    268     m_pbValidSlice[s] = true;
    269   }
    270   m_pSliceSUMap = new Int[maxNumSUInLCU * numLCUInPic];
    271 
    272   //initialization
    273   for(UInt i=0; i< (maxNumSUInLCU * numLCUInPic); i++ )
    274   {
    275     m_pSliceSUMap[i] = -1;
    276   }
    277   for( UInt CUAddr = 0; CUAddr < numLCUInPic ; CUAddr++ )
    278   {
    279     TComDataCU* pcCU = getCU( CUAddr );
    280     pcCU->setSliceSUMap(m_pSliceSUMap + (CUAddr* maxNumSUInLCU));
    281     pcCU->getNDBFilterBlocks()->clear();
    282   }
    283   m_vSliceCUDataLink.clear();
    284 
    285   m_vSliceCUDataLink.resize(numSlices);
    286 
    287   UInt startAddr, endAddr, firstCUInStartLCU, startLCU, endLCU, lastCUInEndLCU, uiAddr;
    288   UInt LPelX, TPelY, LCUX, LCUY;
    289   UInt currSU;
    290   UInt startSU, endSU;
    291 
    292   for(Int s=0; s< numSlices; s++)
    293   {
    294     //1st step: decide the real start address
    295     startAddr = sliceStartAddress[s];
    296     endAddr   = sliceStartAddress[s+1] -1;
    297 
    298     startLCU            = startAddr / maxNumSUInLCU;
    299     firstCUInStartLCU   = startAddr % maxNumSUInLCU;
    300 
    301     endLCU              = endAddr   / maxNumSUInLCU;
    302     lastCUInEndLCU      = endAddr   % maxNumSUInLCU;   
    303 
    304     uiAddr = m_apcPicSym->getCUOrderMap(startLCU);
    305 
    306     LCUX      = getCU(uiAddr)->getCUPelX();
    307     LCUY      = getCU(uiAddr)->getCUPelY();
    308     LPelX     = LCUX + g_auiRasterToPelX[ g_auiZscanToRaster[firstCUInStartLCU] ];
    309     TPelY     = LCUY + g_auiRasterToPelY[ g_auiZscanToRaster[firstCUInStartLCU] ];
    310     currSU    = firstCUInStartLCU;
    311 
    312     Bool bMoveToNextLCU = false;
    313     Bool bSliceInOneLCU = (startLCU == endLCU);
    314 
    315     while(!( LPelX < picWidth ) || !( TPelY < picHeight ))
    316     {
    317       currSU ++;
    318 
    319       if(bSliceInOneLCU)
    320       {
    321         if(currSU > lastCUInEndLCU)
    322         {
    323           m_pbValidSlice[s] = false;
    324           break;
    325         }
    326       }
    327 
    328       if(currSU >= maxNumSUInLCU )
    329       {
    330         bMoveToNextLCU = true;
    331         break;
    332       }
    333 
    334       LPelX = LCUX + g_auiRasterToPelX[ g_auiZscanToRaster[currSU] ];
    335       TPelY = LCUY + g_auiRasterToPelY[ g_auiZscanToRaster[currSU] ];
    336 
    337     }
    338 
    339 
    340     if(!m_pbValidSlice[s])
    341     {
    342       continue;
    343     }
    344 
    345     if(currSU != firstCUInStartLCU)
    346     {
    347       if(!bMoveToNextLCU)
    348       {
    349         firstCUInStartLCU = currSU;
    350       }
    351       else
    352       {
    353         startLCU++;
    354         firstCUInStartLCU = 0;
    355         assert( startLCU < getNumCUsInFrame());
    356       }
    357       assert(startLCU*maxNumSUInLCU + firstCUInStartLCU < endAddr);
    358     }
    359 
    360 
    361     //2nd step: assign NonDBFilterInfo to each processing block
    362     for(UInt i= startLCU; i <= endLCU; i++)
    363     {
    364       startSU = (i == startLCU)?(firstCUInStartLCU):(0);
    365       endSU   = (i == endLCU  )?(lastCUInEndLCU   ):(maxNumSUInLCU -1);
    366 
    367       uiAddr = m_apcPicSym->getCUOrderMap(i);
    368       Int iTileID= m_apcPicSym->getTileIdxMap(uiAddr);
    369 
    370       TComDataCU* pcCU = getCU(uiAddr);
    371       m_vSliceCUDataLink[s].push_back(pcCU);
    372 
    373       createNonDBFilterInfoLCU(iTileID, s, pcCU, startSU, endSU, m_sliceGranularityForNDBFilter, picWidth, picHeight);
    374     }
    375   }
    376 
    377   //step 3: border availability
    378   for(Int s=0; s< numSlices; s++)
    379   {
    380     if(!m_pbValidSlice[s])
    381     {
    382       continue;
    383     }
    384 
    385     for(Int i=0; i< m_vSliceCUDataLink[s].size(); i++)
    386     {
    387       TComDataCU* pcCU = m_vSliceCUDataLink[s][i];
    388       uiAddr = pcCU->getAddr();
    389 
    390       if(pcCU->getPic()==0)
    391       {
    392         continue;
    393       }
    394       Int iTileID= m_apcPicSym->getTileIdxMap(uiAddr);
    395       Bool bTopTileBoundary = false, bDownTileBoundary= false, bLeftTileBoundary= false, bRightTileBoundary= false;
    396 
    397       if(m_bIndependentTileBoundaryForNDBFilter)
    398       {
    399         //left
    400         if( uiAddr % numLCUsInPicWidth != 0)
    401         {
    402           bLeftTileBoundary = ( m_apcPicSym->getTileIdxMap(uiAddr -1) != iTileID )?true:false;
    403         }
    404         //right
    405         if( (uiAddr % numLCUsInPicWidth) != (numLCUsInPicWidth -1) )
    406         {
    407           bRightTileBoundary = ( m_apcPicSym->getTileIdxMap(uiAddr +1) != iTileID)?true:false;
    408         }
    409         //top
    410         if( uiAddr >= numLCUsInPicWidth)
    411         {
    412           bTopTileBoundary = (m_apcPicSym->getTileIdxMap(uiAddr - numLCUsInPicWidth) !=  iTileID )?true:false;
    413         }
    414         //down
    415         if( uiAddr + numLCUsInPicWidth < numLCUInPic )
    416         {
    417           bDownTileBoundary = (m_apcPicSym->getTileIdxMap(uiAddr + numLCUsInPicWidth) != iTileID)?true:false;
    418         }
    419 
    420       }
    421 
    422       pcCU->setNDBFilterBlockBorderAvailability(numLCUsInPicWidth, numLCUsInPicHeight, maxNumSUInLCUWidth, maxNumSUInLCUHeight,picWidth, picHeight
    423         , *LFCrossSliceBoundary
    424         ,bTopTileBoundary, bDownTileBoundary, bLeftTileBoundary, bRightTileBoundary
    425         ,m_bIndependentTileBoundaryForNDBFilter);
    426 
    427     }
    428 
    429   }
    430 
    431   if( m_bIndependentSliceBoundaryForNDBFilter || m_bIndependentTileBoundaryForNDBFilter)
    432   {
    433     m_pNDBFilterYuvTmp = new TComPicYuv();
    434 #if AUXILIARY_PICTURES
    435     m_pNDBFilterYuvTmp->create(picWidth, picHeight, getChromaFormat(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth);
    436 #else
    437     m_pNDBFilterYuvTmp->create(picWidth, picHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth);
    438 #endif
    439 
    440   }
    441 
    442 }
    443 
    444 /** Create non-deblocked filter information for LCU
    445  * \param tileID tile index
    446  * \param sliceID slice index
    447  * \param pcCU CU data pointer
    448  * \param startSU start SU index in LCU
    449  * \param endSU end SU index in LCU
    450  * \param sliceGranularyDepth slice granularity
    451  * \param picWidth picture width
    452  * \param picHeight picture height
    453  */
    454 Void TComPic::createNonDBFilterInfoLCU(Int tileID, Int sliceID, TComDataCU* pcCU, UInt startSU, UInt endSU, Int sliceGranularyDepth, UInt picWidth, UInt picHeight)
    455 {
    456   UInt LCUX          = pcCU->getCUPelX();
    457   UInt LCUY          = pcCU->getCUPelY();
    458   Int* pCUSliceMap    = pcCU->getSliceSUMap();
    459   UInt maxNumSUInLCU = getNumPartInCU();
    460   UInt maxNumSUInSGU = maxNumSUInLCU >> (sliceGranularyDepth << 1);
    461   UInt maxNumSUInLCUWidth = getNumPartInWidth();
    462   UInt LPelX, TPelY;
    463   UInt currSU;
    464 
    465 
    466   //get the number of valid NBFilterBLock
    467   currSU   = startSU;
    468   while(currSU <= endSU)
    469   {
    470     LPelX = LCUX + g_auiRasterToPelX[ g_auiZscanToRaster[currSU] ];
    471     TPelY = LCUY + g_auiRasterToPelY[ g_auiZscanToRaster[currSU] ];
    472 
    473     while(!( LPelX < picWidth ) || !( TPelY < picHeight ))
    474     {
    475       currSU += maxNumSUInSGU;
    476       if(currSU >= maxNumSUInLCU || currSU > endSU)
    477       {
    478         break;
    479       }
    480       LPelX = LCUX + g_auiRasterToPelX[ g_auiZscanToRaster[currSU] ];
    481       TPelY = LCUY + g_auiRasterToPelY[ g_auiZscanToRaster[currSU] ];
    482     }
    483 
    484     if(currSU >= maxNumSUInLCU || currSU > endSU)
    485     {
    486       break;
    487     }
    488 
    489     NDBFBlockInfo NDBFBlock;
    490 
    491     NDBFBlock.tileID  = tileID;
    492     NDBFBlock.sliceID = sliceID;
    493     NDBFBlock.posY    = TPelY;
    494     NDBFBlock.posX    = LPelX;
    495     NDBFBlock.startSU = currSU;
    496 
    497     UInt uiLastValidSU  = currSU;
    498     UInt uiIdx, uiLPelX_su, uiTPelY_su;
    499     for(uiIdx = currSU; uiIdx < currSU + maxNumSUInSGU; uiIdx++)
    500     {
    501       if(uiIdx > endSU)
    502       {
    503         break;       
    504       }
    505       uiLPelX_su   = LCUX + g_auiRasterToPelX[ g_auiZscanToRaster[uiIdx] ];
    506       uiTPelY_su   = LCUY + g_auiRasterToPelY[ g_auiZscanToRaster[uiIdx] ];
    507       if( !(uiLPelX_su < picWidth ) || !( uiTPelY_su < picHeight ))
    508       {
    509         continue;
    510       }
    511       pCUSliceMap[uiIdx] = sliceID;
    512       uiLastValidSU = uiIdx;
    513     }
    514     NDBFBlock.endSU = uiLastValidSU;
    515 
    516     UInt rTLSU = g_auiZscanToRaster[ NDBFBlock.startSU ];
    517     UInt rBRSU = g_auiZscanToRaster[ NDBFBlock.endSU   ];
    518     NDBFBlock.widthSU  = (rBRSU % maxNumSUInLCUWidth) - (rTLSU % maxNumSUInLCUWidth)+ 1;
    519     NDBFBlock.heightSU = (UInt)(rBRSU / maxNumSUInLCUWidth) - (UInt)(rTLSU / maxNumSUInLCUWidth)+ 1;
    520     NDBFBlock.width    = NDBFBlock.widthSU  * getMinCUWidth();
    521     NDBFBlock.height   = NDBFBlock.heightSU * getMinCUHeight();
    522 
    523     pcCU->getNDBFilterBlocks()->push_back(NDBFBlock);
    524 
    525     currSU += maxNumSUInSGU;
    526   }
    527 
    528 }
    529 
    530 /** destroy non-deblocked filter information for LCU
    531  */
    532 Void TComPic::destroyNonDBFilterInfo()
    533 {
    534   if(m_pbValidSlice != NULL)
    535   {
    536     delete[] m_pbValidSlice;
    537     m_pbValidSlice = NULL;
    538   }
    539 
    540   if(m_pSliceSUMap != NULL)
    541   {
    542     delete[] m_pSliceSUMap;
    543     m_pSliceSUMap = NULL;
    544   }
    545   for( UInt CUAddr = 0; CUAddr < getNumCUsInFrame() ; CUAddr++ )
    546   {
    547     TComDataCU* pcCU = getCU( CUAddr );
    548     pcCU->getNDBFilterBlocks()->clear();
    549   }
    550 
    551   if( m_bIndependentSliceBoundaryForNDBFilter || m_bIndependentTileBoundaryForNDBFilter)
    552   {
    553     m_pNDBFilterYuvTmp->destroy();
    554     delete m_pNDBFilterYuvTmp;
    555     m_pNDBFilterYuvTmp = NULL;
    556   }
    557 
    558 }
    559 #endif
    560215
    561216#if SVC_EXTENSION
  • branches/SHM-5.0-dev/source/Lib/TLibCommon/TComPic.h

    r540 r593  
    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 *
     
    6161private:
    6262  UInt                  m_uiTLayer;               //  Temporal layer
    63 #if SVC_EXTENSION
    64   UInt                  m_layerId;              //  Layer ID
    65 #endif
    6663  Bool                  m_bUsedByCurr;            //  Used by current picture
    6764  Bool                  m_bIsLongTerm;            //  IS long term picture
     
    7572  Bool                  m_bNeededForOutput;
    7673  UInt                  m_uiCurrSliceIdx;         // Index of current slice
    77 #if !HM_CLEANUP_SAO
    78   Int*                  m_pSliceSUMap;
    79   Bool*                 m_pbValidSlice;
    80   Int                   m_sliceGranularityForNDBFilter;
    81   Bool                  m_bIndependentSliceBoundaryForNDBFilter;
    82   Bool                  m_bIndependentTileBoundaryForNDBFilter;
    83   TComPicYuv*           m_pNDBFilterYuvTmp;    //!< temporary picture buffer when non-cross slice/tile boundary in-loop filtering is enabled
    84 #endif
    8574  Bool                  m_bCheckLTMSB;
    8675 
     
    9685  SEIMessages  m_SEIs; ///< Any SEI messages that have been received.  If !NULL we own the object.
    9786#if SVC_EXTENSION
     87  UInt                  m_layerId;              //  Layer ID
    9888  Bool                  m_bSpatialEnhLayer[MAX_LAYERS];       // whether current layer is a spatial enhancement layer,
    9989  TComPicYuv*           m_pcFullPelBaseRec[MAX_LAYERS];    // upsampled base layer recontruction for difference domain inter prediction
     
    125115  UInt          getTLayer()                { return m_uiTLayer;   }
    126116  Void          setTLayer( UInt uiTLayer ) { m_uiTLayer = uiTLayer; }
    127 #if SVC_EXTENSION
    128   Void          setLayerId (UInt layerId) { m_layerId = layerId; }
    129   UInt          getLayerId ()               { return m_layerId; }
    130   Bool          isSpatialEnhLayer(UInt refLayerIdc)             { return m_bSpatialEnhLayer[refLayerIdc]; }
    131   Void          setSpatialEnhLayerFlag (UInt refLayerIdc, Bool b) { m_bSpatialEnhLayer[refLayerIdc] = b; }
    132   Void          setFullPelBaseRec   (UInt refLayerIdc, TComPicYuv* p) { m_pcFullPelBaseRec[refLayerIdc] = p; }
    133   TComPicYuv*   getFullPelBaseRec   (UInt refLayerIdc)  { return  m_pcFullPelBaseRec[refLayerIdc];  }
    134 #endif
    135 #if REF_IDX_ME_ZEROMV || ENCODER_FAST_MODE || REF_IDX_MFM
    136   Bool          isILR( UInt currLayerId )   { return ( getIsLongTerm() && m_layerId < currLayerId ); }
    137 #endif
    138 
    139 #if REF_IDX_MFM
    140   Void          copyUpsampledMvField  ( UInt refLayerIdc, TComPic* pcPicBase );
    141   Void          initUpsampledMvField  ();
    142 #endif
    143 #if MFM_ENCCONSTRAINT
    144   Bool          checkSameRefInfo();
    145 #endif
    146 
    147117  Bool          getUsedByCurr()             { return m_bUsedByCurr; }
    148118  Void          setUsedByCurr( Bool bUsed ) { m_bUsedByCurr = bUsed; }
     
    178148 
    179149  Int           getStride()           { return m_apcPicYuv[1]->getStride(); }
    180 #if AUXILIARY_PICTURES
    181   ChromaFormat  getChromaFormat() const { return m_apcPicYuv[1]->getChromaFormat(); }
    182 #endif
    183150  Int           getCStride()          { return m_apcPicYuv[1]->getCStride(); }
    184151 
     
    201168  Window&       getDefDisplayWindow()   { return m_defaultDisplayWindow; }
    202169
    203 #if HM_CLEANUP_SAO
    204170  Bool          getSAOMergeAvailability(Int currAddr, Int mergeAddr);
    205 #else
    206   Void          createNonDBFilterInfo   (std::vector<Int> sliceStartAddress, Int sliceGranularityDepth
    207                                         ,std::vector<Bool>* LFCrossSliceBoundary
    208                                         ,Int  numTiles = 1
    209                                         ,Bool bNDBFilterCrossTileBoundary = true);
    210   Void          createNonDBFilterInfoLCU(Int tileID, Int sliceID, TComDataCU* pcCU, UInt startSU, UInt endSU, Int sliceGranularyDepth, UInt picWidth, UInt picHeight);
    211   Void          destroyNonDBFilterInfo();
    212 
    213   Bool          getValidSlice                                  (Int sliceID)  {return m_pbValidSlice[sliceID];}
    214   Bool          getIndependentSliceBoundaryForNDBFilter        ()             {return m_bIndependentSliceBoundaryForNDBFilter;}
    215   Bool          getIndependentTileBoundaryForNDBFilter         ()             {return m_bIndependentTileBoundaryForNDBFilter; }
    216   TComPicYuv*   getYuvPicBufferForIndependentBoundaryProcessing()             {return m_pNDBFilterYuvTmp;}
    217   std::vector<TComDataCU*>& getOneSliceCUDataForNDBFilter      (Int sliceID) { return m_vSliceCUDataLink[sliceID];}
    218 #endif
    219171
    220172  /* field coding parameters*/
     
    239191
    240192#if SVC_EXTENSION
     193  Void          setLayerId (UInt layerId) { m_layerId = layerId; }
     194  UInt          getLayerId ()               { return m_layerId; }
     195  Bool          isSpatialEnhLayer(UInt refLayerIdc)             { return m_bSpatialEnhLayer[refLayerIdc]; }
     196  Void          setSpatialEnhLayerFlag (UInt refLayerIdc, Bool b) { m_bSpatialEnhLayer[refLayerIdc] = b; }
     197  Void          setFullPelBaseRec   (UInt refLayerIdc, TComPicYuv* p) { m_pcFullPelBaseRec[refLayerIdc] = p; }
     198  TComPicYuv*   getFullPelBaseRec   (UInt refLayerIdc)  { return  m_pcFullPelBaseRec[refLayerIdc];  }
     199#if REF_IDX_ME_ZEROMV || ENCODER_FAST_MODE || REF_IDX_MFM
     200  Bool          isILR( UInt currLayerId )   { return ( getIsLongTerm() && m_layerId < currLayerId ); }
     201#endif
     202#if REF_IDX_MFM
     203  Void          copyUpsampledMvField  ( UInt refLayerIdc, TComPic* pcPicBase );
     204  Void          initUpsampledMvField  ();
     205#endif
     206#if MFM_ENCCONSTRAINT
     207  Bool          checkSameRefInfo();
     208#endif
     209#if AUXILIARY_PICTURES
     210  ChromaFormat  getChromaFormat() const { return m_apcPicYuv[1]->getChromaFormat(); }
     211#endif
    241212  Void  copyUpsampledPictureYuv(TComPicYuv*   pcPicYuvIn, TComPicYuv*   pcPicYuvOut);
    242213#if AVC_SYNTAX
  • branches/SHM-5.0-dev/source/Lib/TLibCommon/TComPicSym.cpp

    r540 r593  
    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 #if HM_CLEANUP_SAO
    7069,m_saoBlkParams(NULL)
    71 #endif
    7270{};
    7371
     
    131129  }
    132130
    133 #if HM_CLEANUP_SAO
    134131  m_saoBlkParams = new SAOBlkParam[m_uiNumCUsInFrame];
    135 #else
    136   m_saoParam = NULL;
    137 #endif
    138132}
    139133
     
    191185  m_puiInverseCUOrderMap = NULL;
    192186 
    193 #if HM_CLEANUP_SAO
    194187  if(m_saoBlkParams)
    195188  {
    196189    delete[] m_saoBlkParams; m_saoBlkParams = NULL;
    197190  }
    198 #else
    199   if (m_saoParam)
    200   {
    201     TComSampleAdaptiveOffset::freeSaoParam(m_saoParam);
    202     delete m_saoParam;
    203     m_saoParam = NULL;
    204   }
    205 #endif
    206191}
    207192
     
    347332}
    348333
    349 
    350 #if HM_CLEANUP_SAO
    351334Void TComPicSym::deriveLoopFilterBoundaryAvailibility(Int ctu,
    352335                                                      Bool& isLeftAvail,
     
    419402      if(ctuAboveRigtht != NULL)
    420403      {
    421         Int curSliceStartTS  = getCUOrderMap(ctuCurr->getSlice()->getSliceCurStartCUAddr()/m_uiNumPartitions);
    422         Int aboveRigthtSliceStartTS = getCUOrderMap(ctuAboveRigtht->getSlice()->getSliceCurStartCUAddr()/m_uiNumPartitions);
    423 
    424         isAboveRightAvail = (curSliceStartTS == aboveRigthtSliceStartTS)?(true):
     404        Int curSliceStartEncOrder  = ctuCurr->getSlice()->getSliceCurStartCUAddr();
     405        Int aboveRigthtSliceStartEncOrder = ctuAboveRigtht->getSlice()->getSliceCurStartCUAddr();
     406
     407        isAboveRightAvail = (curSliceStartEncOrder == aboveRigthtSliceStartEncOrder)?(true):
    425408          (
    426           (curSliceStartTS > aboveRigthtSliceStartTS)?(ctuCurr->getSlice()->getLFCrossSliceBoundaryFlag())
     409          (curSliceStartEncOrder > aboveRigthtSliceStartEncOrder)?(ctuCurr->getSlice()->getLFCrossSliceBoundaryFlag())
    427410          :(ctuAboveRigtht->getSlice()->getLFCrossSliceBoundaryFlag())
    428411          );         
     
    431414      if(ctuBelowLeft != NULL)
    432415      {
    433         Int curSliceStartTS       = getCUOrderMap(ctuCurr->getSlice()->getSliceCurStartCUAddr()/m_uiNumPartitions);
    434         Int belowLeftSliceStartTS = getCUOrderMap(ctuBelowLeft->getSlice()->getSliceCurStartCUAddr()/m_uiNumPartitions);
    435 
    436         isBelowLeftAvail = (curSliceStartTS == belowLeftSliceStartTS)?(true):
     416        Int curSliceStartEncOrder  = ctuCurr->getSlice()->getSliceCurStartCUAddr();
     417        Int belowLeftSliceStartEncOrder = ctuBelowLeft->getSlice()->getSliceCurStartCUAddr();
     418
     419        isBelowLeftAvail = (curSliceStartEncOrder == belowLeftSliceStartEncOrder)?(true):
    437420          (
    438           (curSliceStartTS > belowLeftSliceStartTS)?(ctuCurr->getSlice()->getLFCrossSliceBoundaryFlag())
     421          (curSliceStartEncOrder > belowLeftSliceStartEncOrder)?(ctuCurr->getSlice()->getLFCrossSliceBoundaryFlag())
    439422          :(ctuBelowLeft->getSlice()->getLFCrossSliceBoundaryFlag())
    440423          );
     
    456439
    457440}
    458 #else
    459 Void TComPicSym::allocSaoParam(TComSampleAdaptiveOffset *sao)
    460 {
    461   m_saoParam = new SAOParam;
    462   sao->allocSaoParam(m_saoParam);
    463 }
    464 #endif
    465441
    466442TComTile::TComTile()
  • branches/SHM-5.0-dev/source/Lib/TLibCommon/TComPicSym.h

    r540 r593  
    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 *
     
    105105  UInt*         m_puiCUOrderMap;       //the map of LCU raster scan address relative to LCU encoding order
    106106  UInt*         m_puiTileIdxMap;       //the map of the tile index relative to LCU raster scan address
     107  UInt*         m_puiInverseCUOrderMap;
     108
     109  SAOBlkParam *m_saoBlkParams;
     110
     111#if SVC_EXTENSION
    107112#if N0383_IL_CONSTRAINED_TILE_SETS_SEI
    108113  Int*          m_piTileSetIdxMap;     //the map of the tile set index relative to LCU raster scan address
     
    110115  Bool*         m_pbSkippedTileSetFlag;
    111116#endif
    112   UInt*         m_puiInverseCUOrderMap;
    113 
    114 #if HM_CLEANUP_SAO
    115   SAOBlkParam *m_saoBlkParams;
    116 #else
    117   SAOParam *m_saoParam;
    118117#endif
    119118
     
    130129  UInt        getNumberOfCUsInFrame()   { return m_uiNumCUsInFrame;  }
    131130  TComDataCU*&  getCU( UInt uiCUAddr )  { return m_apcTComDataCU[uiCUAddr];     }
    132  
    133 #if LAYER_CTB
    134   UInt        getMaxCUWidth()           { return m_uiMaxCUWidth;                }
    135   UInt        getMaxCUHeight()          { return m_uiMaxCUHeight;               }
    136 #endif
    137 
    138 #if AVC_SYNTAX
    139   UInt        getMaxCUWidth()           { return m_uiMaxCUWidth;                }
    140   UInt        getMaxCUHeight()          { return m_uiMaxCUHeight;               }
    141   UInt        getMaxDepth()             { return m_uhTotalDepth;               }
    142 #endif
    143131 
    144132  Void        setSlice(TComSlice* p, UInt i) { m_apcTComSlice[i] = p;           }
     
    158146  UInt         getCUOrderMap( Int encCUOrder )                       { return *(m_puiCUOrderMap + (encCUOrder>=m_uiNumCUsInFrame ? m_uiNumCUsInFrame : encCUOrder)); }
    159147  UInt         getTileIdxMap( Int i )                                { return *(m_puiTileIdxMap + i); }
     148  Void         setInverseCUOrderMap( Int cuAddr, Int encCUOrder )    { *(m_puiInverseCUOrderMap + cuAddr) = encCUOrder; }
     149  UInt         getInverseCUOrderMap( Int cuAddr )                    { return *(m_puiInverseCUOrderMap + (cuAddr>=m_uiNumCUsInFrame ? m_uiNumCUsInFrame : cuAddr)); }
     150  UInt         getPicSCUEncOrder( UInt SCUAddr );
     151  UInt         getPicSCUAddr( UInt SCUEncOrder );
     152  Void         xCreateTComTileArray();
     153  Void         xInitTiles();
     154  UInt         xCalculateNxtCUAddr( UInt uiCurrCUAddr );
     155  SAOBlkParam* getSAOBlkParam() { return m_saoBlkParams;}
     156  Void deriveLoopFilterBoundaryAvailibility(Int ctu, Bool& isLeftAvail,Bool& isRightAvail,Bool& isAboveAvail,Bool& isBelowAvail,Bool& isAboveLeftAvail,Bool& isAboveRightAvail,Bool& isBelowLeftAvail,Bool& isBelowRightAvail);
     157
     158#if SVC_EXTENSION
     159#if LAYER_CTB
     160  UInt        getMaxCUWidth()           { return m_uiMaxCUWidth;                }
     161  UInt        getMaxCUHeight()          { return m_uiMaxCUHeight;               }
     162#endif
     163#if AVC_SYNTAX
     164  UInt        getMaxCUWidth()           { return m_uiMaxCUWidth;                }
     165  UInt        getMaxCUHeight()          { return m_uiMaxCUHeight;               }
     166  UInt        getMaxDepth()             { return m_uhTotalDepth;               }
     167#endif
    160168#if N0383_IL_CONSTRAINED_TILE_SETS_SEI
    161169  Void         setTileSetIdxMap( Int i, Int tileSetIdx, UChar setType, Bool skipFlag )
     
    169177  Bool         getSkippedTileSetFlag( Int i )                        { return *(m_pbSkippedTileSetFlag + i); }
    170178#endif
    171   Void         setInverseCUOrderMap( Int cuAddr, Int encCUOrder )    { *(m_puiInverseCUOrderMap + cuAddr) = encCUOrder; }
    172   UInt         getInverseCUOrderMap( Int cuAddr )                    { return *(m_puiInverseCUOrderMap + (cuAddr>=m_uiNumCUsInFrame ? m_uiNumCUsInFrame : cuAddr)); }
    173   UInt         getPicSCUEncOrder( UInt SCUAddr );
    174   UInt         getPicSCUAddr( UInt SCUEncOrder );
    175   Void         xCreateTComTileArray();
    176   Void         xInitTiles();
    177   UInt         xCalculateNxtCUAddr( UInt uiCurrCUAddr );
    178 #if HM_CLEANUP_SAO
    179   SAOBlkParam* getSAOBlkParam() { return m_saoBlkParams;}
    180   Void deriveLoopFilterBoundaryAvailibility(Int ctu, Bool& isLeftAvail,Bool& isRightAvail,Bool& isAboveAvail,Bool& isBelowAvail,Bool& isAboveLeftAvail,Bool& isAboveRightAvail,Bool& isBelowLeftAvail,Bool& isBelowRightAvail);
    181 #else
    182   Void allocSaoParam(TComSampleAdaptiveOffset *sao);
    183   SAOParam *getSaoParam() { return m_saoParam; }
    184 #endif
    185 
    186 
     179#endif //SVC_EXTENSION
    187180};// END CLASS DEFINITION TComPicSym
    188181
  • branches/SHM-5.0-dev/source/Lib/TLibCommon/TComPicYuv.cpp

    r494 r593  
    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/SHM-5.0-dev/source/Lib/TLibCommon/TComPicYuv.h

    r494 r593  
    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 *
     
    7575  Int   m_iPicWidth;            ///< Width of picture
    7676  Int   m_iPicHeight;           ///< Height of picture
    77 #if AUXILIARY_PICTURES
    78   ChromaFormat m_chromaFormatIDC; ////< Chroma Format
    79 #endif
    8077 
    8178  Int   m_iCuWidth;             ///< Width of Coding Unit (CU)
     
    9188  Int   m_iChromaMarginY;
    9289 
     90  Bool  m_bIsBorderExtended;
     91
     92#if SVC_EXTENSION
     93#if AUXILIARY_PICTURES
     94  ChromaFormat m_chromaFormatIDC; ////< Chroma Format
     95#endif
    9396#if SVC_UPSAMPLING
    9497  Window  m_conformanceWindow;
    9598#endif
    96 
    9799#if M0040_ADAPTIVE_RESOLUTION_CHANGE
    98100  Bool    m_isReconstructed;
    99101#endif
    100 
    101   Bool  m_bIsBorderExtended;
     102#endif //SVC_EXTENSION
    102103 
    103104protected:
     
    136137  Int   getWidth    ()     { return  m_iPicWidth;    }
    137138  Int   getHeight   ()     { return  m_iPicHeight;   }
    138 #if AUXILIARY_PICTURES
    139   ChromaFormat  getChromaFormat   ()                     const { return m_chromaFormatIDC; }
    140 #endif
    141  
    142 #if SVC_EXTENSION
    143   Void   setHeight   ( Int iPicHeight )     { m_iPicHeight = iPicHeight; }
    144 #endif
    145139
    146140  Int   getStride   ()     { return (m_iPicWidth     ) + (m_iLumaMarginX  <<1); }
     
    172166  Pel*  getCrAddr   ( Int iCuAddr, Int uiAbsZorderIdx ) { return m_piPicOrgV + m_cuOffsetC[iCuAddr] + m_buOffsetC[g_auiZscanToRaster[uiAbsZorderIdx]]; }
    173167 
    174 #if SVC_UPSAMPLING
    175   Window& getConformanceWindow()                           { return  m_conformanceWindow;             }
    176   Void    setConformanceWindow(Window& conformanceWindow ) { m_conformanceWindow = conformanceWindow; }
    177 #endif
    178 
    179168  // ------------------------------------------------------------------------------------------------
    180169  //  Miscellaneous
     
    193182  Void  dump (Char* pFileName, Bool bAdd = false);
    194183
     184  // Set border extension flag
     185  Void  setBorderExtension(Bool b) { m_bIsBorderExtended = b; }
     186 
     187#if SVC_EXTENSION
     188  Void   setHeight   ( Int iPicHeight )     { m_iPicHeight = iPicHeight; }
     189#if SVC_UPSAMPLING
     190  Window& getConformanceWindow()                           { return  m_conformanceWindow;             }
     191  Void    setConformanceWindow(Window& conformanceWindow ) { m_conformanceWindow = conformanceWindow; }
     192#endif
    195193#if M0040_ADAPTIVE_RESOLUTION_CHANGE
    196194  Void  setReconstructed(Bool x) { m_isReconstructed = x;    }
    197195  Bool  isReconstructed()        { return m_isReconstructed; }
    198196#endif
    199 
    200197#if AUXILIARY_PICTURES
     198  ChromaFormat  getChromaFormat   ()                     const { return m_chromaFormatIDC; }
    201199  Void convertToMonochrome();
    202200#endif
    203 
    204   // Set border extension flag
    205   Void  setBorderExtension(Bool b) { m_bIsBorderExtended = b; }
     201#endif //SVC_EXTENSION
     202
    206203};// END CLASS DEFINITION TComPicYuv
    207204
  • branches/SHM-5.0-dev/source/Lib/TLibCommon/TComPicYuvMD5.cpp

    r313 r593  
    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/SHM-5.0-dev/source/Lib/TLibCommon/TComPrediction.cpp

    r494 r593  
    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 *
     
    408408}
    409409
     410
    410411Void TComPrediction::motionCompensation ( TComDataCU* pcCU, TComYuv* pcYuvPred, RefPicList eRefPicList, Int iPartIdx )
    411412{
  • branches/SHM-5.0-dev/source/Lib/TLibCommon/TComPrediction.h

    r494 r593  
    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/SHM-5.0-dev/source/Lib/TLibCommon/TComRdCost.cpp

    r540 r593  
    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 *
     
    410410    }
    411411  }
    412   else if ( ( (iWidth % 4) == 0 ) && ( (iHeight % 4) == 0 ) )
    413   {
     412  else
     413  {
     414    assert(iWidth % 4 == 0 && iHeight % 4 == 0);
     415   
    414416    for ( y=0; y<iHeight; y+= 4 )
    415417    {
     
    420422      pi0 += iStride0*4;
    421423      pi1 += iStride1*4;
    422     }
    423   }
    424   else
    425   {
    426     for ( y=0; y<iHeight; y+= 2 )
    427     {
    428       for ( x=0; x<iWidth; x+= 2 )
    429       {
    430         uiSum += xCalcHADs8x8( &pi0[x], &pi1[x], iStride0, iStride1, 1 );
    431       }
    432       pi0 += iStride0*2;
    433       pi1 += iStride1*2;
    434424    }
    435425  }
  • branches/SHM-5.0-dev/source/Lib/TLibCommon/TComRdCost.h

    r540 r593  
    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/SHM-5.0-dev/source/Lib/TLibCommon/TComRdCostWeightPrediction.cpp

    r313 r593  
    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/SHM-5.0-dev/source/Lib/TLibCommon/TComRdCostWeightPrediction.h

    r313 r593  
    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/SHM-5.0-dev/source/Lib/TLibCommon/TComRom.cpp

    r549 r593  
    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 *
     
    8686// Data structure related table & variable
    8787// ====================================================================================================================
    88 #if LAYER_CTB
    89 UInt g_auiLayerMaxCUWidth[MAX_LAYERS];
    90 UInt g_auiLayerMaxCUHeight[MAX_LAYERS];
    91 UInt g_auiLayerMaxCUDepth[MAX_LAYERS];
    92 UInt g_auiLayerAddCUDepth[MAX_LAYERS];
    93 UInt g_auiLayerZscanToRaster[MAX_LAYERS][ MAX_NUM_SPU_W*MAX_NUM_SPU_W ];
    94 UInt g_auiLayerRasterToZscan[MAX_LAYERS][ MAX_NUM_SPU_W*MAX_NUM_SPU_W ];
    95 UInt g_auiLayerRasterToPelX[MAX_LAYERS][ MAX_NUM_SPU_W*MAX_NUM_SPU_W ];
    96 UInt g_auiLayerRasterToPelY[MAX_LAYERS][ MAX_NUM_SPU_W*MAX_NUM_SPU_W ];
    97 #endif
     88
    9889UInt g_uiMaxCUWidth  = MAX_CU_SIZE;
    9990UInt g_uiMaxCUHeight = MAX_CU_SIZE;
     
    10697
    10798UInt g_auiPUOffset[8] = { 0, 8, 4, 4, 2, 10, 1, 5};
    108 
    109 #if FAST_INTRA_SHVC
    110 UInt g_reducedSetIntraModes[NUM_INTRA_MODE-1] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 };
    111 UInt g_predefSetIntraModes[NUM_INTRA_MODE-1] = {26,10,18,34,2,22,14,30,6,24,12,28,8,20,16,32,4,17,19,15,21,13,23,11,25,9,27,7,29,5,31,3,33,0,2};
    112 #endif
    11399
    114100Void initZscanToRaster ( Int iMaxDepth, Int iDepth, UInt uiStartVal, UInt*& rpuiCurrIdx )
     
    321307UInt g_uiPCMBitDepthLuma     = 8;    // PCM bit-depth
    322308UInt g_uiPCMBitDepthChroma   = 8;    // PCM bit-depth
    323 #if O0194_DIFFERENT_BITDEPTH_EL_BL
    324 Int  g_bitDepthYLayer[MAX_LAYERS];
    325 Int  g_bitDepthCLayer[MAX_LAYERS];
    326 
    327 UInt g_uiPCMBitDepthLumaDec[MAX_LAYERS];    // PCM bit-depth
    328 UInt g_uiPCMBitDepthChromaDec[MAX_LAYERS];    // PCM bit-depth
    329 #endif
    330 #if O0194_WEIGHTED_PREDICTION_CGS
    331 void * g_refWeightACDCParam; // type=wpACDCParam
    332 #endif
     309
    333310// ====================================================================================================================
    334311// Misc.
     
    528505
    529506#if SVC_EXTENSION
     507#if FAST_INTRA_SHVC
     508UInt g_reducedSetIntraModes[NUM_INTRA_MODE-1] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 };
     509UInt g_predefSetIntraModes[NUM_INTRA_MODE-1] = {26,10,18,34,2,22,14,30,6,24,12,28,8,20,16,32,4,17,19,15,21,13,23,11,25,9,27,7,29,5,31,3,33,0,2};
     510#endif
     511#if O0194_DIFFERENT_BITDEPTH_EL_BL
     512Int  g_bitDepthYLayer[MAX_LAYERS];
     513Int  g_bitDepthCLayer[MAX_LAYERS];
     514
     515UInt g_uiPCMBitDepthLumaDec[MAX_LAYERS];    // PCM bit-depth
     516UInt g_uiPCMBitDepthChromaDec[MAX_LAYERS];    // PCM bit-depth
     517#endif
     518#if O0194_WEIGHTED_PREDICTION_CGS
     519void * g_refWeightACDCParam; // type=wpACDCParam
     520#endif
    530521Int g_mvScalingFactor  [MAX_LAYERS][2] = {{0,0}, {0,0}};
    531522Int g_posScalingFactor [MAX_LAYERS][2] = {{0,0}, {0,0}};
     
    571562  };
    572563}
     564#if LAYER_CTB
     565UInt g_auiLayerMaxCUWidth[MAX_LAYERS];
     566UInt g_auiLayerMaxCUHeight[MAX_LAYERS];
     567UInt g_auiLayerMaxCUDepth[MAX_LAYERS];
     568UInt g_auiLayerAddCUDepth[MAX_LAYERS];
     569UInt g_auiLayerZscanToRaster[MAX_LAYERS][ MAX_NUM_SPU_W*MAX_NUM_SPU_W ];
     570UInt g_auiLayerRasterToZscan[MAX_LAYERS][ MAX_NUM_SPU_W*MAX_NUM_SPU_W ];
     571UInt g_auiLayerRasterToPelX[MAX_LAYERS][ MAX_NUM_SPU_W*MAX_NUM_SPU_W ];
     572UInt g_auiLayerRasterToPelY[MAX_LAYERS][ MAX_NUM_SPU_W*MAX_NUM_SPU_W ];
    573573#endif
     574#endif //SVC_EXTENSION
    574575
    575576//! \}
  • branches/SHM-5.0-dev/source/Lib/TLibCommon/TComRom.h

    r549 r593  
    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 *
     
    8181
    8282// global variable (LCU width/height, max. CU depth)
    83 #if LAYER_CTB
    84 extern       UInt g_auiLayerMaxCUWidth[MAX_LAYERS];
    85 extern       UInt g_auiLayerMaxCUHeight[MAX_LAYERS];
    86 extern       UInt g_auiLayerMaxCUDepth[MAX_LAYERS];
    87 extern       UInt g_auiLayerAddCUDepth[MAX_LAYERS];
    88 extern       UInt g_auiLayerZscanToRaster[MAX_LAYERS][ MAX_NUM_SPU_W*MAX_NUM_SPU_W ];
    89 extern       UInt g_auiLayerRasterToZscan[MAX_LAYERS][ MAX_NUM_SPU_W*MAX_NUM_SPU_W ];
    90 extern       UInt g_auiLayerRasterToPelX[MAX_LAYERS][ MAX_NUM_SPU_W*MAX_NUM_SPU_W ];
    91 extern       UInt g_auiLayerRasterToPelY[MAX_LAYERS][ MAX_NUM_SPU_W*MAX_NUM_SPU_W ];
    92 #endif
    9383extern       UInt g_uiMaxCUWidth;
    9484extern       UInt g_uiMaxCUHeight;
     
    139129
    140130extern const UChar  g_aucIntraModeNumFast[ MAX_CU_DEPTH ];
    141 
    142 #if FAST_INTRA_SHVC
    143 extern       UInt  g_reducedSetIntraModes[NUM_INTRA_MODE-1];
    144 extern       UInt  g_predefSetIntraModes[NUM_INTRA_MODE-1];
    145 #endif
    146131
    147132// ====================================================================================================================
     
    287272
    288273#if SVC_EXTENSION
     274#if FAST_INTRA_SHVC
     275extern       UInt  g_reducedSetIntraModes[NUM_INTRA_MODE-1];
     276extern       UInt  g_predefSetIntraModes[NUM_INTRA_MODE-1];
     277#endif
    289278extern Int g_mvScalingFactor  [MAX_LAYERS][2];
    290279extern Int g_posScalingFactor [MAX_LAYERS][2];
    291280std::string NaluToStr( NalUnitType nalu );
    292 #endif
     281#if LAYER_CTB
     282extern       UInt g_auiLayerMaxCUWidth[MAX_LAYERS];
     283extern       UInt g_auiLayerMaxCUHeight[MAX_LAYERS];
     284extern       UInt g_auiLayerMaxCUDepth[MAX_LAYERS];
     285extern       UInt g_auiLayerAddCUDepth[MAX_LAYERS];
     286extern       UInt g_auiLayerZscanToRaster[MAX_LAYERS][ MAX_NUM_SPU_W*MAX_NUM_SPU_W ];
     287extern       UInt g_auiLayerRasterToZscan[MAX_LAYERS][ MAX_NUM_SPU_W*MAX_NUM_SPU_W ];
     288extern       UInt g_auiLayerRasterToPelX[MAX_LAYERS][ MAX_NUM_SPU_W*MAX_NUM_SPU_W ];
     289extern       UInt g_auiLayerRasterToPelY[MAX_LAYERS][ MAX_NUM_SPU_W*MAX_NUM_SPU_W ];
     290#endif
     291#endif //SVC_EXTENSION
    293292
    294293//! \}
  • branches/SHM-5.0-dev/source/Lib/TLibCommon/TComSampleAdaptiveOffset.cpp

    r540 r593  
    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 *
     
    4444//! \ingroup TLibCommon
    4545//! \{
    46 #if HM_CLEANUP_SAO
    4746UInt g_saoMaxOffsetQVal[NUM_SAO_COMPONENTS];
    4847
     
    698697  return pBuf;
    699698}
    700 #else
    701 
    702 SAOParam::~SAOParam()
    703 {
    704   for (Int i = 0 ; i<3; i++)
    705   {
    706     if (psSaoPart[i])
    707     {
    708       delete [] psSaoPart[i];
    709     }
    710   }
    711 }
    712 
    713 // ====================================================================================================================
    714 // Tables
    715 // ====================================================================================================================
    716 
    717 TComSampleAdaptiveOffset::TComSampleAdaptiveOffset()
    718 {
    719   m_pClipTable = NULL;
    720   m_pClipTableBase = NULL;
    721   m_pChromaClipTable = NULL;
    722   m_pChromaClipTableBase = NULL;
    723   m_iOffsetBo = NULL;
    724   m_iChromaOffsetBo = NULL;
    725   m_lumaTableBo = NULL;
    726   m_chromaTableBo = NULL;
    727   m_iUpBuff1 = NULL;
    728   m_iUpBuff2 = NULL;
    729   m_iUpBufft = NULL;
    730   ipSwap = NULL;
    731 
    732   m_pTmpU1 = NULL;
    733   m_pTmpU2 = NULL;
    734   m_pTmpL1 = NULL;
    735   m_pTmpL2 = NULL;
    736 }
    737 
    738 TComSampleAdaptiveOffset::~TComSampleAdaptiveOffset()
    739 {
    740 
    741 }
    742 
    743 const Int TComSampleAdaptiveOffset::m_aiNumCulPartsLevel[5] =
    744 {
    745   1,   //level 0
    746   5,   //level 1
    747   21,  //level 2
    748   85,  //level 3
    749   341, //level 4
    750 };
    751 
    752 const UInt TComSampleAdaptiveOffset::m_auiEoTable[9] =
    753 {
    754   1, //0   
    755   2, //1   
    756   0, //2
    757   3, //3
    758   4, //4
    759   0, //5 
    760   0, //6 
    761   0, //7
    762   0
    763 };
    764 
    765 const Int TComSampleAdaptiveOffset::m_iNumClass[MAX_NUM_SAO_TYPE] =
    766 {
    767   SAO_EO_LEN,
    768   SAO_EO_LEN,
    769   SAO_EO_LEN,
    770   SAO_EO_LEN,
    771   SAO_BO_LEN
    772 };
    773 
    774 const UInt TComSampleAdaptiveOffset::m_uiMaxDepth = SAO_MAX_DEPTH;
    775 
    776 
    777 /** convert Level Row Col to Idx
    778  * \param   level,  row,  col
    779  */
    780 Int  TComSampleAdaptiveOffset::convertLevelRowCol2Idx(Int level, Int row, Int col)
    781 {
    782   Int idx;
    783   if (level == 0)
    784   {
    785     idx = 0;
    786   }
    787   else if (level == 1)
    788   {
    789     idx = 1 + row*2 + col;
    790   }
    791   else if (level == 2)
    792   {
    793     idx = 5 + row*4 + col;
    794   }
    795   else if (level == 3)
    796   {
    797     idx = 21 + row*8 + col;
    798   }
    799   else // (level == 4)
    800   {
    801     idx = 85 + row*16 + col;
    802   }
    803   return idx;
    804 }
    805 
    806 /** create SampleAdaptiveOffset memory.
    807  * \param
    808  */
    809 Void TComSampleAdaptiveOffset::create( UInt uiSourceWidth, UInt uiSourceHeight, UInt uiMaxCUWidth, UInt uiMaxCUHeight )
    810 {
    811   m_iPicWidth  = uiSourceWidth;
    812   m_iPicHeight = uiSourceHeight;
    813 
    814   m_uiMaxCUWidth  = uiMaxCUWidth;
    815   m_uiMaxCUHeight = uiMaxCUHeight;
    816 
    817   m_iNumCuInWidth  = m_iPicWidth / m_uiMaxCUWidth;
    818   m_iNumCuInWidth += ( m_iPicWidth % m_uiMaxCUWidth ) ? 1 : 0;
    819 
    820   m_iNumCuInHeight  = m_iPicHeight / m_uiMaxCUHeight;
    821   m_iNumCuInHeight += ( m_iPicHeight % m_uiMaxCUHeight ) ? 1 : 0;
    822 
    823   Int iMaxSplitLevelHeight = (Int)(logf((Float)m_iNumCuInHeight)/logf(2.0));
    824   Int iMaxSplitLevelWidth  = (Int)(logf((Float)m_iNumCuInWidth )/logf(2.0));
    825 
    826   m_uiMaxSplitLevel = (iMaxSplitLevelHeight < iMaxSplitLevelWidth)?(iMaxSplitLevelHeight):(iMaxSplitLevelWidth);
    827   m_uiMaxSplitLevel = (m_uiMaxSplitLevel< m_uiMaxDepth)?(m_uiMaxSplitLevel):(m_uiMaxDepth);
    828   /* various structures are overloaded to store per component data.
    829    * m_iNumTotalParts must allow for sufficient storage in any allocated arrays */
    830   m_iNumTotalParts  = max(3,m_aiNumCulPartsLevel[m_uiMaxSplitLevel]);
    831 
    832   UInt uiPixelRangeY = 1 << g_bitDepthY;
    833   UInt uiBoRangeShiftY = g_bitDepthY - SAO_BO_BITS;
    834 
    835   m_lumaTableBo = new Pel [uiPixelRangeY];
    836   for (Int k2=0; k2<uiPixelRangeY; k2++)
    837   {
    838     m_lumaTableBo[k2] = 1 + (k2>>uiBoRangeShiftY);
    839   }
    840 
    841   UInt uiPixelRangeC = 1 << g_bitDepthC;
    842   UInt uiBoRangeShiftC = g_bitDepthC - SAO_BO_BITS;
    843 
    844   m_chromaTableBo = new Pel [uiPixelRangeC];
    845   for (Int k2=0; k2<uiPixelRangeC; k2++)
    846   {
    847     m_chromaTableBo[k2] = 1 + (k2>>uiBoRangeShiftC);
    848   }
    849 
    850   m_iUpBuff1 = new Int[m_iPicWidth+2];
    851   m_iUpBuff2 = new Int[m_iPicWidth+2];
    852   m_iUpBufft = new Int[m_iPicWidth+2];
    853 
    854   m_iUpBuff1++;
    855   m_iUpBuff2++;
    856   m_iUpBufft++;
    857   Pel i;
    858 
    859   UInt uiMaxY  = (1 << g_bitDepthY) - 1;;
    860   UInt uiMinY  = 0;
    861 
    862   Int iCRangeExt = uiMaxY>>1;
    863 
    864   m_pClipTableBase = new Pel[uiMaxY+2*iCRangeExt];
    865   m_iOffsetBo      = new Int[uiMaxY+2*iCRangeExt];
    866 
    867   for(i=0;i<(uiMinY+iCRangeExt);i++)
    868   {
    869     m_pClipTableBase[i] = uiMinY;
    870   }
    871 
    872   for(i=uiMinY+iCRangeExt;i<(uiMaxY+  iCRangeExt);i++)
    873   {
    874     m_pClipTableBase[i] = i-iCRangeExt;
    875   }
    876 
    877   for(i=uiMaxY+iCRangeExt;i<(uiMaxY+2*iCRangeExt);i++)
    878   {
    879     m_pClipTableBase[i] = uiMaxY;
    880   }
    881 
    882   m_pClipTable = &(m_pClipTableBase[iCRangeExt]);
    883 
    884   UInt uiMaxC  = (1 << g_bitDepthC) - 1;
    885   UInt uiMinC  = 0;
    886 
    887   Int iCRangeExtC = uiMaxC>>1;
    888 
    889   m_pChromaClipTableBase = new Pel[uiMaxC+2*iCRangeExtC];
    890   m_iChromaOffsetBo      = new Int[uiMaxC+2*iCRangeExtC];
    891 
    892   for(i=0;i<(uiMinC+iCRangeExtC);i++)
    893   {
    894     m_pChromaClipTableBase[i] = uiMinC;
    895   }
    896 
    897   for(i=uiMinC+iCRangeExtC;i<(uiMaxC+  iCRangeExtC);i++)
    898   {
    899     m_pChromaClipTableBase[i] = i-iCRangeExtC;
    900   }
    901 
    902   for(i=uiMaxC+iCRangeExtC;i<(uiMaxC+2*iCRangeExtC);i++)
    903   {
    904     m_pChromaClipTableBase[i] = uiMaxC;
    905   }
    906 
    907   m_pChromaClipTable = &(m_pChromaClipTableBase[iCRangeExtC]);
    908 
    909   m_pTmpL1 = new Pel [m_uiMaxCUHeight+1];
    910   m_pTmpL2 = new Pel [m_uiMaxCUHeight+1];
    911   m_pTmpU1 = new Pel [m_iPicWidth];
    912   m_pTmpU2 = new Pel [m_iPicWidth];
    913 }
    914 
    915 /** destroy SampleAdaptiveOffset memory.
    916  * \param
    917  */
    918 Void TComSampleAdaptiveOffset::destroy()
    919 {
    920   if (m_pClipTableBase)
    921   {
    922     delete [] m_pClipTableBase; m_pClipTableBase = NULL;
    923   }
    924   if (m_iOffsetBo)
    925   {
    926     delete [] m_iOffsetBo; m_iOffsetBo = NULL;
    927   }
    928   if (m_lumaTableBo)
    929   {
    930     delete[] m_lumaTableBo; m_lumaTableBo = NULL;
    931   }
    932 
    933   if (m_pChromaClipTableBase)
    934   {
    935     delete [] m_pChromaClipTableBase; m_pChromaClipTableBase = NULL;
    936   }
    937   if (m_iChromaOffsetBo)
    938   {
    939     delete [] m_iChromaOffsetBo; m_iChromaOffsetBo = NULL;
    940   }
    941   if (m_chromaTableBo)
    942   {
    943     delete[] m_chromaTableBo; m_chromaTableBo = NULL;
    944   }
    945 
    946   if (m_iUpBuff1)
    947   {
    948     m_iUpBuff1--;
    949     delete [] m_iUpBuff1; m_iUpBuff1 = NULL;
    950   }
    951   if (m_iUpBuff2)
    952   {
    953     m_iUpBuff2--;
    954     delete [] m_iUpBuff2; m_iUpBuff2 = NULL;
    955   }
    956   if (m_iUpBufft)
    957   {
    958     m_iUpBufft--;
    959     delete [] m_iUpBufft; m_iUpBufft = NULL;
    960   }
    961   if (m_pTmpL1)
    962   {
    963     delete [] m_pTmpL1; m_pTmpL1 = NULL;
    964   }
    965   if (m_pTmpL2)
    966   {
    967     delete [] m_pTmpL2; m_pTmpL2 = NULL;
    968   }
    969   if (m_pTmpU1)
    970   {
    971     delete [] m_pTmpU1; m_pTmpU1 = NULL;
    972   }
    973   if (m_pTmpU2)
    974   {
    975     delete [] m_pTmpU2; m_pTmpU2 = NULL;
    976   }
    977 }
    978 
    979 /** allocate memory for SAO parameters
    980  * \param    *pcSaoParam
    981  */
    982 Void TComSampleAdaptiveOffset::allocSaoParam(SAOParam *pcSaoParam)
    983 {
    984   pcSaoParam->iMaxSplitLevel = m_uiMaxSplitLevel;
    985   pcSaoParam->psSaoPart[0] = new SAOQTPart[ m_aiNumCulPartsLevel[pcSaoParam->iMaxSplitLevel] ];
    986   initSAOParam(pcSaoParam, 0, 0, 0, -1, 0, m_iNumCuInWidth-1,  0, m_iNumCuInHeight-1,0);
    987   pcSaoParam->psSaoPart[1] = new SAOQTPart[ m_aiNumCulPartsLevel[pcSaoParam->iMaxSplitLevel] ];
    988   pcSaoParam->psSaoPart[2] = new SAOQTPart[ m_aiNumCulPartsLevel[pcSaoParam->iMaxSplitLevel] ];
    989   initSAOParam(pcSaoParam, 0, 0, 0, -1, 0, m_iNumCuInWidth-1,  0, m_iNumCuInHeight-1,1);
    990   initSAOParam(pcSaoParam, 0, 0, 0, -1, 0, m_iNumCuInWidth-1,  0, m_iNumCuInHeight-1,2);
    991   pcSaoParam->numCuInWidth  = m_iNumCuInWidth;
    992   pcSaoParam->numCuInHeight = m_iNumCuInHeight;
    993   pcSaoParam->saoLcuParam[0] = new SaoLcuParam [m_iNumCuInHeight*m_iNumCuInWidth];
    994   pcSaoParam->saoLcuParam[1] = new SaoLcuParam [m_iNumCuInHeight*m_iNumCuInWidth];
    995   pcSaoParam->saoLcuParam[2] = new SaoLcuParam [m_iNumCuInHeight*m_iNumCuInWidth];
    996 }
    997 
    998 /** initialize SAO parameters
    999  * \param    *pcSaoParam,  iPartLevel,  iPartRow,  iPartCol,  iParentPartIdx,  StartCUX,  EndCUX,  StartCUY,  EndCUY,  iYCbCr
    1000  */
    1001 Void TComSampleAdaptiveOffset::initSAOParam(SAOParam *pcSaoParam, Int iPartLevel, Int iPartRow, Int iPartCol, Int iParentPartIdx, Int StartCUX, Int EndCUX, Int StartCUY, Int EndCUY, Int iYCbCr)
    1002 {
    1003   Int j;
    1004   Int iPartIdx = convertLevelRowCol2Idx(iPartLevel, iPartRow, iPartCol);
    1005 
    1006   SAOQTPart* pSaoPart;
    1007 
    1008   pSaoPart = &(pcSaoParam->psSaoPart[iYCbCr][iPartIdx]);
    1009 
    1010   pSaoPart->PartIdx   = iPartIdx;
    1011   pSaoPart->PartLevel = iPartLevel;
    1012   pSaoPart->PartRow   = iPartRow;
    1013   pSaoPart->PartCol   = iPartCol;
    1014 
    1015   pSaoPart->StartCUX  = StartCUX;
    1016   pSaoPart->EndCUX    = EndCUX;
    1017   pSaoPart->StartCUY  = StartCUY;
    1018   pSaoPart->EndCUY    = EndCUY;
    1019 
    1020   pSaoPart->UpPartIdx = iParentPartIdx;
    1021   pSaoPart->iBestType   = -1;
    1022   pSaoPart->iLength     =  0;
    1023 
    1024   pSaoPart->subTypeIdx = 0;
    1025 
    1026   for (j=0;j<MAX_NUM_SAO_OFFSETS;j++)
    1027   {
    1028     pSaoPart->iOffset[j] = 0;
    1029   }
    1030 
    1031   if(pSaoPart->PartLevel != m_uiMaxSplitLevel)
    1032   {
    1033     Int DownLevel    = (iPartLevel+1 );
    1034     Int DownRowStart = (iPartRow << 1);
    1035     Int DownColStart = (iPartCol << 1);
    1036 
    1037     Int iDownRowIdx, iDownColIdx;
    1038     Int NumCUWidth,  NumCUHeight;
    1039     Int NumCULeft;
    1040     Int NumCUTop;
    1041 
    1042     Int DownStartCUX, DownStartCUY;
    1043     Int DownEndCUX, DownEndCUY;
    1044 
    1045     NumCUWidth  = EndCUX - StartCUX +1;
    1046     NumCUHeight = EndCUY - StartCUY +1;
    1047     NumCULeft   = (NumCUWidth  >> 1);
    1048     NumCUTop    = (NumCUHeight >> 1);
    1049 
    1050     DownStartCUX= StartCUX;
    1051     DownEndCUX  = DownStartCUX + NumCULeft - 1;
    1052     DownStartCUY= StartCUY;
    1053     DownEndCUY  = DownStartCUY + NumCUTop  - 1;
    1054     iDownRowIdx = DownRowStart + 0;
    1055     iDownColIdx = DownColStart + 0;
    1056 
    1057     pSaoPart->DownPartsIdx[0]= convertLevelRowCol2Idx(DownLevel, iDownRowIdx, iDownColIdx);
    1058 
    1059     initSAOParam(pcSaoParam, DownLevel, iDownRowIdx, iDownColIdx, iPartIdx, DownStartCUX, DownEndCUX, DownStartCUY, DownEndCUY, iYCbCr);
    1060 
    1061     DownStartCUX = StartCUX + NumCULeft;
    1062     DownEndCUX   = EndCUX;
    1063     DownStartCUY = StartCUY;
    1064     DownEndCUY   = DownStartCUY + NumCUTop -1;
    1065     iDownRowIdx  = DownRowStart + 0;
    1066     iDownColIdx  = DownColStart + 1;
    1067 
    1068     pSaoPart->DownPartsIdx[1] = convertLevelRowCol2Idx(DownLevel, iDownRowIdx, iDownColIdx);
    1069 
    1070     initSAOParam(pcSaoParam, DownLevel, iDownRowIdx, iDownColIdx, iPartIdx,  DownStartCUX, DownEndCUX, DownStartCUY, DownEndCUY, iYCbCr);
    1071 
    1072     DownStartCUX = StartCUX;
    1073     DownEndCUX   = DownStartCUX + NumCULeft -1;
    1074     DownStartCUY = StartCUY + NumCUTop;
    1075     DownEndCUY   = EndCUY;
    1076     iDownRowIdx  = DownRowStart + 1;
    1077     iDownColIdx  = DownColStart + 0;
    1078 
    1079     pSaoPart->DownPartsIdx[2] = convertLevelRowCol2Idx(DownLevel, iDownRowIdx, iDownColIdx);
    1080 
    1081     initSAOParam(pcSaoParam, DownLevel, iDownRowIdx, iDownColIdx, iPartIdx, DownStartCUX, DownEndCUX, DownStartCUY, DownEndCUY, iYCbCr);
    1082 
    1083     DownStartCUX = StartCUX+ NumCULeft;
    1084     DownEndCUX   = EndCUX;
    1085     DownStartCUY = StartCUY + NumCUTop;
    1086     DownEndCUY   = EndCUY;
    1087     iDownRowIdx  = DownRowStart + 1;
    1088     iDownColIdx  = DownColStart + 1;
    1089 
    1090     pSaoPart->DownPartsIdx[3] = convertLevelRowCol2Idx(DownLevel, iDownRowIdx, iDownColIdx);
    1091 
    1092     initSAOParam(pcSaoParam, DownLevel, iDownRowIdx, iDownColIdx, iPartIdx,DownStartCUX, DownEndCUX, DownStartCUY, DownEndCUY, iYCbCr);
    1093   }
    1094   else
    1095   {
    1096     pSaoPart->DownPartsIdx[0]=pSaoPart->DownPartsIdx[1]= pSaoPart->DownPartsIdx[2]= pSaoPart->DownPartsIdx[3]= -1;
    1097   }
    1098 }
    1099 
    1100 /** free memory of SAO parameters
    1101  * \param   pcSaoParam
    1102  */
    1103 Void TComSampleAdaptiveOffset::freeSaoParam(SAOParam *pcSaoParam)
    1104 {
    1105   delete [] pcSaoParam->psSaoPart[0];
    1106   delete [] pcSaoParam->psSaoPart[1];
    1107   delete [] pcSaoParam->psSaoPart[2];
    1108   pcSaoParam->psSaoPart[0] = 0;
    1109   pcSaoParam->psSaoPart[1] = 0;
    1110   pcSaoParam->psSaoPart[2] = 0;
    1111   if( pcSaoParam->saoLcuParam[0])
    1112   {
    1113     delete [] pcSaoParam->saoLcuParam[0]; pcSaoParam->saoLcuParam[0] = NULL;
    1114   }
    1115   if( pcSaoParam->saoLcuParam[1])
    1116   {
    1117     delete [] pcSaoParam->saoLcuParam[1]; pcSaoParam->saoLcuParam[1] = NULL;
    1118   }
    1119   if( pcSaoParam->saoLcuParam[2])
    1120   {
    1121     delete [] pcSaoParam->saoLcuParam[2]; pcSaoParam->saoLcuParam[2] = NULL;
    1122   }
    1123 }
    1124 
    1125 /** reset SAO parameters
    1126  * \param   pcSaoParam
    1127  */
    1128 Void TComSampleAdaptiveOffset::resetSAOParam(SAOParam *pcSaoParam)
    1129 {
    1130   Int iNumComponet = 3;
    1131   for(Int c=0; c<iNumComponet; c++)
    1132   {
    1133 if (c<2)
    1134   {
    1135     pcSaoParam->bSaoFlag[c] = 0;
    1136   }
    1137     for(Int i=0; i< m_aiNumCulPartsLevel[m_uiMaxSplitLevel]; i++)
    1138     {
    1139       pcSaoParam->psSaoPart[c][i].iBestType     = -1;
    1140       pcSaoParam->psSaoPart[c][i].iLength       =  0;
    1141       pcSaoParam->psSaoPart[c][i].bSplit        = false;
    1142       pcSaoParam->psSaoPart[c][i].bProcessed    = false;
    1143       pcSaoParam->psSaoPart[c][i].dMinCost      = MAX_DOUBLE;
    1144       pcSaoParam->psSaoPart[c][i].iMinDist      = MAX_INT;
    1145       pcSaoParam->psSaoPart[c][i].iMinRate      = MAX_INT;
    1146       pcSaoParam->psSaoPart[c][i].subTypeIdx    = 0;
    1147       for (Int j=0;j<MAX_NUM_SAO_OFFSETS;j++)
    1148       {
    1149         pcSaoParam->psSaoPart[c][i].iOffset[j] = 0;
    1150         pcSaoParam->psSaoPart[c][i].iOffset[j] = 0;
    1151         pcSaoParam->psSaoPart[c][i].iOffset[j] = 0;
    1152       }
    1153     }
    1154     pcSaoParam->oneUnitFlag[0]   = 0;
    1155     pcSaoParam->oneUnitFlag[1]   = 0;
    1156     pcSaoParam->oneUnitFlag[2]   = 0;
    1157     resetLcuPart(pcSaoParam->saoLcuParam[0]);
    1158     resetLcuPart(pcSaoParam->saoLcuParam[1]);
    1159     resetLcuPart(pcSaoParam->saoLcuParam[2]);
    1160   }
    1161 }
    1162 
    1163 /** get the sign of input variable
    1164  * \param   x
    1165  */
    1166 inline Int xSign(Int x)
    1167 {
    1168   return ((x >> 31) | ((Int)( (((UInt) -x)) >> 31)));
    1169 }
    1170 
    1171 /** initialize variables for SAO process
    1172  * \param  pcPic picture data pointer
    1173  */
    1174 Void TComSampleAdaptiveOffset::createPicSaoInfo(TComPic* pcPic)
    1175 {
    1176   m_pcPic   = pcPic;
    1177   m_bUseNIF = ( pcPic->getIndependentSliceBoundaryForNDBFilter() || pcPic->getIndependentTileBoundaryForNDBFilter() );
    1178   if(m_bUseNIF)
    1179   {
    1180     m_pcYuvTmp = pcPic->getYuvPicBufferForIndependentBoundaryProcessing();
    1181   }
    1182 }
    1183 
    1184 Void TComSampleAdaptiveOffset::destroyPicSaoInfo()
    1185 {
    1186 
    1187 }
    1188 
    1189 /** sample adaptive offset process for one LCU
    1190  * \param   iAddr, iSaoType, iYCbCr
    1191  */
    1192 Void TComSampleAdaptiveOffset::processSaoCu(Int iAddr, Int iSaoType, Int iYCbCr)
    1193 {
    1194   if(!m_bUseNIF)
    1195   {
    1196     processSaoCuOrg( iAddr, iSaoType, iYCbCr);
    1197   }
    1198   else
    1199   { 
    1200     Int  isChroma = (iYCbCr != 0)? 1:0;
    1201     Int  stride   = (iYCbCr != 0)?(m_pcPic->getCStride()):(m_pcPic->getStride());
    1202     Pel* pPicRest = getPicYuvAddr(m_pcPic->getPicYuvRec(), iYCbCr);
    1203     Pel* pPicDec  = getPicYuvAddr(m_pcYuvTmp, iYCbCr);
    1204 
    1205     std::vector<NDBFBlockInfo>& vFilterBlocks = *(m_pcPic->getCU(iAddr)->getNDBFilterBlocks());
    1206 
    1207     //variables
    1208     UInt  xPos, yPos, width, height;
    1209     Bool* pbBorderAvail;
    1210     UInt  posOffset;
    1211 
    1212     for(Int i=0; i< vFilterBlocks.size(); i++)
    1213     {
    1214       xPos        = vFilterBlocks[i].posX   >> isChroma;
    1215       yPos        = vFilterBlocks[i].posY   >> isChroma;
    1216       width       = vFilterBlocks[i].width  >> isChroma;
    1217       height      = vFilterBlocks[i].height >> isChroma;
    1218       pbBorderAvail = vFilterBlocks[i].isBorderAvailable;
    1219 
    1220       posOffset = (yPos* stride) + xPos;
    1221 
    1222       processSaoBlock(pPicDec+ posOffset, pPicRest+ posOffset, stride, iSaoType, width, height, pbBorderAvail, iYCbCr);
    1223     }
    1224   }
    1225 }
    1226 
    1227 /** Perform SAO for non-cross-slice or non-cross-tile process
    1228  * \param  pDec to-be-filtered block buffer pointer
    1229  * \param  pRest filtered block buffer pointer
    1230  * \param  stride picture buffer stride
    1231  * \param  saoType SAO offset type
    1232  * \param  xPos x coordinate
    1233  * \param  yPos y coordinate
    1234  * \param  width block width
    1235  * \param  height block height
    1236  * \param  pbBorderAvail availabilities of block border pixels
    1237  */
    1238 Void TComSampleAdaptiveOffset::processSaoBlock(Pel* pDec, Pel* pRest, Int stride, Int saoType, UInt width, UInt height, Bool* pbBorderAvail, Int iYCbCr)
    1239 {
    1240   //variables
    1241   Int startX, startY, endX, endY, x, y;
    1242   Int signLeft,signRight,signDown,signDown1;
    1243   UInt edgeType;
    1244   Pel *pClipTbl = (iYCbCr==0)?m_pClipTable:m_pChromaClipTable;
    1245   Int *pOffsetBo = (iYCbCr==0)?m_iOffsetBo: m_iChromaOffsetBo;
    1246 
    1247   switch (saoType)
    1248   {
    1249   case SAO_EO_0: // dir: -
    1250     {
    1251 
    1252       startX = (pbBorderAvail[SGU_L]) ? 0 : 1;
    1253       endX   = (pbBorderAvail[SGU_R]) ? width : (width -1);
    1254       for (y=0; y< height; y++)
    1255       {
    1256         signLeft = xSign(pDec[startX] - pDec[startX-1]);
    1257         for (x=startX; x< endX; x++)
    1258         {
    1259           signRight =  xSign(pDec[x] - pDec[x+1]);
    1260           edgeType =  signRight + signLeft + 2;
    1261           signLeft  = -signRight;
    1262 
    1263           pRest[x] = pClipTbl[pDec[x] + m_iOffsetEo[edgeType]];
    1264         }
    1265         pDec  += stride;
    1266         pRest += stride;
    1267       }
    1268       break;
    1269     }
    1270   case SAO_EO_1: // dir: |
    1271     {
    1272       startY = (pbBorderAvail[SGU_T]) ? 0 : 1;
    1273       endY   = (pbBorderAvail[SGU_B]) ? height : height-1;
    1274       if (!pbBorderAvail[SGU_T])
    1275       {
    1276         pDec  += stride;
    1277         pRest += stride;
    1278       }
    1279       for (x=0; x< width; x++)
    1280       {
    1281         m_iUpBuff1[x] = xSign(pDec[x] - pDec[x-stride]);
    1282       }
    1283       for (y=startY; y<endY; y++)
    1284       {
    1285         for (x=0; x< width; x++)
    1286         {
    1287           signDown  = xSign(pDec[x] - pDec[x+stride]);
    1288           edgeType = signDown + m_iUpBuff1[x] + 2;
    1289           m_iUpBuff1[x]= -signDown;
    1290 
    1291           pRest[x] = pClipTbl[pDec[x] + m_iOffsetEo[edgeType]];
    1292         }
    1293         pDec  += stride;
    1294         pRest += stride;
    1295       }
    1296       break;
    1297     }
    1298   case SAO_EO_2: // dir: 135
    1299     {
    1300       Int posShift= stride + 1;
    1301 
    1302       startX = (pbBorderAvail[SGU_L]) ? 0 : 1 ;
    1303       endX   = (pbBorderAvail[SGU_R]) ? width : (width-1);
    1304 
    1305       //prepare 2nd line upper sign
    1306       pDec += stride;
    1307       for (x=startX; x< endX+1; x++)
    1308       {
    1309         m_iUpBuff1[x] = xSign(pDec[x] - pDec[x- posShift]);
    1310       }
    1311 
    1312       //1st line
    1313       pDec -= stride;
    1314       if(pbBorderAvail[SGU_TL])
    1315       {
    1316         x= 0;
    1317         edgeType      =  xSign(pDec[x] - pDec[x- posShift]) - m_iUpBuff1[x+1] + 2;
    1318         pRest[x] = pClipTbl[pDec[x] + m_iOffsetEo[edgeType]];
    1319 
    1320       }
    1321       if(pbBorderAvail[SGU_T])
    1322       {
    1323         for(x= 1; x< endX; x++)
    1324         {
    1325           edgeType      =  xSign(pDec[x] - pDec[x- posShift]) - m_iUpBuff1[x+1] + 2;
    1326           pRest[x] = pClipTbl[pDec[x] + m_iOffsetEo[edgeType]];
    1327         }
    1328       }
    1329       pDec   += stride;
    1330       pRest  += stride;
    1331 
    1332 
    1333       //middle lines
    1334       for (y= 1; y< height-1; y++)
    1335       {
    1336         for (x=startX; x<endX; x++)
    1337         {
    1338           signDown1      =  xSign(pDec[x] - pDec[x+ posShift]) ;
    1339           edgeType      =  signDown1 + m_iUpBuff1[x] + 2;
    1340           pRest[x] = pClipTbl[pDec[x] + m_iOffsetEo[edgeType]];
    1341 
    1342           m_iUpBufft[x+1] = -signDown1;
    1343         }
    1344         m_iUpBufft[startX] = xSign(pDec[stride+startX] - pDec[startX-1]);
    1345 
    1346         ipSwap     = m_iUpBuff1;
    1347         m_iUpBuff1 = m_iUpBufft;
    1348         m_iUpBufft = ipSwap;
    1349 
    1350         pDec  += stride;
    1351         pRest += stride;
    1352       }
    1353 
    1354       //last line
    1355       if(pbBorderAvail[SGU_B])
    1356       {
    1357         for(x= startX; x< width-1; x++)
    1358         {
    1359           edgeType =  xSign(pDec[x] - pDec[x+ posShift]) + m_iUpBuff1[x] + 2;
    1360           pRest[x] = pClipTbl[pDec[x] + m_iOffsetEo[edgeType]];
    1361         }
    1362       }
    1363       if(pbBorderAvail[SGU_BR])
    1364       {
    1365         x= width -1;
    1366         edgeType =  xSign(pDec[x] - pDec[x+ posShift]) + m_iUpBuff1[x] + 2;
    1367         pRest[x] = pClipTbl[pDec[x] + m_iOffsetEo[edgeType]];
    1368       }
    1369       break;
    1370     }
    1371   case SAO_EO_3: // dir: 45
    1372     {
    1373       Int  posShift     = stride - 1;
    1374       startX = (pbBorderAvail[SGU_L]) ? 0 : 1;
    1375       endX   = (pbBorderAvail[SGU_R]) ? width : (width -1);
    1376 
    1377       //prepare 2nd line upper sign
    1378       pDec += stride;
    1379       for (x=startX-1; x< endX; x++)
    1380       {
    1381         m_iUpBuff1[x] = xSign(pDec[x] - pDec[x- posShift]);
    1382       }
    1383 
    1384 
    1385       //first line
    1386       pDec -= stride;
    1387       if(pbBorderAvail[SGU_T])
    1388       {
    1389         for(x= startX; x< width -1; x++)
    1390         {
    1391           edgeType = xSign(pDec[x] - pDec[x- posShift]) -m_iUpBuff1[x-1] + 2;
    1392           pRest[x] = pClipTbl[pDec[x] + m_iOffsetEo[edgeType]];
    1393         }
    1394       }
    1395       if(pbBorderAvail[SGU_TR])
    1396       {
    1397         x= width-1;
    1398         edgeType = xSign(pDec[x] - pDec[x- posShift]) -m_iUpBuff1[x-1] + 2;
    1399         pRest[x] = pClipTbl[pDec[x] + m_iOffsetEo[edgeType]];
    1400       }
    1401       pDec  += stride;
    1402       pRest += stride;
    1403 
    1404       //middle lines
    1405       for (y= 1; y< height-1; y++)
    1406       {
    1407         for(x= startX; x< endX; x++)
    1408         {
    1409           signDown1      =  xSign(pDec[x] - pDec[x+ posShift]) ;
    1410           edgeType      =  signDown1 + m_iUpBuff1[x] + 2;
    1411 
    1412           pRest[x] = pClipTbl[pDec[x] + m_iOffsetEo[edgeType]];
    1413           m_iUpBuff1[x-1] = -signDown1;
    1414         }
    1415         m_iUpBuff1[endX-1] = xSign(pDec[endX-1 + stride] - pDec[endX]);
    1416 
    1417         pDec  += stride;
    1418         pRest += stride;
    1419       }
    1420 
    1421       //last line
    1422       if(pbBorderAvail[SGU_BL])
    1423       {
    1424         x= 0;
    1425         edgeType = xSign(pDec[x] - pDec[x+ posShift]) + m_iUpBuff1[x] + 2;
    1426         pRest[x] = pClipTbl[pDec[x] + m_iOffsetEo[edgeType]];
    1427 
    1428       }
    1429       if(pbBorderAvail[SGU_B])
    1430       {
    1431         for(x= 1; x< endX; x++)
    1432         {
    1433           edgeType = xSign(pDec[x] - pDec[x+ posShift]) + m_iUpBuff1[x] + 2;
    1434           pRest[x] = pClipTbl[pDec[x] + m_iOffsetEo[edgeType]];
    1435         }
    1436       }
    1437       break;
    1438     }   
    1439   case SAO_BO:
    1440     {
    1441       for (y=0; y< height; y++)
    1442       {
    1443         for (x=0; x< width; x++)
    1444         {
    1445           pRest[x] = pOffsetBo[pDec[x]];
    1446         }
    1447         pRest += stride;
    1448         pDec  += stride;
    1449       }
    1450       break;
    1451     }
    1452   default: break;
    1453   }
    1454 
    1455 }
    1456 
    1457 /** sample adaptive offset process for one LCU crossing LCU boundary
    1458  * \param   iAddr, iSaoType, iYCbCr
    1459  */
    1460 Void TComSampleAdaptiveOffset::processSaoCuOrg(Int iAddr, Int iSaoType, Int iYCbCr)
    1461 {
    1462   Int x,y;
    1463   TComDataCU *pTmpCu = m_pcPic->getCU(iAddr);
    1464   Pel* pRec;
    1465   Int  iStride;
    1466   Int  iLcuWidth  = m_uiMaxCUWidth;
    1467   Int  iLcuHeight = m_uiMaxCUHeight;
    1468   UInt uiLPelX    = pTmpCu->getCUPelX();
    1469   UInt uiTPelY    = pTmpCu->getCUPelY();
    1470   UInt uiRPelX;
    1471   UInt uiBPelY;
    1472   Int  iSignLeft;
    1473   Int  iSignRight;
    1474   Int  iSignDown;
    1475   Int  iSignDown1;
    1476   Int  iSignDown2;
    1477   UInt uiEdgeType;
    1478   Int iPicWidthTmp;
    1479   Int iPicHeightTmp;
    1480   Int iStartX;
    1481   Int iStartY;
    1482   Int iEndX;
    1483   Int iEndY;
    1484   Int iIsChroma = (iYCbCr!=0)? 1:0;
    1485   Int iShift;
    1486   Int iCuHeightTmp;
    1487   Pel *pTmpLSwap;
    1488   Pel *pTmpL;
    1489   Pel *pTmpU;
    1490   Pel *pClipTbl = NULL;
    1491   Int *pOffsetBo = NULL;
    1492 
    1493   iPicWidthTmp  = m_iPicWidth  >> iIsChroma;
    1494   iPicHeightTmp = m_iPicHeight >> iIsChroma;
    1495   iLcuWidth     = iLcuWidth    >> iIsChroma;
    1496   iLcuHeight    = iLcuHeight   >> iIsChroma;
    1497   uiLPelX       = uiLPelX      >> iIsChroma;
    1498   uiTPelY       = uiTPelY      >> iIsChroma;
    1499   uiRPelX       = uiLPelX + iLcuWidth  ;
    1500   uiBPelY       = uiTPelY + iLcuHeight ;
    1501   uiRPelX       = uiRPelX > iPicWidthTmp  ? iPicWidthTmp  : uiRPelX;
    1502   uiBPelY       = uiBPelY > iPicHeightTmp ? iPicHeightTmp : uiBPelY;
    1503   iLcuWidth     = uiRPelX - uiLPelX;
    1504   iLcuHeight    = uiBPelY - uiTPelY;
    1505 
    1506   if(pTmpCu->getPic()==0)
    1507   {
    1508     return;
    1509   }
    1510   if (iYCbCr == 0)
    1511   {
    1512     pRec       = m_pcPic->getPicYuvRec()->getLumaAddr(iAddr);
    1513     iStride    = m_pcPic->getStride();
    1514   }
    1515   else if (iYCbCr == 1)
    1516   {
    1517     pRec       = m_pcPic->getPicYuvRec()->getCbAddr(iAddr);
    1518     iStride    = m_pcPic->getCStride();
    1519   }
    1520   else
    1521   {
    1522     pRec       = m_pcPic->getPicYuvRec()->getCrAddr(iAddr);
    1523     iStride    = m_pcPic->getCStride();
    1524   }
    1525 
    1526 //   if (iSaoType!=SAO_BO_0 || iSaoType!=SAO_BO_1)
    1527   {
    1528     iCuHeightTmp = (m_uiMaxCUHeight >> iIsChroma);
    1529     iShift = (m_uiMaxCUWidth>> iIsChroma)-1;
    1530     for (Int i=0;i<iCuHeightTmp+1;i++)
    1531     {
    1532       m_pTmpL2[i] = pRec[iShift];
    1533       pRec += iStride;
    1534     }
    1535     pRec -= (iStride*(iCuHeightTmp+1));
    1536 
    1537     pTmpL = m_pTmpL1;
    1538     pTmpU = &(m_pTmpU1[uiLPelX]);
    1539   }
    1540 
    1541   pClipTbl = (iYCbCr==0)? m_pClipTable:m_pChromaClipTable;
    1542   pOffsetBo = (iYCbCr==0)? m_iOffsetBo:m_iChromaOffsetBo;
    1543 
    1544   switch (iSaoType)
    1545   {
    1546   case SAO_EO_0: // dir: -
    1547     {
    1548       iStartX = (uiLPelX == 0) ? 1 : 0;
    1549       iEndX   = (uiRPelX == iPicWidthTmp) ? iLcuWidth-1 : iLcuWidth;
    1550       for (y=0; y<iLcuHeight; y++)
    1551       {
    1552         iSignLeft = xSign(pRec[iStartX] - pTmpL[y]);
    1553         for (x=iStartX; x< iEndX; x++)
    1554         {
    1555           iSignRight =  xSign(pRec[x] - pRec[x+1]);
    1556           uiEdgeType =  iSignRight + iSignLeft + 2;
    1557           iSignLeft  = -iSignRight;
    1558 
    1559           pRec[x] = pClipTbl[pRec[x] + m_iOffsetEo[uiEdgeType]];
    1560         }
    1561         pRec += iStride;
    1562       }
    1563       break;
    1564     }
    1565   case SAO_EO_1: // dir: |
    1566     {
    1567       iStartY = (uiTPelY == 0) ? 1 : 0;
    1568       iEndY   = (uiBPelY == iPicHeightTmp) ? iLcuHeight-1 : iLcuHeight;
    1569       if (uiTPelY == 0)
    1570       {
    1571         pRec += iStride;
    1572       }
    1573       for (x=0; x< iLcuWidth; x++)
    1574       {
    1575         m_iUpBuff1[x] = xSign(pRec[x] - pTmpU[x]);
    1576       }
    1577       for (y=iStartY; y<iEndY; y++)
    1578       {
    1579         for (x=0; x<iLcuWidth; x++)
    1580         {
    1581           iSignDown  = xSign(pRec[x] - pRec[x+iStride]);
    1582           uiEdgeType = iSignDown + m_iUpBuff1[x] + 2;
    1583           m_iUpBuff1[x]= -iSignDown;
    1584 
    1585           pRec[x] = pClipTbl[pRec[x] + m_iOffsetEo[uiEdgeType]];
    1586         }
    1587         pRec += iStride;
    1588       }
    1589       break;
    1590     }
    1591   case SAO_EO_2: // dir: 135
    1592     {
    1593       iStartX = (uiLPelX == 0)            ? 1 : 0;
    1594       iEndX   = (uiRPelX == iPicWidthTmp) ? iLcuWidth-1 : iLcuWidth;
    1595 
    1596       iStartY = (uiTPelY == 0) ?             1 : 0;
    1597       iEndY   = (uiBPelY == iPicHeightTmp) ? iLcuHeight-1 : iLcuHeight;
    1598 
    1599       if (uiTPelY == 0)
    1600       {
    1601         pRec += iStride;
    1602       }
    1603 
    1604       for (x=iStartX; x<iEndX; x++)
    1605       {
    1606         m_iUpBuff1[x] = xSign(pRec[x] - pTmpU[x-1]);
    1607       }
    1608       for (y=iStartY; y<iEndY; y++)
    1609       {
    1610         iSignDown2 = xSign(pRec[iStride+iStartX] - pTmpL[y]);
    1611         for (x=iStartX; x<iEndX; x++)
    1612         {
    1613           iSignDown1      =  xSign(pRec[x] - pRec[x+iStride+1]) ;
    1614           uiEdgeType      =  iSignDown1 + m_iUpBuff1[x] + 2;
    1615           m_iUpBufft[x+1] = -iSignDown1;
    1616           pRec[x] = pClipTbl[pRec[x] + m_iOffsetEo[uiEdgeType]];
    1617         }
    1618         m_iUpBufft[iStartX] = iSignDown2;
    1619 
    1620         ipSwap     = m_iUpBuff1;
    1621         m_iUpBuff1 = m_iUpBufft;
    1622         m_iUpBufft = ipSwap;
    1623 
    1624         pRec += iStride;
    1625       }
    1626       break;
    1627     }
    1628   case SAO_EO_3: // dir: 45
    1629     {
    1630       iStartX = (uiLPelX == 0) ? 1 : 0;
    1631       iEndX   = (uiRPelX == iPicWidthTmp) ? iLcuWidth-1 : iLcuWidth;
    1632 
    1633       iStartY = (uiTPelY == 0) ? 1 : 0;
    1634       iEndY   = (uiBPelY == iPicHeightTmp) ? iLcuHeight-1 : iLcuHeight;
    1635 
    1636       if (iStartY == 1)
    1637       {
    1638         pRec += iStride;
    1639       }
    1640 
    1641       for (x=iStartX-1; x<iEndX; x++)
    1642       {
    1643         m_iUpBuff1[x] = xSign(pRec[x] - pTmpU[x+1]);
    1644       }
    1645       for (y=iStartY; y<iEndY; y++)
    1646       {
    1647         x=iStartX;
    1648         iSignDown1      =  xSign(pRec[x] - pTmpL[y+1]) ;
    1649         uiEdgeType      =  iSignDown1 + m_iUpBuff1[x] + 2;
    1650         m_iUpBuff1[x-1] = -iSignDown1;
    1651         pRec[x] = pClipTbl[pRec[x] + m_iOffsetEo[uiEdgeType]];
    1652         for (x=iStartX+1; x<iEndX; x++)
    1653         {
    1654           iSignDown1      =  xSign(pRec[x] - pRec[x+iStride-1]) ;
    1655           uiEdgeType      =  iSignDown1 + m_iUpBuff1[x] + 2;
    1656           m_iUpBuff1[x-1] = -iSignDown1;
    1657           pRec[x] = pClipTbl[pRec[x] + m_iOffsetEo[uiEdgeType]];
    1658         }
    1659         m_iUpBuff1[iEndX-1] = xSign(pRec[iEndX-1 + iStride] - pRec[iEndX]);
    1660 
    1661         pRec += iStride;
    1662       }
    1663       break;
    1664     }   
    1665   case SAO_BO:
    1666     {
    1667       for (y=0; y<iLcuHeight; y++)
    1668       {
    1669         for (x=0; x<iLcuWidth; x++)
    1670         {
    1671           pRec[x] = pOffsetBo[pRec[x]];
    1672         }
    1673         pRec += iStride;
    1674       }
    1675       break;
    1676     }
    1677   default: break;
    1678   }
    1679 //   if (iSaoType!=SAO_BO_0 || iSaoType!=SAO_BO_1)
    1680   {
    1681     pTmpLSwap = m_pTmpL1;
    1682     m_pTmpL1  = m_pTmpL2;
    1683     m_pTmpL2  = pTmpLSwap;
    1684   }
    1685 }
    1686 /** Sample adaptive offset process
    1687  * \param pcPic, pcSaoParam 
    1688  */
    1689 Void TComSampleAdaptiveOffset::SAOProcess(SAOParam* pcSaoParam)
    1690 {
    1691   {
    1692     m_uiSaoBitIncreaseY = max(g_bitDepthY - 10, 0);
    1693     m_uiSaoBitIncreaseC = max(g_bitDepthC - 10, 0);
    1694 
    1695     if(m_bUseNIF)
    1696     {
    1697       m_pcPic->getPicYuvRec()->copyToPic(m_pcYuvTmp);
    1698     }
    1699     if (m_saoLcuBasedOptimization)
    1700     {
    1701       pcSaoParam->oneUnitFlag[0] = 0; 
    1702       pcSaoParam->oneUnitFlag[1] = 0; 
    1703       pcSaoParam->oneUnitFlag[2] = 0; 
    1704     }
    1705     Int iY  = 0;
    1706     {
    1707       processSaoUnitAll( pcSaoParam->saoLcuParam[iY], pcSaoParam->oneUnitFlag[iY], iY);
    1708     }
    1709     {
    1710        processSaoUnitAll( pcSaoParam->saoLcuParam[1], pcSaoParam->oneUnitFlag[1], 1);//Cb
    1711        processSaoUnitAll( pcSaoParam->saoLcuParam[2], pcSaoParam->oneUnitFlag[2], 2);//Cr
    1712     }
    1713     m_pcPic = NULL;
    1714   }
    1715 }
    1716 
    1717 Pel* TComSampleAdaptiveOffset::getPicYuvAddr(TComPicYuv* pcPicYuv, Int iYCbCr, Int iAddr)
    1718 {
    1719   switch (iYCbCr)
    1720   {
    1721   case 0:
    1722     return pcPicYuv->getLumaAddr(iAddr);
    1723     break;
    1724   case 1:
    1725     return pcPicYuv->getCbAddr(iAddr);
    1726     break;
    1727   case 2:
    1728     return pcPicYuv->getCrAddr(iAddr);
    1729     break;
    1730   default:
    1731     return NULL;
    1732     break;
    1733   }
    1734 }
    1735 /** Process SAO all units
    1736  * \param saoLcuParam SAO LCU parameters
    1737  * \param oneUnitFlag one unit flag
    1738  * \param yCbCr color componet index
    1739  */
    1740 Void TComSampleAdaptiveOffset::processSaoUnitAll(SaoLcuParam* saoLcuParam, Bool oneUnitFlag, Int yCbCr)
    1741 {
    1742   Pel *pRec;
    1743   Int picWidthTmp;
    1744 
    1745   if (yCbCr == 0)
    1746   {
    1747     pRec        = m_pcPic->getPicYuvRec()->getLumaAddr();
    1748     picWidthTmp = m_iPicWidth;
    1749   }
    1750   else if (yCbCr == 1)
    1751   {
    1752     pRec        = m_pcPic->getPicYuvRec()->getCbAddr();
    1753     picWidthTmp = m_iPicWidth>>1;
    1754   }
    1755   else
    1756   {
    1757     pRec        = m_pcPic->getPicYuvRec()->getCrAddr();
    1758     picWidthTmp = m_iPicWidth>>1;
    1759   }
    1760 
    1761   memcpy(m_pTmpU1, pRec, sizeof(Pel)*picWidthTmp);
    1762 
    1763   Int  i;
    1764   UInt edgeType;
    1765   Pel* ppLumaTable = NULL;
    1766   Pel* pClipTable = NULL;
    1767   Int* pOffsetBo = NULL;
    1768   Int  typeIdx;
    1769 
    1770   Int offset[LUMA_GROUP_NUM+1];
    1771   Int idxX;
    1772   Int idxY;
    1773   Int addr;
    1774   Int frameWidthInCU = m_pcPic->getFrameWidthInCU();
    1775   Int frameHeightInCU = m_pcPic->getFrameHeightInCU();
    1776   Int stride;
    1777   Pel *tmpUSwap;
    1778   Int isChroma = (yCbCr == 0) ? 0:1;
    1779   Bool mergeLeftFlag;
    1780   Int saoBitIncrease = (yCbCr == 0) ? m_uiSaoBitIncreaseY : m_uiSaoBitIncreaseC;
    1781 
    1782   pOffsetBo = (yCbCr==0) ? m_iOffsetBo : m_iChromaOffsetBo;
    1783 
    1784   offset[0] = 0;
    1785   for (idxY = 0; idxY< frameHeightInCU; idxY++)
    1786   {
    1787     addr = idxY * frameWidthInCU;
    1788     if (yCbCr == 0)
    1789     {
    1790       pRec  = m_pcPic->getPicYuvRec()->getLumaAddr(addr);
    1791       stride = m_pcPic->getStride();
    1792       picWidthTmp = m_iPicWidth;
    1793     }
    1794     else if (yCbCr == 1)
    1795     {
    1796       pRec  = m_pcPic->getPicYuvRec()->getCbAddr(addr);
    1797       stride = m_pcPic->getCStride();
    1798       picWidthTmp = m_iPicWidth>>1;
    1799     }
    1800     else
    1801     {
    1802       pRec  = m_pcPic->getPicYuvRec()->getCrAddr(addr);
    1803       stride = m_pcPic->getCStride();
    1804       picWidthTmp = m_iPicWidth>>1;
    1805     }
    1806 
    1807     //     pRec += iStride*(m_uiMaxCUHeight-1);
    1808     for (i=0;i<(m_uiMaxCUHeight>>isChroma)+1;i++)
    1809     {
    1810       m_pTmpL1[i] = pRec[0];
    1811       pRec+=stride;
    1812     }
    1813     pRec-=(stride<<1);
    1814 
    1815     memcpy(m_pTmpU2, pRec, sizeof(Pel)*picWidthTmp);
    1816 
    1817     for (idxX = 0; idxX < frameWidthInCU; idxX++)
    1818     {
    1819       addr = idxY * frameWidthInCU + idxX;
    1820 
    1821       if (oneUnitFlag)
    1822       {
    1823         typeIdx = saoLcuParam[0].typeIdx;
    1824         mergeLeftFlag = (addr == 0)? 0:1;
    1825       }
    1826       else
    1827       {
    1828         typeIdx = saoLcuParam[addr].typeIdx;
    1829         mergeLeftFlag = saoLcuParam[addr].mergeLeftFlag;
    1830       }
    1831       if (typeIdx>=0)
    1832       {
    1833         if (!mergeLeftFlag)
    1834         {
    1835 
    1836           if (typeIdx == SAO_BO)
    1837           {
    1838             for (i=0; i<SAO_MAX_BO_CLASSES+1;i++)
    1839             {
    1840               offset[i] = 0;
    1841             }
    1842             for (i=0; i<saoLcuParam[addr].length; i++)
    1843             {
    1844               offset[ (saoLcuParam[addr].subTypeIdx +i)%SAO_MAX_BO_CLASSES  +1] = saoLcuParam[addr].offset[i] << saoBitIncrease;
    1845             }
    1846 
    1847             ppLumaTable = (yCbCr==0)?m_lumaTableBo:m_chromaTableBo;
    1848             pClipTable = (yCbCr==0)?m_pClipTable:m_pChromaClipTable;
    1849 
    1850             Int bitDepth = (yCbCr==0) ? g_bitDepthY : g_bitDepthC;
    1851             for (i=0;i<(1<<bitDepth);i++)
    1852             {
    1853               pOffsetBo[i] = pClipTable[i + offset[ppLumaTable[i]]];
    1854             }
    1855 
    1856           }
    1857           if (typeIdx == SAO_EO_0 || typeIdx == SAO_EO_1 || typeIdx == SAO_EO_2 || typeIdx == SAO_EO_3)
    1858           {
    1859             for (i=0;i<saoLcuParam[addr].length;i++)
    1860             {
    1861               offset[i+1] = saoLcuParam[addr].offset[i] << saoBitIncrease;
    1862             }
    1863             for (edgeType=0;edgeType<6;edgeType++)
    1864             {
    1865               m_iOffsetEo[edgeType]= offset[m_auiEoTable[edgeType]];
    1866             }
    1867           }
    1868         }
    1869         processSaoCu(addr, typeIdx, yCbCr);
    1870       }
    1871       else
    1872       {
    1873         if (idxX != (frameWidthInCU-1))
    1874         {
    1875           if (yCbCr == 0)
    1876           {
    1877             pRec  = m_pcPic->getPicYuvRec()->getLumaAddr(addr);
    1878             stride = m_pcPic->getStride();
    1879           }
    1880           else if (yCbCr == 1)
    1881           {
    1882             pRec  = m_pcPic->getPicYuvRec()->getCbAddr(addr);
    1883             stride = m_pcPic->getCStride();
    1884           }
    1885           else
    1886           {
    1887             pRec  = m_pcPic->getPicYuvRec()->getCrAddr(addr);
    1888             stride = m_pcPic->getCStride();
    1889           }
    1890           Int widthShift = m_uiMaxCUWidth>>isChroma;
    1891           for (i=0;i<(m_uiMaxCUHeight>>isChroma)+1;i++)
    1892           {
    1893             m_pTmpL1[i] = pRec[widthShift-1];
    1894             pRec+=stride;
    1895           }
    1896         }
    1897       }
    1898     }
    1899     tmpUSwap = m_pTmpU1;
    1900     m_pTmpU1 = m_pTmpU2;
    1901     m_pTmpU2 = tmpUSwap;
    1902   }
    1903 
    1904 }
    1905 /** Reset SAO LCU part
    1906  * \param saoLcuParam
    1907  */
    1908 Void TComSampleAdaptiveOffset::resetLcuPart(SaoLcuParam* saoLcuParam)
    1909 {
    1910   Int i,j;
    1911   for (i=0;i<m_iNumCuInWidth*m_iNumCuInHeight;i++)
    1912   {
    1913     saoLcuParam[i].mergeUpFlag     =  1;
    1914     saoLcuParam[i].mergeLeftFlag =  0;
    1915     saoLcuParam[i].partIdx   =  0;
    1916     saoLcuParam[i].typeIdx      = -1;
    1917     for (j=0;j<MAX_NUM_SAO_OFFSETS;j++)
    1918     {
    1919       saoLcuParam[i].offset[j] = 0;
    1920     }
    1921     saoLcuParam[i].subTypeIdx = 0;
    1922   }
    1923 }
    1924 
    1925 /** convert QP part to SAO unit
    1926 * \param saoParam SAO parameter
    1927 * \param partIdx SAO part index
    1928 * \param yCbCr color component index
    1929  */
    1930 Void TComSampleAdaptiveOffset::convertQT2SaoUnit(SAOParam *saoParam, UInt partIdx, Int yCbCr)
    1931 {
    1932 
    1933   SAOQTPart*  saoPart= &(saoParam->psSaoPart[yCbCr][partIdx]);
    1934   if (!saoPart->bSplit)
    1935   {
    1936     convertOnePart2SaoUnit(saoParam, partIdx, yCbCr);
    1937     return;
    1938   }
    1939 
    1940   if (saoPart->PartLevel < m_uiMaxSplitLevel)
    1941   {
    1942     convertQT2SaoUnit(saoParam, saoPart->DownPartsIdx[0], yCbCr);
    1943     convertQT2SaoUnit(saoParam, saoPart->DownPartsIdx[1], yCbCr);
    1944     convertQT2SaoUnit(saoParam, saoPart->DownPartsIdx[2], yCbCr);
    1945     convertQT2SaoUnit(saoParam, saoPart->DownPartsIdx[3], yCbCr);
    1946   }
    1947 }
    1948 /** convert one SAO part to SAO unit
    1949 * \param saoParam SAO parameter
    1950 * \param partIdx SAO part index
    1951 * \param yCbCr color component index
    1952  */
    1953 Void TComSampleAdaptiveOffset::convertOnePart2SaoUnit(SAOParam *saoParam, UInt partIdx, Int yCbCr)
    1954 {
    1955   Int j;
    1956   Int idxX;
    1957   Int idxY;
    1958   Int addr;
    1959   Int frameWidthInCU = m_pcPic->getFrameWidthInCU();
    1960   SAOQTPart* saoQTPart = saoParam->psSaoPart[yCbCr];
    1961   SaoLcuParam* saoLcuParam = saoParam->saoLcuParam[yCbCr];
    1962 
    1963   for (idxY = saoQTPart[partIdx].StartCUY; idxY<= saoQTPart[partIdx].EndCUY; idxY++)
    1964   {
    1965     for (idxX = saoQTPart[partIdx].StartCUX; idxX<= saoQTPart[partIdx].EndCUX; idxX++)
    1966     {
    1967       addr = idxY * frameWidthInCU + idxX;
    1968       saoLcuParam[addr].partIdxTmp = (Int)partIdx;
    1969       saoLcuParam[addr].typeIdx    = saoQTPart[partIdx].iBestType;
    1970       saoLcuParam[addr].subTypeIdx = saoQTPart[partIdx].subTypeIdx;
    1971       if (saoLcuParam[addr].typeIdx!=-1)
    1972       {
    1973         saoLcuParam[addr].length    = saoQTPart[partIdx].iLength;
    1974         for (j=0;j<MAX_NUM_SAO_OFFSETS;j++)
    1975         {
    1976           saoLcuParam[addr].offset[j] = saoQTPart[partIdx].iOffset[j];
    1977         }
    1978       }
    1979       else
    1980       {
    1981         saoLcuParam[addr].length    = 0;
    1982         saoLcuParam[addr].subTypeIdx = saoQTPart[partIdx].subTypeIdx;
    1983         for (j=0;j<MAX_NUM_SAO_OFFSETS;j++)
    1984         {
    1985           saoLcuParam[addr].offset[j] = 0;
    1986         }
    1987       }
    1988     }
    1989   }
    1990 }
    1991 
    1992 Void TComSampleAdaptiveOffset::resetSaoUnit(SaoLcuParam* saoUnit)
    1993 {
    1994   saoUnit->partIdx       = 0;
    1995   saoUnit->partIdxTmp    = 0;
    1996   saoUnit->mergeLeftFlag = 0;
    1997   saoUnit->mergeUpFlag   = 0;
    1998   saoUnit->typeIdx       = -1;
    1999   saoUnit->length        = 0;
    2000   saoUnit->subTypeIdx    = 0;
    2001 
    2002   for (Int i=0;i<4;i++)
    2003   {
    2004     saoUnit->offset[i] = 0;
    2005   }
    2006 }
    2007 
    2008 Void TComSampleAdaptiveOffset::copySaoUnit(SaoLcuParam* saoUnitDst, SaoLcuParam* saoUnitSrc )
    2009 {
    2010   saoUnitDst->mergeLeftFlag = saoUnitSrc->mergeLeftFlag;
    2011   saoUnitDst->mergeUpFlag   = saoUnitSrc->mergeUpFlag;
    2012   saoUnitDst->typeIdx       = saoUnitSrc->typeIdx;
    2013   saoUnitDst->length        = saoUnitSrc->length;
    2014 
    2015   saoUnitDst->subTypeIdx  = saoUnitSrc->subTypeIdx;
    2016   for (Int i=0;i<4;i++)
    2017   {
    2018     saoUnitDst->offset[i] = saoUnitSrc->offset[i];
    2019   }
    2020 }
    2021 #endif
     699
    2022700/** PCM LF disable process.
    2023701 * \param pcPic picture (TComPic) pointer
  • branches/SHM-5.0-dev/source/Lib/TLibCommon/TComSampleAdaptiveOffset.h

    r540 r593  
    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 *
     
    4545//! \{
    4646
    47 
    48 #if HM_CLEANUP_SAO
    4947// ====================================================================================================================
    5048// Constants
     
    105103
    106104};
    107 #else
    108 
    109 // ====================================================================================================================
    110 // Constants
    111 // ====================================================================================================================
    112 
    113 #define SAO_MAX_DEPTH                 4
    114 #define SAO_BO_BITS                   5
    115 #define LUMA_GROUP_NUM                (1<<SAO_BO_BITS)
    116 #define MAX_NUM_SAO_OFFSETS           4
    117 #define MAX_NUM_SAO_CLASS             33
    118 // ====================================================================================================================
    119 // Class definition
    120 // ====================================================================================================================
    121 
    122 /// Sample Adaptive Offset class
    123 class TComSampleAdaptiveOffset
    124 {
    125 protected:
    126   TComPic*          m_pcPic;
    127 
    128   static const UInt m_uiMaxDepth;
    129   static const Int m_aiNumCulPartsLevel[5];
    130   static const UInt m_auiEoTable[9];
    131   Int *m_iOffsetBo;
    132   Int *m_iChromaOffsetBo;
    133   Int m_iOffsetEo[LUMA_GROUP_NUM];
    134 
    135   Int  m_iPicWidth;
    136   Int  m_iPicHeight;
    137   UInt m_uiMaxSplitLevel;
    138   UInt m_uiMaxCUWidth;
    139   UInt m_uiMaxCUHeight;
    140   Int  m_iNumCuInWidth;
    141   Int  m_iNumCuInHeight;
    142   Int  m_iNumTotalParts;
    143   static const Int m_iNumClass[MAX_NUM_SAO_TYPE];
    144 
    145   UInt m_uiSaoBitIncreaseY;
    146   UInt m_uiSaoBitIncreaseC;  //for chroma
    147   UInt m_uiQP;
    148 
    149   Pel   *m_pClipTable;
    150   Pel   *m_pClipTableBase;
    151   Pel   *m_lumaTableBo;
    152   Pel   *m_pChromaClipTable;
    153   Pel   *m_pChromaClipTableBase;
    154   Pel   *m_chromaTableBo;
    155   Int   *m_iUpBuff1;
    156   Int   *m_iUpBuff2;
    157   Int   *m_iUpBufft;
    158   Int   *ipSwap;
    159   Bool  m_bUseNIF;       //!< true for performing non-cross slice boundary ALF
    160   TComPicYuv* m_pcYuvTmp;    //!< temporary picture buffer pointer when non-across slice/tile boundary SAO is enabled
    161 
    162   Pel* m_pTmpU1;
    163   Pel* m_pTmpU2;
    164   Pel* m_pTmpL1;
    165   Pel* m_pTmpL2;
    166   Int     m_maxNumOffsetsPerPic;
    167   Bool    m_saoLcuBoundary;
    168   Bool    m_saoLcuBasedOptimization;
    169 
    170   Void xPCMRestoration        (TComPic* pcPic);
    171   Void xPCMCURestoration      (TComDataCU* pcCU, UInt uiAbsZorderIdx, UInt uiDepth);
    172   Void xPCMSampleRestoration  (TComDataCU* pcCU, UInt uiAbsZorderIdx, UInt uiDepth, TextType ttText);
    173 public:
    174   TComSampleAdaptiveOffset         ();
    175   virtual ~TComSampleAdaptiveOffset();
    176 
    177   Void create( UInt uiSourceWidth, UInt uiSourceHeight, UInt uiMaxCUWidth, UInt uiMaxCUHeight );
    178   Void destroy ();
    179 
    180   Int  convertLevelRowCol2Idx(Int level, Int row, Int col);
    181 
    182   Void initSAOParam   (SAOParam *pcSaoParam, Int iPartLevel, Int iPartRow, Int iPartCol, Int iParentPartIdx, Int StartCUX, Int EndCUX, Int StartCUY, Int EndCUY, Int iYCbCr);
    183   Void allocSaoParam  (SAOParam* pcSaoParam);
    184   Void resetSAOParam  (SAOParam *pcSaoParam);
    185   static Void freeSaoParam   (SAOParam *pcSaoParam);
    186  
    187   Void SAOProcess(SAOParam* pcSaoParam);
    188   Void processSaoCu(Int iAddr, Int iSaoType, Int iYCbCr);
    189   Pel* getPicYuvAddr(TComPicYuv* pcPicYuv, Int iYCbCr,Int iAddr = 0);
    190 
    191   Void processSaoCuOrg(Int iAddr, Int iPartIdx, Int iYCbCr);  //!< LCU-basd SAO process without slice granularity
    192   Void createPicSaoInfo(TComPic* pcPic);
    193   Void destroyPicSaoInfo();
    194   Void processSaoBlock(Pel* pDec, Pel* pRest, Int stride, Int iSaoType, UInt width, UInt height, Bool* pbBorderAvail, Int iYCbCr);
    195 
    196   Void resetLcuPart(SaoLcuParam* saoLcuParam);
    197   Void convertQT2SaoUnit(SAOParam* saoParam, UInt partIdx, Int yCbCr);
    198   Void convertOnePart2SaoUnit(SAOParam *saoParam, UInt partIdx, Int yCbCr);
    199   Void processSaoUnitAll(SaoLcuParam* saoLcuParam, Bool oneUnitFlag, Int yCbCr);
    200   Void setSaoLcuBoundary (Bool bVal)  {m_saoLcuBoundary = bVal;}
    201   Bool getSaoLcuBoundary ()           {return m_saoLcuBoundary;}
    202   Void setSaoLcuBasedOptimization (Bool bVal)  {m_saoLcuBasedOptimization = bVal;}
    203   Bool getSaoLcuBasedOptimization ()           {return m_saoLcuBasedOptimization;}
    204   Void resetSaoUnit(SaoLcuParam* saoUnit);
    205   Void copySaoUnit(SaoLcuParam* saoUnitDst, SaoLcuParam* saoUnitSrc );
    206   Void PCMLFDisableProcess    ( TComPic* pcPic);                        ///< interface function for ALF process
    207 };
    208 
    209 #endif
    210105
    211106//! \}
  • branches/SHM-5.0-dev/source/Lib/TLibCommon/TComSlice.cpp

    r582 r593  
    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 *
     
    143143  initWpAcDcParam();
    144144  m_saoEnabledFlag = false;
    145 #if HM_CLEANUP_SAO
    146145  m_saoEnabledFlagChroma = false;
    147 #endif
    148146}
    149147
     
    987985{
    988986  TComPic*                 rpcPic;
     987#if !FIX1172
    989988  setAssociatedIRAPPOC(pocCRA);
     989#endif
    990990  Int pocCurr = getPOC();
    991991
     
    12771277  {
    12781278    rpcPic = *(iterPic++);
     1279#if BUGFIX_INTRAPERIOD
     1280    if(!rpcPic->getReconMark())
     1281    {
     1282      continue;
     1283    }
     1284#endif
    12791285    if (rpcPic->getPOC() == this->getPOC())
    12801286    {
     
    13731379  }
    13741380}
     1381
     1382
    13751383
    13761384/** Function for applying picture marking based on the Reference Picture Set in pReferencePictureSet.
     
    21762184{
    21772185  // For layer 0
    2178   setNumLayersInIdList(0, 1);
    2179   setLayerSetLayerIdList(0, 0, 0);
    2180 
     2186  m_numLayerInIdList[0] = 1;
     2187  m_layerSetLayerIdList[0][0] = 0;
     2188 
    21812189  // For other layers
    21822190  Int i, m, n;
    2183   for( i = 1; i <= getNumLayerSets() - 1; i++ )
     2191  for( i = 1; i <= m_numLayerSets - 1; i++ )
    21842192  {
    21852193    n = 0;
    2186     for( m = 0; m <= this->getMaxLayerId(); m++)
    2187     {
    2188       if(this->getLayerIdIncludedFlag(i, m))
    2189       {
    2190         setLayerSetLayerIdList(i, n, m);
     2194    for( m = 0; m <= m_maxLayerId; m++)
     2195    {
     2196      if( m_layerIdIncludedFlag[i][m] )
     2197      {
     2198        m_layerSetLayerIdList[i][n] = m;
    21912199        n++;
    21922200      }
    21932201    }
    2194     setNumLayersInIdList(i, n);
     2202    m_numLayerInIdList[i] = n;
    21952203  }
    21962204}
     
    25052513, m_qpBDOffsetY               (  0)
    25062514, m_qpBDOffsetC               (  0)
    2507 , m_useLossless               (false)
    25082515, m_uiPCMBitDepthLuma         (  8)
    25092516, m_uiPCMBitDepthChroma       (  8)
  • branches/SHM-5.0-dev/source/Lib/TLibCommon/TComSlice.h

    r582 r593  
    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 *
     
    714714  UInt    getNumReorderPics(UInt tLayer)                        { return m_numReorderPics[tLayer]; }
    715715 
    716   Void    setMaxDecPicBuffering(UInt v, UInt tLayer)            { m_uiMaxDecPicBuffering[tLayer] = v;    }
     716  Void    setMaxDecPicBuffering(UInt v, UInt tLayer)            { assert(tLayer < MAX_TLAYER); m_uiMaxDecPicBuffering[tLayer] = v;    }
    717717  UInt    getMaxDecPicBuffering(UInt tLayer)                    { return m_uiMaxDecPicBuffering[tLayer]; }
    718718 
     
    13201320  Int         m_qpBDOffsetC;
    13211321
    1322   Bool        m_useLossless;
    1323 
    13241322  UInt        m_uiPCMBitDepthLuma;
    13251323  UInt        m_uiPCMBitDepthChroma;
     
    13401338  Bool        m_scalingListEnabledFlag;
    13411339  Bool        m_scalingListPresentFlag;
    1342 
    13431340  TComScalingList*     m_scalingList;   //!< ScalingList class pointer
    1344 
    13451341  UInt        m_uiMaxDecPicBuffering[MAX_TLAYER];
    13461342  UInt        m_uiMaxLatencyIncrease[MAX_TLAYER];  // Really max latency increase plus 1 (value 0 expresses no limit)
     
    14561452  UInt getMaxTrSize   ()         { return  m_uiMaxTrSize;   }
    14571453 
    1458   // Tool list
    1459   Bool getUseLossless ()         { return m_useLossless; }
    1460   Void setUseLossless ( Bool b ) { m_useLossless  = b; }
    1461  
    14621454  // AMP accuracy
    14631455  Int       getAMPAcc   ( UInt uiDepth ) { return m_iAMPAcc[uiDepth]; }
     
    14991491#endif
    15001492  TComScalingList* getScalingList ()       { return m_scalingList; }               //!< get ScalingList class pointer in SPS
    1501 
    15021493  UInt getMaxDecPicBuffering  (UInt tlayer)            { return m_uiMaxDecPicBuffering[tlayer]; }
    1503   Void setMaxDecPicBuffering  ( UInt ui, UInt tlayer ) { m_uiMaxDecPicBuffering[tlayer] = ui;   }
     1494  Void setMaxDecPicBuffering  ( UInt ui, UInt tlayer ) { assert(tlayer < MAX_TLAYER);  m_uiMaxDecPicBuffering[tlayer] = ui;   }
    15041495  UInt getMaxLatencyIncrease  (UInt tlayer)            { return m_uiMaxLatencyIncrease[tlayer];   }
    15051496  Void setMaxLatencyIncrease  ( UInt ui , UInt tlayer) { m_uiMaxLatencyIncrease[tlayer] = ui;      }
  • branches/SHM-5.0-dev/source/Lib/TLibCommon/TComTrQuant.cpp

    r540 r593  
    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 *
     
    10821082    UInt uiLog2TrSize = g_aucConvertToBit[ iWidth ] + 2;
    10831083    Int scalingListType = (pcCU->isIntra(uiAbsPartIdx) ? 0 : 3) + g_eTTable[(Int)eTType];
    1084     assert(scalingListType < 6);
     1084    assert(scalingListType < SCALING_LIST_NUM);
    10851085    Int *piQuantCoeff = 0;
    10861086    piQuantCoeff = getQuantCoeff(scalingListType,m_cQP.m_iRem,uiLog2TrSize-2);
     
    13211321    Pel* pResi = rpcResidual + uiAddr;
    13221322    Int scalingListType = (pcCU->isIntra(uiAbsPartIdx) ? 0 : 3) + g_eTTable[(Int)eTxt];
    1323     assert(scalingListType < 6);
     1323    assert(scalingListType < SCALING_LIST_NUM);
    13241324    invtransformNxN( pcCU->getCUTransquantBypass(uiAbsPartIdx), eTxt, REG_DCT, pResi, uiStride, rpcCoeff, uiWidth, uiHeight, scalingListType, pcCU->getTransformSkip(uiAbsPartIdx, eTxt) );
    13251325  }
     
    15221522  const UInt uiMaxNumCoeff       = uiWidth * uiHeight;
    15231523  Int scalingListType = (pcCU->isIntra(uiAbsPartIdx) ? 0 : 3) + g_eTTable[(Int)eTType];
    1524   assert(scalingListType < 6);
     1524  assert(scalingListType < SCALING_LIST_NUM);
    15251525 
    15261526  Int iQBits = QUANT_SHIFT + m_cQP.m_iPer + iTransformShift;                   // Right shift of non-RDOQ quantizer;  level = (coeff*uiQ + offset)>>q_bits
  • branches/SHM-5.0-dev/source/Lib/TLibCommon/TComTrQuant.h

    r540 r593  
    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/SHM-5.0-dev/source/Lib/TLibCommon/TComWeightPrediction.cpp

    r313 r593  
    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/SHM-5.0-dev/source/Lib/TLibCommon/TComWeightPrediction.h

    r442 r593  
    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/SHM-5.0-dev/source/Lib/TLibCommon/TComYuv.cpp

    r345 r593  
    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 *
     
    604604    {
    605605#if DISABLING_CLIP_FOR_BIPREDME
    606       pDst[x ] = (pDst[x ]<<1) - pSrc[x ] ;
     606      pDst[x ] = 2 * pDst[x] - pSrc[x];
    607607#else
    608       pDst[x ] = Clip( (pDst[x ]<<1) - pSrc[x ] );
     608      pDst[x ] = ClipY(2 * pDst[x] - pSrc[x]);
    609609#endif
    610610    }
     
    624624    {
    625625#if DISABLING_CLIP_FOR_BIPREDME
    626       pDstU[x ] = (pDstU[x ]<<1) - pSrcU[x ] ;
    627       pDstV[x ] = (pDstV[x ]<<1) - pSrcV[x ] ;
     626      pDstU[x ] = 2 * pDstU[x] - pSrcU[x];
     627      pDstV[x ] = 2 * pDstV[x] - pSrcV[x];
    628628#else
    629       pDstU[x ] = Clip( (pDstU[x ]<<1) - pSrcU[x ] );
    630       pDstV[x ] = Clip( (pDstV[x ]<<1) - pSrcV[x ] );
     629      pDstU[x ] = ClipC(2 * pDstU[x] - pSrcU[x]);
     630      pDstV[x ] = ClipC(2 * pDstV[x] - pSrcV[x]);
    631631#endif
    632632    }
  • branches/SHM-5.0-dev/source/Lib/TLibCommon/TComYuv.h

    r345 r593  
    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/SHM-5.0-dev/source/Lib/TLibCommon/TypeDef.h

    r583 r593  
    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#define RESOLUTION_BASED_DPB             1      ///< JCTVC-P0192: Assign layers to sub-DPBs based on the rep_format() signaled in the VPS
    6060#define SUB_BITSTREAM_PROPERTY_SEI       1      ///< JCTVC-P0204: Sub-bitstream property SEI message
     61#if SUB_BITSTREAM_PROPERTY_SEI
     62#define MAX_SUB_STREAMS                  1024
     63#endif
    6164#define O0109_O0199_FLAGS_TO_VUI         1      ///< JCTVC-O0109, O0199: move single_layer_for_non_irap_flag and higher_layer_flag to vps_vui
    6265#define O0109_VIEW_ID_LEN                1      ///< JCTVC-O0109: view_id_len_minus1 to view_id_len, and add constraint (1<<view_id_len) is greater than or equal to NumViews
     
    112115#if VPS_EXTNS
    113116#define VPS_EXTN_MASK_AND_DIM_INFO       1      ///< Include avc_base_layer_flag, splitting_flag, scalability mask and dimension related info
     117#if VPS_EXTN_MASK_AND_DIM_INFO
     118#define MAX_VPS_NUM_SCALABILITY_TYPES    16
     119#endif
    114120#define VPS_EXTN_OP_LAYER_SETS           1      ///< Include output layer sets in VPS extension
    115121#define VPS_EXTN_PROFILE_INFO            1      ///< Include profile information for layer sets in VPS extension
     
    222228#define O0149_CROSS_LAYER_BLA_FLAG       1      ///< JCTVC-O0149: signal cross_layer_bla_flag in slice header
    223229
     230#if VIEW_ID_RELATED_SIGNALING
     231/// scalability types
     232enum ScalabilityType
     233{
     234  VIEW_ORDER_INDEX  = 1,
     235  SCALABILITY_ID = 2,
     236};
     237#endif
     238
    224239#else
    225240#define SYNTAX_OUTPUT                    0
     
    229244//! \ingroup TLibCommon
    230245//! \{
    231 
    232 #define HM_CLEANUP_SAO                  1  ///< JCTVC-N0230, 1) three SAO encoder-only software bugfixes. 2) new SAO implementation without picture quadtree, fine-grained slice legacies, and other redundancies.
    233 #if HM_CLEANUP_SAO 
     246#define BUGFIX_INTRAPERIOD 1
    234247#define SAO_ENCODE_ALLOW_USE_PREDEBLOCK 1
    235 #endif
     248
     249#define FIX1172 1 ///< fix ticket #1172
    236250
    237251#define MAX_NUM_PICS_IN_SOP           1024
     
    240254#define MAX_NESTING_NUM_LAYER       64
    241255
    242 #if VPS_EXTN_MASK_AND_DIM_INFO
    243 #define MAX_VPS_NUM_SCALABILITY_TYPES             16
    244 #endif
     256#if VPS_RENAME
    245257#define MAX_VPS_OP_LAYER_SETS_PLUS1               3
    246 #if VPS_RENAME
    247258#define MAX_VPS_LAYER_SETS_PLUS1                  1024
    248259#define MAX_VPS_LAYER_ID_PLUS1                    MAX_LAYERS
     
    253264#endif
    254265
    255 #if SUB_BITSTREAM_PROPERTY_SEI
    256 #define MAX_SUB_STREAMS                           1024
    257 #endif
    258 
    259266#define MAX_CPB_CNT                     32  ///< Upper bound of (cpb_cnt_minus1 + 1)
    260267#if O0137_MAX_LAYERID
     
    277284#define C1FLAG_NUMBER               8 // maximum number of largerThan1 flag coded in one chunk :  16 in HM5
    278285#define C2FLAG_NUMBER               1 // maximum number of largerThan2 flag coded in one chunk:  16 in HM5
    279 #if !HM_CLEANUP_SAO
    280 #define REMOVE_SAO_LCU_ENC_CONSTRAINTS_3 1  ///< disable the encoder constraint that conditionally disable SAO for chroma for entire slice in interleaved mode
    281 #endif
    282286#define SAO_ENCODING_CHOICE              1  ///< I0184: picture early termination
    283287#if SAO_ENCODING_CHOICE
     
    383387typedef       bool                Bool;
    384388
     389#ifdef __arm__
     390typedef       signed char         Char;
     391#else
    385392typedef       char                Char;
     393#endif
    386394typedef       unsigned char       UChar;
    387395typedef       short               Short;
     
    432440};
    433441
    434 #if HM_CLEANUP_SAO
    435442enum SAOComponentIdx
    436443{
     
    523530};
    524531
    525 
    526 #else
    527 #define NUM_DOWN_PART 4
    528 
    529 enum SAOTypeLen
    530 {
    531   SAO_EO_LEN    = 4,
    532   SAO_BO_LEN    = 4,
    533   SAO_MAX_BO_CLASSES = 32
    534 };
    535 
    536 enum SAOType
    537 {
    538   SAO_EO_0 = 0,
    539   SAO_EO_1,
    540   SAO_EO_2,
    541   SAO_EO_3,
    542   SAO_BO,
    543   MAX_NUM_SAO_TYPE
    544 };
    545 
    546 typedef struct _SaoQTPart
    547 {
    548   Int         iBestType;
    549   Int         iLength;
    550   Int         subTypeIdx ;                 ///< indicates EO class or BO band position
    551   Int         iOffset[4];
    552   Int         StartCUX;
    553   Int         StartCUY;
    554   Int         EndCUX;
    555   Int         EndCUY;
    556 
    557   Int         PartIdx;
    558   Int         PartLevel;
    559   Int         PartCol;
    560   Int         PartRow;
    561 
    562   Int         DownPartsIdx[NUM_DOWN_PART];
    563   Int         UpPartIdx;
    564 
    565   Bool        bSplit;
    566 
    567   //---- encoder only start -----//
    568   Bool        bProcessed;
    569   Double      dMinCost;
    570   Int64       iMinDist;
    571   Int         iMinRate;
    572   //---- encoder only end -----//
    573 } SAOQTPart;
    574 
    575 typedef struct _SaoLcuParam
    576 {
    577   Bool       mergeUpFlag;
    578   Bool       mergeLeftFlag;
    579   Int        typeIdx;
    580   Int        subTypeIdx;                  ///< indicates EO class or BO band position
    581   Int        offset[4];
    582   Int        partIdx;
    583   Int        partIdxTmp;
    584   Int        length;
    585 } SaoLcuParam;
    586 
    587 struct SAOParam
    588 {
    589   Bool       bSaoFlag[2];
    590   SAOQTPart* psSaoPart[3];
    591   Int        iMaxSplitLevel;
    592   Bool         oneUnitFlag[3];
    593   SaoLcuParam* saoLcuParam[3];
    594   Int          numCuInHeight;
    595   Int          numCuInWidth;
    596   ~SAOParam();
    597 };
    598 #endif
    599532/// parameters for deblocking filter
    600533typedef struct _LFCUParam
     
    788721  };
    789722}
    790 #if VIEW_ID_RELATED_SIGNALING
    791 /// scalability types
    792   enum ScalabilityType
    793   {
    794     VIEW_ORDER_INDEX  = 1,
    795     SCALABILITY_ID = 2,
    796   };
    797 #endif
    798723//! \}
    799724
Note: See TracChangeset for help on using the changeset viewer.