Changeset 595 in SHVCSoftware for trunk/source/Lib


Ignore:
Timestamp:
2 Feb 2014, 06:01:53 (11 years ago)
Author:
seregin
Message:

merge with SHM-5.0-dev branch

Location:
trunk
Files:
127 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/source

  • trunk/source/Lib/TAppCommon/program_options_lite.cpp

    r540 r595  
    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 *
  • trunk/source/Lib/TAppCommon/program_options_lite.h

    r313 r595  
    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 *
  • trunk/source/Lib/TLibCommon/AccessUnit.h

    r313 r595  
    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 *
  • trunk/source/Lib/TLibCommon/CommonDef.h

    r588 r595  
    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
  • trunk/source/Lib/TLibCommon/ContextModel.cpp

    r313 r595  
    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 *
  • trunk/source/Lib/TLibCommon/ContextModel.h

    r313 r595  
    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 *
  • trunk/source/Lib/TLibCommon/ContextModel3DBuffer.cpp

    r313 r595  
    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 *
  • trunk/source/Lib/TLibCommon/ContextModel3DBuffer.h

    r313 r595  
    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 *
  • trunk/source/Lib/TLibCommon/ContextTables.h

    r345 r595  
    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
  • trunk/source/Lib/TLibCommon/NAL.h

    r540 r595  
    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 *
  • trunk/source/Lib/TLibCommon/SEI.cpp

    r588 r595  
    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 *
  • trunk/source/Lib/TLibCommon/SEI.h

    r588 r595  
    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 *
  • trunk/source/Lib/TLibCommon/TComBitCounter.h

    r313 r595  
    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 *
  • trunk/source/Lib/TLibCommon/TComBitStream.cpp

    r313 r595  
    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 *
  • trunk/source/Lib/TLibCommon/TComBitStream.h

    r313 r595  
    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 *
  • trunk/source/Lib/TLibCommon/TComCABACTables.cpp

    r313 r595  
    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 *
  • trunk/source/Lib/TLibCommon/TComCABACTables.h

    r313 r595  
    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 *
  • trunk/source/Lib/TLibCommon/TComDataCU.cpp

    r588 r595  
    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//! \}
  • trunk/source/Lib/TLibCommon/TComDataCU.h

    r540 r595  
    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
  • trunk/source/Lib/TLibCommon/TComInterpolationFilter.cpp

    r313 r595  
    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 *
  • trunk/source/Lib/TLibCommon/TComInterpolationFilter.h

    r313 r595  
    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 *
  • trunk/source/Lib/TLibCommon/TComList.h

    r313 r595  
    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 *
  • trunk/source/Lib/TLibCommon/TComLoopFilter.cpp

    r442 r595  
    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 *
  • trunk/source/Lib/TLibCommon/TComLoopFilter.h

    r313 r595  
    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 *
  • trunk/source/Lib/TLibCommon/TComMotionInfo.cpp

    r345 r595  
    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 *
  • trunk/source/Lib/TLibCommon/TComMotionInfo.h

    r345 r595  
    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 *
  • trunk/source/Lib/TLibCommon/TComMv.h

    r442 r595  
    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 *
  • trunk/source/Lib/TLibCommon/TComPattern.cpp

    r313 r595  
    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 *
  • trunk/source/Lib/TLibCommon/TComPattern.h

    r313 r595  
    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 *
  • trunk/source/Lib/TLibCommon/TComPic.cpp

    r540 r595  
    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
  • trunk/source/Lib/TLibCommon/TComPic.h

    r540 r595  
    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
  • trunk/source/Lib/TLibCommon/TComPicSym.cpp

    r540 r595  
    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()
  • trunk/source/Lib/TLibCommon/TComPicSym.h

    r540 r595  
    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
  • trunk/source/Lib/TLibCommon/TComPicYuv.cpp

    r494 r595  
    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 *
  • trunk/source/Lib/TLibCommon/TComPicYuv.h

    r494 r595  
    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
  • trunk/source/Lib/TLibCommon/TComPicYuvMD5.cpp

    r313 r595  
    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 *
  • trunk/source/Lib/TLibCommon/TComPrediction.cpp

    r494 r595  
    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{
  • trunk/source/Lib/TLibCommon/TComPrediction.h

    r494 r595  
    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 *
  • trunk/source/Lib/TLibCommon/TComRdCost.cpp

    r540 r595  
    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  }
  • trunk/source/Lib/TLibCommon/TComRdCost.h

    r540 r595  
    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 *
  • trunk/source/Lib/TLibCommon/TComRdCostWeightPrediction.cpp

    r313 r595  
    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 *
  • trunk/source/Lib/TLibCommon/TComRdCostWeightPrediction.h

    r313 r595  
    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 *
  • trunk/source/Lib/TLibCommon/TComRom.cpp

    r588 r595  
    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//! \}
  • trunk/source/Lib/TLibCommon/TComRom.h

    r588 r595  
    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//! \}
  • trunk/source/Lib/TLibCommon/TComSampleAdaptiveOffset.cpp

    r540 r595  
    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
  • trunk/source/Lib/TLibCommon/TComSampleAdaptiveOffset.h

    r540 r595  
    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//! \}
  • trunk/source/Lib/TLibCommon/TComSlice.cpp

    r588 r595  
    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)
  • trunk/source/Lib/TLibCommon/TComSlice.h

    r588 r595  
    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;      }
  • trunk/source/Lib/TLibCommon/TComTrQuant.cpp

    r540 r595  
    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
  • trunk/source/Lib/TLibCommon/TComTrQuant.h

    r540 r595  
    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 *
  • trunk/source/Lib/TLibCommon/TComWeightPrediction.cpp

    r313 r595  
    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 *
  • trunk/source/Lib/TLibCommon/TComWeightPrediction.h

    r442 r595  
    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 *
  • trunk/source/Lib/TLibCommon/TComYuv.cpp

    r345 r595  
    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    }
  • trunk/source/Lib/TLibCommon/TComYuv.h

    r345 r595  
    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 *
  • trunk/source/Lib/TLibCommon/TypeDef.h

    r588 r595  
    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
  • trunk/source/Lib/TLibDecoder/AnnexBread.cpp

    r313 r595  
    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 *
  • trunk/source/Lib/TLibDecoder/AnnexBread.h

    r313 r595  
    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 *
  • trunk/source/Lib/TLibDecoder/NALread.cpp

    r540 r595  
    44 * granted under this license.
    55 *
    6  * Copyright (c) 2010-2013, ITU/ISO/IEC
     6 * Copyright (c) 2010-2014, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
     
    7070        break;
    7171      }
     72      assert(*it_read <= 0x03);
    7273    }
    7374    zeroCount = (*it_read == 0x00) ? zeroCount+1 : 0;
  • trunk/source/Lib/TLibDecoder/NALread.h

    r313 r595  
    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 *
  • trunk/source/Lib/TLibDecoder/SEIread.cpp

    r588 r595  
    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 *
     
    9393    fprintf( g_hTrace, "===========Tone Mapping Info SEI message ===========\n");
    9494    break;
     95  case SEI::SOP_DESCRIPTION:
     96    fprintf( g_hTrace, "=========== SOP Description SEI message ===========\n");
     97    break;
     98  case SEI::SCALABLE_NESTING:
     99    fprintf( g_hTrace, "=========== Scalable Nesting SEI message ===========\n");
     100    break;
     101#if SVC_EXTENSION
    95102#if LAYERS_NOT_PRESENT_SEI
    96103  case SEI::LAYERS_NOT_PRESENT:
     
    98105    break;
    99106#endif
    100   case SEI::SOP_DESCRIPTION:
    101     fprintf( g_hTrace, "=========== SOP Description SEI message ===========\n");
    102     break;
    103107#if N0383_IL_CONSTRAINED_TILE_SETS_SEI
    104108  case SEI::INTER_LAYER_CONSTRAINED_TILE_SETS:
     
    111115      break;
    112116#endif
    113   case SEI::SCALABLE_NESTING:
    114     fprintf( g_hTrace, "=========== Scalable Nesting SEI message ===========\n");
    115     break;
     117#endif //SVC_EXTENSION
    116118  default:
    117119    fprintf( g_hTrace, "=========== Unknown SEI message ===========\n");
     
    259261      xParseSEIToneMappingInfo((SEIToneMappingInfo&) *sei, payloadSize);
    260262      break;
    261 #if LAYERS_NOT_PRESENT_SEI
    262     case SEI::LAYERS_NOT_PRESENT:
    263       if (!vps)
    264       {
    265         printf ("Warning: Found Layers not present SEI message, but no active VPS is available. Ignoring.");
    266       }
    267       else
    268       {
    269         sei = new SEILayersNotPresent;
    270         xParseSEILayersNotPresent((SEILayersNotPresent&) *sei, payloadSize, vps);
    271       }
    272       break;
    273 #endif
    274263    case SEI::SOP_DESCRIPTION:
    275264      sei = new SEISOPDescription;
    276265      xParseSEISOPDescription((SEISOPDescription&) *sei, payloadSize);
    277266      break;
    278 #if N0383_IL_CONSTRAINED_TILE_SETS_SEI
    279     case SEI::INTER_LAYER_CONSTRAINED_TILE_SETS:
    280       sei = new SEIInterLayerConstrainedTileSets;
    281       xParseSEIInterLayerConstrainedTileSets((SEIInterLayerConstrainedTileSets&) *sei, payloadSize);
    282       break;
    283 #endif
    284 #if SUB_BITSTREAM_PROPERTY_SEI
    285    case SEI::SUB_BITSTREAM_PROPERTY:
    286      sei = new SEISubBitstreamProperty;
    287      xParseSEISubBitstreamProperty((SEISubBitstreamProperty&) *sei);
    288      break;
    289 #endif
    290267    case SEI::SCALABLE_NESTING:
    291268      sei = new SEIScalableNesting;
     
    295272      xParseSEIScalableNesting((SEIScalableNesting&) *sei, nalUnitType, payloadSize, sps);
    296273#endif
     274#if SVC_EXTENSION
     275#if LAYERS_NOT_PRESENT_SEI
     276    case SEI::LAYERS_NOT_PRESENT:
     277      if (!vps)
     278      {
     279        printf ("Warning: Found Layers not present SEI message, but no active VPS is available. Ignoring.");
     280      }
     281      else
     282      {
     283        sei = new SEILayersNotPresent;
     284        xParseSEILayersNotPresent((SEILayersNotPresent&) *sei, payloadSize, vps);
     285      }
     286      break;
     287#endif
     288#if N0383_IL_CONSTRAINED_TILE_SETS_SEI
     289    case SEI::INTER_LAYER_CONSTRAINED_TILE_SETS:
     290      sei = new SEIInterLayerConstrainedTileSets;
     291      xParseSEIInterLayerConstrainedTileSets((SEIInterLayerConstrainedTileSets&) *sei, payloadSize);
     292      break;
     293#endif
     294#if SUB_BITSTREAM_PROPERTY_SEI
     295   case SEI::SUB_BITSTREAM_PROPERTY:
     296     sei = new SEISubBitstreamProperty;
     297     xParseSEISubBitstreamProperty((SEISubBitstreamProperty&) *sei);
     298     break;
     299#endif
     300#endif //SVC_EXTENSION
    297301      break;
    298302    default:
     
    499503  if( !pHRD->getSubPicCpbParamsPresentFlag() )
    500504  {
    501     READ_FLAG( code, "rap_cpb_params_present_flag" );                   sei.m_rapCpbParamsPresentFlag = code;
     505    READ_FLAG( code, "irap_cpb_params_present_flag" );                   sei.m_rapCpbParamsPresentFlag = code;
     506  }
     507  if( sei.m_rapCpbParamsPresentFlag )
     508  {
     509    READ_CODE( pHRD->getCpbRemovalDelayLengthMinus1() + 1, code, "cpb_delay_offset" );      sei.m_cpbDelayOffset = code;
     510    READ_CODE( pHRD->getDpbOutputDelayLengthMinus1()  + 1, code, "dpb_delay_offset" );      sei.m_dpbDelayOffset = code;
    502511  }
    503512  //read splicing flag and cpb_removal_delay_delta
     
    506515  READ_CODE( ( pHRD->getCpbRemovalDelayLengthMinus1() + 1 ), code, "au_cpb_removal_delay_delta_minus1" );
    507516  sei.m_auCpbRemovalDelayDelta = code + 1;
    508   if( sei.m_rapCpbParamsPresentFlag )
    509   {
    510     READ_CODE( pHRD->getCpbRemovalDelayLengthMinus1() + 1, code, "cpb_delay_offset" );      sei.m_cpbDelayOffset = code;
    511     READ_CODE( pHRD->getDpbOutputDelayLengthMinus1()  + 1, code, "dpb_delay_offset" );      sei.m_dpbDelayOffset = code;
    512   }
    513517  for( nalOrVcl = 0; nalOrVcl < 2; nalOrVcl ++ )
    514518  {
     
    752756}
    753757
    754 #if LAYERS_NOT_PRESENT_SEI
    755 Void SEIReader::xParseSEILayersNotPresent(SEILayersNotPresent &sei, UInt payloadSize, TComVPS *vps)
    756 {
    757   UInt uiCode;
    758   UInt i = 0;
    759 
    760   READ_UVLC( uiCode,           "lp_sei_active_vps_id" ); sei.m_activeVpsId = uiCode;
    761   assert(vps->getVPSId() == sei.m_activeVpsId);
    762   sei.m_vpsMaxLayers = vps->getMaxLayers();
    763   for (; i < sei.m_vpsMaxLayers; i++)
    764   {
    765     READ_FLAG( uiCode,         "layer_not_present_flag"   ); sei.m_layerNotPresentFlag[i] = uiCode ? true : false;
    766   }
    767   for (; i < MAX_LAYERS; i++)
    768   {
    769     sei.m_layerNotPresentFlag[i] = false;
    770   }
    771   xParseByteAlign();
    772 }
    773 #endif
    774 
    775758Void SEIReader::xParseSEISOPDescription(SEISOPDescription &sei, UInt payloadSize)
    776759{
     
    797780}
    798781
    799 #if N0383_IL_CONSTRAINED_TILE_SETS_SEI
    800 Void SEIReader::xParseSEIInterLayerConstrainedTileSets (SEIInterLayerConstrainedTileSets &sei, UInt payloadSize)
    801 {
    802   UInt uiCode;
    803 
    804   READ_FLAG( uiCode, "il_all_tiles_exact_sample_value_match_flag"   ); sei.m_ilAllTilesExactSampleValueMatchFlag = uiCode;
    805   READ_FLAG( uiCode, "il_one_tile_per_tile_set_flag"                ); sei.m_ilOneTilePerTileSetFlag = uiCode;
    806   if( !sei.m_ilOneTilePerTileSetFlag )
    807   {
    808     READ_UVLC( uiCode, "il_num_sets_in_message_minus1"                ); sei.m_ilNumSetsInMessageMinus1 = uiCode;
    809     if( sei.m_ilNumSetsInMessageMinus1 )
    810     {
    811       READ_FLAG( uiCode, "skipped_tile_set_present_flag"                ); sei.m_skippedTileSetPresentFlag = uiCode;
    812     }
    813     else
    814     {
    815       sei.m_skippedTileSetPresentFlag = false;
    816     }
    817     UInt numSignificantSets = sei.m_ilNumSetsInMessageMinus1 - (sei.m_skippedTileSetPresentFlag ? 1 : 0) + 1;
    818     for( UInt i = 0; i < numSignificantSets; i++ )
    819     {
    820       READ_UVLC( uiCode, "ilcts_id"                                     ); sei.m_ilctsId[i] = uiCode;
    821       READ_UVLC( uiCode, "il_num_tile_rects_in_set_minus1"              ) ;sei.m_ilNumTileRectsInSetMinus1[i] = uiCode;
    822       for( UInt j = 0; j <= sei.m_ilNumTileRectsInSetMinus1[i]; j++ )
    823       {
    824         READ_UVLC( uiCode, "il_top_left_tile_index"                       ); sei.m_ilTopLeftTileIndex[i][j] = uiCode;
    825         READ_UVLC( uiCode, "il_bottom_right_tile_index"                   ); sei.m_ilBottomRightTileIndex[i][j] = uiCode;
    826       }
    827       READ_CODE( 2, uiCode, "ilc_idc"                                   ); sei.m_ilcIdc[i] = uiCode;
    828       if( sei.m_ilAllTilesExactSampleValueMatchFlag )
    829       {
    830         READ_FLAG( uiCode, "il_exact_sample_value_match_flag"             ); sei.m_ilExactSampleValueMatchFlag[i] = uiCode;
    831       }
    832     }
    833   }
    834   else
    835   {
    836     READ_CODE( 2, uiCode, "all_tiles_ilc_idc"                         ); sei.m_allTilesIlcIdc = uiCode;
    837   }
    838 
    839   xParseByteAlign();
    840 }
    841 #endif
    842 #if SUB_BITSTREAM_PROPERTY_SEI
    843 Void SEIReader::xParseSEISubBitstreamProperty(SEISubBitstreamProperty &sei)
    844 {
    845   UInt uiCode;
    846   READ_CODE( 4, uiCode, "active_vps_id" );                      sei.m_activeVpsId = uiCode;
    847   READ_UVLC(    uiCode, "num_additional_sub_streams_minus1" );  sei.m_numAdditionalSubStreams = uiCode + 1;
    848 
    849   for( Int i = 0; i < sei.m_numAdditionalSubStreams; i++ )
    850   {
    851     READ_CODE(  2, uiCode, "sub_bitstream_mode[i]"           ); sei.m_subBitstreamMode[i] = uiCode;
    852     READ_UVLC(     uiCode, "output_layer_set_idx_to_vps[i]"  ); sei.m_outputLayerSetIdxToVps[i] = uiCode;
    853     READ_CODE(  3, uiCode, "highest_sub_layer_id[i]"         ); sei.m_highestSublayerId[i] = uiCode;
    854     READ_CODE( 16, uiCode, "avg_bit_rate[i]"                 ); sei.m_avgBitRate[i] = uiCode;
    855     READ_CODE( 16, uiCode, "max_bit_rate[i]"                 ); sei.m_maxBitRate[i] = uiCode;
    856   }
    857   xParseByteAlign();
    858 }
    859 #endif
    860782#if LAYERS_NOT_PRESENT_SEI
    861783Void SEIReader::xParseSEIScalableNesting(SEIScalableNesting& sei, const NalUnitType nalUnitType, UInt payloadSize, TComVPS *vps, TComSPS *sps)
     
    925847  }
    926848}
     849
     850#if SVC_EXTENSION
     851#if LAYERS_NOT_PRESENT_SEI
     852Void SEIReader::xParseSEILayersNotPresent(SEILayersNotPresent &sei, UInt payloadSize, TComVPS *vps)
     853{
     854  UInt uiCode;
     855  UInt i = 0;
     856
     857  READ_UVLC( uiCode,           "lp_sei_active_vps_id" ); sei.m_activeVpsId = uiCode;
     858  assert(vps->getVPSId() == sei.m_activeVpsId);
     859  sei.m_vpsMaxLayers = vps->getMaxLayers();
     860  for (; i < sei.m_vpsMaxLayers; i++)
     861  {
     862    READ_FLAG( uiCode,         "layer_not_present_flag"   ); sei.m_layerNotPresentFlag[i] = uiCode ? true : false;
     863  }
     864  for (; i < MAX_LAYERS; i++)
     865  {
     866    sei.m_layerNotPresentFlag[i] = false;
     867  }
     868  xParseByteAlign();
     869}
     870#endif
     871#if N0383_IL_CONSTRAINED_TILE_SETS_SEI
     872Void SEIReader::xParseSEIInterLayerConstrainedTileSets (SEIInterLayerConstrainedTileSets &sei, UInt payloadSize)
     873{
     874  UInt uiCode;
     875
     876  READ_FLAG( uiCode, "il_all_tiles_exact_sample_value_match_flag"   ); sei.m_ilAllTilesExactSampleValueMatchFlag = uiCode;
     877  READ_FLAG( uiCode, "il_one_tile_per_tile_set_flag"                ); sei.m_ilOneTilePerTileSetFlag = uiCode;
     878  if( !sei.m_ilOneTilePerTileSetFlag )
     879  {
     880    READ_UVLC( uiCode, "il_num_sets_in_message_minus1"                ); sei.m_ilNumSetsInMessageMinus1 = uiCode;
     881    if( sei.m_ilNumSetsInMessageMinus1 )
     882    {
     883      READ_FLAG( uiCode, "skipped_tile_set_present_flag"                ); sei.m_skippedTileSetPresentFlag = uiCode;
     884    }
     885    else
     886    {
     887      sei.m_skippedTileSetPresentFlag = false;
     888    }
     889    UInt numSignificantSets = sei.m_ilNumSetsInMessageMinus1 - (sei.m_skippedTileSetPresentFlag ? 1 : 0) + 1;
     890    for( UInt i = 0; i < numSignificantSets; i++ )
     891    {
     892      READ_UVLC( uiCode, "ilcts_id"                                     ); sei.m_ilctsId[i] = uiCode;
     893      READ_UVLC( uiCode, "il_num_tile_rects_in_set_minus1"              ) ;sei.m_ilNumTileRectsInSetMinus1[i] = uiCode;
     894      for( UInt j = 0; j <= sei.m_ilNumTileRectsInSetMinus1[i]; j++ )
     895      {
     896        READ_UVLC( uiCode, "il_top_left_tile_index"                       ); sei.m_ilTopLeftTileIndex[i][j] = uiCode;
     897        READ_UVLC( uiCode, "il_bottom_right_tile_index"                   ); sei.m_ilBottomRightTileIndex[i][j] = uiCode;
     898      }
     899      READ_CODE( 2, uiCode, "ilc_idc"                                   ); sei.m_ilcIdc[i] = uiCode;
     900      if( sei.m_ilAllTilesExactSampleValueMatchFlag )
     901      {
     902        READ_FLAG( uiCode, "il_exact_sample_value_match_flag"             ); sei.m_ilExactSampleValueMatchFlag[i] = uiCode;
     903      }
     904    }
     905  }
     906  else
     907  {
     908    READ_CODE( 2, uiCode, "all_tiles_ilc_idc"                         ); sei.m_allTilesIlcIdc = uiCode;
     909  }
     910
     911  xParseByteAlign();
     912}
     913#endif
     914#if SUB_BITSTREAM_PROPERTY_SEI
     915Void SEIReader::xParseSEISubBitstreamProperty(SEISubBitstreamProperty &sei)
     916{
     917  UInt uiCode;
     918  READ_CODE( 4, uiCode, "active_vps_id" );                      sei.m_activeVpsId = uiCode;
     919  READ_UVLC(    uiCode, "num_additional_sub_streams_minus1" );  sei.m_numAdditionalSubStreams = uiCode + 1;
     920
     921  for( Int i = 0; i < sei.m_numAdditionalSubStreams; i++ )
     922  {
     923    READ_CODE(  2, uiCode, "sub_bitstream_mode[i]"           ); sei.m_subBitstreamMode[i] = uiCode;
     924    READ_UVLC(     uiCode, "output_layer_set_idx_to_vps[i]"  ); sei.m_outputLayerSetIdxToVps[i] = uiCode;
     925    READ_CODE(  3, uiCode, "highest_sub_layer_id[i]"         ); sei.m_highestSublayerId[i] = uiCode;
     926    READ_CODE( 16, uiCode, "avg_bit_rate[i]"                 ); sei.m_avgBitRate[i] = uiCode;
     927    READ_CODE( 16, uiCode, "max_bit_rate[i]"                 ); sei.m_maxBitRate[i] = uiCode;
     928  }
     929  xParseByteAlign();
     930}
     931#endif
     932#endif //SVC_EXTENSION
     933
    927934//! \}
  • trunk/source/Lib/TLibDecoder/SEIread.h

    r588 r595  
    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 *
  • trunk/source/Lib/TLibDecoder/SyntaxElementParser.cpp

    r442 r595  
    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*
  • trunk/source/Lib/TLibDecoder/SyntaxElementParser.h

    r313 r595  
    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 *
  • trunk/source/Lib/TLibDecoder/TDecBinCoder.h

    r313 r595  
    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 *
  • trunk/source/Lib/TLibDecoder/TDecBinCoderCABAC.cpp

    r313 r595  
    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 *
  • trunk/source/Lib/TLibDecoder/TDecBinCoderCABAC.h

    r313 r595  
    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 *
  • trunk/source/Lib/TLibDecoder/TDecCAVLC.cpp

    r588 r595  
    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*
     
    673673  READ_UVLC( uiCode, "log2_diff_max_min_coding_block_size" );
    674674  pcSPS->setLog2DiffMaxMinCodingBlockSize(uiCode);
     675 
     676  if (pcSPS->getPTL()->getGeneralPTL()->getLevelIdc() >= Level::LEVEL5)
     677  {
     678    assert(log2MinCUSize + pcSPS->getLog2DiffMaxMinCodingBlockSize() >= 5);
     679  }
     680 
    675681  Int maxCUDepthDelta = uiCode;
    676682  pcSPS->setMaxCUWidth  ( 1<<(log2MinCUSize + maxCUDepthDelta) );
  • trunk/source/Lib/TLibDecoder/TDecCAVLC.h

    r588 r595  
    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 *
  • trunk/source/Lib/TLibDecoder/TDecCu.cpp

    r540 r595  
    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 *
     
    532532  m_pcPrediction->predIntraLumaAng( pcCU->getPattern(), uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight, bAboveAvail, bLeftAvail );
    533533 
     534  if ( pcCU->getCbf( uiAbsPartIdx, TEXT_LUMA, uiTrDepth ) )
     535  {
    534536  //===== inverse transform =====
    535537#if REPN_FORMAT_IN_VPS
     
    540542
    541543  Int scalingListType = (pcCU->isIntra(uiAbsPartIdx) ? 0 : 3) + g_eTTable[(Int)TEXT_LUMA];
    542   assert(scalingListType < 6);
     544    assert(scalingListType < SCALING_LIST_NUM);
    543545  m_pcTrQuant->invtransformNxN( pcCU->getCUTransquantBypass(uiAbsPartIdx), TEXT_LUMA, pcCU->getLumaIntraDir( uiAbsPartIdx ), piResi, uiStride, pcCoeff, uiWidth, uiHeight, scalingListType, useTransformSkip );
    544546
     
    560562    pReco     += uiStride;
    561563    pRecIPred += uiRecIPredStride;
     564  }
     565  }
     566  else
     567  {
     568    //===== reconstruction =====
     569    Pel* pPred      = piPred;
     570    Pel* pReco      = piReco;
     571    Pel* pRecIPred  = piRecIPred;
     572    for ( Int y = 0; y < uiHeight; y++ )
     573    {
     574      for ( Int x = 0; x < uiWidth; x++ )
     575      {
     576        pReco    [ x ] = pPred[ x ];
     577        pRecIPred[ x ] = pReco[ x ];
     578      }
     579      pPred     += uiStride;
     580      pReco     += uiStride;
     581      pRecIPred += uiRecIPredStride;
     582    }
    562583  }
    563584}
     
    624645  m_pcPrediction->predIntraChromaAng( pPatChroma, uiChromaPredMode, piPred, uiStride, uiWidth, uiHeight, bAboveAvail, bLeftAvail ); 
    625646
     647  if ( pcCU->getCbf( uiAbsPartIdx, eText, uiTrDepth ) )
     648  {
    626649  //===== inverse transform =====
    627650  Int curChromaQpOffset;
     
    646669
    647670  Int scalingListType = (pcCU->isIntra(uiAbsPartIdx) ? 0 : 3) + g_eTTable[(Int)eText];
    648   assert(scalingListType < 6);
     671    assert(scalingListType < SCALING_LIST_NUM);
    649672  m_pcTrQuant->invtransformNxN( pcCU->getCUTransquantBypass(uiAbsPartIdx), eText, REG_DCT, piResi, uiStride, pcCoeff, uiWidth, uiHeight, scalingListType, useTransformSkipChroma );
    650673
     
    665688    pReco     += uiStride;
    666689    pRecIPred += uiRecIPredStride;
     690  }
     691  }
     692  else
     693  {
     694    //===== reconstruction =====
     695    Pel* pPred      = piPred;
     696    Pel* pReco      = piReco;
     697    Pel* pRecIPred  = piRecIPred;
     698    for ( Int y = 0; y < uiHeight; y++ )
     699    {
     700      for ( Int x = 0; x < uiWidth; x++ )
     701      {
     702        pReco    [ x ] = pPred[ x ];
     703        pRecIPred[ x ] = pReco[ x ];
     704      }
     705      pPred     += uiStride;
     706      pReco     += uiStride;
     707      pRecIPred += uiRecIPredStride;
     708    }   
    667709  }
    668710}
  • trunk/source/Lib/TLibDecoder/TDecCu.h

    r345 r595  
    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 *
  • trunk/source/Lib/TLibDecoder/TDecEntropy.cpp

    r345 r595  
    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 *
     
    319319}
    320320
    321 Void TDecEntropy::xDecodeTransform( TComDataCU* pcCU, UInt offsetLuma, UInt offsetChroma, UInt uiAbsPartIdx, UInt uiDepth, UInt width, UInt height, UInt uiTrIdx, Bool& bCodeDQP)
     321Void TDecEntropy::xDecodeTransform( TComDataCU* pcCU, UInt offsetLuma, UInt offsetChroma, UInt uiAbsPartIdx, UInt uiDepth, UInt width, UInt height, UInt uiTrIdx, Bool& bCodeDQP, Int quadtreeTULog2MinSizeInCU)
    322322{
    323323  UInt uiSubdiv;
     
    343343  else if( (pcCU->getSlice()->getSPS()->getQuadtreeTUMaxDepthInter() == 1) && (pcCU->getPredictionMode(uiAbsPartIdx) == MODE_INTER) && ( pcCU->getPartitionSize(uiAbsPartIdx) != SIZE_2Nx2N ) && (uiDepth == pcCU->getDepth(uiAbsPartIdx)) )
    344344  {
    345     uiSubdiv = (uiLog2TrafoSize > pcCU->getQuadtreeTULog2MinSizeInCU(uiAbsPartIdx));
     345    uiSubdiv = (uiLog2TrafoSize > quadtreeTULog2MinSizeInCU);
    346346  }
    347347  else if( uiLog2TrafoSize > pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() )
     
    353353    uiSubdiv = 0;
    354354  }
    355   else if( uiLog2TrafoSize == pcCU->getQuadtreeTULog2MinSizeInCU(uiAbsPartIdx) )
     355  else if( uiLog2TrafoSize == quadtreeTULog2MinSizeInCU )
    356356  {
    357357    uiSubdiv = 0;
     
    359359  else
    360360  {
    361     assert( uiLog2TrafoSize > pcCU->getQuadtreeTULog2MinSizeInCU(uiAbsPartIdx) );
     361    assert( uiLog2TrafoSize > quadtreeTULog2MinSizeInCU );
    362362    m_pcEntropyDecoderIf->parseTransformSubdivFlag( uiSubdiv, 5 - uiLog2TrafoSize );
    363363  }
     
    405405    for( Int i = 0; i < 4; i++ )
    406406    {
    407       xDecodeTransform( pcCU, offsetLuma, offsetChroma, uiAbsPartIdx, uiDepth, width, height, uiTrIdx, bCodeDQP );
     407      xDecodeTransform( pcCU, offsetLuma, offsetChroma, uiAbsPartIdx, uiDepth, width, height, uiTrIdx, bCodeDQP, quadtreeTULog2MinSizeInCU );
    408408      uiYCbf |= pcCU->getCbf( uiAbsPartIdx, TEXT_LUMA, uiTrDepth+1 );
    409409      uiUCbf |= pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepth+1 );
     
    553553   
    554554  }
    555   xDecodeTransform( pcCU, uiLumaOffset, uiChromaOffset, uiAbsPartIdx, uiDepth, uiWidth, uiHeight, 0, bCodeDQP );
     555 
     556  Int getQuadtreeTULog2MinSizeInCU = pcCU->getQuadtreeTULog2MinSizeInCU(uiAbsPartIdx);
     557 
     558  xDecodeTransform( pcCU, uiLumaOffset, uiChromaOffset, uiAbsPartIdx, uiDepth, uiWidth, uiHeight, 0, bCodeDQP, getQuadtreeTULog2MinSizeInCU );
    556559}
    557560
  • trunk/source/Lib/TLibDecoder/TDecEntropy.h

    r540 r595  
    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 *
     
    167167 
    168168private:
    169   Void xDecodeTransform        ( TComDataCU* pcCU, UInt offsetLuma, UInt offsetChroma, UInt uiAbsPartIdx, UInt uiDepth, UInt width, UInt height, UInt uiTrIdx, Bool& bCodeDQP );
     169  Void xDecodeTransform        ( TComDataCU* pcCU, UInt offsetLuma, UInt offsetChroma, UInt uiAbsPartIdx, UInt uiDepth, UInt width, UInt height, UInt uiTrIdx, Bool& bCodeDQP, Int getQuadtreeTULog2MinSizeInCU );
    170170
    171171public:
  • trunk/source/Lib/TLibDecoder/TDecGop.cpp

    r588 r595  
    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 *
     
    128128  //-- For time output for each slice
    129129  long iBeforeTime = clock();
    130 #if !HM_CLEANUP_SAO
    131   UInt uiStartCUAddr   = pcSlice->getSliceSegmentCurStartCUAddr();
    132 
    133   UInt uiSliceStartCuAddr = pcSlice->getSliceCurStartCUAddr();
    134   if(uiSliceStartCuAddr == uiStartCUAddr)
    135   {
    136     m_sliceStartCUAddress.push_back(uiSliceStartCuAddr);
    137   }
    138 #endif
    139130  m_pcSbacDecoder->init( (TDecBinIf*)m_pcBinCABAC );
    140131  m_pcEntropyDecoder->setEntropyDecoder (m_pcSbacDecoder);
     
    163154  m_pcEntropyDecoder->setBitstream      ( ppcSubstreams[0] );
    164155  m_pcEntropyDecoder->resetEntropy      (pcSlice);
    165 #if !HM_CLEANUP_SAO
    166   if(uiSliceStartCuAddr == uiStartCUAddr)
    167   {
    168     m_LFCrossSliceBoundaryFlag.push_back( pcSlice->getLFCrossSliceBoundaryFlag());
    169   }
    170 #endif
    171156  m_pcSbacDecoders[0].load(m_pcSbacDecoder);
    172157  m_pcSliceDecoder->decompressSlice( ppcSubstreams, rpcPic, m_pcSbacDecoder, m_pcSbacDecoders);
     
    196181  m_pcLoopFilter->setCfg(bLFCrossTileBoundary);
    197182  m_pcLoopFilter->loopFilterPic( rpcPic );
    198 #if !HM_CLEANUP_SAO
    199   if(pcSlice->getSPS()->getUseSAO())
    200   {
    201     m_sliceStartCUAddress.push_back(rpcPic->getNumCUsInFrame()* rpcPic->getNumPartInCU());
    202     rpcPic->createNonDBFilterInfo(m_sliceStartCUAddress, 0, &m_LFCrossSliceBoundaryFlag, rpcPic->getPicSym()->getNumTiles(), bLFCrossTileBoundary);
    203   }
    204 #endif
    205183  if( pcSlice->getSPS()->getUseSAO() )
    206184  {
    207 #if HM_CLEANUP_SAO
    208185    m_pcSAO->reconstructBlkSAOParams(rpcPic, rpcPic->getPicSym()->getSAOBlkParam());
    209186    m_pcSAO->SAOProcess(rpcPic);
    210187    m_pcSAO->PCMLFDisableProcess(rpcPic);
    211 #else
    212     {
    213       SAOParam *saoParam = rpcPic->getPicSym()->getSaoParam();
    214       saoParam->bSaoFlag[0] = pcSlice->getSaoEnabledFlag();
    215       saoParam->bSaoFlag[1] = pcSlice->getSaoEnabledFlagChroma();
    216       m_pcSAO->setSaoLcuBasedOptimization(1);
    217       m_pcSAO->createPicSaoInfo(rpcPic);
    218       m_pcSAO->SAOProcess(saoParam);
    219       m_pcSAO->PCMLFDisableProcess(rpcPic);
    220       m_pcSAO->destroyPicSaoInfo();
    221     }
    222 #endif
    223   }
    224 #if !HM_CLEANUP_SAO
    225   if(pcSlice->getSPS()->getUseSAO())
    226   {
    227     rpcPic->destroyNonDBFilterInfo();
    228   }
    229 #endif
     188  }
    230189  rpcPic->compressMotion();
    231190  Char c = (pcSlice->isIntra() ? 'I' : pcSlice->isInterP() ? 'P' : 'B');
     
    291250  rpcPic->setOutputMark(true);
    292251  rpcPic->setReconMark(true);
    293 #if !HM_CLEANUP_SAO
    294   m_sliceStartCUAddress.clear();
    295   m_LFCrossSliceBoundaryFlag.clear();
    296 #endif
    297252}
    298253
  • trunk/source/Lib/TLibDecoder/TDecGop.h

    r540 r595  
    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 *
     
    8383  Int                   m_decodedPictureHashSEIEnabled;  ///< Checksum(3)/CRC(2)/MD5(1)/disable(0) acting on decoded picture hash SEI message
    8484
    85 #if !HM_CLEANUP_SAO
    86   //! list that contains the CU address of each slice plus the end address
    87   std::vector<Int> m_sliceStartCUAddress;
    88   std::vector<Bool> m_LFCrossSliceBoundaryFlag;
    89 #endif
    9085#if SVC_EXTENSION
    9186  UInt                  m_layerId;
  • trunk/source/Lib/TLibDecoder/TDecSbac.cpp

    r540 r595  
    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 *
     
    7272, m_cCUAbsSCModel             ( 1,             1,               NUM_ABS_FLAG_CTX              , m_contextModels + m_numContextModels, m_numContextModels)
    7373, m_cMVPIdxSCModel            ( 1,             1,               NUM_MVP_IDX_CTX               , m_contextModels + m_numContextModels, m_numContextModels)
    74 , m_cCUAMPSCModel             ( 1,             1,               NUM_CU_AMP_CTX                , m_contextModels + m_numContextModels, m_numContextModels)
    7574, m_cSaoMergeSCModel      ( 1,             1,               NUM_SAO_MERGE_FLAG_CTX   , m_contextModels + m_numContextModels, m_numContextModels)
    7675, m_cSaoTypeIdxSCModel        ( 1,             1,               NUM_SAO_TYPE_IDX_CTX          , m_contextModels + m_numContextModels, m_numContextModels)
     
    114113  m_cCUMergeIdxExtSCModel.initBuffer     ( sliceType, qp, (UChar*)INIT_MERGE_IDX_EXT );
    115114  m_cCUPartSizeSCModel.initBuffer        ( sliceType, qp, (UChar*)INIT_PART_SIZE );
    116   m_cCUAMPSCModel.initBuffer             ( sliceType, qp, (UChar*)INIT_CU_AMP_POS );
    117115  m_cCUPredModeSCModel.initBuffer        ( sliceType, qp, (UChar*)INIT_PRED_MODE );
    118116  m_cCUIntraPredSCModel.initBuffer       ( sliceType, qp, (UChar*)INIT_INTRA_PRED_MODE );
     
    160158  m_cCUMergeIdxExtSCModel.initBuffer     ( eSliceType, iQp, (UChar*)INIT_MERGE_IDX_EXT );
    161159  m_cCUPartSizeSCModel.initBuffer        ( eSliceType, iQp, (UChar*)INIT_PART_SIZE );
    162   m_cCUAMPSCModel.initBuffer             ( eSliceType, iQp, (UChar*)INIT_CU_AMP_POS );
    163160  m_cCUPredModeSCModel.initBuffer        ( eSliceType, iQp, (UChar*)INIT_PRED_MODE );
    164161  m_cCUIntraPredSCModel.initBuffer       ( eSliceType, iQp, (UChar*)INIT_INTRA_PRED_MODE );
     
    579576      if (eMode == SIZE_2NxN)
    580577      {
    581         m_pcTDecBinIf->decodeBin(uiSymbol, m_cCUAMPSCModel.get( 0, 0, 0 ));
     578        m_pcTDecBinIf->decodeBin(uiSymbol, m_cCUPartSizeSCModel.get( 0, 0, 3 ));
    582579        if (uiSymbol == 0)
    583580        {
     
    588585      else if (eMode == SIZE_Nx2N)
    589586      {
    590         m_pcTDecBinIf->decodeBin(uiSymbol, m_cCUAMPSCModel.get( 0, 0, 0 ));
     587        m_pcTDecBinIf->decodeBin(uiSymbol, m_cCUPartSizeSCModel.get( 0, 0, 3 ));
    591588        if (uiSymbol == 0)
    592589        {
     
    13821379    if (uiCode == 0)
    13831380    {
    1384 #if HM_CLEANUP_SAO
    13851381      ruiVal = 1;
    1386 #else
    1387       ruiVal = 5;
    1388 #endif
    13891382    }
    13901383    else
    13911384    {
    1392 #if HM_CLEANUP_SAO
    13931385      ruiVal = 2;
    1394 #else
    1395       ruiVal = 1;
    1396 #endif
    1397     }
    1398   }
    1399 }
    1400 
    1401 #if HM_CLEANUP_SAO
     1386    }
     1387  }
     1388}
    14021389
    14031390Void TDecSbac::parseSaoSign(UInt& val)
     
    15311518}
    15321519
    1533 #else
    1534 
    1535 inline Void copySaoOneLcuParam(SaoLcuParam* psDst,  SaoLcuParam* psSrc)
    1536 {
    1537   Int i;
    1538   psDst->partIdx = psSrc->partIdx;
    1539   psDst->typeIdx    = psSrc->typeIdx;
    1540   if (psDst->typeIdx != -1)
    1541   {
    1542     psDst->subTypeIdx = psSrc->subTypeIdx ;
    1543     psDst->length  = psSrc->length;
    1544     for (i=0;i<psDst->length;i++)
    1545     {
    1546       psDst->offset[i] = psSrc->offset[i];
    1547     }
    1548   }
    1549   else
    1550   {
    1551     psDst->length  = 0;
    1552     for (i=0;i<SAO_BO_LEN;i++)
    1553     {
    1554       psDst->offset[i] = 0;
    1555     }
    1556   }
    1557 }
    1558 
    1559 Void TDecSbac::parseSaoOffset(SaoLcuParam* psSaoLcuParam, UInt compIdx)
    1560 {
    1561   UInt uiSymbol;
    1562   static Int iTypeLength[MAX_NUM_SAO_TYPE] =
    1563   {
    1564     SAO_EO_LEN,
    1565     SAO_EO_LEN,
    1566     SAO_EO_LEN,
    1567     SAO_EO_LEN,
    1568     SAO_BO_LEN
    1569   };
    1570 
    1571   if (compIdx==2)
    1572   {
    1573     uiSymbol = (UInt)( psSaoLcuParam->typeIdx + 1);
    1574   }
    1575   else
    1576   {
    1577     parseSaoTypeIdx(uiSymbol);
    1578   }
    1579   psSaoLcuParam->typeIdx = (Int)uiSymbol - 1;
    1580   if (uiSymbol)
    1581   {
    1582     psSaoLcuParam->length = iTypeLength[psSaoLcuParam->typeIdx];
    1583 
    1584     Int bitDepth = compIdx ? g_bitDepthC : g_bitDepthY;
    1585     Int offsetTh = 1 << min(bitDepth - 5,5);
    1586 
    1587     if( psSaoLcuParam->typeIdx == SAO_BO )
    1588     {
    1589       for(Int i=0; i< psSaoLcuParam->length; i++)
    1590       {
    1591         parseSaoMaxUvlc(uiSymbol, offsetTh -1 );
    1592         psSaoLcuParam->offset[i] = uiSymbol;
    1593       }   
    1594       for(Int i=0; i< psSaoLcuParam->length; i++)
    1595       {
    1596         if (psSaoLcuParam->offset[i] != 0)
    1597         {
    1598           m_pcTDecBinIf->decodeBinEP ( uiSymbol);
    1599           if (uiSymbol)
    1600           {
    1601             psSaoLcuParam->offset[i] = -psSaoLcuParam->offset[i] ;
    1602           }
    1603         }
    1604       }
    1605       parseSaoUflc(5, uiSymbol );
    1606       psSaoLcuParam->subTypeIdx = uiSymbol;
    1607     }
    1608     else if( psSaoLcuParam->typeIdx < 4 )
    1609     {
    1610       parseSaoMaxUvlc(uiSymbol, offsetTh -1 ); psSaoLcuParam->offset[0] = uiSymbol;
    1611       parseSaoMaxUvlc(uiSymbol, offsetTh -1 ); psSaoLcuParam->offset[1] = uiSymbol;
    1612       parseSaoMaxUvlc(uiSymbol, offsetTh -1 ); psSaoLcuParam->offset[2] = -(Int)uiSymbol;
    1613       parseSaoMaxUvlc(uiSymbol, offsetTh -1 ); psSaoLcuParam->offset[3] = -(Int)uiSymbol;
    1614      if (compIdx != 2)
    1615      {
    1616        parseSaoUflc(2, uiSymbol );
    1617        psSaoLcuParam->subTypeIdx = uiSymbol;
    1618        psSaoLcuParam->typeIdx += psSaoLcuParam->subTypeIdx;
    1619      }
    1620    }
    1621   }
    1622   else
    1623   {
    1624     psSaoLcuParam->length = 0;
    1625   }
    1626 }
    1627 
    1628 Void TDecSbac::parseSaoOneLcuInterleaving(Int rx, Int ry, SAOParam* pSaoParam, TComDataCU* pcCU, Int iCUAddrInSlice, Int iCUAddrUpInSlice, Int allowMergeLeft, Int allowMergeUp)
    1629 {
    1630   Int iAddr = pcCU->getAddr();
    1631   UInt uiSymbol;
    1632   for (Int iCompIdx=0; iCompIdx<3; iCompIdx++)
    1633   {
    1634     pSaoParam->saoLcuParam[iCompIdx][iAddr].mergeUpFlag    = 0;
    1635     pSaoParam->saoLcuParam[iCompIdx][iAddr].mergeLeftFlag  = 0;
    1636     pSaoParam->saoLcuParam[iCompIdx][iAddr].subTypeIdx     = 0;
    1637     pSaoParam->saoLcuParam[iCompIdx][iAddr].typeIdx        = -1;
    1638     pSaoParam->saoLcuParam[iCompIdx][iAddr].offset[0]     = 0;
    1639     pSaoParam->saoLcuParam[iCompIdx][iAddr].offset[1]     = 0;
    1640     pSaoParam->saoLcuParam[iCompIdx][iAddr].offset[2]     = 0;
    1641     pSaoParam->saoLcuParam[iCompIdx][iAddr].offset[3]     = 0;
    1642 
    1643   }
    1644  if (pSaoParam->bSaoFlag[0] || pSaoParam->bSaoFlag[1] )
    1645   {
    1646     if (rx>0 && iCUAddrInSlice!=0 && allowMergeLeft)
    1647     {
    1648       parseSaoMerge(uiSymbol);
    1649       pSaoParam->saoLcuParam[0][iAddr].mergeLeftFlag = (Bool)uiSymbol; 
    1650     }
    1651     if (pSaoParam->saoLcuParam[0][iAddr].mergeLeftFlag==0)
    1652     {
    1653       if ((ry > 0) && (iCUAddrUpInSlice>=0) && allowMergeUp)
    1654       {
    1655         parseSaoMerge(uiSymbol);
    1656         pSaoParam->saoLcuParam[0][iAddr].mergeUpFlag = (Bool)uiSymbol;
    1657       }
    1658     }
    1659   }
    1660 
    1661   for (Int iCompIdx=0; iCompIdx<3; iCompIdx++)
    1662   {
    1663     if ((iCompIdx == 0  && pSaoParam->bSaoFlag[0]) || (iCompIdx > 0  && pSaoParam->bSaoFlag[1]) )
    1664     {
    1665       if (rx>0 && iCUAddrInSlice!=0 && allowMergeLeft)
    1666       {
    1667         pSaoParam->saoLcuParam[iCompIdx][iAddr].mergeLeftFlag = pSaoParam->saoLcuParam[0][iAddr].mergeLeftFlag;
    1668       }
    1669       else
    1670       {
    1671         pSaoParam->saoLcuParam[iCompIdx][iAddr].mergeLeftFlag = 0;
    1672       }
    1673 
    1674       if (pSaoParam->saoLcuParam[iCompIdx][iAddr].mergeLeftFlag==0)
    1675       {
    1676         if ((ry > 0) && (iCUAddrUpInSlice>=0) && allowMergeUp)
    1677         {
    1678           pSaoParam->saoLcuParam[iCompIdx][iAddr].mergeUpFlag = pSaoParam->saoLcuParam[0][iAddr].mergeUpFlag;
    1679         }
    1680         else
    1681         {
    1682           pSaoParam->saoLcuParam[iCompIdx][iAddr].mergeUpFlag = 0;
    1683         }
    1684         if (!pSaoParam->saoLcuParam[iCompIdx][iAddr].mergeUpFlag)
    1685         {
    1686           pSaoParam->saoLcuParam[2][iAddr].typeIdx = pSaoParam->saoLcuParam[1][iAddr].typeIdx;
    1687           parseSaoOffset(&(pSaoParam->saoLcuParam[iCompIdx][iAddr]), iCompIdx);
    1688         }
    1689         else
    1690         {
    1691           copySaoOneLcuParam(&pSaoParam->saoLcuParam[iCompIdx][iAddr], &pSaoParam->saoLcuParam[iCompIdx][iAddr-pSaoParam->numCuInWidth]);
    1692         }
    1693       }
    1694       else
    1695       {
    1696         copySaoOneLcuParam(&pSaoParam->saoLcuParam[iCompIdx][iAddr],  &pSaoParam->saoLcuParam[iCompIdx][iAddr-1]);
    1697       }
    1698     }
    1699     else
    1700     {
    1701       pSaoParam->saoLcuParam[iCompIdx][iAddr].typeIdx = -1;
    1702       pSaoParam->saoLcuParam[iCompIdx][iAddr].subTypeIdx = 0;
    1703     }
    1704   }
    1705 }
    1706 
    1707 #endif
    1708 
    17091520/**
    17101521 - Initialize our contexts from the nominated source.
  • trunk/source/Lib/TLibDecoder/TDecSbac.h

    r540 r595  
    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 *
     
    9090  Void  parseSaoTypeIdx           ( UInt&  ruiVal  );
    9191  Void  parseSaoUflc              ( UInt uiLength, UInt& ruiVal     );
    92 #if HM_CLEANUP_SAO
    9392  Void parseSAOBlkParam (SAOBlkParam& saoBlkParam, Bool* sliceEnabled, Bool leftMergeAvail, Bool aboveMergeAvail);
    9493  Void parseSaoSign(UInt& val);
    95 #else
    96   Void  parseSaoOneLcuInterleaving(Int rx, Int ry, SAOParam* pSaoParam, TComDataCU* pcCU, Int iCUAddrInSlice, Int iCUAddrUpInSlice, Int allowMergeLeft, Int allowMergeUp);
    97   Void  parseSaoOffset            (SaoLcuParam* psSaoLcuParam, UInt compIdx);
    98 #endif
    9994private:
    10095  Void  xReadUnarySymbol    ( UInt& ruiSymbol, ContextModel* pcSCModel, Int iOffset );
     
    171166  ContextModel3DBuffer m_cMVPIdxSCModel;
    172167 
    173   ContextModel3DBuffer m_cCUAMPSCModel;
    174168  ContextModel3DBuffer m_cSaoMergeSCModel;
    175169  ContextModel3DBuffer m_cSaoTypeIdxSCModel;
  • trunk/source/Lib/TLibDecoder/TDecSlice.cpp

    r540 r595  
    44 * granted under this license. 
    55 *
    6  * Copyright (c) 2010-2013, ITU/ISO/IEC
     6 * Copyright (c) 2010-2014, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
     
    323323#endif
    324324
    325 #if HM_CLEANUP_SAO
    326325    if ( pcSlice->getSPS()->getUseSAO() )
    327326    {
     
    358357      }
    359358    }
    360 #else
    361     if ( pcSlice->getSPS()->getUseSAO() && (pcSlice->getSaoEnabledFlag()||pcSlice->getSaoEnabledFlagChroma()) )
    362     {
    363       SAOParam *saoParam = rpcPic->getPicSym()->getSaoParam();
    364       saoParam->bSaoFlag[0] = pcSlice->getSaoEnabledFlag();
    365       if (iCUAddr == iStartCUAddr)
    366       {
    367         saoParam->bSaoFlag[1] = pcSlice->getSaoEnabledFlagChroma();
    368       }
    369       Int numCuInWidth     = saoParam->numCuInWidth;
    370       Int cuAddrInSlice = iCUAddr - rpcPic->getPicSym()->getCUOrderMap(pcSlice->getSliceCurStartCUAddr()/rpcPic->getNumPartInCU());
    371       Int cuAddrUpInSlice  = cuAddrInSlice - numCuInWidth;
    372       Int rx = iCUAddr % numCuInWidth;
    373       Int ry = iCUAddr / numCuInWidth;
    374       Int allowMergeLeft = 1;
    375       Int allowMergeUp   = 1;
    376       if (rx!=0)
    377       {
    378         if (rpcPic->getPicSym()->getTileIdxMap(iCUAddr-1) != rpcPic->getPicSym()->getTileIdxMap(iCUAddr))
    379         {
    380           allowMergeLeft = 0;
    381         }
    382       }
    383       if (ry!=0)
    384       {
    385         if (rpcPic->getPicSym()->getTileIdxMap(iCUAddr-numCuInWidth) != rpcPic->getPicSym()->getTileIdxMap(iCUAddr))
    386         {
    387           allowMergeUp = 0;
    388         }
    389       }
    390       pcSbacDecoder->parseSaoOneLcuInterleaving(rx, ry, saoParam,pcCU, cuAddrInSlice, cuAddrUpInSlice, allowMergeLeft, allowMergeUp);
    391     }
    392     else if ( pcSlice->getSPS()->getUseSAO() )
    393     {
    394       Int addr = pcCU->getAddr();
    395       SAOParam *saoParam = rpcPic->getPicSym()->getSaoParam();
    396       for (Int cIdx=0; cIdx<3; cIdx++)
    397       {
    398         SaoLcuParam *saoLcuParam = &(saoParam->saoLcuParam[cIdx][addr]);
    399         if ( ((cIdx == 0) && !pcSlice->getSaoEnabledFlag()) || ((cIdx == 1 || cIdx == 2) && !pcSlice->getSaoEnabledFlagChroma()))
    400         {
    401           saoLcuParam->mergeUpFlag   = 0;
    402           saoLcuParam->mergeLeftFlag = 0;
    403           saoLcuParam->subTypeIdx    = 0;
    404           saoLcuParam->typeIdx       = -1;
    405           saoLcuParam->offset[0]     = 0;
    406           saoLcuParam->offset[1]     = 0;
    407           saoLcuParam->offset[2]     = 0;
    408           saoLcuParam->offset[3]     = 0;
    409         }
    410       }
    411     }
    412 #endif
    413359
    414360    m_pcCuDecoder->decodeCU     ( pcCU, uiIsLast );
  • trunk/source/Lib/TLibDecoder/TDecSlice.h

    r442 r595  
    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 *
  • trunk/source/Lib/TLibDecoder/TDecTop.cpp

    r588 r595  
    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 *
     
    404404#endif
    405405#endif
    406 #if !HM_CLEANUP_SAO
    407     rpcPic->getPicSym()->allocSaoParam(&m_cSAO);
    408 #endif
    409406    m_cListPic.pushBack( rpcPic );
    410407   
     
    485482#endif
    486483#endif
    487 #endif
    488 #if !HM_CLEANUP_SAO
    489   rpcPic->getPicSym()->allocSaoParam(&m_cSAO);
    490484#endif
    491485}
     
    784778#if REPN_FORMAT_IN_VPS
    785779#if AUXILIARY_PICTURES
    786 #if HM_CLEANUP_SAO
    787780  m_cSAO.create( m_apcSlicePilot->getPicWidthInLumaSamples(), m_apcSlicePilot->getPicHeightInLumaSamples(), sps->getChromaFormatIdc(), sps->getMaxCUWidth(), sps->getMaxCUHeight(), sps->getMaxCUDepth() );
    788781#else
    789   m_cSAO.create( m_apcSlicePilot->getPicWidthInLumaSamples(), m_apcSlicePilot->getPicHeightInLumaSamples(), sps->getMaxCUWidth(), sps->getMaxCUHeight() );
    790 #endif
    791 #else
    792 #if HM_CLEANUP_SAO
    793782  m_cSAO.create( m_apcSlicePilot->getPicWidthInLumaSamples(), m_apcSlicePilot->getPicHeightInLumaSamples(), sps->getMaxCUWidth(), sps->getMaxCUHeight(), sps->getMaxCUDepth() );
    794 #else
    795   m_cSAO.create( m_apcSlicePilot->getPicWidthInLumaSamples(), m_apcSlicePilot->getPicHeightInLumaSamples(), sps->getMaxCUWidth(), sps->getMaxCUHeight() );
    796 #endif
    797 #endif
    798 #else
    799 #if HM_CLEANUP_SAO
     783#endif
     784#else
    800785  m_cSAO.create( sps->getPicWidthInLumaSamples(), sps->getPicHeightInLumaSamples(), sps->getMaxCUWidth(), sps->getMaxCUHeight(), sps->getMaxCUDepth() );
    801 #else
    802   m_cSAO.create( sps->getPicWidthInLumaSamples(), sps->getPicHeightInLumaSamples(), sps->getMaxCUWidth(), sps->getMaxCUHeight() );
    803 #endif
    804786#endif
    805787  m_cLoopFilter.create( sps->getMaxCUDepth() );
     
    817799{
    818800  TComPic*&   pcPic         = m_pcPic;
     801#if SVC_EXTENSION
    819802#if NO_CLRAS_OUTPUT_FLAG
    820803  Bool bFirstSliceInSeq;
    821804#endif
    822 #if SVC_EXTENSION
    823805  m_apcSlicePilot->setVPS( m_parameterSetManagerDecoder.getPrefetchedVPS(0) );
    824806#if OUTPUT_LAYER_SET_INDEX
     
    831813#endif
    832814  m_apcSlicePilot->initSlice( nalu.m_layerId );
    833 #else
     815#else //SVC_EXTENSION
    834816  m_apcSlicePilot->initSlice();
    835817#endif
     
    839821    m_uiSliceIdx     = 0;
    840822  }
     823  else
     824  {
     825    m_apcSlicePilot->copySliceInfo( pcPic->getPicSym()->getSlice(m_uiSliceIdx-1) );
     826  }
    841827  m_apcSlicePilot->setSliceIdx(m_uiSliceIdx);
    842   if (!m_bFirstSliceInPicture)
    843   {
    844     m_apcSlicePilot->copySliceInfo( pcPic->getPicSym()->getSlice(m_uiSliceIdx-1) );
    845   }
    846828
    847829  m_apcSlicePilot->setNalUnitType(nalu.m_nalUnitType);
     
    857839
    858840#if SVC_EXTENSION
    859   m_apcSlicePilot->setSliceIdx( m_uiSliceIdx ); // it should be removed if HM will reflect it in above
    860841#if VPS_EXTN_DIRECT_REF_LAYERS
    861842  setRefLayerParams(m_apcSlicePilot->getVPS());
     
    18751856      return false;
    18761857     
     1858     
     1859    case NAL_UNIT_RESERVED_VCL_N10:
     1860    case NAL_UNIT_RESERVED_VCL_R11:
     1861    case NAL_UNIT_RESERVED_VCL_N12:
     1862    case NAL_UNIT_RESERVED_VCL_R13:
     1863    case NAL_UNIT_RESERVED_VCL_N14:
     1864    case NAL_UNIT_RESERVED_VCL_R15:
     1865     
     1866    case NAL_UNIT_RESERVED_IRAP_VCL22:
     1867    case NAL_UNIT_RESERVED_IRAP_VCL23:
     1868     
     1869    case NAL_UNIT_RESERVED_VCL24:
     1870    case NAL_UNIT_RESERVED_VCL25:
     1871    case NAL_UNIT_RESERVED_VCL26:
     1872    case NAL_UNIT_RESERVED_VCL27:
     1873    case NAL_UNIT_RESERVED_VCL28:
     1874    case NAL_UNIT_RESERVED_VCL29:
     1875    case NAL_UNIT_RESERVED_VCL30:
     1876    case NAL_UNIT_RESERVED_VCL31:
     1877     
     1878    case NAL_UNIT_FILLER_DATA:
     1879    case NAL_UNIT_RESERVED_NVCL41:
     1880    case NAL_UNIT_RESERVED_NVCL42:
     1881    case NAL_UNIT_RESERVED_NVCL43:
     1882    case NAL_UNIT_RESERVED_NVCL44:
     1883    case NAL_UNIT_RESERVED_NVCL45:
     1884    case NAL_UNIT_RESERVED_NVCL46:
     1885    case NAL_UNIT_RESERVED_NVCL47:
     1886    case NAL_UNIT_UNSPECIFIED_48:
     1887    case NAL_UNIT_UNSPECIFIED_49:
     1888    case NAL_UNIT_UNSPECIFIED_50:
     1889    case NAL_UNIT_UNSPECIFIED_51:
     1890    case NAL_UNIT_UNSPECIFIED_52:
     1891    case NAL_UNIT_UNSPECIFIED_53:
     1892    case NAL_UNIT_UNSPECIFIED_54:
     1893    case NAL_UNIT_UNSPECIFIED_55:
     1894    case NAL_UNIT_UNSPECIFIED_56:
     1895    case NAL_UNIT_UNSPECIFIED_57:
     1896    case NAL_UNIT_UNSPECIFIED_58:
     1897    case NAL_UNIT_UNSPECIFIED_59:
     1898    case NAL_UNIT_UNSPECIFIED_60:
     1899    case NAL_UNIT_UNSPECIFIED_61:
     1900    case NAL_UNIT_UNSPECIFIED_62:
     1901    case NAL_UNIT_UNSPECIFIED_63:
     1902
    18771903    default:
    18781904      assert (0);
     
    19541980}
    19551981
     1982#if SVC_EXTENSION
    19561983#if VPS_EXTN_DIRECT_REF_LAYERS
    19571984TDecTop* TDecTop::getRefLayerDec( UInt refLayerIdc )
     
    19681995
    19691996#if VPS_EXTN_DIRECT_REF_LAYERS
    1970 
    19711997Void TDecTop::setRefLayerParams( TComVPS* vps )
    19721998{
     
    21372163}
    21382164#endif
     2165#endif //SVC_EXTENSION
    21392166//! \}
  • trunk/source/Lib/TLibDecoder/TDecTop.h

    r588 r595  
    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 *
     
    221221  Void      xInitILRP(TComSPS *pcSPS);
    222222#endif
    223 #endif
     223#if OUTPUT_LAYER_SET_INDEX
     224  CommonDecoderParams*    getCommonDecoderParams() { return m_commonDecoderParams; }
     225  Void                    setCommonDecoderParams(CommonDecoderParams* x) { m_commonDecoderParams = x; }
     226  Void      checkValueOfTargetOutputLayerSetIdx(TComVPS *vps);
     227#endif
     228#if SCALINGLIST_INFERRING
     229  ParameterSetManagerDecoder* getParameterSetManager() { return &m_parameterSetManagerDecoder; }
     230#endif
     231#if RESOLUTION_BASED_DPB
     232  Void setSubDpbIdx(Int idx)    { m_subDpbIdx = idx; }
     233  Int  getSubDpbIdx()           { return m_subDpbIdx; }
     234  Void assignSubDpbs(TComVPS *vps);
     235#endif
     236#endif //SVC_EXTENSION
    224237#if AVC_SYNTAX || SYNTAX_OUTPUT
    225238  Void      setBLSyntaxFile( fstream* pFile ) { m_pBLSyntaxFile = pFile; }
     
    256269  Void setNoOutputOfPriorPicsFlags(Bool x)   { m_noOutputOfPriorPicsFlags = x;   }
    257270#endif
    258 public:
    259 #if OUTPUT_LAYER_SET_INDEX
    260   CommonDecoderParams*    getCommonDecoderParams() { return m_commonDecoderParams; }
    261   Void                    setCommonDecoderParams(CommonDecoderParams* x) { m_commonDecoderParams = x; }
    262   Void      checkValueOfTargetOutputLayerSetIdx(TComVPS *vps);
    263 #endif
    264 #if SCALINGLIST_INFERRING
    265   ParameterSetManagerDecoder* getParameterSetManager() { return &m_parameterSetManagerDecoder; }
    266 #endif
    267 #if RESOLUTION_BASED_DPB
    268   Void setSubDpbIdx(Int idx)    { m_subDpbIdx = idx; }
    269   Int  getSubDpbIdx()           { return m_subDpbIdx; }
    270   Void assignSubDpbs(TComVPS *vps);
    271 #endif
    272271};// END CLASS DEFINITION TDecTop
    273272
  • trunk/source/Lib/TLibEncoder/AnnexBwrite.h

    r313 r595  
    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 *
  • trunk/source/Lib/TLibEncoder/NALwrite.cpp

    r588 r595  
    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 *
  • trunk/source/Lib/TLibEncoder/NALwrite.h

    r313 r595  
    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 *
  • trunk/source/Lib/TLibEncoder/SEIwrite.cpp

    r588 r595  
    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 *
     
    8787    fprintf( g_hTrace, "=========== Tone Mapping Info SEI message ===========\n");
    8888    break;
     89  case SEI::SOP_DESCRIPTION:
     90    fprintf( g_hTrace, "=========== SOP Description SEI message ===========\n");
     91    break;
     92  case SEI::SCALABLE_NESTING:
     93    fprintf( g_hTrace, "=========== Scalable Nesting SEI message ===========\n");
     94    break;
     95#if SVC_EXTENSION
    8996#if LAYERS_NOT_PRESENT_SEI
    9097  case SEI::LAYERS_NOT_PRESENT:
     
    9299    break;
    93100#endif
    94   case SEI::SOP_DESCRIPTION:
    95     fprintf( g_hTrace, "=========== SOP Description SEI message ===========\n");
    96     break;
    97101#if N0383_IL_CONSTRAINED_TILE_SETS_SEI
    98102  case SEI::INTER_LAYER_CONSTRAINED_TILE_SETS:
     
    105109      break;
    106110#endif
    107   case SEI::SCALABLE_NESTING:
    108     fprintf( g_hTrace, "=========== Scalable Nesting SEI message ===========\n");
    109     break;
     111#endif //SVC_EXTENSION
    110112  default:
    111113    fprintf( g_hTrace, "=========== Unknown SEI message ===========\n");
     
    155157    xWriteSEIToneMappingInfo(*static_cast<const SEIToneMappingInfo*>(&sei));
    156158    break;
     159  case SEI::SOP_DESCRIPTION:
     160    xWriteSEISOPDescription(*static_cast<const SEISOPDescription*>(&sei));
     161    break;
     162  case SEI::SCALABLE_NESTING:
     163    xWriteSEIScalableNesting(bs, *static_cast<const SEIScalableNesting*>(&sei), sps);
     164    break;
     165#if SVC_EXTENSION
    157166#if LAYERS_NOT_PRESENT_SEI
    158167  case SEI::LAYERS_NOT_PRESENT:
     
    160169    break;
    161170#endif
    162   case SEI::SOP_DESCRIPTION:
    163     xWriteSEISOPDescription(*static_cast<const SEISOPDescription*>(&sei));
    164     break;
    165171#if N0383_IL_CONSTRAINED_TILE_SETS_SEI
    166172  case SEI::INTER_LAYER_CONSTRAINED_TILE_SETS:
     
    173179     break;
    174180#endif
    175   case SEI::SCALABLE_NESTING:
    176     xWriteSEIScalableNesting(bs, *static_cast<const SEIScalableNesting*>(&sei), sps);
    177     break;
     181#endif //SVC_EXTENSION
    178182  default:
    179183    assert(!"Unhandled SEI message");
     
    337341  if( !hrd->getSubPicCpbParamsPresentFlag() )
    338342  {
    339     WRITE_FLAG( sei.m_rapCpbParamsPresentFlag, "rap_cpb_params_present_flag" );
     343    WRITE_FLAG( sei.m_rapCpbParamsPresentFlag, "irap_cpb_params_present_flag" );
     344  }
     345  if( sei.m_rapCpbParamsPresentFlag )
     346  {
     347    WRITE_CODE( sei.m_cpbDelayOffset, hrd->getCpbRemovalDelayLengthMinus1() + 1, "cpb_delay_offset" );
     348    WRITE_CODE( sei.m_dpbDelayOffset, hrd->getDpbOutputDelayLengthMinus1()  + 1, "dpb_delay_offset" );
    340349  }
    341350  WRITE_FLAG( sei.m_concatenationFlag, "concatenation_flag");
    342351  WRITE_CODE( sei.m_auCpbRemovalDelayDelta - 1, ( hrd->getCpbRemovalDelayLengthMinus1() + 1 ), "au_cpb_removal_delay_delta_minus1" );
    343   if( sei.m_rapCpbParamsPresentFlag )
    344   {
    345     WRITE_CODE( sei.m_cpbDelayOffset, hrd->getCpbRemovalDelayLengthMinus1() + 1, "cpb_delay_offset" );
    346     WRITE_CODE( sei.m_dpbDelayOffset, hrd->getDpbOutputDelayLengthMinus1()  + 1, "dpb_delay_offset" );
    347   }
    348352  for( nalOrVcl = 0; nalOrVcl < 2; nalOrVcl ++ )
    349353  {
     
    546550}
    547551
    548 #if LAYERS_NOT_PRESENT_SEI
    549 Void SEIWriter::xWriteSEILayersNotPresent(const SEILayersNotPresent& sei)
    550 {
    551   WRITE_UVLC( sei.m_activeVpsId,           "lp_sei_active_vps_id" );
    552   for (UInt i = 0; i < sei.m_vpsMaxLayers; i++)
    553   {
    554     WRITE_FLAG( sei.m_layerNotPresentFlag[i], "layer_not_present_flag"   );
    555   }
    556   xWriteByteAlign();
    557 }
    558 #endif
    559 
    560552Void SEIWriter::xWriteSEISOPDescription(const SEISOPDescription& sei)
    561553{
     
    578570  xWriteByteAlign();
    579571}
     572
     573Void SEIWriter::xWriteSEIScalableNesting(TComBitIf& bs, const SEIScalableNesting& sei, TComSPS *sps)
     574{
     575  WRITE_FLAG( sei.m_bitStreamSubsetFlag,             "bitstream_subset_flag"         );
     576  WRITE_FLAG( sei.m_nestingOpFlag,                   "nesting_op_flag      "         );
     577  if (sei.m_nestingOpFlag)
     578  {
     579    WRITE_FLAG( sei.m_defaultOpFlag,                 "default_op_flag"               );
     580    WRITE_UVLC( sei.m_nestingNumOpsMinus1,           "nesting_num_ops"               );
     581    for (UInt i = (sei.m_defaultOpFlag ? 1 : 0); i <= sei.m_nestingNumOpsMinus1; i++)
     582    {
     583      WRITE_CODE( sei.m_nestingNoOpMaxTemporalIdPlus1, 3, "nesting_no_op_max_temporal_id" );
     584      WRITE_CODE( sei.m_nestingMaxTemporalIdPlus1[i], 3,  "nesting_max_temporal_id"       );
     585      WRITE_UVLC( sei.m_nestingOpIdx[i],                  "nesting_op_idx"                );
     586    }
     587  }
     588  else
     589  {
     590    WRITE_FLAG( sei.m_allLayersFlag,                      "all_layers_flag"               );
     591    if (!sei.m_allLayersFlag)
     592    {
     593      WRITE_CODE( sei.m_nestingNoOpMaxTemporalIdPlus1, 3, "nesting_no_op_max_temporal_id" );
     594      WRITE_UVLC( sei.m_nestingNumLayersMinus1,           "nesting_num_layers"            );
     595      for (UInt i = 0; i <= sei.m_nestingNumLayersMinus1; i++)
     596      {
     597        WRITE_CODE( sei.m_nestingLayerId[i], 6,           "nesting_layer_id"              );
     598      }
     599    }
     600  }
     601 
     602  // byte alignment
     603  while ( m_pcBitIf->getNumberOfWrittenBits() % 8 != 0 )
     604  {
     605    WRITE_FLAG( 0, "nesting_zero_bit" );
     606  }
     607
     608  // write nested SEI messages
     609  for (SEIMessages::const_iterator it = sei.m_nestedSEIs.begin(); it != sei.m_nestedSEIs.end(); it++)
     610  {
     611    writeSEImessage(bs, *(*it), sps);
     612  }
     613}
     614
     615Void SEIWriter::xWriteByteAlign()
     616{
     617  if( m_pcBitIf->getNumberOfWrittenBits() % 8 != 0)
     618  {
     619    WRITE_FLAG( 1, "bit_equal_to_one" );
     620    while( m_pcBitIf->getNumberOfWrittenBits() % 8 != 0 )
     621    {
     622      WRITE_FLAG( 0, "bit_equal_to_zero" );
     623    }
     624  }
     625};
     626
     627#if SVC_EXTENSION
     628#if LAYERS_NOT_PRESENT_SEI
     629Void SEIWriter::xWriteSEILayersNotPresent(const SEILayersNotPresent& sei)
     630{
     631  WRITE_UVLC( sei.m_activeVpsId,           "lp_sei_active_vps_id" );
     632  for (UInt i = 0; i < sei.m_vpsMaxLayers; i++)
     633  {
     634    WRITE_FLAG( sei.m_layerNotPresentFlag[i], "layer_not_present_flag"   );
     635  }
     636  xWriteByteAlign();
     637}
     638#endif
    580639
    581640#if N0383_IL_CONSTRAINED_TILE_SETS_SEI
     
    634693}
    635694#endif
    636 Void SEIWriter::xWriteSEIScalableNesting(TComBitIf& bs, const SEIScalableNesting& sei, TComSPS *sps)
    637 {
    638   WRITE_FLAG( sei.m_bitStreamSubsetFlag,             "bitstream_subset_flag"         );
    639   WRITE_FLAG( sei.m_nestingOpFlag,                   "nesting_op_flag      "         );
    640   if (sei.m_nestingOpFlag)
    641   {
    642     WRITE_FLAG( sei.m_defaultOpFlag,                 "default_op_flag"               );
    643     WRITE_UVLC( sei.m_nestingNumOpsMinus1,           "nesting_num_ops"               );
    644     for (UInt i = (sei.m_defaultOpFlag ? 1 : 0); i <= sei.m_nestingNumOpsMinus1; i++)
    645     {
    646       WRITE_CODE( sei.m_nestingNoOpMaxTemporalIdPlus1, 3, "nesting_no_op_max_temporal_id" );
    647       WRITE_CODE( sei.m_nestingMaxTemporalIdPlus1[i], 3,  "nesting_max_temporal_id"       );
    648       WRITE_UVLC( sei.m_nestingOpIdx[i],                  "nesting_op_idx"                );
    649     }
    650   }
    651   else
    652   {
    653     WRITE_FLAG( sei.m_allLayersFlag,                      "all_layers_flag"               );
    654     if (!sei.m_allLayersFlag)
    655     {
    656       WRITE_CODE( sei.m_nestingNoOpMaxTemporalIdPlus1, 3, "nesting_no_op_max_temporal_id" );
    657       WRITE_UVLC( sei.m_nestingNumLayersMinus1,           "nesting_num_layers"            );
    658       for (UInt i = 0; i <= sei.m_nestingNumLayersMinus1; i++)
    659       {
    660         WRITE_CODE( sei.m_nestingLayerId[i], 6,           "nesting_layer_id"              );
    661       }
    662     }
    663   }
    664  
    665   // byte alignment
    666   while ( m_pcBitIf->getNumberOfWrittenBits() % 8 != 0 )
    667   {
    668     WRITE_FLAG( 0, "nesting_zero_bit" );
    669   }
    670 
    671   // write nested SEI messages
    672   for (SEIMessages::const_iterator it = sei.m_nestedSEIs.begin(); it != sei.m_nestedSEIs.end(); it++)
    673   {
    674     writeSEImessage(bs, *(*it), sps);
    675   }
    676 }
    677 
    678 Void SEIWriter::xWriteByteAlign()
    679 {
    680   if( m_pcBitIf->getNumberOfWrittenBits() % 8 != 0)
    681   {
    682     WRITE_FLAG( 1, "bit_equal_to_one" );
    683     while( m_pcBitIf->getNumberOfWrittenBits() % 8 != 0 )
    684     {
    685       WRITE_FLAG( 0, "bit_equal_to_zero" );
    686     }
    687   }
    688 };
     695#endif //SVC_EXTENSION
    689696
    690697//! \}
  • trunk/source/Lib/TLibEncoder/SEIwrite.h

    r588 r595  
    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 *
     
    6464  Void xWriteSEIGradualDecodingRefreshInfo(const SEIGradualDecodingRefreshInfo &sei);
    6565  Void xWriteSEIToneMappingInfo(const SEIToneMappingInfo& sei);
     66  Void xWriteSEISOPDescription(const SEISOPDescription& sei);
     67  Void xWriteSEIScalableNesting(TComBitIf& bs, const SEIScalableNesting& sei, TComSPS *sps);
     68  Void xWriteByteAlign();
     69#if SVC_EXTENSION
    6670#if LAYERS_NOT_PRESENT_SEI
    6771  Void xWriteSEILayersNotPresent(const SEILayersNotPresent& sei);
    6872#endif
    69   Void xWriteSEISOPDescription(const SEISOPDescription& sei);
    7073#if N0383_IL_CONSTRAINED_TILE_SETS_SEI
    7174  Void xWriteSEIInterLayerConstrainedTileSets(const SEIInterLayerConstrainedTileSets& sei);
     
    7477  Void xWriteSEISubBitstreamProperty(const SEISubBitstreamProperty &sei);
    7578#endif
    76   Void xWriteSEIScalableNesting(TComBitIf& bs, const SEIScalableNesting& sei, TComSPS *sps);
    77   Void xWriteByteAlign();
     79#endif //SVC_EXTENSION
    7880};
    7981
  • trunk/source/Lib/TLibEncoder/SyntaxElementWriter.cpp

    r313 r595  
    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 *
  • trunk/source/Lib/TLibEncoder/SyntaxElementWriter.h

    r313 r595  
    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 *
  • trunk/source/Lib/TLibEncoder/TEncAnalyze.cpp

    r540 r595  
    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 *
  • trunk/source/Lib/TLibEncoder/TEncAnalyze.h

    r540 r595  
    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 *
  • trunk/source/Lib/TLibEncoder/TEncBinCoder.h

    r313 r595  
    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 *
  • trunk/source/Lib/TLibEncoder/TEncBinCoderCABAC.cpp

    r313 r595  
    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 *
  • trunk/source/Lib/TLibEncoder/TEncBinCoderCABAC.h

    r313 r595  
    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 *
  • trunk/source/Lib/TLibEncoder/TEncBinCoderCABACCounter.cpp

    r313 r595  
    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 *
  • trunk/source/Lib/TLibEncoder/TEncBinCoderCABACCounter.h

    r313 r595  
    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 *
  • trunk/source/Lib/TLibEncoder/TEncCavlc.cpp

    r588 r595  
    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 *
     
    579579  }
    580580  WRITE_FLAG( pcSPS->getTMVPFlagsPresent()  ? 1 : 0,           "sps_temporal_mvp_enable_flag" );
     581
    581582  WRITE_FLAG( pcSPS->getUseStrongIntraSmoothing(),             "sps_strong_intra_smoothing_enable_flag" );
    582583
     
    17331734         WRITE_FLAG( pcSlice->getSaoEnabledFlag(), "slice_sao_luma_flag" );         
    17341735#if AUXILIARY_PICTURES
    1735          if (pcSlice->getChromaFormatIdc() != CHROMA_400)
    1736          {
    1737 #endif
    1738 #if HM_CLEANUP_SAO
     1736         if (pcSlice->getChromaFormatIdc() != CHROMA_400)         
     1737#endif
    17391738         WRITE_FLAG( pcSlice->getSaoEnabledFlagChroma(), "slice_sao_chroma_flag" );
    1740 #else
    1741          {
    1742            SAOParam *saoParam = pcSlice->getPic()->getPicSym()->getSaoParam();
    1743            WRITE_FLAG( saoParam->bSaoFlag[1], "slice_sao_chroma_flag" );
    1744          }
    1745 #endif
    1746 #if AUXILIARY_PICTURES
    1747          }
    1748 #endif
    17491739      }
    17501740    }   
  • trunk/source/Lib/TLibEncoder/TEncCavlc.h

    r588 r595  
    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 *
     
    8888  UInt  getCoeffCost          ()                { return  m_uiCoeffCost;  }
    8989  Void  codeVPS                 ( TComVPS* pcVPS );
    90 #if VPS_EXTNS
    91   Void  codeVPSExtension        ( TComVPS* pcVPS );
    92 #endif
    93 
    94 #if VPS_VUI
    95   Void codeVPSVUI               (TComVPS *vps);
    96 #endif
    97 #if REPN_FORMAT_IN_VPS
    98   Void  codeRepFormat           ( RepFormat *repFormat );
    99 #endif
    100 #if VPS_DPB_SIZE_TABLE
    101   Void  codeVpsDpbSizeTable      (TComVPS *vps);
    102 #endif
    10390  Void  codeVUI                 ( TComVUI *pcVUI, TComSPS* pcSPS );
    10491  Void  codeSPS                 ( TComSPS* pcSPS );
    105 #if SPS_EXTENSION
    106   Void codeSPSExtension         ( TComSPS* pcSPS );
    107 #endif
    10892  Void  codePPS                 ( TComPPS* pcPPS );
    10993  Void  codeSliceHeader         ( TComSlice* pcSlice );
     
    116100 
    117101  Void codeMVPIdx ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefList );
    118 #if HM_CLEANUP_SAO
    119102  Void codeSAOBlkParam(SAOBlkParam& saoBlkParam, Bool* sliceEnabled, Bool leftMergeAvail, Bool aboveMergeAvail, Bool onlyEstMergeInfo = false){printf("only supported in CABAC"); assert(0); exit(-1);}
    120 #else
    121   Void codeSAOSign       ( UInt code   ) { printf("Not supported\n"); assert (0); }
    122   Void codeSaoMaxUvlc    ( UInt   code, UInt maxSymbol ){printf("Not supported\n"); assert (0);}
    123   Void codeSaoMerge  ( UInt uiCode ){printf("Not supported\n"); assert (0);}
    124   Void codeSaoTypeIdx    ( UInt uiCode ){printf("Not supported\n"); assert (0);}
    125   Void codeSaoUflc       ( UInt uiLength, UInt   uiCode ){ assert(uiCode < 32); printf("Not supported\n"); assert (0);}
    126 #endif
    127103  Void codeCUTransquantBypassFlag( TComDataCU* pcCU, UInt uiAbsPartIdx );
    128104  Void codeSkipFlag      ( TComDataCU* pcCU, UInt uiAbsPartIdx );
     
    165141  Void codeDFSvlc       ( Int   iCode, const Char *pSymbolName );
    166142
     143#if SPS_EXTENSION
     144  Void codeSPSExtension         ( TComSPS* pcSPS );
     145#if VPS_EXTNS
     146  Void  codeVPSExtension        ( TComVPS* pcVPS );
     147#endif
     148#if VPS_VUI
     149  Void codeVPSVUI               (TComVPS *vps);
     150#endif
     151#if REPN_FORMAT_IN_VPS
     152  Void  codeRepFormat           ( RepFormat *repFormat );
     153#endif
     154#if VPS_DPB_SIZE_TABLE
     155  Void  codeVpsDpbSizeTable      (TComVPS *vps);
     156#endif
     157#endif //SVC_EXTENSION
     158
    167159};
    168160
  • trunk/source/Lib/TLibEncoder/TEncCfg.h

    r588 r595  
    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 *
     
    9191
    9292std::istringstream &operator>>(std::istringstream &in, GOPEntry &entry);     //input
    93 
    94 #if REPN_FORMAT_IN_VPS
    95 struct RepFormatCfg
    96 {
    97   Int   m_chromaFormatIdc;
    98   Bool  m_separateColourPlaneFlag;
    99   Int   m_picWidthInLumaSamples;
    100   Int   m_picHeightInLumaSamples;
    101   Int   m_bitDepthLuma;
    102   Int   m_bitDepthChroma;
    103   RepFormatCfg()
    104     : m_chromaFormatIdc         (CHROMA_420)
    105     , m_separateColourPlaneFlag (0)
    106     , m_picWidthInLumaSamples   (352)
    107     , m_picHeightInLumaSamples  (288)
    108     , m_bitDepthLuma            (8)
    109     , m_bitDepthChroma          (8)
    110   {}
    111 };
    112 std::istringstream &operator>>(std::istringstream &in, RepFormatCfg &repFormatCfg);
    113 #endif
    114 
    11593//! \ingroup TLibEncoder
    11694//! \{
     
    162140  Int       m_maxTempLayer;                      ///< Max temporal layer
    163141  Bool m_useAMP;
    164 #if VPS_EXTN_DIRECT_REF_LAYERS
    165   Int       m_numDirectRefLayers;
    166   Int       m_refLayerId[MAX_VPS_LAYER_ID_PLUS1];
    167 
    168   Int       m_numActiveRefLayers;
    169   Int       m_predLayerId[MAX_VPS_LAYER_ID_PLUS1];
    170   Int       m_numSamplePredRefLayers;
    171   Int       m_samplePredRefLayerId[MAX_VPS_LAYER_ID_PLUS1];
    172   Int       m_numMotionPredRefLayers;
    173   Int       m_motionPredRefLayerId[MAX_VPS_LAYER_ID_PLUS1];
    174   Bool      m_samplePredEnabledFlag[MAX_VPS_LAYER_ID_PLUS1];
    175   Bool      m_motionPredEnabledFlag[MAX_VPS_LAYER_ID_PLUS1];
    176 #endif
    177 #if N0120_MAX_TID_REF_CFG
    178   Int       m_maxTidIlRefPicsPlus1;
    179 #endif
    180142  //======= Transform =============
    181143  UInt      m_uiQuadtreeTULog2MaxSize;
     
    194156  Int       m_maxNumOffsetsPerPic;
    195157  Bool      m_saoLcuBoundary;
    196 #if !HM_CLEANUP_SAO
    197   Bool      m_saoLcuBasedOptimization;
    198 #endif
    199   //====== Lossless ========
    200   Bool      m_useLossless;
    201158  //====== Motion search ========
    202159  Int       m_iFastSearch;                      //  0:Full search  1:Diamond  2:PMVFAST
     
    210167  Int       m_chromaCbQpOffset;                 //  Chroma Cb QP Offset (0:default)
    211168  Int       m_chromaCrQpOffset;                 //  Chroma Cr Qp Offset (0:default)
    212 #if AUXILIARY_PICTURES
    213   ChromaFormat m_chromaFormatIDC;
    214 #endif
    215169
    216170#if ADAPTIVE_QP_SELECTION
     
    222176 
    223177  //====== Tool list ========
    224   Bool      m_bUseSBACRD;
    225178  Bool      m_bUseASR;
    226179  Bool      m_bUseHADME;
     
    233186  Bool      m_bUseCbfFastMode;
    234187  Bool      m_useEarlySkipDetection;
    235 #if FAST_INTRA_SHVC
    236   Bool      m_useFastIntraScalable;
    237 #endif
    238188  Bool      m_useTransformSkip;
    239189  Bool      m_useTransformSkipFast;
     
    305255  Int       m_gradualDecodingRefreshInfoEnabled;
    306256  Int       m_decodingUnitInfoSEIEnabled;
    307 #if LAYERS_NOT_PRESENT_SEI
    308   Int       m_layersNotPresentSEIEnabled;
    309 #endif
    310257  Int       m_SOPDescriptionSEIEnabled;
    311258  Int       m_scalableNestingSEIEnabled;
    312 #if N0383_IL_CONSTRAINED_TILE_SETS_SEI
    313   Bool      m_interLayerConstrainedTileSetsSEIEnabled;
    314   UInt      m_ilNumSetsInMessage;
    315   Bool      m_skippedTileSetPresentFlag;
    316   UInt      m_topLeftTileIndex[1024];
    317   UInt      m_bottomRightTileIndex[1024];
    318   UInt      m_ilcIdc[1024];
    319 #endif
    320259  //====== Weighted Prediction ========
    321260  Bool      m_useWeightedPred;       //< Use of Weighting Prediction (P_SLICE)
     
    335274  Bool      m_RCForceIntraQP;
    336275  Bool      m_TransquantBypassEnableFlag;                     ///< transquant_bypass_enable_flag setting in PPS.
    337   Bool      m_CUTransquantBypassFlagValue;                    ///< if transquant_bypass_enable_flag, the fixed value to use for the per-CU cu_transquant_bypass_flag.
     276  Bool      m_CUTransquantBypassFlagForce;                    ///< if transquant_bypass_enable_flag, then, if true, all CU transquant bypass flags will be set to true.
    338277#if SVC_EXTENSION
    339   static TComVPS                    m_cVPS;
     278  static TComVPS             m_cVPS;
    340279#else
    341280  TComVPS                    m_cVPS;
     
    391330  Bool      m_crossLayerBLAFlag;
    392331#endif
    393 #endif
     332#if VPS_EXTN_DIRECT_REF_LAYERS
     333  Int       m_numDirectRefLayers;
     334  Int       m_refLayerId[MAX_VPS_LAYER_ID_PLUS1];
     335
     336  Int       m_numActiveRefLayers;
     337  Int       m_predLayerId[MAX_VPS_LAYER_ID_PLUS1];
     338  Int       m_numSamplePredRefLayers;
     339  Int       m_samplePredRefLayerId[MAX_VPS_LAYER_ID_PLUS1];
     340  Int       m_numMotionPredRefLayers;
     341  Int       m_motionPredRefLayerId[MAX_VPS_LAYER_ID_PLUS1];
     342  Bool      m_samplePredEnabledFlag[MAX_VPS_LAYER_ID_PLUS1];
     343  Bool      m_motionPredEnabledFlag[MAX_VPS_LAYER_ID_PLUS1];
     344#endif
     345#if N0120_MAX_TID_REF_CFG
     346  Int       m_maxTidIlRefPicsPlus1;
     347#endif
     348#if AUXILIARY_PICTURES
     349  ChromaFormat m_chromaFormatIDC;
     350#endif
     351#if FAST_INTRA_SHVC
     352  Bool      m_useFastIntraScalable;
     353#endif
     354#if LAYERS_NOT_PRESENT_SEI
     355  Int       m_layersNotPresentSEIEnabled;
     356#endif
     357#if N0383_IL_CONSTRAINED_TILE_SETS_SEI
     358  Bool      m_interLayerConstrainedTileSetsSEIEnabled;
     359  UInt      m_ilNumSetsInMessage;
     360  Bool      m_skippedTileSetPresentFlag;
     361  UInt      m_topLeftTileIndex[1024];
     362  UInt      m_bottomRightTileIndex[1024];
     363  UInt      m_ilcIdc[1024];
     364#endif
     365#endif //SVC_EXTENSION
    394366
    395367public:
     
    437409  Bool      getMaxTempLayer                 ()                              { return m_maxTempLayer;              }
    438410  Void      setMaxTempLayer                 ( Int maxTempLayer )            { m_maxTempLayer = maxTempLayer;      }
    439 #if VPS_EXTN_DIRECT_REF_LAYERS
    440   Int       getNumDirectRefLayers           ()                              { return m_numDirectRefLayers;      }
    441   Void      setNumDirectRefLayers           (Int num)                       { m_numDirectRefLayers = num;       }
    442 
    443   Int       getRefLayerId                   (Int i)                         { return m_refLayerId[i];           }
    444   Void      setRefLayerId                   (Int i, Int refLayerId)         { m_refLayerId[i] = refLayerId;     }
    445 
    446   Int       getNumActiveRefLayers           ()                              { return m_numActiveRefLayers;      }
    447   Void      setNumActiveRefLayers           (Int num)                       { m_numActiveRefLayers = num;       }
    448 
    449   Int       getPredLayerId                  (Int i)                         { return m_predLayerId[i];          }
    450   Void      setPredLayerId                  (Int i, Int refLayerId)         { m_predLayerId[i] = refLayerId;    }
    451 
    452   Int       getNumSamplePredRefLayers       ()                              { return m_numSamplePredRefLayers;  }
    453   Void      setNumSamplePredRefLayers       (Int num)                       { m_numSamplePredRefLayers = num;   }
    454 
    455   Int       getSamplePredRefLayerId         (Int i)                         { return m_samplePredRefLayerId[i];       }
    456   Void      setSamplePredRefLayerId         (Int i, Int refLayerId)         { m_samplePredRefLayerId[i] = refLayerId; }
    457 
    458   Int       getNumMotionPredRefLayers       ()                              { return m_numMotionPredRefLayers;  }
    459   Void      setNumMotionPredRefLayers       (Int num)                       { m_numMotionPredRefLayers = num;   }
    460 
    461   Int       getMotionPredRefLayerId         (Int i)                         { return m_motionPredRefLayerId[i];       }
    462   Void      setMotionPredRefLayerId         (Int i, Int refLayerId)         { m_motionPredRefLayerId[i] = refLayerId; }
    463 
    464   Bool      getSamplePredEnabledFlag        (Int i)                         { return m_samplePredEnabledFlag[i];  }
    465   Void      setSamplePredEnabledFlag        (Int i,Bool flag)               { m_samplePredEnabledFlag[i] = flag;  }
    466 
    467   Bool      getMotionPredEnabledFlag        (Int i)                         { return m_motionPredEnabledFlag[i];  }
    468   Void      setMotionPredEnabledFlag        (Int i,Bool flag)               { m_motionPredEnabledFlag[i] = flag;  }
    469 #endif
    470 #if N0120_MAX_TID_REF_CFG
    471   Int       getMaxTidIlRefPicsPlus1         ()                              { return m_maxTidIlRefPicsPlus1; }
    472   Void      setMaxTidIlRefPicsPlus1         (Int num)                       { m_maxTidIlRefPicsPlus1 = num;  }
    473 #endif
    474411  //======== Transform =============
    475412  Void      setQuadtreeTULog2MaxSize        ( UInt  u )      { m_uiQuadtreeTULog2MaxSize = u; }
     
    508445  Void      setQPAdaptationRange            ( Int   i )      { m_iQPAdaptationRange = i; }
    509446 
    510   //====== Lossless ========
    511   Void      setUseLossless                  (Bool    b  )        { m_useLossless = b;  }
    512447  //====== Sequence ========
    513448  Int       getFrameRate                    ()      { return  m_iFrameRate; }
     
    552487  Bool      getUseAdaptiveQP                ()      { return  m_bUseAdaptiveQP; }
    553488  Int       getQPAdaptationRange            ()      { return  m_iQPAdaptationRange; }
    554   //====== Lossless ========
    555   Bool      getUseLossless                  ()      { return  m_useLossless;  }
    556489 
    557490  //==== Tool list ========
    558   Void      setUseSBACRD                    ( Bool  b )     { m_bUseSBACRD  = b; }
    559491  Void      setUseASR                       ( Bool  b )     { m_bUseASR     = b; }
    560492  Void      setUseHADME                     ( Bool  b )     { m_bUseHADME   = b; }
     
    567499  Void      setUseCbfFastMode            ( Bool  b )     { m_bUseCbfFastMode = b; }
    568500  Void      setUseEarlySkipDetection        ( Bool  b )     { m_useEarlySkipDetection = b; }
    569 #if FAST_INTRA_SHVC
    570   Void      setUseFastIntraScalable         ( Bool  b )     { m_useFastIntraScalable = b; }
    571 #endif
    572501  Void      setUseConstrainedIntraPred      ( Bool  b )     { m_bUseConstrainedIntraPred = b; }
    573502  Void      setPCMInputBitDepthFlag         ( Bool  b )     { m_bPCMInputBitDepthFlag = b; }
     
    578507  Void      setdQPs                         ( Int*  p )     { m_aidQP       = p; }
    579508  Void      setDeltaQpRD                    ( UInt  u )     {m_uiDeltaQpRD  = u; }
    580   Bool      getUseSBACRD                    ()      { return m_bUseSBACRD;  }
    581509  Bool      getUseASR                       ()      { return m_bUseASR;     }
    582510  Bool      getUseHADME                     ()      { return m_bUseHADME;   }
     
    589517  Bool      getUseCbfFastMode           ()      { return m_bUseCbfFastMode; }
    590518  Bool      getUseEarlySkipDetection        ()      { return m_useEarlySkipDetection; }
    591 #if FAST_INTRA_SHVC
    592   Bool      getUseFastIntraScalable         ()      { return m_useFastIntraScalable; }
    593 #endif
    594519  Bool      getUseConstrainedIntraPred      ()      { return m_bUseConstrainedIntraPred; }
    595520  Bool      getPCMInputBitDepthFlag         ()      { return m_bPCMInputBitDepthFlag;   }
     
    625550  Void  setSaoLcuBoundary              (Bool val)      { m_saoLcuBoundary = val; }
    626551  Bool  getSaoLcuBoundary              ()              { return m_saoLcuBoundary; }
    627 #if !HM_CLEANUP_SAO
    628   Void  setSaoLcuBasedOptimization               (Bool val)            { m_saoLcuBasedOptimization = val; }
    629   Bool  getSaoLcuBasedOptimization               ()                    { return m_saoLcuBasedOptimization; }
    630 #endif
    631552  Void  setLFCrossTileBoundaryFlag               ( Bool   val  )       { m_loopFilterAcrossTilesEnabledFlag = val; }
    632553  Bool  getLFCrossTileBoundaryFlag               ()                    { return m_loopFilterAcrossTilesEnabledFlag;   }
     
    748669  Void  setDecodingUnitInfoSEIEnabled(Int b)                { m_decodingUnitInfoSEIEnabled = b;    }
    749670  Int   getDecodingUnitInfoSEIEnabled()                     { return m_decodingUnitInfoSEIEnabled; }
    750 #if LAYERS_NOT_PRESENT_SEI
    751   Void  setLayersNotPresentSEIEnabled(Int b)             { m_layersNotPresentSEIEnabled = b; }
    752   Int   getLayersNotPresentSEIEnabled()                  { return m_layersNotPresentSEIEnabled; }
    753 #endif
    754671  Void  setSOPDescriptionSEIEnabled(Int b)                { m_SOPDescriptionSEIEnabled = b; }
    755672  Int   getSOPDescriptionSEIEnabled()                     { return m_SOPDescriptionSEIEnabled; }
    756673  Void  setScalableNestingSEIEnabled(Int b)                { m_scalableNestingSEIEnabled = b; }
    757674  Int   getScalableNestingSEIEnabled()                     { return m_scalableNestingSEIEnabled; }
    758 #if N0383_IL_CONSTRAINED_TILE_SETS_SEI
    759   Void  setInterLayerConstrainedTileSetsSEIEnabled(Bool b) { m_interLayerConstrainedTileSetsSEIEnabled = b; }
    760   Bool  getInterLayerConstrainedTileSetsSEIEnabled()       { return m_interLayerConstrainedTileSetsSEIEnabled; }
    761   Void  setIlNumSetsInMessage(UInt b)                      { m_ilNumSetsInMessage = b; }
    762   Int   getIlNumSetsInMessage()                            { return m_ilNumSetsInMessage; }
    763   Void  setSkippedTileSetPresentFlag(Bool b)               { m_skippedTileSetPresentFlag = b; }
    764   Bool  getSkippedTileSetPresentFlag()                     { return m_skippedTileSetPresentFlag; }
    765   Void  setTopLeftTileIndex(UInt *b)
    766   {
    767     for (UInt i = 0; i < m_ilNumSetsInMessage; i++)
    768     {
    769       m_topLeftTileIndex[i] = b[i];
    770     }
    771   }
    772   UInt  getTopLeftTileIndex(UInt b)                        { return m_topLeftTileIndex[b]; }
    773   Void  setBottomRightTileIndex(UInt *b)
    774   {
    775     for (UInt i = 0; i < m_ilNumSetsInMessage; i++)
    776     {
    777       m_bottomRightTileIndex[i] = b[i];
    778     }
    779   }
    780   UInt  getBottomRightTileIndex(UInt b)                    { return m_bottomRightTileIndex[b]; }
    781   Void  setIlcIdc(UInt *b)
    782   {
    783     for (UInt i = 0; i < m_ilNumSetsInMessage; i++)
    784     {
    785       m_ilcIdc[i] = b[i];
    786     }
    787   }
    788   UInt  getIlcIdc(UInt b)                                  { return m_ilcIdc[b]; }
    789 #endif
    790675  Void      setUseWP               ( Bool b )    { m_useWeightedPred   = b;    }
    791676  Void      setWPBiPred            ( Bool b )    { m_useWeightedBiPred = b;    }
     
    820705  Bool      getTransquantBypassEnableFlag()           { return m_TransquantBypassEnableFlag; }
    821706  Void      setTransquantBypassEnableFlag(Bool flag)  { m_TransquantBypassEnableFlag = flag; }
    822   Bool      getCUTransquantBypassFlagValue()          { return m_CUTransquantBypassFlagValue; }
    823   Void      setCUTransquantBypassFlagValue(Bool flag) { m_CUTransquantBypassFlagValue = flag; }
     707  Bool      getCUTransquantBypassFlagForceValue()          { return m_CUTransquantBypassFlagForce; }
     708  Void      setCUTransquantBypassFlagForceValue(Bool flag) { m_CUTransquantBypassFlagForce = flag; }
    824709  Void setVPS(TComVPS *p) { m_cVPS = *p; }
    825710  TComVPS *getVPS() { return &m_cVPS; }
     
    934819  Void      setCrossLayerBLAFlag(Bool b) { m_crossLayerBLAFlag = b;    }
    935820#endif
     821#if FAST_INTRA_SHVC
     822  Bool      getUseFastIntraScalable         ()      { return m_useFastIntraScalable; }
     823  Void      setUseFastIntraScalable         ( Bool  b )     { m_useFastIntraScalable = b; }
     824#endif
     825#if VPS_EXTN_DIRECT_REF_LAYERS
     826  Int       getNumDirectRefLayers           ()                              { return m_numDirectRefLayers;      }
     827  Void      setNumDirectRefLayers           (Int num)                       { m_numDirectRefLayers = num;       }
     828
     829  Int       getRefLayerId                   (Int i)                         { return m_refLayerId[i];           }
     830  Void      setRefLayerId                   (Int i, Int refLayerId)         { m_refLayerId[i] = refLayerId;     }
     831
     832  Int       getNumActiveRefLayers           ()                              { return m_numActiveRefLayers;      }
     833  Void      setNumActiveRefLayers           (Int num)                       { m_numActiveRefLayers = num;       }
     834
     835  Int       getPredLayerId                  (Int i)                         { return m_predLayerId[i];          }
     836  Void      setPredLayerId                  (Int i, Int refLayerId)         { m_predLayerId[i] = refLayerId;    }
     837
     838  Int       getNumSamplePredRefLayers       ()                              { return m_numSamplePredRefLayers;  }
     839  Void      setNumSamplePredRefLayers       (Int num)                       { m_numSamplePredRefLayers = num;   }
     840
     841  Int       getSamplePredRefLayerId         (Int i)                         { return m_samplePredRefLayerId[i];       }
     842  Void      setSamplePredRefLayerId         (Int i, Int refLayerId)         { m_samplePredRefLayerId[i] = refLayerId; }
     843
     844  Int       getNumMotionPredRefLayers       ()                              { return m_numMotionPredRefLayers;  }
     845  Void      setNumMotionPredRefLayers       (Int num)                       { m_numMotionPredRefLayers = num;   }
     846
     847  Int       getMotionPredRefLayerId         (Int i)                         { return m_motionPredRefLayerId[i];       }
     848  Void      setMotionPredRefLayerId         (Int i, Int refLayerId)         { m_motionPredRefLayerId[i] = refLayerId; }
     849
     850  Bool      getSamplePredEnabledFlag        (Int i)                         { return m_samplePredEnabledFlag[i];  }
     851  Void      setSamplePredEnabledFlag        (Int i,Bool flag)               { m_samplePredEnabledFlag[i] = flag;  }
     852
     853  Bool      getMotionPredEnabledFlag        (Int i)                         { return m_motionPredEnabledFlag[i];  }
     854  Void      setMotionPredEnabledFlag        (Int i,Bool flag)               { m_motionPredEnabledFlag[i] = flag;  }
     855#endif
     856#if N0120_MAX_TID_REF_CFG
     857  Int       getMaxTidIlRefPicsPlus1         ()                              { return m_maxTidIlRefPicsPlus1; }
     858  Void      setMaxTidIlRefPicsPlus1         (Int num)                       { m_maxTidIlRefPicsPlus1 = num;  }
     859#endif
     860#if LAYERS_NOT_PRESENT_SEI
     861  Void  setLayersNotPresentSEIEnabled(Int b)             { m_layersNotPresentSEIEnabled = b; }
     862  Int   getLayersNotPresentSEIEnabled()                  { return m_layersNotPresentSEIEnabled; }
     863#endif
     864#if N0383_IL_CONSTRAINED_TILE_SETS_SEI
     865  Void  setInterLayerConstrainedTileSetsSEIEnabled(Bool b) { m_interLayerConstrainedTileSetsSEIEnabled = b; }
     866  Bool  getInterLayerConstrainedTileSetsSEIEnabled()       { return m_interLayerConstrainedTileSetsSEIEnabled; }
     867  Void  setIlNumSetsInMessage(UInt b)                      { m_ilNumSetsInMessage = b; }
     868  Int   getIlNumSetsInMessage()                            { return m_ilNumSetsInMessage; }
     869  Void  setSkippedTileSetPresentFlag(Bool b)               { m_skippedTileSetPresentFlag = b; }
     870  Bool  getSkippedTileSetPresentFlag()                     { return m_skippedTileSetPresentFlag; }
     871  Void  setTopLeftTileIndex(UInt *b)
     872  {
     873    for (UInt i = 0; i < m_ilNumSetsInMessage; i++)
     874    {
     875      m_topLeftTileIndex[i] = b[i];
     876    }
     877  }
     878  UInt  getTopLeftTileIndex(UInt b)                        { return m_topLeftTileIndex[b]; }
     879  Void  setBottomRightTileIndex(UInt *b)
     880  {
     881    for (UInt i = 0; i < m_ilNumSetsInMessage; i++)
     882    {
     883      m_bottomRightTileIndex[i] = b[i];
     884    }
     885  }
     886  UInt  getBottomRightTileIndex(UInt b)                    { return m_bottomRightTileIndex[b]; }
     887  Void  setIlcIdc(UInt *b)
     888  {
     889    for (UInt i = 0; i < m_ilNumSetsInMessage; i++)
     890    {
     891      m_ilcIdc[i] = b[i];
     892    }
     893  }
     894  UInt  getIlcIdc(UInt b)                                  { return m_ilcIdc[b]; }
     895#endif
    936896#endif
    937897};
    938898
     899#if SVC_EXTENSION
     900#if REPN_FORMAT_IN_VPS
     901struct RepFormatCfg
     902{
     903  Int   m_chromaFormatIdc;
     904  Bool  m_separateColourPlaneFlag;
     905  Int   m_picWidthInLumaSamples;
     906  Int   m_picHeightInLumaSamples;
     907  Int   m_bitDepthLuma;
     908  Int   m_bitDepthChroma;
     909  RepFormatCfg()
     910    : m_chromaFormatIdc         (CHROMA_420)
     911    , m_separateColourPlaneFlag (0)
     912    , m_picWidthInLumaSamples   (352)
     913    , m_picHeightInLumaSamples  (288)
     914    , m_bitDepthLuma            (8)
     915    , m_bitDepthChroma          (8)
     916  {}
     917};
     918std::istringstream &operator>>(std::istringstream &in, RepFormatCfg &repFormatCfg);
     919#endif
     920#endif //SVC_EXTENSION
     921
    939922//! \}
    940923
  • trunk/source/Lib/TLibEncoder/TEncCu.cpp

    r588 r595  
    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 *
     
    223223  m_pcRDGoOnSbacCoder = pcEncTop->getRDGoOnSbacCoder();
    224224 
    225   m_bUseSBACRD        = pcEncTop->getUseSBACRD();
    226225  m_pcRateCtrl        = pcEncTop->getRateCtrl();
    227226}
     
    394393  Int iMaxQP;
    395394  Bool isAddLowestQP = false;
    396 #if REPN_FORMAT_IN_VPS
    397   Int lowestQP = -rpcTempCU->getSlice()->getQpBDOffsetY();
    398 #else
    399   Int lowestQP = -rpcTempCU->getSlice()->getSPS()->getQpBDOffsetY();
    400 #endif
    401395
    402396  if( (g_uiMaxCUWidth>>uiDepth) >= rpcTempCU->getSlice()->getPPS()->getMinCuDQPSize() )
     
    409403    iMinQP = Clip3( -rpcTempCU->getSlice()->getSPS()->getQpBDOffsetY(), MAX_QP, iBaseQP-idQP );
    410404    iMaxQP = Clip3( -rpcTempCU->getSlice()->getSPS()->getQpBDOffsetY(), MAX_QP, iBaseQP+idQP );
    411 #endif
    412     if ( (rpcTempCU->getSlice()->getSPS()->getUseLossless()) && (lowestQP < iMinQP) && rpcTempCU->getSlice()->getPPS()->getUseDQP() )
    413     {
    414       isAddLowestQP = true;
    415       iMinQP = iMinQP - 1;
    416     }
     405#endif   
    417406  }
    418407  else
     
    426415    iMinQP = m_pcRateCtrl->getRCQP();
    427416    iMaxQP = m_pcRateCtrl->getRCQP();
     417  }
     418
     419  // transquant-bypass (TQB) processing loop variable initialisation ---
     420
     421  const Int lowestQP = iMinQP; // For TQB, use this QP which is the lowest non TQB QP tested (rather than QP'=0) - that way delta QPs are smaller, and TQB can be tested at all CU levels.
     422
     423  if ( (rpcTempCU->getSlice()->getPPS()->getTransquantBypassEnableFlag()) )
     424  {
     425    isAddLowestQP = true; // mark that the first iteration is to cost TQB mode.
     426    iMinQP = iMinQP - 1;  // increase loop variable range by 1, to allow testing of TQB mode along with other QPs
     427    if ( m_pcEncCfg->getCUTransquantBypassFlagForceValue() )
     428    {
     429      iMaxQP = iMinQP;
     430    }
    428431  }
    429432
     
    443446    if (m_pcEncCfg->getSkipPictureAtArcSwitch() && m_pcEncCfg->getAdaptiveResolutionChange() > 0 && pcSlice->getLayerId() == 1 && pcSlice->getPOC() == m_pcEncCfg->getAdaptiveResolutionChange())
    444447    {
    445       rpcTempCU->initEstData( uiDepth, iBaseQP );
     448      Int iQP = iBaseQP;
     449      const Bool bIsLosslessMode = isAddLowestQP && (iQP == iMinQP);
     450
     451      if( bIsLosslessMode )
     452      {
     453        iQP = lowestQP;
     454      }
     455
     456      rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );
    446457     
    447458      xCheckRDCostMerge2Nx2N( rpcBestCU, rpcTempCU, &earlyDetectionSkipMode, true );
     
    466477    for (Int iQP=iMinQP; iQP<=iMaxQP; iQP++)
    467478    {
    468       if (isAddLowestQP && (iQP == iMinQP))
     479      const Bool bIsLosslessMode = isAddLowestQP && (iQP == iMinQP);
     480
     481      if (bIsLosslessMode)
    469482      {
    470483        iQP = lowestQP;
    471484      }
    472485
    473       rpcTempCU->initEstData( uiDepth, iQP );
     486      rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );
    474487
    475488      // do inter modes, SKIP and 2Nx2N
     
    483496        if(m_pcEncCfg->getUseEarlySkipDetection())
    484497        {
    485           xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2Nx2N );  rpcTempCU->initEstData( uiDepth, iQP );//by Competition for inter_2Nx2N
     498          xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2Nx2N );
     499          rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );//by Competition for inter_2Nx2N
    486500        }
    487501        // SKIP
    488502        xCheckRDCostMerge2Nx2N( rpcBestCU, rpcTempCU, &earlyDetectionSkipMode );//by Merge for inter_2Nx2N
    489         rpcTempCU->initEstData( uiDepth, iQP );
     503        rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );
    490504       
    491505#if (ENCODER_FAST_MODE == 2)
     
    496510        {
    497511          // 2Nx2N, NxN
    498           xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2Nx2N );  rpcTempCU->initEstData( uiDepth, iQP );
     512          xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2Nx2N );
     513          rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );
    499514          if(m_pcEncCfg->getUseCbfFastMode())
    500515          {
     
    507522      }
    508523
    509       if (isAddLowestQP && (iQP == lowestQP))
     524      if (bIsLosslessMode)
    510525      {
    511526        iQP = iMinQP;
     
    517532      for (Int iQP=iMinQP; iQP<=iMaxQP; iQP++)
    518533      {
    519         if (isAddLowestQP && (iQP == iMinQP))
     534        const Bool bIsLosslessMode = isAddLowestQP && (iQP == iMinQP);
     535
     536        if (bIsLosslessMode)
    520537        {
    521538          iQP = lowestQP;
    522539        }
    523         rpcTempCU->initEstData( uiDepth, iQP );
     540        rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );
    524541
    525542        // do inter modes, NxN, 2NxN, and Nx2N
     
    536553            {
    537554              xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_NxN   );
    538               rpcTempCU->initEstData( uiDepth, iQP );
     555              rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );
    539556            }
    540557          }
     
    544561          {
    545562            xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_Nx2N  );
    546             rpcTempCU->initEstData( uiDepth, iQP );
     563            rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );
    547564            if(m_pcEncCfg->getUseCbfFastMode() && rpcBestCU->getPartitionSize(0) == SIZE_Nx2N )
    548565            {
     
    553570          {
    554571            xCheckRDCostInter      ( rpcBestCU, rpcTempCU, SIZE_2NxN  );
    555             rpcTempCU->initEstData( uiDepth, iQP );
     572            rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );
    556573            if(m_pcEncCfg->getUseCbfFastMode() && rpcBestCU->getPartitionSize(0) == SIZE_2NxN)
    557574            {
     
    581598              {
    582599                xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnU );
    583                 rpcTempCU->initEstData( uiDepth, iQP );
     600                rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );
    584601                if(m_pcEncCfg->getUseCbfFastMode() && rpcBestCU->getPartitionSize(0) == SIZE_2NxnU )
    585602                {
     
    590607              {
    591608                xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnD );
    592                 rpcTempCU->initEstData( uiDepth, iQP );
     609                rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );
    593610                if(m_pcEncCfg->getUseCbfFastMode() && rpcBestCU->getPartitionSize(0) == SIZE_2NxnD )
    594611                {
     
    603620              {
    604621                xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnU, true );
    605                 rpcTempCU->initEstData( uiDepth, iQP );
     622                rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );
    606623                if(m_pcEncCfg->getUseCbfFastMode() && rpcBestCU->getPartitionSize(0) == SIZE_2NxnU )
    607624                {
     
    612629              {
    613630                xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnD, true );
    614                 rpcTempCU->initEstData( uiDepth, iQP );
     631                rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );
    615632                if(m_pcEncCfg->getUseCbfFastMode() && rpcBestCU->getPartitionSize(0) == SIZE_2NxnD )
    616633                {
     
    627644              {
    628645                xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nLx2N );
    629                 rpcTempCU->initEstData( uiDepth, iQP );
     646                rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );
    630647                if(m_pcEncCfg->getUseCbfFastMode() && rpcBestCU->getPartitionSize(0) == SIZE_nLx2N )
    631648                {
     
    636653              {
    637654                xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nRx2N );
    638                 rpcTempCU->initEstData( uiDepth, iQP );
     655                rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );
    639656              }
    640657            }
     
    645662              {
    646663                xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nLx2N, true );
    647                 rpcTempCU->initEstData( uiDepth, iQP );
     664                rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );
    648665                if(m_pcEncCfg->getUseCbfFastMode() && rpcBestCU->getPartitionSize(0) == SIZE_nLx2N )
    649666                {
     
    654671              {
    655672                xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nRx2N, true );
    656                 rpcTempCU->initEstData( uiDepth, iQP );
     673                rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );
    657674              }
    658675            }
     
    661678#else
    662679            xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnU );
    663             rpcTempCU->initEstData( uiDepth, iQP );
     680            rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );
    664681            xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnD );
    665             rpcTempCU->initEstData( uiDepth, iQP );
     682            rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );
    666683            xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nLx2N );
    667             rpcTempCU->initEstData( uiDepth, iQP );
     684            rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );
    668685
    669686            xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nRx2N );
    670             rpcTempCU->initEstData( uiDepth, iQP );
     687            rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );
    671688
    672689#endif
     
    691708          {
    692709            xCheckRDCostIntra( rpcBestCU, rpcTempCU, SIZE_2Nx2N );
    693             rpcTempCU->initEstData( uiDepth, iQP );
     710          rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );
    694711            if( uiDepth == g_uiMaxCUDepth - g_uiAddCUDepth )
    695712            {
     
    697714              {
    698715                xCheckRDCostIntra( rpcBestCU, rpcTempCU, SIZE_NxN   );
    699                 rpcTempCU->initEstData( uiDepth, iQP );
     716              rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );
    700717              }
    701718            }
     
    712729          {
    713730            xCheckIntraPCM (rpcBestCU, rpcTempCU);
    714             rpcTempCU->initEstData( uiDepth, iQP );
     731            rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );
    715732          }
    716733        }
     
    725742        { 
    726743           xCheckRDCostILRUni( rpcBestCU, rpcTempCU, pcSlice->getInterLayerPredLayerIdc(refLayer));
    727            rpcTempCU->initEstData( uiDepth, iQP );
     744           rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );
    728745        }
    729746      }
    730747#endif
    731748
    732         if (isAddLowestQP && (iQP == lowestQP))
     749        if (bIsLosslessMode)
    733750        {
    734751          iQP = iMinQP;
     
    740757    m_pcEntropyCoder->encodeSplitFlag( rpcBestCU, 0, uiDepth, true );
    741758    rpcBestCU->getTotalBits() += m_pcEntropyCoder->getNumberOfWrittenBits(); // split bits
    742     if(m_pcEncCfg->getUseSBACRD())
    743     {
    744759      rpcBestCU->getTotalBins() += ((TEncBinCABAC *)((TEncSbac*)m_pcEntropyCoder->m_pcEntropyCoderIf)->getEncBinIf())->getBinsCoded();
    745     }
    746760    rpcBestCU->getTotalCost()  = m_pcRdCost->calcRdCost( rpcBestCU->getTotalBits(), rpcBestCU->getTotalDistortion() );
    747761
     
    778792    iMinQP = Clip3( -rpcTempCU->getSlice()->getSPS()->getQpBDOffsetY(), MAX_QP, iBaseQP-idQP );
    779793    iMaxQP = Clip3( -rpcTempCU->getSlice()->getSPS()->getQpBDOffsetY(), MAX_QP, iBaseQP+idQP );
    780 #endif
    781     if ( (rpcTempCU->getSlice()->getSPS()->getUseLossless()) && (lowestQP < iMinQP) && rpcTempCU->getSlice()->getPPS()->getUseDQP() )
    782     {
    783       isAddLowestQP = true;
    784       iMinQP = iMinQP - 1;     
    785     }
     794#endif   
    786795  }
    787796  else if( (g_uiMaxCUWidth>>uiDepth) > rpcTempCU->getSlice()->getPPS()->getMinCuDQPSize() )
     
    810819    iMaxQP = m_pcRateCtrl->getRCQP();
    811820  }
     821
     822  if ( m_pcEncCfg->getCUTransquantBypassFlagForceValue() )
     823    {
     824    iMaxQP = iMinQP; // If all blocks are forced into using transquant bypass, do not loop here.
     825    }
     826
    812827  for (Int iQP=iMinQP; iQP<=iMaxQP; iQP++)
    813828  {
    814     if (isAddLowestQP && (iQP == iMinQP))
    815     {
    816       iQP = lowestQP;
    817     }
    818     rpcTempCU->initEstData( uiDepth, iQP );
     829    const Bool bIsLosslessMode = false; // False at this level. Next level down may set it to true.
     830    rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );
    819831
    820832    // further split
     
    837849#endif
    838850        {
    839           if( m_bUseSBACRD )
     851          if ( 0 == uiPartUnitIdx) //initialize RD with previous depth buffer
    840852          {
    841             if ( 0 == uiPartUnitIdx) //initialize RD with previous depth buffer
    842             {
    843               m_pppcRDSbacCoder[uhNextDepth][CI_CURR_BEST]->load(m_pppcRDSbacCoder[uiDepth][CI_CURR_BEST]);
    844             }
    845             else
    846             {
    847               m_pppcRDSbacCoder[uhNextDepth][CI_CURR_BEST]->load(m_pppcRDSbacCoder[uhNextDepth][CI_NEXT_BEST]);
    848             }
     853            m_pppcRDSbacCoder[uhNextDepth][CI_CURR_BEST]->load(m_pppcRDSbacCoder[uiDepth][CI_CURR_BEST]);
     854          }
     855          else
     856          {
     857            m_pppcRDSbacCoder[uhNextDepth][CI_CURR_BEST]->load(m_pppcRDSbacCoder[uhNextDepth][CI_NEXT_BEST]);
    849858          }
    850859
     
    878887
    879888        rpcTempCU->getTotalBits() += m_pcEntropyCoder->getNumberOfWrittenBits(); // split bits
    880         if(m_pcEncCfg->getUseSBACRD())
    881         {
    882           rpcTempCU->getTotalBins() += ((TEncBinCABAC *)((TEncSbac*)m_pcEntropyCoder->m_pcEntropyCoderIf)->getEncBinIf())->getBinsCoded();
    883         }
     889        rpcTempCU->getTotalBins() += ((TEncBinCABAC *)((TEncSbac*)m_pcEntropyCoder->m_pcEntropyCoderIf)->getEncBinIf())->getBinsCoded();
    884890      }
    885891      rpcTempCU->getTotalCost()  = m_pcRdCost->calcRdCost( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() );
     
    913919          m_pcEntropyCoder->encodeQP( rpcTempCU, uiTargetPartIdx, false );
    914920          rpcTempCU->getTotalBits() += m_pcEntropyCoder->getNumberOfWrittenBits(); // dQP bits
    915           if(m_pcEncCfg->getUseSBACRD())
    916           {
    917             rpcTempCU->getTotalBins() += ((TEncBinCABAC *)((TEncSbac*)m_pcEntropyCoder->m_pcEntropyCoderIf)->getEncBinIf())->getBinsCoded();
    918           }
     921          rpcTempCU->getTotalBins() += ((TEncBinCABAC *)((TEncSbac*)m_pcEntropyCoder->m_pcEntropyCoderIf)->getEncBinIf())->getBinsCoded();
    919922          rpcTempCU->getTotalCost()  = m_pcRdCost->calcRdCost( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() );
    920923#endif
     
    930933      }
    931934
    932       if( m_bUseSBACRD )
    933       {
    934         m_pppcRDSbacCoder[uhNextDepth][CI_NEXT_BEST]->store(m_pppcRDSbacCoder[uiDepth][CI_TEMP_BEST]);
    935       }
     935      m_pppcRDSbacCoder[uhNextDepth][CI_NEXT_BEST]->store(m_pppcRDSbacCoder[uiDepth][CI_TEMP_BEST]);
     936
    936937      Bool isEndOfSlice        = rpcBestCU->getSlice()->getSliceMode()==FIXED_NUMBER_OF_BYTES
    937938                                 && (rpcBestCU->getTotalBits()>rpcBestCU->getSlice()->getSliceArgument()<<3);
     
    944945      xCheckBestMode( rpcBestCU, rpcTempCU, uiDepth);                                  // RD compare current larger prediction
    945946    }                                                                                  // with sub partitioned prediction.
    946     if (isAddLowestQP && (iQP == lowestQP))
    947     {
    948       iQP = iMinQP;
    949     }
    950947  }
    951948
     
    13341331  UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS];
    13351332  Int numValidMergeCand = 0;
     1333  const Bool bTransquantBypassFlag = rpcTempCU->getCUTransquantBypass(0);
    13361334
    13371335  for( UInt ui = 0; ui < rpcTempCU->getSlice()->getMaxNumMergeCand(); ++ui )
     
    13411339  UChar uhDepth = rpcTempCU->getDepth( 0 );
    13421340  rpcTempCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uhDepth ); // interprets depth relative to LCU level
    1343   rpcTempCU->setCUTransquantBypassSubParts( m_pcEncCfg->getCUTransquantBypassFlagValue(), 0, uhDepth );
    13441341  rpcTempCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours,uhInterDirNeighbours, numValidMergeCand );
    13451342
     
    13851382          // set MC parameters
    13861383          rpcTempCU->setPredModeSubParts( MODE_INTER, 0, uhDepth ); // interprets depth relative to LCU level
    1387           rpcTempCU->setCUTransquantBypassSubParts( m_pcEncCfg->getCUTransquantBypassFlagValue(),     0, uhDepth );
     1384          rpcTempCU->setCUTransquantBypassSubParts( bTransquantBypassFlag,     0, uhDepth );
    13881385          rpcTempCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uhDepth ); // interprets depth relative to LCU level
    13891386          rpcTempCU->setMergeFlagSubParts( true, 0, 0, uhDepth ); // interprets depth relative to LCU level
     
    14151412          xCheckDQP( rpcTempCU );
    14161413          xCheckBestMode(rpcBestCU, rpcTempCU, uhDepth);
    1417           rpcTempCU->initEstData( uhDepth, orgQP );
     1414          rpcTempCU->initEstData( uhDepth, orgQP, bTransquantBypassFlag );
    14181415         
    14191416          if( m_pcEncCfg->getUseFastDecisionForMerge() && !bestIsSkip )
     
    14781475  rpcTempCU->setPartSizeSubParts  ( ePartSize,  0, uhDepth );
    14791476  rpcTempCU->setPredModeSubParts  ( MODE_INTER, 0, uhDepth );
    1480   rpcTempCU->setCUTransquantBypassSubParts  ( m_pcEncCfg->getCUTransquantBypassFlagValue(),      0, uhDepth );
    14811477 
    14821478#if AMP_MRG
     
    15091505  rpcTempCU->setPartSizeSubParts( eSize, 0, uiDepth );
    15101506  rpcTempCU->setPredModeSubParts( MODE_INTRA, 0, uiDepth );
    1511   rpcTempCU->setCUTransquantBypassSubParts( m_pcEncCfg->getCUTransquantBypassFlagValue(), 0, uiDepth );
    15121507 
    15131508  Bool bSeparateLumaChroma = true; // choose estimation mode
     
    15391534  setdQPFlag( bCodeDQP );
    15401535 
    1541   if( m_bUseSBACRD ) m_pcRDGoOnSbacCoder->store(m_pppcRDSbacCoder[uiDepth][CI_TEMP_BEST]);
     1536  m_pcRDGoOnSbacCoder->store(m_pppcRDSbacCoder[uiDepth][CI_TEMP_BEST]);
    15421537 
    15431538  rpcTempCU->getTotalBits() = m_pcEntropyCoder->getNumberOfWrittenBits();
    1544   if(m_pcEncCfg->getUseSBACRD())
    1545   {
    1546     rpcTempCU->getTotalBins() = ((TEncBinCABAC *)((TEncSbac*)m_pcEntropyCoder->m_pcEntropyCoderIf)->getEncBinIf())->getBinsCoded();
    1547   }
     1539  rpcTempCU->getTotalBins() = ((TEncBinCABAC *)((TEncSbac*)m_pcEntropyCoder->m_pcEntropyCoderIf)->getEncBinIf())->getBinsCoded();
    15481540  rpcTempCU->getTotalCost() = m_pcRdCost->calcRdCost( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() );
    15491541 
     
    15701562  rpcTempCU->setPredModeSubParts( MODE_INTRA, 0, uiDepth );
    15711563  rpcTempCU->setTrIdxSubParts ( 0, 0, uiDepth );
    1572   rpcTempCU->setCUTransquantBypassSubParts( m_pcEncCfg->getCUTransquantBypassFlagValue(), 0, uiDepth );
    15731564
    15741565  m_pcPredSearch->IPCMSearch( rpcTempCU, m_ppcOrigYuv[uiDepth], m_ppcPredYuvTemp[uiDepth], m_ppcResiYuvTemp[uiDepth], m_ppcRecoYuvTemp[uiDepth]);
    15751566
    1576   if( m_bUseSBACRD ) m_pcRDGoOnSbacCoder->load(m_pppcRDSbacCoder[uiDepth][CI_CURR_BEST]);
     1567  m_pcRDGoOnSbacCoder->load(m_pppcRDSbacCoder[uiDepth][CI_CURR_BEST]);
    15771568
    15781569  m_pcEntropyCoder->resetBits();
     
    15861577  m_pcEntropyCoder->encodeIPCMInfo ( rpcTempCU, 0, true );
    15871578
    1588   if( m_bUseSBACRD ) m_pcRDGoOnSbacCoder->store(m_pppcRDSbacCoder[uiDepth][CI_TEMP_BEST]);
     1579  m_pcRDGoOnSbacCoder->store(m_pppcRDSbacCoder[uiDepth][CI_TEMP_BEST]);
    15891580
    15901581  rpcTempCU->getTotalBits() = m_pcEntropyCoder->getNumberOfWrittenBits();
    1591   if(m_pcEncCfg->getUseSBACRD())
    1592   {
    1593     rpcTempCU->getTotalBins() = ((TEncBinCABAC *)((TEncSbac*)m_pcEntropyCoder->m_pcEntropyCoderIf)->getEncBinIf())->getBinsCoded();
    1594   }
     1582  rpcTempCU->getTotalBins() = ((TEncBinCABAC *)((TEncSbac*)m_pcEntropyCoder->m_pcEntropyCoderIf)->getEncBinIf())->getBinsCoded();
    15951583  rpcTempCU->getTotalCost() = m_pcRdCost->calcRdCost( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() );
    15961584
     
    16271615    pcCU  = NULL;
    16281616
    1629     if( m_bUseSBACRD )  // store temp best CI for next CU coding
    1630       m_pppcRDSbacCoder[uiDepth][CI_TEMP_BEST]->store(m_pppcRDSbacCoder[uiDepth][CI_NEXT_BEST]);
     1617    // store temp best CI for next CU coding
     1618    m_pppcRDSbacCoder[uiDepth][CI_TEMP_BEST]->store(m_pppcRDSbacCoder[uiDepth][CI_NEXT_BEST]);
    16311619  }
    16321620}
     
    16441632      m_pcEntropyCoder->encodeQP( pcCU, 0, false );
    16451633      pcCU->getTotalBits() += m_pcEntropyCoder->getNumberOfWrittenBits(); // dQP bits
    1646       if(m_pcEncCfg->getUseSBACRD())
    1647       {
    1648         pcCU->getTotalBins() += ((TEncBinCABAC *)((TEncSbac*)m_pcEntropyCoder->m_pcEntropyCoderIf)->getEncBinIf())->getBinsCoded();
    1649       }
     1634      pcCU->getTotalBins() += ((TEncBinCABAC *)((TEncSbac*)m_pcEntropyCoder->m_pcEntropyCoderIf)->getEncBinIf())->getBinsCoded();
    16501635      pcCU->getTotalCost() = m_pcRdCost->calcRdCost( pcCU->getTotalBits(), pcCU->getTotalDistortion() );
    16511636#endif
     
    17951780}
    17961781
     1782/** Collect ARL statistics from one LCU
     1783 * \param pcCU
     1784 */
     1785Void TEncCu::xLcuCollectARLStats(TComDataCU* rpcCU )
     1786{
     1787  Double cSum[ LEVEL_RANGE + 1 ];     //: the sum of DCT coefficients corresponding to datatype and quantization output
     1788  UInt numSamples[ LEVEL_RANGE + 1 ]; //: the number of coefficients corresponding to datatype and quantization output
     1789
     1790  TCoeff* pCoeffY = rpcCU->getCoeffY();
     1791  Int* pArlCoeffY = rpcCU->getArlCoeffY();
     1792
     1793  UInt uiMinCUWidth = g_uiMaxCUWidth >> g_uiMaxCUDepth;
     1794  UInt uiMinNumCoeffInCU = 1 << uiMinCUWidth;
     1795
     1796  memset( cSum, 0, sizeof( Double )*(LEVEL_RANGE+1) );
     1797  memset( numSamples, 0, sizeof( UInt )*(LEVEL_RANGE+1) );
     1798
     1799  // Collect stats to cSum[][] and numSamples[][]
     1800  for(Int i = 0; i < rpcCU->getTotalNumPart(); i ++ )
     1801  {
     1802    UInt uiTrIdx = rpcCU->getTransformIdx(i);
     1803
     1804    if(rpcCU->getPredictionMode(i) == MODE_INTER)
     1805    if( rpcCU->getCbf( i, TEXT_LUMA, uiTrIdx ) )
     1806    {
     1807      xTuCollectARLStats(pCoeffY, pArlCoeffY, uiMinNumCoeffInCU, cSum, numSamples);
     1808    }//Note that only InterY is processed. QP rounding is based on InterY data only.
     1809   
     1810    pCoeffY  += uiMinNumCoeffInCU;
     1811    pArlCoeffY  += uiMinNumCoeffInCU;
     1812  }
     1813
     1814  for(Int u=1; u<LEVEL_RANGE;u++)
     1815  {
     1816    m_pcTrQuant->getSliceSumC()[u] += cSum[ u ] ;
     1817    m_pcTrQuant->getSliceNSamples()[u] += numSamples[ u ] ;
     1818  }
     1819  m_pcTrQuant->getSliceSumC()[LEVEL_RANGE] += cSum[ LEVEL_RANGE ] ;
     1820  m_pcTrQuant->getSliceNSamples()[LEVEL_RANGE] += numSamples[ LEVEL_RANGE ] ;
     1821}
     1822#endif
     1823
     1824#if SVC_EXTENSION
    17971825#if N0383_IL_CONSTRAINED_TILE_SETS_SEI
    17981826Bool TEncCu::xCheckTileSetConstraint( TComDataCU*& rpcCU )
     
    18611889#endif
    18621890
    1863 /** Collect ARL statistics from one LCU
    1864  * \param pcCU
    1865  */
    1866 Void TEncCu::xLcuCollectARLStats(TComDataCU* rpcCU )
    1867 {
    1868   Double cSum[ LEVEL_RANGE + 1 ];     //: the sum of DCT coefficients corresponding to datatype and quantization output
    1869   UInt numSamples[ LEVEL_RANGE + 1 ]; //: the number of coefficients corresponding to datatype and quantization output
    1870 
    1871   TCoeff* pCoeffY = rpcCU->getCoeffY();
    1872   Int* pArlCoeffY = rpcCU->getArlCoeffY();
    1873 
    1874   UInt uiMinCUWidth = g_uiMaxCUWidth >> g_uiMaxCUDepth;
    1875   UInt uiMinNumCoeffInCU = 1 << uiMinCUWidth;
    1876 
    1877   memset( cSum, 0, sizeof( Double )*(LEVEL_RANGE+1) );
    1878   memset( numSamples, 0, sizeof( UInt )*(LEVEL_RANGE+1) );
    1879 
    1880   // Collect stats to cSum[][] and numSamples[][]
    1881   for(Int i = 0; i < rpcCU->getTotalNumPart(); i ++ )
    1882   {
    1883     UInt uiTrIdx = rpcCU->getTransformIdx(i);
    1884 
    1885     if(rpcCU->getPredictionMode(i) == MODE_INTER)
    1886     if( rpcCU->getCbf( i, TEXT_LUMA, uiTrIdx ) )
    1887     {
    1888       xTuCollectARLStats(pCoeffY, pArlCoeffY, uiMinNumCoeffInCU, cSum, numSamples);
    1889     }//Note that only InterY is processed. QP rounding is based on InterY data only.
    1890    
    1891     pCoeffY  += uiMinNumCoeffInCU;
    1892     pArlCoeffY  += uiMinNumCoeffInCU;
    1893   }
    1894 
    1895   for(Int u=1; u<LEVEL_RANGE;u++)
    1896   {
    1897     m_pcTrQuant->getSliceSumC()[u] += cSum[ u ] ;
    1898     m_pcTrQuant->getSliceNSamples()[u] += numSamples[ u ] ;
    1899   }
    1900   m_pcTrQuant->getSliceSumC()[LEVEL_RANGE] += cSum[ LEVEL_RANGE ] ;
    1901   m_pcTrQuant->getSliceNSamples()[LEVEL_RANGE] += numSamples[ LEVEL_RANGE ] ;
    1902 }
    1903 #endif
    1904 
    19051891#if (ENCODER_FAST_MODE)
    19061892Void TEncCu::xCheckRDCostILRUni(TComDataCU *&rpcBestCU, TComDataCU *&rpcTempCU, UInt refLayerId)
     
    19131899  rpcTempCU->setPartSizeSubParts  ( SIZE_2Nx2N,  0, uhDepth );  //2Nx2N
    19141900  rpcTempCU->setPredModeSubParts  ( MODE_INTER, 0, uhDepth );
    1915   rpcTempCU->setCUTransquantBypassSubParts  ( m_pcEncCfg->getCUTransquantBypassFlagValue(), 0, uhDepth );
     1901  rpcTempCU->setCUTransquantBypassSubParts  ( m_pcEncCfg->getCUTransquantBypassFlagForceValue(), 0, uhDepth );
    19161902  Bool exitILR = m_pcPredSearch->predInterSearchILRUni( rpcTempCU, m_ppcOrigYuv[uhDepth], m_ppcPredYuvTemp[uhDepth], m_ppcResiYuvTemp[uhDepth], m_ppcRecoYuvTemp[uhDepth], refLayerId );
    19171903  if(!exitILR)
     
    19261912}
    19271913#endif
     1914#endif //SVC_EXTENSION
    19281915//! \}
  • trunk/source/Lib/TLibEncoder/TEncCu.h

    r540 r595  
    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 *
     
    8989  TComRdCost*             m_pcRdCost;
    9090 
    91 #if SVC_EXTENSION
    92   TEncTop**               m_ppcTEncTop;
    93 #endif
    94  
    9591  TEncEntropy*            m_pcEntropyCoder;
    9692  TEncCavlc*              m_pcCavlcCoder;
     
    10197  TEncSbac***             m_pppcRDSbacCoder;
    10298  TEncSbac*               m_pcRDGoOnSbacCoder;
    103   Bool                    m_bUseSBACRD;
    10499  TEncRateCtrl*           m_pcRateCtrl;
    105100
     101#if SVC_EXTENSION
     102  TEncTop**               m_ppcTEncTop;
    106103#if N0383_IL_CONSTRAINED_TILE_SETS_SEI
    107104  Bool                    m_disableILP;
    108105#endif
     106#endif //SVC_EXTENSION
    109107public:
    110108  /// copy parameters from encoder class
     
    148146#endif
    149147  Void  xCheckRDCostIntra   ( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, PartSize ePartSize  );
    150 #if ENCODER_FAST_MODE
    151   Void  xCheckRDCostILRUni  ( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, UInt refLayerId);
    152 #endif
    153148  Void  xCheckDQP           ( TComDataCU*  pcCU );
    154149 
     
    167162#endif
    168163
    169 #if N0383_IL_CONSTRAINED_TILE_SETS_SEI
    170   Bool xCheckTileSetConstraint( TComDataCU*& rpcCU );
    171   Void xVerifyTileSetConstraint( TComDataCU*& rpcCU );
    172 #endif
    173 
    174164#if AMP_ENC_SPEEDUP
    175165#if AMP_MRG
     
    180170#endif
    181171
     172  Void  xFillPCMBuffer     ( TComDataCU*& pCU, TComYuv* pOrgYuv );
     173
    182174#if SVC_EXTENSION
    183175  TEncTop*   getLayerEnc(UInt LayerId)  {return m_ppcTEncTop[LayerId]; }
    184 #endif
    185 
    186   Void  xFillPCMBuffer     ( TComDataCU*& pCU, TComYuv* pOrgYuv );
     176#if ENCODER_FAST_MODE
     177  Void  xCheckRDCostILRUni  ( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, UInt refLayerId);
     178#endif
     179#if N0383_IL_CONSTRAINED_TILE_SETS_SEI
     180  Bool xCheckTileSetConstraint( TComDataCU*& rpcCU );
     181  Void xVerifyTileSetConstraint( TComDataCU*& rpcCU );
     182#endif
     183#endif //SVC_EXTENSION
    187184};
    188185
  • trunk/source/Lib/TLibEncoder/TEncEntropy.cpp

    r540 r595  
    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 *
     
    5151Void TEncEntropy::encodeSliceHeader ( TComSlice* pcSlice )
    5252{
    53 #if !HM_CLEANUP_SAO
    54   if (pcSlice->getSPS()->getUseSAO())
    55   {
    56     SAOParam *saoParam = pcSlice->getPic()->getPicSym()->getSaoParam();
    57     pcSlice->setSaoEnabledFlag     (saoParam->bSaoFlag[0]);
    58     {
    59       pcSlice->setSaoEnabledFlagChroma   (saoParam->bSaoFlag[1]);
    60     }
    61   }
    62 #endif
    6353  m_pcEntropyCoderIf->codeSliceHeader( pcSlice );
    6454  return;
     
    639629}
    640630
    641 #if !HM_CLEANUP_SAO
    642 /** Encode SAO Offset
    643  * \param  saoLcuParam SAO LCU paramters
    644  */
    645 Void TEncEntropy::encodeSaoOffset(SaoLcuParam* saoLcuParam, UInt compIdx)
    646 {
    647   UInt uiSymbol;
    648   Int i;
    649 
    650   uiSymbol = saoLcuParam->typeIdx + 1;
    651   if (compIdx!=2)
    652   {
    653     m_pcEntropyCoderIf->codeSaoTypeIdx(uiSymbol);
    654   }
    655   if (uiSymbol)
    656   {
    657     if (saoLcuParam->typeIdx < 4 && compIdx != 2)
    658     {
    659       saoLcuParam->subTypeIdx = saoLcuParam->typeIdx;
    660     }
    661     Int bitDepth = compIdx ? g_bitDepthC : g_bitDepthY;
    662     Int offsetTh = 1 << min(bitDepth - 5,5);
    663     if( saoLcuParam->typeIdx == SAO_BO )
    664     {
    665       for( i=0; i< saoLcuParam->length; i++)
    666       {
    667         UInt absOffset = ( (saoLcuParam->offset[i] < 0) ? -saoLcuParam->offset[i] : saoLcuParam->offset[i]);
    668         m_pcEntropyCoderIf->codeSaoMaxUvlc(absOffset, offsetTh-1);
    669       } 
    670       for( i=0; i< saoLcuParam->length; i++)
    671       {
    672         if (saoLcuParam->offset[i] != 0)
    673         {
    674           UInt sign = (saoLcuParam->offset[i] < 0) ? 1 : 0 ;
    675           m_pcEntropyCoderIf->codeSAOSign(sign);
    676         }
    677       }
    678       uiSymbol = (UInt) (saoLcuParam->subTypeIdx);
    679       m_pcEntropyCoderIf->codeSaoUflc(5, uiSymbol);
    680     }
    681     else if( saoLcuParam->typeIdx < 4 )
    682     {
    683       m_pcEntropyCoderIf->codeSaoMaxUvlc( saoLcuParam->offset[0], offsetTh-1);
    684       m_pcEntropyCoderIf->codeSaoMaxUvlc( saoLcuParam->offset[1], offsetTh-1);
    685       m_pcEntropyCoderIf->codeSaoMaxUvlc(-saoLcuParam->offset[2], offsetTh-1);
    686       m_pcEntropyCoderIf->codeSaoMaxUvlc(-saoLcuParam->offset[3], offsetTh-1);
    687       if (compIdx!=2)
    688       {
    689         uiSymbol = (UInt) (saoLcuParam->subTypeIdx);
    690         m_pcEntropyCoderIf->codeSaoUflc(2, uiSymbol);
    691       }
    692     }
    693   }
    694 }
    695 
    696 /** Encode SAO unit interleaving
    697 * \param  rx
    698 * \param  ry
    699 * \param  pSaoParam
    700 * \param  pcCU
    701 * \param  iCUAddrInSlice
    702 * \param  iCUAddrUpInSlice
    703 * \param  bLFCrossSliceBoundaryFlag
    704  */
    705 Void TEncEntropy::encodeSaoUnitInterleaving(Int compIdx, Bool saoFlag, Int rx, Int ry, SaoLcuParam* saoLcuParam, Int cuAddrInSlice, Int cuAddrUpInSlice, Int allowMergeLeft, Int allowMergeUp)
    706 {
    707   if (saoFlag)
    708   {
    709     if (rx>0 && cuAddrInSlice!=0 && allowMergeLeft)
    710     {
    711       m_pcEntropyCoderIf->codeSaoMerge(saoLcuParam->mergeLeftFlag);
    712     }
    713     else
    714     {
    715       saoLcuParam->mergeLeftFlag = 0;
    716     }
    717     if (saoLcuParam->mergeLeftFlag == 0)
    718     {
    719       if ( (ry > 0) && (cuAddrUpInSlice>=0) && allowMergeUp )
    720       {
    721         m_pcEntropyCoderIf->codeSaoMerge(saoLcuParam->mergeUpFlag);
    722       }
    723       else
    724       {
    725         saoLcuParam->mergeUpFlag = 0;
    726       }
    727       if (!saoLcuParam->mergeUpFlag)
    728       {
    729         encodeSaoOffset(saoLcuParam, compIdx);
    730       }
    731     }
    732   }
    733 }
    734 
    735 #endif
    736 
    737631Int TEncEntropy::countNonZeroCoeffs( TCoeff* pcCoef, UInt uiSize )
    738632{
  • trunk/source/Lib/TLibEncoder/TEncEntropy.h

    r540 r595  
    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  virtual Void codeCoeffNxN      ( TComDataCU* pcCU, TCoeff* pcCoef, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, UInt uiDepth, TextType eTType ) = 0;
    106106  virtual Void codeTransformSkipFlags ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt width, UInt height, TextType eTType ) = 0;
    107 #if HM_CLEANUP_SAO
    108107  virtual Void codeSAOBlkParam(SAOBlkParam& saoBlkParam, Bool* sliceEnabled, Bool leftMergeAvail, Bool aboveMergeAvail, Bool onlyEstMergeInfo = false)    =0;
    109 #else
    110   virtual Void codeSAOSign          ( UInt code   ) = 0;
    111   virtual Void codeSaoMaxUvlc       ( UInt code, UInt maxSymbol ) = 0;
    112   virtual Void codeSaoMerge    ( UInt   uiCode  ) = 0;
    113   virtual Void codeSaoTypeIdx      ( UInt   uiCode) = 0;
    114   virtual Void codeSaoUflc         ( UInt uiLength, UInt   uiCode ) = 0;
    115 #endif
    116108  virtual Void estBit               (estBitsSbacStruct* pcEstBitsSbac, Int width, Int height, TextType eTType) = 0;
    117109 
     
    192184 
    193185  Void estimateBit             ( estBitsSbacStruct* pcEstBitsSbac, Int width, Int height, TextType eTType);
    194 #if HM_CLEANUP_SAO
    195186  Void encodeSAOBlkParam(SAOBlkParam& saoBlkParam, Bool* sliceEnabled, Bool leftMergeAvail, Bool aboveMergeAvail){m_pcEntropyCoderIf->codeSAOBlkParam(saoBlkParam, sliceEnabled, leftMergeAvail, aboveMergeAvail, false);}
    196 #else
    197   Void    encodeSaoOffset(SaoLcuParam* saoLcuParam, UInt compIdx);
    198   Void    encodeSaoUnitInterleaving(Int compIdx, Bool saoFlag, Int rx, Int ry, SaoLcuParam* saoLcuParam, Int cuAddrInSlice, Int cuAddrUpInSlice, Int allowMergeLeft, Int allowMergeUp);
    199 #endif
    200187  static Int countNonZeroCoeffs( TCoeff* pcCoef, UInt uiSize );
    201188
  • trunk/source/Lib/TLibEncoder/TEncGOP.cpp

    r588 r595  
    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 *
     
    9696  xResetNonNestedSEIPresentFlags();
    9797  xResetNestedSEIPresentFlags();
     98#if FIX1172
     99  m_associatedIRAPType = NAL_UNIT_CODED_SLICE_IDR_N_LP;
     100  m_associatedIRAPPOC  = 0;
     101#endif
    98102#if SVC_UPSAMPLING
    99103  m_pcPredSearch        = NULL;
     
    167171}
    168172
    169 #if LAYERS_NOT_PRESENT_SEI
    170 SEILayersNotPresent* TEncGOP::xCreateSEILayersNotPresent ()
    171 {
    172   UInt i = 0;
    173   SEILayersNotPresent *seiLayersNotPresent = new SEILayersNotPresent();
    174   seiLayersNotPresent->m_activeVpsId = m_pcCfg->getVPS()->getVPSId();
    175   seiLayersNotPresent->m_vpsMaxLayers = m_pcCfg->getVPS()->getMaxLayers();
    176   for ( ; i < seiLayersNotPresent->m_vpsMaxLayers; i++)
    177   {
    178     seiLayersNotPresent->m_layerNotPresentFlag[i] = true;
    179   }
    180   for ( ; i < MAX_LAYERS; i++)
    181   {
    182     seiLayersNotPresent->m_layerNotPresentFlag[i] = false;
    183   }
    184   return seiLayersNotPresent;
    185 }
    186 #endif
    187173
    188174SEIFramePacking* TEncGOP::xCreateSEIFramePacking()
     
    307293}
    308294
    309 #if N0383_IL_CONSTRAINED_TILE_SETS_SEI
    310 SEIInterLayerConstrainedTileSets* TEncGOP::xCreateSEIInterLayerConstrainedTileSets()
    311 {
    312   SEIInterLayerConstrainedTileSets *seiInterLayerConstrainedTileSets = new SEIInterLayerConstrainedTileSets();
    313   seiInterLayerConstrainedTileSets->m_ilAllTilesExactSampleValueMatchFlag = false;
    314   seiInterLayerConstrainedTileSets->m_ilOneTilePerTileSetFlag = false;
    315   if (!seiInterLayerConstrainedTileSets->m_ilOneTilePerTileSetFlag)
    316   {
    317     seiInterLayerConstrainedTileSets->m_ilNumSetsInMessageMinus1 = m_pcCfg->getIlNumSetsInMessage() - 1;
    318     if (seiInterLayerConstrainedTileSets->m_ilNumSetsInMessageMinus1)
    319     {
    320       seiInterLayerConstrainedTileSets->m_skippedTileSetPresentFlag = m_pcCfg->getSkippedTileSetPresentFlag();
    321     }
    322     else
    323     {
    324       seiInterLayerConstrainedTileSets->m_skippedTileSetPresentFlag = false;
    325     }
    326     seiInterLayerConstrainedTileSets->m_ilNumSetsInMessageMinus1 += seiInterLayerConstrainedTileSets->m_skippedTileSetPresentFlag ? 1 : 0;
    327     for (UInt i = 0; i < m_pcCfg->getIlNumSetsInMessage(); i++)
    328     {
    329       seiInterLayerConstrainedTileSets->m_ilctsId[i] = i;
    330       seiInterLayerConstrainedTileSets->m_ilNumTileRectsInSetMinus1[i] = 0;
    331       for( UInt j = 0; j <= seiInterLayerConstrainedTileSets->m_ilNumTileRectsInSetMinus1[i]; j++)
    332       {
    333         seiInterLayerConstrainedTileSets->m_ilTopLeftTileIndex[i][j]     = m_pcCfg->getTopLeftTileIndex(i);
    334         seiInterLayerConstrainedTileSets->m_ilBottomRightTileIndex[i][j] = m_pcCfg->getBottomRightTileIndex(i);
    335       }
    336       seiInterLayerConstrainedTileSets->m_ilcIdc[i] = m_pcCfg->getIlcIdc(i);
    337       if (seiInterLayerConstrainedTileSets->m_ilAllTilesExactSampleValueMatchFlag)
    338       {
    339         seiInterLayerConstrainedTileSets->m_ilExactSampleValueMatchFlag[i] = false;
    340       }
    341     }
    342   }
    343 
    344   return seiInterLayerConstrainedTileSets;
    345 }
    346 #endif
    347 
    348295Void TEncGOP::xCreateLeadingSEIMessages (/*SEIMessages seiMessages,*/ AccessUnit &accessUnit, TComSPS *sps)
    349296{
     
    362309    m_activeParameterSetSEIPresentInAU = true;
    363310  }
    364 
    365 #if LAYERS_NOT_PRESENT_SEI
    366   if(m_pcCfg->getLayersNotPresentSEIEnabled())
    367   {
    368     SEILayersNotPresent *sei = xCreateSEILayersNotPresent ();
    369     m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream);
    370     m_seiWriter.writeSEImessage(nalu.m_Bitstream, *sei, sps);
    371     writeRBSPTrailingBits(nalu.m_Bitstream);
    372     accessUnit.push_back(new NALUnitEBSP(nalu));
    373     delete sei;
    374   }
    375 #endif
    376311
    377312  if(m_pcCfg->getFramePackingArrangementSEIEnabled())
     
    408343    delete sei;
    409344  }
     345
     346#if SVC_EXTENSION
     347#if LAYERS_NOT_PRESENT_SEI
     348  if(m_pcCfg->getLayersNotPresentSEIEnabled())
     349  {
     350    SEILayersNotPresent *sei = xCreateSEILayersNotPresent ();
     351    m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream);
     352    m_seiWriter.writeSEImessage(nalu.m_Bitstream, *sei, sps);
     353    writeRBSPTrailingBits(nalu.m_Bitstream);
     354    accessUnit.push_back(new NALUnitEBSP(nalu));
     355    delete sei;
     356  }
     357#endif
     358
    410359#if N0383_IL_CONSTRAINED_TILE_SETS_SEI
    411360  if(m_pcCfg->getInterLayerConstrainedTileSetsSEIEnabled())
     
    421370  }
    422371#endif
     372#endif //SVC_EXTENSION
    423373}
    424374
     
    547497#endif
    548498
    549     if( getNalUnitType(pocCurr, m_iLastIDR) == NAL_UNIT_CODED_SLICE_IDR_W_RADL || getNalUnitType(pocCurr, m_iLastIDR) == NAL_UNIT_CODED_SLICE_IDR_N_LP )
     499    if( getNalUnitType(pocCurr, m_iLastIDR, isField) == NAL_UNIT_CODED_SLICE_IDR_W_RADL || getNalUnitType(pocCurr, m_iLastIDR, isField) == NAL_UNIT_CODED_SLICE_IDR_N_LP )
    550500    {
    551501      m_iLastIDR = pocCurr;
     
    554504    accessUnitsInGOP.push_back(AccessUnit());
    555505    AccessUnit& accessUnit = accessUnitsInGOP.back();
    556     xGetBuffer( rcListPic, rcListPicYuvRecOut, iNumPicRcvd, iTimeOffset, pcPic, pcPicYuvRecOut, pocCurr, isField );
     506    xGetBuffer( rcListPic, rcListPicYuvRecOut, iNumPicRcvd, iTimeOffset, pcPic, pcPicYuvRecOut, pocCurr, isField);
    557507
    558508    //  Slice data initialization
     
    571521    pcSlice->getPic()->setField(isField);
    572522
     523#if SVC_EXTENSION
    573524#if POC_RESET_FLAG
    574525    if( !pcSlice->getPocResetFlag() ) // For picture that are not reset, we should adjust the value of POC calculated from the configuration files.
     
    636587#endif
    637588#if O0149_CROSS_LAYER_BLA_FLAG
    638     if( m_layerId == 0 && (getNalUnitType(pocCurr, m_iLastIDR) == NAL_UNIT_CODED_SLICE_IDR_W_RADL || getNalUnitType(pocCurr, m_iLastIDR) == NAL_UNIT_CODED_SLICE_IDR_N_LP) )
     589    if( m_layerId == 0 && (getNalUnitType(pocCurr, m_iLastIDR, isField) == NAL_UNIT_CODED_SLICE_IDR_W_RADL || getNalUnitType(pocCurr, m_iLastIDR, isField) == NAL_UNIT_CODED_SLICE_IDR_N_LP) )
    639590    {
    640591      pcSlice->setCrossLayerBLAFlag(m_pcEncTop->getCrossLayerBLAFlag());
     
    693644    }
    694645#endif
     646#endif //SVC_EXTENSION
    695647
    696648    pcSlice->setLastIDR(m_iLastIDR);
     
    760712        pcSlice->setDefaultScalingList ();
    761713      }
    762 
    763714      pcSlice->getScalingList()->checkDcOfMatrix();
    764715      m_pcEncTop->getSPS()->setScalingListPresentFlag(pcSlice->checkDefaultScalingList());
     
    782733      pcSlice->setSliceType(P_SLICE);
    783734    }
     735    if(pcSlice->getSliceType()==B_SLICE&&m_pcCfg->getGOPEntry(iGOPid).m_sliceType=='I')
     736    {
     737      pcSlice->setSliceType(I_SLICE);
     738    }
     739
    784740    // Set the nal unit type
    785     pcSlice->setNalUnitType(getNalUnitType(pocCurr, m_iLastIDR));
     741    pcSlice->setNalUnitType(getNalUnitType(pocCurr, m_iLastIDR, isField));
    786742#if SVC_EXTENSION
    787743    if (m_layerId > 0)
     
    953909    m_pcEncTop->selectReferencePictureSet(pcSlice, pocCurr, iGOPid);
    954910    pcSlice->getRPS()->setNumberOfLongtermPictures(0);
     911#if FIX1172
     912    if ( pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP
     913      || pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL
     914      || pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP
     915      || pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL
     916      || pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP
     917      || pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA )  // IRAP picture
     918    {
     919      m_associatedIRAPType = pcSlice->getNalUnitType();
     920      m_associatedIRAPPOC = pocCurr;
     921    }
     922    pcSlice->setAssociatedIRAPType(m_associatedIRAPType);
     923    pcSlice->setAssociatedIRAPPOC(m_associatedIRAPPOC);
     924#endif
    955925
    956926    if ((pcSlice->checkThatAllRefPicsAreAvailable(rcListPic, pcSlice->getRPS(), false) != 0) || (pcSlice->isIRAP()))
     
    960930    pcSlice->applyReferencePictureSet(rcListPic, pcSlice->getRPS());
    961931
    962     if(pcSlice->getTLayer() > 0)
     932    if(pcSlice->getTLayer() > 0
     933      &&  !( pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_RADL_N     // Check if not a leading picture
     934          || pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_RADL_R
     935          || pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N
     936          || pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_R )
     937        )
    963938    {
    964939      if(pcSlice->isTemporalLayerSwitchingPoint(rcListPic) || pcSlice->getSPS()->getTemporalIdNestingFlag())
     
    16331608
    16341609    // SAO parameter estimation using non-deblocked pixels for LCU bottom and right boundary areas
    1635 #if HM_CLEANUP_SAO
    16361610    if( pcSlice->getSPS()->getUseSAO() && m_pcCfg->getSaoLcuBoundary() )
    16371611    {
    16381612      m_pcSAO->getPreDBFStatistics(pcPic);
    16391613    }
    1640 #else
    1641     if( m_pcCfg->getSaoLcuBasedOptimization() && m_pcCfg->getSaoLcuBoundary() )
    1642     {
    1643       m_pcSAO->resetStats();
    1644       m_pcSAO->calcSaoStatsCu_BeforeDblk( pcPic );
    1645     }
    1646 #endif   
    16471614    //-- Loop filter
    16481615    Bool bLFCrossTileBoundary = pcSlice->getPPS()->getLoopFilterAcrossTilesEnabledFlag();
     
    16541621    m_pcLoopFilter->loopFilterPic( pcPic );
    16551622
    1656 #if !HM_CLEANUP_SAO   
    1657     pcSlice = pcPic->getSlice(0);
    1658     if(pcSlice->getSPS()->getUseSAO())
    1659     {
    1660       std::vector<Bool> LFCrossSliceBoundaryFlag;
    1661       for(Int s=0; s< uiNumSlices; s++)
    1662       {
    1663         LFCrossSliceBoundaryFlag.push_back(  ((uiNumSlices==1)?true:pcPic->getSlice(s)->getLFCrossSliceBoundaryFlag()) );
    1664       }
    1665       m_storedStartCUAddrForEncodingSlice.resize(uiNumSlices+1);
    1666       pcPic->createNonDBFilterInfo(m_storedStartCUAddrForEncodingSlice, 0, &LFCrossSliceBoundaryFlag ,pcPic->getPicSym()->getNumTiles() ,bLFCrossTileBoundary);
    1667     }
    1668 
    1669 
    1670     pcSlice = pcPic->getSlice(0);
    1671 
    1672     if(pcSlice->getSPS()->getUseSAO())
    1673     {
    1674       m_pcSAO->createPicSaoInfo(pcPic);
    1675     }
    1676 #endif
    16771623    /////////////////////////////////////////////////////////////////////////////////////////////////// File writing
    16781624    // Set entropy coder
     
    17921738        {
    17931739          SOPcurrPOC += deltaPOC;
    1794           SOPDescriptionSEI.m_sopDescVclNaluType[i] = getNalUnitType(SOPcurrPOC, m_iLastIDR);
     1740          SOPDescriptionSEI.m_sopDescVclNaluType[i] = getNalUnitType(SOPcurrPOC, m_iLastIDR, isField);
    17951741          SOPDescriptionSEI.m_sopDescTemporalId[i] = m_pcCfg->getGOPEntry(j).m_temporalId;
    17961742          SOPDescriptionSEI.m_sopDescStRpsIdx[i] = m_pcEncTop->getReferencePictureSetIdxForSOP(pcSlice, SOPcurrPOC, j);
     
    22572203              m_pcEntropyCoder->resetEntropy();
    22582204              m_pcEntropyCoder->setBitstream( m_pcBitCounter );
    2259 #if HM_CLEANUP_SAO
    22602205              Bool sliceEnabled[NUM_SAO_COMPONENTS];
    22612206              m_pcSAO->initRDOCabacCoder(m_pcEncTop->getRDGoOnSbacCoder(), pcSlice);
     
    22762221                pcPic->getSlice(s)->setSaoEnabledFlagChroma(sliceEnabled[SAO_Cb]);
    22772222              }
    2278 #else
    2279               m_pcSAO->startSaoEnc(pcPic, m_pcEntropyCoder, m_pcEncTop->getRDSbacCoder(), m_pcEncTop->getRDGoOnSbacCoder());
    2280               SAOParam& cSaoParam = *pcSlice->getPic()->getPicSym()->getSaoParam();
    2281 
    2282 #if SAO_ENCODING_CHOICE
    2283               m_pcSAO->SAOProcess(&cSaoParam, pcPic->getSlice(0)->getLambdas()[TEXT_LUMA], pcPic->getSlice(0)->getLambdas()[TEXT_CHROMA], pcPic->getSlice(0)->getDepth());
    2284 #else
    2285               m_pcSAO->SAOProcess(&cSaoParam, pcPic->getSlice(0)->getLambdaLuma(), pcPic->getSlice(0)->getLambdaChroma());
    2286 #endif
    2287               m_pcSAO->endSaoEnc();
    2288               m_pcSAO->PCMLFDisableProcess(pcPic);
    2289 #endif
    22902223            }
    2291 #if !HM_CLEANUP_SAO         
    2292 #if SAO_RDO
    2293             m_pcEntropyCoder->setEntropyCoder ( m_pcCavlcCoder, pcSlice );
    2294 #endif
    2295 #endif
    22962224            processingState = ENCODE_SLICE;
    2297 #if !HM_CLEANUP_SAO
    2298 #if HIGHER_LAYER_IRAP_SKIP_FLAG
    2299             if ( ( m_pcEncTop->getSkipPictureAtArcSwitch() && m_pcEncTop->getAdaptiveResolutionChange() > 0 && pcSlice->getLayerId() == 1 && pcSlice->getPOC() == m_pcEncTop->getAdaptiveResolutionChange()) )
    2300             {
    2301               pcSlice->getPic()->getPicSym()->getSaoParam()->bSaoFlag[0]=0;
    2302               pcSlice->getPic()->getPicSym()->getSaoParam()->bSaoFlag[1]=0;
    2303             }
    2304 #endif
    2305             for(Int s=0; s< uiNumSlices; s++)
    2306             {
    2307               if (pcSlice->getSPS()->getUseSAO())
    2308               {
    2309                 pcPic->getSlice(s)->setSaoEnabledFlag((pcSlice->getPic()->getPicSym()->getSaoParam()->bSaoFlag[0]==1)?true:false);
    2310               }
    2311             }
    2312 #endif
    23132225          }
    23142226          break;
     
    23212233        }
    23222234      } // end iteration over slices
    2323 #if !HM_CLEANUP_SAO   
    2324       if(pcSlice->getSPS()->getUseSAO())
    2325       {
    2326         if(pcSlice->getSPS()->getUseSAO())
    2327         {
    2328           m_pcSAO->destroyPicSaoInfo();
    2329         }
    2330         pcPic->destroyNonDBFilterInfo();
    2331       }
    2332 #endif
    23332235      pcPic->compressMotion();
    23342236     
     
    24022304
    24032305      //In case of field coding, compute the interlaced PSNR for both fields
    2404       if (isField && ((!pcPic->isTopField() && isTff) || (pcPic->isTopField() && !isTff)))
     2306    if (isField && ((!pcPic->isTopField() && isTff) || (pcPic->isTopField() && !isTff)) && (pcPic->getPOC()%m_iGopSize != 1))
    24052307      {
    24062308        //get complementary top field
     
    24142316        xCalculateInterlacedAddPSNR(pcPicTop, pcPic, pcPicTop->getPicYuvRec(), pcPic->getPicYuvRec(), accessUnit, dEncTime );
    24152317      }
     2318    else if (isField && pcPic->getPOC()!= 0 && (pcPic->getPOC()%m_iGopSize == 0))
     2319    {
     2320      //get complementary bottom field
     2321      TComPic* pcPicBottom;
     2322      TComList<TComPic*>::iterator   iterPic = rcListPic.begin();
     2323      while ((*iterPic)->getPOC() != pcPic->getPOC()+1)
     2324      {
     2325        iterPic ++;
     2326      }
     2327      pcPicBottom = *(iterPic);
     2328      xCalculateInterlacedAddPSNR(pcPic, pcPicBottom, pcPic->getPicYuvRec(), pcPicBottom->getPicYuvRec(), accessUnit, dEncTime );
     2329    }
    24162330
    24172331      if (digestStr)
     
    27172631  m_pcEntropyCoder->resetEntropy    ();
    27182632  m_pcEntropyCoder->setBitstream    ( m_pcBitCounter );
    2719 #if !HM_CLEANUP_SAO
    2720   pcSlice = pcPic->getSlice(0);
    2721   if(pcSlice->getSPS()->getUseSAO())
    2722   {
    2723     std::vector<Bool> LFCrossSliceBoundaryFlag(1, true);
    2724     std::vector<Int>  sliceStartAddress;
    2725     sliceStartAddress.push_back(0);
    2726     sliceStartAddress.push_back(pcPic->getNumCUsInFrame()* pcPic->getNumPartInCU());
    2727     pcPic->createNonDBFilterInfo(sliceStartAddress, 0, &LFCrossSliceBoundaryFlag);
    2728   }
    2729  
    2730   if( pcSlice->getSPS()->getUseSAO())
    2731   {
    2732     pcPic->destroyNonDBFilterInfo();
    2733   }
    2734 #endif
    27352633  m_pcEntropyCoder->resetEntropy    ();
    27362634  ruiBits += m_pcEntropyCoder->getNumberOfWrittenBits();
     
    33033201 * This function checks the configuration and returns the appropriate nal_unit_type for the picture.
    33043202 */
    3305 NalUnitType TEncGOP::getNalUnitType(Int pocCurr, Int lastIDR)
     3203NalUnitType TEncGOP::getNalUnitType(Int pocCurr, Int lastIDR, Bool isField)
    33063204{
    33073205  if (pocCurr == 0)
     
    33093207    return NAL_UNIT_CODED_SLICE_IDR_W_RADL;
    33103208  }
    3311   if (pocCurr % m_pcCfg->getIntraPeriod() == 0)
     3209  if ((pocCurr - isField) % m_pcCfg->getIntraPeriod() == 0)
    33123210  {
    33133211    if (m_pcCfg->getDecodingRefreshType() == 1)
     
    35323430  return seiStartPos;
    35333431}
    3534 
    3535 #if N0383_IL_CONSTRAINED_TILE_SETS_SEI
    3536 Void TEncGOP::xBuildTileSetsMap(TComPicSym* picSym)
    3537 {
    3538   Int numCUs = picSym->getFrameWidthInCU() * picSym->getFrameHeightInCU();
    3539 
    3540   for (Int i = 0; i < numCUs; i++)
    3541   {
    3542     picSym->setTileSetIdxMap(i, -1, 0, false);
    3543   }
    3544 
    3545   for (Int i = 0; i < m_pcCfg->getIlNumSetsInMessage(); i++)
    3546   {
    3547     TComTile* topLeftTile     = picSym->getTComTile(m_pcCfg->getTopLeftTileIndex(i));
    3548     TComTile* bottomRightTile = picSym->getTComTile(m_pcCfg->getBottomRightTileIndex(i));
    3549     Int tileSetLeftEdgePosInCU = topLeftTile->getRightEdgePosInCU() - topLeftTile->getTileWidth() + 1;
    3550     Int tileSetRightEdgePosInCU = bottomRightTile->getRightEdgePosInCU();
    3551     Int tileSetTopEdgePosInCU = topLeftTile->getBottomEdgePosInCU() - topLeftTile->getTileHeight() + 1;
    3552     Int tileSetBottomEdgePosInCU = bottomRightTile->getBottomEdgePosInCU();
    3553     assert(tileSetLeftEdgePosInCU < tileSetRightEdgePosInCU && tileSetTopEdgePosInCU < tileSetBottomEdgePosInCU);
    3554     for (Int j = tileSetTopEdgePosInCU; j <= tileSetBottomEdgePosInCU; j++)
    3555     {
    3556       for (Int k = tileSetLeftEdgePosInCU; k <= tileSetRightEdgePosInCU; k++)
    3557       {
    3558         picSym->setTileSetIdxMap(j * picSym->getFrameWidthInCU() + k, i, m_pcCfg->getIlcIdc(i), false);
    3559       }
    3560     }
    3561   }
    3562  
    3563   if (m_pcCfg->getSkippedTileSetPresentFlag())
    3564   {
    3565     Int skippedTileSetIdx = m_pcCfg->getIlNumSetsInMessage();
    3566     for (Int i = 0; i < numCUs; i++)
    3567     {
    3568       if (picSym->getTileSetIdxMap(i) < 0)
    3569       {
    3570         picSym->setTileSetIdxMap(i, skippedTileSetIdx, 0, true);
    3571       }
    3572     }
    3573   }
    3574 }
    3575 #endif
    35763432
    35773433Void TEncGOP::dblMetric( TComPic* pcPic, UInt uiNumSlices )
     
    36983554  free(rowSAD);
    36993555}
     3556#if SVC_EXTENSION
     3557#if LAYERS_NOT_PRESENT_SEI
     3558SEILayersNotPresent* TEncGOP::xCreateSEILayersNotPresent ()
     3559{
     3560  UInt i = 0;
     3561  SEILayersNotPresent *seiLayersNotPresent = new SEILayersNotPresent();
     3562  seiLayersNotPresent->m_activeVpsId = m_pcCfg->getVPS()->getVPSId();
     3563  seiLayersNotPresent->m_vpsMaxLayers = m_pcCfg->getVPS()->getMaxLayers();
     3564  for ( ; i < seiLayersNotPresent->m_vpsMaxLayers; i++)
     3565  {
     3566    seiLayersNotPresent->m_layerNotPresentFlag[i] = true;
     3567  }
     3568  for ( ; i < MAX_LAYERS; i++)
     3569  {
     3570    seiLayersNotPresent->m_layerNotPresentFlag[i] = false;
     3571  }
     3572  return seiLayersNotPresent;
     3573}
     3574#endif
     3575
     3576#if N0383_IL_CONSTRAINED_TILE_SETS_SEI
     3577SEIInterLayerConstrainedTileSets* TEncGOP::xCreateSEIInterLayerConstrainedTileSets()
     3578{
     3579  SEIInterLayerConstrainedTileSets *seiInterLayerConstrainedTileSets = new SEIInterLayerConstrainedTileSets();
     3580  seiInterLayerConstrainedTileSets->m_ilAllTilesExactSampleValueMatchFlag = false;
     3581  seiInterLayerConstrainedTileSets->m_ilOneTilePerTileSetFlag = false;
     3582  if (!seiInterLayerConstrainedTileSets->m_ilOneTilePerTileSetFlag)
     3583  {
     3584    seiInterLayerConstrainedTileSets->m_ilNumSetsInMessageMinus1 = m_pcCfg->getIlNumSetsInMessage() - 1;
     3585    if (seiInterLayerConstrainedTileSets->m_ilNumSetsInMessageMinus1)
     3586    {
     3587      seiInterLayerConstrainedTileSets->m_skippedTileSetPresentFlag = m_pcCfg->getSkippedTileSetPresentFlag();
     3588    }
     3589    else
     3590    {
     3591      seiInterLayerConstrainedTileSets->m_skippedTileSetPresentFlag = false;
     3592    }
     3593    seiInterLayerConstrainedTileSets->m_ilNumSetsInMessageMinus1 += seiInterLayerConstrainedTileSets->m_skippedTileSetPresentFlag ? 1 : 0;
     3594    for (UInt i = 0; i < m_pcCfg->getIlNumSetsInMessage(); i++)
     3595    {
     3596      seiInterLayerConstrainedTileSets->m_ilctsId[i] = i;
     3597      seiInterLayerConstrainedTileSets->m_ilNumTileRectsInSetMinus1[i] = 0;
     3598      for( UInt j = 0; j <= seiInterLayerConstrainedTileSets->m_ilNumTileRectsInSetMinus1[i]; j++)
     3599      {
     3600        seiInterLayerConstrainedTileSets->m_ilTopLeftTileIndex[i][j]     = m_pcCfg->getTopLeftTileIndex(i);
     3601        seiInterLayerConstrainedTileSets->m_ilBottomRightTileIndex[i][j] = m_pcCfg->getBottomRightTileIndex(i);
     3602      }
     3603      seiInterLayerConstrainedTileSets->m_ilcIdc[i] = m_pcCfg->getIlcIdc(i);
     3604      if (seiInterLayerConstrainedTileSets->m_ilAllTilesExactSampleValueMatchFlag)
     3605      {
     3606        seiInterLayerConstrainedTileSets->m_ilExactSampleValueMatchFlag[i] = false;
     3607      }
     3608    }
     3609  }
     3610
     3611  return seiInterLayerConstrainedTileSets;
     3612}
     3613
     3614Void TEncGOP::xBuildTileSetsMap(TComPicSym* picSym)
     3615{
     3616  Int numCUs = picSym->getFrameWidthInCU() * picSym->getFrameHeightInCU();
     3617
     3618  for (Int i = 0; i < numCUs; i++)
     3619  {
     3620    picSym->setTileSetIdxMap(i, -1, 0, false);
     3621  }
     3622
     3623  for (Int i = 0; i < m_pcCfg->getIlNumSetsInMessage(); i++)
     3624  {
     3625    TComTile* topLeftTile     = picSym->getTComTile(m_pcCfg->getTopLeftTileIndex(i));
     3626    TComTile* bottomRightTile = picSym->getTComTile(m_pcCfg->getBottomRightTileIndex(i));
     3627    Int tileSetLeftEdgePosInCU = topLeftTile->getRightEdgePosInCU() - topLeftTile->getTileWidth() + 1;
     3628    Int tileSetRightEdgePosInCU = bottomRightTile->getRightEdgePosInCU();
     3629    Int tileSetTopEdgePosInCU = topLeftTile->getBottomEdgePosInCU() - topLeftTile->getTileHeight() + 1;
     3630    Int tileSetBottomEdgePosInCU = bottomRightTile->getBottomEdgePosInCU();
     3631    assert(tileSetLeftEdgePosInCU < tileSetRightEdgePosInCU && tileSetTopEdgePosInCU < tileSetBottomEdgePosInCU);
     3632    for (Int j = tileSetTopEdgePosInCU; j <= tileSetBottomEdgePosInCU; j++)
     3633    {
     3634      for (Int k = tileSetLeftEdgePosInCU; k <= tileSetRightEdgePosInCU; k++)
     3635      {
     3636        picSym->setTileSetIdxMap(j * picSym->getFrameWidthInCU() + k, i, m_pcCfg->getIlcIdc(i), false);
     3637      }
     3638    }
     3639  }
     3640 
     3641  if (m_pcCfg->getSkippedTileSetPresentFlag())
     3642  {
     3643    Int skippedTileSetIdx = m_pcCfg->getIlNumSetsInMessage();
     3644    for (Int i = 0; i < numCUs; i++)
     3645    {
     3646      if (picSym->getTileSetIdxMap(i) < 0)
     3647      {
     3648        picSym->setTileSetIdxMap(i, skippedTileSetIdx, 0, true);
     3649      }
     3650    }
     3651  }
     3652}
     3653#endif
     3654#endif //SVC_EXTENSION
     3655
    37003656//! \}
  • trunk/source/Lib/TLibEncoder/TEncGOP.h

    r588 r595  
    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 *
     
    8383  Bool                    m_bFirst;
    8484 
    85 #if SVC_EXTENSION
    86   UInt                    m_layerId;     
    87 #endif
    88 
    8985  //  Access channel
    9086  TEncTop*                m_pcEncTop;
     
    9288  TEncSlice*              m_pcSliceEncoder;
    9389  TComList<TComPic*>*     m_pcListPic;
    94  
    95 #if SVC_EXTENSION
    96   TEncTop**               m_ppcTEncTop;
    97 #if SVC_UPSAMPLING
    98   TEncSearch*             m_pcPredSearch;                       ///< encoder search class
    99 #endif 
    100 #endif
    10190 
    10291  TEncEntropy*            m_pcEntropyCoder;
     
    120109  std::vector<Int>        m_storedStartCUAddrForEncodingSlice;
    121110  std::vector<Int>        m_storedStartCUAddrForEncodingSliceSegment;
     111#if FIX1172
     112  NalUnitType             m_associatedIRAPType;
     113  Int                     m_associatedIRAPPOC;
     114#endif
    122115
    123116  std::vector<Int> m_vRVM_RP;
     
    132125  Bool                    m_nestedBufferingPeriodSEIPresentInAU;
    133126  Bool                    m_nestedPictureTimingSEIPresentInAU;
     127
     128#if SVC_EXTENSION
     129  UInt                    m_layerId;     
     130  TEncTop**               m_ppcTEncTop;
     131#if SVC_UPSAMPLING
     132  TEncSearch*             m_pcPredSearch;                       ///< encoder search class
     133#endif 
     134#endif
     135 
    134136public:
    135137  TEncGOP();
     
    162164 
    163165  TEncSlice*  getSliceEncoder()   { return m_pcSliceEncoder; }
    164   NalUnitType getNalUnitType( Int pocCurr, Int lastIdr );
     166  NalUnitType getNalUnitType( Int pocCurr, Int lastIdr, Bool isField );
    165167  Void arrangeLongtermPicturesInRPS(TComSlice *, TComList<TComPic*>& );
    166168protected:
     
    181183
    182184  SEIActiveParameterSets* xCreateSEIActiveParameterSets (TComSPS *sps);
    183 #if LAYERS_NOT_PRESENT_SEI
    184   SEILayersNotPresent*    xCreateSEILayersNotPresent ();
    185 #endif
    186185  SEIFramePacking*        xCreateSEIFramePacking();
    187186  SEIDisplayOrientation*  xCreateSEIDisplayOrientation();
    188187
    189188  SEIToneMappingInfo*     xCreateSEIToneMappingInfo();
    190 
    191 #if N0383_IL_CONSTRAINED_TILE_SETS_SEI
    192   SEIInterLayerConstrainedTileSets* xCreateSEIInterLayerConstrainedTileSets();
    193 #endif
    194189
    195190  Void xCreateLeadingSEIMessages (/*SEIMessages seiMessages,*/ AccessUnit &accessUnit, TComSPS *sps);
     
    206201    m_nestedPictureTimingSEIPresentInAU      = false;
    207202  }
     203  Void dblMetric( TComPic* pcPic, UInt uiNumSlices );
     204
     205#if SVC_EXTENSION
     206#if LAYERS_NOT_PRESENT_SEI
     207  SEILayersNotPresent*    xCreateSEILayersNotPresent ();
     208#endif
    208209#if N0383_IL_CONSTRAINED_TILE_SETS_SEI
    209210  Void xBuildTileSetsMap(TComPicSym* picSym);
    210 #endif
    211   Void dblMetric( TComPic* pcPic, UInt uiNumSlices );
     211  SEIInterLayerConstrainedTileSets* xCreateSEIInterLayerConstrainedTileSets();
     212#endif
     213#endif //SVC_EXTENSION
    212214};// END CLASS DEFINITION TEncGOP
    213215
  • trunk/source/Lib/TLibEncoder/TEncPic.cpp

    r494 r595  
    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 *
  • trunk/source/Lib/TLibEncoder/TEncPic.h

    r494 r595  
    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 *
  • trunk/source/Lib/TLibEncoder/TEncPreanalyzer.cpp

    r313 r595  
    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 *
  • trunk/source/Lib/TLibEncoder/TEncPreanalyzer.h

    r313 r595  
    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 *
  • trunk/source/Lib/TLibEncoder/TEncRateCtrl.cpp

    r540 r595  
    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 *
  • trunk/source/Lib/TLibEncoder/TEncRateCtrl.h

    r540 r595  
    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 *
  • trunk/source/Lib/TLibEncoder/TEncSampleAdaptiveOffset.cpp

    r540 r595  
    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 *
     
    4646
    4747
    48 #if HM_CLEANUP_SAO
    49 
    5048/** rounding with IBDI
    5149 * \param  x
     
    259257  TComPicYuv* orgYuv= pPic->getPicYuvOrg();
    260258  TComPicYuv* resYuv= pPic->getPicYuvRec();
    261   m_labmda[SAO_Y]= lambdas[0]; m_labmda[SAO_Cb]= lambdas[1]; m_labmda[SAO_Cr]= lambdas[2];
     259  m_lambda[SAO_Y]= lambdas[0]; m_lambda[SAO_Cb]= lambdas[1]; m_lambda[SAO_Cr]= lambdas[2];
    262260  TComPicYuv* srcYuv = m_tempPicYuv;
    263261  resYuv->copyToPic(srcYuv);
     
    509507          if( quantOffsets[classIdx] != 0 ) //iterative adjustment only when derived offset is not zero
    510508          {
    511             quantOffsets[classIdx] = estIterOffset( typeIdc, classIdx, m_labmda[compIdx], quantOffsets[classIdx], statData.count[classIdx], statData.diff[classIdx], shift, m_offsetStepLog2[compIdx], classDist , classCost , offsetTh );
     509            quantOffsets[classIdx] = estIterOffset( typeIdc, classIdx, m_lambda[compIdx], quantOffsets[classIdx], statData.count[classIdx], statData.diff[classIdx], shift, m_offsetStepLog2[compIdx], classDist , classCost , offsetTh );
    512510          }
    513511        }
     
    523521        for(Int classIdx=0; classIdx< NUM_SAO_BO_CLASSES; classIdx++)
    524522        {         
    525           costBOClasses[classIdx]= m_labmda[compIdx];
     523          costBOClasses[classIdx]= m_lambda[compIdx];
    526524          if( quantOffsets[classIdx] != 0 ) //iterative adjustment only when derived offset is not zero
    527525          {
    528             quantOffsets[classIdx] = estIterOffset( typeIdc, classIdx, m_labmda[compIdx], quantOffsets[classIdx], statData.count[classIdx], statData.diff[classIdx], shift, m_offsetStepLog2[compIdx], distBOClasses[classIdx], costBOClasses[classIdx], offsetTh );
     526            quantOffsets[classIdx] = estIterOffset( typeIdc, classIdx, m_lambda[compIdx], quantOffsets[classIdx], statData.count[classIdx], statData.diff[classIdx], shift, m_offsetStepLog2[compIdx], distBOClasses[classIdx], costBOClasses[classIdx], offsetTh );
    529527          }
    530528        }
     
    572570{
    573571  Double minCost, cost;
    574   Int rate, minRate;
     572  Int rate;
     573  UInt previousWrittenBits;
    575574  Int64 dist[NUM_SAO_COMPONENTS], modeDist[NUM_SAO_COMPONENTS];
    576575  SAOOffset testOffset[NUM_SAO_COMPONENTS];
     
    592591  m_pcRDGoOnSbacCoder->resetBits();
    593592  m_pcRDGoOnSbacCoder->codeSAOOffsetParam(compIdx, modeParam[compIdx], sliceEnabled[compIdx]);
    594   minRate= m_pcRDGoOnSbacCoder->getNumberOfWrittenBits();
    595593  modeDist[compIdx] = 0;
    596   minCost= m_labmda[compIdx]*((Double)minRate);
     594  minCost= m_lambda[compIdx]*((Double)m_pcRDGoOnSbacCoder->getNumberOfWrittenBits());
    597595  m_pcRDGoOnSbacCoder->store(cabacCoderRDO[SAO_CABACSTATE_BLK_TEMP]);
    598596  if(sliceEnabled[compIdx])
     
    617615      m_pcRDGoOnSbacCoder->codeSAOOffsetParam(compIdx, testOffset[compIdx], sliceEnabled[compIdx]);
    618616      rate = m_pcRDGoOnSbacCoder->getNumberOfWrittenBits();
    619       cost = (Double)dist[compIdx] + m_labmda[compIdx]*((Double)rate);
     617      cost = (Double)dist[compIdx] + m_lambda[compIdx]*((Double)rate);
    620618      if(cost < minCost)
    621619      {
    622620        minCost = cost;
    623         minRate = rate;
    624621        modeDist[compIdx] = dist[compIdx];
    625622        modeParam[compIdx]= testOffset[compIdx];
     
    632629
    633630  //------ chroma --------//
    634   assert(m_labmda[SAO_Cb] == m_labmda[SAO_Cr]);
    635   Double chromaLambda = m_labmda[SAO_Cb];
    636631  //"off" case as initial cost
     632  cost = 0;
     633  previousWrittenBits = 0;
    637634  m_pcRDGoOnSbacCoder->resetBits();
    638   modeParam[SAO_Cb].modeIdc = SAO_MODE_OFF;
    639   m_pcRDGoOnSbacCoder->codeSAOOffsetParam(SAO_Cb, modeParam[SAO_Cb], sliceEnabled[SAO_Cb]);
    640   modeParam[SAO_Cr].modeIdc = SAO_MODE_OFF;
    641   m_pcRDGoOnSbacCoder->codeSAOOffsetParam(SAO_Cr, modeParam[SAO_Cr], sliceEnabled[SAO_Cr]);
    642   minRate= m_pcRDGoOnSbacCoder->getNumberOfWrittenBits();
    643   modeDist[SAO_Cb] = modeDist[SAO_Cr]= 0;
    644   minCost= chromaLambda*((Double)minRate);
     635  for (Int component = SAO_Cb; component < NUM_SAO_COMPONENTS; component++)
     636  {
     637    modeParam[component].modeIdc = SAO_MODE_OFF;
     638    modeDist [component] = 0;
     639
     640    m_pcRDGoOnSbacCoder->codeSAOOffsetParam(component, modeParam[component], sliceEnabled[component]);
     641
     642    const UInt currentWrittenBits = m_pcRDGoOnSbacCoder->getNumberOfWrittenBits();
     643    cost += m_lambda[component] * (currentWrittenBits - previousWrittenBits);
     644    previousWrittenBits = currentWrittenBits;
     645  }
     646
     647  minCost = cost;
    645648
    646649  //doesn't need to store cabac status here since the whole CTU parameters will be re-encoded at the end of this function
     
    648651  for(Int typeIdc=0; typeIdc< NUM_SAO_NEW_TYPES; typeIdc++)
    649652  {
     653    m_pcRDGoOnSbacCoder->load(cabacCoderRDO[SAO_CABACSTATE_BLK_MID]);
     654    m_pcRDGoOnSbacCoder->resetBits();
     655    previousWrittenBits = 0;
     656    cost = 0;
     657
    650658    for(compIdx= SAO_Cb; compIdx< NUM_SAO_COMPONENTS; compIdx++)
    651659    {
     
    663671      invertQuantOffsets(compIdx, typeIdc, testOffset[compIdx].typeAuxInfo, invQuantOffset, testOffset[compIdx].offset);
    664672      dist[compIdx]= getDistortion(ctu, compIdx, typeIdc, testOffset[compIdx].typeAuxInfo, invQuantOffset, blkStats[ctu][compIdx][typeIdc]);
    665     }
    666 
    667     //get rate
    668     m_pcRDGoOnSbacCoder->load(cabacCoderRDO[SAO_CABACSTATE_BLK_MID]);
    669     m_pcRDGoOnSbacCoder->resetBits();
    670     m_pcRDGoOnSbacCoder->codeSAOOffsetParam(SAO_Cb, testOffset[SAO_Cb], sliceEnabled[SAO_Cb]);
    671     m_pcRDGoOnSbacCoder->codeSAOOffsetParam(SAO_Cr, testOffset[SAO_Cr], sliceEnabled[SAO_Cr]);
    672     rate = m_pcRDGoOnSbacCoder->getNumberOfWrittenBits();
    673 
    674     cost = (Double)(dist[SAO_Cb]+ dist[SAO_Cr]) + chromaLambda*((Double)rate);
     673
     674      m_pcRDGoOnSbacCoder->codeSAOOffsetParam(compIdx, testOffset[compIdx], sliceEnabled[compIdx]);
     675
     676      const UInt currentWrittenBits = m_pcRDGoOnSbacCoder->getNumberOfWrittenBits();
     677      cost += dist[compIdx] + (m_lambda[compIdx] * (currentWrittenBits - previousWrittenBits));
     678      previousWrittenBits = currentWrittenBits;
     679    }
     680
    675681    if(cost < minCost)
    676682    {
    677683      minCost = cost;
    678       minRate = rate;
    679       modeDist[SAO_Cb] = dist[SAO_Cb];
    680       modeDist[SAO_Cr] = dist[SAO_Cr];
    681       modeParam[SAO_Cb]= testOffset[SAO_Cb];
    682       modeParam[SAO_Cr]= testOffset[SAO_Cr];
     684      for(compIdx= SAO_Cb; compIdx< NUM_SAO_COMPONENTS; compIdx++)
     685      {
     686        modeDist [compIdx] = dist      [compIdx];
     687        modeParam[compIdx] = testOffset[compIdx];
     688      }
    683689    }
    684690  }
     
    686692
    687693  //----- re-gen rate & normalized cost----//
    688   modeNormCost  = (Double)modeDist[SAO_Y]/m_labmda[SAO_Y];
    689   modeNormCost += (Double)(modeDist[SAO_Cb]+ modeDist[SAO_Cr])/chromaLambda;
     694  modeNormCost = 0;
     695  for(UInt component = SAO_Y; component < NUM_SAO_COMPONENTS; component++)
     696  {
     697    modeNormCost += (Double)modeDist[component] / m_lambda[component];
     698  }
    690699  m_pcRDGoOnSbacCoder->load(cabacCoderRDO[inCabacLabel]);
    691700  m_pcRDGoOnSbacCoder->resetBits();
     
    724733        //offsets have been reconstructed. Don't call inversed quantization function.
    725734        normDist += (((Double)getDistortion(ctu, compIdx, mergedOffsetParam.typeIdc, mergedOffsetParam.typeAuxInfo, mergedOffsetParam.offset, blkStats[ctu][compIdx][mergedOffsetParam.typeIdc]))
    726                        /m_labmda[compIdx]
     735                       /m_lambda[compIdx]
    727736                    );
    728737      }
     
    13041313}
    13051314
    1306 #else
    1307 
    1308 
    1309 
    1310 TEncSampleAdaptiveOffset::TEncSampleAdaptiveOffset()
    1311 {
    1312   m_pcEntropyCoder = NULL;
    1313   m_pppcRDSbacCoder = NULL;
    1314   m_pcRDGoOnSbacCoder = NULL;
    1315   m_pppcBinCoderCABAC = NULL;           
    1316   m_iCount = NULL;     
    1317   m_iOffset = NULL;     
    1318   m_iOffsetOrg = NULL; 
    1319   m_iRate = NULL;       
    1320   m_iDist = NULL;       
    1321   m_dCost = NULL;       
    1322   m_dCostPartBest = NULL;
    1323   m_iDistOrg = NULL;     
    1324   m_iTypePartBest = NULL;
    1325 #if SAO_ENCODING_CHOICE_CHROMA
    1326   m_depthSaoRate[0][0] = 0;
    1327   m_depthSaoRate[0][1] = 0;
    1328   m_depthSaoRate[0][2] = 0;
    1329   m_depthSaoRate[0][3] = 0;
    1330   m_depthSaoRate[1][0] = 0;
    1331   m_depthSaoRate[1][1] = 0;
    1332   m_depthSaoRate[1][2] = 0;
    1333   m_depthSaoRate[1][3] = 0;
    1334 #endif
    1335 }
    1336 TEncSampleAdaptiveOffset::~TEncSampleAdaptiveOffset()
    1337 {
    1338 
    1339 }
    1340 // ====================================================================================================================
    1341 // Constants
    1342 // ====================================================================================================================
    1343 
    1344 
    1345 // ====================================================================================================================
    1346 // Tables
    1347 // ====================================================================================================================
    1348 
    1349 inline Double xRoundIbdi2(Int bitDepth, Double x)
    1350 {
    1351   return ((x)>0) ? (Int)(((Int)(x)+(1<<(bitDepth-8-1)))/(1<<(bitDepth-8))) : ((Int)(((Int)(x)-(1<<(bitDepth-8-1)))/(1<<(bitDepth-8))));
    1352 }
    1353 
    1354 /** rounding with IBDI
    1355  * \param  x
    1356  */
    1357 inline Double xRoundIbdi(Int bitDepth, Double x)
    1358 {
    1359   return (bitDepth > 8 ? xRoundIbdi2(bitDepth, (x)) : ((x)>=0 ? ((Int)((x)+0.5)) : ((Int)((x)-0.5)))) ;
    1360 }
    1361 
    1362 
    1363 
    1364 /** process SAO for one partition
    1365  * \param  *psQTPart, iPartIdx, dLambda
    1366  */
    1367 Void TEncSampleAdaptiveOffset::rdoSaoOnePart(SAOQTPart *psQTPart, Int iPartIdx, Double dLambda, Int yCbCr)
    1368 {
    1369   Int iTypeIdx;
    1370   Int iNumTotalType = MAX_NUM_SAO_TYPE;
    1371   SAOQTPart*  pOnePart = &(psQTPart[iPartIdx]);
    1372 
    1373   Int64 iEstDist;
    1374   Int iClassIdx;
    1375   Int uiShift = 2 * DISTORTION_PRECISION_ADJUSTMENT((yCbCr == 0 ? g_bitDepthY : g_bitDepthC)-8);
    1376   UInt uiDepth = pOnePart->PartLevel;
    1377 
    1378   m_iDistOrg [iPartIdx] =  0;
    1379 
    1380   Double  bestRDCostTableBo = MAX_DOUBLE;
    1381   Int     bestClassTableBo    = 0;
    1382   Int     currentDistortionTableBo[MAX_NUM_SAO_CLASS];
    1383   Double  currentRdCostTableBo[MAX_NUM_SAO_CLASS];
    1384 
    1385   Int addr;
    1386   Int allowMergeLeft;
    1387   Int allowMergeUp;
    1388   Int frameWidthInCU = m_pcPic->getFrameWidthInCU();
    1389   SaoLcuParam  saoLcuParamRdo;
    1390 
    1391   for (iTypeIdx=-1; iTypeIdx<iNumTotalType; iTypeIdx++)
    1392   {
    1393     if( m_bUseSBACRD )
    1394     {
    1395       m_pcRDGoOnSbacCoder->load(m_pppcRDSbacCoder[uiDepth][CI_CURR_BEST]);
    1396       m_pcRDGoOnSbacCoder->resetBits();
    1397     }
    1398     else
    1399     {
    1400       m_pcEntropyCoder->resetEntropy();
    1401       m_pcEntropyCoder->resetBits();
    1402     }
    1403 
    1404     iEstDist = 0;
    1405 
    1406     if (iTypeIdx == -1)
    1407     {     
    1408       for (Int ry = pOnePart->StartCUY; ry<= pOnePart->EndCUY; ry++)
    1409       {
    1410         for (Int rx = pOnePart->StartCUX; rx <= pOnePart->EndCUX; rx++)
    1411         {
    1412           addr = ry * frameWidthInCU + rx;         
    1413 
    1414           // get bits for iTypeIdx = -1
    1415           allowMergeLeft = 1;
    1416           allowMergeUp   = 1;
    1417           if (rx != 0)
    1418           {
    1419             // check tile id and slice id
    1420             if ( (m_pcPic->getPicSym()->getTileIdxMap(addr-1) != m_pcPic->getPicSym()->getTileIdxMap(addr)) || (m_pcPic->getCU(addr-1)->getSlice()->getSliceIdx() != m_pcPic->getCU(addr)->getSlice()->getSliceIdx()))
    1421             {
    1422               allowMergeLeft = 0;
    1423             }
    1424           }
    1425           if (ry!=0)
    1426           {
    1427             if ( (m_pcPic->getPicSym()->getTileIdxMap(addr-m_iNumCuInWidth) != m_pcPic->getPicSym()->getTileIdxMap(addr)) || (m_pcPic->getCU(addr-m_iNumCuInWidth)->getSlice()->getSliceIdx() != m_pcPic->getCU(addr)->getSlice()->getSliceIdx()))
    1428             {
    1429               allowMergeUp = 0;
    1430             }
    1431           }
    1432 
    1433           // reset
    1434           resetSaoUnit(&saoLcuParamRdo);
    1435 
    1436           // set merge flag
    1437           saoLcuParamRdo.mergeUpFlag   = 1;
    1438           saoLcuParamRdo.mergeLeftFlag = 1;
    1439 
    1440           if (ry == pOnePart->StartCUY)
    1441           {
    1442             saoLcuParamRdo.mergeUpFlag = 0;
    1443           }
    1444          
    1445           if (rx == pOnePart->StartCUX)
    1446           {
    1447             saoLcuParamRdo.mergeLeftFlag = 0;
    1448           }
    1449 
    1450           m_pcEntropyCoder->encodeSaoUnitInterleaving(yCbCr, 1, rx, ry,  &saoLcuParamRdo, 1,  1,  allowMergeLeft, allowMergeUp);
    1451 
    1452         }
    1453       }
    1454     }
    1455 
    1456     if (iTypeIdx>=0)
    1457     {
    1458       iEstDist = estSaoTypeDist(iPartIdx, iTypeIdx, uiShift, dLambda, currentDistortionTableBo, currentRdCostTableBo);
    1459       if( iTypeIdx == SAO_BO )
    1460       {
    1461         // Estimate Best Position
    1462         Double currentRDCost = 0.0;
    1463 
    1464         for(Int i=0; i< SAO_MAX_BO_CLASSES -SAO_BO_LEN +1; i++)
    1465         {
    1466           currentRDCost = 0.0;
    1467           for(UInt uj = i; uj < i+SAO_BO_LEN; uj++)
    1468           {
    1469             currentRDCost += currentRdCostTableBo[uj];
    1470           }
    1471 
    1472           if( currentRDCost < bestRDCostTableBo)
    1473           {
    1474             bestRDCostTableBo = currentRDCost;
    1475             bestClassTableBo  = i;
    1476           }
    1477         }
    1478 
    1479         // Re code all Offsets
    1480         // Code Center
    1481         for(iClassIdx = bestClassTableBo; iClassIdx < bestClassTableBo+SAO_BO_LEN; iClassIdx++)
    1482         {
    1483           iEstDist += currentDistortionTableBo[iClassIdx];
    1484         }
    1485       }
    1486 
    1487       for (Int ry = pOnePart->StartCUY; ry<= pOnePart->EndCUY; ry++)
    1488       {
    1489         for (Int rx = pOnePart->StartCUX; rx <= pOnePart->EndCUX; rx++)
    1490         {
    1491           addr = ry * frameWidthInCU + rx;         
    1492 
    1493           // get bits for iTypeIdx = -1
    1494           allowMergeLeft = 1;
    1495           allowMergeUp   = 1;
    1496           if (rx != 0)
    1497           {
    1498             // check tile id and slice id
    1499             if ( (m_pcPic->getPicSym()->getTileIdxMap(addr-1) != m_pcPic->getPicSym()->getTileIdxMap(addr)) || (m_pcPic->getCU(addr-1)->getSlice()->getSliceIdx() != m_pcPic->getCU(addr)->getSlice()->getSliceIdx()))
    1500             {
    1501               allowMergeLeft = 0;
    1502             }
    1503           }
    1504           if (ry!=0)
    1505           {
    1506             if ( (m_pcPic->getPicSym()->getTileIdxMap(addr-m_iNumCuInWidth) != m_pcPic->getPicSym()->getTileIdxMap(addr)) || (m_pcPic->getCU(addr-m_iNumCuInWidth)->getSlice()->getSliceIdx() != m_pcPic->getCU(addr)->getSlice()->getSliceIdx()))
    1507             {
    1508               allowMergeUp = 0;
    1509             }
    1510           }
    1511 
    1512           // reset
    1513           resetSaoUnit(&saoLcuParamRdo);
    1514          
    1515           // set merge flag
    1516           saoLcuParamRdo.mergeUpFlag   = 1;
    1517           saoLcuParamRdo.mergeLeftFlag = 1;
    1518 
    1519           if (ry == pOnePart->StartCUY)
    1520           {
    1521             saoLcuParamRdo.mergeUpFlag = 0;
    1522           }
    1523          
    1524           if (rx == pOnePart->StartCUX)
    1525           {
    1526             saoLcuParamRdo.mergeLeftFlag = 0;
    1527           }
    1528 
    1529           // set type and offsets
    1530           saoLcuParamRdo.typeIdx = iTypeIdx;
    1531           saoLcuParamRdo.subTypeIdx = (iTypeIdx==SAO_BO)?bestClassTableBo:0;
    1532           saoLcuParamRdo.length = m_iNumClass[iTypeIdx];
    1533           for (iClassIdx = 0; iClassIdx < saoLcuParamRdo.length; iClassIdx++)
    1534           {
    1535             saoLcuParamRdo.offset[iClassIdx] = (Int)m_iOffset[iPartIdx][iTypeIdx][iClassIdx+saoLcuParamRdo.subTypeIdx+1];
    1536           }
    1537 
    1538           m_pcEntropyCoder->encodeSaoUnitInterleaving(yCbCr, 1, rx, ry,  &saoLcuParamRdo, 1,  1,  allowMergeLeft, allowMergeUp);
    1539 
    1540         }
    1541       }
    1542 
    1543       m_iDist[iPartIdx][iTypeIdx] = iEstDist;
    1544       m_iRate[iPartIdx][iTypeIdx] = m_pcEntropyCoder->getNumberOfWrittenBits();
    1545 
    1546       m_dCost[iPartIdx][iTypeIdx] = (Double)((Double)m_iDist[iPartIdx][iTypeIdx] + dLambda * (Double) m_iRate[iPartIdx][iTypeIdx]);
    1547 
    1548       if(m_dCost[iPartIdx][iTypeIdx] < m_dCostPartBest[iPartIdx])
    1549       {
    1550         m_iDistOrg [iPartIdx] = 0;
    1551         m_dCostPartBest[iPartIdx] = m_dCost[iPartIdx][iTypeIdx];
    1552         m_iTypePartBest[iPartIdx] = iTypeIdx;
    1553         if( m_bUseSBACRD )
    1554           m_pcRDGoOnSbacCoder->store( m_pppcRDSbacCoder[pOnePart->PartLevel][CI_TEMP_BEST] );
    1555       }
    1556     }
    1557     else
    1558     {
    1559       if(m_iDistOrg[iPartIdx] < m_dCostPartBest[iPartIdx] )
    1560       {
    1561         m_dCostPartBest[iPartIdx] = (Double) m_iDistOrg[iPartIdx] + m_pcEntropyCoder->getNumberOfWrittenBits()*dLambda ;
    1562         m_iTypePartBest[iPartIdx] = -1;
    1563         if( m_bUseSBACRD )
    1564         {
    1565           m_pcRDGoOnSbacCoder->store( m_pppcRDSbacCoder[pOnePart->PartLevel][CI_TEMP_BEST] );
    1566         }
    1567       }
    1568     }
    1569   }
    1570 
    1571   pOnePart->bProcessed = true;
    1572   pOnePart->bSplit     = false;
    1573   pOnePart->iMinDist   =        m_iTypePartBest[iPartIdx] >= 0 ? m_iDist[iPartIdx][m_iTypePartBest[iPartIdx]] : m_iDistOrg[iPartIdx];
    1574   pOnePart->iMinRate   = (Int) (m_iTypePartBest[iPartIdx] >= 0 ? m_iRate[iPartIdx][m_iTypePartBest[iPartIdx]] : 0);
    1575   pOnePart->dMinCost   = pOnePart->iMinDist + dLambda * pOnePart->iMinRate;
    1576   pOnePart->iBestType  = m_iTypePartBest[iPartIdx];
    1577   if (pOnePart->iBestType != -1)
    1578   {
    1579     //     pOnePart->bEnableFlag =  1;
    1580     pOnePart->iLength = m_iNumClass[pOnePart->iBestType];
    1581     Int minIndex = 0;
    1582     if( pOnePart->iBestType == SAO_BO )
    1583     {
    1584       pOnePart->subTypeIdx = bestClassTableBo;
    1585       minIndex = pOnePart->subTypeIdx;
    1586     }
    1587     for (Int i=0; i< pOnePart->iLength ; i++)
    1588     {
    1589       pOnePart->iOffset[i] = (Int) m_iOffset[iPartIdx][pOnePart->iBestType][minIndex+i+1];
    1590     }
    1591 
    1592   }
    1593   else
    1594   {
    1595     //     pOnePart->bEnableFlag = 0;
    1596     pOnePart->iLength     = 0;
    1597   }
    1598 }
    1599 
    1600 /** Run partition tree disable
    1601  */
    1602 Void TEncSampleAdaptiveOffset::disablePartTree(SAOQTPart *psQTPart, Int iPartIdx)
    1603 {
    1604   SAOQTPart*  pOnePart= &(psQTPart[iPartIdx]);
    1605   pOnePart->bSplit      = false;
    1606   pOnePart->iLength     =  0;
    1607   pOnePart->iBestType   = -1;
    1608 
    1609   if (pOnePart->PartLevel < m_uiMaxSplitLevel)
    1610   {
    1611     for (Int i=0; i<NUM_DOWN_PART; i++)
    1612     {
    1613       disablePartTree(psQTPart, pOnePart->DownPartsIdx[i]);
    1614     }
    1615   }
    1616 }
    1617 
    1618 /** Run quadtree decision function
    1619  * \param  iPartIdx, pcPicOrg, pcPicDec, pcPicRest, &dCostFinal
    1620  */
    1621 Void TEncSampleAdaptiveOffset::runQuadTreeDecision(SAOQTPart *psQTPart, Int iPartIdx, Double &dCostFinal, Int iMaxLevel, Double dLambda, Int yCbCr)
    1622 {
    1623   SAOQTPart*  pOnePart = &(psQTPart[iPartIdx]);
    1624 
    1625   UInt uiDepth = pOnePart->PartLevel;
    1626   UInt uhNextDepth = uiDepth+1;
    1627 
    1628   if (iPartIdx == 0)
    1629   {
    1630     dCostFinal = 0;
    1631   }
    1632 
    1633   //SAO for this part
    1634   if(!pOnePart->bProcessed)
    1635   {
    1636     rdoSaoOnePart (psQTPart, iPartIdx, dLambda, yCbCr);
    1637   }
    1638 
    1639   //SAO for sub 4 parts
    1640   if (pOnePart->PartLevel < iMaxLevel)
    1641   {
    1642     Double      dCostNotSplit = dLambda + pOnePart->dMinCost;
    1643     Double      dCostSplit    = dLambda;
    1644 
    1645     for (Int i=0; i< NUM_DOWN_PART ;i++)
    1646     {
    1647       if( m_bUseSBACRD ) 
    1648       {
    1649         if ( 0 == i) //initialize RD with previous depth buffer
    1650         {
    1651           m_pppcRDSbacCoder[uhNextDepth][CI_CURR_BEST]->load(m_pppcRDSbacCoder[uiDepth][CI_CURR_BEST]);
    1652         }
    1653         else
    1654         {
    1655           m_pppcRDSbacCoder[uhNextDepth][CI_CURR_BEST]->load(m_pppcRDSbacCoder[uhNextDepth][CI_NEXT_BEST]);
    1656         }
    1657       } 
    1658       runQuadTreeDecision(psQTPart, pOnePart->DownPartsIdx[i], dCostFinal, iMaxLevel, dLambda, yCbCr);
    1659       dCostSplit += dCostFinal;
    1660       if( m_bUseSBACRD )
    1661       {
    1662         m_pppcRDSbacCoder[uhNextDepth][CI_NEXT_BEST]->load(m_pppcRDSbacCoder[uhNextDepth][CI_TEMP_BEST]);
    1663       }
    1664     }
    1665 
    1666     if(dCostSplit < dCostNotSplit)
    1667     {
    1668       dCostFinal = dCostSplit;
    1669       pOnePart->bSplit      = true;
    1670       pOnePart->iLength     =  0;
    1671       pOnePart->iBestType   = -1;
    1672       if( m_bUseSBACRD )
    1673       {
    1674         m_pppcRDSbacCoder[uiDepth][CI_NEXT_BEST]->load(m_pppcRDSbacCoder[uhNextDepth][CI_NEXT_BEST]);
    1675       }
    1676     }
    1677     else
    1678     {
    1679       dCostFinal = dCostNotSplit;
    1680       pOnePart->bSplit = false;
    1681       for (Int i=0; i<NUM_DOWN_PART; i++)
    1682       {
    1683         disablePartTree(psQTPart, pOnePart->DownPartsIdx[i]);
    1684       }
    1685       if( m_bUseSBACRD )
    1686       {
    1687         m_pppcRDSbacCoder[uiDepth][CI_NEXT_BEST]->load(m_pppcRDSbacCoder[uiDepth][CI_TEMP_BEST]);
    1688       }
    1689     }
    1690   }
    1691   else
    1692   {
    1693     dCostFinal = pOnePart->dMinCost;
    1694   }
    1695 }
    1696 
    1697 /** delete allocated memory of TEncSampleAdaptiveOffset class.
    1698  */
    1699 Void TEncSampleAdaptiveOffset::destroyEncBuffer()
    1700 {
    1701   for (Int i=0;i<m_iNumTotalParts;i++)
    1702   {
    1703     for (Int j=0;j<MAX_NUM_SAO_TYPE;j++)
    1704     {
    1705       if (m_iCount [i][j])
    1706       {
    1707         delete [] m_iCount [i][j];
    1708       }
    1709       if (m_iOffset[i][j])
    1710       {
    1711         delete [] m_iOffset[i][j];
    1712       }
    1713       if (m_iOffsetOrg[i][j])
    1714       {
    1715         delete [] m_iOffsetOrg[i][j];
    1716       }
    1717     }
    1718     if (m_iRate[i])
    1719     {
    1720       delete [] m_iRate[i];
    1721     }
    1722     if (m_iDist[i])
    1723     {
    1724       delete [] m_iDist[i];
    1725     }
    1726     if (m_dCost[i])
    1727     {
    1728       delete [] m_dCost[i];
    1729     }
    1730     if (m_iCount [i])
    1731     {
    1732       delete [] m_iCount [i];
    1733     }
    1734     if (m_iOffset[i])
    1735     {
    1736       delete [] m_iOffset[i];
    1737     }
    1738     if (m_iOffsetOrg[i])
    1739     {
    1740       delete [] m_iOffsetOrg[i];
    1741     }
    1742 
    1743   }
    1744   if (m_iDistOrg)
    1745   {
    1746     delete [] m_iDistOrg ; m_iDistOrg = NULL;
    1747   }
    1748   if (m_dCostPartBest)
    1749   {
    1750     delete [] m_dCostPartBest ; m_dCostPartBest = NULL;
    1751   }
    1752   if (m_iTypePartBest)
    1753   {
    1754     delete [] m_iTypePartBest ; m_iTypePartBest = NULL;
    1755   }
    1756   if (m_iRate)
    1757   {
    1758     delete [] m_iRate ; m_iRate = NULL;
    1759   }
    1760   if (m_iDist)
    1761   {
    1762     delete [] m_iDist ; m_iDist = NULL;
    1763   }
    1764   if (m_dCost)
    1765   {
    1766     delete [] m_dCost ; m_dCost = NULL;
    1767   }
    1768   if (m_iCount)
    1769   {
    1770     delete [] m_iCount  ; m_iCount = NULL;
    1771   }
    1772   if (m_iOffset)
    1773   {
    1774     delete [] m_iOffset ; m_iOffset = NULL;
    1775   }
    1776   if (m_iOffsetOrg)
    1777   {
    1778     delete [] m_iOffsetOrg ; m_iOffsetOrg = NULL;
    1779   }
    1780   Int numLcu = m_iNumCuInWidth * m_iNumCuInHeight;
    1781 
    1782   for (Int i=0;i<numLcu;i++)
    1783   {
    1784     for (Int j=0;j<3;j++)
    1785     {
    1786       for (Int k=0;k<MAX_NUM_SAO_TYPE;k++)
    1787       {
    1788         if (m_count_PreDblk [i][j][k])
    1789         {
    1790           delete [] m_count_PreDblk [i][j][k];
    1791         }
    1792         if (m_offsetOrg_PreDblk[i][j][k])
    1793         {
    1794           delete [] m_offsetOrg_PreDblk[i][j][k];
    1795         }
    1796       }
    1797       if (m_count_PreDblk [i][j])
    1798       {
    1799         delete [] m_count_PreDblk [i][j];
    1800       }
    1801       if (m_offsetOrg_PreDblk[i][j])
    1802       {
    1803         delete [] m_offsetOrg_PreDblk[i][j];
    1804       }
    1805     }
    1806     if (m_count_PreDblk [i])
    1807     {
    1808       delete [] m_count_PreDblk [i];
    1809     }
    1810     if (m_offsetOrg_PreDblk[i])
    1811     {
    1812       delete [] m_offsetOrg_PreDblk[i];
    1813     }
    1814   }
    1815   if (m_count_PreDblk)
    1816   {
    1817     delete [] m_count_PreDblk  ; m_count_PreDblk = NULL;
    1818   }
    1819   if (m_offsetOrg_PreDblk)
    1820   {
    1821     delete [] m_offsetOrg_PreDblk ; m_offsetOrg_PreDblk = NULL;
    1822   }
    1823 
    1824   Int iMaxDepth = 4;
    1825   Int iDepth;
    1826   for ( iDepth = 0; iDepth < iMaxDepth+1; iDepth++ )
    1827   {
    1828     for (Int iCIIdx = 0; iCIIdx < CI_NUM; iCIIdx ++ )
    1829     {
    1830       delete m_pppcRDSbacCoder[iDepth][iCIIdx];
    1831       delete m_pppcBinCoderCABAC[iDepth][iCIIdx];
    1832     }
    1833   }
    1834 
    1835   for ( iDepth = 0; iDepth < iMaxDepth+1; iDepth++ )
    1836   {
    1837     delete [] m_pppcRDSbacCoder[iDepth];
    1838     delete [] m_pppcBinCoderCABAC[iDepth];
    1839   }
    1840 
    1841   delete [] m_pppcRDSbacCoder;
    1842   delete [] m_pppcBinCoderCABAC;
    1843 }
    1844 
    1845 /** create Encoder Buffer for SAO
    1846  * \param
    1847  */
    1848 Void TEncSampleAdaptiveOffset::createEncBuffer()
    1849 {
    1850   m_iDistOrg = new Int64 [m_iNumTotalParts];
    1851   m_dCostPartBest = new Double [m_iNumTotalParts];
    1852   m_iTypePartBest = new Int [m_iNumTotalParts];
    1853 
    1854   m_iRate = new Int64* [m_iNumTotalParts];
    1855   m_iDist = new Int64* [m_iNumTotalParts];
    1856   m_dCost = new Double*[m_iNumTotalParts];
    1857 
    1858   m_iCount  = new Int64 **[m_iNumTotalParts];
    1859   m_iOffset = new Int64 **[m_iNumTotalParts];
    1860   m_iOffsetOrg = new Int64 **[m_iNumTotalParts];
    1861 
    1862   for (Int i=0;i<m_iNumTotalParts;i++)
    1863   {
    1864     m_iRate[i] = new Int64  [MAX_NUM_SAO_TYPE];
    1865     m_iDist[i] = new Int64  [MAX_NUM_SAO_TYPE];
    1866     m_dCost[i] = new Double [MAX_NUM_SAO_TYPE];
    1867 
    1868     m_iCount [i] = new Int64 *[MAX_NUM_SAO_TYPE];
    1869     m_iOffset[i] = new Int64 *[MAX_NUM_SAO_TYPE];
    1870     m_iOffsetOrg[i] = new Int64 *[MAX_NUM_SAO_TYPE];
    1871 
    1872     for (Int j=0;j<MAX_NUM_SAO_TYPE;j++)
    1873     {
    1874       m_iCount [i][j]   = new Int64 [MAX_NUM_SAO_CLASS];
    1875       m_iOffset[i][j]   = new Int64 [MAX_NUM_SAO_CLASS];
    1876       m_iOffsetOrg[i][j]= new Int64 [MAX_NUM_SAO_CLASS];
    1877     }
    1878   }
    1879   Int numLcu = m_iNumCuInWidth * m_iNumCuInHeight;
    1880   m_count_PreDblk  = new Int64 ***[numLcu];
    1881   m_offsetOrg_PreDblk = new Int64 ***[numLcu];
    1882   for (Int i=0; i<numLcu; i++)
    1883   {
    1884     m_count_PreDblk[i]  = new Int64 **[3];
    1885     m_offsetOrg_PreDblk[i] = new Int64 **[3];
    1886 
    1887     for (Int j=0;j<3;j++)
    1888     {
    1889       m_count_PreDblk [i][j] = new Int64 *[MAX_NUM_SAO_TYPE];
    1890       m_offsetOrg_PreDblk[i][j] = new Int64 *[MAX_NUM_SAO_TYPE];
    1891 
    1892       for (Int k=0;k<MAX_NUM_SAO_TYPE;k++)
    1893       {
    1894         m_count_PreDblk [i][j][k]   = new Int64 [MAX_NUM_SAO_CLASS];
    1895         m_offsetOrg_PreDblk[i][j][k]= new Int64 [MAX_NUM_SAO_CLASS];
    1896       }
    1897     }
    1898   }
    1899 
    1900   Int iMaxDepth = 4;
    1901   m_pppcRDSbacCoder = new TEncSbac** [iMaxDepth+1];
    1902 #if FAST_BIT_EST
    1903   m_pppcBinCoderCABAC = new TEncBinCABACCounter** [iMaxDepth+1];
    1904 #else
    1905   m_pppcBinCoderCABAC = new TEncBinCABAC** [iMaxDepth+1];
    1906 #endif
    1907 
    1908   for ( Int iDepth = 0; iDepth < iMaxDepth+1; iDepth++ )
    1909   {
    1910     m_pppcRDSbacCoder[iDepth] = new TEncSbac* [CI_NUM];
    1911 #if FAST_BIT_EST
    1912     m_pppcBinCoderCABAC[iDepth] = new TEncBinCABACCounter* [CI_NUM];
    1913 #else
    1914     m_pppcBinCoderCABAC[iDepth] = new TEncBinCABAC* [CI_NUM];
    1915 #endif
    1916     for (Int iCIIdx = 0; iCIIdx < CI_NUM; iCIIdx ++ )
    1917     {
    1918       m_pppcRDSbacCoder[iDepth][iCIIdx] = new TEncSbac;
    1919 #if FAST_BIT_EST
    1920       m_pppcBinCoderCABAC [iDepth][iCIIdx] = new TEncBinCABACCounter;
    1921 #else
    1922       m_pppcBinCoderCABAC [iDepth][iCIIdx] = new TEncBinCABAC;
    1923 #endif
    1924       m_pppcRDSbacCoder   [iDepth][iCIIdx]->init( m_pppcBinCoderCABAC [iDepth][iCIIdx] );
    1925     }
    1926   }
    1927 }
    1928 
    1929 /** Start SAO encoder
    1930  * \param pcPic, pcEntropyCoder, pppcRDSbacCoder, pcRDGoOnSbacCoder
    1931  */
    1932 Void TEncSampleAdaptiveOffset::startSaoEnc( TComPic* pcPic, TEncEntropy* pcEntropyCoder, TEncSbac*** pppcRDSbacCoder, TEncSbac* pcRDGoOnSbacCoder)
    1933 {
    1934     m_bUseSBACRD = true;
    1935   m_pcPic = pcPic;
    1936   m_pcEntropyCoder = pcEntropyCoder;
    1937 
    1938   m_pcRDGoOnSbacCoder = pcRDGoOnSbacCoder;
    1939   m_pcEntropyCoder->setEntropyCoder(m_pcRDGoOnSbacCoder, pcPic->getSlice(0));
    1940   m_pcEntropyCoder->resetEntropy();
    1941   m_pcEntropyCoder->resetBits();
    1942 
    1943   if( m_bUseSBACRD )
    1944   {
    1945     m_pcRDGoOnSbacCoder->store( m_pppcRDSbacCoder[0][CI_NEXT_BEST]);
    1946     m_pppcRDSbacCoder[0][CI_CURR_BEST]->load( m_pppcRDSbacCoder[0][CI_NEXT_BEST]);
    1947   }
    1948 }
    1949 
    1950 /** End SAO encoder
    1951  */
    1952 Void TEncSampleAdaptiveOffset::endSaoEnc()
    1953 {
    1954   m_pcPic = NULL;
    1955   m_pcEntropyCoder = NULL;
    1956 }
    1957 
    1958 inline Int xSign(Int x)
    1959 {
    1960   return ((x >> 31) | ((Int)( (((UInt) -x)) >> 31)));
    1961 }
    1962 
    1963 /** Calculate SAO statistics for non-cross-slice or non-cross-tile processing
    1964  * \param  pRecStart to-be-filtered block buffer pointer
    1965  * \param  pOrgStart original block buffer pointer
    1966  * \param  stride picture buffer stride
    1967  * \param  ppStat statistics buffer
    1968  * \param  ppCount counter buffer
    1969  * \param  width block width
    1970  * \param  height block height
    1971  * \param  pbBorderAvail availabilities of block border pixels
    1972  */
    1973 Void TEncSampleAdaptiveOffset::calcSaoStatsBlock( Pel* pRecStart, Pel* pOrgStart, Int stride, Int64** ppStats, Int64** ppCount, UInt width, UInt height, Bool* pbBorderAvail, Int iYCbCr)
    1974 {
    1975   Int64 *stats, *count;
    1976   Int classIdx, posShift, startX, endX, startY, endY, signLeft,signRight,signDown,signDown1;
    1977   Pel *pOrg, *pRec;
    1978   UInt edgeType;
    1979   Int x, y;
    1980   Pel *pTableBo = (iYCbCr==0)?m_lumaTableBo:m_chromaTableBo;
    1981 
    1982   //--------- Band offset-----------//
    1983   stats = ppStats[SAO_BO];
    1984   count = ppCount[SAO_BO];
    1985   pOrg   = pOrgStart;
    1986   pRec   = pRecStart;
    1987   for (y=0; y< height; y++)
    1988   {
    1989     for (x=0; x< width; x++)
    1990     {
    1991       classIdx = pTableBo[pRec[x]];
    1992       if (classIdx)
    1993       {
    1994         stats[classIdx] += (pOrg[x] - pRec[x]);
    1995         count[classIdx] ++;
    1996       }
    1997     }
    1998     pOrg += stride;
    1999     pRec += stride;
    2000   }
    2001   //---------- Edge offset 0--------------//
    2002   stats = ppStats[SAO_EO_0];
    2003   count = ppCount[SAO_EO_0];
    2004   pOrg   = pOrgStart;
    2005   pRec   = pRecStart;
    2006 
    2007 
    2008   startX = (pbBorderAvail[SGU_L]) ? 0 : 1;
    2009   endX   = (pbBorderAvail[SGU_R]) ? width : (width -1);
    2010   for (y=0; y< height; y++)
    2011   {
    2012     signLeft = xSign(pRec[startX] - pRec[startX-1]);
    2013     for (x=startX; x< endX; x++)
    2014     {
    2015       signRight =  xSign(pRec[x] - pRec[x+1]);
    2016       edgeType =  signRight + signLeft + 2;
    2017       signLeft  = -signRight;
    2018 
    2019       stats[m_auiEoTable[edgeType]] += (pOrg[x] - pRec[x]);
    2020       count[m_auiEoTable[edgeType]] ++;
    2021     }
    2022     pRec  += stride;
    2023     pOrg += stride;
    2024   }
    2025 
    2026   //---------- Edge offset 1--------------//
    2027   stats = ppStats[SAO_EO_1];
    2028   count = ppCount[SAO_EO_1];
    2029   pOrg   = pOrgStart;
    2030   pRec   = pRecStart;
    2031 
    2032   startY = (pbBorderAvail[SGU_T]) ? 0 : 1;
    2033   endY   = (pbBorderAvail[SGU_B]) ? height : height-1;
    2034   if (!pbBorderAvail[SGU_T])
    2035   {
    2036     pRec  += stride;
    2037     pOrg  += stride;
    2038   }
    2039 
    2040   for (x=0; x< width; x++)
    2041   {
    2042     m_iUpBuff1[x] = xSign(pRec[x] - pRec[x-stride]);
    2043   }
    2044   for (y=startY; y<endY; y++)
    2045   {
    2046     for (x=0; x< width; x++)
    2047     {
    2048       signDown     =  xSign(pRec[x] - pRec[x+stride]);
    2049       edgeType    =  signDown + m_iUpBuff1[x] + 2;
    2050       m_iUpBuff1[x] = -signDown;
    2051 
    2052       stats[m_auiEoTable[edgeType]] += (pOrg[x] - pRec[x]);
    2053       count[m_auiEoTable[edgeType]] ++;
    2054     }
    2055     pOrg += stride;
    2056     pRec += stride;
    2057   }
    2058   //---------- Edge offset 2--------------//
    2059   stats = ppStats[SAO_EO_2];
    2060   count = ppCount[SAO_EO_2];
    2061   pOrg   = pOrgStart;
    2062   pRec   = pRecStart;
    2063 
    2064   posShift= stride + 1;
    2065 
    2066   startX = (pbBorderAvail[SGU_L]) ? 0 : 1 ;
    2067   endX   = (pbBorderAvail[SGU_R]) ? width : (width-1);
    2068 
    2069   //prepare 2nd line upper sign
    2070   pRec += stride;
    2071   for (x=startX; x< endX+1; x++)
    2072   {
    2073     m_iUpBuff1[x] = xSign(pRec[x] - pRec[x- posShift]);
    2074   }
    2075 
    2076   //1st line
    2077   pRec -= stride;
    2078   if(pbBorderAvail[SGU_TL])
    2079   {
    2080     x= 0;
    2081     edgeType      =  xSign(pRec[x] - pRec[x- posShift]) - m_iUpBuff1[x+1] + 2;
    2082     stats[m_auiEoTable[edgeType]] += (pOrg[x] - pRec[x]);
    2083     count[m_auiEoTable[edgeType]] ++;
    2084   }
    2085   if(pbBorderAvail[SGU_T])
    2086   {
    2087     for(x= 1; x< endX; x++)
    2088     {
    2089       edgeType      =  xSign(pRec[x] - pRec[x- posShift]) - m_iUpBuff1[x+1] + 2;
    2090       stats[m_auiEoTable[edgeType]] += (pOrg[x] - pRec[x]);
    2091       count[m_auiEoTable[edgeType]] ++;
    2092     }
    2093   }
    2094   pRec   += stride;
    2095   pOrg   += stride;
    2096 
    2097   //middle lines
    2098   for (y= 1; y< height-1; y++)
    2099   {
    2100     for (x=startX; x<endX; x++)
    2101     {
    2102       signDown1      =  xSign(pRec[x] - pRec[x+ posShift]) ;
    2103       edgeType      =  signDown1 + m_iUpBuff1[x] + 2;
    2104       stats[m_auiEoTable[edgeType]] += (pOrg[x] - pRec[x]);
    2105       count[m_auiEoTable[edgeType]] ++;
    2106 
    2107       m_iUpBufft[x+1] = -signDown1;
    2108     }
    2109     m_iUpBufft[startX] = xSign(pRec[stride+startX] - pRec[startX-1]);
    2110 
    2111     ipSwap     = m_iUpBuff1;
    2112     m_iUpBuff1 = m_iUpBufft;
    2113     m_iUpBufft = ipSwap;
    2114 
    2115     pRec  += stride;
    2116     pOrg  += stride;
    2117   }
    2118 
    2119   //last line
    2120   if(pbBorderAvail[SGU_B])
    2121   {
    2122     for(x= startX; x< width-1; x++)
    2123     {
    2124       edgeType =  xSign(pRec[x] - pRec[x+ posShift]) + m_iUpBuff1[x] + 2;
    2125       stats[m_auiEoTable[edgeType]] += (pOrg[x] - pRec[x]);
    2126       count[m_auiEoTable[edgeType]] ++;
    2127     }
    2128   }
    2129   if(pbBorderAvail[SGU_BR])
    2130   {
    2131     x= width -1;
    2132     edgeType =  xSign(pRec[x] - pRec[x+ posShift]) + m_iUpBuff1[x] + 2;
    2133     stats[m_auiEoTable[edgeType]] += (pOrg[x] - pRec[x]);
    2134     count[m_auiEoTable[edgeType]] ++;
    2135   }
    2136 
    2137   //---------- Edge offset 3--------------//
    2138 
    2139   stats = ppStats[SAO_EO_3];
    2140   count = ppCount[SAO_EO_3];
    2141   pOrg   = pOrgStart;
    2142   pRec   = pRecStart;
    2143 
    2144   posShift     = stride - 1;
    2145   startX = (pbBorderAvail[SGU_L]) ? 0 : 1;
    2146   endX   = (pbBorderAvail[SGU_R]) ? width : (width -1);
    2147 
    2148   //prepare 2nd line upper sign
    2149   pRec += stride;
    2150   for (x=startX-1; x< endX; x++)
    2151   {
    2152     m_iUpBuff1[x] = xSign(pRec[x] - pRec[x- posShift]);
    2153   }
    2154 
    2155 
    2156   //first line
    2157   pRec -= stride;
    2158   if(pbBorderAvail[SGU_T])
    2159   {
    2160     for(x= startX; x< width -1; x++)
    2161     {
    2162       edgeType = xSign(pRec[x] - pRec[x- posShift]) -m_iUpBuff1[x-1] + 2;
    2163       stats[m_auiEoTable[edgeType]] += (pOrg[x] - pRec[x]);
    2164       count[m_auiEoTable[edgeType]] ++;
    2165     }
    2166   }
    2167   if(pbBorderAvail[SGU_TR])
    2168   {
    2169     x= width-1;
    2170     edgeType = xSign(pRec[x] - pRec[x- posShift]) -m_iUpBuff1[x-1] + 2;
    2171     stats[m_auiEoTable[edgeType]] += (pOrg[x] - pRec[x]);
    2172     count[m_auiEoTable[edgeType]] ++;
    2173   }
    2174   pRec  += stride;
    2175   pOrg  += stride;
    2176 
    2177   //middle lines
    2178   for (y= 1; y< height-1; y++)
    2179   {
    2180     for(x= startX; x< endX; x++)
    2181     {
    2182       signDown1      =  xSign(pRec[x] - pRec[x+ posShift]) ;
    2183       edgeType      =  signDown1 + m_iUpBuff1[x] + 2;
    2184 
    2185       stats[m_auiEoTable[edgeType]] += (pOrg[x] - pRec[x]);
    2186       count[m_auiEoTable[edgeType]] ++;
    2187       m_iUpBuff1[x-1] = -signDown1;
    2188 
    2189     }
    2190     m_iUpBuff1[endX-1] = xSign(pRec[endX-1 + stride] - pRec[endX]);
    2191 
    2192     pRec  += stride;
    2193     pOrg  += stride;
    2194   }
    2195 
    2196   //last line
    2197   if(pbBorderAvail[SGU_BL])
    2198   {
    2199     x= 0;
    2200     edgeType = xSign(pRec[x] - pRec[x+ posShift]) + m_iUpBuff1[x] + 2;
    2201     stats[m_auiEoTable[edgeType]] += (pOrg[x] - pRec[x]);
    2202     count[m_auiEoTable[edgeType]] ++;
    2203 
    2204   }
    2205   if(pbBorderAvail[SGU_B])
    2206   {
    2207     for(x= 1; x< endX; x++)
    2208     {
    2209       edgeType = xSign(pRec[x] - pRec[x+ posShift]) + m_iUpBuff1[x] + 2;
    2210       stats[m_auiEoTable[edgeType]] += (pOrg[x] - pRec[x]);
    2211       count[m_auiEoTable[edgeType]] ++;
    2212     }
    2213   }
    2214 }
    2215 
    2216 /** Calculate SAO statistics for current LCU
    2217  * \param  iAddr,  iPartIdx,  iYCbCr
    2218  */
    2219 Void TEncSampleAdaptiveOffset::calcSaoStatsCu(Int iAddr, Int iPartIdx, Int iYCbCr)
    2220 {
    2221   if(!m_bUseNIF)
    2222   {
    2223     calcSaoStatsCuOrg( iAddr, iPartIdx, iYCbCr);
    2224   }
    2225   else
    2226   {
    2227     Int64** ppStats = m_iOffsetOrg[iPartIdx];
    2228     Int64** ppCount = m_iCount    [iPartIdx];
    2229 
    2230     //parameters
    2231     Int  isChroma = (iYCbCr != 0)? 1:0;
    2232     Int  stride   = (iYCbCr != 0)?(m_pcPic->getCStride()):(m_pcPic->getStride());
    2233     Pel* pPicOrg = getPicYuvAddr (m_pcPic->getPicYuvOrg(), iYCbCr);
    2234     Pel* pPicRec  = getPicYuvAddr(m_pcYuvTmp, iYCbCr);
    2235 
    2236     std::vector<NDBFBlockInfo>& vFilterBlocks = *(m_pcPic->getCU(iAddr)->getNDBFilterBlocks());
    2237 
    2238     //variables
    2239     UInt  xPos, yPos, width, height;
    2240     Bool* pbBorderAvail;
    2241     UInt  posOffset;
    2242 
    2243     for(Int i=0; i< vFilterBlocks.size(); i++)
    2244     {
    2245       xPos        = vFilterBlocks[i].posX   >> isChroma;
    2246       yPos        = vFilterBlocks[i].posY   >> isChroma;
    2247       width       = vFilterBlocks[i].width  >> isChroma;
    2248       height      = vFilterBlocks[i].height >> isChroma;
    2249       pbBorderAvail = vFilterBlocks[i].isBorderAvailable;
    2250 
    2251       posOffset = (yPos* stride) + xPos;
    2252 
    2253       calcSaoStatsBlock(pPicRec+ posOffset, pPicOrg+ posOffset, stride, ppStats, ppCount,width, height, pbBorderAvail, iYCbCr);
    2254     }
    2255   }
    2256 
    2257 }
    2258 
    2259 /** Calculate SAO statistics for current LCU without non-crossing slice
    2260  * \param  iAddr,  iPartIdx,  iYCbCr
    2261  */
    2262 Void TEncSampleAdaptiveOffset::calcSaoStatsCuOrg(Int iAddr, Int iPartIdx, Int iYCbCr)
    2263 {
    2264   Int x,y;
    2265   TComDataCU *pTmpCu = m_pcPic->getCU(iAddr);
    2266   TComSPS *pTmpSPS =  m_pcPic->getSlice(0)->getSPS();
    2267 
    2268   Pel* pOrg;
    2269   Pel* pRec;
    2270   Int iStride;
    2271   Int iLcuHeight = pTmpSPS->getMaxCUHeight();
    2272   Int iLcuWidth  = pTmpSPS->getMaxCUWidth();
    2273   UInt uiLPelX   = pTmpCu->getCUPelX();
    2274   UInt uiTPelY   = pTmpCu->getCUPelY();
    2275   UInt uiRPelX;
    2276   UInt uiBPelY;
    2277   Int64* iStats;
    2278   Int64* iCount;
    2279   Int iClassIdx;
    2280   Int iPicWidthTmp;
    2281   Int iPicHeightTmp;
    2282   Int iStartX;
    2283   Int iStartY;
    2284   Int iEndX;
    2285   Int iEndY;
    2286   Pel* pTableBo = (iYCbCr==0)?m_lumaTableBo:m_chromaTableBo;
    2287 
    2288   Int iIsChroma = (iYCbCr!=0)? 1:0;
    2289   Int numSkipLine = iIsChroma? 2:4;
    2290   if (m_saoLcuBasedOptimization == 0)
    2291   {
    2292     numSkipLine = 0;
    2293   }
    2294 
    2295   Int numSkipLineRight = iIsChroma? 3:5;
    2296   if (m_saoLcuBasedOptimization == 0)
    2297   {
    2298     numSkipLineRight = 0;
    2299   }
    2300 
    2301   iPicWidthTmp  = m_iPicWidth  >> iIsChroma;
    2302   iPicHeightTmp = m_iPicHeight >> iIsChroma;
    2303   iLcuWidth     = iLcuWidth    >> iIsChroma;
    2304   iLcuHeight    = iLcuHeight   >> iIsChroma;
    2305   uiLPelX       = uiLPelX      >> iIsChroma;
    2306   uiTPelY       = uiTPelY      >> iIsChroma;
    2307   uiRPelX       = uiLPelX + iLcuWidth  ;
    2308   uiBPelY       = uiTPelY + iLcuHeight ;
    2309   uiRPelX       = uiRPelX > iPicWidthTmp  ? iPicWidthTmp  : uiRPelX;
    2310   uiBPelY       = uiBPelY > iPicHeightTmp ? iPicHeightTmp : uiBPelY;
    2311   iLcuWidth     = uiRPelX - uiLPelX;
    2312   iLcuHeight    = uiBPelY - uiTPelY;
    2313 
    2314   iStride    =  (iYCbCr == 0)? m_pcPic->getStride(): m_pcPic->getCStride();
    2315 
    2316 //if(iSaoType == BO_0 || iSaoType == BO_1)
    2317   {
    2318     if( m_saoLcuBasedOptimization && m_saoLcuBoundary )
    2319     {
    2320       numSkipLine = iIsChroma? 1:3;
    2321       numSkipLineRight = iIsChroma? 2:4;
    2322     }
    2323     iStats = m_iOffsetOrg[iPartIdx][SAO_BO];
    2324     iCount = m_iCount    [iPartIdx][SAO_BO];
    2325 
    2326     pOrg = getPicYuvAddr(m_pcPic->getPicYuvOrg(), iYCbCr, iAddr);
    2327     pRec = getPicYuvAddr(m_pcPic->getPicYuvRec(), iYCbCr, iAddr);
    2328 
    2329     iEndX   = (uiRPelX == iPicWidthTmp) ? iLcuWidth : iLcuWidth-numSkipLineRight;
    2330     iEndY   = (uiBPelY == iPicHeightTmp) ? iLcuHeight : iLcuHeight-numSkipLine;
    2331     for (y=0; y<iEndY; y++)
    2332     {
    2333       for (x=0; x<iEndX; x++)
    2334       {
    2335         iClassIdx = pTableBo[pRec[x]];
    2336         if (iClassIdx)
    2337         {
    2338           iStats[iClassIdx] += (pOrg[x] - pRec[x]);
    2339           iCount[iClassIdx] ++;
    2340         }
    2341       }
    2342       pOrg += iStride;
    2343       pRec += iStride;
    2344     }
    2345 
    2346   }
    2347   Int iSignLeft;
    2348   Int iSignRight;
    2349   Int iSignDown;
    2350   Int iSignDown1;
    2351   Int iSignDown2;
    2352 
    2353   UInt uiEdgeType;
    2354 
    2355 //if (iSaoType == EO_0  || iSaoType == EO_1 || iSaoType == EO_2 || iSaoType == EO_3)
    2356   {
    2357   //if (iSaoType == EO_0)
    2358     {
    2359       if( m_saoLcuBasedOptimization && m_saoLcuBoundary )
    2360       {
    2361         numSkipLine = iIsChroma? 1:3;
    2362         numSkipLineRight = iIsChroma? 3:5;
    2363       }
    2364       iStats = m_iOffsetOrg[iPartIdx][SAO_EO_0];
    2365       iCount = m_iCount    [iPartIdx][SAO_EO_0];
    2366 
    2367       pOrg = getPicYuvAddr(m_pcPic->getPicYuvOrg(), iYCbCr, iAddr);
    2368       pRec = getPicYuvAddr(m_pcPic->getPicYuvRec(), iYCbCr, iAddr);
    2369 
    2370       iStartX = (uiLPelX == 0) ? 1 : 0;
    2371       iEndX   = (uiRPelX == iPicWidthTmp) ? iLcuWidth-1 : iLcuWidth-numSkipLineRight;
    2372       for (y=0; y<iLcuHeight-numSkipLine; y++)
    2373       {
    2374         iSignLeft = xSign(pRec[iStartX] - pRec[iStartX-1]);
    2375         for (x=iStartX; x< iEndX; x++)
    2376         {
    2377           iSignRight =  xSign(pRec[x] - pRec[x+1]);
    2378           uiEdgeType =  iSignRight + iSignLeft + 2;
    2379           iSignLeft  = -iSignRight;
    2380 
    2381           iStats[m_auiEoTable[uiEdgeType]] += (pOrg[x] - pRec[x]);
    2382           iCount[m_auiEoTable[uiEdgeType]] ++;
    2383         }
    2384         pOrg += iStride;
    2385         pRec += iStride;
    2386       }
    2387     }
    2388 
    2389   //if (iSaoType == EO_1)
    2390     {
    2391       if( m_saoLcuBasedOptimization && m_saoLcuBoundary )
    2392       {
    2393         numSkipLine = iIsChroma? 2:4;
    2394         numSkipLineRight = iIsChroma? 2:4;
    2395       }
    2396       iStats = m_iOffsetOrg[iPartIdx][SAO_EO_1];
    2397       iCount = m_iCount    [iPartIdx][SAO_EO_1];
    2398 
    2399       pOrg = getPicYuvAddr(m_pcPic->getPicYuvOrg(), iYCbCr, iAddr);
    2400       pRec = getPicYuvAddr(m_pcPic->getPicYuvRec(), iYCbCr, iAddr);
    2401 
    2402       iStartY = (uiTPelY == 0) ? 1 : 0;
    2403       iEndX   = (uiRPelX == iPicWidthTmp) ? iLcuWidth : iLcuWidth-numSkipLineRight;
    2404       iEndY   = (uiBPelY == iPicHeightTmp) ? iLcuHeight-1 : iLcuHeight-numSkipLine;
    2405       if (uiTPelY == 0)
    2406       {
    2407         pOrg += iStride;
    2408         pRec += iStride;
    2409       }
    2410 
    2411       for (x=0; x< iLcuWidth; x++)
    2412       {
    2413         m_iUpBuff1[x] = xSign(pRec[x] - pRec[x-iStride]);
    2414       }
    2415       for (y=iStartY; y<iEndY; y++)
    2416       {
    2417         for (x=0; x<iEndX; x++)
    2418         {
    2419           iSignDown     =  xSign(pRec[x] - pRec[x+iStride]);
    2420           uiEdgeType    =  iSignDown + m_iUpBuff1[x] + 2;
    2421           m_iUpBuff1[x] = -iSignDown;
    2422 
    2423           iStats[m_auiEoTable[uiEdgeType]] += (pOrg[x] - pRec[x]);
    2424           iCount[m_auiEoTable[uiEdgeType]] ++;
    2425         }
    2426         pOrg += iStride;
    2427         pRec += iStride;
    2428       }
    2429     }
    2430   //if (iSaoType == EO_2)
    2431     {
    2432       if( m_saoLcuBasedOptimization && m_saoLcuBoundary )
    2433       {
    2434         numSkipLine = iIsChroma? 2:4;
    2435         numSkipLineRight = iIsChroma? 3:5;
    2436       }
    2437       iStats = m_iOffsetOrg[iPartIdx][SAO_EO_2];
    2438       iCount = m_iCount    [iPartIdx][SAO_EO_2];
    2439 
    2440       pOrg = getPicYuvAddr(m_pcPic->getPicYuvOrg(), iYCbCr, iAddr);
    2441       pRec = getPicYuvAddr(m_pcPic->getPicYuvRec(), iYCbCr, iAddr);
    2442 
    2443       iStartX = (uiLPelX == 0) ? 1 : 0;
    2444       iEndX   = (uiRPelX == iPicWidthTmp) ? iLcuWidth-1 : iLcuWidth-numSkipLineRight;
    2445 
    2446       iStartY = (uiTPelY == 0) ? 1 : 0;
    2447       iEndY   = (uiBPelY == iPicHeightTmp) ? iLcuHeight-1 : iLcuHeight-numSkipLine;
    2448       if (uiTPelY == 0)
    2449       {
    2450         pOrg += iStride;
    2451         pRec += iStride;
    2452       }
    2453 
    2454       for (x=iStartX; x<iEndX; x++)
    2455       {
    2456         m_iUpBuff1[x] = xSign(pRec[x] - pRec[x-iStride-1]);
    2457       }
    2458       for (y=iStartY; y<iEndY; y++)
    2459       {
    2460         iSignDown2 = xSign(pRec[iStride+iStartX] - pRec[iStartX-1]);
    2461         for (x=iStartX; x<iEndX; x++)
    2462         {
    2463           iSignDown1      =  xSign(pRec[x] - pRec[x+iStride+1]) ;
    2464           uiEdgeType      =  iSignDown1 + m_iUpBuff1[x] + 2;
    2465           m_iUpBufft[x+1] = -iSignDown1;
    2466           iStats[m_auiEoTable[uiEdgeType]] += (pOrg[x] - pRec[x]);
    2467           iCount[m_auiEoTable[uiEdgeType]] ++;
    2468         }
    2469         m_iUpBufft[iStartX] = iSignDown2;
    2470         ipSwap     = m_iUpBuff1;
    2471         m_iUpBuff1 = m_iUpBufft;
    2472         m_iUpBufft = ipSwap;
    2473 
    2474         pRec += iStride;
    2475         pOrg += iStride;
    2476       }
    2477     }
    2478   //if (iSaoType == EO_3  )
    2479     {
    2480       if( m_saoLcuBasedOptimization && m_saoLcuBoundary )
    2481       {
    2482         numSkipLine = iIsChroma? 2:4;
    2483         numSkipLineRight = iIsChroma? 3:5;
    2484       }
    2485       iStats = m_iOffsetOrg[iPartIdx][SAO_EO_3];
    2486       iCount = m_iCount    [iPartIdx][SAO_EO_3];
    2487 
    2488       pOrg = getPicYuvAddr(m_pcPic->getPicYuvOrg(), iYCbCr, iAddr);
    2489       pRec = getPicYuvAddr(m_pcPic->getPicYuvRec(), iYCbCr, iAddr);
    2490 
    2491       iStartX = (uiLPelX == 0) ? 1 : 0;
    2492       iEndX   = (uiRPelX == iPicWidthTmp) ? iLcuWidth-1 : iLcuWidth-numSkipLineRight;
    2493 
    2494       iStartY = (uiTPelY == 0) ? 1 : 0;
    2495       iEndY   = (uiBPelY == iPicHeightTmp) ? iLcuHeight-1 : iLcuHeight-numSkipLine;
    2496       if (iStartY == 1)
    2497       {
    2498         pOrg += iStride;
    2499         pRec += iStride;
    2500       }
    2501 
    2502       for (x=iStartX-1; x<iEndX; x++)
    2503       {
    2504         m_iUpBuff1[x] = xSign(pRec[x] - pRec[x-iStride+1]);
    2505       }
    2506 
    2507       for (y=iStartY; y<iEndY; y++)
    2508       {
    2509         for (x=iStartX; x<iEndX; x++)
    2510         {
    2511           iSignDown1      =  xSign(pRec[x] - pRec[x+iStride-1]) ;
    2512           uiEdgeType      =  iSignDown1 + m_iUpBuff1[x] + 2;
    2513           m_iUpBuff1[x-1] = -iSignDown1;
    2514           iStats[m_auiEoTable[uiEdgeType]] += (pOrg[x] - pRec[x]);
    2515           iCount[m_auiEoTable[uiEdgeType]] ++;
    2516         }
    2517         m_iUpBuff1[iEndX-1] = xSign(pRec[iEndX-1 + iStride] - pRec[iEndX]);
    2518 
    2519         pRec += iStride;
    2520         pOrg += iStride;
    2521       }
    2522     }
    2523   }
    2524 }
    2525 
    2526 
    2527 Void TEncSampleAdaptiveOffset::calcSaoStatsCu_BeforeDblk( TComPic* pcPic )
    2528 {
    2529   Int addr, yCbCr;
    2530   Int x,y;
    2531   TComSPS *pTmpSPS =  pcPic->getSlice(0)->getSPS();
    2532 
    2533   Pel* pOrg;
    2534   Pel* pRec;
    2535   Int stride;
    2536   Int lcuHeight = pTmpSPS->getMaxCUHeight();
    2537   Int lcuWidth  = pTmpSPS->getMaxCUWidth();
    2538   UInt rPelX;
    2539   UInt bPelY;
    2540   Int64* stats;
    2541   Int64* count;
    2542   Int classIdx;
    2543   Int picWidthTmp = 0;
    2544   Int picHeightTmp = 0;
    2545   Int startX;
    2546   Int startY;
    2547   Int endX;
    2548   Int endY;
    2549   Int firstX, firstY;
    2550 
    2551   Int idxY;
    2552   Int idxX;
    2553   Int frameHeightInCU = m_iNumCuInHeight;
    2554   Int frameWidthInCU  = m_iNumCuInWidth;
    2555   Int j, k;
    2556 
    2557   Int isChroma;
    2558   Int numSkipLine, numSkipLineRight;
    2559 
    2560   UInt lPelX, tPelY;
    2561   TComDataCU *pTmpCu;
    2562   Pel* pTableBo;
    2563 
    2564   for (idxY = 0; idxY< frameHeightInCU; idxY++)
    2565   {
    2566     for (idxX = 0; idxX< frameWidthInCU; idxX++)
    2567     {
    2568       lcuHeight = pTmpSPS->getMaxCUHeight();
    2569       lcuWidth  = pTmpSPS->getMaxCUWidth();
    2570       addr     = idxX  + frameWidthInCU*idxY;
    2571       pTmpCu = pcPic->getCU(addr);
    2572       lPelX   = pTmpCu->getCUPelX();
    2573       tPelY   = pTmpCu->getCUPelY();
    2574       for( yCbCr = 0; yCbCr < 3; yCbCr++ )
    2575       {
    2576         isChroma = (yCbCr!=0)? 1:0;
    2577 
    2578         for ( j=0;j<MAX_NUM_SAO_TYPE;j++)
    2579         {
    2580           for ( k=0;k< MAX_NUM_SAO_CLASS;k++)
    2581           {
    2582             m_count_PreDblk    [addr][yCbCr][j][k] = 0;
    2583             m_offsetOrg_PreDblk[addr][yCbCr][j][k] = 0;
    2584           } 
    2585         }
    2586         if( yCbCr == 0 )
    2587         {
    2588           picWidthTmp  = m_iPicWidth;
    2589           picHeightTmp = m_iPicHeight;
    2590         }
    2591         else if( yCbCr == 1 )
    2592         {
    2593           picWidthTmp  = m_iPicWidth  >> isChroma;
    2594           picHeightTmp = m_iPicHeight >> isChroma;
    2595           lcuWidth     = lcuWidth    >> isChroma;
    2596           lcuHeight    = lcuHeight   >> isChroma;
    2597           lPelX       = lPelX      >> isChroma;
    2598           tPelY       = tPelY      >> isChroma;
    2599         }
    2600         rPelX       = lPelX + lcuWidth  ;
    2601         bPelY       = tPelY + lcuHeight ;
    2602         rPelX       = rPelX > picWidthTmp  ? picWidthTmp  : rPelX;
    2603         bPelY       = bPelY > picHeightTmp ? picHeightTmp : bPelY;
    2604         lcuWidth     = rPelX - lPelX;
    2605         lcuHeight    = bPelY - tPelY;
    2606 
    2607         stride    =  (yCbCr == 0)? pcPic->getStride(): pcPic->getCStride();
    2608         pTableBo = (yCbCr==0)?m_lumaTableBo:m_chromaTableBo;
    2609 
    2610         //if(iSaoType == BO)
    2611 
    2612         numSkipLine = isChroma? 1:3;
    2613         numSkipLineRight = isChroma? 2:4;
    2614 
    2615         stats = m_offsetOrg_PreDblk[addr][yCbCr][SAO_BO];
    2616         count = m_count_PreDblk[addr][yCbCr][SAO_BO];
    2617 
    2618         pOrg = getPicYuvAddr(pcPic->getPicYuvOrg(), yCbCr, addr);
    2619         pRec = getPicYuvAddr(pcPic->getPicYuvRec(), yCbCr, addr);
    2620 
    2621         startX   = (rPelX == picWidthTmp) ? lcuWidth : lcuWidth-numSkipLineRight;
    2622         startY   = (bPelY == picHeightTmp) ? lcuHeight : lcuHeight-numSkipLine;
    2623 
    2624         for (y=0; y<lcuHeight; y++)
    2625         {
    2626           for (x=0; x<lcuWidth; x++)
    2627           {
    2628             if( x < startX && y < startY )
    2629               continue;
    2630 
    2631             classIdx = pTableBo[pRec[x]];
    2632             if (classIdx)
    2633             {
    2634               stats[classIdx] += (pOrg[x] - pRec[x]);
    2635               count[classIdx] ++;
    2636             }
    2637           }
    2638           pOrg += stride;
    2639           pRec += stride;
    2640         }
    2641 
    2642         Int signLeft;
    2643         Int signRight;
    2644         Int signDown;
    2645         Int signDown1;
    2646         Int signDown2;
    2647 
    2648         UInt uiEdgeType;
    2649 
    2650         //if (iSaoType == EO_0)
    2651 
    2652         numSkipLine = isChroma? 1:3;
    2653         numSkipLineRight = isChroma? 3:5;
    2654 
    2655         stats = m_offsetOrg_PreDblk[addr][yCbCr][SAO_EO_0];
    2656         count = m_count_PreDblk[addr][yCbCr][SAO_EO_0];
    2657 
    2658         pOrg = getPicYuvAddr(pcPic->getPicYuvOrg(), yCbCr, addr);
    2659         pRec = getPicYuvAddr(pcPic->getPicYuvRec(), yCbCr, addr);
    2660 
    2661         startX   = (rPelX == picWidthTmp) ? lcuWidth-1 : lcuWidth-numSkipLineRight;
    2662         startY   = (bPelY == picHeightTmp) ? lcuHeight : lcuHeight-numSkipLine;
    2663         firstX   = (lPelX == 0) ? 1 : 0;
    2664         endX   = (rPelX == picWidthTmp) ? lcuWidth-1 : lcuWidth;
    2665 
    2666         for (y=0; y<lcuHeight; y++)
    2667         {
    2668           signLeft = xSign(pRec[firstX] - pRec[firstX-1]);
    2669           for (x=firstX; x< endX; x++)
    2670           {
    2671             signRight =  xSign(pRec[x] - pRec[x+1]);
    2672             uiEdgeType =  signRight + signLeft + 2;
    2673             signLeft  = -signRight;
    2674 
    2675             if( x < startX && y < startY )
    2676               continue;
    2677 
    2678             stats[m_auiEoTable[uiEdgeType]] += (pOrg[x] - pRec[x]);
    2679             count[m_auiEoTable[uiEdgeType]] ++;
    2680           }
    2681           pOrg += stride;
    2682           pRec += stride;
    2683         }
    2684 
    2685         //if (iSaoType == EO_1)
    2686 
    2687         numSkipLine = isChroma? 2:4;
    2688         numSkipLineRight = isChroma? 2:4;
    2689 
    2690         stats = m_offsetOrg_PreDblk[addr][yCbCr][SAO_EO_1];
    2691         count = m_count_PreDblk[addr][yCbCr][SAO_EO_1];
    2692 
    2693         pOrg = getPicYuvAddr(pcPic->getPicYuvOrg(), yCbCr, addr);
    2694         pRec = getPicYuvAddr(pcPic->getPicYuvRec(), yCbCr, addr);
    2695 
    2696         startX   = (rPelX == picWidthTmp) ? lcuWidth : lcuWidth-numSkipLineRight;
    2697         startY   = (bPelY == picHeightTmp) ? lcuHeight-1 : lcuHeight-numSkipLine;
    2698         firstY = (tPelY == 0) ? 1 : 0;
    2699         endY   = (bPelY == picHeightTmp) ? lcuHeight-1 : lcuHeight;
    2700         if (firstY == 1)
    2701         {
    2702           pOrg += stride;
    2703           pRec += stride;
    2704         }
    2705 
    2706         for (x=0; x< lcuWidth; x++)
    2707         {
    2708           m_iUpBuff1[x] = xSign(pRec[x] - pRec[x-stride]);
    2709         }
    2710         for (y=firstY; y<endY; y++)
    2711         {
    2712           for (x=0; x<lcuWidth; x++)
    2713           {
    2714             signDown     =  xSign(pRec[x] - pRec[x+stride]);
    2715             uiEdgeType    =  signDown + m_iUpBuff1[x] + 2;
    2716             m_iUpBuff1[x] = -signDown;
    2717 
    2718             if( x < startX && y < startY )
    2719               continue;
    2720 
    2721             stats[m_auiEoTable[uiEdgeType]] += (pOrg[x] - pRec[x]);
    2722             count[m_auiEoTable[uiEdgeType]] ++;
    2723           }
    2724           pOrg += stride;
    2725           pRec += stride;
    2726         }
    2727 
    2728         //if (iSaoType == EO_2)
    2729 
    2730         numSkipLine = isChroma? 2:4;
    2731         numSkipLineRight = isChroma? 3:5;
    2732 
    2733         stats = m_offsetOrg_PreDblk[addr][yCbCr][SAO_EO_2];
    2734         count = m_count_PreDblk[addr][yCbCr][SAO_EO_2];
    2735 
    2736         pOrg = getPicYuvAddr(pcPic->getPicYuvOrg(), yCbCr, addr);
    2737         pRec = getPicYuvAddr(pcPic->getPicYuvRec(), yCbCr, addr);
    2738 
    2739         startX   = (rPelX == picWidthTmp) ? lcuWidth-1 : lcuWidth-numSkipLineRight;
    2740         startY   = (bPelY == picHeightTmp) ? lcuHeight-1 : lcuHeight-numSkipLine;
    2741         firstX   = (lPelX == 0) ? 1 : 0;
    2742         firstY = (tPelY == 0) ? 1 : 0;
    2743         endX   = (rPelX == picWidthTmp) ? lcuWidth-1 : lcuWidth;
    2744         endY   = (bPelY == picHeightTmp) ? lcuHeight-1 : lcuHeight;
    2745         if (firstY == 1)
    2746         {
    2747           pOrg += stride;
    2748           pRec += stride;
    2749         }
    2750 
    2751         for (x=firstX; x<endX; x++)
    2752         {
    2753           m_iUpBuff1[x] = xSign(pRec[x] - pRec[x-stride-1]);
    2754         }
    2755         for (y=firstY; y<endY; y++)
    2756         {
    2757           signDown2 = xSign(pRec[stride+startX] - pRec[startX-1]);
    2758           for (x=firstX; x<endX; x++)
    2759           {
    2760             signDown1      =  xSign(pRec[x] - pRec[x+stride+1]) ;
    2761             uiEdgeType      =  signDown1 + m_iUpBuff1[x] + 2;
    2762             m_iUpBufft[x+1] = -signDown1;
    2763 
    2764             if( x < startX && y < startY )
    2765               continue;
    2766 
    2767             stats[m_auiEoTable[uiEdgeType]] += (pOrg[x] - pRec[x]);
    2768             count[m_auiEoTable[uiEdgeType]] ++;
    2769           }
    2770           m_iUpBufft[firstX] = signDown2;
    2771           ipSwap     = m_iUpBuff1;
    2772           m_iUpBuff1 = m_iUpBufft;
    2773           m_iUpBufft = ipSwap;
    2774 
    2775           pRec += stride;
    2776           pOrg += stride;
    2777         }
    2778 
    2779         //if (iSaoType == EO_3)
    2780 
    2781         numSkipLine = isChroma? 2:4;
    2782         numSkipLineRight = isChroma? 3:5;
    2783 
    2784         stats = m_offsetOrg_PreDblk[addr][yCbCr][SAO_EO_3];
    2785         count = m_count_PreDblk[addr][yCbCr][SAO_EO_3];
    2786 
    2787         pOrg = getPicYuvAddr(pcPic->getPicYuvOrg(), yCbCr, addr);
    2788         pRec = getPicYuvAddr(pcPic->getPicYuvRec(), yCbCr, addr);
    2789 
    2790         startX   = (rPelX == picWidthTmp) ? lcuWidth-1 : lcuWidth-numSkipLineRight;
    2791         startY   = (bPelY == picHeightTmp) ? lcuHeight-1 : lcuHeight-numSkipLine;
    2792         firstX   = (lPelX == 0) ? 1 : 0;
    2793         firstY = (tPelY == 0) ? 1 : 0;
    2794         endX   = (rPelX == picWidthTmp) ? lcuWidth-1 : lcuWidth;
    2795         endY   = (bPelY == picHeightTmp) ? lcuHeight-1 : lcuHeight;
    2796         if (firstY == 1)
    2797         {
    2798           pOrg += stride;
    2799           pRec += stride;
    2800         }
    2801 
    2802         for (x=firstX-1; x<endX; x++)
    2803         {
    2804           m_iUpBuff1[x] = xSign(pRec[x] - pRec[x-stride+1]);
    2805         }
    2806 
    2807         for (y=firstY; y<endY; y++)
    2808         {
    2809           for (x=firstX; x<endX; x++)
    2810           {
    2811             signDown1      =  xSign(pRec[x] - pRec[x+stride-1]) ;
    2812             uiEdgeType      =  signDown1 + m_iUpBuff1[x] + 2;
    2813             m_iUpBuff1[x-1] = -signDown1;
    2814 
    2815             if( x < startX && y < startY )
    2816               continue;
    2817 
    2818             stats[m_auiEoTable[uiEdgeType]] += (pOrg[x] - pRec[x]);
    2819             count[m_auiEoTable[uiEdgeType]] ++;
    2820           }
    2821           m_iUpBuff1[endX-1] = xSign(pRec[endX-1 + stride] - pRec[endX]);
    2822 
    2823           pRec += stride;
    2824           pOrg += stride;
    2825         }
    2826       }
    2827     }
    2828   }
    2829 }
    2830 
    2831 
    2832 /** get SAO statistics
    2833  * \param  *psQTPart,  iYCbCr
    2834  */
    2835 Void TEncSampleAdaptiveOffset::getSaoStats(SAOQTPart *psQTPart, Int iYCbCr)
    2836 {
    2837   Int iLevelIdx, iPartIdx, iTypeIdx, iClassIdx;
    2838   Int i;
    2839   Int iNumTotalType = MAX_NUM_SAO_TYPE;
    2840   Int LcuIdxX;
    2841   Int LcuIdxY;
    2842   Int iAddr;
    2843   Int iFrameWidthInCU = m_pcPic->getFrameWidthInCU();
    2844   Int iDownPartIdx;
    2845   Int iPartStart;
    2846   Int iPartEnd;
    2847   SAOQTPart*  pOnePart;
    2848 
    2849   if (m_uiMaxSplitLevel == 0)
    2850   {
    2851     iPartIdx = 0;
    2852     pOnePart = &(psQTPart[iPartIdx]);
    2853     for (LcuIdxY = pOnePart->StartCUY; LcuIdxY<= pOnePart->EndCUY; LcuIdxY++)
    2854     {
    2855       for (LcuIdxX = pOnePart->StartCUX; LcuIdxX<= pOnePart->EndCUX; LcuIdxX++)
    2856       {
    2857         iAddr = LcuIdxY*iFrameWidthInCU + LcuIdxX;
    2858         calcSaoStatsCu(iAddr, iPartIdx, iYCbCr);
    2859       }
    2860     }
    2861   }
    2862   else
    2863   {
    2864     for(iPartIdx=m_aiNumCulPartsLevel[m_uiMaxSplitLevel-1]; iPartIdx<m_aiNumCulPartsLevel[m_uiMaxSplitLevel]; iPartIdx++)
    2865     {
    2866       pOnePart = &(psQTPart[iPartIdx]);
    2867       for (LcuIdxY = pOnePart->StartCUY; LcuIdxY<= pOnePart->EndCUY; LcuIdxY++)
    2868       {
    2869         for (LcuIdxX = pOnePart->StartCUX; LcuIdxX<= pOnePart->EndCUX; LcuIdxX++)
    2870         {
    2871           iAddr = LcuIdxY*iFrameWidthInCU + LcuIdxX;
    2872           calcSaoStatsCu(iAddr, iPartIdx, iYCbCr);
    2873         }
    2874       }
    2875     }
    2876     for (iLevelIdx = m_uiMaxSplitLevel-1; iLevelIdx>=0; iLevelIdx-- )
    2877     {
    2878       iPartStart = (iLevelIdx > 0) ? m_aiNumCulPartsLevel[iLevelIdx-1] : 0;
    2879       iPartEnd   = m_aiNumCulPartsLevel[iLevelIdx];
    2880 
    2881       for(iPartIdx = iPartStart; iPartIdx < iPartEnd; iPartIdx++)
    2882       {
    2883         pOnePart = &(psQTPart[iPartIdx]);
    2884         for (i=0; i< NUM_DOWN_PART; i++)
    2885         {
    2886           iDownPartIdx = pOnePart->DownPartsIdx[i];
    2887           for (iTypeIdx=0; iTypeIdx<iNumTotalType; iTypeIdx++)
    2888           {
    2889             for (iClassIdx=0; iClassIdx< (iTypeIdx < SAO_BO ? m_iNumClass[iTypeIdx] : SAO_MAX_BO_CLASSES) +1; iClassIdx++)
    2890             {
    2891               m_iOffsetOrg[iPartIdx][iTypeIdx][iClassIdx] += m_iOffsetOrg[iDownPartIdx][iTypeIdx][iClassIdx];
    2892               m_iCount [iPartIdx][iTypeIdx][iClassIdx]    += m_iCount [iDownPartIdx][iTypeIdx][iClassIdx];
    2893             }
    2894           }
    2895         }
    2896       }
    2897     }
    2898   }
    2899 }
    2900 
    2901 /** reset offset statistics
    2902  * \param
    2903  */
    2904 Void TEncSampleAdaptiveOffset::resetStats()
    2905 {
    2906   for (Int i=0;i<m_iNumTotalParts;i++)
    2907   {
    2908     m_dCostPartBest[i] = MAX_DOUBLE;
    2909     m_iTypePartBest[i] = -1;
    2910     m_iDistOrg[i] = 0;
    2911     for (Int j=0;j<MAX_NUM_SAO_TYPE;j++)
    2912     {
    2913       m_iDist[i][j] = 0;
    2914       m_iRate[i][j] = 0;
    2915       m_dCost[i][j] = 0;
    2916       for (Int k=0;k<MAX_NUM_SAO_CLASS;k++)
    2917       {
    2918         m_iCount [i][j][k] = 0;
    2919         m_iOffset[i][j][k] = 0;
    2920         m_iOffsetOrg[i][j][k] = 0;
    2921       } 
    2922     }
    2923   }
    2924 }
    2925 
    2926 /** Sample adaptive offset process
    2927  * \param pcSaoParam
    2928  * \param dLambdaLuma
    2929  * \param dLambdaChroma
    2930  */
    2931 #if SAO_ENCODING_CHOICE
    2932 Void TEncSampleAdaptiveOffset::SAOProcess(SAOParam *pcSaoParam, Double dLambdaLuma, Double dLambdaChroma, Int depth)
    2933 #else
    2934 Void TEncSampleAdaptiveOffset::SAOProcess(SAOParam *pcSaoParam, Double dLambdaLuma, Double dLambdaChroma)
    2935 #endif
    2936 {
    2937   if(m_bUseNIF)
    2938   {
    2939     m_pcPic->getPicYuvRec()->copyToPic(m_pcYuvTmp);
    2940   }
    2941 
    2942   m_uiSaoBitIncreaseY = max(g_bitDepthY - 10, 0);
    2943   m_uiSaoBitIncreaseC = max(g_bitDepthC - 10, 0);
    2944   m_iOffsetThY = 1 << min(g_bitDepthY - 5, 5);
    2945   m_iOffsetThC = 1 << min(g_bitDepthC - 5, 5);
    2946   resetSAOParam(pcSaoParam);
    2947   if( !m_saoLcuBasedOptimization || !m_saoLcuBoundary )
    2948   {
    2949     resetStats();
    2950   }
    2951   Double dCostFinal = 0;
    2952   if ( m_saoLcuBasedOptimization)
    2953   {
    2954 #if SAO_ENCODING_CHOICE
    2955     rdoSaoUnitAll(pcSaoParam, dLambdaLuma, dLambdaChroma, depth);
    2956 #else
    2957     rdoSaoUnitAll(pcSaoParam, dLambdaLuma, dLambdaChroma);
    2958 #endif
    2959   }
    2960   else
    2961   {
    2962     pcSaoParam->bSaoFlag[0] = 1;
    2963     pcSaoParam->bSaoFlag[1] = 0;
    2964     dCostFinal = 0;
    2965     Double lambdaRdo =  dLambdaLuma;
    2966     resetStats();
    2967     getSaoStats(pcSaoParam->psSaoPart[0], 0);
    2968     runQuadTreeDecision(pcSaoParam->psSaoPart[0], 0, dCostFinal, m_uiMaxSplitLevel, lambdaRdo, 0);
    2969     pcSaoParam->bSaoFlag[0] = dCostFinal < 0 ? 1:0;
    2970     if(pcSaoParam->bSaoFlag[0])
    2971     {
    2972       convertQT2SaoUnit(pcSaoParam, 0, 0);
    2973       assignSaoUnitSyntax(pcSaoParam->saoLcuParam[0],  pcSaoParam->psSaoPart[0], pcSaoParam->oneUnitFlag[0], 0);
    2974     }
    2975   }
    2976   if (pcSaoParam->bSaoFlag[0])
    2977   {
    2978     processSaoUnitAll( pcSaoParam->saoLcuParam[0], pcSaoParam->oneUnitFlag[0], 0);
    2979   }
    2980   if (pcSaoParam->bSaoFlag[1])
    2981   {
    2982     processSaoUnitAll( pcSaoParam->saoLcuParam[1], pcSaoParam->oneUnitFlag[1], 1);
    2983     processSaoUnitAll( pcSaoParam->saoLcuParam[2], pcSaoParam->oneUnitFlag[2], 2);
    2984   }
    2985 }
    2986 /** Check merge SAO unit
    2987  * \param saoUnitCurr current SAO unit
    2988  * \param saoUnitCheck SAO unit tobe check
    2989  * \param dir direction
    2990  */
    2991 Void TEncSampleAdaptiveOffset::checkMerge(SaoLcuParam * saoUnitCurr, SaoLcuParam * saoUnitCheck, Int dir)
    2992 {
    2993   Int i ;
    2994   Int countDiff = 0;
    2995   if (saoUnitCurr->partIdx != saoUnitCheck->partIdx)
    2996   {
    2997     if (saoUnitCurr->typeIdx !=-1)
    2998     {
    2999       if (saoUnitCurr->typeIdx == saoUnitCheck->typeIdx)
    3000       {
    3001         for (i=0;i<saoUnitCurr->length;i++)
    3002         {
    3003           countDiff += (saoUnitCurr->offset[i] != saoUnitCheck->offset[i]);
    3004         }
    3005         countDiff += (saoUnitCurr->subTypeIdx != saoUnitCheck->subTypeIdx);
    3006         if (countDiff ==0)
    3007         {
    3008           saoUnitCurr->partIdx = saoUnitCheck->partIdx;
    3009           if (dir == 1)
    3010           {
    3011             saoUnitCurr->mergeUpFlag = 1;
    3012             saoUnitCurr->mergeLeftFlag = 0;
    3013           }
    3014           else
    3015           {
    3016             saoUnitCurr->mergeUpFlag = 0;
    3017             saoUnitCurr->mergeLeftFlag = 1;
    3018           }
    3019         }
    3020       }
    3021     }
    3022     else
    3023     {
    3024       if (saoUnitCurr->typeIdx == saoUnitCheck->typeIdx)
    3025       {
    3026         saoUnitCurr->partIdx = saoUnitCheck->partIdx;
    3027         if (dir == 1)
    3028         {
    3029           saoUnitCurr->mergeUpFlag = 1;
    3030           saoUnitCurr->mergeLeftFlag = 0;
    3031         }
    3032         else
    3033         {
    3034           saoUnitCurr->mergeUpFlag = 0;
    3035           saoUnitCurr->mergeLeftFlag = 1;
    3036         }
    3037       }
    3038     }
    3039   }
    3040 }
    3041 /** Assign SAO unit syntax from picture-based algorithm
    3042  * \param saoLcuParam SAO LCU parameters
    3043  * \param saoPart SAO part
    3044  * \param oneUnitFlag SAO one unit flag
    3045  * \param iYCbCr color component Index
    3046  */
    3047 Void TEncSampleAdaptiveOffset::assignSaoUnitSyntax(SaoLcuParam* saoLcuParam,  SAOQTPart* saoPart, Bool &oneUnitFlag, Int yCbCr)
    3048 {
    3049   if (saoPart->bSplit == 0)
    3050   {
    3051     oneUnitFlag = 1;
    3052   }
    3053   else
    3054   {
    3055     Int i,j, addr, addrUp, addrLeft,  idx, idxUp, idxLeft,  idxCount;
    3056 
    3057     oneUnitFlag = 0;
    3058 
    3059     idxCount = -1;
    3060     saoLcuParam[0].mergeUpFlag = 0;
    3061     saoLcuParam[0].mergeLeftFlag = 0;
    3062 
    3063     for (j=0;j<m_iNumCuInHeight;j++)
    3064     {
    3065       for (i=0;i<m_iNumCuInWidth;i++)
    3066       {
    3067         addr     = i + j*m_iNumCuInWidth;
    3068         addrLeft = (addr%m_iNumCuInWidth == 0) ? -1 : addr - 1;
    3069         addrUp   = (addr<m_iNumCuInWidth)      ? -1 : addr - m_iNumCuInWidth;
    3070         idx      = saoLcuParam[addr].partIdxTmp;
    3071         idxLeft  = (addrLeft == -1) ? -1 : saoLcuParam[addrLeft].partIdxTmp;
    3072         idxUp    = (addrUp == -1)   ? -1 : saoLcuParam[addrUp].partIdxTmp;
    3073 
    3074         if(idx!=idxLeft && idx!=idxUp)
    3075         {
    3076           saoLcuParam[addr].mergeUpFlag   = 0; idxCount++;
    3077           saoLcuParam[addr].mergeLeftFlag = 0;
    3078           saoLcuParam[addr].partIdx = idxCount;
    3079         }
    3080         else if (idx==idxLeft)
    3081         {
    3082           saoLcuParam[addr].mergeUpFlag   = 1;
    3083           saoLcuParam[addr].mergeLeftFlag = 1;
    3084           saoLcuParam[addr].partIdx = saoLcuParam[addrLeft].partIdx;
    3085         }
    3086         else if (idx==idxUp)
    3087         {
    3088           saoLcuParam[addr].mergeUpFlag   = 1;
    3089           saoLcuParam[addr].mergeLeftFlag = 0;
    3090           saoLcuParam[addr].partIdx = saoLcuParam[addrUp].partIdx;
    3091         }
    3092         if (addrUp != -1)
    3093         {
    3094           checkMerge(&saoLcuParam[addr], &saoLcuParam[addrUp], 1);
    3095         }
    3096         if (addrLeft != -1)
    3097         {
    3098           checkMerge(&saoLcuParam[addr], &saoLcuParam[addrLeft], 0);
    3099         }
    3100       }
    3101     }
    3102   }
    3103 }
    3104 /** rate distortion optimization of all SAO units
    3105  * \param saoParam SAO parameters
    3106  * \param lambda
    3107  * \param lambdaChroma
    3108  */
    3109 #if SAO_ENCODING_CHOICE
    3110 Void TEncSampleAdaptiveOffset::rdoSaoUnitAll(SAOParam *saoParam, Double lambda, Double lambdaChroma, Int depth)
    3111 #else
    3112 Void TEncSampleAdaptiveOffset::rdoSaoUnitAll(SAOParam *saoParam, Double lambda, Double lambdaChroma)
    3113 #endif
    3114 {
    3115 
    3116   Int idxY;
    3117   Int idxX;
    3118   Int frameHeightInCU = saoParam->numCuInHeight;
    3119   Int frameWidthInCU  = saoParam->numCuInWidth;
    3120   Int j, k;
    3121   Int addr = 0;
    3122   Int addrUp = -1;
    3123   Int addrLeft = -1;
    3124   Int compIdx = 0;
    3125   SaoLcuParam mergeSaoParam[3][2];
    3126   Double compDistortion[3];
    3127 
    3128   saoParam->bSaoFlag[0] = true;
    3129 #if AUXILIARY_PICTURES
    3130   saoParam->bSaoFlag[1] = m_pcPic->getChromaFormat() == CHROMA_400 ? false : true;
    3131 #else
    3132   saoParam->bSaoFlag[1] = true;
    3133 #endif
    3134   saoParam->oneUnitFlag[0] = false;
    3135   saoParam->oneUnitFlag[1] = false;
    3136   saoParam->oneUnitFlag[2] = false;
    3137 
    3138 #if SAO_ENCODING_CHOICE
    3139 #if SAO_ENCODING_CHOICE_CHROMA
    3140   Int numNoSao[2];
    3141   numNoSao[0] = 0;// Luma
    3142   numNoSao[1] = 0;// Chroma
    3143   if( depth > 0 && m_depthSaoRate[0][depth-1] > SAO_ENCODING_RATE )
    3144   {
    3145     saoParam->bSaoFlag[0] = false;
    3146   }
    3147   if( depth > 0 && m_depthSaoRate[1][depth-1] > SAO_ENCODING_RATE_CHROMA )
    3148   {
    3149     saoParam->bSaoFlag[1] = false;
    3150   }
    3151 #else
    3152   Int numNoSao = 0;
    3153 
    3154   if( depth > 0 && m_depth0SaoRate > SAO_ENCODING_RATE )
    3155   {
    3156     saoParam->bSaoFlag[0] = false;
    3157     saoParam->bSaoFlag[1] = false;
    3158   }
    3159 #endif
    3160 #endif
    3161 
    3162   for (idxY = 0; idxY< frameHeightInCU; idxY++)
    3163   {
    3164     for (idxX = 0; idxX< frameWidthInCU; idxX++)
    3165     {
    3166       addr     = idxX  + frameWidthInCU*idxY;
    3167       addrUp   = addr < frameWidthInCU ? -1:idxX   + frameWidthInCU*(idxY-1);
    3168       addrLeft = idxX == 0               ? -1:idxX-1 + frameWidthInCU*idxY;
    3169       Int allowMergeLeft = 1;
    3170       Int allowMergeUp   = 1;
    3171       UInt rate;
    3172       Double bestCost, mergeCost;
    3173       if (idxX!=0)
    3174       {
    3175         // check tile id and slice id
    3176         if ( (m_pcPic->getPicSym()->getTileIdxMap(addr-1) != m_pcPic->getPicSym()->getTileIdxMap(addr)) || (m_pcPic->getCU(addr-1)->getSlice()->getSliceIdx() != m_pcPic->getCU(addr)->getSlice()->getSliceIdx()))
    3177         {
    3178           allowMergeLeft = 0;
    3179         }
    3180       }
    3181       else
    3182       {
    3183         allowMergeLeft = 0;
    3184       }
    3185       if (idxY!=0)
    3186       {
    3187         if ( (m_pcPic->getPicSym()->getTileIdxMap(addr-m_iNumCuInWidth) != m_pcPic->getPicSym()->getTileIdxMap(addr)) || (m_pcPic->getCU(addr-m_iNumCuInWidth)->getSlice()->getSliceIdx() != m_pcPic->getCU(addr)->getSlice()->getSliceIdx()))
    3188         {
    3189           allowMergeUp = 0;
    3190         }
    3191       }
    3192       else
    3193       {
    3194         allowMergeUp = 0;
    3195       }
    3196 
    3197       compDistortion[0] = 0;
    3198       compDistortion[1] = 0;
    3199       compDistortion[2] = 0;
    3200       m_pcRDGoOnSbacCoder->load(m_pppcRDSbacCoder[0][CI_CURR_BEST]);
    3201       if (allowMergeLeft)
    3202       {
    3203         m_pcEntropyCoder->m_pcEntropyCoderIf->codeSaoMerge(0);
    3204       }
    3205       if (allowMergeUp)
    3206       {
    3207         m_pcEntropyCoder->m_pcEntropyCoderIf->codeSaoMerge(0);
    3208       }
    3209       m_pcRDGoOnSbacCoder->store( m_pppcRDSbacCoder[0][CI_TEMP_BEST] );
    3210       // reset stats Y, Cb, Cr
    3211       for ( compIdx=0;compIdx<3;compIdx++)
    3212       {
    3213         for ( j=0;j<MAX_NUM_SAO_TYPE;j++)
    3214         {
    3215           for ( k=0;k< MAX_NUM_SAO_CLASS;k++)
    3216           {
    3217             m_iOffset   [compIdx][j][k] = 0;
    3218             if( m_saoLcuBasedOptimization && m_saoLcuBoundary ){
    3219               m_iCount    [compIdx][j][k] = m_count_PreDblk    [addr][compIdx][j][k];
    3220               m_iOffsetOrg[compIdx][j][k] = m_offsetOrg_PreDblk[addr][compIdx][j][k];
    3221             }
    3222             else
    3223             {
    3224               m_iCount    [compIdx][j][k] = 0;
    3225               m_iOffsetOrg[compIdx][j][k] = 0;
    3226             }
    3227           } 
    3228         }
    3229         saoParam->saoLcuParam[compIdx][addr].typeIdx       =  -1;
    3230         saoParam->saoLcuParam[compIdx][addr].mergeUpFlag   = 0;
    3231         saoParam->saoLcuParam[compIdx][addr].mergeLeftFlag = 0;
    3232         saoParam->saoLcuParam[compIdx][addr].subTypeIdx    = 0;
    3233 #if SAO_ENCODING_CHOICE
    3234   if( (compIdx ==0 && saoParam->bSaoFlag[0])|| (compIdx >0 && saoParam->bSaoFlag[1]) )
    3235 #endif
    3236         {
    3237           calcSaoStatsCu(addr, compIdx,  compIdx);
    3238 
    3239        }
    3240       }
    3241       saoComponentParamDist(allowMergeLeft, allowMergeUp, saoParam, addr, addrUp, addrLeft, 0,  lambda, &mergeSaoParam[0][0], &compDistortion[0]);
    3242       sao2ChromaParamDist(allowMergeLeft, allowMergeUp, saoParam, addr, addrUp, addrLeft, lambdaChroma, &mergeSaoParam[1][0], &mergeSaoParam[2][0], &compDistortion[0]);
    3243      if( saoParam->bSaoFlag[0] || saoParam->bSaoFlag[1] )
    3244       {
    3245         // Cost of new SAO_params
    3246         m_pcRDGoOnSbacCoder->load(m_pppcRDSbacCoder[0][CI_CURR_BEST]);
    3247         m_pcRDGoOnSbacCoder->resetBits();
    3248         if (allowMergeLeft)
    3249         {
    3250           m_pcEntropyCoder->m_pcEntropyCoderIf->codeSaoMerge(0);
    3251         }
    3252         if (allowMergeUp)
    3253         {
    3254           m_pcEntropyCoder->m_pcEntropyCoderIf->codeSaoMerge(0);
    3255         }
    3256         for ( compIdx=0;compIdx<3;compIdx++)
    3257         {
    3258         if( (compIdx ==0 && saoParam->bSaoFlag[0]) || (compIdx >0 && saoParam->bSaoFlag[1]))
    3259           {
    3260            m_pcEntropyCoder->encodeSaoOffset(&saoParam->saoLcuParam[compIdx][addr], compIdx);
    3261           }
    3262         }
    3263 
    3264         rate = m_pcEntropyCoder->getNumberOfWrittenBits();
    3265         bestCost = compDistortion[0] + (Double)rate;
    3266         m_pcRDGoOnSbacCoder->store(m_pppcRDSbacCoder[0][CI_TEMP_BEST]);
    3267 
    3268         // Cost of Merge
    3269         for(Int mergeUp=0; mergeUp<2; ++mergeUp)
    3270         {
    3271           if ( (allowMergeLeft && (mergeUp==0)) || (allowMergeUp && (mergeUp==1)) )
    3272           {
    3273             m_pcRDGoOnSbacCoder->load(m_pppcRDSbacCoder[0][CI_CURR_BEST]);
    3274             m_pcRDGoOnSbacCoder->resetBits();
    3275             if (allowMergeLeft)
    3276             {
    3277               m_pcEntropyCoder->m_pcEntropyCoderIf->codeSaoMerge(1-mergeUp);
    3278             }
    3279             if ( allowMergeUp && (mergeUp==1) )
    3280             {
    3281               m_pcEntropyCoder->m_pcEntropyCoderIf->codeSaoMerge(1);
    3282             }
    3283 
    3284             rate = m_pcEntropyCoder->getNumberOfWrittenBits();
    3285             mergeCost = compDistortion[mergeUp+1] + (Double)rate;
    3286             if (mergeCost < bestCost)
    3287             {
    3288               bestCost = mergeCost;
    3289               m_pcRDGoOnSbacCoder->store(m_pppcRDSbacCoder[0][CI_TEMP_BEST]);             
    3290               for ( compIdx=0;compIdx<3;compIdx++)
    3291               {
    3292                 mergeSaoParam[compIdx][mergeUp].mergeLeftFlag = 1-mergeUp;
    3293                 mergeSaoParam[compIdx][mergeUp].mergeUpFlag = mergeUp;
    3294                 if( (compIdx==0 && saoParam->bSaoFlag[0]) || (compIdx>0 && saoParam->bSaoFlag[1]))
    3295                 {
    3296                   copySaoUnit(&saoParam->saoLcuParam[compIdx][addr], &mergeSaoParam[compIdx][mergeUp] );             
    3297                 }
    3298               }
    3299             }
    3300           }
    3301         }
    3302 #if SAO_ENCODING_CHOICE
    3303 #if SAO_ENCODING_CHOICE_CHROMA
    3304 if( saoParam->saoLcuParam[0][addr].typeIdx == -1)
    3305 {
    3306   numNoSao[0]++;
    3307 }
    3308 if( saoParam->saoLcuParam[1][addr].typeIdx == -1)
    3309 {
    3310   numNoSao[1]+=2;
    3311 }
    3312 #else
    3313         for ( compIdx=0;compIdx<3;compIdx++)
    3314         {
    3315           if( depth == 0 && saoParam->saoLcuParam[compIdx][addr].typeIdx == -1)
    3316           {
    3317             numNoSao++;
    3318           }
    3319         }
    3320 #endif
    3321 #endif
    3322         m_pcRDGoOnSbacCoder->load(m_pppcRDSbacCoder[0][CI_TEMP_BEST]);
    3323         m_pcRDGoOnSbacCoder->store(m_pppcRDSbacCoder[0][CI_CURR_BEST]);
    3324       }
    3325     }
    3326   }
    3327 #if SAO_ENCODING_CHOICE
    3328 #if SAO_ENCODING_CHOICE_CHROMA
    3329   if( !saoParam->bSaoFlag[0])
    3330   {
    3331     m_depthSaoRate[0][depth] = 1.0;
    3332   }
    3333   else
    3334   {
    3335     m_depthSaoRate[0][depth] = numNoSao[0]/((Double) frameHeightInCU*frameWidthInCU);
    3336   }
    3337   if( !saoParam->bSaoFlag[1])
    3338   {
    3339     m_depthSaoRate[1][depth] = 1.0;
    3340   }
    3341   else
    3342   {
    3343     m_depthSaoRate[1][depth] = numNoSao[1]/((Double) frameHeightInCU*frameWidthInCU*2);
    3344   }
    3345 #else
    3346   if( depth == 0)
    3347   {
    3348     // update SAO Rate
    3349     m_depth0SaoRate = numNoSao/((Double) frameHeightInCU*frameWidthInCU*3);
    3350   }
    3351 #endif
    3352 #endif
    3353 
    3354 }
    3355 /** rate distortion optimization of SAO unit
    3356  * \param saoParam SAO parameters
    3357  * \param addr address
    3358  * \param addrUp above address
    3359  * \param addrLeft left address
    3360  * \param yCbCr color component index
    3361  * \param lambda
    3362  */
    3363 inline Int64 TEncSampleAdaptiveOffset::estSaoTypeDist(Int compIdx, Int typeIdx, Int shift, Double lambda, Int *currentDistortionTableBo, Double *currentRdCostTableBo)
    3364 {
    3365   Int64 estDist = 0;
    3366   Int classIdx;
    3367   Int bitDepth = (compIdx==0) ? g_bitDepthY : g_bitDepthC;
    3368   Int saoBitIncrease = (compIdx==0) ? m_uiSaoBitIncreaseY : m_uiSaoBitIncreaseC;
    3369   Int saoOffsetTh = (compIdx==0) ? m_iOffsetThY : m_iOffsetThC;
    3370 
    3371   for(classIdx=1; classIdx < ( (typeIdx < SAO_BO) ?  m_iNumClass[typeIdx]+1 : SAO_MAX_BO_CLASSES+1); classIdx++)
    3372   {
    3373     if( typeIdx == SAO_BO)
    3374     {
    3375       currentDistortionTableBo[classIdx-1] = 0;
    3376       currentRdCostTableBo[classIdx-1] = lambda;
    3377     }
    3378     if(m_iCount [compIdx][typeIdx][classIdx])
    3379     {
    3380       m_iOffset[compIdx][typeIdx][classIdx] = (Int64) xRoundIbdi(bitDepth, (Double)(m_iOffsetOrg[compIdx][typeIdx][classIdx]<<(bitDepth-8)) / (Double)(m_iCount [compIdx][typeIdx][classIdx]<<saoBitIncrease));
    3381       m_iOffset[compIdx][typeIdx][classIdx] = Clip3(-saoOffsetTh+1, saoOffsetTh-1, (Int)m_iOffset[compIdx][typeIdx][classIdx]);
    3382       if (typeIdx < 4)
    3383       {
    3384         if ( m_iOffset[compIdx][typeIdx][classIdx]<0 && classIdx<3 )
    3385         {
    3386           m_iOffset[compIdx][typeIdx][classIdx] = 0;
    3387         }
    3388         if ( m_iOffset[compIdx][typeIdx][classIdx]>0 && classIdx>=3)
    3389         {
    3390           m_iOffset[compIdx][typeIdx][classIdx] = 0;
    3391         }
    3392       }
    3393       m_iOffset[compIdx][typeIdx][classIdx] = estIterOffset( typeIdx, classIdx, lambda, m_iOffset[compIdx][typeIdx][classIdx], m_iCount [compIdx][typeIdx][classIdx], m_iOffsetOrg[compIdx][typeIdx][classIdx], shift, saoBitIncrease, currentDistortionTableBo, currentRdCostTableBo, saoOffsetTh );
    3394     }
    3395     else
    3396     {
    3397       m_iOffsetOrg[compIdx][typeIdx][classIdx] = 0;
    3398       m_iOffset[compIdx][typeIdx][classIdx] = 0;
    3399     }
    3400     if( typeIdx != SAO_BO )
    3401     {
    3402       estDist   += estSaoDist( m_iCount [compIdx][typeIdx][classIdx], m_iOffset[compIdx][typeIdx][classIdx] << saoBitIncrease, m_iOffsetOrg[compIdx][typeIdx][classIdx], shift);
    3403     }
    3404 
    3405   }
    3406   return estDist;
    3407 }
    3408 
    3409 inline Int64 TEncSampleAdaptiveOffset::estSaoDist(Int64 count, Int64 offset, Int64 offsetOrg, Int shift)
    3410 {
    3411   return (( count*offset*offset-offsetOrg*offset*2 ) >> shift);
    3412 }
    3413 inline Int64 TEncSampleAdaptiveOffset::estIterOffset(Int typeIdx, Int classIdx, Double lambda, Int64 offsetInput, Int64 count, Int64 offsetOrg, Int shift, Int bitIncrease, Int *currentDistortionTableBo, Double *currentRdCostTableBo, Int offsetTh )
    3414 {
    3415   //Clean up, best_q_offset.
    3416   Int64 iterOffset, tempOffset;
    3417   Int64 tempDist, tempRate;
    3418   Double tempCost, tempMinCost;
    3419   Int64 offsetOutput = 0;
    3420   iterOffset = offsetInput;
    3421   // Assuming sending quantized value 0 results in zero offset and sending the value zero needs 1 bit. entropy coder can be used to measure the exact rate here.
    3422   tempMinCost = lambda;
    3423   while (iterOffset != 0)
    3424   {
    3425     // Calculate the bits required for signalling the offset
    3426     tempRate = (typeIdx == SAO_BO) ? (abs((Int)iterOffset)+2) : (abs((Int)iterOffset)+1);
    3427     if (abs((Int)iterOffset)==offsetTh-1)
    3428     { 
    3429       tempRate --;
    3430     }
    3431     // Do the dequntization before distorion calculation
    3432     tempOffset  = iterOffset << bitIncrease;
    3433     tempDist    = estSaoDist( count, tempOffset, offsetOrg, shift);
    3434     tempCost    = ((Double)tempDist + lambda * (Double) tempRate);
    3435     if(tempCost < tempMinCost)
    3436     {
    3437       tempMinCost = tempCost;
    3438       offsetOutput = iterOffset;
    3439       if(typeIdx == SAO_BO)
    3440       {
    3441         currentDistortionTableBo[classIdx-1] = (Int) tempDist;
    3442         currentRdCostTableBo[classIdx-1] = tempCost;
    3443       }
    3444     }
    3445     iterOffset = (iterOffset > 0) ? (iterOffset-1):(iterOffset+1);
    3446   }
    3447   return offsetOutput;
    3448 }
    3449 
    3450 
    3451 Void TEncSampleAdaptiveOffset::saoComponentParamDist(Int allowMergeLeft, Int allowMergeUp, SAOParam *saoParam, Int addr, Int addrUp, Int addrLeft, Int yCbCr, Double lambda, SaoLcuParam *compSaoParam, Double *compDistortion)
    3452 {
    3453   Int typeIdx;
    3454 
    3455   Int64 estDist;
    3456   Int classIdx;
    3457   Int shift = 2 * DISTORTION_PRECISION_ADJUSTMENT(((yCbCr==0)?g_bitDepthY:g_bitDepthC)-8);
    3458   Int64 bestDist;
    3459 
    3460   SaoLcuParam*  saoLcuParam = &(saoParam->saoLcuParam[yCbCr][addr]);
    3461   SaoLcuParam*  saoLcuParamNeighbor = NULL;
    3462 
    3463   resetSaoUnit(saoLcuParam);
    3464   resetSaoUnit(&compSaoParam[0]);
    3465   resetSaoUnit(&compSaoParam[1]);
    3466 
    3467 
    3468   Double dCostPartBest = MAX_DOUBLE;
    3469 
    3470   Double  bestRDCostTableBo = MAX_DOUBLE;
    3471   Int     bestClassTableBo    = 0;
    3472   Int     currentDistortionTableBo[MAX_NUM_SAO_CLASS];
    3473   Double  currentRdCostTableBo[MAX_NUM_SAO_CLASS];
    3474 
    3475 
    3476   SaoLcuParam   saoLcuParamRdo;   
    3477   Double   estRate = 0;
    3478 
    3479   resetSaoUnit(&saoLcuParamRdo);
    3480 
    3481   m_pcRDGoOnSbacCoder->load(m_pppcRDSbacCoder[0][CI_TEMP_BEST]);
    3482   m_pcRDGoOnSbacCoder->resetBits();
    3483  m_pcEntropyCoder->encodeSaoOffset(&saoLcuParamRdo, yCbCr);
    3484  
    3485   dCostPartBest = m_pcEntropyCoder->getNumberOfWrittenBits()*lambda ;
    3486   copySaoUnit(saoLcuParam, &saoLcuParamRdo );
    3487   bestDist = 0;
    3488  
    3489 
    3490 
    3491   for (typeIdx=0; typeIdx<MAX_NUM_SAO_TYPE; typeIdx++)
    3492   {
    3493     estDist = estSaoTypeDist(yCbCr, typeIdx, shift, lambda, currentDistortionTableBo, currentRdCostTableBo);
    3494 
    3495     if( typeIdx == SAO_BO )
    3496     {
    3497       // Estimate Best Position
    3498       Double currentRDCost = 0.0;
    3499 
    3500       for(Int i=0; i< SAO_MAX_BO_CLASSES -SAO_BO_LEN +1; i++)
    3501       {
    3502         currentRDCost = 0.0;
    3503         for(UInt uj = i; uj < i+SAO_BO_LEN; uj++)
    3504         {
    3505           currentRDCost += currentRdCostTableBo[uj];
    3506         }
    3507 
    3508         if( currentRDCost < bestRDCostTableBo)
    3509         {
    3510           bestRDCostTableBo = currentRDCost;
    3511           bestClassTableBo  = i;
    3512         }
    3513       }
    3514 
    3515       // Re code all Offsets
    3516       // Code Center
    3517       estDist = 0;
    3518       for(classIdx = bestClassTableBo; classIdx < bestClassTableBo+SAO_BO_LEN; classIdx++)
    3519       {
    3520         estDist += currentDistortionTableBo[classIdx];
    3521       }
    3522     }
    3523     resetSaoUnit(&saoLcuParamRdo);
    3524     saoLcuParamRdo.length = m_iNumClass[typeIdx];
    3525     saoLcuParamRdo.typeIdx = typeIdx;
    3526     saoLcuParamRdo.mergeLeftFlag = 0;
    3527     saoLcuParamRdo.mergeUpFlag   = 0;
    3528     saoLcuParamRdo.subTypeIdx = (typeIdx == SAO_BO) ? bestClassTableBo : 0;
    3529     for (classIdx = 0; classIdx < saoLcuParamRdo.length; classIdx++)
    3530     {
    3531       saoLcuParamRdo.offset[classIdx] = (Int)m_iOffset[yCbCr][typeIdx][classIdx+saoLcuParamRdo.subTypeIdx+1];
    3532     }
    3533     m_pcRDGoOnSbacCoder->load(m_pppcRDSbacCoder[0][CI_TEMP_BEST]);
    3534     m_pcRDGoOnSbacCoder->resetBits();
    3535     m_pcEntropyCoder->encodeSaoOffset(&saoLcuParamRdo, yCbCr);
    3536 
    3537     estRate = m_pcEntropyCoder->getNumberOfWrittenBits();
    3538     m_dCost[yCbCr][typeIdx] = (Double)((Double)estDist + lambda * (Double) estRate);
    3539 
    3540     if(m_dCost[yCbCr][typeIdx] < dCostPartBest)
    3541     {
    3542       dCostPartBest = m_dCost[yCbCr][typeIdx];
    3543       copySaoUnit(saoLcuParam, &saoLcuParamRdo );
    3544       bestDist = estDist;       
    3545     }
    3546   }
    3547   compDistortion[0] += ((Double)bestDist/lambda);
    3548   m_pcRDGoOnSbacCoder->load(m_pppcRDSbacCoder[0][CI_TEMP_BEST]);
    3549  m_pcEntropyCoder->encodeSaoOffset(saoLcuParam, yCbCr);
    3550   m_pcRDGoOnSbacCoder->store( m_pppcRDSbacCoder[0][CI_TEMP_BEST] );
    3551 
    3552 
    3553   // merge left or merge up
    3554 
    3555   for (Int idxNeighbor=0;idxNeighbor<2;idxNeighbor++)
    3556   {
    3557     saoLcuParamNeighbor = NULL;
    3558     if (allowMergeLeft && addrLeft>=0 && idxNeighbor ==0)
    3559     {
    3560       saoLcuParamNeighbor = &(saoParam->saoLcuParam[yCbCr][addrLeft]);
    3561     }
    3562     else if (allowMergeUp && addrUp>=0 && idxNeighbor ==1)
    3563     {
    3564       saoLcuParamNeighbor = &(saoParam->saoLcuParam[yCbCr][addrUp]);
    3565     }
    3566     if (saoLcuParamNeighbor!=NULL)
    3567     {
    3568       estDist = 0;
    3569       typeIdx = saoLcuParamNeighbor->typeIdx;
    3570       if (typeIdx>=0)
    3571       {
    3572         Int mergeBandPosition = (typeIdx == SAO_BO)?saoLcuParamNeighbor->subTypeIdx:0;
    3573         Int   merge_iOffset;
    3574         for(classIdx = 0; classIdx < m_iNumClass[typeIdx]; classIdx++)
    3575         {
    3576           merge_iOffset = saoLcuParamNeighbor->offset[classIdx];
    3577           estDist   += estSaoDist(m_iCount [yCbCr][typeIdx][classIdx+mergeBandPosition+1], merge_iOffset, m_iOffsetOrg[yCbCr][typeIdx][classIdx+mergeBandPosition+1],  shift);
    3578         }
    3579       }
    3580       else
    3581       {
    3582         estDist = 0;
    3583       }
    3584 
    3585       copySaoUnit(&compSaoParam[idxNeighbor], saoLcuParamNeighbor );
    3586       compSaoParam[idxNeighbor].mergeUpFlag   = idxNeighbor;
    3587       compSaoParam[idxNeighbor].mergeLeftFlag = !idxNeighbor;
    3588 
    3589       compDistortion[idxNeighbor+1] += ((Double)estDist/lambda);
    3590     }
    3591   }
    3592 }
    3593 Void TEncSampleAdaptiveOffset::sao2ChromaParamDist(Int allowMergeLeft, Int allowMergeUp, SAOParam *saoParam, Int addr, Int addrUp, Int addrLeft, Double lambda, SaoLcuParam *crSaoParam, SaoLcuParam *cbSaoParam, Double *distortion)
    3594 {
    3595   Int typeIdx;
    3596 
    3597   Int64 estDist[2];
    3598   Int classIdx;
    3599   Int shift = 2 * DISTORTION_PRECISION_ADJUSTMENT(g_bitDepthC-8);
    3600   Int64 bestDist = 0;
    3601 
    3602   SaoLcuParam*  saoLcuParam[2] = {&(saoParam->saoLcuParam[1][addr]), &(saoParam->saoLcuParam[2][addr])};
    3603   SaoLcuParam*  saoLcuParamNeighbor[2] = {NULL, NULL};
    3604   SaoLcuParam*  saoMergeParam[2][2];
    3605   saoMergeParam[0][0] = &crSaoParam[0];
    3606   saoMergeParam[0][1] = &crSaoParam[1];
    3607   saoMergeParam[1][0] = &cbSaoParam[0];
    3608   saoMergeParam[1][1] = &cbSaoParam[1];
    3609 
    3610   resetSaoUnit(saoLcuParam[0]);
    3611   resetSaoUnit(saoLcuParam[1]);
    3612   resetSaoUnit(saoMergeParam[0][0]);
    3613   resetSaoUnit(saoMergeParam[0][1]);
    3614   resetSaoUnit(saoMergeParam[1][0]);
    3615   resetSaoUnit(saoMergeParam[1][1]);
    3616 
    3617 
    3618   Double costPartBest = MAX_DOUBLE;
    3619 
    3620   Double  bestRDCostTableBo;
    3621   Int     bestClassTableBo[2]    = {0, 0};
    3622   Int     currentDistortionTableBo[MAX_NUM_SAO_CLASS];
    3623   Double  currentRdCostTableBo[MAX_NUM_SAO_CLASS];
    3624 
    3625   SaoLcuParam   saoLcuParamRdo[2];   
    3626   Double   estRate = 0;
    3627 
    3628   resetSaoUnit(&saoLcuParamRdo[0]);
    3629   resetSaoUnit(&saoLcuParamRdo[1]);
    3630 
    3631   m_pcRDGoOnSbacCoder->load(m_pppcRDSbacCoder[0][CI_TEMP_BEST]);
    3632   m_pcRDGoOnSbacCoder->resetBits();
    3633   m_pcEntropyCoder->encodeSaoOffset(&saoLcuParamRdo[0], 1);
    3634   m_pcEntropyCoder->encodeSaoOffset(&saoLcuParamRdo[1], 2);
    3635  
    3636   costPartBest = m_pcEntropyCoder->getNumberOfWrittenBits()*lambda ;
    3637   copySaoUnit(saoLcuParam[0], &saoLcuParamRdo[0] );
    3638   copySaoUnit(saoLcuParam[1], &saoLcuParamRdo[1] );
    3639 
    3640   for (typeIdx=0; typeIdx<MAX_NUM_SAO_TYPE; typeIdx++)
    3641   {
    3642     if( typeIdx == SAO_BO )
    3643     {
    3644       // Estimate Best Position
    3645       for(Int compIdx = 0; compIdx < 2; compIdx++)
    3646       {
    3647         Double currentRDCost = 0.0;
    3648         bestRDCostTableBo = MAX_DOUBLE;
    3649         estDist[compIdx] = estSaoTypeDist(compIdx+1, typeIdx, shift, lambda, currentDistortionTableBo, currentRdCostTableBo);
    3650         for(Int i=0; i< SAO_MAX_BO_CLASSES -SAO_BO_LEN +1; i++)
    3651         {
    3652           currentRDCost = 0.0;
    3653           for(UInt uj = i; uj < i+SAO_BO_LEN; uj++)
    3654           {
    3655             currentRDCost += currentRdCostTableBo[uj];
    3656           }
    3657 
    3658           if( currentRDCost < bestRDCostTableBo)
    3659           {
    3660             bestRDCostTableBo = currentRDCost;
    3661             bestClassTableBo[compIdx]  = i;
    3662           }
    3663         }
    3664 
    3665         // Re code all Offsets
    3666         // Code Center
    3667         estDist[compIdx] = 0;
    3668         for(classIdx = bestClassTableBo[compIdx]; classIdx < bestClassTableBo[compIdx]+SAO_BO_LEN; classIdx++)
    3669         {
    3670           estDist[compIdx] += currentDistortionTableBo[classIdx];
    3671         }
    3672       }
    3673     }
    3674     else
    3675     {
    3676       estDist[0] = estSaoTypeDist(1, typeIdx, shift, lambda, currentDistortionTableBo, currentRdCostTableBo);
    3677       estDist[1] = estSaoTypeDist(2, typeIdx, shift, lambda, currentDistortionTableBo, currentRdCostTableBo);
    3678     }
    3679 
    3680     m_pcRDGoOnSbacCoder->load(m_pppcRDSbacCoder[0][CI_TEMP_BEST]);
    3681     m_pcRDGoOnSbacCoder->resetBits();
    3682 
    3683     for(Int compIdx = 0; compIdx < 2; compIdx++)
    3684     {
    3685       resetSaoUnit(&saoLcuParamRdo[compIdx]);
    3686       saoLcuParamRdo[compIdx].length = m_iNumClass[typeIdx];
    3687       saoLcuParamRdo[compIdx].typeIdx = typeIdx;
    3688       saoLcuParamRdo[compIdx].mergeLeftFlag = 0;
    3689       saoLcuParamRdo[compIdx].mergeUpFlag   = 0;
    3690       saoLcuParamRdo[compIdx].subTypeIdx = (typeIdx == SAO_BO) ? bestClassTableBo[compIdx] : 0;
    3691       for (classIdx = 0; classIdx < saoLcuParamRdo[compIdx].length; classIdx++)
    3692       {
    3693         saoLcuParamRdo[compIdx].offset[classIdx] = (Int)m_iOffset[compIdx+1][typeIdx][classIdx+saoLcuParamRdo[compIdx].subTypeIdx+1];
    3694       }
    3695 
    3696       m_pcEntropyCoder->encodeSaoOffset(&saoLcuParamRdo[compIdx], compIdx+1);
    3697     }
    3698     estRate = m_pcEntropyCoder->getNumberOfWrittenBits();
    3699     m_dCost[1][typeIdx] = (Double)((Double)(estDist[0] + estDist[1])  + lambda * (Double) estRate);
    3700    
    3701     if(m_dCost[1][typeIdx] < costPartBest)
    3702     {
    3703       costPartBest = m_dCost[1][typeIdx];
    3704       copySaoUnit(saoLcuParam[0], &saoLcuParamRdo[0] );
    3705       copySaoUnit(saoLcuParam[1], &saoLcuParamRdo[1] );
    3706       bestDist = (estDist[0]+estDist[1]);       
    3707     }
    3708   }
    3709 
    3710   distortion[0] += ((Double)bestDist/lambda);
    3711   m_pcRDGoOnSbacCoder->load(m_pppcRDSbacCoder[0][CI_TEMP_BEST]);
    3712   m_pcEntropyCoder->encodeSaoOffset(saoLcuParam[0], 1);
    3713   m_pcEntropyCoder->encodeSaoOffset(saoLcuParam[1], 2);
    3714   m_pcRDGoOnSbacCoder->store( m_pppcRDSbacCoder[0][CI_TEMP_BEST] );
    3715 
    3716   // merge left or merge up
    3717 
    3718   for (Int idxNeighbor=0;idxNeighbor<2;idxNeighbor++)
    3719   {
    3720     for(Int compIdx = 0; compIdx < 2; compIdx++)
    3721     {
    3722       saoLcuParamNeighbor[compIdx] = NULL;
    3723       if (allowMergeLeft && addrLeft>=0 && idxNeighbor ==0)
    3724       {
    3725         saoLcuParamNeighbor[compIdx] = &(saoParam->saoLcuParam[compIdx+1][addrLeft]);
    3726       }
    3727       else if (allowMergeUp && addrUp>=0 && idxNeighbor ==1)
    3728       {
    3729         saoLcuParamNeighbor[compIdx] = &(saoParam->saoLcuParam[compIdx+1][addrUp]);
    3730       }
    3731       if (saoLcuParamNeighbor[compIdx]!=NULL)
    3732       {
    3733         estDist[compIdx] = 0;
    3734         typeIdx = saoLcuParamNeighbor[compIdx]->typeIdx;
    3735         if (typeIdx>=0)
    3736         {
    3737           Int mergeBandPosition = (typeIdx == SAO_BO)?saoLcuParamNeighbor[compIdx]->subTypeIdx:0;
    3738           Int   merge_iOffset;
    3739           for(classIdx = 0; classIdx < m_iNumClass[typeIdx]; classIdx++)
    3740           {
    3741             merge_iOffset = saoLcuParamNeighbor[compIdx]->offset[classIdx];
    3742             estDist[compIdx]   += estSaoDist(m_iCount [compIdx+1][typeIdx][classIdx+mergeBandPosition+1], merge_iOffset, m_iOffsetOrg[compIdx+1][typeIdx][classIdx+mergeBandPosition+1],  shift);
    3743           }
    3744         }
    3745         else
    3746         {
    3747           estDist[compIdx] = 0;
    3748         }
    3749 
    3750         copySaoUnit(saoMergeParam[compIdx][idxNeighbor], saoLcuParamNeighbor[compIdx] );
    3751         saoMergeParam[compIdx][idxNeighbor]->mergeUpFlag   = idxNeighbor;
    3752         saoMergeParam[compIdx][idxNeighbor]->mergeLeftFlag = !idxNeighbor;
    3753         distortion[idxNeighbor+1] += ((Double)estDist[compIdx]/lambda);
    3754       }
    3755     }
    3756   }
    3757 }
    3758 
    3759 #endif
    3760 
    37611315//! \}
  • trunk/source/Lib/TLibEncoder/TEncSampleAdaptiveOffset.h

    r540 r595  
    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 *
     
    5454// ====================================================================================================================
    5555
    56 #if HM_CLEANUP_SAO
    5756enum SAOCabacStateLablesRDO //CABAC state labels
    5857{
     
    146145  TEncSbac*              m_pcRDGoOnSbacCoder;
    147146  TEncBinCABACCounter**  m_pppcBinCoderCABAC;   
    148   Double                 m_labmda[NUM_SAO_COMPONENTS];
     147  Double                 m_lambda[NUM_SAO_COMPONENTS];
    149148
    150149  //statistics
     
    159158  Int                    m_skipLinesB[NUM_SAO_COMPONENTS][NUM_SAO_NEW_TYPES];
    160159};
    161 #else
    162 
    163 
    164 class TEncSampleAdaptiveOffset : public TComSampleAdaptiveOffset
    165 {
    166 private:
    167   TEncEntropy*      m_pcEntropyCoder;
    168   TEncSbac***       m_pppcRDSbacCoder;              ///< for CABAC
    169   TEncSbac*         m_pcRDGoOnSbacCoder;
    170 #if FAST_BIT_EST
    171   TEncBinCABACCounter*** m_pppcBinCoderCABAC;            ///< temporal CABAC state storage for RD computation
    172 #else
    173   TEncBinCABAC***   m_pppcBinCoderCABAC;            ///< temporal CABAC state storage for RD computation
    174 #endif
    175  
    176   Int64  ***m_iCount;      //[MAX_NUM_SAO_PART][MAX_NUM_SAO_TYPE][MAX_NUM_SAO_CLASS];
    177   Int64  ***m_iOffset;     //[MAX_NUM_SAO_PART][MAX_NUM_SAO_TYPE][MAX_NUM_SAO_CLASS];
    178   Int64  ***m_iOffsetOrg;  //[MAX_NUM_SAO_PART][MAX_NUM_SAO_TYPE];
    179   Int64  ****m_count_PreDblk;      //[LCU][YCbCr][MAX_NUM_SAO_TYPE][MAX_NUM_SAO_CLASS];
    180   Int64  ****m_offsetOrg_PreDblk;  //[LCU][YCbCr][MAX_NUM_SAO_TYPE][MAX_NUM_SAO_CLASS];
    181   Int64  **m_iRate;        //[MAX_NUM_SAO_PART][MAX_NUM_SAO_TYPE];
    182   Int64  **m_iDist;        //[MAX_NUM_SAO_PART][MAX_NUM_SAO_TYPE];
    183   Double **m_dCost;        //[MAX_NUM_SAO_PART][MAX_NUM_SAO_TYPE];
    184   Double *m_dCostPartBest; //[MAX_NUM_SAO_PART];
    185   Int64  *m_iDistOrg;      //[MAX_NUM_SAO_PART];
    186   Int    *m_iTypePartBest; //[MAX_NUM_SAO_PART];
    187   Int     m_iOffsetThY;
    188   Int     m_iOffsetThC;
    189   Bool    m_bUseSBACRD;
    190 #if SAO_ENCODING_CHOICE
    191 #if SAO_ENCODING_CHOICE_CHROMA
    192   Double  m_depthSaoRate[2][4];
    193 #else
    194   Double  m_depth0SaoRate;
    195 #endif
    196 #endif
    197 
    198 public:
    199   TEncSampleAdaptiveOffset         ();
    200   virtual ~TEncSampleAdaptiveOffset();
    201 
    202   Void startSaoEnc( TComPic* pcPic, TEncEntropy* pcEntropyCoder, TEncSbac*** pppcRDSbacCoder, TEncSbac* pcRDGoOnSbacCoder);
    203   Void endSaoEnc();
    204   Void resetStats();
    205 #if SAO_ENCODING_CHOICE
    206   Void SAOProcess(SAOParam *pcSaoParam, Double dLambda, Double dLambdaChroma, Int depth);
    207 #else
    208   Void SAOProcess(SAOParam *pcSaoParam, Double dLambda, Double dLambdaChroma);
    209 #endif
    210 
    211   Void runQuadTreeDecision(SAOQTPart *psQTPart, Int iPartIdx, Double &dCostFinal, Int iMaxLevel, Double dLambda, Int yCbCr);
    212   Void rdoSaoOnePart(SAOQTPart *psQTPart, Int iPartIdx, Double dLambda, Int yCbCr);
    213  
    214   Void disablePartTree(SAOQTPart *psQTPart, Int iPartIdx);
    215   Void getSaoStats(SAOQTPart *psQTPart, Int iYCbCr);
    216   Void calcSaoStatsCu(Int iAddr, Int iPartIdx, Int iYCbCr);
    217   Void calcSaoStatsBlock( Pel* pRecStart, Pel* pOrgStart, Int stride, Int64** ppStats, Int64** ppCount, UInt width, UInt height, Bool* pbBorderAvail, Int iYCbCr);
    218   Void calcSaoStatsCuOrg(Int iAddr, Int iPartIdx, Int iYCbCr);
    219   Void calcSaoStatsCu_BeforeDblk( TComPic* pcPic );
    220   Void destroyEncBuffer();
    221   Void createEncBuffer();
    222   Void assignSaoUnitSyntax(SaoLcuParam* saoLcuParam,  SAOQTPart* saoPart, Bool &oneUnitFlag, Int yCbCr);
    223   Void checkMerge(SaoLcuParam * lcuParamCurr,SaoLcuParam * lcuParamCheck, Int dir);
    224 #if SAO_ENCODING_CHOICE
    225   Void rdoSaoUnitAll(SAOParam *saoParam, Double lambda, Double lambdaChroma, Int depth);
    226 #else
    227   Void rdoSaoUnitAll(SAOParam *saoParam, Double lambda, Double lambdaChroma);
    228 #endif
    229   Void saoComponentParamDist(Int allowMergeLeft, Int allowMergeUp, SAOParam *saoParam, Int addr, Int addrUp, Int addrLeft, Int yCbCr, Double lambda, SaoLcuParam *compSaoParam, Double *distortion);
    230   Void sao2ChromaParamDist(Int allowMergeLeft, Int allowMergeUp, SAOParam *saoParam, Int addr, Int addrUp, Int addrLeft, Double lambda, SaoLcuParam *crSaoParam, SaoLcuParam *cbSaoParam, Double *distortion);
    231   inline Int64 estSaoDist(Int64 count, Int64 offset, Int64 offsetOrg, Int shift);
    232   inline Int64 estIterOffset(Int typeIdx, Int classIdx, Double lambda, Int64 offsetInput, Int64 count, Int64 offsetOrg, Int shift, Int bitIncrease, Int *currentDistortionTableBo, Double *currentRdCostTableBo, Int offsetTh );
    233   inline Int64 estSaoTypeDist(Int compIdx, Int typeIdx, Int shift, Double lambda, Int *currentDistortionTableBo, Double *currentRdCostTableBo);
    234   Void setMaxNumOffsetsPerPic(Int iVal) {m_maxNumOffsetsPerPic = iVal; }
    235   Int  getMaxNumOffsetsPerPic() {return m_maxNumOffsetsPerPic; }
    236 };
    237 #endif
    238160//! \}
    239161
  • trunk/source/Lib/TLibEncoder/TEncSbac.cpp

    r540 r595  
    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 *
     
    7878, m_cCUAbsSCModel             ( 1,             1,               NUM_ABS_FLAG_CTX              , m_contextModels + m_numContextModels, m_numContextModels)
    7979, m_cMVPIdxSCModel            ( 1,             1,               NUM_MVP_IDX_CTX               , m_contextModels + m_numContextModels, m_numContextModels)
    80 , m_cCUAMPSCModel             ( 1,             1,               NUM_CU_AMP_CTX                , m_contextModels + m_numContextModels, m_numContextModels)
    8180, m_cSaoMergeSCModel          ( 1,             1,               NUM_SAO_MERGE_FLAG_CTX   , m_contextModels + m_numContextModels, m_numContextModels)
    8281, m_cSaoTypeIdxSCModel        ( 1,             1,               NUM_SAO_TYPE_IDX_CTX          , m_contextModels + m_numContextModels, m_numContextModels)
     
    112111  m_cCUMergeIdxExtSCModel.initBuffer     ( eSliceType, iQp, (UChar*)INIT_MERGE_IDX_EXT);
    113112  m_cCUPartSizeSCModel.initBuffer        ( eSliceType, iQp, (UChar*)INIT_PART_SIZE );
    114   m_cCUAMPSCModel.initBuffer             ( eSliceType, iQp, (UChar*)INIT_CU_AMP_POS );
    115113  m_cCUPredModeSCModel.initBuffer        ( eSliceType, iQp, (UChar*)INIT_PRED_MODE );
    116114  m_cCUIntraPredSCModel.initBuffer       ( eSliceType, iQp, (UChar*)INIT_INTRA_PRED_MODE );
     
    166164      curCost += m_cCUMergeIdxExtSCModel.calcCost     ( curSliceType, qp, (UChar*)INIT_MERGE_IDX_EXT);
    167165      curCost += m_cCUPartSizeSCModel.calcCost        ( curSliceType, qp, (UChar*)INIT_PART_SIZE );
    168       curCost += m_cCUAMPSCModel.calcCost             ( curSliceType, qp, (UChar*)INIT_CU_AMP_POS );
    169166      curCost += m_cCUPredModeSCModel.calcCost        ( curSliceType, qp, (UChar*)INIT_PRED_MODE );
    170167      curCost += m_cCUIntraPredSCModel.calcCost       ( curSliceType, qp, (UChar*)INIT_INTRA_PRED_MODE );
     
    215212  m_cCUMergeIdxExtSCModel.initBuffer     ( eSliceType, iQp, (UChar*)INIT_MERGE_IDX_EXT);
    216213  m_cCUPartSizeSCModel.initBuffer        ( eSliceType, iQp, (UChar*)INIT_PART_SIZE );
    217   m_cCUAMPSCModel.initBuffer             ( eSliceType, iQp, (UChar*)INIT_CU_AMP_POS );
    218214  m_cCUPredModeSCModel.initBuffer        ( eSliceType, iQp, (UChar*)INIT_PRED_MODE );
    219215  m_cCUIntraPredSCModel.initBuffer       ( eSliceType, iQp, (UChar*)INIT_INTRA_PRED_MODE );
     
    442438        if (eSize == SIZE_2NxN)
    443439        {
    444           m_pcBinIf->encodeBin(1, m_cCUAMPSCModel.get( 0, 0, 0 ));
     440          m_pcBinIf->encodeBin(1, m_cCUPartSizeSCModel.get( 0, 0, 3 ));
    445441        }
    446442        else
    447443        {
    448           m_pcBinIf->encodeBin(0, m_cCUAMPSCModel.get( 0, 0, 0 ));         
     444          m_pcBinIf->encodeBin(0, m_cCUPartSizeSCModel.get( 0, 0, 3 ));
    449445          m_pcBinIf->encodeBinEP((eSize == SIZE_2NxnU? 0: 1));
    450446        }
     
    466462        if (eSize == SIZE_Nx2N)
    467463        {
    468           m_pcBinIf->encodeBin(1, m_cCUAMPSCModel.get( 0, 0, 0 ));
     464          m_pcBinIf->encodeBin(1, m_cCUPartSizeSCModel.get( 0, 0, 3 ));
    469465        }
    470466        else
    471467        {
    472           m_pcBinIf->encodeBin(0, m_cCUAMPSCModel.get( 0, 0, 0 ));
     468          m_pcBinIf->encodeBin(0, m_cCUPartSizeSCModel.get( 0, 0, 3 ));
    473469          m_pcBinIf->encodeBinEP((eSize == SIZE_nLx2N? 0: 1));
    474470        }
     
    13931389  {
    13941390    m_pcBinIf->encodeBin( 1, m_cSaoTypeIdxSCModel.get( 0, 0, 0 ) );
    1395 #if HM_CLEANUP_SAO
    13961391    m_pcBinIf->encodeBinEP( uiCode == 1 ? 0 : 1 );
    1397 #else
    1398     m_pcBinIf->encodeBinEP( uiCode <= 4 ? 1 : 0 );
    1399 #endif
    14001392  }
    14011393}
     
    16001592}
    16011593
    1602 #if HM_CLEANUP_SAO
    16031594Void TEncSbac::codeSAOOffsetParam(Int compIdx, SAOOffset& ctbParam, Bool sliceEnabled)
    16041595{
     
    17131704  }
    17141705}
    1715 #endif
    17161706
    17171707//! \}
  • trunk/source/Lib/TLibEncoder/TEncSbac.h

    r540 r595  
    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 *
     
    104104  Void  codeScalingList      ( TComScalingList* /*scalingList*/     ){ assert (0);  return;};
    105105
    106 #if HM_CLEANUP_SAO
    107106  Void codeSAOOffsetParam(Int compIdx, SAOOffset& ctbParam, Bool sliceEnabled);
    108107  Void codeSAOBlkParam(SAOBlkParam& saoBlkParam
     
    112111                    , Bool onlyEstMergeInfo = false
    113112                    );
    114 #endif
    115113
    116114private:
     
    208206  ContextModel3DBuffer m_cMVPIdxSCModel;
    209207 
    210   ContextModel3DBuffer m_cCUAMPSCModel;
    211208  ContextModel3DBuffer m_cSaoMergeSCModel;
    212209  ContextModel3DBuffer m_cSaoTypeIdxSCModel;
  • trunk/source/Lib/TLibEncoder/TEncSearch.cpp

    r540 r595  
    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 *
     
    199199  m_pppcRDSbacCoder     = pppcRDSbacCoder;
    200200  m_pcRDGoOnSbacCoder   = pcRDGoOnSbacCoder;
    201  
    202   m_bUseSBACRD          = pppcRDSbacCoder ? true : false;
    203201 
    204202  for (Int iDir = 0; iDir < 2; iDir++)
     
    11251123  {
    11261124    Int scalingListType = 0 + g_eTTable[(Int)TEXT_LUMA];
    1127     assert(scalingListType < 6);
     1125    assert(scalingListType < SCALING_LIST_NUM);
    11281126    m_pcTrQuant->invtransformNxN( pcCU->getCUTransquantBypass(uiAbsPartIdx), TEXT_LUMA,pcCU->getLumaIntraDir( uiAbsPartIdx ), piResi, uiStride, pcCoeff, uiWidth, uiHeight, scalingListType, useTransformSkip );
    11291127  }
     
    13181316    {
    13191317      Int scalingListType = 0 + g_eTTable[(Int)eText];
    1320       assert(scalingListType < 6);
     1318      assert(scalingListType < SCALING_LIST_NUM);
    13211319      m_pcTrQuant->invtransformNxN( pcCU->getCUTransquantBypass(uiAbsPartIdx), TEXT_CHROMA, REG_DCT, piResi, uiStride, pcCoeff, uiWidth, uiHeight, scalingListType, useTransformSkipChroma );
    13221320    }
     
    14241422  checkTransformSkip         &= (widthTransformSkip == 4 && heightTransformSkip == 4);
    14251423  checkTransformSkip         &= (!pcCU->getCUTransquantBypass(0));
    1426   checkTransformSkip         &= (!((pcCU->getQP( 0 ) == 0) && (pcCU->getSlice()->getSPS()->getUseLossless())));
    14271424  if ( m_pcEncCfg->getUseTransformSkipFast() )
    14281425  {
     
    14341431    {
    14351432      //----- store original entropy coding status -----
    1436       if( m_bUseSBACRD)
    1437       {
    1438         m_pcRDGoOnSbacCoder->store( m_pppcRDSbacCoder[ uiFullDepth ][ CI_QT_TRAFO_ROOT ] );
    1439       }
     1433      m_pcRDGoOnSbacCoder->store( m_pppcRDSbacCoder[ uiFullDepth ][ CI_QT_TRAFO_ROOT ] );
     1434
    14401435      UInt   singleDistYTmp     = 0;
    14411436      UInt   singleDistCTmp     = 0;
     
    15031498          {
    15041499            xStoreIntraResultQT(pcCU, uiTrDepth, uiAbsPartIdx,bLumaOnly );
    1505             if( m_bUseSBACRD)
    1506             {
    1507               m_pcRDGoOnSbacCoder->store( m_pppcRDSbacCoder[ uiFullDepth ][ CI_TEMP_BEST ] );
    1508             }
     1500            m_pcRDGoOnSbacCoder->store( m_pppcRDSbacCoder[ uiFullDepth ][ CI_TEMP_BEST ] );
    15091501          }
    15101502        }
     
    15291521          }
    15301522        }
    1531         if(m_bUseSBACRD)
    1532         {
    1533           m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[ uiFullDepth ][ CI_TEMP_BEST ] );
    1534         }
    1535       }
     1523        m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[ uiFullDepth ][ CI_TEMP_BEST ] );
     1524      }
    15361525
    15371526      if( !bLumaOnly )
     
    15581547      pcCU ->setTransformSkipSubParts ( 0, TEXT_LUMA, uiAbsPartIdx, uiFullDepth );
    15591548      //----- store original entropy coding status -----
    1560       if( m_bUseSBACRD && bCheckSplit )
     1549      if( bCheckSplit )
    15611550      {
    15621551        m_pcRDGoOnSbacCoder->store( m_pppcRDSbacCoder[ uiFullDepth ][ CI_QT_TRAFO_ROOT ] );
     
    15951584  {
    15961585    //----- store full entropy coding status, load original entropy coding status -----
    1597     if( m_bUseSBACRD )
    1598     {
    1599       if( bCheckFull )
    1600       {
    1601         m_pcRDGoOnSbacCoder->store( m_pppcRDSbacCoder[ uiFullDepth ][ CI_QT_TRAFO_TEST ] );
    1602         m_pcRDGoOnSbacCoder->load ( m_pppcRDSbacCoder[ uiFullDepth ][ CI_QT_TRAFO_ROOT ] );
    1603       }
    1604       else
    1605       {
    1606         m_pcRDGoOnSbacCoder->store( m_pppcRDSbacCoder[ uiFullDepth ][ CI_QT_TRAFO_ROOT ] );
    1607       }
    1608     }
     1586    if( bCheckFull )
     1587    {
     1588      m_pcRDGoOnSbacCoder->store( m_pppcRDSbacCoder[ uiFullDepth ][ CI_QT_TRAFO_TEST ] );
     1589      m_pcRDGoOnSbacCoder->load ( m_pppcRDSbacCoder[ uiFullDepth ][ CI_QT_TRAFO_ROOT ] );
     1590    }
     1591    else
     1592    {
     1593      m_pcRDGoOnSbacCoder->store( m_pppcRDSbacCoder[ uiFullDepth ][ CI_QT_TRAFO_ROOT ] );
     1594    }
     1595
    16091596    //----- code splitted block -----
    16101597    Double  dSplitCost      = 0.0;
     
    16471634    }
    16481635    //----- restore context states -----
    1649     if( m_bUseSBACRD )
    1650     {
    1651       m_pcRDGoOnSbacCoder->load ( m_pppcRDSbacCoder[ uiFullDepth ][ CI_QT_TRAFO_ROOT ] );
    1652     }
     1636    m_pcRDGoOnSbacCoder->load ( m_pppcRDSbacCoder[ uiFullDepth ][ CI_QT_TRAFO_ROOT ] );
     1637
    16531638    //----- determine rate and r-d cost -----
    16541639    UInt uiSplitBits = xGetIntraBitsQT( pcCU, uiTrDepth, uiAbsPartIdx, true, !bLumaOnly, false );
     
    16651650    }
    16661651    //----- set entropy coding status -----
    1667     if( m_bUseSBACRD )
    1668     {
    1669       m_pcRDGoOnSbacCoder->load ( m_pppcRDSbacCoder[ uiFullDepth ][ CI_QT_TRAFO_TEST ] );
    1670     }
    1671    
     1652    m_pcRDGoOnSbacCoder->load ( m_pppcRDSbacCoder[ uiFullDepth ][ CI_QT_TRAFO_TEST ] );
     1653
    16721654    //--- set transform index and Cbf values ---
    16731655    pcCU->setTrIdxSubParts( uiTrDepth, uiAbsPartIdx, uiFullDepth );
     
    21942176    {
    21952177        //use RDO to decide whether Cr/Cb takes TS
    2196         if( m_bUseSBACRD )
    2197         {
    2198           m_pcRDGoOnSbacCoder->store( m_pppcRDSbacCoder[uiFullDepth][CI_QT_TRAFO_ROOT] );
    2199         }
     2178        m_pcRDGoOnSbacCoder->store( m_pppcRDSbacCoder[uiFullDepth][CI_QT_TRAFO_ROOT] );
    22002179
    22012180        for(Int chromaId = 0; chromaId < 2; chromaId ++)
     
    22392218
    22402219            if(singleCostTmp < dSingleCost)
     2220          {
     2221            dSingleCost = singleCostTmp;
     2222            singleDistC = singleDistCTmp;
     2223            bestModeId  = chromaModeId;
     2224            singleCbfC  = singleCbfCTmp;
     2225           
     2226            if(bestModeId == firstCheckId)
    22412227            {
    2242               dSingleCost = singleCostTmp;
    2243               singleDistC = singleDistCTmp;
    2244               bestModeId  = chromaModeId;
    2245               singleCbfC  = singleCbfCTmp;
    2246 
    2247               if(bestModeId == firstCheckId)
    2248               {
    2249                 xStoreIntraResultChromaQT(pcCU, uiTrDepth, uiAbsPartIdx,chromaId);
    2250                 if( m_bUseSBACRD)
    2251                 {
    2252                   m_pcRDGoOnSbacCoder->store( m_pppcRDSbacCoder[ uiFullDepth ][ CI_TEMP_BEST ] );
    2253                 }
    2254               }
    2255             }
    2256             if(chromaModeId == firstCheckId)
    2257             {
    2258               m_pcRDGoOnSbacCoder->load ( m_pppcRDSbacCoder[ uiFullDepth ][ CI_QT_TRAFO_ROOT ] );
     2228              xStoreIntraResultChromaQT(pcCU, uiTrDepth, uiAbsPartIdx,chromaId);
     2229              m_pcRDGoOnSbacCoder->store( m_pppcRDSbacCoder[ uiFullDepth ][ CI_TEMP_BEST ] );
    22592230            }
    22602231          }
    2261 
    2262           if(bestModeId == firstCheckId)
     2232          if(chromaModeId == firstCheckId)
    22632233          {
    2264             xLoadIntraResultChromaQT(pcCU, uiTrDepth, uiAbsPartIdx,chromaId);
    2265             pcCU->setCbfSubParts ( singleCbfC << uiTrDepth, (TextType)(chromaId + 2), uiAbsPartIdx, pcCU->getDepth(0) + actualTrDepth );
    2266             if(m_bUseSBACRD)
    2267             {
    2268               m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[ uiFullDepth ][ CI_TEMP_BEST ] );
    2269             }
     2234            m_pcRDGoOnSbacCoder->load ( m_pppcRDSbacCoder[ uiFullDepth ][ CI_QT_TRAFO_ROOT ] );
    22702235          }
    2271           pcCU ->setTransformSkipSubParts( bestModeId, (TextType)(chromaId + 2), uiAbsPartIdx, pcCU->getDepth( 0 ) +  actualTrDepth );
    2272           ruiDist += singleDistC;
    2273 
    2274           if(chromaId == 0)
    2275           {
    2276             if( m_bUseSBACRD )
    2277             {
    2278               m_pcRDGoOnSbacCoder->store( m_pppcRDSbacCoder[uiFullDepth][CI_QT_TRAFO_ROOT] );
    2279             }
    2280           }
    2281         }
     2236        }
     2237       
     2238        if(bestModeId == firstCheckId)
     2239        {
     2240          xLoadIntraResultChromaQT(pcCU, uiTrDepth, uiAbsPartIdx,chromaId);
     2241          pcCU->setCbfSubParts ( singleCbfC << uiTrDepth, (TextType)(chromaId + 2), uiAbsPartIdx, pcCU->getDepth(0) + actualTrDepth );
     2242          m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[ uiFullDepth ][ CI_TEMP_BEST ] );
     2243        }
     2244        pcCU ->setTransformSkipSubParts( bestModeId, (TextType)(chromaId + 2), uiAbsPartIdx, pcCU->getDepth( 0 ) +  actualTrDepth );
     2245        ruiDist += singleDistC;
     2246       
     2247        if(chromaId == 0)
     2248        {
     2249          m_pcRDGoOnSbacCoder->store( m_pppcRDSbacCoder[uiFullDepth][CI_QT_TRAFO_ROOT] );
     2250        }
     2251      }
    22822252    }
    22832253    else
     
    25752545     
    25762546      // set context models
    2577       if( m_bUseSBACRD )
    2578       {
    2579         m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[uiDepth][CI_CURR_BEST] );
    2580       }
     2547      m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[uiDepth][CI_CURR_BEST] );
    25812548     
    25822549      // determine residual for partition
     
    26402607     
    26412608      // set context models
    2642       if( m_bUseSBACRD )
    2643       {
    2644         m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[uiDepth][CI_CURR_BEST] );
    2645       }
     2609      m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[uiDepth][CI_CURR_BEST] );
    26462610     
    26472611      // determine residual for partition
     
    27702734 
    27712735  //===== reset context models =====
    2772   if(m_bUseSBACRD)
    2773   {
    2774     m_pcRDGoOnSbacCoder->load(m_pppcRDSbacCoder[uiDepth][CI_CURR_BEST]);
    2775   }
     2736  m_pcRDGoOnSbacCoder->load(m_pppcRDSbacCoder[uiDepth][CI_CURR_BEST]);
    27762737 
    27772738  //===== set distortion (rate and r-d costs are determined later) =====
     
    28052766  {
    28062767    //----- restore context models -----
    2807     if( m_bUseSBACRD )
    2808     {
    2809       m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[uiDepth][CI_CURR_BEST] );
    2810     }
     2768    m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[uiDepth][CI_CURR_BEST] );
    28112769   
    28122770    //----- chroma coding -----
     
    28142772    pcCU->setChromIntraDirSubParts  ( uiModeList[uiMode], 0, uiDepth );
    28152773    xRecurIntraChromaCodingQT       ( pcCU,   0, 0, pcOrgYuv, pcPredYuv, pcResiYuv, uiDist );
    2816     if( m_bUseSBACRD && pcCU->getSlice()->getPPS()->getUseTransformSkip() )
     2774    if( pcCU->getSlice()->getPPS()->getUseTransformSkip() )
    28172775    {
    28182776      m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[uiDepth][CI_CURR_BEST] );
     
    28462804 
    28472805  //----- restore context models -----
    2848   if( m_bUseSBACRD )
    2849   {
    2850     m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[uiDepth][CI_CURR_BEST] );
    2851   }
     2806  m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[uiDepth][CI_CURR_BEST] );
    28522807}
    28532808
     
    30052960  dCost = m_pcRdCost->calcRdCost( uiBits, uiDistortion );
    30062961
    3007   if(m_bUseSBACRD)
    3008   {
    3009     m_pcRDGoOnSbacCoder->load(m_pppcRDSbacCoder[uiDepth][CI_CURR_BEST]);
    3010   }
     2962  m_pcRDGoOnSbacCoder->load(m_pppcRDSbacCoder[uiDepth][CI_CURR_BEST]);
    30112963
    30122964  pcCU->getTotalBits()       = uiBits;
     
    45744526    + m_pcRdCost->getDistPart(g_bitDepthC, rpcYuvRec->getCrAddr(),   rpcYuvRec->getCStride(), pcYuvOrg->getCrAddr(),   pcYuvOrg->getCStride(), uiWidth >> 1, uiHeight >> 1, TEXT_CHROMA_V );
    45754527
    4576     if( m_bUseSBACRD )
    4577     {
    4578       m_pcRDGoOnSbacCoder->load(m_pppcRDSbacCoder[pcCU->getDepth(0)][CI_CURR_BEST]);
    4579     }
     4528    m_pcRDGoOnSbacCoder->load(m_pppcRDSbacCoder[pcCU->getDepth(0)][CI_CURR_BEST]);
    45804529   
    45814530    m_pcEntropyCoder->resetBits();
     
    45924541    pcCU->getTotalCost()       = m_pcRdCost->calcRdCost( uiBits, uiDistortion );
    45934542   
    4594     if( m_bUseSBACRD )
    4595     {
    4596       m_pcRDGoOnSbacCoder->store(m_pppcRDSbacCoder[pcCU->getDepth(0)][CI_TEMP_BEST]);
    4597     }
     4543    m_pcRDGoOnSbacCoder->store(m_pppcRDSbacCoder[pcCU->getDepth(0)][CI_TEMP_BEST]);
    45984544   
    45994545    pcCU->setCbfSubParts( 0, 0, 0, 0, pcCU->getDepth( 0 ) );
     
    46314577    uiBits = 0;
    46324578    uiDistortion = 0;
    4633     if( m_bUseSBACRD )
    4634     {
    4635       m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[ pcCU->getDepth( 0 ) ][ CI_CURR_BEST ] );
    4636     }
     4579    m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[ pcCU->getDepth( 0 ) ][ CI_CURR_BEST ] );
    46374580   
    46384581    UInt uiZeroDistortion = 0;
     
    46684611    }
    46694612   
    4670     if( m_bUseSBACRD )
    4671     {
    4672       m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[pcCU->getDepth(0)][CI_CURR_BEST] );
    4673     }
     4613    m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[pcCU->getDepth(0)][CI_CURR_BEST] );
    46744614#if 0 // check
    46754615    {
     
    46774617      m_pcEntropyCoder->encodeCoeff( pcCU, 0, pcCU->getDepth(0), pcCU->getWidth(0), pcCU->getHeight(0) );
    46784618      const UInt uiBitsForCoeff = m_pcEntropyCoder->getNumberOfWrittenBits();
    4679       if( m_bUseSBACRD )
    4680       {
    4681         m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[pcCU->getDepth(0)][CI_CURR_BEST] );
    4682       }
     4619      m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[pcCU->getDepth(0)][CI_CURR_BEST] );
    46834620      if( uiBitsForCoeff != uiBits )
    46844621        assert( 0 );
     
    47294666      dCostBest        = dCost;
    47304667      qpBest           = qp;
    4731       if( m_bUseSBACRD )
    4732       {
    4733         m_pcRDGoOnSbacCoder->store( m_pppcRDSbacCoder[ pcCU->getDepth( 0 ) ][ CI_TEMP_BEST ] );
    4734       }
     4668      m_pcRDGoOnSbacCoder->store( m_pppcRDSbacCoder[ pcCU->getDepth( 0 ) ][ CI_TEMP_BEST ] );
    47354669    }
    47364670  }
     
    47404674  if( qpMin != qpMax && qpBest != qpMax )
    47414675  {
    4742     if( m_bUseSBACRD )
    4743     {
    4744       assert( 0 ); // check
    4745       m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[ pcCU->getDepth( 0 ) ][ CI_TEMP_BEST ] );
    4746     }
     4676    assert( 0 ); // check
     4677    m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[ pcCU->getDepth( 0 ) ][ CI_TEMP_BEST ] );
     4678
    47474679    // copy best cbf and trIdx to pcCU
    47484680    const UInt uiQPartNum = pcCU->getPic()->getNumPartInCU() >> (pcCU->getDepth(0) << 1);
     
    48244756  UInt uiBestTransformMode[3] = {0};
    48254757
    4826   if( m_bUseSBACRD )
    4827   {
    4828     m_pcRDGoOnSbacCoder->store( m_pppcRDSbacCoder[ uiDepth ][ CI_QT_TRAFO_ROOT ] );
    4829   }
     4758  m_pcRDGoOnSbacCoder->store( m_pppcRDSbacCoder[ uiDepth ][ CI_QT_TRAFO_ROOT ] );
    48304759 
    48314760  if( bCheckFull )
     
    49654894
    49664895      Int scalingListType = 3 + g_eTTable[(Int)TEXT_LUMA];
    4967       assert(scalingListType < 6);     
     4896      assert(scalingListType < SCALING_LIST_NUM);
    49684897      m_pcTrQuant->invtransformNxN( pcCU->getCUTransquantBypass(uiAbsPartIdx), TEXT_LUMA,REG_DCT, pcResiCurrY, m_pcQTTempTComYuv[uiQTTempAccessLayer].getStride(),  pcCoeffCurrY, trWidth, trHeight, scalingListType );//this is for inter mode only
    49694898     
     
    50384967
    50394968        Int scalingListType = 3 + g_eTTable[(Int)TEXT_CHROMA_U];
    5040         assert(scalingListType < 6);
     4969        assert(scalingListType < SCALING_LIST_NUM);
    50414970        m_pcTrQuant->invtransformNxN( pcCU->getCUTransquantBypass(uiAbsPartIdx), TEXT_CHROMA,REG_DCT, pcResiCurrU, m_pcQTTempTComYuv[uiQTTempAccessLayer].getCStride(), pcCoeffCurrU, trWidthC, trHeightC, scalingListType  );
    50424971       
     
    51085037
    51095038        Int scalingListType = 3 + g_eTTable[(Int)TEXT_CHROMA_V];
    5110         assert(scalingListType < 6);
     5039        assert(scalingListType < SCALING_LIST_NUM);
    51115040        m_pcTrQuant->invtransformNxN( pcCU->getCUTransquantBypass(uiAbsPartIdx), TEXT_CHROMA,REG_DCT, pcResiCurrV, m_pcQTTempTComYuv[uiQTTempAccessLayer].getCStride(), pcCoeffCurrV, trWidthC, trHeightC, scalingListType );
    51125041       
     
    51925121      }
    51935122
    5194       if( m_bUseSBACRD )
    5195       {
    5196         m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[ uiDepth ][ CI_QT_TRAFO_ROOT ] );
    5197       }
     5123      m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[ uiDepth ][ CI_QT_TRAFO_ROOT ] );
    51985124
    51995125      pcCU->setTransformSkipSubParts ( 1, TEXT_LUMA, uiAbsPartIdx, uiDepth );
     
    52345160
    52355161        Int scalingListType = 3 + g_eTTable[(Int)TEXT_LUMA];
    5236         assert(scalingListType < 6);     
     5162        assert(scalingListType < SCALING_LIST_NUM);
    52375163
    52385164        m_pcTrQuant->invtransformNxN( pcCU->getCUTransquantBypass(uiAbsPartIdx), TEXT_LUMA,REG_DCT, pcResiCurrY, m_pcQTTempTComYuv[uiQTTempAccessLayer].getStride(),  pcCoeffCurrY, trWidth, trHeight, scalingListType, true );
     
    52925218      }
    52935219
    5294       if( m_bUseSBACRD )
    5295       {
    5296         m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[ uiDepth ][ CI_QT_TRAFO_ROOT ] );
    5297       }
     5220      m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[ uiDepth ][ CI_QT_TRAFO_ROOT ] );
    52985221
    52995222      pcCU->setTransformSkipSubParts ( 1, TEXT_CHROMA_U, uiAbsPartIdx, pcCU->getDepth(0)+uiTrModeC );
     
    53455268
    53465269        Int scalingListType = 3 + g_eTTable[(Int)TEXT_CHROMA_U];
    5347         assert(scalingListType < 6);
     5270        assert(scalingListType < SCALING_LIST_NUM);
    53485271
    53495272        m_pcTrQuant->invtransformNxN( pcCU->getCUTransquantBypass(uiAbsPartIdx), TEXT_CHROMA,REG_DCT, pcResiCurrU, m_pcQTTempTComYuv[uiQTTempAccessLayer].getCStride(), pcCoeffCurrU, trWidthC, trHeightC, scalingListType, true  );
     
    53875310
    53885311        Int scalingListType = 3 + g_eTTable[(Int)TEXT_CHROMA_V];
    5389         assert(scalingListType < 6);
     5312        assert(scalingListType < SCALING_LIST_NUM);
    53905313
    53915314        m_pcTrQuant->invtransformNxN( pcCU->getCUTransquantBypass(uiAbsPartIdx), TEXT_CHROMA,REG_DCT, pcResiCurrV, m_pcQTTempTComYuv[uiQTTempAccessLayer].getCStride(), pcCoeffCurrV, trWidthC, trHeightC, scalingListType, true );
     
    54235346    }
    54245347
    5425     if( m_bUseSBACRD )
    5426     {
    5427       m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[ uiDepth ][ CI_QT_TRAFO_ROOT ] );
    5428     }
    5429 
     5348    m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[ uiDepth ][ CI_QT_TRAFO_ROOT ] );
    54305349    m_pcEntropyCoder->resetBits();
    54315350
     
    54605379  if( bCheckSplit )
    54615380  {
    5462     if( m_bUseSBACRD && bCheckFull )
     5381    if( bCheckFull )
    54635382    {
    54645383      m_pcRDGoOnSbacCoder->store( m_pppcRDSbacCoder[ uiDepth ][ CI_QT_TRAFO_TEST ] );
     
    54925411    }
    54935412   
    5494     if( m_bUseSBACRD )
    5495     {
    5496       m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[ uiDepth ][ CI_QT_TRAFO_ROOT ] );
    5497     }
     5413    m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[ uiDepth ][ CI_QT_TRAFO_ROOT ] );
    54985414    m_pcEntropyCoder->resetBits();
    54995415   
     
    55235439    }
    55245440    assert( bCheckFull );
    5525     if( m_bUseSBACRD )
    5526     {
    5527       m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[ uiDepth ][ CI_QT_TRAFO_TEST ] );
    5528     }
     5441
     5442    m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[ uiDepth ][ CI_QT_TRAFO_TEST ] );
    55295443  }
    55305444  rdCost += dSingleCost;
     
    57175631UInt TEncSearch::xModeBitsIntra( TComDataCU* pcCU, UInt uiMode, UInt uiPU, UInt uiPartOffset, UInt uiDepth, UInt uiInitTrDepth )
    57185632{
    5719   if( m_bUseSBACRD )
    5720   {
    5721     // Reload only contexts required for coding intra mode information
    5722     m_pcRDGoOnSbacCoder->loadIntraDirModeLuma( m_pppcRDSbacCoder[uiDepth][CI_CURR_BEST] );
    5723   }
     5633  // Reload only contexts required for coding intra mode information
     5634  m_pcRDGoOnSbacCoder->loadIntraDirModeLuma( m_pppcRDSbacCoder[uiDepth][CI_CURR_BEST] );
    57245635 
    57255636  pcCU->setLumaIntraDirSubParts ( uiMode, uiPartOffset, uiDepth + uiInitTrDepth );
     
    60375948}
    60385949
     5950#if SVC_EXTENSION
    60395951#if REF_IDX_ME_ZEROMV
    60405952Void TEncSearch::xPatternSearchFracDIFMv0(TComDataCU* pcCU,
     
    62056117}
    62066118#endif
     6119#endif //SVC_EXTENSION
    62076120
    62086121//! \}
  • trunk/source/Lib/TLibEncoder/TEncSearch.h

    r540 r595  
    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 *
     
    9797  TEncCfg*        m_pcEncCfg;
    9898 
    99 #if SVC_EXTENSION
    100   TEncTop**       m_ppcTEncTop;
    101 #endif
    102  
    10399  // interface to classes
    104100  TComTrQuant*    m_pcTrQuant;
     
    118114  TEncSbac***     m_pppcRDSbacCoder;
    119115  TEncSbac*       m_pcRDGoOnSbacCoder;
    120   Bool            m_bUseSBACRD;
    121116  DistParam       m_cDistParam;
    122117 
     
    130125  UInt            m_auiMVPIdxCost[AMVP_MAX_NUM_CANDS+1][AMVP_MAX_NUM_CANDS+1]; //th array bounds
    131126
     127#if SVC_EXTENSION
     128  TEncTop**       m_ppcTEncTop;
    132129#if N0383_IL_CONSTRAINED_TILE_SETS_SEI
    133130  Bool            m_disableILP;
    134131#endif
     132#endif //SVC_EXTENAION
    135133
    136134public:
     
    207205                                );
    208206 
    209 #if (ENCODER_FAST_MODE)
    210   Bool predInterSearchILRUni    ( TComDataCU* pcCU, TComYuv*    pcOrgYuv, TComYuv*&   rpcPredYuv, TComYuv*&   rpcResiYuv, TComYuv*&   rpcRecoYuv, UInt        refLayerId );
    211 #endif
    212  
    213207  /// encode residual and compute rd-cost for inter mode
    214208  Void encodeResAndCalcRdInterCU( TComDataCU* pcCU,
     
    226220  Void IPCMSearch (TComDataCU* pcCU, TComYuv* pcOrgYuv, TComYuv*& rpcPredYuv, TComYuv*& rpcResiYuv, TComYuv*& rpcRecoYuv );
    227221
     222#if SVC_EXTENSION
     223#if (ENCODER_FAST_MODE)
     224  Bool predInterSearchILRUni    ( TComDataCU* pcCU, TComYuv*    pcOrgYuv, TComYuv*&   rpcPredYuv, TComYuv*&   rpcResiYuv, TComYuv*&   rpcRecoYuv, UInt        refLayerId );
     225#endif 
    228226#if N0383_IL_CONSTRAINED_TILE_SETS_SEI
    229227  Void setDisableILP(Bool a) {m_disableILP = a;}
    230228#endif
     229#endif //SVC_EXTENSION
    231230
    232231protected:
     
    453452                                   ,Bool biPred
    454453                                   );
     454 
     455  Void xExtDIFUpSamplingH( TComPattern* pcPattern, Bool biPred  );
     456  Void xExtDIFUpSamplingQ( TComPattern* pcPatternKey, TComMv halfPelRef, Bool biPred );
     457 
     458  // -------------------------------------------------------------------------------------------------------------------
     459  // T & Q & Q-1 & T-1
     460  // -------------------------------------------------------------------------------------------------------------------
     461 
     462  Void xEncodeResidualQT( TComDataCU* pcCU, UInt uiAbsPartIdx, const UInt uiDepth, Bool bSubdivAndCbf, TextType eType );
     463  Void xEstimateResidualQT( TComDataCU* pcCU, UInt uiQuadrant, UInt uiAbsPartIdx, UInt absTUPartIdx,TComYuv* pcResi, const UInt uiDepth, Double &rdCost, UInt &ruiBits, UInt &ruiDist, UInt *puiZeroDist );
     464  Void xSetResidualQTData( TComDataCU* pcCU, UInt uiQuadrant, UInt uiAbsPartIdx,UInt absTUPartIdx, TComYuv* pcResi, UInt uiDepth, Bool bSpatial );
     465 
     466  UInt  xModeBitsIntra ( TComDataCU* pcCU, UInt uiMode, UInt uiPU, UInt uiPartOffset, UInt uiDepth, UInt uiInitTrDepth );
     467  UInt  xUpdateCandList( UInt uiMode, Double uiCost, UInt uiFastCandNum, UInt * CandModeList, Double * CandCostList );
     468 
     469  // -------------------------------------------------------------------------------------------------------------------
     470  // compute symbol bits
     471  // -------------------------------------------------------------------------------------------------------------------
     472 
     473  Void xAddSymbolBitsInter        ( TComDataCU*   pcCU,
     474                                   UInt          uiQp,
     475                                   UInt          uiTrMode,
     476                                   UInt&         ruiBits,
     477                                   TComYuv*&     rpcYuvRec,
     478                                   TComYuv*      pcYuvPred,
     479                                   TComYuv*&     rpcYuvResi );
     480 
     481  Void  setWpScalingDistParam( TComDataCU* pcCU, Int iRefIdx, RefPicList eRefPicListCur );
     482  inline  Void  setDistParamComp( UInt uiComp )  { m_cDistParam.uiComp = uiComp; }
     483
     484#if SVC_EXTENSION
    455485#if REF_IDX_ME_ZEROMV
    456486  Void xPatternSearchFracDIFMv0  ( TComDataCU*   pcCU,
     
    464494                                   Bool          biPred );
    465495#endif
    466   Void xExtDIFUpSamplingH( TComPattern* pcPattern, Bool biPred  );
    467   Void xExtDIFUpSamplingQ( TComPattern* pcPatternKey, TComMv halfPelRef, Bool biPred );
    468  
    469   // -------------------------------------------------------------------------------------------------------------------
    470   // T & Q & Q-1 & T-1
    471   // -------------------------------------------------------------------------------------------------------------------
    472  
    473   Void xEncodeResidualQT( TComDataCU* pcCU, UInt uiAbsPartIdx, const UInt uiDepth, Bool bSubdivAndCbf, TextType eType );
    474   Void xEstimateResidualQT( TComDataCU* pcCU, UInt uiQuadrant, UInt uiAbsPartIdx, UInt absTUPartIdx,TComYuv* pcResi, const UInt uiDepth, Double &rdCost, UInt &ruiBits, UInt &ruiDist, UInt *puiZeroDist );
    475   Void xSetResidualQTData( TComDataCU* pcCU, UInt uiQuadrant, UInt uiAbsPartIdx,UInt absTUPartIdx, TComYuv* pcResi, UInt uiDepth, Bool bSpatial );
    476  
    477   UInt  xModeBitsIntra ( TComDataCU* pcCU, UInt uiMode, UInt uiPU, UInt uiPartOffset, UInt uiDepth, UInt uiInitTrDepth );
    478   UInt  xUpdateCandList( UInt uiMode, Double uiCost, UInt uiFastCandNum, UInt * CandModeList, Double * CandCostList );
    479  
    480   // -------------------------------------------------------------------------------------------------------------------
    481   // compute symbol bits
    482   // -------------------------------------------------------------------------------------------------------------------
    483  
    484   Void xAddSymbolBitsInter        ( TComDataCU*   pcCU,
    485                                    UInt          uiQp,
    486                                    UInt          uiTrMode,
    487                                    UInt&         ruiBits,
    488                                    TComYuv*&     rpcYuvRec,
    489                                    TComYuv*      pcYuvPred,
    490                                    TComYuv*&     rpcYuvResi );
    491  
    492   Void  setWpScalingDistParam( TComDataCU* pcCU, Int iRefIdx, RefPicList eRefPicListCur );
    493   inline  Void  setDistParamComp( UInt uiComp )  { m_cDistParam.uiComp = uiComp; }
    494  
     496#endif //SVC_EXTENSION 
     497
    495498};// END CLASS DEFINITION TEncSearch
    496499
  • trunk/source/Lib/TLibEncoder/TEncSlice.cpp

    r588 r595  
    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 *
     
    254254
    255255  eSliceType=B_SLICE;
    256   eSliceType = (pocLast == 0 || pocCurr % m_pcCfg->getIntraPeriod() == 0 || m_pcGOPEncoder->getGOPSize() == 0) ? I_SLICE : eSliceType;
     256  eSliceType = (pocLast == 0 || (pocCurr - isField) % m_pcCfg->getIntraPeriod() == 0 || m_pcGOPEncoder->getGOPSize() == 0) ? I_SLICE : eSliceType;
    257257
    258258  rpcSlice->setSliceType    ( eSliceType );
     
    280280  {
    281281#if REPN_FORMAT_IN_VPS
    282     if (!(( m_pcCfg->getMaxDeltaQP() == 0 ) && (dQP == -rpcSlice->getQpBDOffsetY() ) && (rpcSlice->getSPS()->getUseLossless())))
     282    if (!(( m_pcCfg->getMaxDeltaQP() == 0 ) && (dQP == -rpcSlice->getQpBDOffsetY() ) && (rpcSlice->getPPS()->getTransquantBypassEnableFlag())))
    283283#else
    284     if (!(( m_pcCfg->getMaxDeltaQP() == 0 ) && (dQP == -rpcSlice->getSPS()->getQpBDOffsetY() ) && (rpcSlice->getSPS()->getUseLossless())))
     284    if (!(( m_pcCfg->getMaxDeltaQP() == 0 ) && (dQP == -rpcSlice->getSPS()->getQpBDOffsetY() ) && (rpcSlice->getPPS()->getTransquantBypassEnableFlag())))
    285285#endif
    286286    {
     
    423423#if HB_LAMBDA_FOR_LDC
    424424  // restore original slice type
    425   eSliceType = (pocLast == 0 || pocCurr % m_pcCfg->getIntraPeriod() == 0 || m_pcGOPEncoder->getGOPSize() == 0) ? I_SLICE : eSliceType;
     425  eSliceType = (pocLast == 0 || (pocCurr - isField) % m_pcCfg->getIntraPeriod() == 0 || m_pcGOPEncoder->getGOPSize() == 0) ? I_SLICE : eSliceType;
    426426
    427427#if SVC_EXTENSION
     
    785785
    786786  // set entropy coder
    787   if( m_pcCfg->getUseSBACRD() )
    788   {
    789     m_pcSbacCoder->init( m_pcBinCABAC );
    790     m_pcEntropyCoder->setEntropyCoder   ( m_pcSbacCoder, pcSlice );
    791     m_pcEntropyCoder->resetEntropy      ();
    792     m_pppcRDSbacCoder[0][CI_CURR_BEST]->load(m_pcSbacCoder);
    793     pppcRDSbacCoder = (TEncBinCABAC *) m_pppcRDSbacCoder[0][CI_CURR_BEST]->getEncBinIf();
    794     pppcRDSbacCoder->setBinCountingEnableFlag( false );
    795     pppcRDSbacCoder->setBinsCoded( 0 );
    796   }
    797   else
    798   {
    799     m_pcEntropyCoder->setEntropyCoder ( m_pcCavlcCoder, pcSlice );
    800     m_pcEntropyCoder->resetEntropy      ();
    801     m_pcEntropyCoder->setBitstream    ( m_pcBitCounter );
    802   }
    803 
     787  m_pcSbacCoder->init( m_pcBinCABAC );
     788  m_pcEntropyCoder->setEntropyCoder   ( m_pcSbacCoder, pcSlice );
     789  m_pcEntropyCoder->resetEntropy      ();
     790  m_pppcRDSbacCoder[0][CI_CURR_BEST]->load(m_pcSbacCoder);
     791  pppcRDSbacCoder = (TEncBinCABAC *) m_pppcRDSbacCoder[0][CI_CURR_BEST]->getEncBinIf();
     792  pppcRDSbacCoder->setBinCountingEnableFlag( false );
     793  pppcRDSbacCoder->setBinsCoded( 0 );
     794 
    804795  //------------------------------------------------------------------------------
    805796  //  Weighted Prediction parameters estimation.
     
    854845  UInt uiTilesAcross  = 0;
    855846
    856   if( m_pcCfg->getUseSBACRD() )
    857   {
    858     iNumSubstreams = pcSlice->getPPS()->getNumSubstreams();
    859     uiTilesAcross = rpcPic->getPicSym()->getNumColumnsMinus1()+1;
    860     delete[] m_pcBufferSbacCoders;
    861     delete[] m_pcBufferBinCoderCABACs;
    862     m_pcBufferSbacCoders     = new TEncSbac    [uiTilesAcross];
    863     m_pcBufferBinCoderCABACs = new TEncBinCABAC[uiTilesAcross];
    864     for (Int ui = 0; ui < uiTilesAcross; ui++)
    865     {
    866       m_pcBufferSbacCoders[ui].init( &m_pcBufferBinCoderCABACs[ui] );
    867     }
    868     for (UInt ui = 0; ui < uiTilesAcross; ui++)
    869     {
    870       m_pcBufferSbacCoders[ui].load(m_pppcRDSbacCoder[0][CI_CURR_BEST]);  //init. state
    871     }
    872 
    873     for ( UInt ui = 0 ; ui < iNumSubstreams ; ui++ ) //init all sbac coders for RD optimization
    874     {
    875       ppppcRDSbacCoders[ui][0][CI_CURR_BEST]->load(m_pppcRDSbacCoder[0][CI_CURR_BEST]);
    876     }
    877   }
    878   //if( m_pcCfg->getUseSBACRD() )
    879   {
    880     delete[] m_pcBufferLowLatSbacCoders;
    881     delete[] m_pcBufferLowLatBinCoderCABACs;
    882     m_pcBufferLowLatSbacCoders     = new TEncSbac    [uiTilesAcross];
    883     m_pcBufferLowLatBinCoderCABACs = new TEncBinCABAC[uiTilesAcross];
    884     for (Int ui = 0; ui < uiTilesAcross; ui++)
    885     {
    886       m_pcBufferLowLatSbacCoders[ui].init( &m_pcBufferLowLatBinCoderCABACs[ui] );
    887     }
    888     for (UInt ui = 0; ui < uiTilesAcross; ui++)
    889       m_pcBufferLowLatSbacCoders[ui].load(m_pppcRDSbacCoder[0][CI_CURR_BEST]);  //init. state
    890   }
     847  iNumSubstreams = pcSlice->getPPS()->getNumSubstreams();
     848  uiTilesAcross = rpcPic->getPicSym()->getNumColumnsMinus1()+1;
     849  delete[] m_pcBufferSbacCoders;
     850  delete[] m_pcBufferBinCoderCABACs;
     851  m_pcBufferSbacCoders     = new TEncSbac    [uiTilesAcross];
     852  m_pcBufferBinCoderCABACs = new TEncBinCABAC[uiTilesAcross];
     853  for (Int ui = 0; ui < uiTilesAcross; ui++)
     854  {
     855    m_pcBufferSbacCoders[ui].init( &m_pcBufferBinCoderCABACs[ui] );
     856  }
     857  for (UInt ui = 0; ui < uiTilesAcross; ui++)
     858  {
     859    m_pcBufferSbacCoders[ui].load(m_pppcRDSbacCoder[0][CI_CURR_BEST]);  //init. state
     860  }
     861
     862  for ( UInt ui = 0 ; ui < iNumSubstreams ; ui++ ) //init all sbac coders for RD optimization
     863  {
     864    ppppcRDSbacCoders[ui][0][CI_CURR_BEST]->load(m_pppcRDSbacCoder[0][CI_CURR_BEST]);
     865  }
     866
     867  delete[] m_pcBufferLowLatSbacCoders;
     868  delete[] m_pcBufferLowLatBinCoderCABACs;
     869  m_pcBufferLowLatSbacCoders     = new TEncSbac    [uiTilesAcross];
     870  m_pcBufferLowLatBinCoderCABACs = new TEncBinCABAC[uiTilesAcross];
     871  for (Int ui = 0; ui < uiTilesAcross; ui++)
     872  {
     873    m_pcBufferLowLatSbacCoders[ui].init( &m_pcBufferLowLatBinCoderCABACs[ui] );
     874  }
     875  for (UInt ui = 0; ui < uiTilesAcross; ui++)
     876    m_pcBufferLowLatSbacCoders[ui].load(m_pppcRDSbacCoder[0][CI_CURR_BEST]);  //init. state
     877
    891878  UInt uiWidthInLCUs  = rpcPic->getPicSym()->getFrameWidthInCU();
    892879  //UInt uiHeightInLCUs = rpcPic->getPicSym()->getFrameHeightInCU();
     
    944931
    945932    // inherit from TR if necessary, select substream to use.
    946     if( m_pcCfg->getUseSBACRD() )
    947     {
    948       uiTileCol = rpcPic->getPicSym()->getTileIdxMap(uiCUAddr) % (rpcPic->getPicSym()->getNumColumnsMinus1()+1); // what column of tiles are we in?
    949       uiTileStartLCU = rpcPic->getPicSym()->getTComTile(rpcPic->getPicSym()->getTileIdxMap(uiCUAddr))->getFirstCUAddr();
    950       uiTileLCUX = uiTileStartLCU % uiWidthInLCUs;
    951       //UInt uiSliceStartLCU = pcSlice->getSliceCurStartCUAddr();
    952       uiCol     = uiCUAddr % uiWidthInLCUs;
    953       uiLin     = uiCUAddr / uiWidthInLCUs;
    954       if (pcSlice->getPPS()->getNumSubstreams() > 1)
    955       {
    956         // independent tiles => substreams are "per tile".  iNumSubstreams has already been multiplied.
    957         Int iNumSubstreamsPerTile = iNumSubstreams/rpcPic->getPicSym()->getNumTiles();
    958         uiSubStrm = rpcPic->getPicSym()->getTileIdxMap(uiCUAddr)*iNumSubstreamsPerTile
    959                       + uiLin%iNumSubstreamsPerTile;
     933    uiTileCol = rpcPic->getPicSym()->getTileIdxMap(uiCUAddr) % (rpcPic->getPicSym()->getNumColumnsMinus1()+1); // what column of tiles are we in?
     934    uiTileStartLCU = rpcPic->getPicSym()->getTComTile(rpcPic->getPicSym()->getTileIdxMap(uiCUAddr))->getFirstCUAddr();
     935    uiTileLCUX = uiTileStartLCU % uiWidthInLCUs;
     936    //UInt uiSliceStartLCU = pcSlice->getSliceCurStartCUAddr();
     937    uiCol     = uiCUAddr % uiWidthInLCUs;
     938    uiLin     = uiCUAddr / uiWidthInLCUs;
     939    if (pcSlice->getPPS()->getNumSubstreams() > 1)
     940    {
     941      // independent tiles => substreams are "per tile".  iNumSubstreams has already been multiplied.
     942      Int iNumSubstreamsPerTile = iNumSubstreams/rpcPic->getPicSym()->getNumTiles();
     943      uiSubStrm = rpcPic->getPicSym()->getTileIdxMap(uiCUAddr)*iNumSubstreamsPerTile
     944          + uiLin%iNumSubstreamsPerTile;
     945    }
     946    else
     947    {
     948      // dependent tiles => substreams are "per frame".
     949      uiSubStrm = uiLin % iNumSubstreams;
     950    }
     951    if ( ((pcSlice->getPPS()->getNumSubstreams() > 1) || depSliceSegmentsEnabled ) && (uiCol == uiTileLCUX) && m_pcCfg->getWaveFrontsynchro())
     952    {
     953      // We'll sync if the TR is available.
     954      TComDataCU *pcCUUp = pcCU->getCUAbove();
     955      UInt uiWidthInCU = rpcPic->getFrameWidthInCU();
     956      UInt uiMaxParts = 1<<(pcSlice->getSPS()->getMaxCUDepth()<<1);
     957      TComDataCU *pcCUTR = NULL;
     958      if ( pcCUUp && ((uiCUAddr%uiWidthInCU+1) < uiWidthInCU)  )
     959      {
     960        pcCUTR = rpcPic->getCU( uiCUAddr - uiWidthInCU + 1 );
     961      }
     962      if ( ((pcCUTR==NULL) || (pcCUTR->getSlice()==NULL) ||
     963          (pcCUTR->getSCUAddr()+uiMaxParts-1 < pcSlice->getSliceCurStartCUAddr()) ||
     964          ((rpcPic->getPicSym()->getTileIdxMap( pcCUTR->getAddr() ) != rpcPic->getPicSym()->getTileIdxMap(uiCUAddr)))
     965      )
     966      )
     967      {
     968        // TR not available.
    960969      }
    961970      else
    962971      {
    963         // dependent tiles => substreams are "per frame".
    964         uiSubStrm = uiLin % iNumSubstreams;
    965       }
    966       if ( ((pcSlice->getPPS()->getNumSubstreams() > 1) || depSliceSegmentsEnabled ) && (uiCol == uiTileLCUX) && m_pcCfg->getWaveFrontsynchro())
    967       {
    968         // We'll sync if the TR is available.
    969         TComDataCU *pcCUUp = pcCU->getCUAbove();
    970         UInt uiWidthInCU = rpcPic->getFrameWidthInCU();
    971         UInt uiMaxParts = 1<<(pcSlice->getSPS()->getMaxCUDepth()<<1);
    972         TComDataCU *pcCUTR = NULL;
    973         if ( pcCUUp && ((uiCUAddr%uiWidthInCU+1) < uiWidthInCU)  )
    974         {
    975           pcCUTR = rpcPic->getCU( uiCUAddr - uiWidthInCU + 1 );
    976         }
    977         if ( ((pcCUTR==NULL) || (pcCUTR->getSlice()==NULL) ||
    978              (pcCUTR->getSCUAddr()+uiMaxParts-1 < pcSlice->getSliceCurStartCUAddr()) ||
    979              ((rpcPic->getPicSym()->getTileIdxMap( pcCUTR->getAddr() ) != rpcPic->getPicSym()->getTileIdxMap(uiCUAddr)))
    980              )
    981            )
    982         {
    983           // TR not available.
    984         }
    985         else
    986         {
    987           // TR is available, we use it.
    988           ppppcRDSbacCoders[uiSubStrm][0][CI_CURR_BEST]->loadContexts( &m_pcBufferSbacCoders[uiTileCol] );
    989         }
    990       }
    991       m_pppcRDSbacCoder[0][CI_CURR_BEST]->load( ppppcRDSbacCoders[uiSubStrm][0][CI_CURR_BEST] ); //this load is used to simplify the code
    992     }
     972        // TR is available, we use it.
     973        ppppcRDSbacCoders[uiSubStrm][0][CI_CURR_BEST]->loadContexts( &m_pcBufferSbacCoders[uiTileCol] );
     974      }
     975    }
     976    m_pppcRDSbacCoder[0][CI_CURR_BEST]->load( ppppcRDSbacCoders[uiSubStrm][0][CI_CURR_BEST] ); //this load is used to simplify the code
    993977
    994978    // reset the entropy coder
     
    1008992      m_pcEntropyCoder->setEntropyCoder     ( m_pcSbacCoder, pcSlice );
    1009993    }
    1010     // if RD based on SBAC is used
    1011     if( m_pcCfg->getUseSBACRD() )
    1012     {
    1013       // set go-on entropy coder
    1014       m_pcEntropyCoder->setEntropyCoder ( m_pcRDGoOnSbacCoder, pcSlice );
    1015       m_pcEntropyCoder->setBitstream( &pcBitCounters[uiSubStrm] );
    1016 
    1017       ((TEncBinCABAC*)m_pcRDGoOnSbacCoder->getEncBinIf())->setBinCountingEnableFlag(true);
    1018 
    1019       Double oldLambda = m_pcRdCost->getLambda();
    1020       if ( m_pcCfg->getUseRateCtrl() )
    1021       {
    1022         Int estQP        = pcSlice->getSliceQp();
    1023         Double estLambda = -1.0;
    1024         Double bpp       = -1.0;
    1025 
    1026         if ( ( rpcPic->getSlice( 0 )->getSliceType() == I_SLICE && m_pcCfg->getForceIntraQP() ) || !m_pcCfg->getLCULevelRC() )
     994
     995    // set go-on entropy coder
     996    m_pcEntropyCoder->setEntropyCoder ( m_pcRDGoOnSbacCoder, pcSlice );
     997    m_pcEntropyCoder->setBitstream( &pcBitCounters[uiSubStrm] );
     998
     999    ((TEncBinCABAC*)m_pcRDGoOnSbacCoder->getEncBinIf())->setBinCountingEnableFlag(true);
     1000
     1001    Double oldLambda = m_pcRdCost->getLambda();
     1002    if ( m_pcCfg->getUseRateCtrl() )
     1003    {
     1004      Int estQP        = pcSlice->getSliceQp();
     1005      Double estLambda = -1.0;
     1006      Double bpp       = -1.0;
     1007
     1008      if ( ( rpcPic->getSlice( 0 )->getSliceType() == I_SLICE && m_pcCfg->getForceIntraQP() ) || !m_pcCfg->getLCULevelRC() )
     1009      {
     1010        estQP = pcSlice->getSliceQp();
     1011      }
     1012      else
     1013      {
     1014        bpp = m_pcRateCtrl->getRCPic()->getLCUTargetBpp(pcSlice->getSliceType());
     1015        if ( rpcPic->getSlice( 0 )->getSliceType() == I_SLICE)
    10271016        {
    1028           estQP = pcSlice->getSliceQp();
     1017          estLambda = m_pcRateCtrl->getRCPic()->getLCUEstLambdaAndQP(bpp, pcSlice->getSliceQp(), &estQP);
    10291018        }
    10301019        else
    10311020        {
    1032           bpp = m_pcRateCtrl->getRCPic()->getLCUTargetBpp(pcSlice->getSliceType());
    1033           if ( rpcPic->getSlice( 0 )->getSliceType() == I_SLICE)
    1034           {
    1035             estLambda = m_pcRateCtrl->getRCPic()->getLCUEstLambdaAndQP(bpp, pcSlice->getSliceQp(), &estQP);
    1036           }
    1037           else
    1038           {
    1039             estLambda = m_pcRateCtrl->getRCPic()->getLCUEstLambda( bpp );
    1040             estQP     = m_pcRateCtrl->getRCPic()->getLCUEstQP    ( estLambda, pcSlice->getSliceQp() );
    1041           }
     1021          estLambda = m_pcRateCtrl->getRCPic()->getLCUEstLambda( bpp );
     1022          estQP     = m_pcRateCtrl->getRCPic()->getLCUEstQP    ( estLambda, pcSlice->getSliceQp() );
     1023        }
    10421024
    10431025#if REPN_FORMAT_IN_VPS
     
    10561038          m_pcTrQuant->setLambda( estLambda );
    10571039#endif
     1040      }
     1041
     1042      m_pcRateCtrl->setRCQP( estQP );
     1043      pcCU->getSlice()->setSliceQpBase( estQP );
     1044    }
     1045
     1046    // run CU encoder
     1047    m_pcCuEncoder->compressCU( pcCU );
     1048
     1049    // restore entropy coder to an initial stage
     1050    m_pcEntropyCoder->setEntropyCoder ( m_pppcRDSbacCoder[0][CI_CURR_BEST], pcSlice );
     1051    m_pcEntropyCoder->setBitstream( &pcBitCounters[uiSubStrm] );
     1052    m_pcCuEncoder->setBitCounter( &pcBitCounters[uiSubStrm] );
     1053    m_pcBitCounter = &pcBitCounters[uiSubStrm];
     1054    pppcRDSbacCoder->setBinCountingEnableFlag( true );
     1055    m_pcBitCounter->resetBits();
     1056    pppcRDSbacCoder->setBinsCoded( 0 );
     1057    m_pcCuEncoder->encodeCU( pcCU );
     1058
     1059    pppcRDSbacCoder->setBinCountingEnableFlag( false );
     1060    if (m_pcCfg->getSliceMode()==FIXED_NUMBER_OF_BYTES && ( ( pcSlice->getSliceBits() + m_pcEntropyCoder->getNumberOfWrittenBits() ) ) > m_pcCfg->getSliceArgument()<<3)
     1061    {
     1062      pcSlice->setNextSlice( true );
     1063      break;
     1064    }
     1065    if (m_pcCfg->getSliceSegmentMode()==FIXED_NUMBER_OF_BYTES && pcSlice->getSliceSegmentBits()+m_pcEntropyCoder->getNumberOfWrittenBits() > (m_pcCfg->getSliceSegmentArgument() << 3) &&pcSlice->getSliceCurEndCUAddr()!=pcSlice->getSliceSegmentCurEndCUAddr())
     1066    {
     1067      pcSlice->setNextSliceSegment( true );
     1068      break;
     1069    }
     1070
     1071    ppppcRDSbacCoders[uiSubStrm][0][CI_CURR_BEST]->load( m_pppcRDSbacCoder[0][CI_CURR_BEST] );
     1072    //Store probabilties of second LCU in line into buffer
     1073    if ( ( uiCol == uiTileLCUX+1) && (depSliceSegmentsEnabled || (pcSlice->getPPS()->getNumSubstreams() > 1)) && m_pcCfg->getWaveFrontsynchro())
     1074    {
     1075      m_pcBufferSbacCoders[uiTileCol].loadContexts(ppppcRDSbacCoders[uiSubStrm][0][CI_CURR_BEST]);
     1076    }
     1077
     1078    if ( m_pcCfg->getUseRateCtrl() )
     1079    {
     1080
     1081      Int actualQP        = g_RCInvalidQPValue;
     1082      Double actualLambda = m_pcRdCost->getLambda();
     1083      Int actualBits      = pcCU->getTotalBits();
     1084      Int numberOfEffectivePixels    = 0;
     1085      for ( Int idx = 0; idx < rpcPic->getNumPartInCU(); idx++ )
     1086      {
     1087        if ( pcCU->getPredictionMode( idx ) != MODE_NONE && ( !pcCU->isSkipped( idx ) ) )
     1088        {
     1089          numberOfEffectivePixels = numberOfEffectivePixels + 16;
     1090          break;
    10581091        }
    1059 
    1060         m_pcRateCtrl->setRCQP( estQP );
    1061         pcCU->getSlice()->setSliceQpBase( estQP );
    1062       }
    1063 
    1064       // run CU encoder
    1065       m_pcCuEncoder->compressCU( pcCU );
    1066 
    1067       // restore entropy coder to an initial stage
    1068       m_pcEntropyCoder->setEntropyCoder ( m_pppcRDSbacCoder[0][CI_CURR_BEST], pcSlice );
    1069       m_pcEntropyCoder->setBitstream( &pcBitCounters[uiSubStrm] );
    1070       m_pcCuEncoder->setBitCounter( &pcBitCounters[uiSubStrm] );
    1071       m_pcBitCounter = &pcBitCounters[uiSubStrm];
    1072       pppcRDSbacCoder->setBinCountingEnableFlag( true );
    1073       m_pcBitCounter->resetBits();
    1074       pppcRDSbacCoder->setBinsCoded( 0 );
    1075       m_pcCuEncoder->encodeCU( pcCU );
    1076 
    1077       pppcRDSbacCoder->setBinCountingEnableFlag( false );
    1078       if (m_pcCfg->getSliceMode()==FIXED_NUMBER_OF_BYTES && ( ( pcSlice->getSliceBits() + m_pcEntropyCoder->getNumberOfWrittenBits() ) ) > m_pcCfg->getSliceArgument()<<3)
    1079       {
    1080         pcSlice->setNextSlice( true );
    1081         break;
    1082       }
    1083       if (m_pcCfg->getSliceSegmentMode()==FIXED_NUMBER_OF_BYTES && pcSlice->getSliceSegmentBits()+m_pcEntropyCoder->getNumberOfWrittenBits() > (m_pcCfg->getSliceSegmentArgument() << 3) &&pcSlice->getSliceCurEndCUAddr()!=pcSlice->getSliceSegmentCurEndCUAddr())
    1084       {
    1085         pcSlice->setNextSliceSegment( true );
    1086         break;
    1087       }
    1088       if( m_pcCfg->getUseSBACRD() )
    1089       {
    1090          ppppcRDSbacCoders[uiSubStrm][0][CI_CURR_BEST]->load( m_pppcRDSbacCoder[0][CI_CURR_BEST] );
    1091 
    1092          //Store probabilties of second LCU in line into buffer
    1093          if ( ( uiCol == uiTileLCUX+1) && (depSliceSegmentsEnabled || (pcSlice->getPPS()->getNumSubstreams() > 1)) && m_pcCfg->getWaveFrontsynchro())
    1094         {
    1095           m_pcBufferSbacCoders[uiTileCol].loadContexts(ppppcRDSbacCoders[uiSubStrm][0][CI_CURR_BEST]);
    1096         }
    1097       }
    1098 
    1099       if ( m_pcCfg->getUseRateCtrl() )
    1100       {
    1101 
    1102         Int actualQP        = g_RCInvalidQPValue;
    1103         Double actualLambda = m_pcRdCost->getLambda();
    1104         Int actualBits      = pcCU->getTotalBits();
    1105         Int numberOfEffectivePixels    = 0;
    1106         for ( Int idx = 0; idx < rpcPic->getNumPartInCU(); idx++ )
    1107         {
    1108           if ( pcCU->getPredictionMode( idx ) != MODE_NONE && ( !pcCU->isSkipped( idx ) ) )
    1109           {
    1110             numberOfEffectivePixels = numberOfEffectivePixels + 16;
    1111             break;
    1112           }
    1113         }
    1114 
    1115         if ( numberOfEffectivePixels == 0 )
    1116         {
    1117           actualQP = g_RCInvalidQPValue;
    1118         }
    1119         else
    1120         {
    1121           actualQP = pcCU->getQP( 0 );
    1122         }
    1123         m_pcRdCost->setLambda(oldLambda);
    1124 
    1125         m_pcRateCtrl->getRCPic()->updateAfterLCU( m_pcRateCtrl->getRCPic()->getLCUCoded(), actualBits, actualQP, actualLambda,
    1126           pcCU->getSlice()->getSliceType() == I_SLICE ? 0 : m_pcCfg->getLCULevelRC() );
    1127       }
    1128     }
    1129     // other case: encodeCU is not called
    1130     else
    1131     {
    1132       m_pcCuEncoder->compressCU( pcCU );
    1133       m_pcCuEncoder->encodeCU( pcCU );
    1134       if (m_pcCfg->getSliceMode()==FIXED_NUMBER_OF_BYTES && ( ( pcSlice->getSliceBits()+ m_pcEntropyCoder->getNumberOfWrittenBits() ) ) > m_pcCfg->getSliceArgument()<<3)
    1135       {
    1136         pcSlice->setNextSlice( true );
    1137         break;
    1138       }
    1139       if (m_pcCfg->getSliceSegmentMode()==FIXED_NUMBER_OF_BYTES && pcSlice->getSliceSegmentBits()+ m_pcEntropyCoder->getNumberOfWrittenBits()> m_pcCfg->getSliceSegmentArgument()<<3 &&pcSlice->getSliceCurEndCUAddr()!=pcSlice->getSliceSegmentCurEndCUAddr())
    1140       {
    1141         pcSlice->setNextSliceSegment( true );
    1142         break;
    1143       }
     1092      }
     1093
     1094      if ( numberOfEffectivePixels == 0 )
     1095      {
     1096        actualQP = g_RCInvalidQPValue;
     1097      }
     1098      else
     1099      {
     1100        actualQP = pcCU->getQP( 0 );
     1101      }
     1102      m_pcRdCost->setLambda(oldLambda);
     1103
     1104      m_pcRateCtrl->getRCPic()->updateAfterLCU( m_pcRateCtrl->getRCPic()->getLCUCoded(), actualBits, actualQP, actualLambda,
     1105        pcCU->getSlice()->getSliceType() == I_SLICE ? 0 : m_pcCfg->getLCULevelRC() );
    11441106    }
    11451107
     
    11511113  {
    11521114    pcSlice->setNextSlice( true );
     1115  }
     1116  if(m_pcCfg->getSliceMode()==FIXED_NUMBER_OF_BYTES || m_pcCfg->getSliceSegmentMode()==FIXED_NUMBER_OF_BYTES)
     1117  {
     1118    if(pcSlice->getSliceCurEndCUAddr()<=pcSlice->getSliceSegmentCurEndCUAddr())
     1119    {
     1120       pcSlice->setNextSlice( true );
     1121    }
     1122    else
     1123    {
     1124       pcSlice->setNextSliceSegment( true );
     1125    }
    11531126  }
    11541127  if( depSliceSegmentsEnabled )
     
    12691242       uiCUAddr = rpcPic->getPicSym()->getCUOrderMap(++uiEncCUOrder) )
    12701243  {
    1271     if( m_pcCfg->getUseSBACRD() )
    1272     {
    1273       uiTileCol = rpcPic->getPicSym()->getTileIdxMap(uiCUAddr) % (rpcPic->getPicSym()->getNumColumnsMinus1()+1); // what column of tiles are we in?
    1274       uiTileStartLCU = rpcPic->getPicSym()->getTComTile(rpcPic->getPicSym()->getTileIdxMap(uiCUAddr))->getFirstCUAddr();
    1275       uiTileLCUX = uiTileStartLCU % uiWidthInLCUs;
    1276       //UInt uiSliceStartLCU = pcSlice->getSliceCurStartCUAddr();
    1277       uiCol     = uiCUAddr % uiWidthInLCUs;
    1278       uiLin     = uiCUAddr / uiWidthInLCUs;
    1279       if (pcSlice->getPPS()->getNumSubstreams() > 1)
    1280       {
    1281         // independent tiles => substreams are "per tile".  iNumSubstreams has already been multiplied.
    1282         Int iNumSubstreamsPerTile = iNumSubstreams/rpcPic->getPicSym()->getNumTiles();
    1283         uiSubStrm = rpcPic->getPicSym()->getTileIdxMap(uiCUAddr)*iNumSubstreamsPerTile
    1284                       + uiLin%iNumSubstreamsPerTile;
     1244    uiTileCol = rpcPic->getPicSym()->getTileIdxMap(uiCUAddr) % (rpcPic->getPicSym()->getNumColumnsMinus1()+1); // what column of tiles are we in?
     1245    uiTileStartLCU = rpcPic->getPicSym()->getTComTile(rpcPic->getPicSym()->getTileIdxMap(uiCUAddr))->getFirstCUAddr();
     1246    uiTileLCUX = uiTileStartLCU % uiWidthInLCUs;
     1247    //UInt uiSliceStartLCU = pcSlice->getSliceCurStartCUAddr();
     1248    uiCol     = uiCUAddr % uiWidthInLCUs;
     1249    uiLin     = uiCUAddr / uiWidthInLCUs;
     1250    if (pcSlice->getPPS()->getNumSubstreams() > 1)
     1251    {
     1252      // independent tiles => substreams are "per tile".  iNumSubstreams has already been multiplied.
     1253      Int iNumSubstreamsPerTile = iNumSubstreams/rpcPic->getPicSym()->getNumTiles();
     1254      uiSubStrm = rpcPic->getPicSym()->getTileIdxMap(uiCUAddr)*iNumSubstreamsPerTile
     1255          + uiLin%iNumSubstreamsPerTile;
     1256    }
     1257    else
     1258    {
     1259      // dependent tiles => substreams are "per frame".
     1260      uiSubStrm = uiLin % iNumSubstreams;
     1261    }
     1262
     1263    m_pcEntropyCoder->setBitstream( &pcSubstreams[uiSubStrm] );
     1264    // Synchronize cabac probabilities with upper-right LCU if it's available and we're at the start of a line.
     1265    if (((pcSlice->getPPS()->getNumSubstreams() > 1) || depSliceSegmentsEnabled) && (uiCol == uiTileLCUX) && m_pcCfg->getWaveFrontsynchro())
     1266    {
     1267      // We'll sync if the TR is available.
     1268      TComDataCU *pcCUUp = rpcPic->getCU( uiCUAddr )->getCUAbove();
     1269      UInt uiWidthInCU = rpcPic->getFrameWidthInCU();
     1270      UInt uiMaxParts = 1<<(pcSlice->getSPS()->getMaxCUDepth()<<1);
     1271      TComDataCU *pcCUTR = NULL;
     1272      if ( pcCUUp && ((uiCUAddr%uiWidthInCU+1) < uiWidthInCU)  )
     1273      {
     1274        pcCUTR = rpcPic->getCU( uiCUAddr - uiWidthInCU + 1 );
     1275      }
     1276      if ( (true/*bEnforceSliceRestriction*/ &&
     1277          ((pcCUTR==NULL) || (pcCUTR->getSlice()==NULL) ||
     1278              (pcCUTR->getSCUAddr()+uiMaxParts-1 < pcSlice->getSliceCurStartCUAddr()) ||
     1279              ((rpcPic->getPicSym()->getTileIdxMap( pcCUTR->getAddr() ) != rpcPic->getPicSym()->getTileIdxMap(uiCUAddr)))
     1280          ))
     1281      )
     1282      {
     1283        // TR not available.
    12851284      }
    12861285      else
    12871286      {
    1288         // dependent tiles => substreams are "per frame".
    1289         uiSubStrm = uiLin % iNumSubstreams;
    1290       }
    1291 
    1292       m_pcEntropyCoder->setBitstream( &pcSubstreams[uiSubStrm] );
    1293       // Synchronize cabac probabilities with upper-right LCU if it's available and we're at the start of a line.
    1294       if (((pcSlice->getPPS()->getNumSubstreams() > 1) || depSliceSegmentsEnabled) && (uiCol == uiTileLCUX) && m_pcCfg->getWaveFrontsynchro())
    1295       {
    1296         // We'll sync if the TR is available.
    1297         TComDataCU *pcCUUp = rpcPic->getCU( uiCUAddr )->getCUAbove();
    1298         UInt uiWidthInCU = rpcPic->getFrameWidthInCU();
    1299         UInt uiMaxParts = 1<<(pcSlice->getSPS()->getMaxCUDepth()<<1);
    1300         TComDataCU *pcCUTR = NULL;
    1301         if ( pcCUUp && ((uiCUAddr%uiWidthInCU+1) < uiWidthInCU)  )
    1302         {
    1303           pcCUTR = rpcPic->getCU( uiCUAddr - uiWidthInCU + 1 );
    1304         }
    1305         if ( (true/*bEnforceSliceRestriction*/ &&
    1306              ((pcCUTR==NULL) || (pcCUTR->getSlice()==NULL) ||
    1307              (pcCUTR->getSCUAddr()+uiMaxParts-1 < pcSlice->getSliceCurStartCUAddr()) ||
    1308              ((rpcPic->getPicSym()->getTileIdxMap( pcCUTR->getAddr() ) != rpcPic->getPicSym()->getTileIdxMap(uiCUAddr)))
    1309              ))
    1310            )
    1311         {
    1312           // TR not available.
    1313         }
    1314         else
    1315         {
    1316           // TR is available, we use it.
    1317           pcSbacCoders[uiSubStrm].loadContexts( &m_pcBufferSbacCoders[uiTileCol] );
    1318         }
    1319       }
    1320       m_pcSbacCoder->load(&pcSbacCoders[uiSubStrm]);  //this load is used to simplify the code (avoid to change all the call to m_pcSbacCoder)
    1321     }
     1287        // TR is available, we use it.
     1288        pcSbacCoders[uiSubStrm].loadContexts( &m_pcBufferSbacCoders[uiTileCol] );
     1289      }
     1290    }
     1291    m_pcSbacCoder->load(&pcSbacCoders[uiSubStrm]);  //this load is used to simplify the code (avoid to change all the call to m_pcSbacCoder)
     1292
    13221293    // reset the entropy coder
    13231294    if( uiCUAddr == rpcPic->getPicSym()->getTComTile(rpcPic->getPicSym()->getTileIdxMap(uiCUAddr))->getFirstCUAddr() &&                                   // must be first CU of tile
     
    13601331
    13611332    TComDataCU*& pcCU = rpcPic->getCU( uiCUAddr );
    1362 #if HM_CLEANUP_SAO
    13631333    if ( pcSlice->getSPS()->getUseSAO() )
    13641334    {
     
    13891359      }
    13901360    }
    1391 #else
    1392     if ( pcSlice->getSPS()->getUseSAO() && (pcSlice->getSaoEnabledFlag()||pcSlice->getSaoEnabledFlagChroma()) )
    1393     {
    1394       SAOParam *saoParam = pcSlice->getPic()->getPicSym()->getSaoParam();
    1395       Int iNumCuInWidth     = saoParam->numCuInWidth;
    1396       Int iCUAddrInSlice    = uiCUAddr - rpcPic->getPicSym()->getCUOrderMap(pcSlice->getSliceCurStartCUAddr()/rpcPic->getNumPartInCU());
    1397       Int iCUAddrUpInSlice  = iCUAddrInSlice - iNumCuInWidth;
    1398       Int rx = uiCUAddr % iNumCuInWidth;
    1399       Int ry = uiCUAddr / iNumCuInWidth;
    1400       Int allowMergeLeft = 1;
    1401       Int allowMergeUp   = 1;
    1402       if (rx!=0)
    1403       {
    1404         if (rpcPic->getPicSym()->getTileIdxMap(uiCUAddr-1) != rpcPic->getPicSym()->getTileIdxMap(uiCUAddr))
    1405         {
    1406           allowMergeLeft = 0;
    1407         }
    1408       }
    1409       if (ry!=0)
    1410       {
    1411         if (rpcPic->getPicSym()->getTileIdxMap(uiCUAddr-iNumCuInWidth) != rpcPic->getPicSym()->getTileIdxMap(uiCUAddr))
    1412         {
    1413           allowMergeUp = 0;
    1414         }
    1415       }
    1416       Int addr = pcCU->getAddr();
    1417       allowMergeLeft = allowMergeLeft && (rx>0) && (iCUAddrInSlice!=0);
    1418       allowMergeUp = allowMergeUp && (ry>0) && (iCUAddrUpInSlice>=0);
    1419       if( saoParam->bSaoFlag[0] || saoParam->bSaoFlag[1] )
    1420       {
    1421         Int mergeLeft = saoParam->saoLcuParam[0][addr].mergeLeftFlag;
    1422         Int mergeUp = saoParam->saoLcuParam[0][addr].mergeUpFlag;
    1423         if (allowMergeLeft)
    1424         {
    1425           m_pcEntropyCoder->m_pcEntropyCoderIf->codeSaoMerge(mergeLeft);
    1426         }
    1427         else
    1428         {
    1429           mergeLeft = 0;
    1430         }
    1431         if(mergeLeft == 0)
    1432         {
    1433           if (allowMergeUp)
    1434           {
    1435             m_pcEntropyCoder->m_pcEntropyCoderIf->codeSaoMerge(mergeUp);
    1436           }
    1437           else
    1438           {
    1439             mergeUp = 0;
    1440           }
    1441           if(mergeUp == 0)
    1442           {
    1443             for (Int compIdx=0;compIdx<3;compIdx++)
    1444             {
    1445             if( (compIdx == 0 && saoParam->bSaoFlag[0]) || (compIdx > 0 && saoParam->bSaoFlag[1]))
    1446               {
    1447                 m_pcEntropyCoder->encodeSaoOffset(&saoParam->saoLcuParam[compIdx][addr], compIdx);
    1448               }
    1449             }
    1450           }
    1451         }
    1452       }
    1453     }
    1454     else if (pcSlice->getSPS()->getUseSAO())
    1455     {
    1456       Int addr = pcCU->getAddr();
    1457       SAOParam *saoParam = pcSlice->getPic()->getPicSym()->getSaoParam();
    1458       for (Int cIdx=0; cIdx<3; cIdx++)
    1459       {
    1460         SaoLcuParam *saoLcuParam = &(saoParam->saoLcuParam[cIdx][addr]);
    1461         if ( ((cIdx == 0) && !pcSlice->getSaoEnabledFlag()) || ((cIdx == 1 || cIdx == 2) && !pcSlice->getSaoEnabledFlagChroma()))
    1462         {
    1463           saoLcuParam->mergeUpFlag   = 0;
    1464           saoLcuParam->mergeLeftFlag = 0;
    1465           saoLcuParam->subTypeIdx    = 0;
    1466           saoLcuParam->typeIdx       = -1;
    1467           saoLcuParam->offset[0]     = 0;
    1468           saoLcuParam->offset[1]     = 0;
    1469           saoLcuParam->offset[2]     = 0;
    1470           saoLcuParam->offset[3]     = 0;
    1471         }
    1472       }
    1473     }
    1474 #endif
    14751361
    14761362#if ENC_DEC_TRACE
     
    14891375    g_bJustDoIt = g_bEncDecTraceDisable;
    14901376#endif
    1491     if( m_pcCfg->getUseSBACRD() )
    1492     {
    1493        pcSbacCoders[uiSubStrm].load(m_pcSbacCoder);   //load back status of the entropy coder after encoding the LCU into relevant bitstream entropy coder
    1494 
    1495 
    1496        //Store probabilties of second LCU in line into buffer
    1497        if ( (depSliceSegmentsEnabled || (pcSlice->getPPS()->getNumSubstreams() > 1)) && (uiCol == uiTileLCUX+1) && m_pcCfg->getWaveFrontsynchro())
    1498       {
    1499         m_pcBufferSbacCoders[uiTileCol].loadContexts( &pcSbacCoders[uiSubStrm] );
    1500       }
     1377    pcSbacCoders[uiSubStrm].load(m_pcSbacCoder);   //load back status of the entropy coder after encoding the LCU into relevant bitstream entropy coder
     1378    //Store probabilties of second LCU in line into buffer
     1379    if ( (depSliceSegmentsEnabled || (pcSlice->getPPS()->getNumSubstreams() > 1)) && (uiCol == uiTileLCUX+1) && m_pcCfg->getWaveFrontsynchro())
     1380    {
     1381      m_pcBufferSbacCoders[uiTileCol].loadContexts( &pcSbacCoders[uiSubStrm] );
    15011382    }
    15021383  }
     
    18701751}
    18711752
     1753#if SVC_EXTENSION
    18721754#if JCTVC_M0259_LAMBDAREFINEMENT
    18731755Double TEncSlice::xCalEnhLambdaFactor( Double deltaQP , Double beta )
     
    18881770}
    18891771#endif
     1772#endif //SVC_EXTENSION
    18901773//! \}
  • trunk/source/Lib/TLibEncoder/TEncSlice.h

    r540 r595  
    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 *
     
    6565  // encoder configuration
    6666  TEncCfg*                m_pcCfg;                              ///< encoder configuration class
    67  
    68 #if SVC_EXTENSION
    69   TEncTop**               m_ppcTEncTop;
    70 #endif 
    7167
    7268  // pictures
     
    107103  UInt                    m_uiSliceIdx;
    108104  std::vector<TEncSbac*> CTXMem;
     105
     106#if SVC_EXTENSION
     107  TEncTop**               m_ppcTEncTop;
     108#endif
     109
    109110public:
    110111  TEncSlice();
     
    152153  Double  xGetQPValueAccordingToLambda ( Double lambda );
    153154
     155#if SVC_EXTENSION
    154156#if JCTVC_M0259_LAMBDAREFINEMENT
    155 private:
    156157  Double  xCalEnhLambdaFactor( Double deltaQP , Double beta );
    157158#endif
     159#endif //SVC_EXTENSION
    158160};
    159161
  • trunk/source/Lib/TLibEncoder/TEncTop.cpp

    r588 r595  
    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 *
     
    129129  if (m_bUseSAO)
    130130  {
    131 #if HM_CLEANUP_SAO
    132131#if AUXILIARY_PICTURES
    133132    m_cEncSAO.create( getSourceWidth(), getSourceHeight(), m_chromaFormatIDC, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth );
     
    140139    m_cEncSAO.createEncData();
    141140#endif
    142 #else
    143     m_cEncSAO.setSaoLcuBoundary(getSaoLcuBoundary());
    144     m_cEncSAO.setSaoLcuBasedOptimization(getSaoLcuBasedOptimization());
    145     m_cEncSAO.setMaxNumOffsetsPerPic(getMaxNumOffsetsPerPic());
    146     m_cEncSAO.create( getSourceWidth(), getSourceHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight );
    147     m_cEncSAO.createEncBuffer();
    148 #endif
    149141  }
    150142#if ADAPTIVE_QP_SELECTION
     
    161153                      g_uiMaxCUWidth, g_uiMaxCUHeight, m_RCKeepHierarchicalBit, m_RCUseLCUSeparateModel, m_GOPList );
    162154  }
    163   // if SBAC-based RD optimization is used
    164   if( m_bUseSBACRD )
    165   {
    166     m_pppcRDSbacCoder = new TEncSbac** [g_uiMaxCUDepth+1];
     155
     156  m_pppcRDSbacCoder = new TEncSbac** [g_uiMaxCUDepth+1];
    167157#if FAST_BIT_EST
    168     m_pppcBinCoderCABAC = new TEncBinCABACCounter** [g_uiMaxCUDepth+1];
    169 #else
    170     m_pppcBinCoderCABAC = new TEncBinCABAC** [g_uiMaxCUDepth+1];
    171 #endif
    172    
    173     for ( Int iDepth = 0; iDepth < g_uiMaxCUDepth+1; iDepth++ )
    174     {
    175       m_pppcRDSbacCoder[iDepth] = new TEncSbac* [CI_NUM];
     158  m_pppcBinCoderCABAC = new TEncBinCABACCounter** [g_uiMaxCUDepth+1];
     159#else
     160  m_pppcBinCoderCABAC = new TEncBinCABAC** [g_uiMaxCUDepth+1];
     161#endif
     162
     163  for ( Int iDepth = 0; iDepth < g_uiMaxCUDepth+1; iDepth++ )
     164  {
     165    m_pppcRDSbacCoder[iDepth] = new TEncSbac* [CI_NUM];
    176166#if FAST_BIT_EST
    177       m_pppcBinCoderCABAC[iDepth] = new TEncBinCABACCounter* [CI_NUM];
    178 #else
    179       m_pppcBinCoderCABAC[iDepth] = new TEncBinCABAC* [CI_NUM];
    180 #endif
    181      
    182       for (Int iCIIdx = 0; iCIIdx < CI_NUM; iCIIdx ++ )
    183       {
    184         m_pppcRDSbacCoder[iDepth][iCIIdx] = new TEncSbac;
     167    m_pppcBinCoderCABAC[iDepth] = new TEncBinCABACCounter* [CI_NUM];
     168#else
     169    m_pppcBinCoderCABAC[iDepth] = new TEncBinCABAC* [CI_NUM];
     170#endif
     171
     172    for (Int iCIIdx = 0; iCIIdx < CI_NUM; iCIIdx ++ )
     173    {
     174      m_pppcRDSbacCoder[iDepth][iCIIdx] = new TEncSbac;
    185175#if FAST_BIT_EST
    186         m_pppcBinCoderCABAC [iDepth][iCIIdx] = new TEncBinCABACCounter;
    187 #else
    188         m_pppcBinCoderCABAC [iDepth][iCIIdx] = new TEncBinCABAC;
    189 #endif
    190         m_pppcRDSbacCoder   [iDepth][iCIIdx]->init( m_pppcBinCoderCABAC [iDepth][iCIIdx] );
    191       }
     176      m_pppcBinCoderCABAC [iDepth][iCIIdx] = new TEncBinCABACCounter;
     177#else
     178      m_pppcBinCoderCABAC [iDepth][iCIIdx] = new TEncBinCABAC;
     179#endif
     180      m_pppcRDSbacCoder   [iDepth][iCIIdx]->init( m_pppcBinCoderCABAC [iDepth][iCIIdx] );
    192181    }
    193182  }
     
    226215    m_pcSbacCoders[ui].init( &m_pcBinCoderCABACs[ui] );
    227216  }
    228   if( m_bUseSBACRD )
    229   {
    230     m_ppppcRDSbacCoders      = new TEncSbac***    [iNumSubstreams];
    231     m_ppppcBinCodersCABAC    = new TEncBinCABAC***[iNumSubstreams];
    232     for ( UInt ui = 0 ; ui < iNumSubstreams ; ui++ )
    233     {
    234       m_ppppcRDSbacCoders[ui]  = new TEncSbac** [g_uiMaxCUDepth+1];
    235       m_ppppcBinCodersCABAC[ui]= new TEncBinCABAC** [g_uiMaxCUDepth+1];
    236      
    237       for ( Int iDepth = 0; iDepth < g_uiMaxCUDepth+1; iDepth++ )
    238       {
    239         m_ppppcRDSbacCoders[ui][iDepth]  = new TEncSbac*     [CI_NUM];
    240         m_ppppcBinCodersCABAC[ui][iDepth]= new TEncBinCABAC* [CI_NUM];
    241 
    242         for (Int iCIIdx = 0; iCIIdx < CI_NUM; iCIIdx ++ )
    243         {
    244           m_ppppcRDSbacCoders  [ui][iDepth][iCIIdx] = new TEncSbac;
    245           m_ppppcBinCodersCABAC[ui][iDepth][iCIIdx] = new TEncBinCABAC;
    246           m_ppppcRDSbacCoders  [ui][iDepth][iCIIdx]->init( m_ppppcBinCodersCABAC[ui][iDepth][iCIIdx] );
    247         }
     217
     218  m_ppppcRDSbacCoders      = new TEncSbac***    [iNumSubstreams];
     219  m_ppppcBinCodersCABAC    = new TEncBinCABAC***[iNumSubstreams];
     220  for ( UInt ui = 0 ; ui < iNumSubstreams ; ui++ )
     221  {
     222    m_ppppcRDSbacCoders[ui]  = new TEncSbac** [g_uiMaxCUDepth+1];
     223    m_ppppcBinCodersCABAC[ui]= new TEncBinCABAC** [g_uiMaxCUDepth+1];
     224
     225    for ( Int iDepth = 0; iDepth < g_uiMaxCUDepth+1; iDepth++ )
     226    {
     227      m_ppppcRDSbacCoders[ui][iDepth]  = new TEncSbac*     [CI_NUM];
     228      m_ppppcBinCodersCABAC[ui][iDepth]= new TEncBinCABAC* [CI_NUM];
     229
     230      for (Int iCIIdx = 0; iCIIdx < CI_NUM; iCIIdx ++ )
     231      {
     232        m_ppppcRDSbacCoders  [ui][iDepth][iCIIdx] = new TEncSbac;
     233        m_ppppcBinCodersCABAC[ui][iDepth][iCIIdx] = new TEncBinCABAC;
     234        m_ppppcRDSbacCoders  [ui][iDepth][iCIIdx]->init( m_ppppcBinCodersCABAC[ui][iDepth][iCIIdx] );
    248235      }
    249236    }
     
    259246  if (m_cSPS.getUseSAO())
    260247  {
    261 #if HM_CLEANUP_SAO
    262248    m_cEncSAO.destroyEncData();
    263249    m_cEncSAO.destroy();
    264 #else
    265     m_cEncSAO.destroy();
    266     m_cEncSAO.destroyEncBuffer();
    267 #endif
    268250  }
    269251  m_cLoopFilter.        destroy();
    270252  m_cRateCtrl.          destroy();
    271   // SBAC RD
    272   if( m_bUseSBACRD )
    273   {
    274     Int iDepth;
     253
     254  Int iDepth;
     255  for ( iDepth = 0; iDepth < g_uiMaxCUDepth+1; iDepth++ )
     256  {
     257    for (Int iCIIdx = 0; iCIIdx < CI_NUM; iCIIdx ++ )
     258    {
     259      delete m_pppcRDSbacCoder[iDepth][iCIIdx];
     260      delete m_pppcBinCoderCABAC[iDepth][iCIIdx];
     261    }
     262  }
     263
     264  for ( iDepth = 0; iDepth < g_uiMaxCUDepth+1; iDepth++ )
     265  {
     266    delete [] m_pppcRDSbacCoder[iDepth];
     267    delete [] m_pppcBinCoderCABAC[iDepth];
     268  }
     269
     270  delete [] m_pppcRDSbacCoder;
     271  delete [] m_pppcBinCoderCABAC;
     272
     273  for ( UInt ui = 0; ui < m_iNumSubstreams; ui++ )
     274  {
    275275    for ( iDepth = 0; iDepth < g_uiMaxCUDepth+1; iDepth++ )
    276276    {
    277277      for (Int iCIIdx = 0; iCIIdx < CI_NUM; iCIIdx ++ )
    278278      {
    279         delete m_pppcRDSbacCoder[iDepth][iCIIdx];
    280         delete m_pppcBinCoderCABAC[iDepth][iCIIdx];
    281       }
    282     }
    283    
     279        delete m_ppppcRDSbacCoders  [ui][iDepth][iCIIdx];
     280        delete m_ppppcBinCodersCABAC[ui][iDepth][iCIIdx];
     281      }
     282    }
     283
    284284    for ( iDepth = 0; iDepth < g_uiMaxCUDepth+1; iDepth++ )
    285285    {
    286       delete [] m_pppcRDSbacCoder[iDepth];
    287       delete [] m_pppcBinCoderCABAC[iDepth];
    288     }
    289    
    290     delete [] m_pppcRDSbacCoder;
    291     delete [] m_pppcBinCoderCABAC;
    292 
    293     for ( UInt ui = 0; ui < m_iNumSubstreams; ui++ )
    294     {
    295       for ( iDepth = 0; iDepth < g_uiMaxCUDepth+1; iDepth++ )
    296       {
    297         for (Int iCIIdx = 0; iCIIdx < CI_NUM; iCIIdx ++ )
    298         {
    299           delete m_ppppcRDSbacCoders  [ui][iDepth][iCIIdx];
    300           delete m_ppppcBinCodersCABAC[ui][iDepth][iCIIdx];
    301         }
    302       }
    303 
    304       for ( iDepth = 0; iDepth < g_uiMaxCUDepth+1; iDepth++ )
    305       {
    306         delete [] m_ppppcRDSbacCoders  [ui][iDepth];
    307         delete [] m_ppppcBinCodersCABAC[ui][iDepth];
    308       }
    309       delete[] m_ppppcRDSbacCoders  [ui];
    310       delete[] m_ppppcBinCodersCABAC[ui];
    311     }
    312     delete[] m_ppppcRDSbacCoders;
    313     delete[] m_ppppcBinCodersCABAC;
    314   }
     286      delete [] m_ppppcRDSbacCoders  [ui][iDepth];
     287      delete [] m_ppppcBinCodersCABAC[ui][iDepth];
     288    }
     289    delete[] m_ppppcRDSbacCoders  [ui];
     290    delete[] m_ppppcBinCodersCABAC[ui];
     291  }
     292  delete[] m_ppppcRDSbacCoders;
     293  delete[] m_ppppcBinCodersCABAC;
    315294  delete[] m_pcSbacCoders;
    316295  delete[] m_pcBinCoderCABACs;
     
    525504    TComPic *pcTopField;
    526505    xGetNewPicBuffer( pcTopField );
    527 #if !HM_CLEANUP_SAO
    528     pcTopField->getPicSym()->allocSaoParam(&m_cEncSAO);
    529 #endif
    530506    pcTopField->setReconMark (false);
    531507   
     
    568544    TComPic* pcBottomField;
    569545    xGetNewPicBuffer( pcBottomField );
    570 #if !HM_CLEANUP_SAO
    571     pcBottomField->getPicSym()->allocSaoParam(&m_cEncSAO);
    572 #endif
    573546    pcBottomField->setReconMark (false);
    574547   
     
    652625    TComPic *pcTopField;
    653626    xGetNewPicBuffer( pcTopField );
    654 #if !HM_CLEANUP_SAO
    655     pcTopField->getPicSym()->allocSaoParam(&m_cEncSAO);
    656 #endif
    657627    pcTopField->setReconMark (false);
    658628   
     
    706676    TComPic* pcBottomField;
    707677    xGetNewPicBuffer( pcBottomField );
    708 #if !HM_CLEANUP_SAO
    709     pcBottomField->getPicSym()->allocSaoParam(&m_cEncSAO);
    710 #endif
    711678    pcBottomField->setReconMark (false);
    712679   
     
    912879#endif
    913880    }
    914 #if !HM_CLEANUP_SAO
    915     if (getUseSAO())
    916     {
    917       rpcPic->getPicSym()->allocSaoParam(&m_cEncSAO);
    918     }
    919 #endif
    920881    m_cListPic.pushBack( rpcPic );
    921882  }
     
    1001962 
    1002963  m_cSPS.setTMVPFlagsPresent(false);
    1003   m_cSPS.setUseLossless   ( m_useLossless  );
    1004964
    1005965  m_cSPS.setMaxTrSize   ( 1 << m_uiQuadtreeTULog2MaxSize );
     
    1038998  m_cSPS.setMaxTLayers( m_maxTempLayer );
    1039999  m_cSPS.setTemporalIdNestingFlag( ( m_maxTempLayer == 1 ) ? true : false );
    1040   for ( i = 0; i < m_cSPS.getMaxTLayers(); i++ )
     1000  for ( i = 0; i < min(m_cSPS.getMaxTLayers(),(UInt) MAX_TLAYER); i++ )
    10411001  {
    10421002    m_cSPS.setMaxDecPicBuffering(m_maxDecPicBuffering[i], i);
     
    10981058  Bool bUseDQP = (getMaxCuDQPDepth() > 0)? true : false;
    10991059
    1100 #if REPN_FORMAT_IN_VPS
    1101   Int lowestQP;
    1102 #if O0096_REP_FORMAT_INDEX
    1103   if( m_layerId == 0 )
    1104   {
    1105     lowestQP = - m_cSPS.getQpBDOffsetY();
    1106   }
    1107   else
    1108   {
    1109     lowestQP = - (m_cVPS.getVpsRepFormat( m_cVPS.getVpsRepFormatIdx( m_cSPS.getUpdateRepFormatFlag() ? m_cSPS.getUpdateRepFormatIndex() : m_layerId ) )->getBitDepthVpsLuma() - 8) * 6;
    1110   }
    1111 #else
    1112   if( m_layerId == 0 || m_cSPS.getUpdateRepFormatFlag() )
    1113   {
    1114     lowestQP = - m_cSPS.getQpBDOffsetY();
    1115   }
    1116   else
    1117   {
    1118     lowestQP = - (m_cVPS.getVpsRepFormat( m_cVPS.getVpsRepFormatIdx( m_layerId ) )->getBitDepthVpsLuma() - 8) * 6;
    1119   }
    1120 #endif
    1121 #else
    1122   Int lowestQP = - m_cSPS.getQpBDOffsetY();
    1123 #endif
    1124 
    1125   if(getUseLossless())
    1126   {
    1127     if ((getMaxCuDQPDepth() == 0) && (getMaxDeltaQP() == 0 ) && (getQP() == lowestQP) )
    1128     {
    1129       bUseDQP = false;
    1130     }
    1131     else
    1132     {
    1133       bUseDQP = true;
    1134     }
    1135   }
    1136   else
    1137   {
    1138     if(bUseDQP == false)
    1139     {
    1140       if((getMaxDeltaQP() != 0 )|| getUseAdaptiveQP())
    1141       {
    1142         bUseDQP = true;
    1143       }
    1144     }
     1060  if((getMaxDeltaQP() != 0 )|| getUseAdaptiveQP())
     1061  {
     1062    bUseDQP = true;
    11451063  }
    11461064
  • trunk/source/Lib/TLibEncoder/TEncTop.h

    r588 r595  
    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 *
     
    7373  UInt                    m_uiNumAllPicCoded;             ///< number of coded pictures
    7474  TComList<TComPic*>      m_cListPic;                     ///< dynamic list of pictures
    75 #if SVC_EXTENSION
    76   static Int              m_iSPSIdCnt;                    ///< next Id number for SPS   
    77   static Int              m_iPPSIdCnt;                    ///< next Id number for PPS   
    78 #if AVC_SYNTAX
    79   fstream*                m_pBLSyntaxFile;
    80 #endif
    81 #endif
    82  
     75 
    8376  // encoder search
    8477  TEncSearch              m_cSearch;                      ///< encoder search class
     
    130123 
    131124#if SVC_EXTENSION
    132 
     125  static Int              m_iSPSIdCnt;                    ///< next Id number for SPS   
     126  static Int              m_iPPSIdCnt;                    ///< next Id number for PPS   
     127#if AVC_SYNTAX
     128  fstream*                m_pBLSyntaxFile;
     129#endif
    133130  TEncTop**               m_ppcTEncTop;
    134131  TEncTop*                getLayerEnc(UInt layer)   { return m_ppcTEncTop[layer]; }
     
    163160  Void  xInitRPS          (Bool isFieldCoding);           ///< initialize PPS from encoder options
    164161#if SVC_EXTENSION
    165   Void xInitILRP();
     162  Void  xInitILRP();
    166163#endif
    167164public:
     
    210207  Int getReferencePictureSetIdxForSOP(TComSlice* slice, Int POCCurr, Int GOPid );
    211208  TComScalingList*        getScalingList        () { return  &m_scalingList;         }
     209  // -------------------------------------------------------------------------------------------------------------------
     210  // encoder function
     211  // -------------------------------------------------------------------------------------------------------------------
     212
     213  /// encode several number of pictures until end-of-sequence
    212214#if SVC_EXTENSION
    213215  Void                    setLayerEnc(TEncTop** p) {m_ppcTEncTop = p;}
     
    224226#endif
    225227  Window&  getScaledRefLayerWindow(Int x)            { return m_scaledRefLayerWindow[x]; }
    226 #endif //SVC_EXTENSION
    227 
    228   // -------------------------------------------------------------------------------------------------------------------
    229   // encoder function
    230   // -------------------------------------------------------------------------------------------------------------------
    231 
    232   /// encode several number of pictures until end-of-sequence
    233 #if SVC_EXTENSION
    234228  TComPic** getIlpList() { return m_cIlpPic; }
    235229#if REF_IDX_MFM
     
    281275
    282276#endif // __TENCTOP__
     277
  • trunk/source/Lib/TLibEncoder/WeightPredAnalysis.cpp

    r494 r595  
    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 *
  • trunk/source/Lib/TLibEncoder/WeightPredAnalysis.h

    r313 r595  
    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 *
  • trunk/source/Lib/TLibVideoIO/TVideoIOYuv.cpp

    r494 r595  
    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 *
  • trunk/source/Lib/TLibVideoIO/TVideoIOYuv.h

    r442 r595  
    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 *
  • trunk/source/Lib/libmd5/MD5.h

    r313 r595  
    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 *
  • trunk/source/Lib/libmd5/libmd5.h

    r313 r595  
    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 *
Note: See TracChangeset for help on using the changeset viewer.