Changeset 595 in SHVCSoftware for trunk/source/Lib
- Timestamp:
- 2 Feb 2014, 06:01:53 (11 years ago)
- Location:
- trunk
- Files:
-
- 127 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/SHM-5.0-dev merged: 591,593-594
- Property svn:mergeinfo changed
-
trunk/source
- Property svn:mergeinfo changed
/branches/SHM-5.0-dev/source merged: 593
- Property svn:mergeinfo changed
-
trunk/source/Lib/TAppCommon/program_options_lite.cpp
r540 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * -
trunk/source/Lib/TAppCommon/program_options_lite.h
r313 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * -
trunk/source/Lib/TLibCommon/AccessUnit.h
r313 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * -
trunk/source/Lib/TLibCommon/CommonDef.h
r588 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * … … 40 40 41 41 #include <algorithm> 42 42 43 #if _MSC_VER > 1000 43 44 // disable "signed and unsigned mismatch" … … 57 58 #if SVC_EXTENSION 58 59 #include <vector> 59 #define NV_VERSION "5.0 (HM-1 2.1)" ///< Current software version60 #define NV_VERSION "5.0 (HM-13.0)" ///< Current software version 60 61 #else 61 #define NV_VERSION "1 2.1" ///< Current software version62 #define NV_VERSION "13.0" ///< Current software version 62 63 #endif 63 64 -
trunk/source/Lib/TLibCommon/ContextModel.cpp
r313 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * -
trunk/source/Lib/TLibCommon/ContextModel.h
r313 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * -
trunk/source/Lib/TLibCommon/ContextModel3DBuffer.cpp
r313 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * -
trunk/source/Lib/TLibCommon/ContextModel3DBuffer.h
r313 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * -
trunk/source/Lib/TLibCommon/ContextTables.h
r345 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * … … 42 42 //! \ingroup TLibCommon 43 43 //! \{ 44 #define FIX827 1 ///< Fix for issue #827: CABAC init tables45 #define FIX712 1 ///< Fix for issue #712: CABAC init tables46 44 47 45 // ==================================================================================================================== … … 58 56 59 57 #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)61 58 #define NUM_PRED_MODE_CTX 1 ///< number of context models for prediction mode 62 59 … … 69 66 #define NUM_REF_NO_CTX 2 ///< number of context models for reference index 70 67 #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 CBF68 #define NUM_QT_CBF_CTX 4 ///< number of context models for QT CBF 72 69 #define NUM_QT_ROOT_CBF_CTX 1 ///< number of context models for QT ROOT CBF 73 70 #define NUM_DELTA_QP_CTX 3 ///< number of context models for dQP … … 88 85 #define NUM_ABS_FLAG_CTX_CHROMA 2 ///< number of context models for greater than 2 flag of chroma 89 86 90 #define NUM_MVP_IDX_CTX 2///< number of context models for MVP index87 #define NUM_MVP_IDX_CTX 1 ///< number of context models for MVP index 91 88 92 89 #define NUM_SAO_MERGE_FLAG_CTX 1 ///< number of context models for SAO merge flags … … 146 143 INIT_PART_SIZE[3][NUM_PART_SIZE_CTX] = 147 144 { 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 }, 159 148 }; 160 149 … … 218 207 INIT_QT_CBF[3][2*NUM_QT_CBF_CTX] = 219 208 { 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 }, 223 212 }; 224 213 … … 286 275 INIT_MVP_IDX[3][NUM_MVP_IDX_CTX] = 287 276 { 288 { 168 , CNU, },289 { 168 , CNU, },290 { CNU , CNU,},277 { 168 }, 278 { 168 }, 279 { CNU }, 291 280 }; 292 281 … … 302 291 INIT_SAO_TYPE_IDX[3][NUM_SAO_TYPE_IDX_CTX] = 303 292 { 304 #if FIX827305 293 { 160, }, 306 294 { 185, }, 307 295 { 200, }, 308 #else309 { 200, },310 { 185, },311 { 160, },312 #endif313 296 }; 314 297 … … 316 299 INIT_TRANS_SUBDIV_FLAG[3][NUM_TRANS_SUBDIV_FLAG_CTX] = 317 300 { 318 #if FIX712319 301 { 224, 167, 122, }, 320 302 { 124, 138, 94, }, 321 303 { 153, 138, 138, }, 322 #else323 { 153, 138, 138, },324 { 124, 138, 94, },325 { 224, 167, 122, },326 #endif327 304 }; 328 305 -
trunk/source/Lib/TLibCommon/NAL.h
r540 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * -
trunk/source/Lib/TLibCommon/SEI.cpp
r588 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * -
trunk/source/Lib/TLibCommon/SEI.h
r588 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * -
trunk/source/Lib/TLibCommon/TComBitCounter.h
r313 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * -
trunk/source/Lib/TLibCommon/TComBitStream.cpp
r313 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * -
trunk/source/Lib/TLibCommon/TComBitStream.h
r313 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * -
trunk/source/Lib/TLibCommon/TComCABACTables.cpp
r313 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * -
trunk/source/Lib/TLibCommon/TComCABACTables.h
r313 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * -
trunk/source/Lib/TLibCommon/TComDataCU.cpp
r588 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * … … 309 309 } 310 310 } 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 331 312 // ==================================================================================================================== 332 313 // Public member functions … … 547 528 *- set last-coded qp value according to input last-coded qp 548 529 */ 549 Void TComDataCU::initEstData( UInt uiDepth, Int qp )530 Void TComDataCU::initEstData( UInt uiDepth, Int qp, Bool bTransquantBypass ) 550 531 { 551 532 m_dTotalCost = MAX_DOUBLE; … … 575 556 m_pePartSize[ui] = SIZE_NONE; 576 557 m_pePredMode[ui] = MODE_NONE; 577 m_CUTransquantBypass[ui] = false;558 m_CUTransquantBypass[ui] = bTransquantBypass; 578 559 m_pbIPCMFlag[ui] = 0; 579 560 m_phQP[ui] = qp; … … 2550 2531 TComDataCU* pcCULeft = 0; 2551 2532 pcCULeft = getPULeft( uiLeftPartIdx, uiPartIdxLB ); 2552 2553 2533 Bool isAvailableA1 = pcCULeft && 2554 2534 pcCULeft->isDiffMER(xP -1, yP+nPSH-1, xP, yP) && … … 2582 2562 TComDataCU* pcCUAbove = 0; 2583 2563 pcCUAbove = getPUAbove( uiAbovePartIdx, uiPartIdxRT ); 2584 2585 2564 Bool isAvailableB1 = pcCUAbove && 2586 2565 pcCUAbove->isDiffMER(xP+nPSW-1, yP-1, xP, yP) && … … 2614 2593 TComDataCU* pcCUAboveRight = 0; 2615 2594 pcCUAboveRight = getPUAboveRight( uiAboveRightPartIdx, uiPartIdxRT ); 2616 2617 2595 Bool isAvailableB0 = pcCUAboveRight && 2618 2596 pcCUAboveRight->isDiffMER(xP+nPSW, yP-1, xP, yP) && … … 2645 2623 TComDataCU* pcCULeftBottom = 0; 2646 2624 pcCULeftBottom = this->getPUBelowLeft( uiLeftBottomPartIdx, uiPartIdxLB ); 2647 2648 2625 Bool isAvailableA0 = pcCULeftBottom && 2649 2626 pcCULeftBottom->isDiffMER(xP-1, yP+nPSH, xP, yP) && … … 2671 2648 return; 2672 2649 } 2673 2674 2650 // above left 2675 2651 if( iCount < 4 ) … … 2678 2654 TComDataCU* pcCUAboveLeft = 0; 2679 2655 pcCUAboveLeft = getPUAboveLeft( uiAboveLeftPartIdx, uiAbsPartAddr ); 2680 2681 2656 Bool isAvailableB2 = pcCUAboveLeft && 2682 2657 pcCUAboveLeft->isDiffMER(xP-1, yP-1, xP, yP) && … … 3013 2988 } 3014 2989 } 2990 3015 2991 // Above predictor search 3016 2992 bAdded = xAddMVPCand( pInfo, eRefPicList, iRefIdx, uiPartIdxRT, MD_ABOVE_RIGHT); … … 3025 3001 xAddMVPCand( pInfo, eRefPicList, iRefIdx, uiPartIdxLT, MD_ABOVE_LEFT); 3026 3002 } 3027 bAdded = bAddedSmvp; 3028 if (pInfo->iN==2) bAdded = true; 3029 3030 if(!bAdded) 3003 3004 if (!bAddedSmvp) 3031 3005 { 3032 3006 bAdded = xAddMVPCandOrder( pInfo, eRefPicList, iRefIdx, uiPartIdxRT, MD_ABOVE_RIGHT); … … 3626 3600 return getPic()->getPicSym()->getInverseCUOrderMap(m_uiCUAddr)*(1<<(m_pcSlice->getSPS()->getMaxCUDepth()<<1))+m_uiAbsIdxInLCU; 3627 3601 } 3628 #if !HM_CLEANUP_SAO3629 /** Set neighboring blocks availabilities for non-deblocked filtering3630 * \param numLCUInPicWidth number of LCUs in picture width3631 * \param numLCUInPicHeight number of LCUs in picture height3632 * \param numSUInLCUWidth number of SUs in LCU width3633 * \param numSUInLCUHeight number of SUs in LCU height3634 * \param picWidth picture width3635 * \param picHeight picture height3636 * \param bIndependentSliceBoundaryEnabled true for independent slice boundary enabled3637 * \param bTopTileBoundary true means that top boundary coincides tile boundary3638 * \param bDownTileBoundary true means that bottom boundary coincides tile boundary3639 * \param bLeftTileBoundary true means that left boundary coincides tile boundary3640 * \param bRightTileBoundary true means that right boundary coincides tile boundary3641 * \param bIndependentTileBoundaryEnabled true for independent tile boundary enabled3642 */3643 Void TComDataCU::setNDBFilterBlockBorderAvailability(UInt numLCUInPicWidth, UInt /*numLCUInPicHeight*/, UInt numSUInLCUWidth, UInt numSUInLCUHeight, UInt picWidth, UInt picHeight3644 ,std::vector<Bool>& LFCrossSliceBoundary3645 ,Bool bTopTileBoundary, Bool bDownTileBoundary, Bool bLeftTileBoundary, Bool bRightTileBoundary3646 ,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_L3696 pbAvail = &(pbAvailBorder[SGU_L]);3697 if(bPicLBoundary)3698 {3699 *pbAvail = false;3700 }3701 else if (onlyOneSliceInPic)3702 {3703 *pbAvail = true;3704 }3705 else3706 {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 else3715 {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_R3724 pbAvail = &(pbAvailBorder[SGU_R]);3725 if(bPicRBoundary)3726 {3727 *pbAvail = false;3728 }3729 else if (onlyOneSliceInPic)3730 {3731 *pbAvail = true;3732 }3733 else3734 {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 else3743 {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_T3752 pbAvail = &(pbAvailBorder[SGU_T]);3753 if(bPicTBoundary)3754 {3755 *pbAvail = false;3756 }3757 else if (onlyOneSliceInPic)3758 {3759 *pbAvail = true;3760 }3761 else3762 {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 else3771 {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_B3780 pbAvail = &(pbAvailBorder[SGU_B]);3781 if(bPicBBoundary)3782 {3783 *pbAvail = false;3784 }3785 else if (onlyOneSliceInPic)3786 {3787 *pbAvail = true;3788 }3789 else3790 {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 else3799 {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_TL3808 pbAvail = &(pbAvailBorder[SGU_TL]);3809 if(bPicTBoundary || bPicLBoundary)3810 {3811 *pbAvail = false;3812 }3813 else if (onlyOneSliceInPic)3814 {3815 *pbAvail = true;3816 }3817 else3818 {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 LCU3835 {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_TR3844 pbAvail = &(pbAvailBorder[SGU_TR]);3845 if(bPicTBoundary || bPicRBoundary)3846 {3847 *pbAvail = false;3848 }3849 else if (onlyOneSliceInPic)3850 {3851 *pbAvail = true;3852 }3853 else3854 {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 LCU3871 {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_BL3880 pbAvail = &(pbAvailBorder[SGU_BL]);3881 if(bPicBBoundary || bPicLBoundary)3882 {3883 *pbAvail = false;3884 }3885 else if (onlyOneSliceInPic)3886 {3887 *pbAvail = true;3888 }3889 else3890 {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 LCU3907 {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_BR3916 pbAvail = &(pbAvailBorder[SGU_BR]);3917 if(bPicBBoundary || bPicRBoundary)3918 {3919 *pbAvail = false;3920 }3921 else if (onlyOneSliceInPic)3922 {3923 *pbAvail = true;3924 }3925 else3926 {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 LCU3943 {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 boundary3954 if(!bPicLBoundary && bLCULBoundary)3955 {3956 if(bLeftTileBoundary)3957 {3958 pbAvailBorder[SGU_L] = pbAvailBorder[SGU_TL] = pbAvailBorder[SGU_BL] = false;3959 }3960 }3961 //right LCU boundary3962 if(!bPicRBoundary && bLCURBoundary)3963 {3964 if(bRightTileBoundary)3965 {3966 pbAvailBorder[SGU_R] = pbAvailBorder[SGU_TR] = pbAvailBorder[SGU_BR] = false;3967 }3968 }3969 //top LCU boundary3970 if(!bPicTBoundary && bLCUTBoundary)3971 {3972 if(bTopTileBoundary)3973 {3974 pbAvailBorder[SGU_T] = pbAvailBorder[SGU_TL] = pbAvailBorder[SGU_TR] = false;3975 }3976 }3977 //down LCU boundary3978 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 #endif3999 3602 4000 3603 #if SVC_EXTENSION … … 4077 3680 rcMvFieldEnhance.setMvField( cMv, rcMvFieldBase.getRefIdx() ); 4078 3681 } 4079 #endif 3682 #endif //SVC_EXTENSION 4080 3683 //! \} -
trunk/source/Lib/TLibCommon/TComDataCU.h
r540 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * … … 55 55 //! \{ 56 56 57 #if !HM_CLEANUP_SAO58 // ====================================================================================================================59 // Non-deblocking in-loop filter processing block data structure60 // ====================================================================================================================61 62 /// Non-deblocking filter processing block border tag63 enum NDBFBlockBorderTag64 {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_BORDER74 };75 76 /// Non-deblocking filter processing block information77 struct NDBFBlockInfo78 {79 Int tileID; //!< tile ID80 Int sliceID; //!< slice ID81 UInt startSU; //!< starting SU z-scan address in LCU82 UInt endSU; //!< ending SU z-scan address in LCU83 UInt widthSU; //!< number of SUs in width84 UInt heightSU; //!< number of SUs in height85 UInt posX; //!< top-left X coordinate in picture86 UInt posY; //!< top-left Y coordinate in picture87 UInt width; //!< number of pixels in width88 UInt height; //!< number of pixels in height89 Bool isBorderAvailable[NUM_SGU_BORDER]; //!< the border availabilities90 Bool allBordersAvailable;91 92 NDBFBlockInfo():tileID(0), sliceID(0), startSU(0), endSU(0) {} //!< constructor93 const NDBFBlockInfo& operator= (const NDBFBlockInfo& src); //!< "=" operator94 };95 #endif96 97 98 57 // ==================================================================================================================== 99 58 // Class definition … … 161 120 Pel* m_pcIPCMSampleCr; ///< PCM sample buffer (Cr) 162 121 163 #if !HM_CLEANUP_SAO164 Int* m_piSliceSUMap; ///< pointer of slice ID map165 std::vector<NDBFBlockInfo> m_vNDFBlock;166 #endif167 122 // ------------------------------------------------------------------------------------------------------------------- 168 123 // neighbour access variables … … 241 196 242 197 Void initCU ( TComPic* pcPic, UInt uiCUAddr ); 243 Void initEstData ( UInt uiDepth, Int qp );198 Void initEstData ( UInt uiDepth, Int qp, Bool bTransquantBypass ); 244 199 Void initSubCU ( TComDataCU* pcCU, UInt uiPartUnitIdx, UInt uiDepth, Int qp ); 245 200 Void setOutsideCUPart ( UInt uiAbsPartIdx, UInt uiDepth ); … … 392 347 Void setIPCMFlagSubParts (Bool bIpcmFlag, UInt uiAbsPartIdx, UInt uiDepth); 393 348 394 #if !HM_CLEANUP_SAO395 /// get slice ID for SU396 Int getSUSliceID (UInt uiIdx) {return m_piSliceSUMap[uiIdx]; }397 398 /// get the pointer of slice ID map399 Int* getSliceSUMap () {return m_piSliceSUMap; }400 401 /// set the pointer of slice ID map402 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 picHeight406 ,std::vector<Bool>& LFCrossSliceBoundary407 ,Bool bTopTileBoundary, Bool bDownTileBoundary, Bool bLeftTileBoundary, Bool bRightTileBoundary408 ,Bool bIndependentTileBoundaryEnabled );409 #endif410 349 // ------------------------------------------------------------------------------------------------------------------- 411 350 // member functions for accessing partition information … … 442 381 443 382 Void compressMV (); 444 445 #if SVC_EXTENSION446 Void setLayerId (UInt layerId) { m_layerId = layerId; }447 UInt getLayerId () { return m_layerId; }448 #endif449 383 450 384 // ------------------------------------------------------------------------------------------------------------------- … … 490 424 Void deriveLeftBottomIdxGeneral ( UInt uiAbsPartIdx, UInt uiPartIdx, UInt& ruiPartIdxLB ); 491 425 426 492 427 // ------------------------------------------------------------------------------------------------------------------- 493 428 // member functions for modes … … 497 432 Bool isSkipped ( UInt uiPartIdx ); ///< SKIP (no residual) 498 433 Bool isBipredRestriction( UInt puIdx ); 499 #if N0383_IL_CONSTRAINED_TILE_SETS_SEI500 Bool isInterLayerReference(UChar uhInterDir, TComMvField& cMvFieldL0, TComMvField& cMvFieldL1);501 #endif502 434 503 435 // ------------------------------------------------------------------------------------------------------------------- … … 525 457 526 458 #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 527 464 #if FAST_INTRA_SHVC 528 465 Int reduceSetOfIntraModes ( UInt uiAbsPartIdx, Int* uiIntraDirPred, Int &fullSetOfModes ); 529 466 #endif 530 531 467 #if REF_IDX_ME_ZEROMV 532 468 Bool xCheckZeroMVILRMerge(UChar uhInterDir, TComMvField& cMvFieldL0, TComMvField& cMvFieldL1); 533 469 Bool xCheckZeroMVILRMvdL1Zero(Int iRefList, Int iRefIdx, Int MvpIdx); 534 470 #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 ); 535 474 #endif 536 475 … … 546 485 UInt getCoefScanIdx(UInt uiAbsPartIdx, UInt uiWidth, Bool bIsLuma, Bool bIsIntra); 547 486 548 #if SVC_EXTENSION549 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 #endif553 487 }; 554 488 -
trunk/source/Lib/TLibCommon/TComInterpolationFilter.cpp
r313 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * -
trunk/source/Lib/TLibCommon/TComInterpolationFilter.h
r313 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * -
trunk/source/Lib/TLibCommon/TComList.h
r313 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * -
trunk/source/Lib/TLibCommon/TComLoopFilter.cpp
r442 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * -
trunk/source/Lib/TLibCommon/TComLoopFilter.h
r313 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * -
trunk/source/Lib/TLibCommon/TComMotionInfo.cpp
r345 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * -
trunk/source/Lib/TLibCommon/TComMotionInfo.h
r345 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * -
trunk/source/Lib/TLibCommon/TComMv.h
r442 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * -
trunk/source/Lib/TLibCommon/TComPattern.cpp
r313 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * -
trunk/source/Lib/TLibCommon/TComPattern.h
r313 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * -
trunk/source/Lib/TLibCommon/TComPic.cpp
r540 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * … … 48 48 TComPic::TComPic() 49 49 : m_uiTLayer (0) 50 #if SVC_EXTENSION51 , m_layerId( 0 )52 #endif53 50 , m_bUsedByCurr (false) 54 51 , m_bIsLongTerm (false) … … 59 56 , m_bNeededForOutput (false) 60 57 , m_uiCurrSliceIdx (0) 61 #if !HM_CLEANUP_SAO62 , m_pSliceSUMap (NULL)63 , m_pbValidSlice (NULL)64 , m_sliceGranularityForNDBFilter (0)65 , m_bIndependentSliceBoundaryForNDBFilter (false)66 , m_bIndependentTileBoundaryForNDBFilter (false)67 , m_pNDBFilterYuvTmp (NULL)68 #endif69 58 , m_bCheckLTMSB (false) 59 #if SVC_EXTENSION 60 , m_layerId( 0 ) 61 #endif 70 62 { 71 63 #if SVC_EXTENSION … … 214 206 } 215 207 } 216 #if HM_CLEANUP_SAO 208 217 209 Bool TComPic::getSAOMergeAvailability(Int currAddr, Int mergeAddr) 218 210 { … … 221 213 return (mergeCtbInSliceSeg && mergeCtbInTile); 222 214 } 223 #else224 /** Create non-deblocked filter information225 * \param pSliceStartAddress array for storing slice start addresses226 * \param numSlices number of slices in picture227 * \param sliceGranularityDepth slice granularity228 * \param bNDBFilterCrossSliceBoundary cross-slice-boundary in-loop filtering; true for "cross".229 * \param numTiles number of tiles in picture230 * \param bNDBFilterCrossTileBoundary cross-tile-boundary in-loop filtering; true for "cross".231 */232 Void TComPic::createNonDBFilterInfo(std::vector<Int> sliceStartAddress, Int sliceGranularityDepth233 ,std::vector<Bool>* LFCrossSliceBoundary234 ,Int numTiles235 ,Bool bNDBFilterCrossTileBoundary)236 {237 UInt maxNumSUInLCU = getNumPartInCU();238 UInt numLCUInPic = getNumCUsInFrame();239 #if REPN_FORMAT_IN_VPS240 UInt picWidth = getSlice(0)->getPicWidthInLumaSamples();241 UInt picHeight = getSlice(0)->getPicHeightInLumaSamples();242 #else243 UInt picWidth = getSlice(0)->getSPS()->getPicWidthInLumaSamples();244 UInt picHeight = getSlice(0)->getSPS()->getPicHeightInLumaSamples();245 #endif246 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 //initialization273 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 address295 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 else352 {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 block362 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 availability378 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 //left400 if( uiAddr % numLCUsInPicWidth != 0)401 {402 bLeftTileBoundary = ( m_apcPicSym->getTileIdxMap(uiAddr -1) != iTileID )?true:false;403 }404 //right405 if( (uiAddr % numLCUsInPicWidth) != (numLCUsInPicWidth -1) )406 {407 bRightTileBoundary = ( m_apcPicSym->getTileIdxMap(uiAddr +1) != iTileID)?true:false;408 }409 //top410 if( uiAddr >= numLCUsInPicWidth)411 {412 bTopTileBoundary = (m_apcPicSym->getTileIdxMap(uiAddr - numLCUsInPicWidth) != iTileID )?true:false;413 }414 //down415 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, picHeight423 , *LFCrossSliceBoundary424 ,bTopTileBoundary, bDownTileBoundary, bLeftTileBoundary, bRightTileBoundary425 ,m_bIndependentTileBoundaryForNDBFilter);426 427 }428 429 }430 431 if( m_bIndependentSliceBoundaryForNDBFilter || m_bIndependentTileBoundaryForNDBFilter)432 {433 m_pNDBFilterYuvTmp = new TComPicYuv();434 #if AUXILIARY_PICTURES435 m_pNDBFilterYuvTmp->create(picWidth, picHeight, getChromaFormat(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth);436 #else437 m_pNDBFilterYuvTmp->create(picWidth, picHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth);438 #endif439 440 }441 442 }443 444 /** Create non-deblocked filter information for LCU445 * \param tileID tile index446 * \param sliceID slice index447 * \param pcCU CU data pointer448 * \param startSU start SU index in LCU449 * \param endSU end SU index in LCU450 * \param sliceGranularyDepth slice granularity451 * \param picWidth picture width452 * \param picHeight picture height453 */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 NBFilterBLock467 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 LCU531 */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 #endif560 215 561 216 #if SVC_EXTENSION -
trunk/source/Lib/TLibCommon/TComPic.h
r540 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * … … 61 61 private: 62 62 UInt m_uiTLayer; // Temporal layer 63 #if SVC_EXTENSION64 UInt m_layerId; // Layer ID65 #endif66 63 Bool m_bUsedByCurr; // Used by current picture 67 64 Bool m_bIsLongTerm; // IS long term picture … … 75 72 Bool m_bNeededForOutput; 76 73 UInt m_uiCurrSliceIdx; // Index of current slice 77 #if !HM_CLEANUP_SAO78 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 enabled84 #endif85 74 Bool m_bCheckLTMSB; 86 75 … … 96 85 SEIMessages m_SEIs; ///< Any SEI messages that have been received. If !NULL we own the object. 97 86 #if SVC_EXTENSION 87 UInt m_layerId; // Layer ID 98 88 Bool m_bSpatialEnhLayer[MAX_LAYERS]; // whether current layer is a spatial enhancement layer, 99 89 TComPicYuv* m_pcFullPelBaseRec[MAX_LAYERS]; // upsampled base layer recontruction for difference domain inter prediction … … 125 115 UInt getTLayer() { return m_uiTLayer; } 126 116 Void setTLayer( UInt uiTLayer ) { m_uiTLayer = uiTLayer; } 127 #if SVC_EXTENSION128 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 #endif135 #if REF_IDX_ME_ZEROMV || ENCODER_FAST_MODE || REF_IDX_MFM136 Bool isILR( UInt currLayerId ) { return ( getIsLongTerm() && m_layerId < currLayerId ); }137 #endif138 139 #if REF_IDX_MFM140 Void copyUpsampledMvField ( UInt refLayerIdc, TComPic* pcPicBase );141 Void initUpsampledMvField ();142 #endif143 #if MFM_ENCCONSTRAINT144 Bool checkSameRefInfo();145 #endif146 147 117 Bool getUsedByCurr() { return m_bUsedByCurr; } 148 118 Void setUsedByCurr( Bool bUsed ) { m_bUsedByCurr = bUsed; } … … 178 148 179 149 Int getStride() { return m_apcPicYuv[1]->getStride(); } 180 #if AUXILIARY_PICTURES181 ChromaFormat getChromaFormat() const { return m_apcPicYuv[1]->getChromaFormat(); }182 #endif183 150 Int getCStride() { return m_apcPicYuv[1]->getCStride(); } 184 151 … … 201 168 Window& getDefDisplayWindow() { return m_defaultDisplayWindow; } 202 169 203 #if HM_CLEANUP_SAO204 170 Bool getSAOMergeAvailability(Int currAddr, Int mergeAddr); 205 #else206 Void createNonDBFilterInfo (std::vector<Int> sliceStartAddress, Int sliceGranularityDepth207 ,std::vector<Bool>* LFCrossSliceBoundary208 ,Int numTiles = 1209 ,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 #endif219 171 220 172 /* field coding parameters*/ … … 239 191 240 192 #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 241 212 Void copyUpsampledPictureYuv(TComPicYuv* pcPicYuvIn, TComPicYuv* pcPicYuvOut); 242 213 #if AVC_SYNTAX -
trunk/source/Lib/TLibCommon/TComPicSym.cpp
r540 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * … … 67 67 ,m_puiTileIdxMap(NULL) 68 68 ,m_puiInverseCUOrderMap(NULL) 69 #if HM_CLEANUP_SAO70 69 ,m_saoBlkParams(NULL) 71 #endif72 70 {}; 73 71 … … 131 129 } 132 130 133 #if HM_CLEANUP_SAO134 131 m_saoBlkParams = new SAOBlkParam[m_uiNumCUsInFrame]; 135 #else136 m_saoParam = NULL;137 #endif138 132 } 139 133 … … 191 185 m_puiInverseCUOrderMap = NULL; 192 186 193 #if HM_CLEANUP_SAO194 187 if(m_saoBlkParams) 195 188 { 196 189 delete[] m_saoBlkParams; m_saoBlkParams = NULL; 197 190 } 198 #else199 if (m_saoParam)200 {201 TComSampleAdaptiveOffset::freeSaoParam(m_saoParam);202 delete m_saoParam;203 m_saoParam = NULL;204 }205 #endif206 191 } 207 192 … … 347 332 } 348 333 349 350 #if HM_CLEANUP_SAO351 334 Void TComPicSym::deriveLoopFilterBoundaryAvailibility(Int ctu, 352 335 Bool& isLeftAvail, … … 419 402 if(ctuAboveRigtht != NULL) 420 403 { 421 Int curSliceStart TS = getCUOrderMap(ctuCurr->getSlice()->getSliceCurStartCUAddr()/m_uiNumPartitions);422 Int aboveRigthtSliceStart TS = getCUOrderMap(ctuAboveRigtht->getSlice()->getSliceCurStartCUAddr()/m_uiNumPartitions);423 424 isAboveRightAvail = (curSliceStart TS == aboveRigthtSliceStartTS)?(true):404 Int curSliceStartEncOrder = ctuCurr->getSlice()->getSliceCurStartCUAddr(); 405 Int aboveRigthtSliceStartEncOrder = ctuAboveRigtht->getSlice()->getSliceCurStartCUAddr(); 406 407 isAboveRightAvail = (curSliceStartEncOrder == aboveRigthtSliceStartEncOrder)?(true): 425 408 ( 426 (curSliceStart TS > aboveRigthtSliceStartTS)?(ctuCurr->getSlice()->getLFCrossSliceBoundaryFlag())409 (curSliceStartEncOrder > aboveRigthtSliceStartEncOrder)?(ctuCurr->getSlice()->getLFCrossSliceBoundaryFlag()) 427 410 :(ctuAboveRigtht->getSlice()->getLFCrossSliceBoundaryFlag()) 428 411 ); … … 431 414 if(ctuBelowLeft != NULL) 432 415 { 433 Int curSliceStart TS = getCUOrderMap(ctuCurr->getSlice()->getSliceCurStartCUAddr()/m_uiNumPartitions);434 Int belowLeftSliceStart TS = getCUOrderMap(ctuBelowLeft->getSlice()->getSliceCurStartCUAddr()/m_uiNumPartitions);435 436 isBelowLeftAvail = (curSliceStart TS == belowLeftSliceStartTS)?(true):416 Int curSliceStartEncOrder = ctuCurr->getSlice()->getSliceCurStartCUAddr(); 417 Int belowLeftSliceStartEncOrder = ctuBelowLeft->getSlice()->getSliceCurStartCUAddr(); 418 419 isBelowLeftAvail = (curSliceStartEncOrder == belowLeftSliceStartEncOrder)?(true): 437 420 ( 438 (curSliceStart TS > belowLeftSliceStartTS)?(ctuCurr->getSlice()->getLFCrossSliceBoundaryFlag())421 (curSliceStartEncOrder > belowLeftSliceStartEncOrder)?(ctuCurr->getSlice()->getLFCrossSliceBoundaryFlag()) 439 422 :(ctuBelowLeft->getSlice()->getLFCrossSliceBoundaryFlag()) 440 423 ); … … 456 439 457 440 } 458 #else459 Void TComPicSym::allocSaoParam(TComSampleAdaptiveOffset *sao)460 {461 m_saoParam = new SAOParam;462 sao->allocSaoParam(m_saoParam);463 }464 #endif465 441 466 442 TComTile::TComTile() -
trunk/source/Lib/TLibCommon/TComPicSym.h
r540 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * … … 105 105 UInt* m_puiCUOrderMap; //the map of LCU raster scan address relative to LCU encoding order 106 106 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 107 112 #if N0383_IL_CONSTRAINED_TILE_SETS_SEI 108 113 Int* m_piTileSetIdxMap; //the map of the tile set index relative to LCU raster scan address … … 110 115 Bool* m_pbSkippedTileSetFlag; 111 116 #endif 112 UInt* m_puiInverseCUOrderMap;113 114 #if HM_CLEANUP_SAO115 SAOBlkParam *m_saoBlkParams;116 #else117 SAOParam *m_saoParam;118 117 #endif 119 118 … … 130 129 UInt getNumberOfCUsInFrame() { return m_uiNumCUsInFrame; } 131 130 TComDataCU*& getCU( UInt uiCUAddr ) { return m_apcTComDataCU[uiCUAddr]; } 132 133 #if LAYER_CTB134 UInt getMaxCUWidth() { return m_uiMaxCUWidth; }135 UInt getMaxCUHeight() { return m_uiMaxCUHeight; }136 #endif137 138 #if AVC_SYNTAX139 UInt getMaxCUWidth() { return m_uiMaxCUWidth; }140 UInt getMaxCUHeight() { return m_uiMaxCUHeight; }141 UInt getMaxDepth() { return m_uhTotalDepth; }142 #endif143 131 144 132 Void setSlice(TComSlice* p, UInt i) { m_apcTComSlice[i] = p; } … … 158 146 UInt getCUOrderMap( Int encCUOrder ) { return *(m_puiCUOrderMap + (encCUOrder>=m_uiNumCUsInFrame ? m_uiNumCUsInFrame : encCUOrder)); } 159 147 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 160 168 #if N0383_IL_CONSTRAINED_TILE_SETS_SEI 161 169 Void setTileSetIdxMap( Int i, Int tileSetIdx, UChar setType, Bool skipFlag ) … … 169 177 Bool getSkippedTileSetFlag( Int i ) { return *(m_pbSkippedTileSetFlag + i); } 170 178 #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 187 180 };// END CLASS DEFINITION TComPicSym 188 181 -
trunk/source/Lib/TLibCommon/TComPicYuv.cpp
r494 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * -
trunk/source/Lib/TLibCommon/TComPicYuv.h
r494 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * … … 75 75 Int m_iPicWidth; ///< Width of picture 76 76 Int m_iPicHeight; ///< Height of picture 77 #if AUXILIARY_PICTURES78 ChromaFormat m_chromaFormatIDC; ////< Chroma Format79 #endif80 77 81 78 Int m_iCuWidth; ///< Width of Coding Unit (CU) … … 91 88 Int m_iChromaMarginY; 92 89 90 Bool m_bIsBorderExtended; 91 92 #if SVC_EXTENSION 93 #if AUXILIARY_PICTURES 94 ChromaFormat m_chromaFormatIDC; ////< Chroma Format 95 #endif 93 96 #if SVC_UPSAMPLING 94 97 Window m_conformanceWindow; 95 98 #endif 96 97 99 #if M0040_ADAPTIVE_RESOLUTION_CHANGE 98 100 Bool m_isReconstructed; 99 101 #endif 100 101 Bool m_bIsBorderExtended; 102 #endif //SVC_EXTENSION 102 103 103 104 protected: … … 136 137 Int getWidth () { return m_iPicWidth; } 137 138 Int getHeight () { return m_iPicHeight; } 138 #if AUXILIARY_PICTURES139 ChromaFormat getChromaFormat () const { return m_chromaFormatIDC; }140 #endif141 142 #if SVC_EXTENSION143 Void setHeight ( Int iPicHeight ) { m_iPicHeight = iPicHeight; }144 #endif145 139 146 140 Int getStride () { return (m_iPicWidth ) + (m_iLumaMarginX <<1); } … … 172 166 Pel* getCrAddr ( Int iCuAddr, Int uiAbsZorderIdx ) { return m_piPicOrgV + m_cuOffsetC[iCuAddr] + m_buOffsetC[g_auiZscanToRaster[uiAbsZorderIdx]]; } 173 167 174 #if SVC_UPSAMPLING175 Window& getConformanceWindow() { return m_conformanceWindow; }176 Void setConformanceWindow(Window& conformanceWindow ) { m_conformanceWindow = conformanceWindow; }177 #endif178 179 168 // ------------------------------------------------------------------------------------------------ 180 169 // Miscellaneous … … 193 182 Void dump (Char* pFileName, Bool bAdd = false); 194 183 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 195 193 #if M0040_ADAPTIVE_RESOLUTION_CHANGE 196 194 Void setReconstructed(Bool x) { m_isReconstructed = x; } 197 195 Bool isReconstructed() { return m_isReconstructed; } 198 196 #endif 199 200 197 #if AUXILIARY_PICTURES 198 ChromaFormat getChromaFormat () const { return m_chromaFormatIDC; } 201 199 Void convertToMonochrome(); 202 200 #endif 203 204 // Set border extension flag 205 Void setBorderExtension(Bool b) { m_bIsBorderExtended = b; } 201 #endif //SVC_EXTENSION 202 206 203 };// END CLASS DEFINITION TComPicYuv 207 204 -
trunk/source/Lib/TLibCommon/TComPicYuvMD5.cpp
r313 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * -
trunk/source/Lib/TLibCommon/TComPrediction.cpp
r494 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * … … 408 408 } 409 409 410 410 411 Void TComPrediction::motionCompensation ( TComDataCU* pcCU, TComYuv* pcYuvPred, RefPicList eRefPicList, Int iPartIdx ) 411 412 { -
trunk/source/Lib/TLibCommon/TComPrediction.h
r494 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * -
trunk/source/Lib/TLibCommon/TComRdCost.cpp
r540 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * … … 410 410 } 411 411 } 412 else if ( ( (iWidth % 4) == 0 ) && ( (iHeight % 4) == 0 ) ) 413 { 412 else 413 { 414 assert(iWidth % 4 == 0 && iHeight % 4 == 0); 415 414 416 for ( y=0; y<iHeight; y+= 4 ) 415 417 { … … 420 422 pi0 += iStride0*4; 421 423 pi1 += iStride1*4; 422 }423 }424 else425 {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;434 424 } 435 425 } -
trunk/source/Lib/TLibCommon/TComRdCost.h
r540 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * -
trunk/source/Lib/TLibCommon/TComRdCostWeightPrediction.cpp
r313 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * -
trunk/source/Lib/TLibCommon/TComRdCostWeightPrediction.h
r313 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * -
trunk/source/Lib/TLibCommon/TComRom.cpp
r588 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * … … 86 86 // Data structure related table & variable 87 87 // ==================================================================================================================== 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 98 89 UInt g_uiMaxCUWidth = MAX_CU_SIZE; 99 90 UInt g_uiMaxCUHeight = MAX_CU_SIZE; … … 106 97 107 98 UInt g_auiPUOffset[8] = { 0, 8, 4, 4, 2, 10, 1, 5}; 108 109 #if FAST_INTRA_SHVC110 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 #endif113 99 114 100 Void initZscanToRaster ( Int iMaxDepth, Int iDepth, UInt uiStartVal, UInt*& rpuiCurrIdx ) … … 321 307 UInt g_uiPCMBitDepthLuma = 8; // PCM bit-depth 322 308 UInt 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 333 310 // ==================================================================================================================== 334 311 // Misc. … … 528 505 529 506 #if SVC_EXTENSION 507 #if FAST_INTRA_SHVC 508 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 }; 509 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}; 510 #endif 511 #if O0194_DIFFERENT_BITDEPTH_EL_BL 512 Int g_bitDepthYLayer[MAX_LAYERS]; 513 Int g_bitDepthCLayer[MAX_LAYERS]; 514 515 UInt g_uiPCMBitDepthLumaDec[MAX_LAYERS]; // PCM bit-depth 516 UInt g_uiPCMBitDepthChromaDec[MAX_LAYERS]; // PCM bit-depth 517 #endif 518 #if O0194_WEIGHTED_PREDICTION_CGS 519 void * g_refWeightACDCParam; // type=wpACDCParam 520 #endif 530 521 Int g_mvScalingFactor [MAX_LAYERS][2] = {{0,0}, {0,0}}; 531 522 Int g_posScalingFactor [MAX_LAYERS][2] = {{0,0}, {0,0}}; … … 571 562 }; 572 563 } 564 #if LAYER_CTB 565 UInt g_auiLayerMaxCUWidth[MAX_LAYERS]; 566 UInt g_auiLayerMaxCUHeight[MAX_LAYERS]; 567 UInt g_auiLayerMaxCUDepth[MAX_LAYERS]; 568 UInt g_auiLayerAddCUDepth[MAX_LAYERS]; 569 UInt g_auiLayerZscanToRaster[MAX_LAYERS][ MAX_NUM_SPU_W*MAX_NUM_SPU_W ]; 570 UInt g_auiLayerRasterToZscan[MAX_LAYERS][ MAX_NUM_SPU_W*MAX_NUM_SPU_W ]; 571 UInt g_auiLayerRasterToPelX[MAX_LAYERS][ MAX_NUM_SPU_W*MAX_NUM_SPU_W ]; 572 UInt g_auiLayerRasterToPelY[MAX_LAYERS][ MAX_NUM_SPU_W*MAX_NUM_SPU_W ]; 573 573 #endif 574 #endif //SVC_EXTENSION 574 575 575 576 //! \} -
trunk/source/Lib/TLibCommon/TComRom.h
r588 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * … … 81 81 82 82 // global variable (LCU width/height, max. CU depth) 83 #if LAYER_CTB84 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 #endif93 83 extern UInt g_uiMaxCUWidth; 94 84 extern UInt g_uiMaxCUHeight; … … 139 129 140 130 extern const UChar g_aucIntraModeNumFast[ MAX_CU_DEPTH ]; 141 142 #if FAST_INTRA_SHVC143 extern UInt g_reducedSetIntraModes[NUM_INTRA_MODE-1];144 extern UInt g_predefSetIntraModes[NUM_INTRA_MODE-1];145 #endif146 131 147 132 // ==================================================================================================================== … … 287 272 288 273 #if SVC_EXTENSION 274 #if FAST_INTRA_SHVC 275 extern UInt g_reducedSetIntraModes[NUM_INTRA_MODE-1]; 276 extern UInt g_predefSetIntraModes[NUM_INTRA_MODE-1]; 277 #endif 289 278 extern Int g_mvScalingFactor [MAX_LAYERS][2]; 290 279 extern Int g_posScalingFactor [MAX_LAYERS][2]; 291 280 std::string NaluToStr( NalUnitType nalu ); 292 #endif 281 #if LAYER_CTB 282 extern UInt g_auiLayerMaxCUWidth[MAX_LAYERS]; 283 extern UInt g_auiLayerMaxCUHeight[MAX_LAYERS]; 284 extern UInt g_auiLayerMaxCUDepth[MAX_LAYERS]; 285 extern UInt g_auiLayerAddCUDepth[MAX_LAYERS]; 286 extern UInt g_auiLayerZscanToRaster[MAX_LAYERS][ MAX_NUM_SPU_W*MAX_NUM_SPU_W ]; 287 extern UInt g_auiLayerRasterToZscan[MAX_LAYERS][ MAX_NUM_SPU_W*MAX_NUM_SPU_W ]; 288 extern UInt g_auiLayerRasterToPelX[MAX_LAYERS][ MAX_NUM_SPU_W*MAX_NUM_SPU_W ]; 289 extern UInt g_auiLayerRasterToPelY[MAX_LAYERS][ MAX_NUM_SPU_W*MAX_NUM_SPU_W ]; 290 #endif 291 #endif //SVC_EXTENSION 293 292 294 293 //! \} -
trunk/source/Lib/TLibCommon/TComSampleAdaptiveOffset.cpp
r540 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * … … 44 44 //! \ingroup TLibCommon 45 45 //! \{ 46 #if HM_CLEANUP_SAO47 46 UInt g_saoMaxOffsetQVal[NUM_SAO_COMPONENTS]; 48 47 … … 698 697 return pBuf; 699 698 } 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 2022 700 /** PCM LF disable process. 2023 701 * \param pcPic picture (TComPic) pointer -
trunk/source/Lib/TLibCommon/TComSampleAdaptiveOffset.h
r540 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * … … 45 45 //! \{ 46 46 47 48 #if HM_CLEANUP_SAO49 47 // ==================================================================================================================== 50 48 // Constants … … 105 103 106 104 }; 107 #else108 109 // ====================================================================================================================110 // Constants111 // ====================================================================================================================112 113 #define SAO_MAX_DEPTH 4114 #define SAO_BO_BITS 5115 #define LUMA_GROUP_NUM (1<<SAO_BO_BITS)116 #define MAX_NUM_SAO_OFFSETS 4117 #define MAX_NUM_SAO_CLASS 33118 // ====================================================================================================================119 // Class definition120 // ====================================================================================================================121 122 /// Sample Adaptive Offset class123 class TComSampleAdaptiveOffset124 {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 chroma147 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 ALF160 TComPicYuv* m_pcYuvTmp; //!< temporary picture buffer pointer when non-across slice/tile boundary SAO is enabled161 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 granularity192 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 process207 };208 209 #endif210 105 211 106 //! \} -
trunk/source/Lib/TLibCommon/TComSlice.cpp
r588 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * … … 143 143 initWpAcDcParam(); 144 144 m_saoEnabledFlag = false; 145 #if HM_CLEANUP_SAO146 145 m_saoEnabledFlagChroma = false; 147 #endif148 146 } 149 147 … … 987 985 { 988 986 TComPic* rpcPic; 987 #if !FIX1172 989 988 setAssociatedIRAPPOC(pocCRA); 989 #endif 990 990 Int pocCurr = getPOC(); 991 991 … … 1277 1277 { 1278 1278 rpcPic = *(iterPic++); 1279 #if BUGFIX_INTRAPERIOD 1280 if(!rpcPic->getReconMark()) 1281 { 1282 continue; 1283 } 1284 #endif 1279 1285 if (rpcPic->getPOC() == this->getPOC()) 1280 1286 { … … 1373 1379 } 1374 1380 } 1381 1382 1375 1383 1376 1384 /** Function for applying picture marking based on the Reference Picture Set in pReferencePictureSet. … … 2176 2184 { 2177 2185 // 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 2181 2189 // For other layers 2182 2190 Int i, m, n; 2183 for( i = 1; i <= getNumLayerSets()- 1; i++ )2191 for( i = 1; i <= m_numLayerSets - 1; i++ ) 2184 2192 { 2185 2193 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; 2191 2199 n++; 2192 2200 } 2193 2201 } 2194 setNumLayersInIdList(i, n);2202 m_numLayerInIdList[i] = n; 2195 2203 } 2196 2204 } … … 2505 2513 , m_qpBDOffsetY ( 0) 2506 2514 , m_qpBDOffsetC ( 0) 2507 , m_useLossless (false)2508 2515 , m_uiPCMBitDepthLuma ( 8) 2509 2516 , m_uiPCMBitDepthChroma ( 8) -
trunk/source/Lib/TLibCommon/TComSlice.h
r588 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * … … 714 714 UInt getNumReorderPics(UInt tLayer) { return m_numReorderPics[tLayer]; } 715 715 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; } 717 717 UInt getMaxDecPicBuffering(UInt tLayer) { return m_uiMaxDecPicBuffering[tLayer]; } 718 718 … … 1320 1320 Int m_qpBDOffsetC; 1321 1321 1322 Bool m_useLossless;1323 1324 1322 UInt m_uiPCMBitDepthLuma; 1325 1323 UInt m_uiPCMBitDepthChroma; … … 1340 1338 Bool m_scalingListEnabledFlag; 1341 1339 Bool m_scalingListPresentFlag; 1342 1343 1340 TComScalingList* m_scalingList; //!< ScalingList class pointer 1344 1345 1341 UInt m_uiMaxDecPicBuffering[MAX_TLAYER]; 1346 1342 UInt m_uiMaxLatencyIncrease[MAX_TLAYER]; // Really max latency increase plus 1 (value 0 expresses no limit) … … 1456 1452 UInt getMaxTrSize () { return m_uiMaxTrSize; } 1457 1453 1458 // Tool list1459 Bool getUseLossless () { return m_useLossless; }1460 Void setUseLossless ( Bool b ) { m_useLossless = b; }1461 1462 1454 // AMP accuracy 1463 1455 Int getAMPAcc ( UInt uiDepth ) { return m_iAMPAcc[uiDepth]; } … … 1499 1491 #endif 1500 1492 TComScalingList* getScalingList () { return m_scalingList; } //!< get ScalingList class pointer in SPS 1501 1502 1493 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; } 1504 1495 UInt getMaxLatencyIncrease (UInt tlayer) { return m_uiMaxLatencyIncrease[tlayer]; } 1505 1496 Void setMaxLatencyIncrease ( UInt ui , UInt tlayer) { m_uiMaxLatencyIncrease[tlayer] = ui; } -
trunk/source/Lib/TLibCommon/TComTrQuant.cpp
r540 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * … … 1082 1082 UInt uiLog2TrSize = g_aucConvertToBit[ iWidth ] + 2; 1083 1083 Int scalingListType = (pcCU->isIntra(uiAbsPartIdx) ? 0 : 3) + g_eTTable[(Int)eTType]; 1084 assert(scalingListType < 6);1084 assert(scalingListType < SCALING_LIST_NUM); 1085 1085 Int *piQuantCoeff = 0; 1086 1086 piQuantCoeff = getQuantCoeff(scalingListType,m_cQP.m_iRem,uiLog2TrSize-2); … … 1321 1321 Pel* pResi = rpcResidual + uiAddr; 1322 1322 Int scalingListType = (pcCU->isIntra(uiAbsPartIdx) ? 0 : 3) + g_eTTable[(Int)eTxt]; 1323 assert(scalingListType < 6);1323 assert(scalingListType < SCALING_LIST_NUM); 1324 1324 invtransformNxN( pcCU->getCUTransquantBypass(uiAbsPartIdx), eTxt, REG_DCT, pResi, uiStride, rpcCoeff, uiWidth, uiHeight, scalingListType, pcCU->getTransformSkip(uiAbsPartIdx, eTxt) ); 1325 1325 } … … 1522 1522 const UInt uiMaxNumCoeff = uiWidth * uiHeight; 1523 1523 Int scalingListType = (pcCU->isIntra(uiAbsPartIdx) ? 0 : 3) + g_eTTable[(Int)eTType]; 1524 assert(scalingListType < 6);1524 assert(scalingListType < SCALING_LIST_NUM); 1525 1525 1526 1526 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 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * -
trunk/source/Lib/TLibCommon/TComWeightPrediction.cpp
r313 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * -
trunk/source/Lib/TLibCommon/TComWeightPrediction.h
r442 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * -
trunk/source/Lib/TLibCommon/TComYuv.cpp
r345 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * … … 604 604 { 605 605 #if DISABLING_CLIP_FOR_BIPREDME 606 pDst[x ] = (pDst[x ]<<1) - pSrc[x ];606 pDst[x ] = 2 * pDst[x] - pSrc[x]; 607 607 #else 608 pDst[x ] = Clip ( (pDst[x ]<<1) - pSrc[x ]);608 pDst[x ] = ClipY(2 * pDst[x] - pSrc[x]); 609 609 #endif 610 610 } … … 624 624 { 625 625 #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]; 628 628 #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]); 631 631 #endif 632 632 } -
trunk/source/Lib/TLibCommon/TComYuv.h
r345 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * -
trunk/source/Lib/TLibCommon/TypeDef.h
r588 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * … … 59 59 #define RESOLUTION_BASED_DPB 1 ///< JCTVC-P0192: Assign layers to sub-DPBs based on the rep_format() signaled in the VPS 60 60 #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 61 64 #define O0109_O0199_FLAGS_TO_VUI 1 ///< JCTVC-O0109, O0199: move single_layer_for_non_irap_flag and higher_layer_flag to vps_vui 62 65 #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 … … 112 115 #if VPS_EXTNS 113 116 #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 114 120 #define VPS_EXTN_OP_LAYER_SETS 1 ///< Include output layer sets in VPS extension 115 121 #define VPS_EXTN_PROFILE_INFO 1 ///< Include profile information for layer sets in VPS extension … … 222 228 #define O0149_CROSS_LAYER_BLA_FLAG 1 ///< JCTVC-O0149: signal cross_layer_bla_flag in slice header 223 229 230 #if VIEW_ID_RELATED_SIGNALING 231 /// scalability types 232 enum ScalabilityType 233 { 234 VIEW_ORDER_INDEX = 1, 235 SCALABILITY_ID = 2, 236 }; 237 #endif 238 224 239 #else 225 240 #define SYNTAX_OUTPUT 0 … … 229 244 //! \ingroup TLibCommon 230 245 //! \{ 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 234 247 #define SAO_ENCODE_ALLOW_USE_PREDEBLOCK 1 235 #endif 248 249 #define FIX1172 1 ///< fix ticket #1172 236 250 237 251 #define MAX_NUM_PICS_IN_SOP 1024 … … 240 254 #define MAX_NESTING_NUM_LAYER 64 241 255 242 #if VPS_EXTN_MASK_AND_DIM_INFO 243 #define MAX_VPS_NUM_SCALABILITY_TYPES 16 244 #endif 256 #if VPS_RENAME 245 257 #define MAX_VPS_OP_LAYER_SETS_PLUS1 3 246 #if VPS_RENAME247 258 #define MAX_VPS_LAYER_SETS_PLUS1 1024 248 259 #define MAX_VPS_LAYER_ID_PLUS1 MAX_LAYERS … … 253 264 #endif 254 265 255 #if SUB_BITSTREAM_PROPERTY_SEI256 #define MAX_SUB_STREAMS 1024257 #endif258 259 266 #define MAX_CPB_CNT 32 ///< Upper bound of (cpb_cnt_minus1 + 1) 260 267 #if O0137_MAX_LAYERID … … 277 284 #define C1FLAG_NUMBER 8 // maximum number of largerThan1 flag coded in one chunk : 16 in HM5 278 285 #define C2FLAG_NUMBER 1 // maximum number of largerThan2 flag coded in one chunk: 16 in HM5 279 #if !HM_CLEANUP_SAO280 #define REMOVE_SAO_LCU_ENC_CONSTRAINTS_3 1 ///< disable the encoder constraint that conditionally disable SAO for chroma for entire slice in interleaved mode281 #endif282 286 #define SAO_ENCODING_CHOICE 1 ///< I0184: picture early termination 283 287 #if SAO_ENCODING_CHOICE … … 383 387 typedef bool Bool; 384 388 389 #ifdef __arm__ 390 typedef signed char Char; 391 #else 385 392 typedef char Char; 393 #endif 386 394 typedef unsigned char UChar; 387 395 typedef short Short; … … 432 440 }; 433 441 434 #if HM_CLEANUP_SAO435 442 enum SAOComponentIdx 436 443 { … … 523 530 }; 524 531 525 526 #else527 #define NUM_DOWN_PART 4528 529 enum SAOTypeLen530 {531 SAO_EO_LEN = 4,532 SAO_BO_LEN = 4,533 SAO_MAX_BO_CLASSES = 32534 };535 536 enum SAOType537 {538 SAO_EO_0 = 0,539 SAO_EO_1,540 SAO_EO_2,541 SAO_EO_3,542 SAO_BO,543 MAX_NUM_SAO_TYPE544 };545 546 typedef struct _SaoQTPart547 {548 Int iBestType;549 Int iLength;550 Int subTypeIdx ; ///< indicates EO class or BO band position551 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 _SaoLcuParam576 {577 Bool mergeUpFlag;578 Bool mergeLeftFlag;579 Int typeIdx;580 Int subTypeIdx; ///< indicates EO class or BO band position581 Int offset[4];582 Int partIdx;583 Int partIdxTmp;584 Int length;585 } SaoLcuParam;586 587 struct SAOParam588 {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 #endif599 532 /// parameters for deblocking filter 600 533 typedef struct _LFCUParam … … 788 721 }; 789 722 } 790 #if VIEW_ID_RELATED_SIGNALING791 /// scalability types792 enum ScalabilityType793 {794 VIEW_ORDER_INDEX = 1,795 SCALABILITY_ID = 2,796 };797 #endif798 723 //! \} 799 724 -
trunk/source/Lib/TLibDecoder/AnnexBread.cpp
r313 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * -
trunk/source/Lib/TLibDecoder/AnnexBread.h
r313 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * -
trunk/source/Lib/TLibDecoder/NALread.cpp
r540 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * … … 70 70 break; 71 71 } 72 assert(*it_read <= 0x03); 72 73 } 73 74 zeroCount = (*it_read == 0x00) ? zeroCount+1 : 0; -
trunk/source/Lib/TLibDecoder/NALread.h
r313 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * -
trunk/source/Lib/TLibDecoder/SEIread.cpp
r588 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * … … 93 93 fprintf( g_hTrace, "===========Tone Mapping Info SEI message ===========\n"); 94 94 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 95 102 #if LAYERS_NOT_PRESENT_SEI 96 103 case SEI::LAYERS_NOT_PRESENT: … … 98 105 break; 99 106 #endif 100 case SEI::SOP_DESCRIPTION:101 fprintf( g_hTrace, "=========== SOP Description SEI message ===========\n");102 break;103 107 #if N0383_IL_CONSTRAINED_TILE_SETS_SEI 104 108 case SEI::INTER_LAYER_CONSTRAINED_TILE_SETS: … … 111 115 break; 112 116 #endif 113 case SEI::SCALABLE_NESTING: 114 fprintf( g_hTrace, "=========== Scalable Nesting SEI message ===========\n"); 115 break; 117 #endif //SVC_EXTENSION 116 118 default: 117 119 fprintf( g_hTrace, "=========== Unknown SEI message ===========\n"); … … 259 261 xParseSEIToneMappingInfo((SEIToneMappingInfo&) *sei, payloadSize); 260 262 break; 261 #if LAYERS_NOT_PRESENT_SEI262 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 else268 {269 sei = new SEILayersNotPresent;270 xParseSEILayersNotPresent((SEILayersNotPresent&) *sei, payloadSize, vps);271 }272 break;273 #endif274 263 case SEI::SOP_DESCRIPTION: 275 264 sei = new SEISOPDescription; 276 265 xParseSEISOPDescription((SEISOPDescription&) *sei, payloadSize); 277 266 break; 278 #if N0383_IL_CONSTRAINED_TILE_SETS_SEI279 case SEI::INTER_LAYER_CONSTRAINED_TILE_SETS:280 sei = new SEIInterLayerConstrainedTileSets;281 xParseSEIInterLayerConstrainedTileSets((SEIInterLayerConstrainedTileSets&) *sei, payloadSize);282 break;283 #endif284 #if SUB_BITSTREAM_PROPERTY_SEI285 case SEI::SUB_BITSTREAM_PROPERTY:286 sei = new SEISubBitstreamProperty;287 xParseSEISubBitstreamProperty((SEISubBitstreamProperty&) *sei);288 break;289 #endif290 267 case SEI::SCALABLE_NESTING: 291 268 sei = new SEIScalableNesting; … … 295 272 xParseSEIScalableNesting((SEIScalableNesting&) *sei, nalUnitType, payloadSize, sps); 296 273 #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 297 301 break; 298 302 default: … … 499 503 if( !pHRD->getSubPicCpbParamsPresentFlag() ) 500 504 { 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; 502 511 } 503 512 //read splicing flag and cpb_removal_delay_delta … … 506 515 READ_CODE( ( pHRD->getCpbRemovalDelayLengthMinus1() + 1 ), code, "au_cpb_removal_delay_delta_minus1" ); 507 516 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 }513 517 for( nalOrVcl = 0; nalOrVcl < 2; nalOrVcl ++ ) 514 518 { … … 752 756 } 753 757 754 #if LAYERS_NOT_PRESENT_SEI755 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 #endif774 775 758 Void SEIReader::xParseSEISOPDescription(SEISOPDescription &sei, UInt payloadSize) 776 759 { … … 797 780 } 798 781 799 #if N0383_IL_CONSTRAINED_TILE_SETS_SEI800 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 else814 {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 else835 {836 READ_CODE( 2, uiCode, "all_tiles_ilc_idc" ); sei.m_allTilesIlcIdc = uiCode;837 }838 839 xParseByteAlign();840 }841 #endif842 #if SUB_BITSTREAM_PROPERTY_SEI843 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 #endif860 782 #if LAYERS_NOT_PRESENT_SEI 861 783 Void SEIReader::xParseSEIScalableNesting(SEIScalableNesting& sei, const NalUnitType nalUnitType, UInt payloadSize, TComVPS *vps, TComSPS *sps) … … 925 847 } 926 848 } 849 850 #if SVC_EXTENSION 851 #if LAYERS_NOT_PRESENT_SEI 852 Void 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 872 Void 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 915 Void 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 927 934 //! \} -
trunk/source/Lib/TLibDecoder/SEIread.h
r588 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * -
trunk/source/Lib/TLibDecoder/SyntaxElementParser.cpp
r442 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * -
trunk/source/Lib/TLibDecoder/SyntaxElementParser.h
r313 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * -
trunk/source/Lib/TLibDecoder/TDecBinCoder.h
r313 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * -
trunk/source/Lib/TLibDecoder/TDecBinCoderCABAC.cpp
r313 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * -
trunk/source/Lib/TLibDecoder/TDecBinCoderCABAC.h
r313 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * -
trunk/source/Lib/TLibDecoder/TDecCAVLC.cpp
r588 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * … … 673 673 READ_UVLC( uiCode, "log2_diff_max_min_coding_block_size" ); 674 674 pcSPS->setLog2DiffMaxMinCodingBlockSize(uiCode); 675 676 if (pcSPS->getPTL()->getGeneralPTL()->getLevelIdc() >= Level::LEVEL5) 677 { 678 assert(log2MinCUSize + pcSPS->getLog2DiffMaxMinCodingBlockSize() >= 5); 679 } 680 675 681 Int maxCUDepthDelta = uiCode; 676 682 pcSPS->setMaxCUWidth ( 1<<(log2MinCUSize + maxCUDepthDelta) ); -
trunk/source/Lib/TLibDecoder/TDecCAVLC.h
r588 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * -
trunk/source/Lib/TLibDecoder/TDecCu.cpp
r540 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * … … 532 532 m_pcPrediction->predIntraLumaAng( pcCU->getPattern(), uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight, bAboveAvail, bLeftAvail ); 533 533 534 if ( pcCU->getCbf( uiAbsPartIdx, TEXT_LUMA, uiTrDepth ) ) 535 { 534 536 //===== inverse transform ===== 535 537 #if REPN_FORMAT_IN_VPS … … 540 542 541 543 Int scalingListType = (pcCU->isIntra(uiAbsPartIdx) ? 0 : 3) + g_eTTable[(Int)TEXT_LUMA]; 542 assert(scalingListType < 6);544 assert(scalingListType < SCALING_LIST_NUM); 543 545 m_pcTrQuant->invtransformNxN( pcCU->getCUTransquantBypass(uiAbsPartIdx), TEXT_LUMA, pcCU->getLumaIntraDir( uiAbsPartIdx ), piResi, uiStride, pcCoeff, uiWidth, uiHeight, scalingListType, useTransformSkip ); 544 546 … … 560 562 pReco += uiStride; 561 563 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 } 562 583 } 563 584 } … … 624 645 m_pcPrediction->predIntraChromaAng( pPatChroma, uiChromaPredMode, piPred, uiStride, uiWidth, uiHeight, bAboveAvail, bLeftAvail ); 625 646 647 if ( pcCU->getCbf( uiAbsPartIdx, eText, uiTrDepth ) ) 648 { 626 649 //===== inverse transform ===== 627 650 Int curChromaQpOffset; … … 646 669 647 670 Int scalingListType = (pcCU->isIntra(uiAbsPartIdx) ? 0 : 3) + g_eTTable[(Int)eText]; 648 assert(scalingListType < 6);671 assert(scalingListType < SCALING_LIST_NUM); 649 672 m_pcTrQuant->invtransformNxN( pcCU->getCUTransquantBypass(uiAbsPartIdx), eText, REG_DCT, piResi, uiStride, pcCoeff, uiWidth, uiHeight, scalingListType, useTransformSkipChroma ); 650 673 … … 665 688 pReco += uiStride; 666 689 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 } 667 709 } 668 710 } -
trunk/source/Lib/TLibDecoder/TDecCu.h
r345 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * -
trunk/source/Lib/TLibDecoder/TDecEntropy.cpp
r345 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * … … 319 319 } 320 320 321 Void TDecEntropy::xDecodeTransform( TComDataCU* pcCU, UInt offsetLuma, UInt offsetChroma, UInt uiAbsPartIdx, UInt uiDepth, UInt width, UInt height, UInt uiTrIdx, Bool& bCodeDQP )321 Void TDecEntropy::xDecodeTransform( TComDataCU* pcCU, UInt offsetLuma, UInt offsetChroma, UInt uiAbsPartIdx, UInt uiDepth, UInt width, UInt height, UInt uiTrIdx, Bool& bCodeDQP, Int quadtreeTULog2MinSizeInCU) 322 322 { 323 323 UInt uiSubdiv; … … 343 343 else if( (pcCU->getSlice()->getSPS()->getQuadtreeTUMaxDepthInter() == 1) && (pcCU->getPredictionMode(uiAbsPartIdx) == MODE_INTER) && ( pcCU->getPartitionSize(uiAbsPartIdx) != SIZE_2Nx2N ) && (uiDepth == pcCU->getDepth(uiAbsPartIdx)) ) 344 344 { 345 uiSubdiv = (uiLog2TrafoSize > pcCU->getQuadtreeTULog2MinSizeInCU(uiAbsPartIdx));345 uiSubdiv = (uiLog2TrafoSize > quadtreeTULog2MinSizeInCU); 346 346 } 347 347 else if( uiLog2TrafoSize > pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() ) … … 353 353 uiSubdiv = 0; 354 354 } 355 else if( uiLog2TrafoSize == pcCU->getQuadtreeTULog2MinSizeInCU(uiAbsPartIdx))355 else if( uiLog2TrafoSize == quadtreeTULog2MinSizeInCU ) 356 356 { 357 357 uiSubdiv = 0; … … 359 359 else 360 360 { 361 assert( uiLog2TrafoSize > pcCU->getQuadtreeTULog2MinSizeInCU(uiAbsPartIdx));361 assert( uiLog2TrafoSize > quadtreeTULog2MinSizeInCU ); 362 362 m_pcEntropyDecoderIf->parseTransformSubdivFlag( uiSubdiv, 5 - uiLog2TrafoSize ); 363 363 } … … 405 405 for( Int i = 0; i < 4; i++ ) 406 406 { 407 xDecodeTransform( pcCU, offsetLuma, offsetChroma, uiAbsPartIdx, uiDepth, width, height, uiTrIdx, bCodeDQP );407 xDecodeTransform( pcCU, offsetLuma, offsetChroma, uiAbsPartIdx, uiDepth, width, height, uiTrIdx, bCodeDQP, quadtreeTULog2MinSizeInCU ); 408 408 uiYCbf |= pcCU->getCbf( uiAbsPartIdx, TEXT_LUMA, uiTrDepth+1 ); 409 409 uiUCbf |= pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepth+1 ); … … 553 553 554 554 } 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 ); 556 559 } 557 560 -
trunk/source/Lib/TLibDecoder/TDecEntropy.h
r540 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * … … 167 167 168 168 private: 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 ); 170 170 171 171 public: -
trunk/source/Lib/TLibDecoder/TDecGop.cpp
r588 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * … … 128 128 //-- For time output for each slice 129 129 long iBeforeTime = clock(); 130 #if !HM_CLEANUP_SAO131 UInt uiStartCUAddr = pcSlice->getSliceSegmentCurStartCUAddr();132 133 UInt uiSliceStartCuAddr = pcSlice->getSliceCurStartCUAddr();134 if(uiSliceStartCuAddr == uiStartCUAddr)135 {136 m_sliceStartCUAddress.push_back(uiSliceStartCuAddr);137 }138 #endif139 130 m_pcSbacDecoder->init( (TDecBinIf*)m_pcBinCABAC ); 140 131 m_pcEntropyDecoder->setEntropyDecoder (m_pcSbacDecoder); … … 163 154 m_pcEntropyDecoder->setBitstream ( ppcSubstreams[0] ); 164 155 m_pcEntropyDecoder->resetEntropy (pcSlice); 165 #if !HM_CLEANUP_SAO166 if(uiSliceStartCuAddr == uiStartCUAddr)167 {168 m_LFCrossSliceBoundaryFlag.push_back( pcSlice->getLFCrossSliceBoundaryFlag());169 }170 #endif171 156 m_pcSbacDecoders[0].load(m_pcSbacDecoder); 172 157 m_pcSliceDecoder->decompressSlice( ppcSubstreams, rpcPic, m_pcSbacDecoder, m_pcSbacDecoders); … … 196 181 m_pcLoopFilter->setCfg(bLFCrossTileBoundary); 197 182 m_pcLoopFilter->loopFilterPic( rpcPic ); 198 #if !HM_CLEANUP_SAO199 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 #endif205 183 if( pcSlice->getSPS()->getUseSAO() ) 206 184 { 207 #if HM_CLEANUP_SAO208 185 m_pcSAO->reconstructBlkSAOParams(rpcPic, rpcPic->getPicSym()->getSAOBlkParam()); 209 186 m_pcSAO->SAOProcess(rpcPic); 210 187 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 } 230 189 rpcPic->compressMotion(); 231 190 Char c = (pcSlice->isIntra() ? 'I' : pcSlice->isInterP() ? 'P' : 'B'); … … 291 250 rpcPic->setOutputMark(true); 292 251 rpcPic->setReconMark(true); 293 #if !HM_CLEANUP_SAO294 m_sliceStartCUAddress.clear();295 m_LFCrossSliceBoundaryFlag.clear();296 #endif297 252 } 298 253 -
trunk/source/Lib/TLibDecoder/TDecGop.h
r540 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * … … 83 83 Int m_decodedPictureHashSEIEnabled; ///< Checksum(3)/CRC(2)/MD5(1)/disable(0) acting on decoded picture hash SEI message 84 84 85 #if !HM_CLEANUP_SAO86 //! list that contains the CU address of each slice plus the end address87 std::vector<Int> m_sliceStartCUAddress;88 std::vector<Bool> m_LFCrossSliceBoundaryFlag;89 #endif90 85 #if SVC_EXTENSION 91 86 UInt m_layerId; -
trunk/source/Lib/TLibDecoder/TDecSbac.cpp
r540 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * … … 72 72 , m_cCUAbsSCModel ( 1, 1, NUM_ABS_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) 73 73 , 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)75 74 , m_cSaoMergeSCModel ( 1, 1, NUM_SAO_MERGE_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) 76 75 , m_cSaoTypeIdxSCModel ( 1, 1, NUM_SAO_TYPE_IDX_CTX , m_contextModels + m_numContextModels, m_numContextModels) … … 114 113 m_cCUMergeIdxExtSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_MERGE_IDX_EXT ); 115 114 m_cCUPartSizeSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_PART_SIZE ); 116 m_cCUAMPSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_CU_AMP_POS );117 115 m_cCUPredModeSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_PRED_MODE ); 118 116 m_cCUIntraPredSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_INTRA_PRED_MODE ); … … 160 158 m_cCUMergeIdxExtSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_MERGE_IDX_EXT ); 161 159 m_cCUPartSizeSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_PART_SIZE ); 162 m_cCUAMPSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_CU_AMP_POS );163 160 m_cCUPredModeSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_PRED_MODE ); 164 161 m_cCUIntraPredSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_INTRA_PRED_MODE ); … … 579 576 if (eMode == SIZE_2NxN) 580 577 { 581 m_pcTDecBinIf->decodeBin(uiSymbol, m_cCU AMPSCModel.get( 0, 0, 0));578 m_pcTDecBinIf->decodeBin(uiSymbol, m_cCUPartSizeSCModel.get( 0, 0, 3 )); 582 579 if (uiSymbol == 0) 583 580 { … … 588 585 else if (eMode == SIZE_Nx2N) 589 586 { 590 m_pcTDecBinIf->decodeBin(uiSymbol, m_cCU AMPSCModel.get( 0, 0, 0));587 m_pcTDecBinIf->decodeBin(uiSymbol, m_cCUPartSizeSCModel.get( 0, 0, 3 )); 591 588 if (uiSymbol == 0) 592 589 { … … 1382 1379 if (uiCode == 0) 1383 1380 { 1384 #if HM_CLEANUP_SAO1385 1381 ruiVal = 1; 1386 #else1387 ruiVal = 5;1388 #endif1389 1382 } 1390 1383 else 1391 1384 { 1392 #if HM_CLEANUP_SAO1393 1385 ruiVal = 2; 1394 #else 1395 ruiVal = 1; 1396 #endif 1397 } 1398 } 1399 } 1400 1401 #if HM_CLEANUP_SAO 1386 } 1387 } 1388 } 1402 1389 1403 1390 Void TDecSbac::parseSaoSign(UInt& val) … … 1531 1518 } 1532 1519 1533 #else1534 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 else1550 {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_LEN1569 };1570 1571 if (compIdx==2)1572 {1573 uiSymbol = (UInt)( psSaoLcuParam->typeIdx + 1);1574 }1575 else1576 {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 else1623 {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 else1670 {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 else1681 {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 else1690 {1691 copySaoOneLcuParam(&pSaoParam->saoLcuParam[iCompIdx][iAddr], &pSaoParam->saoLcuParam[iCompIdx][iAddr-pSaoParam->numCuInWidth]);1692 }1693 }1694 else1695 {1696 copySaoOneLcuParam(&pSaoParam->saoLcuParam[iCompIdx][iAddr], &pSaoParam->saoLcuParam[iCompIdx][iAddr-1]);1697 }1698 }1699 else1700 {1701 pSaoParam->saoLcuParam[iCompIdx][iAddr].typeIdx = -1;1702 pSaoParam->saoLcuParam[iCompIdx][iAddr].subTypeIdx = 0;1703 }1704 }1705 }1706 1707 #endif1708 1709 1520 /** 1710 1521 - Initialize our contexts from the nominated source. -
trunk/source/Lib/TLibDecoder/TDecSbac.h
r540 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * … … 90 90 Void parseSaoTypeIdx ( UInt& ruiVal ); 91 91 Void parseSaoUflc ( UInt uiLength, UInt& ruiVal ); 92 #if HM_CLEANUP_SAO93 92 Void parseSAOBlkParam (SAOBlkParam& saoBlkParam, Bool* sliceEnabled, Bool leftMergeAvail, Bool aboveMergeAvail); 94 93 Void parseSaoSign(UInt& val); 95 #else96 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 #endif99 94 private: 100 95 Void xReadUnarySymbol ( UInt& ruiSymbol, ContextModel* pcSCModel, Int iOffset ); … … 171 166 ContextModel3DBuffer m_cMVPIdxSCModel; 172 167 173 ContextModel3DBuffer m_cCUAMPSCModel;174 168 ContextModel3DBuffer m_cSaoMergeSCModel; 175 169 ContextModel3DBuffer m_cSaoTypeIdxSCModel; -
trunk/source/Lib/TLibDecoder/TDecSlice.cpp
r540 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * … … 323 323 #endif 324 324 325 #if HM_CLEANUP_SAO326 325 if ( pcSlice->getSPS()->getUseSAO() ) 327 326 { … … 358 357 } 359 358 } 360 #else361 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 #endif413 359 414 360 m_pcCuDecoder->decodeCU ( pcCU, uiIsLast ); -
trunk/source/Lib/TLibDecoder/TDecSlice.h
r442 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * -
trunk/source/Lib/TLibDecoder/TDecTop.cpp
r588 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * … … 404 404 #endif 405 405 #endif 406 #if !HM_CLEANUP_SAO407 rpcPic->getPicSym()->allocSaoParam(&m_cSAO);408 #endif409 406 m_cListPic.pushBack( rpcPic ); 410 407 … … 485 482 #endif 486 483 #endif 487 #endif488 #if !HM_CLEANUP_SAO489 rpcPic->getPicSym()->allocSaoParam(&m_cSAO);490 484 #endif 491 485 } … … 784 778 #if REPN_FORMAT_IN_VPS 785 779 #if AUXILIARY_PICTURES 786 #if HM_CLEANUP_SAO787 780 m_cSAO.create( m_apcSlicePilot->getPicWidthInLumaSamples(), m_apcSlicePilot->getPicHeightInLumaSamples(), sps->getChromaFormatIdc(), sps->getMaxCUWidth(), sps->getMaxCUHeight(), sps->getMaxCUDepth() ); 788 781 #else 789 m_cSAO.create( m_apcSlicePilot->getPicWidthInLumaSamples(), m_apcSlicePilot->getPicHeightInLumaSamples(), sps->getMaxCUWidth(), sps->getMaxCUHeight() );790 #endif791 #else792 #if HM_CLEANUP_SAO793 782 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 800 785 m_cSAO.create( sps->getPicWidthInLumaSamples(), sps->getPicHeightInLumaSamples(), sps->getMaxCUWidth(), sps->getMaxCUHeight(), sps->getMaxCUDepth() ); 801 #else802 m_cSAO.create( sps->getPicWidthInLumaSamples(), sps->getPicHeightInLumaSamples(), sps->getMaxCUWidth(), sps->getMaxCUHeight() );803 #endif804 786 #endif 805 787 m_cLoopFilter.create( sps->getMaxCUDepth() ); … … 817 799 { 818 800 TComPic*& pcPic = m_pcPic; 801 #if SVC_EXTENSION 819 802 #if NO_CLRAS_OUTPUT_FLAG 820 803 Bool bFirstSliceInSeq; 821 804 #endif 822 #if SVC_EXTENSION823 805 m_apcSlicePilot->setVPS( m_parameterSetManagerDecoder.getPrefetchedVPS(0) ); 824 806 #if OUTPUT_LAYER_SET_INDEX … … 831 813 #endif 832 814 m_apcSlicePilot->initSlice( nalu.m_layerId ); 833 #else 815 #else //SVC_EXTENSION 834 816 m_apcSlicePilot->initSlice(); 835 817 #endif … … 839 821 m_uiSliceIdx = 0; 840 822 } 823 else 824 { 825 m_apcSlicePilot->copySliceInfo( pcPic->getPicSym()->getSlice(m_uiSliceIdx-1) ); 826 } 841 827 m_apcSlicePilot->setSliceIdx(m_uiSliceIdx); 842 if (!m_bFirstSliceInPicture)843 {844 m_apcSlicePilot->copySliceInfo( pcPic->getPicSym()->getSlice(m_uiSliceIdx-1) );845 }846 828 847 829 m_apcSlicePilot->setNalUnitType(nalu.m_nalUnitType); … … 857 839 858 840 #if SVC_EXTENSION 859 m_apcSlicePilot->setSliceIdx( m_uiSliceIdx ); // it should be removed if HM will reflect it in above860 841 #if VPS_EXTN_DIRECT_REF_LAYERS 861 842 setRefLayerParams(m_apcSlicePilot->getVPS()); … … 1875 1856 return false; 1876 1857 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 1877 1903 default: 1878 1904 assert (0); … … 1954 1980 } 1955 1981 1982 #if SVC_EXTENSION 1956 1983 #if VPS_EXTN_DIRECT_REF_LAYERS 1957 1984 TDecTop* TDecTop::getRefLayerDec( UInt refLayerIdc ) … … 1968 1995 1969 1996 #if VPS_EXTN_DIRECT_REF_LAYERS 1970 1971 1997 Void TDecTop::setRefLayerParams( TComVPS* vps ) 1972 1998 { … … 2137 2163 } 2138 2164 #endif 2165 #endif //SVC_EXTENSION 2139 2166 //! \} -
trunk/source/Lib/TLibDecoder/TDecTop.h
r588 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * … … 221 221 Void xInitILRP(TComSPS *pcSPS); 222 222 #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 224 237 #if AVC_SYNTAX || SYNTAX_OUTPUT 225 238 Void setBLSyntaxFile( fstream* pFile ) { m_pBLSyntaxFile = pFile; } … … 256 269 Void setNoOutputOfPriorPicsFlags(Bool x) { m_noOutputOfPriorPicsFlags = x; } 257 270 #endif 258 public:259 #if OUTPUT_LAYER_SET_INDEX260 CommonDecoderParams* getCommonDecoderParams() { return m_commonDecoderParams; }261 Void setCommonDecoderParams(CommonDecoderParams* x) { m_commonDecoderParams = x; }262 Void checkValueOfTargetOutputLayerSetIdx(TComVPS *vps);263 #endif264 #if SCALINGLIST_INFERRING265 ParameterSetManagerDecoder* getParameterSetManager() { return &m_parameterSetManagerDecoder; }266 #endif267 #if RESOLUTION_BASED_DPB268 Void setSubDpbIdx(Int idx) { m_subDpbIdx = idx; }269 Int getSubDpbIdx() { return m_subDpbIdx; }270 Void assignSubDpbs(TComVPS *vps);271 #endif272 271 };// END CLASS DEFINITION TDecTop 273 272 -
trunk/source/Lib/TLibEncoder/AnnexBwrite.h
r313 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * -
trunk/source/Lib/TLibEncoder/NALwrite.cpp
r588 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * -
trunk/source/Lib/TLibEncoder/NALwrite.h
r313 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * -
trunk/source/Lib/TLibEncoder/SEIwrite.cpp
r588 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * … … 87 87 fprintf( g_hTrace, "=========== Tone Mapping Info SEI message ===========\n"); 88 88 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 89 96 #if LAYERS_NOT_PRESENT_SEI 90 97 case SEI::LAYERS_NOT_PRESENT: … … 92 99 break; 93 100 #endif 94 case SEI::SOP_DESCRIPTION:95 fprintf( g_hTrace, "=========== SOP Description SEI message ===========\n");96 break;97 101 #if N0383_IL_CONSTRAINED_TILE_SETS_SEI 98 102 case SEI::INTER_LAYER_CONSTRAINED_TILE_SETS: … … 105 109 break; 106 110 #endif 107 case SEI::SCALABLE_NESTING: 108 fprintf( g_hTrace, "=========== Scalable Nesting SEI message ===========\n"); 109 break; 111 #endif //SVC_EXTENSION 110 112 default: 111 113 fprintf( g_hTrace, "=========== Unknown SEI message ===========\n"); … … 155 157 xWriteSEIToneMappingInfo(*static_cast<const SEIToneMappingInfo*>(&sei)); 156 158 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 157 166 #if LAYERS_NOT_PRESENT_SEI 158 167 case SEI::LAYERS_NOT_PRESENT: … … 160 169 break; 161 170 #endif 162 case SEI::SOP_DESCRIPTION:163 xWriteSEISOPDescription(*static_cast<const SEISOPDescription*>(&sei));164 break;165 171 #if N0383_IL_CONSTRAINED_TILE_SETS_SEI 166 172 case SEI::INTER_LAYER_CONSTRAINED_TILE_SETS: … … 173 179 break; 174 180 #endif 175 case SEI::SCALABLE_NESTING: 176 xWriteSEIScalableNesting(bs, *static_cast<const SEIScalableNesting*>(&sei), sps); 177 break; 181 #endif //SVC_EXTENSION 178 182 default: 179 183 assert(!"Unhandled SEI message"); … … 337 341 if( !hrd->getSubPicCpbParamsPresentFlag() ) 338 342 { 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" ); 340 349 } 341 350 WRITE_FLAG( sei.m_concatenationFlag, "concatenation_flag"); 342 351 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 }348 352 for( nalOrVcl = 0; nalOrVcl < 2; nalOrVcl ++ ) 349 353 { … … 546 550 } 547 551 548 #if LAYERS_NOT_PRESENT_SEI549 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 #endif559 560 552 Void SEIWriter::xWriteSEISOPDescription(const SEISOPDescription& sei) 561 553 { … … 578 570 xWriteByteAlign(); 579 571 } 572 573 Void 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 615 Void 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 629 Void 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 580 639 581 640 #if N0383_IL_CONSTRAINED_TILE_SETS_SEI … … 634 693 } 635 694 #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 689 696 690 697 //! \} -
trunk/source/Lib/TLibEncoder/SEIwrite.h
r588 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * … … 64 64 Void xWriteSEIGradualDecodingRefreshInfo(const SEIGradualDecodingRefreshInfo &sei); 65 65 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 66 70 #if LAYERS_NOT_PRESENT_SEI 67 71 Void xWriteSEILayersNotPresent(const SEILayersNotPresent& sei); 68 72 #endif 69 Void xWriteSEISOPDescription(const SEISOPDescription& sei);70 73 #if N0383_IL_CONSTRAINED_TILE_SETS_SEI 71 74 Void xWriteSEIInterLayerConstrainedTileSets(const SEIInterLayerConstrainedTileSets& sei); … … 74 77 Void xWriteSEISubBitstreamProperty(const SEISubBitstreamProperty &sei); 75 78 #endif 76 Void xWriteSEIScalableNesting(TComBitIf& bs, const SEIScalableNesting& sei, TComSPS *sps); 77 Void xWriteByteAlign(); 79 #endif //SVC_EXTENSION 78 80 }; 79 81 -
trunk/source/Lib/TLibEncoder/SyntaxElementWriter.cpp
r313 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * -
trunk/source/Lib/TLibEncoder/SyntaxElementWriter.h
r313 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * -
trunk/source/Lib/TLibEncoder/TEncAnalyze.cpp
r540 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * -
trunk/source/Lib/TLibEncoder/TEncAnalyze.h
r540 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * -
trunk/source/Lib/TLibEncoder/TEncBinCoder.h
r313 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * -
trunk/source/Lib/TLibEncoder/TEncBinCoderCABAC.cpp
r313 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * -
trunk/source/Lib/TLibEncoder/TEncBinCoderCABAC.h
r313 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * -
trunk/source/Lib/TLibEncoder/TEncBinCoderCABACCounter.cpp
r313 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * -
trunk/source/Lib/TLibEncoder/TEncBinCoderCABACCounter.h
r313 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * -
trunk/source/Lib/TLibEncoder/TEncCavlc.cpp
r588 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * … … 579 579 } 580 580 WRITE_FLAG( pcSPS->getTMVPFlagsPresent() ? 1 : 0, "sps_temporal_mvp_enable_flag" ); 581 581 582 WRITE_FLAG( pcSPS->getUseStrongIntraSmoothing(), "sps_strong_intra_smoothing_enable_flag" ); 582 583 … … 1733 1734 WRITE_FLAG( pcSlice->getSaoEnabledFlag(), "slice_sao_luma_flag" ); 1734 1735 #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 1739 1738 WRITE_FLAG( pcSlice->getSaoEnabledFlagChroma(), "slice_sao_chroma_flag" ); 1740 #else1741 {1742 SAOParam *saoParam = pcSlice->getPic()->getPicSym()->getSaoParam();1743 WRITE_FLAG( saoParam->bSaoFlag[1], "slice_sao_chroma_flag" );1744 }1745 #endif1746 #if AUXILIARY_PICTURES1747 }1748 #endif1749 1739 } 1750 1740 } -
trunk/source/Lib/TLibEncoder/TEncCavlc.h
r588 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * … … 88 88 UInt getCoeffCost () { return m_uiCoeffCost; } 89 89 Void codeVPS ( TComVPS* pcVPS ); 90 #if VPS_EXTNS91 Void codeVPSExtension ( TComVPS* pcVPS );92 #endif93 94 #if VPS_VUI95 Void codeVPSVUI (TComVPS *vps);96 #endif97 #if REPN_FORMAT_IN_VPS98 Void codeRepFormat ( RepFormat *repFormat );99 #endif100 #if VPS_DPB_SIZE_TABLE101 Void codeVpsDpbSizeTable (TComVPS *vps);102 #endif103 90 Void codeVUI ( TComVUI *pcVUI, TComSPS* pcSPS ); 104 91 Void codeSPS ( TComSPS* pcSPS ); 105 #if SPS_EXTENSION106 Void codeSPSExtension ( TComSPS* pcSPS );107 #endif108 92 Void codePPS ( TComPPS* pcPPS ); 109 93 Void codeSliceHeader ( TComSlice* pcSlice ); … … 116 100 117 101 Void codeMVPIdx ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefList ); 118 #if HM_CLEANUP_SAO119 102 Void codeSAOBlkParam(SAOBlkParam& saoBlkParam, Bool* sliceEnabled, Bool leftMergeAvail, Bool aboveMergeAvail, Bool onlyEstMergeInfo = false){printf("only supported in CABAC"); assert(0); exit(-1);} 120 #else121 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 #endif127 103 Void codeCUTransquantBypassFlag( TComDataCU* pcCU, UInt uiAbsPartIdx ); 128 104 Void codeSkipFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx ); … … 165 141 Void codeDFSvlc ( Int iCode, const Char *pSymbolName ); 166 142 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 167 159 }; 168 160 -
trunk/source/Lib/TLibEncoder/TEncCfg.h
r588 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * … … 91 91 92 92 std::istringstream &operator>>(std::istringstream &in, GOPEntry &entry); //input 93 94 #if REPN_FORMAT_IN_VPS95 struct RepFormatCfg96 {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 #endif114 115 93 //! \ingroup TLibEncoder 116 94 //! \{ … … 162 140 Int m_maxTempLayer; ///< Max temporal layer 163 141 Bool m_useAMP; 164 #if VPS_EXTN_DIRECT_REF_LAYERS165 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 #endif177 #if N0120_MAX_TID_REF_CFG178 Int m_maxTidIlRefPicsPlus1;179 #endif180 142 //======= Transform ============= 181 143 UInt m_uiQuadtreeTULog2MaxSize; … … 194 156 Int m_maxNumOffsetsPerPic; 195 157 Bool m_saoLcuBoundary; 196 #if !HM_CLEANUP_SAO197 Bool m_saoLcuBasedOptimization;198 #endif199 //====== Lossless ========200 Bool m_useLossless;201 158 //====== Motion search ======== 202 159 Int m_iFastSearch; // 0:Full search 1:Diamond 2:PMVFAST … … 210 167 Int m_chromaCbQpOffset; // Chroma Cb QP Offset (0:default) 211 168 Int m_chromaCrQpOffset; // Chroma Cr Qp Offset (0:default) 212 #if AUXILIARY_PICTURES213 ChromaFormat m_chromaFormatIDC;214 #endif215 169 216 170 #if ADAPTIVE_QP_SELECTION … … 222 176 223 177 //====== Tool list ======== 224 Bool m_bUseSBACRD;225 178 Bool m_bUseASR; 226 179 Bool m_bUseHADME; … … 233 186 Bool m_bUseCbfFastMode; 234 187 Bool m_useEarlySkipDetection; 235 #if FAST_INTRA_SHVC236 Bool m_useFastIntraScalable;237 #endif238 188 Bool m_useTransformSkip; 239 189 Bool m_useTransformSkipFast; … … 305 255 Int m_gradualDecodingRefreshInfoEnabled; 306 256 Int m_decodingUnitInfoSEIEnabled; 307 #if LAYERS_NOT_PRESENT_SEI308 Int m_layersNotPresentSEIEnabled;309 #endif310 257 Int m_SOPDescriptionSEIEnabled; 311 258 Int m_scalableNestingSEIEnabled; 312 #if N0383_IL_CONSTRAINED_TILE_SETS_SEI313 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 #endif320 259 //====== Weighted Prediction ======== 321 260 Bool m_useWeightedPred; //< Use of Weighting Prediction (P_SLICE) … … 335 274 Bool m_RCForceIntraQP; 336 275 Bool m_TransquantBypassEnableFlag; ///< transquant_bypass_enable_flag setting in PPS. 337 Bool m_CUTransquantBypassFlag Value; ///< 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. 338 277 #if SVC_EXTENSION 339 static TComVPS 278 static TComVPS m_cVPS; 340 279 #else 341 280 TComVPS m_cVPS; … … 391 330 Bool m_crossLayerBLAFlag; 392 331 #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 394 366 395 367 public: … … 437 409 Bool getMaxTempLayer () { return m_maxTempLayer; } 438 410 Void setMaxTempLayer ( Int maxTempLayer ) { m_maxTempLayer = maxTempLayer; } 439 #if VPS_EXTN_DIRECT_REF_LAYERS440 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 #endif470 #if N0120_MAX_TID_REF_CFG471 Int getMaxTidIlRefPicsPlus1 () { return m_maxTidIlRefPicsPlus1; }472 Void setMaxTidIlRefPicsPlus1 (Int num) { m_maxTidIlRefPicsPlus1 = num; }473 #endif474 411 //======== Transform ============= 475 412 Void setQuadtreeTULog2MaxSize ( UInt u ) { m_uiQuadtreeTULog2MaxSize = u; } … … 508 445 Void setQPAdaptationRange ( Int i ) { m_iQPAdaptationRange = i; } 509 446 510 //====== Lossless ========511 Void setUseLossless (Bool b ) { m_useLossless = b; }512 447 //====== Sequence ======== 513 448 Int getFrameRate () { return m_iFrameRate; } … … 552 487 Bool getUseAdaptiveQP () { return m_bUseAdaptiveQP; } 553 488 Int getQPAdaptationRange () { return m_iQPAdaptationRange; } 554 //====== Lossless ========555 Bool getUseLossless () { return m_useLossless; }556 489 557 490 //==== Tool list ======== 558 Void setUseSBACRD ( Bool b ) { m_bUseSBACRD = b; }559 491 Void setUseASR ( Bool b ) { m_bUseASR = b; } 560 492 Void setUseHADME ( Bool b ) { m_bUseHADME = b; } … … 567 499 Void setUseCbfFastMode ( Bool b ) { m_bUseCbfFastMode = b; } 568 500 Void setUseEarlySkipDetection ( Bool b ) { m_useEarlySkipDetection = b; } 569 #if FAST_INTRA_SHVC570 Void setUseFastIntraScalable ( Bool b ) { m_useFastIntraScalable = b; }571 #endif572 501 Void setUseConstrainedIntraPred ( Bool b ) { m_bUseConstrainedIntraPred = b; } 573 502 Void setPCMInputBitDepthFlag ( Bool b ) { m_bPCMInputBitDepthFlag = b; } … … 578 507 Void setdQPs ( Int* p ) { m_aidQP = p; } 579 508 Void setDeltaQpRD ( UInt u ) {m_uiDeltaQpRD = u; } 580 Bool getUseSBACRD () { return m_bUseSBACRD; }581 509 Bool getUseASR () { return m_bUseASR; } 582 510 Bool getUseHADME () { return m_bUseHADME; } … … 589 517 Bool getUseCbfFastMode () { return m_bUseCbfFastMode; } 590 518 Bool getUseEarlySkipDetection () { return m_useEarlySkipDetection; } 591 #if FAST_INTRA_SHVC592 Bool getUseFastIntraScalable () { return m_useFastIntraScalable; }593 #endif594 519 Bool getUseConstrainedIntraPred () { return m_bUseConstrainedIntraPred; } 595 520 Bool getPCMInputBitDepthFlag () { return m_bPCMInputBitDepthFlag; } … … 625 550 Void setSaoLcuBoundary (Bool val) { m_saoLcuBoundary = val; } 626 551 Bool getSaoLcuBoundary () { return m_saoLcuBoundary; } 627 #if !HM_CLEANUP_SAO628 Void setSaoLcuBasedOptimization (Bool val) { m_saoLcuBasedOptimization = val; }629 Bool getSaoLcuBasedOptimization () { return m_saoLcuBasedOptimization; }630 #endif631 552 Void setLFCrossTileBoundaryFlag ( Bool val ) { m_loopFilterAcrossTilesEnabledFlag = val; } 632 553 Bool getLFCrossTileBoundaryFlag () { return m_loopFilterAcrossTilesEnabledFlag; } … … 748 669 Void setDecodingUnitInfoSEIEnabled(Int b) { m_decodingUnitInfoSEIEnabled = b; } 749 670 Int getDecodingUnitInfoSEIEnabled() { return m_decodingUnitInfoSEIEnabled; } 750 #if LAYERS_NOT_PRESENT_SEI751 Void setLayersNotPresentSEIEnabled(Int b) { m_layersNotPresentSEIEnabled = b; }752 Int getLayersNotPresentSEIEnabled() { return m_layersNotPresentSEIEnabled; }753 #endif754 671 Void setSOPDescriptionSEIEnabled(Int b) { m_SOPDescriptionSEIEnabled = b; } 755 672 Int getSOPDescriptionSEIEnabled() { return m_SOPDescriptionSEIEnabled; } 756 673 Void setScalableNestingSEIEnabled(Int b) { m_scalableNestingSEIEnabled = b; } 757 674 Int getScalableNestingSEIEnabled() { return m_scalableNestingSEIEnabled; } 758 #if N0383_IL_CONSTRAINED_TILE_SETS_SEI759 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 #endif790 675 Void setUseWP ( Bool b ) { m_useWeightedPred = b; } 791 676 Void setWPBiPred ( Bool b ) { m_useWeightedBiPred = b; } … … 820 705 Bool getTransquantBypassEnableFlag() { return m_TransquantBypassEnableFlag; } 821 706 Void setTransquantBypassEnableFlag(Bool flag) { m_TransquantBypassEnableFlag = flag; } 822 Bool getCUTransquantBypassFlag Value() { return m_CUTransquantBypassFlagValue; }823 Void setCUTransquantBypassFlag Value(Bool flag) { m_CUTransquantBypassFlagValue = flag; }707 Bool getCUTransquantBypassFlagForceValue() { return m_CUTransquantBypassFlagForce; } 708 Void setCUTransquantBypassFlagForceValue(Bool flag) { m_CUTransquantBypassFlagForce = flag; } 824 709 Void setVPS(TComVPS *p) { m_cVPS = *p; } 825 710 TComVPS *getVPS() { return &m_cVPS; } … … 934 819 Void setCrossLayerBLAFlag(Bool b) { m_crossLayerBLAFlag = b; } 935 820 #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 936 896 #endif 937 897 }; 938 898 899 #if SVC_EXTENSION 900 #if REPN_FORMAT_IN_VPS 901 struct 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 }; 918 std::istringstream &operator>>(std::istringstream &in, RepFormatCfg &repFormatCfg); 919 #endif 920 #endif //SVC_EXTENSION 921 939 922 //! \} 940 923 -
trunk/source/Lib/TLibEncoder/TEncCu.cpp
r588 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * … … 223 223 m_pcRDGoOnSbacCoder = pcEncTop->getRDGoOnSbacCoder(); 224 224 225 m_bUseSBACRD = pcEncTop->getUseSBACRD();226 225 m_pcRateCtrl = pcEncTop->getRateCtrl(); 227 226 } … … 394 393 Int iMaxQP; 395 394 Bool isAddLowestQP = false; 396 #if REPN_FORMAT_IN_VPS397 Int lowestQP = -rpcTempCU->getSlice()->getQpBDOffsetY();398 #else399 Int lowestQP = -rpcTempCU->getSlice()->getSPS()->getQpBDOffsetY();400 #endif401 395 402 396 if( (g_uiMaxCUWidth>>uiDepth) >= rpcTempCU->getSlice()->getPPS()->getMinCuDQPSize() ) … … 409 403 iMinQP = Clip3( -rpcTempCU->getSlice()->getSPS()->getQpBDOffsetY(), MAX_QP, iBaseQP-idQP ); 410 404 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 417 406 } 418 407 else … … 426 415 iMinQP = m_pcRateCtrl->getRCQP(); 427 416 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 } 428 431 } 429 432 … … 443 446 if (m_pcEncCfg->getSkipPictureAtArcSwitch() && m_pcEncCfg->getAdaptiveResolutionChange() > 0 && pcSlice->getLayerId() == 1 && pcSlice->getPOC() == m_pcEncCfg->getAdaptiveResolutionChange()) 444 447 { 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 ); 446 457 447 458 xCheckRDCostMerge2Nx2N( rpcBestCU, rpcTempCU, &earlyDetectionSkipMode, true ); … … 466 477 for (Int iQP=iMinQP; iQP<=iMaxQP; iQP++) 467 478 { 468 if (isAddLowestQP && (iQP == iMinQP)) 479 const Bool bIsLosslessMode = isAddLowestQP && (iQP == iMinQP); 480 481 if (bIsLosslessMode) 469 482 { 470 483 iQP = lowestQP; 471 484 } 472 485 473 rpcTempCU->initEstData( uiDepth, iQP );486 rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode ); 474 487 475 488 // do inter modes, SKIP and 2Nx2N … … 483 496 if(m_pcEncCfg->getUseEarlySkipDetection()) 484 497 { 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 486 500 } 487 501 // SKIP 488 502 xCheckRDCostMerge2Nx2N( rpcBestCU, rpcTempCU, &earlyDetectionSkipMode );//by Merge for inter_2Nx2N 489 rpcTempCU->initEstData( uiDepth, iQP );503 rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode ); 490 504 491 505 #if (ENCODER_FAST_MODE == 2) … … 496 510 { 497 511 // 2Nx2N, NxN 498 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2Nx2N ); rpcTempCU->initEstData( uiDepth, iQP ); 512 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2Nx2N ); 513 rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode ); 499 514 if(m_pcEncCfg->getUseCbfFastMode()) 500 515 { … … 507 522 } 508 523 509 if ( isAddLowestQP && (iQP == lowestQP))524 if (bIsLosslessMode) 510 525 { 511 526 iQP = iMinQP; … … 517 532 for (Int iQP=iMinQP; iQP<=iMaxQP; iQP++) 518 533 { 519 if (isAddLowestQP && (iQP == iMinQP)) 534 const Bool bIsLosslessMode = isAddLowestQP && (iQP == iMinQP); 535 536 if (bIsLosslessMode) 520 537 { 521 538 iQP = lowestQP; 522 539 } 523 rpcTempCU->initEstData( uiDepth, iQP );540 rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode ); 524 541 525 542 // do inter modes, NxN, 2NxN, and Nx2N … … 536 553 { 537 554 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_NxN ); 538 rpcTempCU->initEstData( uiDepth, iQP );555 rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode ); 539 556 } 540 557 } … … 544 561 { 545 562 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_Nx2N ); 546 rpcTempCU->initEstData( uiDepth, iQP );563 rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode ); 547 564 if(m_pcEncCfg->getUseCbfFastMode() && rpcBestCU->getPartitionSize(0) == SIZE_Nx2N ) 548 565 { … … 553 570 { 554 571 xCheckRDCostInter ( rpcBestCU, rpcTempCU, SIZE_2NxN ); 555 rpcTempCU->initEstData( uiDepth, iQP );572 rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode ); 556 573 if(m_pcEncCfg->getUseCbfFastMode() && rpcBestCU->getPartitionSize(0) == SIZE_2NxN) 557 574 { … … 581 598 { 582 599 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnU ); 583 rpcTempCU->initEstData( uiDepth, iQP );600 rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode ); 584 601 if(m_pcEncCfg->getUseCbfFastMode() && rpcBestCU->getPartitionSize(0) == SIZE_2NxnU ) 585 602 { … … 590 607 { 591 608 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnD ); 592 rpcTempCU->initEstData( uiDepth, iQP );609 rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode ); 593 610 if(m_pcEncCfg->getUseCbfFastMode() && rpcBestCU->getPartitionSize(0) == SIZE_2NxnD ) 594 611 { … … 603 620 { 604 621 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnU, true ); 605 rpcTempCU->initEstData( uiDepth, iQP );622 rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode ); 606 623 if(m_pcEncCfg->getUseCbfFastMode() && rpcBestCU->getPartitionSize(0) == SIZE_2NxnU ) 607 624 { … … 612 629 { 613 630 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnD, true ); 614 rpcTempCU->initEstData( uiDepth, iQP );631 rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode ); 615 632 if(m_pcEncCfg->getUseCbfFastMode() && rpcBestCU->getPartitionSize(0) == SIZE_2NxnD ) 616 633 { … … 627 644 { 628 645 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nLx2N ); 629 rpcTempCU->initEstData( uiDepth, iQP );646 rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode ); 630 647 if(m_pcEncCfg->getUseCbfFastMode() && rpcBestCU->getPartitionSize(0) == SIZE_nLx2N ) 631 648 { … … 636 653 { 637 654 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nRx2N ); 638 rpcTempCU->initEstData( uiDepth, iQP );655 rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode ); 639 656 } 640 657 } … … 645 662 { 646 663 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nLx2N, true ); 647 rpcTempCU->initEstData( uiDepth, iQP );664 rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode ); 648 665 if(m_pcEncCfg->getUseCbfFastMode() && rpcBestCU->getPartitionSize(0) == SIZE_nLx2N ) 649 666 { … … 654 671 { 655 672 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nRx2N, true ); 656 rpcTempCU->initEstData( uiDepth, iQP );673 rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode ); 657 674 } 658 675 } … … 661 678 #else 662 679 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnU ); 663 rpcTempCU->initEstData( uiDepth, iQP );680 rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode ); 664 681 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnD ); 665 rpcTempCU->initEstData( uiDepth, iQP );682 rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode ); 666 683 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nLx2N ); 667 rpcTempCU->initEstData( uiDepth, iQP );684 rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode ); 668 685 669 686 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nRx2N ); 670 rpcTempCU->initEstData( uiDepth, iQP );687 rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode ); 671 688 672 689 #endif … … 691 708 { 692 709 xCheckRDCostIntra( rpcBestCU, rpcTempCU, SIZE_2Nx2N ); 693 rpcTempCU->initEstData( uiDepth, iQP);710 rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode ); 694 711 if( uiDepth == g_uiMaxCUDepth - g_uiAddCUDepth ) 695 712 { … … 697 714 { 698 715 xCheckRDCostIntra( rpcBestCU, rpcTempCU, SIZE_NxN ); 699 rpcTempCU->initEstData( uiDepth, iQP);716 rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode ); 700 717 } 701 718 } … … 712 729 { 713 730 xCheckIntraPCM (rpcBestCU, rpcTempCU); 714 rpcTempCU->initEstData( uiDepth, iQP );731 rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode ); 715 732 } 716 733 } … … 725 742 { 726 743 xCheckRDCostILRUni( rpcBestCU, rpcTempCU, pcSlice->getInterLayerPredLayerIdc(refLayer)); 727 rpcTempCU->initEstData( uiDepth, iQP );744 rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode ); 728 745 } 729 746 } 730 747 #endif 731 748 732 if ( isAddLowestQP && (iQP == lowestQP))749 if (bIsLosslessMode) 733 750 { 734 751 iQP = iMinQP; … … 740 757 m_pcEntropyCoder->encodeSplitFlag( rpcBestCU, 0, uiDepth, true ); 741 758 rpcBestCU->getTotalBits() += m_pcEntropyCoder->getNumberOfWrittenBits(); // split bits 742 if(m_pcEncCfg->getUseSBACRD())743 {744 759 rpcBestCU->getTotalBins() += ((TEncBinCABAC *)((TEncSbac*)m_pcEntropyCoder->m_pcEntropyCoderIf)->getEncBinIf())->getBinsCoded(); 745 }746 760 rpcBestCU->getTotalCost() = m_pcRdCost->calcRdCost( rpcBestCU->getTotalBits(), rpcBestCU->getTotalDistortion() ); 747 761 … … 778 792 iMinQP = Clip3( -rpcTempCU->getSlice()->getSPS()->getQpBDOffsetY(), MAX_QP, iBaseQP-idQP ); 779 793 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 786 795 } 787 796 else if( (g_uiMaxCUWidth>>uiDepth) > rpcTempCU->getSlice()->getPPS()->getMinCuDQPSize() ) … … 810 819 iMaxQP = m_pcRateCtrl->getRCQP(); 811 820 } 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 812 827 for (Int iQP=iMinQP; iQP<=iMaxQP; iQP++) 813 828 { 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 ); 819 831 820 832 // further split … … 837 849 #endif 838 850 { 839 if ( m_bUseSBACRD )851 if ( 0 == uiPartUnitIdx) //initialize RD with previous depth buffer 840 852 { 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]); 849 858 } 850 859 … … 878 887 879 888 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(); 884 890 } 885 891 rpcTempCU->getTotalCost() = m_pcRdCost->calcRdCost( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() ); … … 913 919 m_pcEntropyCoder->encodeQP( rpcTempCU, uiTargetPartIdx, false ); 914 920 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(); 919 922 rpcTempCU->getTotalCost() = m_pcRdCost->calcRdCost( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() ); 920 923 #endif … … 930 933 } 931 934 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 936 937 Bool isEndOfSlice = rpcBestCU->getSlice()->getSliceMode()==FIXED_NUMBER_OF_BYTES 937 938 && (rpcBestCU->getTotalBits()>rpcBestCU->getSlice()->getSliceArgument()<<3); … … 944 945 xCheckBestMode( rpcBestCU, rpcTempCU, uiDepth); // RD compare current larger prediction 945 946 } // with sub partitioned prediction. 946 if (isAddLowestQP && (iQP == lowestQP))947 {948 iQP = iMinQP;949 }950 947 } 951 948 … … 1334 1331 UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS]; 1335 1332 Int numValidMergeCand = 0; 1333 const Bool bTransquantBypassFlag = rpcTempCU->getCUTransquantBypass(0); 1336 1334 1337 1335 for( UInt ui = 0; ui < rpcTempCU->getSlice()->getMaxNumMergeCand(); ++ui ) … … 1341 1339 UChar uhDepth = rpcTempCU->getDepth( 0 ); 1342 1340 rpcTempCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uhDepth ); // interprets depth relative to LCU level 1343 rpcTempCU->setCUTransquantBypassSubParts( m_pcEncCfg->getCUTransquantBypassFlagValue(), 0, uhDepth );1344 1341 rpcTempCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours,uhInterDirNeighbours, numValidMergeCand ); 1345 1342 … … 1385 1382 // set MC parameters 1386 1383 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 ); 1388 1385 rpcTempCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uhDepth ); // interprets depth relative to LCU level 1389 1386 rpcTempCU->setMergeFlagSubParts( true, 0, 0, uhDepth ); // interprets depth relative to LCU level … … 1415 1412 xCheckDQP( rpcTempCU ); 1416 1413 xCheckBestMode(rpcBestCU, rpcTempCU, uhDepth); 1417 rpcTempCU->initEstData( uhDepth, orgQP );1414 rpcTempCU->initEstData( uhDepth, orgQP, bTransquantBypassFlag ); 1418 1415 1419 1416 if( m_pcEncCfg->getUseFastDecisionForMerge() && !bestIsSkip ) … … 1478 1475 rpcTempCU->setPartSizeSubParts ( ePartSize, 0, uhDepth ); 1479 1476 rpcTempCU->setPredModeSubParts ( MODE_INTER, 0, uhDepth ); 1480 rpcTempCU->setCUTransquantBypassSubParts ( m_pcEncCfg->getCUTransquantBypassFlagValue(), 0, uhDepth );1481 1477 1482 1478 #if AMP_MRG … … 1509 1505 rpcTempCU->setPartSizeSubParts( eSize, 0, uiDepth ); 1510 1506 rpcTempCU->setPredModeSubParts( MODE_INTRA, 0, uiDepth ); 1511 rpcTempCU->setCUTransquantBypassSubParts( m_pcEncCfg->getCUTransquantBypassFlagValue(), 0, uiDepth );1512 1507 1513 1508 Bool bSeparateLumaChroma = true; // choose estimation mode … … 1539 1534 setdQPFlag( bCodeDQP ); 1540 1535 1541 if( m_bUseSBACRD )m_pcRDGoOnSbacCoder->store(m_pppcRDSbacCoder[uiDepth][CI_TEMP_BEST]);1536 m_pcRDGoOnSbacCoder->store(m_pppcRDSbacCoder[uiDepth][CI_TEMP_BEST]); 1542 1537 1543 1538 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(); 1548 1540 rpcTempCU->getTotalCost() = m_pcRdCost->calcRdCost( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() ); 1549 1541 … … 1570 1562 rpcTempCU->setPredModeSubParts( MODE_INTRA, 0, uiDepth ); 1571 1563 rpcTempCU->setTrIdxSubParts ( 0, 0, uiDepth ); 1572 rpcTempCU->setCUTransquantBypassSubParts( m_pcEncCfg->getCUTransquantBypassFlagValue(), 0, uiDepth );1573 1564 1574 1565 m_pcPredSearch->IPCMSearch( rpcTempCU, m_ppcOrigYuv[uiDepth], m_ppcPredYuvTemp[uiDepth], m_ppcResiYuvTemp[uiDepth], m_ppcRecoYuvTemp[uiDepth]); 1575 1566 1576 if( m_bUseSBACRD )m_pcRDGoOnSbacCoder->load(m_pppcRDSbacCoder[uiDepth][CI_CURR_BEST]);1567 m_pcRDGoOnSbacCoder->load(m_pppcRDSbacCoder[uiDepth][CI_CURR_BEST]); 1577 1568 1578 1569 m_pcEntropyCoder->resetBits(); … … 1586 1577 m_pcEntropyCoder->encodeIPCMInfo ( rpcTempCU, 0, true ); 1587 1578 1588 if( m_bUseSBACRD )m_pcRDGoOnSbacCoder->store(m_pppcRDSbacCoder[uiDepth][CI_TEMP_BEST]);1579 m_pcRDGoOnSbacCoder->store(m_pppcRDSbacCoder[uiDepth][CI_TEMP_BEST]); 1589 1580 1590 1581 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(); 1595 1583 rpcTempCU->getTotalCost() = m_pcRdCost->calcRdCost( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() ); 1596 1584 … … 1627 1615 pcCU = NULL; 1628 1616 1629 if( m_bUseSBACRD )// store temp best CI for next CU coding1630 1617 // store temp best CI for next CU coding 1618 m_pppcRDSbacCoder[uiDepth][CI_TEMP_BEST]->store(m_pppcRDSbacCoder[uiDepth][CI_NEXT_BEST]); 1631 1619 } 1632 1620 } … … 1644 1632 m_pcEntropyCoder->encodeQP( pcCU, 0, false ); 1645 1633 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(); 1650 1635 pcCU->getTotalCost() = m_pcRdCost->calcRdCost( pcCU->getTotalBits(), pcCU->getTotalDistortion() ); 1651 1636 #endif … … 1795 1780 } 1796 1781 1782 /** Collect ARL statistics from one LCU 1783 * \param pcCU 1784 */ 1785 Void 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 1797 1825 #if N0383_IL_CONSTRAINED_TILE_SETS_SEI 1798 1826 Bool TEncCu::xCheckTileSetConstraint( TComDataCU*& rpcCU ) … … 1861 1889 #endif 1862 1890 1863 /** Collect ARL statistics from one LCU1864 * \param pcCU1865 */1866 Void TEncCu::xLcuCollectARLStats(TComDataCU* rpcCU )1867 {1868 Double cSum[ LEVEL_RANGE + 1 ]; //: the sum of DCT coefficients corresponding to datatype and quantization output1869 UInt numSamples[ LEVEL_RANGE + 1 ]; //: the number of coefficients corresponding to datatype and quantization output1870 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 #endif1904 1905 1891 #if (ENCODER_FAST_MODE) 1906 1892 Void TEncCu::xCheckRDCostILRUni(TComDataCU *&rpcBestCU, TComDataCU *&rpcTempCU, UInt refLayerId) … … 1913 1899 rpcTempCU->setPartSizeSubParts ( SIZE_2Nx2N, 0, uhDepth ); //2Nx2N 1914 1900 rpcTempCU->setPredModeSubParts ( MODE_INTER, 0, uhDepth ); 1915 rpcTempCU->setCUTransquantBypassSubParts ( m_pcEncCfg->getCUTransquantBypassFlag Value(), 0, uhDepth );1901 rpcTempCU->setCUTransquantBypassSubParts ( m_pcEncCfg->getCUTransquantBypassFlagForceValue(), 0, uhDepth ); 1916 1902 Bool exitILR = m_pcPredSearch->predInterSearchILRUni( rpcTempCU, m_ppcOrigYuv[uhDepth], m_ppcPredYuvTemp[uhDepth], m_ppcResiYuvTemp[uhDepth], m_ppcRecoYuvTemp[uhDepth], refLayerId ); 1917 1903 if(!exitILR) … … 1926 1912 } 1927 1913 #endif 1914 #endif //SVC_EXTENSION 1928 1915 //! \} -
trunk/source/Lib/TLibEncoder/TEncCu.h
r540 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * … … 89 89 TComRdCost* m_pcRdCost; 90 90 91 #if SVC_EXTENSION92 TEncTop** m_ppcTEncTop;93 #endif94 95 91 TEncEntropy* m_pcEntropyCoder; 96 92 TEncCavlc* m_pcCavlcCoder; … … 101 97 TEncSbac*** m_pppcRDSbacCoder; 102 98 TEncSbac* m_pcRDGoOnSbacCoder; 103 Bool m_bUseSBACRD;104 99 TEncRateCtrl* m_pcRateCtrl; 105 100 101 #if SVC_EXTENSION 102 TEncTop** m_ppcTEncTop; 106 103 #if N0383_IL_CONSTRAINED_TILE_SETS_SEI 107 104 Bool m_disableILP; 108 105 #endif 106 #endif //SVC_EXTENSION 109 107 public: 110 108 /// copy parameters from encoder class … … 148 146 #endif 149 147 Void xCheckRDCostIntra ( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, PartSize ePartSize ); 150 #if ENCODER_FAST_MODE151 Void xCheckRDCostILRUni ( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, UInt refLayerId);152 #endif153 148 Void xCheckDQP ( TComDataCU* pcCU ); 154 149 … … 167 162 #endif 168 163 169 #if N0383_IL_CONSTRAINED_TILE_SETS_SEI170 Bool xCheckTileSetConstraint( TComDataCU*& rpcCU );171 Void xVerifyTileSetConstraint( TComDataCU*& rpcCU );172 #endif173 174 164 #if AMP_ENC_SPEEDUP 175 165 #if AMP_MRG … … 180 170 #endif 181 171 172 Void xFillPCMBuffer ( TComDataCU*& pCU, TComYuv* pOrgYuv ); 173 182 174 #if SVC_EXTENSION 183 175 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 187 184 }; 188 185 -
trunk/source/Lib/TLibEncoder/TEncEntropy.cpp
r540 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * … … 51 51 Void TEncEntropy::encodeSliceHeader ( TComSlice* pcSlice ) 52 52 { 53 #if !HM_CLEANUP_SAO54 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 #endif63 53 m_pcEntropyCoderIf->codeSliceHeader( pcSlice ); 64 54 return; … … 639 629 } 640 630 641 #if !HM_CLEANUP_SAO642 /** Encode SAO Offset643 * \param saoLcuParam SAO LCU paramters644 */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 interleaving697 * \param rx698 * \param ry699 * \param pSaoParam700 * \param pcCU701 * \param iCUAddrInSlice702 * \param iCUAddrUpInSlice703 * \param bLFCrossSliceBoundaryFlag704 */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 else714 {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 else724 {725 saoLcuParam->mergeUpFlag = 0;726 }727 if (!saoLcuParam->mergeUpFlag)728 {729 encodeSaoOffset(saoLcuParam, compIdx);730 }731 }732 }733 }734 735 #endif736 737 631 Int TEncEntropy::countNonZeroCoeffs( TCoeff* pcCoef, UInt uiSize ) 738 632 { -
trunk/source/Lib/TLibEncoder/TEncEntropy.h
r540 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * … … 105 105 virtual Void codeCoeffNxN ( TComDataCU* pcCU, TCoeff* pcCoef, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, UInt uiDepth, TextType eTType ) = 0; 106 106 virtual Void codeTransformSkipFlags ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt width, UInt height, TextType eTType ) = 0; 107 #if HM_CLEANUP_SAO108 107 virtual Void codeSAOBlkParam(SAOBlkParam& saoBlkParam, Bool* sliceEnabled, Bool leftMergeAvail, Bool aboveMergeAvail, Bool onlyEstMergeInfo = false) =0; 109 #else110 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 #endif116 108 virtual Void estBit (estBitsSbacStruct* pcEstBitsSbac, Int width, Int height, TextType eTType) = 0; 117 109 … … 192 184 193 185 Void estimateBit ( estBitsSbacStruct* pcEstBitsSbac, Int width, Int height, TextType eTType); 194 #if HM_CLEANUP_SAO195 186 Void encodeSAOBlkParam(SAOBlkParam& saoBlkParam, Bool* sliceEnabled, Bool leftMergeAvail, Bool aboveMergeAvail){m_pcEntropyCoderIf->codeSAOBlkParam(saoBlkParam, sliceEnabled, leftMergeAvail, aboveMergeAvail, false);} 196 #else197 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 #endif200 187 static Int countNonZeroCoeffs( TCoeff* pcCoef, UInt uiSize ); 201 188 -
trunk/source/Lib/TLibEncoder/TEncGOP.cpp
r588 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * … … 96 96 xResetNonNestedSEIPresentFlags(); 97 97 xResetNestedSEIPresentFlags(); 98 #if FIX1172 99 m_associatedIRAPType = NAL_UNIT_CODED_SLICE_IDR_N_LP; 100 m_associatedIRAPPOC = 0; 101 #endif 98 102 #if SVC_UPSAMPLING 99 103 m_pcPredSearch = NULL; … … 167 171 } 168 172 169 #if LAYERS_NOT_PRESENT_SEI170 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 #endif187 173 188 174 SEIFramePacking* TEncGOP::xCreateSEIFramePacking() … … 307 293 } 308 294 309 #if N0383_IL_CONSTRAINED_TILE_SETS_SEI310 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 else323 {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 #endif347 348 295 Void TEncGOP::xCreateLeadingSEIMessages (/*SEIMessages seiMessages,*/ AccessUnit &accessUnit, TComSPS *sps) 349 296 { … … 362 309 m_activeParameterSetSEIPresentInAU = true; 363 310 } 364 365 #if LAYERS_NOT_PRESENT_SEI366 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 #endif376 311 377 312 if(m_pcCfg->getFramePackingArrangementSEIEnabled()) … … 408 343 delete sei; 409 344 } 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 410 359 #if N0383_IL_CONSTRAINED_TILE_SETS_SEI 411 360 if(m_pcCfg->getInterLayerConstrainedTileSetsSEIEnabled()) … … 421 370 } 422 371 #endif 372 #endif //SVC_EXTENSION 423 373 } 424 374 … … 547 497 #endif 548 498 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 ) 550 500 { 551 501 m_iLastIDR = pocCurr; … … 554 504 accessUnitsInGOP.push_back(AccessUnit()); 555 505 AccessUnit& accessUnit = accessUnitsInGOP.back(); 556 xGetBuffer( rcListPic, rcListPicYuvRecOut, iNumPicRcvd, iTimeOffset, pcPic, pcPicYuvRecOut, pocCurr, isField 506 xGetBuffer( rcListPic, rcListPicYuvRecOut, iNumPicRcvd, iTimeOffset, pcPic, pcPicYuvRecOut, pocCurr, isField); 557 507 558 508 // Slice data initialization … … 571 521 pcSlice->getPic()->setField(isField); 572 522 523 #if SVC_EXTENSION 573 524 #if POC_RESET_FLAG 574 525 if( !pcSlice->getPocResetFlag() ) // For picture that are not reset, we should adjust the value of POC calculated from the configuration files. … … 636 587 #endif 637 588 #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) ) 639 590 { 640 591 pcSlice->setCrossLayerBLAFlag(m_pcEncTop->getCrossLayerBLAFlag()); … … 693 644 } 694 645 #endif 646 #endif //SVC_EXTENSION 695 647 696 648 pcSlice->setLastIDR(m_iLastIDR); … … 760 712 pcSlice->setDefaultScalingList (); 761 713 } 762 763 714 pcSlice->getScalingList()->checkDcOfMatrix(); 764 715 m_pcEncTop->getSPS()->setScalingListPresentFlag(pcSlice->checkDefaultScalingList()); … … 782 733 pcSlice->setSliceType(P_SLICE); 783 734 } 735 if(pcSlice->getSliceType()==B_SLICE&&m_pcCfg->getGOPEntry(iGOPid).m_sliceType=='I') 736 { 737 pcSlice->setSliceType(I_SLICE); 738 } 739 784 740 // Set the nal unit type 785 pcSlice->setNalUnitType(getNalUnitType(pocCurr, m_iLastIDR ));741 pcSlice->setNalUnitType(getNalUnitType(pocCurr, m_iLastIDR, isField)); 786 742 #if SVC_EXTENSION 787 743 if (m_layerId > 0) … … 953 909 m_pcEncTop->selectReferencePictureSet(pcSlice, pocCurr, iGOPid); 954 910 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 955 925 956 926 if ((pcSlice->checkThatAllRefPicsAreAvailable(rcListPic, pcSlice->getRPS(), false) != 0) || (pcSlice->isIRAP())) … … 960 930 pcSlice->applyReferencePictureSet(rcListPic, pcSlice->getRPS()); 961 931 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 ) 963 938 { 964 939 if(pcSlice->isTemporalLayerSwitchingPoint(rcListPic) || pcSlice->getSPS()->getTemporalIdNestingFlag()) … … 1633 1608 1634 1609 // SAO parameter estimation using non-deblocked pixels for LCU bottom and right boundary areas 1635 #if HM_CLEANUP_SAO1636 1610 if( pcSlice->getSPS()->getUseSAO() && m_pcCfg->getSaoLcuBoundary() ) 1637 1611 { 1638 1612 m_pcSAO->getPreDBFStatistics(pcPic); 1639 1613 } 1640 #else1641 if( m_pcCfg->getSaoLcuBasedOptimization() && m_pcCfg->getSaoLcuBoundary() )1642 {1643 m_pcSAO->resetStats();1644 m_pcSAO->calcSaoStatsCu_BeforeDblk( pcPic );1645 }1646 #endif1647 1614 //-- Loop filter 1648 1615 Bool bLFCrossTileBoundary = pcSlice->getPPS()->getLoopFilterAcrossTilesEnabledFlag(); … … 1654 1621 m_pcLoopFilter->loopFilterPic( pcPic ); 1655 1622 1656 #if !HM_CLEANUP_SAO1657 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 #endif1677 1623 /////////////////////////////////////////////////////////////////////////////////////////////////// File writing 1678 1624 // Set entropy coder … … 1792 1738 { 1793 1739 SOPcurrPOC += deltaPOC; 1794 SOPDescriptionSEI.m_sopDescVclNaluType[i] = getNalUnitType(SOPcurrPOC, m_iLastIDR );1740 SOPDescriptionSEI.m_sopDescVclNaluType[i] = getNalUnitType(SOPcurrPOC, m_iLastIDR, isField); 1795 1741 SOPDescriptionSEI.m_sopDescTemporalId[i] = m_pcCfg->getGOPEntry(j).m_temporalId; 1796 1742 SOPDescriptionSEI.m_sopDescStRpsIdx[i] = m_pcEncTop->getReferencePictureSetIdxForSOP(pcSlice, SOPcurrPOC, j); … … 2257 2203 m_pcEntropyCoder->resetEntropy(); 2258 2204 m_pcEntropyCoder->setBitstream( m_pcBitCounter ); 2259 #if HM_CLEANUP_SAO2260 2205 Bool sliceEnabled[NUM_SAO_COMPONENTS]; 2261 2206 m_pcSAO->initRDOCabacCoder(m_pcEncTop->getRDGoOnSbacCoder(), pcSlice); … … 2276 2221 pcPic->getSlice(s)->setSaoEnabledFlagChroma(sliceEnabled[SAO_Cb]); 2277 2222 } 2278 #else2279 m_pcSAO->startSaoEnc(pcPic, m_pcEntropyCoder, m_pcEncTop->getRDSbacCoder(), m_pcEncTop->getRDGoOnSbacCoder());2280 SAOParam& cSaoParam = *pcSlice->getPic()->getPicSym()->getSaoParam();2281 2282 #if SAO_ENCODING_CHOICE2283 m_pcSAO->SAOProcess(&cSaoParam, pcPic->getSlice(0)->getLambdas()[TEXT_LUMA], pcPic->getSlice(0)->getLambdas()[TEXT_CHROMA], pcPic->getSlice(0)->getDepth());2284 #else2285 m_pcSAO->SAOProcess(&cSaoParam, pcPic->getSlice(0)->getLambdaLuma(), pcPic->getSlice(0)->getLambdaChroma());2286 #endif2287 m_pcSAO->endSaoEnc();2288 m_pcSAO->PCMLFDisableProcess(pcPic);2289 #endif2290 2223 } 2291 #if !HM_CLEANUP_SAO2292 #if SAO_RDO2293 m_pcEntropyCoder->setEntropyCoder ( m_pcCavlcCoder, pcSlice );2294 #endif2295 #endif2296 2224 processingState = ENCODE_SLICE; 2297 #if !HM_CLEANUP_SAO2298 #if HIGHER_LAYER_IRAP_SKIP_FLAG2299 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 #endif2305 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 #endif2313 2225 } 2314 2226 break; … … 2321 2233 } 2322 2234 } // end iteration over slices 2323 #if !HM_CLEANUP_SAO2324 if(pcSlice->getSPS()->getUseSAO())2325 {2326 if(pcSlice->getSPS()->getUseSAO())2327 {2328 m_pcSAO->destroyPicSaoInfo();2329 }2330 pcPic->destroyNonDBFilterInfo();2331 }2332 #endif2333 2235 pcPic->compressMotion(); 2334 2236 … … 2402 2304 2403 2305 //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)) 2405 2307 { 2406 2308 //get complementary top field … … 2414 2316 xCalculateInterlacedAddPSNR(pcPicTop, pcPic, pcPicTop->getPicYuvRec(), pcPic->getPicYuvRec(), accessUnit, dEncTime ); 2415 2317 } 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 } 2416 2330 2417 2331 if (digestStr) … … 2717 2631 m_pcEntropyCoder->resetEntropy (); 2718 2632 m_pcEntropyCoder->setBitstream ( m_pcBitCounter ); 2719 #if !HM_CLEANUP_SAO2720 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 #endif2735 2633 m_pcEntropyCoder->resetEntropy (); 2736 2634 ruiBits += m_pcEntropyCoder->getNumberOfWrittenBits(); … … 3303 3201 * This function checks the configuration and returns the appropriate nal_unit_type for the picture. 3304 3202 */ 3305 NalUnitType TEncGOP::getNalUnitType(Int pocCurr, Int lastIDR )3203 NalUnitType TEncGOP::getNalUnitType(Int pocCurr, Int lastIDR, Bool isField) 3306 3204 { 3307 3205 if (pocCurr == 0) … … 3309 3207 return NAL_UNIT_CODED_SLICE_IDR_W_RADL; 3310 3208 } 3311 if ( pocCurr% m_pcCfg->getIntraPeriod() == 0)3209 if ((pocCurr - isField) % m_pcCfg->getIntraPeriod() == 0) 3312 3210 { 3313 3211 if (m_pcCfg->getDecodingRefreshType() == 1) … … 3532 3430 return seiStartPos; 3533 3431 } 3534 3535 #if N0383_IL_CONSTRAINED_TILE_SETS_SEI3536 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 #endif3576 3432 3577 3433 Void TEncGOP::dblMetric( TComPic* pcPic, UInt uiNumSlices ) … … 3698 3554 free(rowSAD); 3699 3555 } 3556 #if SVC_EXTENSION 3557 #if LAYERS_NOT_PRESENT_SEI 3558 SEILayersNotPresent* 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 3577 SEIInterLayerConstrainedTileSets* 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 3614 Void 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 3700 3656 //! \} -
trunk/source/Lib/TLibEncoder/TEncGOP.h
r588 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * … … 83 83 Bool m_bFirst; 84 84 85 #if SVC_EXTENSION86 UInt m_layerId;87 #endif88 89 85 // Access channel 90 86 TEncTop* m_pcEncTop; … … 92 88 TEncSlice* m_pcSliceEncoder; 93 89 TComList<TComPic*>* m_pcListPic; 94 95 #if SVC_EXTENSION96 TEncTop** m_ppcTEncTop;97 #if SVC_UPSAMPLING98 TEncSearch* m_pcPredSearch; ///< encoder search class99 #endif100 #endif101 90 102 91 TEncEntropy* m_pcEntropyCoder; … … 120 109 std::vector<Int> m_storedStartCUAddrForEncodingSlice; 121 110 std::vector<Int> m_storedStartCUAddrForEncodingSliceSegment; 111 #if FIX1172 112 NalUnitType m_associatedIRAPType; 113 Int m_associatedIRAPPOC; 114 #endif 122 115 123 116 std::vector<Int> m_vRVM_RP; … … 132 125 Bool m_nestedBufferingPeriodSEIPresentInAU; 133 126 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 134 136 public: 135 137 TEncGOP(); … … 162 164 163 165 TEncSlice* getSliceEncoder() { return m_pcSliceEncoder; } 164 NalUnitType getNalUnitType( Int pocCurr, Int lastIdr );166 NalUnitType getNalUnitType( Int pocCurr, Int lastIdr, Bool isField ); 165 167 Void arrangeLongtermPicturesInRPS(TComSlice *, TComList<TComPic*>& ); 166 168 protected: … … 181 183 182 184 SEIActiveParameterSets* xCreateSEIActiveParameterSets (TComSPS *sps); 183 #if LAYERS_NOT_PRESENT_SEI184 SEILayersNotPresent* xCreateSEILayersNotPresent ();185 #endif186 185 SEIFramePacking* xCreateSEIFramePacking(); 187 186 SEIDisplayOrientation* xCreateSEIDisplayOrientation(); 188 187 189 188 SEIToneMappingInfo* xCreateSEIToneMappingInfo(); 190 191 #if N0383_IL_CONSTRAINED_TILE_SETS_SEI192 SEIInterLayerConstrainedTileSets* xCreateSEIInterLayerConstrainedTileSets();193 #endif194 189 195 190 Void xCreateLeadingSEIMessages (/*SEIMessages seiMessages,*/ AccessUnit &accessUnit, TComSPS *sps); … … 206 201 m_nestedPictureTimingSEIPresentInAU = false; 207 202 } 203 Void dblMetric( TComPic* pcPic, UInt uiNumSlices ); 204 205 #if SVC_EXTENSION 206 #if LAYERS_NOT_PRESENT_SEI 207 SEILayersNotPresent* xCreateSEILayersNotPresent (); 208 #endif 208 209 #if N0383_IL_CONSTRAINED_TILE_SETS_SEI 209 210 Void xBuildTileSetsMap(TComPicSym* picSym); 210 #endif 211 Void dblMetric( TComPic* pcPic, UInt uiNumSlices ); 211 SEIInterLayerConstrainedTileSets* xCreateSEIInterLayerConstrainedTileSets(); 212 #endif 213 #endif //SVC_EXTENSION 212 214 };// END CLASS DEFINITION TEncGOP 213 215 -
trunk/source/Lib/TLibEncoder/TEncPic.cpp
r494 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * -
trunk/source/Lib/TLibEncoder/TEncPic.h
r494 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * -
trunk/source/Lib/TLibEncoder/TEncPreanalyzer.cpp
r313 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * -
trunk/source/Lib/TLibEncoder/TEncPreanalyzer.h
r313 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * -
trunk/source/Lib/TLibEncoder/TEncRateCtrl.cpp
r540 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * -
trunk/source/Lib/TLibEncoder/TEncRateCtrl.h
r540 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * -
trunk/source/Lib/TLibEncoder/TEncSampleAdaptiveOffset.cpp
r540 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * … … 46 46 47 47 48 #if HM_CLEANUP_SAO49 50 48 /** rounding with IBDI 51 49 * \param x … … 259 257 TComPicYuv* orgYuv= pPic->getPicYuvOrg(); 260 258 TComPicYuv* resYuv= pPic->getPicYuvRec(); 261 m_la bmda[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]; 262 260 TComPicYuv* srcYuv = m_tempPicYuv; 263 261 resYuv->copyToPic(srcYuv); … … 509 507 if( quantOffsets[classIdx] != 0 ) //iterative adjustment only when derived offset is not zero 510 508 { 511 quantOffsets[classIdx] = estIterOffset( typeIdc, classIdx, m_la bmda[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 ); 512 510 } 513 511 } … … 523 521 for(Int classIdx=0; classIdx< NUM_SAO_BO_CLASSES; classIdx++) 524 522 { 525 costBOClasses[classIdx]= m_la bmda[compIdx];523 costBOClasses[classIdx]= m_lambda[compIdx]; 526 524 if( quantOffsets[classIdx] != 0 ) //iterative adjustment only when derived offset is not zero 527 525 { 528 quantOffsets[classIdx] = estIterOffset( typeIdc, classIdx, m_la bmda[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 ); 529 527 } 530 528 } … … 572 570 { 573 571 Double minCost, cost; 574 Int rate, minRate; 572 Int rate; 573 UInt previousWrittenBits; 575 574 Int64 dist[NUM_SAO_COMPONENTS], modeDist[NUM_SAO_COMPONENTS]; 576 575 SAOOffset testOffset[NUM_SAO_COMPONENTS]; … … 592 591 m_pcRDGoOnSbacCoder->resetBits(); 593 592 m_pcRDGoOnSbacCoder->codeSAOOffsetParam(compIdx, modeParam[compIdx], sliceEnabled[compIdx]); 594 minRate= m_pcRDGoOnSbacCoder->getNumberOfWrittenBits();595 593 modeDist[compIdx] = 0; 596 minCost= m_la bmda[compIdx]*((Double)minRate);594 minCost= m_lambda[compIdx]*((Double)m_pcRDGoOnSbacCoder->getNumberOfWrittenBits()); 597 595 m_pcRDGoOnSbacCoder->store(cabacCoderRDO[SAO_CABACSTATE_BLK_TEMP]); 598 596 if(sliceEnabled[compIdx]) … … 617 615 m_pcRDGoOnSbacCoder->codeSAOOffsetParam(compIdx, testOffset[compIdx], sliceEnabled[compIdx]); 618 616 rate = m_pcRDGoOnSbacCoder->getNumberOfWrittenBits(); 619 cost = (Double)dist[compIdx] + m_la bmda[compIdx]*((Double)rate);617 cost = (Double)dist[compIdx] + m_lambda[compIdx]*((Double)rate); 620 618 if(cost < minCost) 621 619 { 622 620 minCost = cost; 623 minRate = rate;624 621 modeDist[compIdx] = dist[compIdx]; 625 622 modeParam[compIdx]= testOffset[compIdx]; … … 632 629 633 630 //------ chroma --------// 634 assert(m_labmda[SAO_Cb] == m_labmda[SAO_Cr]);635 Double chromaLambda = m_labmda[SAO_Cb];636 631 //"off" case as initial cost 632 cost = 0; 633 previousWrittenBits = 0; 637 634 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; 645 648 646 649 //doesn't need to store cabac status here since the whole CTU parameters will be re-encoded at the end of this function … … 648 651 for(Int typeIdc=0; typeIdc< NUM_SAO_NEW_TYPES; typeIdc++) 649 652 { 653 m_pcRDGoOnSbacCoder->load(cabacCoderRDO[SAO_CABACSTATE_BLK_MID]); 654 m_pcRDGoOnSbacCoder->resetBits(); 655 previousWrittenBits = 0; 656 cost = 0; 657 650 658 for(compIdx= SAO_Cb; compIdx< NUM_SAO_COMPONENTS; compIdx++) 651 659 { … … 663 671 invertQuantOffsets(compIdx, typeIdc, testOffset[compIdx].typeAuxInfo, invQuantOffset, testOffset[compIdx].offset); 664 672 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 675 681 if(cost < minCost) 676 682 { 677 683 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 } 683 689 } 684 690 } … … 686 692 687 693 //----- 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 } 690 699 m_pcRDGoOnSbacCoder->load(cabacCoderRDO[inCabacLabel]); 691 700 m_pcRDGoOnSbacCoder->resetBits(); … … 724 733 //offsets have been reconstructed. Don't call inversed quantization function. 725 734 normDist += (((Double)getDistortion(ctu, compIdx, mergedOffsetParam.typeIdc, mergedOffsetParam.typeAuxInfo, mergedOffsetParam.offset, blkStats[ctu][compIdx][mergedOffsetParam.typeIdc])) 726 /m_la bmda[compIdx]735 /m_lambda[compIdx] 727 736 ); 728 737 } … … 1304 1313 } 1305 1314 1306 #else1307 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_CHROMA1326 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 #endif1335 }1336 TEncSampleAdaptiveOffset::~TEncSampleAdaptiveOffset()1337 {1338 1339 }1340 // ====================================================================================================================1341 // Constants1342 // ====================================================================================================================1343 1344 1345 // ====================================================================================================================1346 // Tables1347 // ====================================================================================================================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 IBDI1355 * \param x1356 */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 partition1365 * \param *psQTPart, iPartIdx, dLambda1366 */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 else1399 {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 = -11415 allowMergeLeft = 1;1416 allowMergeUp = 1;1417 if (rx != 0)1418 {1419 // check tile id and slice id1420 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 // reset1434 resetSaoUnit(&saoLcuParamRdo);1435 1436 // set merge flag1437 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 Position1462 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 Offsets1480 // Code Center1481 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 = -11494 allowMergeLeft = 1;1495 allowMergeUp = 1;1496 if (rx != 0)1497 {1498 // check tile id and slice id1499 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 // reset1513 resetSaoUnit(&saoLcuParamRdo);1514 1515 // set merge flag1516 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 offsets1530 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 else1558 {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 else1594 {1595 // pOnePart->bEnableFlag = 0;1596 pOnePart->iLength = 0;1597 }1598 }1599 1600 /** Run partition tree disable1601 */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 function1619 * \param iPartIdx, pcPicOrg, pcPicDec, pcPicRest, &dCostFinal1620 */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 part1634 if(!pOnePart->bProcessed)1635 {1636 rdoSaoOnePart (psQTPart, iPartIdx, dLambda, yCbCr);1637 }1638 1639 //SAO for sub 4 parts1640 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 buffer1650 {1651 m_pppcRDSbacCoder[uhNextDepth][CI_CURR_BEST]->load(m_pppcRDSbacCoder[uiDepth][CI_CURR_BEST]);1652 }1653 else1654 {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 else1678 {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 else1692 {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 SAO1846 * \param1847 */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_EST1903 m_pppcBinCoderCABAC = new TEncBinCABACCounter** [iMaxDepth+1];1904 #else1905 m_pppcBinCoderCABAC = new TEncBinCABAC** [iMaxDepth+1];1906 #endif1907 1908 for ( Int iDepth = 0; iDepth < iMaxDepth+1; iDepth++ )1909 {1910 m_pppcRDSbacCoder[iDepth] = new TEncSbac* [CI_NUM];1911 #if FAST_BIT_EST1912 m_pppcBinCoderCABAC[iDepth] = new TEncBinCABACCounter* [CI_NUM];1913 #else1914 m_pppcBinCoderCABAC[iDepth] = new TEncBinCABAC* [CI_NUM];1915 #endif1916 for (Int iCIIdx = 0; iCIIdx < CI_NUM; iCIIdx ++ )1917 {1918 m_pppcRDSbacCoder[iDepth][iCIIdx] = new TEncSbac;1919 #if FAST_BIT_EST1920 m_pppcBinCoderCABAC [iDepth][iCIIdx] = new TEncBinCABACCounter;1921 #else1922 m_pppcBinCoderCABAC [iDepth][iCIIdx] = new TEncBinCABAC;1923 #endif1924 m_pppcRDSbacCoder [iDepth][iCIIdx]->init( m_pppcBinCoderCABAC [iDepth][iCIIdx] );1925 }1926 }1927 }1928 1929 /** Start SAO encoder1930 * \param pcPic, pcEntropyCoder, pppcRDSbacCoder, pcRDGoOnSbacCoder1931 */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 encoder1951 */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 processing1964 * \param pRecStart to-be-filtered block buffer pointer1965 * \param pOrgStart original block buffer pointer1966 * \param stride picture buffer stride1967 * \param ppStat statistics buffer1968 * \param ppCount counter buffer1969 * \param width block width1970 * \param height block height1971 * \param pbBorderAvail availabilities of block border pixels1972 */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 sign2070 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 line2077 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 lines2098 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 line2120 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 sign2149 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 line2157 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 lines2178 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 line2197 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 LCU2217 * \param iAddr, iPartIdx, iYCbCr2218 */2219 Void TEncSampleAdaptiveOffset::calcSaoStatsCu(Int iAddr, Int iPartIdx, Int iYCbCr)2220 {2221 if(!m_bUseNIF)2222 {2223 calcSaoStatsCuOrg( iAddr, iPartIdx, iYCbCr);2224 }2225 else2226 {2227 Int64** ppStats = m_iOffsetOrg[iPartIdx];2228 Int64** ppCount = m_iCount [iPartIdx];2229 2230 //parameters2231 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 //variables2239 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 slice2260 * \param iAddr, iPartIdx, iYCbCr2261 */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 statistics2833 * \param *psQTPart, iYCbCr2834 */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 else2863 {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 statistics2902 * \param2903 */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 process2927 * \param pcSaoParam2928 * \param dLambdaLuma2929 * \param dLambdaChroma2930 */2931 #if SAO_ENCODING_CHOICE2932 Void TEncSampleAdaptiveOffset::SAOProcess(SAOParam *pcSaoParam, Double dLambdaLuma, Double dLambdaChroma, Int depth)2933 #else2934 Void TEncSampleAdaptiveOffset::SAOProcess(SAOParam *pcSaoParam, Double dLambdaLuma, Double dLambdaChroma)2935 #endif2936 {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_CHOICE2955 rdoSaoUnitAll(pcSaoParam, dLambdaLuma, dLambdaChroma, depth);2956 #else2957 rdoSaoUnitAll(pcSaoParam, dLambdaLuma, dLambdaChroma);2958 #endif2959 }2960 else2961 {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 unit2987 * \param saoUnitCurr current SAO unit2988 * \param saoUnitCheck SAO unit tobe check2989 * \param dir direction2990 */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 else3015 {3016 saoUnitCurr->mergeUpFlag = 0;3017 saoUnitCurr->mergeLeftFlag = 1;3018 }3019 }3020 }3021 }3022 else3023 {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 else3033 {3034 saoUnitCurr->mergeUpFlag = 0;3035 saoUnitCurr->mergeLeftFlag = 1;3036 }3037 }3038 }3039 }3040 }3041 /** Assign SAO unit syntax from picture-based algorithm3042 * \param saoLcuParam SAO LCU parameters3043 * \param saoPart SAO part3044 * \param oneUnitFlag SAO one unit flag3045 * \param iYCbCr color component Index3046 */3047 Void TEncSampleAdaptiveOffset::assignSaoUnitSyntax(SaoLcuParam* saoLcuParam, SAOQTPart* saoPart, Bool &oneUnitFlag, Int yCbCr)3048 {3049 if (saoPart->bSplit == 0)3050 {3051 oneUnitFlag = 1;3052 }3053 else3054 {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 units3105 * \param saoParam SAO parameters3106 * \param lambda3107 * \param lambdaChroma3108 */3109 #if SAO_ENCODING_CHOICE3110 Void TEncSampleAdaptiveOffset::rdoSaoUnitAll(SAOParam *saoParam, Double lambda, Double lambdaChroma, Int depth)3111 #else3112 Void TEncSampleAdaptiveOffset::rdoSaoUnitAll(SAOParam *saoParam, Double lambda, Double lambdaChroma)3113 #endif3114 {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_PICTURES3130 saoParam->bSaoFlag[1] = m_pcPic->getChromaFormat() == CHROMA_400 ? false : true;3131 #else3132 saoParam->bSaoFlag[1] = true;3133 #endif3134 saoParam->oneUnitFlag[0] = false;3135 saoParam->oneUnitFlag[1] = false;3136 saoParam->oneUnitFlag[2] = false;3137 3138 #if SAO_ENCODING_CHOICE3139 #if SAO_ENCODING_CHOICE_CHROMA3140 Int numNoSao[2];3141 numNoSao[0] = 0;// Luma3142 numNoSao[1] = 0;// Chroma3143 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 #else3152 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 #endif3160 #endif3161 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 id3176 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 else3182 {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 else3193 {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, Cr3211 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 else3223 {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_CHOICE3234 if( (compIdx ==0 && saoParam->bSaoFlag[0])|| (compIdx >0 && saoParam->bSaoFlag[1]) )3235 #endif3236 {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_params3246 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 Merge3269 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_CHOICE3303 #if SAO_ENCODING_CHOICE_CHROMA3304 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 #else3313 for ( compIdx=0;compIdx<3;compIdx++)3314 {3315 if( depth == 0 && saoParam->saoLcuParam[compIdx][addr].typeIdx == -1)3316 {3317 numNoSao++;3318 }3319 }3320 #endif3321 #endif3322 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_CHOICE3328 #if SAO_ENCODING_CHOICE_CHROMA3329 if( !saoParam->bSaoFlag[0])3330 {3331 m_depthSaoRate[0][depth] = 1.0;3332 }3333 else3334 {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 else3342 {3343 m_depthSaoRate[1][depth] = numNoSao[1]/((Double) frameHeightInCU*frameWidthInCU*2);3344 }3345 #else3346 if( depth == 0)3347 {3348 // update SAO Rate3349 m_depth0SaoRate = numNoSao/((Double) frameHeightInCU*frameWidthInCU*3);3350 }3351 #endif3352 #endif3353 3354 }3355 /** rate distortion optimization of SAO unit3356 * \param saoParam SAO parameters3357 * \param addr address3358 * \param addrUp above address3359 * \param addrLeft left address3360 * \param yCbCr color component index3361 * \param lambda3362 */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 else3396 {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 offset3426 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 calculation3432 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 Position3498 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 Offsets3516 // Code Center3517 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 up3554 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 else3581 {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 Position3645 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 Offsets3666 // Code Center3667 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 else3675 {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 up3717 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 else3746 {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 #endif3760 3761 1315 //! \} -
trunk/source/Lib/TLibEncoder/TEncSampleAdaptiveOffset.h
r540 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * … … 54 54 // ==================================================================================================================== 55 55 56 #if HM_CLEANUP_SAO57 56 enum SAOCabacStateLablesRDO //CABAC state labels 58 57 { … … 146 145 TEncSbac* m_pcRDGoOnSbacCoder; 147 146 TEncBinCABACCounter** m_pppcBinCoderCABAC; 148 Double m_la bmda[NUM_SAO_COMPONENTS];147 Double m_lambda[NUM_SAO_COMPONENTS]; 149 148 150 149 //statistics … … 159 158 Int m_skipLinesB[NUM_SAO_COMPONENTS][NUM_SAO_NEW_TYPES]; 160 159 }; 161 #else162 163 164 class TEncSampleAdaptiveOffset : public TComSampleAdaptiveOffset165 {166 private:167 TEncEntropy* m_pcEntropyCoder;168 TEncSbac*** m_pppcRDSbacCoder; ///< for CABAC169 TEncSbac* m_pcRDGoOnSbacCoder;170 #if FAST_BIT_EST171 TEncBinCABACCounter*** m_pppcBinCoderCABAC; ///< temporal CABAC state storage for RD computation172 #else173 TEncBinCABAC*** m_pppcBinCoderCABAC; ///< temporal CABAC state storage for RD computation174 #endif175 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_CHOICE191 #if SAO_ENCODING_CHOICE_CHROMA192 Double m_depthSaoRate[2][4];193 #else194 Double m_depth0SaoRate;195 #endif196 #endif197 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_CHOICE206 Void SAOProcess(SAOParam *pcSaoParam, Double dLambda, Double dLambdaChroma, Int depth);207 #else208 Void SAOProcess(SAOParam *pcSaoParam, Double dLambda, Double dLambdaChroma);209 #endif210 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_CHOICE225 Void rdoSaoUnitAll(SAOParam *saoParam, Double lambda, Double lambdaChroma, Int depth);226 #else227 Void rdoSaoUnitAll(SAOParam *saoParam, Double lambda, Double lambdaChroma);228 #endif229 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 #endif238 160 //! \} 239 161 -
trunk/source/Lib/TLibEncoder/TEncSbac.cpp
r540 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * … … 78 78 , m_cCUAbsSCModel ( 1, 1, NUM_ABS_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) 79 79 , 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)81 80 , m_cSaoMergeSCModel ( 1, 1, NUM_SAO_MERGE_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) 82 81 , m_cSaoTypeIdxSCModel ( 1, 1, NUM_SAO_TYPE_IDX_CTX , m_contextModels + m_numContextModels, m_numContextModels) … … 112 111 m_cCUMergeIdxExtSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_MERGE_IDX_EXT); 113 112 m_cCUPartSizeSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_PART_SIZE ); 114 m_cCUAMPSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_CU_AMP_POS );115 113 m_cCUPredModeSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_PRED_MODE ); 116 114 m_cCUIntraPredSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_INTRA_PRED_MODE ); … … 166 164 curCost += m_cCUMergeIdxExtSCModel.calcCost ( curSliceType, qp, (UChar*)INIT_MERGE_IDX_EXT); 167 165 curCost += m_cCUPartSizeSCModel.calcCost ( curSliceType, qp, (UChar*)INIT_PART_SIZE ); 168 curCost += m_cCUAMPSCModel.calcCost ( curSliceType, qp, (UChar*)INIT_CU_AMP_POS );169 166 curCost += m_cCUPredModeSCModel.calcCost ( curSliceType, qp, (UChar*)INIT_PRED_MODE ); 170 167 curCost += m_cCUIntraPredSCModel.calcCost ( curSliceType, qp, (UChar*)INIT_INTRA_PRED_MODE ); … … 215 212 m_cCUMergeIdxExtSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_MERGE_IDX_EXT); 216 213 m_cCUPartSizeSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_PART_SIZE ); 217 m_cCUAMPSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_CU_AMP_POS );218 214 m_cCUPredModeSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_PRED_MODE ); 219 215 m_cCUIntraPredSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_INTRA_PRED_MODE ); … … 442 438 if (eSize == SIZE_2NxN) 443 439 { 444 m_pcBinIf->encodeBin(1, m_cCU AMPSCModel.get( 0, 0, 0));440 m_pcBinIf->encodeBin(1, m_cCUPartSizeSCModel.get( 0, 0, 3 )); 445 441 } 446 442 else 447 443 { 448 m_pcBinIf->encodeBin(0, m_cCU AMPSCModel.get( 0, 0, 0 ));444 m_pcBinIf->encodeBin(0, m_cCUPartSizeSCModel.get( 0, 0, 3 )); 449 445 m_pcBinIf->encodeBinEP((eSize == SIZE_2NxnU? 0: 1)); 450 446 } … … 466 462 if (eSize == SIZE_Nx2N) 467 463 { 468 m_pcBinIf->encodeBin(1, m_cCU AMPSCModel.get( 0, 0, 0));464 m_pcBinIf->encodeBin(1, m_cCUPartSizeSCModel.get( 0, 0, 3 )); 469 465 } 470 466 else 471 467 { 472 m_pcBinIf->encodeBin(0, m_cCU AMPSCModel.get( 0, 0, 0));468 m_pcBinIf->encodeBin(0, m_cCUPartSizeSCModel.get( 0, 0, 3 )); 473 469 m_pcBinIf->encodeBinEP((eSize == SIZE_nLx2N? 0: 1)); 474 470 } … … 1393 1389 { 1394 1390 m_pcBinIf->encodeBin( 1, m_cSaoTypeIdxSCModel.get( 0, 0, 0 ) ); 1395 #if HM_CLEANUP_SAO1396 1391 m_pcBinIf->encodeBinEP( uiCode == 1 ? 0 : 1 ); 1397 #else1398 m_pcBinIf->encodeBinEP( uiCode <= 4 ? 1 : 0 );1399 #endif1400 1392 } 1401 1393 } … … 1600 1592 } 1601 1593 1602 #if HM_CLEANUP_SAO1603 1594 Void TEncSbac::codeSAOOffsetParam(Int compIdx, SAOOffset& ctbParam, Bool sliceEnabled) 1604 1595 { … … 1713 1704 } 1714 1705 } 1715 #endif1716 1706 1717 1707 //! \} -
trunk/source/Lib/TLibEncoder/TEncSbac.h
r540 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * … … 104 104 Void codeScalingList ( TComScalingList* /*scalingList*/ ){ assert (0); return;}; 105 105 106 #if HM_CLEANUP_SAO107 106 Void codeSAOOffsetParam(Int compIdx, SAOOffset& ctbParam, Bool sliceEnabled); 108 107 Void codeSAOBlkParam(SAOBlkParam& saoBlkParam … … 112 111 , Bool onlyEstMergeInfo = false 113 112 ); 114 #endif115 113 116 114 private: … … 208 206 ContextModel3DBuffer m_cMVPIdxSCModel; 209 207 210 ContextModel3DBuffer m_cCUAMPSCModel;211 208 ContextModel3DBuffer m_cSaoMergeSCModel; 212 209 ContextModel3DBuffer m_cSaoTypeIdxSCModel; -
trunk/source/Lib/TLibEncoder/TEncSearch.cpp
r540 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * … … 199 199 m_pppcRDSbacCoder = pppcRDSbacCoder; 200 200 m_pcRDGoOnSbacCoder = pcRDGoOnSbacCoder; 201 202 m_bUseSBACRD = pppcRDSbacCoder ? true : false;203 201 204 202 for (Int iDir = 0; iDir < 2; iDir++) … … 1125 1123 { 1126 1124 Int scalingListType = 0 + g_eTTable[(Int)TEXT_LUMA]; 1127 assert(scalingListType < 6);1125 assert(scalingListType < SCALING_LIST_NUM); 1128 1126 m_pcTrQuant->invtransformNxN( pcCU->getCUTransquantBypass(uiAbsPartIdx), TEXT_LUMA,pcCU->getLumaIntraDir( uiAbsPartIdx ), piResi, uiStride, pcCoeff, uiWidth, uiHeight, scalingListType, useTransformSkip ); 1129 1127 } … … 1318 1316 { 1319 1317 Int scalingListType = 0 + g_eTTable[(Int)eText]; 1320 assert(scalingListType < 6);1318 assert(scalingListType < SCALING_LIST_NUM); 1321 1319 m_pcTrQuant->invtransformNxN( pcCU->getCUTransquantBypass(uiAbsPartIdx), TEXT_CHROMA, REG_DCT, piResi, uiStride, pcCoeff, uiWidth, uiHeight, scalingListType, useTransformSkipChroma ); 1322 1320 } … … 1424 1422 checkTransformSkip &= (widthTransformSkip == 4 && heightTransformSkip == 4); 1425 1423 checkTransformSkip &= (!pcCU->getCUTransquantBypass(0)); 1426 checkTransformSkip &= (!((pcCU->getQP( 0 ) == 0) && (pcCU->getSlice()->getSPS()->getUseLossless())));1427 1424 if ( m_pcEncCfg->getUseTransformSkipFast() ) 1428 1425 { … … 1434 1431 { 1435 1432 //----- 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 1440 1435 UInt singleDistYTmp = 0; 1441 1436 UInt singleDistCTmp = 0; … … 1503 1498 { 1504 1499 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 ] ); 1509 1501 } 1510 1502 } … … 1529 1521 } 1530 1522 } 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 } 1536 1525 1537 1526 if( !bLumaOnly ) … … 1558 1547 pcCU ->setTransformSkipSubParts ( 0, TEXT_LUMA, uiAbsPartIdx, uiFullDepth ); 1559 1548 //----- store original entropy coding status ----- 1560 if( m_bUseSBACRD &&bCheckSplit )1549 if( bCheckSplit ) 1561 1550 { 1562 1551 m_pcRDGoOnSbacCoder->store( m_pppcRDSbacCoder[ uiFullDepth ][ CI_QT_TRAFO_ROOT ] ); … … 1595 1584 { 1596 1585 //----- 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 1609 1596 //----- code splitted block ----- 1610 1597 Double dSplitCost = 0.0; … … 1647 1634 } 1648 1635 //----- 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 1653 1638 //----- determine rate and r-d cost ----- 1654 1639 UInt uiSplitBits = xGetIntraBitsQT( pcCU, uiTrDepth, uiAbsPartIdx, true, !bLumaOnly, false ); … … 1665 1650 } 1666 1651 //----- 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 1672 1654 //--- set transform index and Cbf values --- 1673 1655 pcCU->setTrIdxSubParts( uiTrDepth, uiAbsPartIdx, uiFullDepth ); … … 2194 2176 { 2195 2177 //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] ); 2200 2179 2201 2180 for(Int chromaId = 0; chromaId < 2; chromaId ++) … … 2239 2218 2240 2219 if(singleCostTmp < dSingleCost) 2220 { 2221 dSingleCost = singleCostTmp; 2222 singleDistC = singleDistCTmp; 2223 bestModeId = chromaModeId; 2224 singleCbfC = singleCbfCTmp; 2225 2226 if(bestModeId == firstCheckId) 2241 2227 { 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 ] ); 2259 2230 } 2260 2231 } 2261 2262 if(bestModeId == firstCheckId) 2232 if(chromaModeId == firstCheckId) 2263 2233 { 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 ] ); 2270 2235 } 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 } 2282 2252 } 2283 2253 else … … 2575 2545 2576 2546 // 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] ); 2581 2548 2582 2549 // determine residual for partition … … 2640 2607 2641 2608 // 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] ); 2646 2610 2647 2611 // determine residual for partition … … 2770 2734 2771 2735 //===== 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]); 2776 2737 2777 2738 //===== set distortion (rate and r-d costs are determined later) ===== … … 2805 2766 { 2806 2767 //----- 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] ); 2811 2769 2812 2770 //----- chroma coding ----- … … 2814 2772 pcCU->setChromIntraDirSubParts ( uiModeList[uiMode], 0, uiDepth ); 2815 2773 xRecurIntraChromaCodingQT ( pcCU, 0, 0, pcOrgYuv, pcPredYuv, pcResiYuv, uiDist ); 2816 if( m_bUseSBACRD &&pcCU->getSlice()->getPPS()->getUseTransformSkip() )2774 if( pcCU->getSlice()->getPPS()->getUseTransformSkip() ) 2817 2775 { 2818 2776 m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[uiDepth][CI_CURR_BEST] ); … … 2846 2804 2847 2805 //----- 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] ); 2852 2807 } 2853 2808 … … 3005 2960 dCost = m_pcRdCost->calcRdCost( uiBits, uiDistortion ); 3006 2961 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]); 3011 2963 3012 2964 pcCU->getTotalBits() = uiBits; … … 4574 4526 + m_pcRdCost->getDistPart(g_bitDepthC, rpcYuvRec->getCrAddr(), rpcYuvRec->getCStride(), pcYuvOrg->getCrAddr(), pcYuvOrg->getCStride(), uiWidth >> 1, uiHeight >> 1, TEXT_CHROMA_V ); 4575 4527 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]); 4580 4529 4581 4530 m_pcEntropyCoder->resetBits(); … … 4592 4541 pcCU->getTotalCost() = m_pcRdCost->calcRdCost( uiBits, uiDistortion ); 4593 4542 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]); 4598 4544 4599 4545 pcCU->setCbfSubParts( 0, 0, 0, 0, pcCU->getDepth( 0 ) ); … … 4631 4577 uiBits = 0; 4632 4578 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 ] ); 4637 4580 4638 4581 UInt uiZeroDistortion = 0; … … 4668 4611 } 4669 4612 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] ); 4674 4614 #if 0 // check 4675 4615 { … … 4677 4617 m_pcEntropyCoder->encodeCoeff( pcCU, 0, pcCU->getDepth(0), pcCU->getWidth(0), pcCU->getHeight(0) ); 4678 4618 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] ); 4683 4620 if( uiBitsForCoeff != uiBits ) 4684 4621 assert( 0 ); … … 4729 4666 dCostBest = dCost; 4730 4667 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 ] ); 4735 4669 } 4736 4670 } … … 4740 4674 if( qpMin != qpMax && qpBest != qpMax ) 4741 4675 { 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 4747 4679 // copy best cbf and trIdx to pcCU 4748 4680 const UInt uiQPartNum = pcCU->getPic()->getNumPartInCU() >> (pcCU->getDepth(0) << 1); … … 4824 4756 UInt uiBestTransformMode[3] = {0}; 4825 4757 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 ] ); 4830 4759 4831 4760 if( bCheckFull ) … … 4965 4894 4966 4895 Int scalingListType = 3 + g_eTTable[(Int)TEXT_LUMA]; 4967 assert(scalingListType < 6);4896 assert(scalingListType < SCALING_LIST_NUM); 4968 4897 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 4969 4898 … … 5038 4967 5039 4968 Int scalingListType = 3 + g_eTTable[(Int)TEXT_CHROMA_U]; 5040 assert(scalingListType < 6);4969 assert(scalingListType < SCALING_LIST_NUM); 5041 4970 m_pcTrQuant->invtransformNxN( pcCU->getCUTransquantBypass(uiAbsPartIdx), TEXT_CHROMA,REG_DCT, pcResiCurrU, m_pcQTTempTComYuv[uiQTTempAccessLayer].getCStride(), pcCoeffCurrU, trWidthC, trHeightC, scalingListType ); 5042 4971 … … 5108 5037 5109 5038 Int scalingListType = 3 + g_eTTable[(Int)TEXT_CHROMA_V]; 5110 assert(scalingListType < 6);5039 assert(scalingListType < SCALING_LIST_NUM); 5111 5040 m_pcTrQuant->invtransformNxN( pcCU->getCUTransquantBypass(uiAbsPartIdx), TEXT_CHROMA,REG_DCT, pcResiCurrV, m_pcQTTempTComYuv[uiQTTempAccessLayer].getCStride(), pcCoeffCurrV, trWidthC, trHeightC, scalingListType ); 5112 5041 … … 5192 5121 } 5193 5122 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 ] ); 5198 5124 5199 5125 pcCU->setTransformSkipSubParts ( 1, TEXT_LUMA, uiAbsPartIdx, uiDepth ); … … 5234 5160 5235 5161 Int scalingListType = 3 + g_eTTable[(Int)TEXT_LUMA]; 5236 assert(scalingListType < 6);5162 assert(scalingListType < SCALING_LIST_NUM); 5237 5163 5238 5164 m_pcTrQuant->invtransformNxN( pcCU->getCUTransquantBypass(uiAbsPartIdx), TEXT_LUMA,REG_DCT, pcResiCurrY, m_pcQTTempTComYuv[uiQTTempAccessLayer].getStride(), pcCoeffCurrY, trWidth, trHeight, scalingListType, true ); … … 5292 5218 } 5293 5219 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 ] ); 5298 5221 5299 5222 pcCU->setTransformSkipSubParts ( 1, TEXT_CHROMA_U, uiAbsPartIdx, pcCU->getDepth(0)+uiTrModeC ); … … 5345 5268 5346 5269 Int scalingListType = 3 + g_eTTable[(Int)TEXT_CHROMA_U]; 5347 assert(scalingListType < 6);5270 assert(scalingListType < SCALING_LIST_NUM); 5348 5271 5349 5272 m_pcTrQuant->invtransformNxN( pcCU->getCUTransquantBypass(uiAbsPartIdx), TEXT_CHROMA,REG_DCT, pcResiCurrU, m_pcQTTempTComYuv[uiQTTempAccessLayer].getCStride(), pcCoeffCurrU, trWidthC, trHeightC, scalingListType, true ); … … 5387 5310 5388 5311 Int scalingListType = 3 + g_eTTable[(Int)TEXT_CHROMA_V]; 5389 assert(scalingListType < 6);5312 assert(scalingListType < SCALING_LIST_NUM); 5390 5313 5391 5314 m_pcTrQuant->invtransformNxN( pcCU->getCUTransquantBypass(uiAbsPartIdx), TEXT_CHROMA,REG_DCT, pcResiCurrV, m_pcQTTempTComYuv[uiQTTempAccessLayer].getCStride(), pcCoeffCurrV, trWidthC, trHeightC, scalingListType, true ); … … 5423 5346 } 5424 5347 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 ] ); 5430 5349 m_pcEntropyCoder->resetBits(); 5431 5350 … … 5460 5379 if( bCheckSplit ) 5461 5380 { 5462 if( m_bUseSBACRD &&bCheckFull )5381 if( bCheckFull ) 5463 5382 { 5464 5383 m_pcRDGoOnSbacCoder->store( m_pppcRDSbacCoder[ uiDepth ][ CI_QT_TRAFO_TEST ] ); … … 5492 5411 } 5493 5412 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 ] ); 5498 5414 m_pcEntropyCoder->resetBits(); 5499 5415 … … 5523 5439 } 5524 5440 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 ] ); 5529 5443 } 5530 5444 rdCost += dSingleCost; … … 5717 5631 UInt TEncSearch::xModeBitsIntra( TComDataCU* pcCU, UInt uiMode, UInt uiPU, UInt uiPartOffset, UInt uiDepth, UInt uiInitTrDepth ) 5718 5632 { 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] ); 5724 5635 5725 5636 pcCU->setLumaIntraDirSubParts ( uiMode, uiPartOffset, uiDepth + uiInitTrDepth ); … … 6037 5948 } 6038 5949 5950 #if SVC_EXTENSION 6039 5951 #if REF_IDX_ME_ZEROMV 6040 5952 Void TEncSearch::xPatternSearchFracDIFMv0(TComDataCU* pcCU, … … 6205 6117 } 6206 6118 #endif 6119 #endif //SVC_EXTENSION 6207 6120 6208 6121 //! \} -
trunk/source/Lib/TLibEncoder/TEncSearch.h
r540 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * … … 97 97 TEncCfg* m_pcEncCfg; 98 98 99 #if SVC_EXTENSION100 TEncTop** m_ppcTEncTop;101 #endif102 103 99 // interface to classes 104 100 TComTrQuant* m_pcTrQuant; … … 118 114 TEncSbac*** m_pppcRDSbacCoder; 119 115 TEncSbac* m_pcRDGoOnSbacCoder; 120 Bool m_bUseSBACRD;121 116 DistParam m_cDistParam; 122 117 … … 130 125 UInt m_auiMVPIdxCost[AMVP_MAX_NUM_CANDS+1][AMVP_MAX_NUM_CANDS+1]; //th array bounds 131 126 127 #if SVC_EXTENSION 128 TEncTop** m_ppcTEncTop; 132 129 #if N0383_IL_CONSTRAINED_TILE_SETS_SEI 133 130 Bool m_disableILP; 134 131 #endif 132 #endif //SVC_EXTENAION 135 133 136 134 public: … … 207 205 ); 208 206 209 #if (ENCODER_FAST_MODE)210 Bool predInterSearchILRUni ( TComDataCU* pcCU, TComYuv* pcOrgYuv, TComYuv*& rpcPredYuv, TComYuv*& rpcResiYuv, TComYuv*& rpcRecoYuv, UInt refLayerId );211 #endif212 213 207 /// encode residual and compute rd-cost for inter mode 214 208 Void encodeResAndCalcRdInterCU( TComDataCU* pcCU, … … 226 220 Void IPCMSearch (TComDataCU* pcCU, TComYuv* pcOrgYuv, TComYuv*& rpcPredYuv, TComYuv*& rpcResiYuv, TComYuv*& rpcRecoYuv ); 227 221 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 228 226 #if N0383_IL_CONSTRAINED_TILE_SETS_SEI 229 227 Void setDisableILP(Bool a) {m_disableILP = a;} 230 228 #endif 229 #endif //SVC_EXTENSION 231 230 232 231 protected: … … 453 452 ,Bool biPred 454 453 ); 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 455 485 #if REF_IDX_ME_ZEROMV 456 486 Void xPatternSearchFracDIFMv0 ( TComDataCU* pcCU, … … 464 494 Bool biPred ); 465 495 #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 495 498 };// END CLASS DEFINITION TEncSearch 496 499 -
trunk/source/Lib/TLibEncoder/TEncSlice.cpp
r588 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * … … 254 254 255 255 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; 257 257 258 258 rpcSlice->setSliceType ( eSliceType ); … … 280 280 { 281 281 #if REPN_FORMAT_IN_VPS 282 if (!(( m_pcCfg->getMaxDeltaQP() == 0 ) && (dQP == -rpcSlice->getQpBDOffsetY() ) && (rpcSlice->get SPS()->getUseLossless())))282 if (!(( m_pcCfg->getMaxDeltaQP() == 0 ) && (dQP == -rpcSlice->getQpBDOffsetY() ) && (rpcSlice->getPPS()->getTransquantBypassEnableFlag()))) 283 283 #else 284 if (!(( m_pcCfg->getMaxDeltaQP() == 0 ) && (dQP == -rpcSlice->getSPS()->getQpBDOffsetY() ) && (rpcSlice->get SPS()->getUseLossless())))284 if (!(( m_pcCfg->getMaxDeltaQP() == 0 ) && (dQP == -rpcSlice->getSPS()->getQpBDOffsetY() ) && (rpcSlice->getPPS()->getTransquantBypassEnableFlag()))) 285 285 #endif 286 286 { … … 423 423 #if HB_LAMBDA_FOR_LDC 424 424 // 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; 426 426 427 427 #if SVC_EXTENSION … … 785 785 786 786 // 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 804 795 //------------------------------------------------------------------------------ 805 796 // Weighted Prediction parameters estimation. … … 854 845 UInt uiTilesAcross = 0; 855 846 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 891 878 UInt uiWidthInLCUs = rpcPic->getPicSym()->getFrameWidthInCU(); 892 879 //UInt uiHeightInLCUs = rpcPic->getPicSym()->getFrameHeightInCU(); … … 944 931 945 932 // 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. 960 969 } 961 970 else 962 971 { 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 993 977 994 978 // reset the entropy coder … … 1008 992 m_pcEntropyCoder->setEntropyCoder ( m_pcSbacCoder, pcSlice ); 1009 993 } 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) 1027 1016 { 1028 est QP = pcSlice->getSliceQp();1017 estLambda = m_pcRateCtrl->getRCPic()->getLCUEstLambdaAndQP(bpp, pcSlice->getSliceQp(), &estQP); 1029 1018 } 1030 1019 else 1031 1020 { 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 } 1042 1024 1043 1025 #if REPN_FORMAT_IN_VPS … … 1056 1038 m_pcTrQuant->setLambda( estLambda ); 1057 1039 #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; 1058 1091 } 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() ); 1144 1106 } 1145 1107 … … 1151 1113 { 1152 1114 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 } 1153 1126 } 1154 1127 if( depSliceSegmentsEnabled ) … … 1269 1242 uiCUAddr = rpcPic->getPicSym()->getCUOrderMap(++uiEncCUOrder) ) 1270 1243 { 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. 1285 1284 } 1286 1285 else 1287 1286 { 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 1322 1293 // reset the entropy coder 1323 1294 if( uiCUAddr == rpcPic->getPicSym()->getTComTile(rpcPic->getPicSym()->getTileIdxMap(uiCUAddr))->getFirstCUAddr() && // must be first CU of tile … … 1360 1331 1361 1332 TComDataCU*& pcCU = rpcPic->getCU( uiCUAddr ); 1362 #if HM_CLEANUP_SAO1363 1333 if ( pcSlice->getSPS()->getUseSAO() ) 1364 1334 { … … 1389 1359 } 1390 1360 } 1391 #else1392 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 else1428 {1429 mergeLeft = 0;1430 }1431 if(mergeLeft == 0)1432 {1433 if (allowMergeUp)1434 {1435 m_pcEntropyCoder->m_pcEntropyCoderIf->codeSaoMerge(mergeUp);1436 }1437 else1438 {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 #endif1475 1361 1476 1362 #if ENC_DEC_TRACE … … 1489 1375 g_bJustDoIt = g_bEncDecTraceDisable; 1490 1376 #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] ); 1501 1382 } 1502 1383 } … … 1870 1751 } 1871 1752 1753 #if SVC_EXTENSION 1872 1754 #if JCTVC_M0259_LAMBDAREFINEMENT 1873 1755 Double TEncSlice::xCalEnhLambdaFactor( Double deltaQP , Double beta ) … … 1888 1770 } 1889 1771 #endif 1772 #endif //SVC_EXTENSION 1890 1773 //! \} -
trunk/source/Lib/TLibEncoder/TEncSlice.h
r540 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * … … 65 65 // encoder configuration 66 66 TEncCfg* m_pcCfg; ///< encoder configuration class 67 68 #if SVC_EXTENSION69 TEncTop** m_ppcTEncTop;70 #endif71 67 72 68 // pictures … … 107 103 UInt m_uiSliceIdx; 108 104 std::vector<TEncSbac*> CTXMem; 105 106 #if SVC_EXTENSION 107 TEncTop** m_ppcTEncTop; 108 #endif 109 109 110 public: 110 111 TEncSlice(); … … 152 153 Double xGetQPValueAccordingToLambda ( Double lambda ); 153 154 155 #if SVC_EXTENSION 154 156 #if JCTVC_M0259_LAMBDAREFINEMENT 155 private:156 157 Double xCalEnhLambdaFactor( Double deltaQP , Double beta ); 157 158 #endif 159 #endif //SVC_EXTENSION 158 160 }; 159 161 -
trunk/source/Lib/TLibEncoder/TEncTop.cpp
r588 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * … … 129 129 if (m_bUseSAO) 130 130 { 131 #if HM_CLEANUP_SAO132 131 #if AUXILIARY_PICTURES 133 132 m_cEncSAO.create( getSourceWidth(), getSourceHeight(), m_chromaFormatIDC, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth ); … … 140 139 m_cEncSAO.createEncData(); 141 140 #endif 142 #else143 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 #endif149 141 } 150 142 #if ADAPTIVE_QP_SELECTION … … 161 153 g_uiMaxCUWidth, g_uiMaxCUHeight, m_RCKeepHierarchicalBit, m_RCUseLCUSeparateModel, m_GOPList ); 162 154 } 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]; 167 157 #if FAST_BIT_EST 168 169 #else 170 171 #endif 172 173 174 175 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]; 176 166 #if FAST_BIT_EST 177 178 #else 179 180 #endif 181 182 183 184 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; 185 175 #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] ); 192 181 } 193 182 } … … 226 215 m_pcSbacCoders[ui].init( &m_pcBinCoderCABACs[ui] ); 227 216 } 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] ); 248 235 } 249 236 } … … 259 246 if (m_cSPS.getUseSAO()) 260 247 { 261 #if HM_CLEANUP_SAO262 248 m_cEncSAO.destroyEncData(); 263 249 m_cEncSAO.destroy(); 264 #else265 m_cEncSAO.destroy();266 m_cEncSAO.destroyEncBuffer();267 #endif268 250 } 269 251 m_cLoopFilter. destroy(); 270 252 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 { 275 275 for ( iDepth = 0; iDepth < g_uiMaxCUDepth+1; iDepth++ ) 276 276 { 277 277 for (Int iCIIdx = 0; iCIIdx < CI_NUM; iCIIdx ++ ) 278 278 { 279 delete m_ppp cRDSbacCoder[iDepth][iCIIdx];280 delete m_ppp cBinCoderCABAC[iDepth][iCIIdx];281 } 282 } 283 279 delete m_ppppcRDSbacCoders [ui][iDepth][iCIIdx]; 280 delete m_ppppcBinCodersCABAC[ui][iDepth][iCIIdx]; 281 } 282 } 283 284 284 for ( iDepth = 0; iDepth < g_uiMaxCUDepth+1; iDepth++ ) 285 285 { 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; 315 294 delete[] m_pcSbacCoders; 316 295 delete[] m_pcBinCoderCABACs; … … 525 504 TComPic *pcTopField; 526 505 xGetNewPicBuffer( pcTopField ); 527 #if !HM_CLEANUP_SAO528 pcTopField->getPicSym()->allocSaoParam(&m_cEncSAO);529 #endif530 506 pcTopField->setReconMark (false); 531 507 … … 568 544 TComPic* pcBottomField; 569 545 xGetNewPicBuffer( pcBottomField ); 570 #if !HM_CLEANUP_SAO571 pcBottomField->getPicSym()->allocSaoParam(&m_cEncSAO);572 #endif573 546 pcBottomField->setReconMark (false); 574 547 … … 652 625 TComPic *pcTopField; 653 626 xGetNewPicBuffer( pcTopField ); 654 #if !HM_CLEANUP_SAO655 pcTopField->getPicSym()->allocSaoParam(&m_cEncSAO);656 #endif657 627 pcTopField->setReconMark (false); 658 628 … … 706 676 TComPic* pcBottomField; 707 677 xGetNewPicBuffer( pcBottomField ); 708 #if !HM_CLEANUP_SAO709 pcBottomField->getPicSym()->allocSaoParam(&m_cEncSAO);710 #endif711 678 pcBottomField->setReconMark (false); 712 679 … … 912 879 #endif 913 880 } 914 #if !HM_CLEANUP_SAO915 if (getUseSAO())916 {917 rpcPic->getPicSym()->allocSaoParam(&m_cEncSAO);918 }919 #endif920 881 m_cListPic.pushBack( rpcPic ); 921 882 } … … 1001 962 1002 963 m_cSPS.setTMVPFlagsPresent(false); 1003 m_cSPS.setUseLossless ( m_useLossless );1004 964 1005 965 m_cSPS.setMaxTrSize ( 1 << m_uiQuadtreeTULog2MaxSize ); … … 1038 998 m_cSPS.setMaxTLayers( m_maxTempLayer ); 1039 999 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++ ) 1041 1001 { 1042 1002 m_cSPS.setMaxDecPicBuffering(m_maxDecPicBuffering[i], i); … … 1098 1058 Bool bUseDQP = (getMaxCuDQPDepth() > 0)? true : false; 1099 1059 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; 1145 1063 } 1146 1064 -
trunk/source/Lib/TLibEncoder/TEncTop.h
r588 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * … … 73 73 UInt m_uiNumAllPicCoded; ///< number of coded pictures 74 74 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 83 76 // encoder search 84 77 TEncSearch m_cSearch; ///< encoder search class … … 130 123 131 124 #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 133 130 TEncTop** m_ppcTEncTop; 134 131 TEncTop* getLayerEnc(UInt layer) { return m_ppcTEncTop[layer]; } … … 163 160 Void xInitRPS (Bool isFieldCoding); ///< initialize PPS from encoder options 164 161 #if SVC_EXTENSION 165 Void xInitILRP();162 Void xInitILRP(); 166 163 #endif 167 164 public: … … 210 207 Int getReferencePictureSetIdxForSOP(TComSlice* slice, Int POCCurr, Int GOPid ); 211 208 TComScalingList* getScalingList () { return &m_scalingList; } 209 // ------------------------------------------------------------------------------------------------------------------- 210 // encoder function 211 // ------------------------------------------------------------------------------------------------------------------- 212 213 /// encode several number of pictures until end-of-sequence 212 214 #if SVC_EXTENSION 213 215 Void setLayerEnc(TEncTop** p) {m_ppcTEncTop = p;} … … 224 226 #endif 225 227 Window& getScaledRefLayerWindow(Int x) { return m_scaledRefLayerWindow[x]; } 226 #endif //SVC_EXTENSION227 228 // -------------------------------------------------------------------------------------------------------------------229 // encoder function230 // -------------------------------------------------------------------------------------------------------------------231 232 /// encode several number of pictures until end-of-sequence233 #if SVC_EXTENSION234 228 TComPic** getIlpList() { return m_cIlpPic; } 235 229 #if REF_IDX_MFM … … 281 275 282 276 #endif // __TENCTOP__ 277 -
trunk/source/Lib/TLibEncoder/WeightPredAnalysis.cpp
r494 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * -
trunk/source/Lib/TLibEncoder/WeightPredAnalysis.h
r313 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * -
trunk/source/Lib/TLibVideoIO/TVideoIOYuv.cpp
r494 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * -
trunk/source/Lib/TLibVideoIO/TVideoIOYuv.h
r442 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * -
trunk/source/Lib/libmd5/MD5.h
r313 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * -
trunk/source/Lib/libmd5/libmd5.h
r313 r595 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 *
Note: See TracChangeset for help on using the changeset viewer.