Changeset 427 in 3DVCSoftware
- Timestamp:
- 21 May 2013, 12:40:58 (11 years ago)
- Location:
- branches/HTM-6.2-dev0
- Files:
-
- 40 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HTM-6.2-dev0/CommonTestConditionsCfgs/baseCfg_2view+depth.cfg
r373 r427 151 151 ALFPicBasedEncode : 1 # ALF LCU-based or picture-based encoding (0: LCU-based, 1: Picture-based) 152 152 MaxNumOffsetsPerPic : 2048 # default 153 SAOInterleaving : 0 # SAO interleaving flag (0: SAO parameter in APS, 1: SAO parameter in slice data) 153 SAOLcuBoundary : 0 # 0: right/bottom LCU boundary areas skipped from SAO parameter estimation, 1: non-deblocked pixels are used for those areas 154 SAOLcuBasedOptimization : 1 # 0: SAO picture-based optimization, 1: SAO LCU-based optimization 154 155 ConstrainedIntraPred : 0 # Constrained Intra Prediction 155 156 weighted_pred_flag : 0 # weighted prediction flag (P-Slices) … … 199 200 FCO : 0 # Flexible coding order flag in 3DV 200 201 FCOCodingOrder : T0D0D1T1 # Coding order for Flexible coding order in 3DV 202 UseVSPCompensation : 1 # Depth dependent tools: BVSP 203 UseDVPRefine : 1 # Depth dependent tools: DoNBDV 201 204 202 205 -
branches/HTM-6.2-dev0/CommonTestConditionsCfgs/baseCfg_2view.cfg
r373 r427 145 145 ALFPicBasedEncode : 1 # ALF LCU-based or picture-based encoding (0: LCU-based, 1: Picture-based) 146 146 MaxNumOffsetsPerPic : 2048 # default 147 SAOInterleaving : 0 # SAO interleaving flag (0: SAO parameter in APS, 1: SAO parameter in slice data) 147 SAOLcuBoundary : 0 # 0: right/bottom LCU boundary areas skipped from SAO parameter estimation, 1: non-deblocked pixels are used for those areas 148 SAOLcuBasedOptimization : 1 # 0: SAO picture-based optimization, 1: SAO LCU-based optimization 148 149 ConstrainedIntraPred : 0 # Constrained Intra Prediction 149 150 weighted_pred_flag : 0 # weighted prediction flag (P-Slices) -
branches/HTM-6.2-dev0/CommonTestConditionsCfgs/baseCfg_3view+depth.cfg
r373 r427 155 155 ALFPicBasedEncode : 1 # ALF LCU-based or picture-based encoding (0: LCU-based, 1: Picture-based) 156 156 MaxNumOffsetsPerPic : 2048 # default 157 SAOInterleaving : 0 # SAO interleaving flag (0: SAO parameter in APS, 1: SAO parameter in slice data) 157 SAOLcuBoundary : 0 # 0: right/bottom LCU boundary areas skipped from SAO parameter estimation, 1: non-deblocked pixels are used for those areas 158 SAOLcuBasedOptimization : 1 # 0: SAO picture-based optimization, 1: SAO LCU-based optimization 158 159 ConstrainedIntraPred : 0 # Constrained Intra Prediction 159 160 weighted_pred_flag : 0 # weighted prediction flag (P-Slices) … … 203 204 FCO : 0 # Flexible coding order flag in 3DV 204 205 FCOCodingOrder : T0D0D1D2T1T2 # Coding order for Flexible coding order in 3DV 205 206 UseVSPCompensation : 1 # Depth dependent tools: BVSP 207 UseDVPRefine : 1 # Depth dependent tools: DoNBDV 206 208 207 209 #========== depth coding tools ========== -
branches/HTM-6.2-dev0/CommonTestConditionsCfgs/baseCfg_3view.cfg
r373 r427 147 147 ALFPicBasedEncode : 1 # ALF LCU-based or picture-based encoding (0: LCU-based, 1: Picture-based) 148 148 MaxNumOffsetsPerPic : 2048 # default 149 SAOInterleaving : 0 # SAO interleaving flag (0: SAO parameter in APS, 1: SAO parameter in slice data) 149 SAOLcuBoundary : 0 # 0: right/bottom LCU boundary areas skipped from SAO parameter estimation, 1: non-deblocked pixels are used for those areas 150 SAOLcuBasedOptimization : 1 # 0: SAO picture-based optimization, 1: SAO LCU-based optimization 150 151 ConstrainedIntraPred : 0 # Constrained Intra Prediction 151 152 weighted_pred_flag : 0 # weighted prediction flag (P-Slices) -
branches/HTM-6.2-dev0/source/App/TAppEncoder/TAppEncCfg.cpp
r390 r427 389 389 #endif 390 390 #endif 391 #if MTK_D0156 392 ("UseVSPCompensation", m_bUseVSPCompensation, true, "Depth dependent tools: BVSP" ) 393 ("UseDVPRefine", m_bUseDVPRefine, true, "Depth dependent tools: DoNBDV" ) 394 #endif 391 395 392 396 /* Coding tools */ … … 396 400 ("SAO", m_abUseSAO, std::vector<Bool>(1, true), "SAO") 397 401 ("MaxNumOffsetsPerPic", m_maxNumOffsetsPerPic, 2048, "2048: default") 402 #if LGE_SAO_MIGRATION_D0091 403 ("SAOLcuBoundary", m_saoLcuBoundary, false, "0: right/bottom LCU boundary areas skipped from SAO parameter estimation, 1: non-deblocked pixels are used for those areas") 404 ("SAOLcuBasedOptimization", m_saoLcuBasedOptimization, true, "0: SAO picture-based optimization, 1: SAO LCU-based optimization ") 405 #else 398 406 ("SAOInterleaving", m_saoInterleavingFlag, false, "0: SAO Picture Mode, 1: SAO Interleaving ") 407 #endif 399 408 400 409 ("ALFEncodePassReduction", m_iALFEncodePassReduction, 0, "0:Original 16-pass, 1: 1-pass, 2: 2-pass encoding") … … 1637 1646 printf("CIP:%d ", m_bUseConstrainedIntraPred); 1638 1647 printf("PCM:%d ", (m_usePCM && (1<<m_uiPCMLog2MinSize) <= m_uiMaxCUWidth)? 1 : 0); 1648 #if LGE_SAO_MIGRATION_D0091 1649 printf("SAOLcuBasedOptimization:%d ", (m_saoLcuBasedOptimization)?(1):(0)); 1650 #else 1639 1651 printf("SAOInterleaving:%d ", (m_saoInterleavingFlag)?(1):(0)); 1652 #endif 1640 1653 #if LOSSLESS_CODING 1641 1654 printf("LosslessCuEnabled:%d ", (m_useLossless)? 1:0 ); … … 1723 1736 printf("DLT:%d ", m_bUseDLT ? 1 : 0 ); 1724 1737 #endif 1738 1739 #if MTK_D0156 1740 printf("BVSP:%d ", m_bUseVSPCompensation ? 1 : 0 ); 1741 printf("DoNBDV:%d ", m_bUseDVPRefine ? 1 : 0 ); 1742 #endif 1743 1725 1744 #if LGE_WVSO_A0119 1726 1745 if ( m_bUseWVSO ) -
branches/HTM-6.2-dev0/source/App/TAppEncoder/TAppEncCfg.h
r373 r427 165 165 #endif 166 166 Int m_maxNumOffsetsPerPic; ///< SAO maximun number of offset per picture 167 #if LGE_SAO_MIGRATION_D0091 168 Bool m_saoLcuBoundary; ///< SAO parameter estimation using non-deblocked pixels for LCU bottom and right boundary areas 169 Bool m_saoLcuBasedOptimization; ///< SAO LCU-based optimization 170 #else 167 171 Bool m_saoInterleavingFlag; ///< SAO interleaving flag 172 #endif 168 173 // coding tools (loop filter) 169 174 vector<Bool> m_abUseALF; ///< flag for using adaptive loop filter [0] - video, [1] - depth … … 321 326 #endif 322 327 328 #if MTK_D0156 329 330 #if MERL_VSP_COMPENSATION_C0152 331 Bool m_bUseVSPCompensation; 332 #endif 333 334 Bool m_bUseDVPRefine; 335 #endif 336 323 337 // internal member functions 324 338 Void xSetGlobal (); ///< set global variables -
branches/HTM-6.2-dev0/source/App/TAppEncoder/TAppEncTop.cpp
r412 r427 230 230 #endif 231 231 #endif 232 #if MTK_D0156 233 #if MERL_VSP_COMPENSATION_C0152 234 m_acTEncTopList[iViewIdx]->setUseVSPCompensation ( iViewIdx ? m_bUseVSPCompensation : 0 ); 235 #endif 236 m_acTEncTopList[iViewIdx]->setUseDVPRefine ( iViewIdx ? m_bUseDVPRefine : 0 ); 237 #endif 232 238 233 239 //====== Tool list ======== … … 308 314 #endif 309 315 m_acTEncTopList[iViewIdx]->setMaxNumOffsetsPerPic (m_maxNumOffsetsPerPic); 316 #if LGE_SAO_MIGRATION_D0091 317 m_acTEncTopList[iViewIdx]->setSaoLcuBoundary (m_saoLcuBoundary); 318 m_acTEncTopList[iViewIdx]->setSaoLcuBasedOptimization (m_saoLcuBasedOptimization); 319 #else 310 320 m_acTEncTopList[iViewIdx]->setSaoInterleavingFlag (m_saoInterleavingFlag); 321 #endif 311 322 m_acTEncTopList[iViewIdx]->setPCMInputBitDepthFlag ( m_bPCMInputBitDepthFlag); 312 323 m_acTEncTopList[iViewIdx]->setPCMFilterDisableFlag ( m_bPCMFilterDisableFlag); … … 573 584 #endif 574 585 #endif 586 #if MTK_D0156 587 588 #if MERL_VSP_COMPENSATION_C0152 589 m_acTEncDepthTopList[iViewIdx]->setUseVSPCompensation ( iViewIdx ? true : false ); 590 #endif 591 592 m_acTEncDepthTopList[iViewIdx]->setUseDVPRefine ( iViewIdx ? true : false ); 593 #endif 575 594 576 595 //====== Weighted Prediction ======== … … 615 634 #endif 616 635 m_acTEncDepthTopList[iViewIdx]->setMaxNumOffsetsPerPic (m_maxNumOffsetsPerPic); 636 #if LGE_SAO_MIGRATION_D0091 637 m_acTEncDepthTopList[iViewIdx]->setSaoLcuBoundary (m_saoLcuBoundary); 638 m_acTEncDepthTopList[iViewIdx]->setSaoLcuBasedOptimization (m_saoLcuBasedOptimization); 639 #else 617 640 m_acTEncDepthTopList[iViewIdx]->setSaoInterleavingFlag (m_saoInterleavingFlag); 641 #endif 618 642 m_acTEncDepthTopList[iViewIdx]->setPCMInputBitDepthFlag ( m_bPCMInputBitDepthFlag); 619 643 m_acTEncDepthTopList[iViewIdx]->setPCMFilterDisableFlag ( m_bPCMFilterDisableFlag); -
branches/HTM-6.2-dev0/source/Lib/TLibCommon/ContextTables.h
r373 r427 101 101 #define NUM_ALF_SVLC_CTX 3 ///< number of context models for ALF SVLC (filter coeff.) 102 102 103 #if LGE_SAO_MIGRATION_D0091 104 #define NUM_SAO_MERGE_FLAG_CTX 1 ///< number of context models for SAO merge flags 105 #define NUM_SAO_TYPE_IDX_CTX 1 ///< number of context models for SAO type index 106 #else 103 107 #define NUM_SAO_FLAG_CTX 1 ///< number of context models for SAO flag 104 108 #define NUM_SAO_UVLC_CTX 2 ///< number of context models for SAO UVLC … … 108 112 #define NUM_SAO_MERGE_UP_FLAG_CTX 1 ///< number of context models for AO SVLC (filter coeff.) 109 113 #define NUM_SAO_TYPE_IDX_CTX 2 ///< number of context models for AO SVLC (filter coeff.) 114 #endif 110 115 #define CNU 154 ///< dummy initialization value for unused context models 'Context model Not Used' 111 116 … … 376 381 { 141, 154, 159, }, 377 382 }; 378 383 #if LGE_SAO_MIGRATION_D0091 384 static const UChar 385 INIT_SAO_MERGE_FLAG[3][NUM_SAO_MERGE_FLAG_CTX] = 386 { 387 { 153, }, 388 { 153, }, 389 { 153, }, 390 }; 391 392 static const UChar 393 INIT_SAO_TYPE_IDX[3][NUM_SAO_TYPE_IDX_CTX] = 394 { 395 { 200, }, 396 { 185, }, 397 { 160, }, 398 }; 399 #else 379 400 static const UChar 380 401 INIT_SAO_FLAG[3][NUM_SAO_FLAG_CTX] = … … 424 445 { 200, 140, }, 425 446 }; 447 #endif 426 448 427 449 static const UChar -
branches/HTM-6.2-dev0/source/Lib/TLibCommon/TComDataCU.cpp
r422 r427 53 53 #if MERL_VSP_C0152 54 54 55 #if MTK_D0156 56 #define CHECK_ADD_YET(pcCURef,uiIdx,vspIdx) && ( (!m_pcSlice->getSPS()->getUseVSPCompensation()) || (!( (pcCURef)->getVSPIndex(uiIdx) == vspIdx && bVspMvZeroDone[vspIdx-1] ))) 57 #else 55 58 #define CHECK_ADD_YET(pcCURef,uiIdx,vspIdx) && !( (pcCURef)->getVSPIndex(uiIdx) == vspIdx && bVspMvZeroDone[vspIdx-1] ) 59 #endif 56 60 57 61 inline Void TComDataCU::xInheritVspMode( TComDataCU* pcCURef, UInt uiIdx, Bool* bVspMvZeroDone, Int iCount, Int* iVSPIndexTrue, TComMvField* pcMvFieldNeighbours, DisInfo* pDInfo 62 #if QC_BVSP_CleanUP_D0191 63 , UChar *puhInterDirNeighbours 64 #endif 58 65 #if MERL_VSP_NBDV_RefVId_Fix_D0166 59 66 , Int* iVSPDirTrue … … 61 68 ) 62 69 { 70 #if MTK_D0156 71 if( !m_pcSlice->getSPS()->getUseVSPCompensation() ) 72 { 73 return; 74 } 75 #endif 76 63 77 Int vspIdx = (Int) pcCURef->getVSPIndex(uiIdx); 64 78 if( vspIdx != 0 ) … … 73 87 if (vspIdx < 4) 74 88 { 89 #if QC_BVSP_CleanUP_D0191 90 puhInterDirNeighbours[ iCount] = 1; 91 #endif 75 92 #if MERL_VSP_NBDV_RefVId_Fix_D0166 76 93 if(pDInfo->iN > 0 ) … … 126 143 } 127 144 128 inline Bool TComDataCU::xAddVspMergeCand( UChar ucVspMergePos, Int vspIdx, Bool* bVspMvZeroDone, UInt uiDepth, Bool* abCandIsInter, Int& iCount, 129 UChar* puhInterDirNeighbours, TComMvField* pcMvFieldNeighbours, Int* iVSPIndexTrue, Int mrgCandIdx, DisInfo* pDInfo 145 inline Bool TComDataCU::xAddVspMergeCand( 146 UChar ucVspMergePos, 147 #if !LGE_VSP_INHERIT_D0092 148 Int vspIdx, 149 Bool* bVspMvZeroDone, 150 #endif 151 UInt uiDepth, 152 Bool* abCandIsInter, 153 Int& iCount, 154 UChar* puhInterDirNeighbours, 155 TComMvField* pcMvFieldNeighbours, 156 Int* iVSPIndexTrue, 157 Int mrgCandIdx, 158 DisInfo* pDInfo 130 159 #if MERL_VSP_NBDV_RefVId_Fix_D0166 131 160 , Int* iVspDirTrue 132 161 #endif 133 162 ) 134 163 { 164 #if MTK_D0156 165 if( !m_pcSlice->getSPS()->getUseVSPCompensation() ) 166 { 167 return true; 168 } 169 #endif 170 135 171 #if MTK_LGE_VSP_DEPTH_OFF_D0105_D0139 136 172 if (getSlice()->getSPS()->isDepth()) … … 149 185 if( ucVspMergePos == VSP_MERGE_POS ) 150 186 { 187 #if !LGE_VSP_INHERIT_D0092 151 188 Int idx = vspIdx - 1; 152 { 189 #endif 190 { 191 #if LGE_VSP_INHERIT_D0092 192 if( getSlice()->getSPS()->getViewId() != 0 ) 193 #else 153 194 if( getSlice()->getSPS()->getViewId() != 0 && bVspMvZeroDone[idx] == false ) 195 #endif 154 196 { 155 197 { 156 198 abCandIsInter [iCount] = true; 199 #if !LGE_VSP_INHERIT_D0092 157 200 bVspMvZeroDone[idx] = true; 201 #endif 158 202 159 203 // get Inter Dir … … 161 205 (getSlice()->getNumRefIdx(REF_PIC_LIST_0) > 0 ? 1 : 2)); 162 206 puhInterDirNeighbours[iCount] = iInterDir; // The direction information does not matter 207 #if QC_BVSP_CleanUP_D0191 208 puhInterDirNeighbours[iCount] = 1; 209 #endif 210 #if LGE_VSP_INHERIT_D0092 211 Int iRefIdx = NOT_VALID; 212 #if QC_BVSP_CleanUP_D0191 213 iRefIdx = getSlice()->getRefPic(REF_PIC_LIST_0, 0)->getPOC()==getSlice()->getPOC() ? 0: getSlice()->getNewRefIdx(REF_PIC_LIST_0); 214 #endif 215 pcMvFieldNeighbours[iCount<<1].setMvField(pDInfo->m_acMvCand[0], iRefIdx ); 216 if ( getSlice()->isInterB() ) 217 { 218 pcMvFieldNeighbours[(iCount<<1)+1].setMvField( pDInfo->m_acMvCand[0], iRefIdx ); 219 } 220 iVSPIndexTrue[iCount] = 1; 221 #else 163 222 // get Mv using checked disparity vector 164 223 if (vspIdx < 4) // spatial … … 200 259 } 201 260 iVSPIndexTrue[idx] = iCount; 261 #endif 202 262 if ( mrgCandIdx == iCount ) 203 263 { … … 3239 3299 UInt iNumbPart; 3240 3300 3301 #if SHARP_ILLUCOMP_PARSE_D0060 3302 if (!(getPartitionSize(uiAbsPartIdx) == SIZE_2Nx2N)) 3303 { 3304 return false; 3305 } 3306 if (getSlice()->getIcSkipParseFlag()) 3307 { 3308 if (getMergeFlag(uiAbsPartIdx) && getMergeIndex(uiAbsPartIdx) == 0) 3309 { 3310 return false; 3311 } 3312 } 3313 if (getMergeFlag(uiAbsPartIdx)) 3314 { 3315 return true; 3316 } 3317 #endif 3318 #if !SHARP_ILLUCOMP_PARSE_D0060 3241 3319 if(!getSlice()->getIsDepth()) 3242 3320 { 3321 #endif 3243 3322 Int iWidth, iHeight; 3244 3323 … … 3261 3340 } 3262 3341 } 3342 #if !SHARP_ILLUCOMP_PARSE_D0060 3263 3343 } 3264 3344 else … … 3282 3362 } 3283 3363 } 3364 #endif 3284 3365 3285 3366 return false; … … 3292 3373 Int iWidth, iHeight; 3293 3374 3375 #if SHARP_ILLUCOMP_PARSE_D0060 3376 if (!(getPartitionSize(uiAbsPartIdx) == SIZE_2Nx2N)) 3377 { 3378 return false; 3379 } 3380 if (getSlice()->getIcSkipParseFlag()) 3381 { 3382 if (getMergeFlag(uiAbsPartIdx) && getMergeIndex(uiAbsPartIdx) == 0) 3383 { 3384 return false; 3385 } 3386 } 3387 if (getMergeFlag(uiAbsPartIdx)) 3388 { 3389 return true; 3390 } 3391 #endif 3294 3392 UInt uiPartMode = getPartitionSize(uiAbsPartIdx); 3295 3393 … … 3810 3908 this->getPartPosition(uiPUIdx, xP, yP, nPSW, nPSH); 3811 3909 3812 #if MERL_VSP_C0152 3910 #if MERL_VSP_C0152 && !LGE_VSP_INHERIT_D0092 3813 3911 Bool bVspMvZeroDone[3] = {false, false, false}; 3814 3912 #endif … … 3996 4094 } 3997 4095 } 3998 #if MERL_VSP_C0152 4096 #if MERL_VSP_C0152 && !QC_BVSP_CleanUP_D0191 && !LGE_VSP_INHERIT_D0092 3999 4097 #if !MTK_LGE_VSP_DEPTH_OFF_D0105_D0139 4000 4098 xInheritVspMode( pcTextureCU, uiPartIdxCenter, bVspMvZeroDone, iCount, iVSPIndexTrue, pcMvFieldNeighbours, &cDisInfo … … 4077 4175 #endif // H3D_IVMP 4078 4176 4177 #if !FIX_MERGE_D 4079 4178 #if MERL_VSP_COMPENSATION_C0152 4080 4179 //===== vsp 0 ===== … … 4088 4187 return; 4089 4188 #endif 4189 #endif 4090 4190 4091 4191 //left … … 4104 4204 { 4105 4205 if ( pcCULeft && !pcCULeft->isIntra( uiLeftPartIdx ) 4106 #if MERL_VSP_C0152 4206 #if MERL_VSP_C0152 && !LGE_VSP_INHERIT_D0092 4107 4207 CHECK_ADD_YET(pcCULeft, uiLeftPartIdx, 1) 4108 4208 #endif … … 4153 4253 #endif 4154 4254 #if MERL_VSP_C0152 4255 #if LGE_VSP_INHERIT_D0092 4256 if (pcCULeft->getVSPIndex(uiLeftPartIdx)==1) 4257 { 4258 iVSPIndexTrue[iCount] = 1; 4259 } 4260 #else 4155 4261 xInheritVspMode( pcCULeft, uiLeftPartIdx, bVspMvZeroDone, iCount, iVSPIndexTrue, pcMvFieldNeighbours, &cDisInfo 4262 #if QC_BVSP_CleanUP_D0191 4263 ,puhInterDirNeighbours 4264 #endif 4156 4265 #if MERL_VSP_NBDV_RefVId_Fix_D0166 4157 4266 , iVSPDirTrue 4158 4267 #endif 4159 4268 ); 4269 #endif 4160 4270 #endif 4161 4271 if ( mrgCandIdx == iCount ) … … 4182 4292 } 4183 4293 if ( pcCUAbove && !pcCUAbove->isIntra( uiAbovePartIdx ) 4184 #if MERL_VSP_C0152 4294 #if MERL_VSP_C0152 && !LGE_VSP_INHERIT_D0092 4185 4295 CHECK_ADD_YET(pcCUAbove, uiAbovePartIdx, 1) 4186 4296 #endif … … 4230 4340 #endif 4231 4341 #if MERL_VSP_C0152 4342 #if LGE_VSP_INHERIT_D0092 4343 if (pcCUAbove->getVSPIndex(uiAbovePartIdx)==1) 4344 { 4345 iVSPIndexTrue[iCount] = 1; 4346 } 4347 #else 4232 4348 xInheritVspMode( pcCUAbove, uiAbovePartIdx, bVspMvZeroDone, iCount, iVSPIndexTrue, pcMvFieldNeighbours, &cDisInfo 4349 #if QC_BVSP_CleanUP_D0191 4350 ,puhInterDirNeighbours 4351 #endif 4233 4352 #if MERL_VSP_NBDV_RefVId_Fix_D0166 4234 4353 , iVSPDirTrue 4235 4354 #endif 4236 4355 ) ; 4356 #endif 4237 4357 #endif 4238 4358 if ( mrgCandIdx == iCount ) … … 4258 4378 } 4259 4379 if ( pcCUAboveRight && !pcCUAboveRight->isIntra( uiAboveRightPartIdx ) 4260 #if MERL_VSP_C0152 4380 #if MERL_VSP_C0152 && !LGE_VSP_INHERIT_D0092 4261 4381 CHECK_ADD_YET(pcCUAboveRight, uiAboveRightPartIdx, 1) 4262 4382 #endif … … 4283 4403 #endif 4284 4404 #if MERL_VSP_C0152 4405 #if LGE_VSP_INHERIT_D0092 4406 if (pcCUAboveRight->getVSPIndex(uiAboveRightPartIdx)==1) 4407 { 4408 iVSPIndexTrue[iCount] = 1; 4409 } 4410 #else 4285 4411 xInheritVspMode( pcCUAboveRight, uiAboveRightPartIdx, bVspMvZeroDone, iCount, iVSPIndexTrue, pcMvFieldNeighbours, &cDisInfo 4412 #if QC_BVSP_CleanUP_D0191 4413 ,puhInterDirNeighbours 4414 #endif 4286 4415 #if MERL_VSP_NBDV_RefVId_Fix_D0166 4287 4416 , iVSPDirTrue 4288 4417 #endif 4289 4418 ) ; 4419 #endif 4290 4420 #endif 4291 4421 if ( mrgCandIdx == iCount ) … … 4345 4475 #endif // H3D_IVMP 4346 4476 4477 #if MERL_VSP_COMPENSATION_C0152 4478 //===== vsp 3 ===== 4479 #if LGE_VSP_INHERIT_D0092 4480 if ( !xAddVspMergeCand(3, uiDepth, abCandIsInter, iCount, puhInterDirNeighbours, pcMvFieldNeighbours, iVSPIndexTrue, mrgCandIdx, &cDisInfo) ) 4481 #else 4482 if( iCount < 4 + extraMergeCand ) 4483 if ( !xAddVspMergeCand(3, 1, bVspMvZeroDone, uiDepth, abCandIsInter, iCount, puhInterDirNeighbours, pcMvFieldNeighbours, iVSPIndexTrue, mrgCandIdx, &cDisInfo) ) 4484 #endif 4485 return; 4486 #endif 4487 4488 #if MERL_VSP_C0152 4489 #if VSP_MERGE_POS < 4 4490 #if H3D_IVMP 4491 if( iCount < 4 + extraMergeCand ) 4492 #else 4493 if( iCount < 4 ) 4494 #endif 4495 { 4496 #endif 4497 #endif 4498 4347 4499 //left bottom 4348 4500 UInt uiLeftBottomPartIdx = 0; … … 4357 4509 } 4358 4510 if ( pcCULeftBottom && !pcCULeftBottom->isIntra( uiLeftBottomPartIdx ) 4359 #if MERL_VSP_C0152 4511 #if MERL_VSP_C0152 && !LGE_VSP_INHERIT_D0092 4360 4512 CHECK_ADD_YET(pcCULeftBottom, uiLeftBottomPartIdx, 1) 4361 4513 #endif … … 4382 4534 #endif 4383 4535 #if MERL_VSP_C0152 4536 #if LGE_VSP_INHERIT_D0092 4537 if (pcCULeftBottom->getVSPIndex(uiLeftBottomPartIdx)==1) 4538 { 4539 iVSPIndexTrue[iCount] = 1; 4540 } 4541 #else 4384 4542 xInheritVspMode( pcCULeftBottom, uiLeftBottomPartIdx, bVspMvZeroDone, iCount, iVSPIndexTrue, pcMvFieldNeighbours, &cDisInfo 4543 #if QC_BVSP_CleanUP_D0191 4544 ,puhInterDirNeighbours 4545 #endif 4385 4546 #if MERL_VSP_NBDV_RefVId_Fix_D0166 4386 4547 , iVSPDirTrue … … 4388 4549 ) ; 4389 4550 #endif 4551 #endif 4390 4552 if ( mrgCandIdx == iCount ) 4391 4553 { … … 4394 4556 iCount ++; 4395 4557 } 4558 4559 #if MERL_VSP_C0152 // Is this correct here? 4560 #if VSP_MERGE_POS < 4 4561 } 4562 #endif 4563 #endif 4396 4564 4397 4565 // above left … … 4413 4581 } 4414 4582 if( pcCUAboveLeft && !pcCUAboveLeft->isIntra( uiAboveLeftPartIdx ) 4415 #if MERL_VSP_C0152 4583 #if MERL_VSP_C0152 && !LGE_VSP_INHERIT_D0092 4416 4584 CHECK_ADD_YET(pcCUAboveLeft, uiAboveLeftPartIdx, 1) 4417 4585 #endif … … 4440 4608 #endif 4441 4609 #if MERL_VSP_C0152 4610 #if LGE_VSP_INHERIT_D0092 4611 if (pcCUAboveLeft->getVSPIndex(uiAboveLeftPartIdx)==1) 4612 { 4613 iVSPIndexTrue[iCount] = 1; 4614 } 4615 #else 4442 4616 xInheritVspMode( pcCUAboveLeft, uiAboveLeftPartIdx, bVspMvZeroDone, iCount, iVSPIndexTrue, pcMvFieldNeighbours, &cDisInfo 4617 #if QC_BVSP_CleanUP_D0191 4618 ,puhInterDirNeighbours 4619 #endif 4443 4620 #if MERL_VSP_NBDV_RefVId_Fix_D0166 4444 4621 , iVSPDirTrue 4445 4622 #endif 4446 4623 ) ; 4624 #endif 4447 4625 #endif 4448 4626 if ( mrgCandIdx == iCount ) … … 4457 4635 //===== vsp 5 ===== 4458 4636 if( iCount < 4 + extraMergeCand ) 4637 #if LGE_VSP_INHERIT_D0092 4638 if ( !xAddVspMergeCand(5, uiDepth, abCandIsInter, iCount, puhInterDirNeighbours, pcMvFieldNeighbours, iVSPIndexTrue, mrgCandIdx, &cDisInfo) 4639 #if MERL_VSP_NBDV_RefVId_Fix_D0166 4640 , iVSPDirTrue 4641 #endif 4642 ) 4643 #else 4459 4644 if ( !xAddVspMergeCand(5, 1, bVspMvZeroDone, uiDepth, abCandIsInter, iCount, puhInterDirNeighbours, pcMvFieldNeighbours, iVSPIndexTrue, mrgCandIdx, &cDisInfo 4460 4645 #if MERL_VSP_NBDV_RefVId_Fix_D0166 4461 4646 , iVSPDirTrue 4462 4647 #endif 4463 ) ) 4648 ) 4649 #endif 4464 4650 return; 4465 4651 #endif … … 4651 4837 #if MERL_VSP_C0152 4652 4838 Bool bValid = true; 4839 #if LGE_VSP_INHERIT_D0092 4840 if (iVSPIndexTrue[i]==1 || iVSPIndexTrue[j]==1) // NOT_VALID 4841 #else 4653 4842 if (pcMvFieldNeighbours[i<<1].getRefIdx() < 0 || pcMvFieldNeighbours[(j<<1)+1].getRefIdx() < 0) // NOT_VALID 4843 #endif 4654 4844 bValid = false; 4655 4845 #endif 4846 4847 #if MTK_D0156 4848 if( !m_pcSlice->getSPS()->getUseVSPCompensation()) 4849 { 4850 bValid = true; 4851 } 4852 #endif 4853 4656 4854 if (abCandIsInter[i] && abCandIsInter[j]&& (puhInterDirNeighbours[i]&0x1)&&(puhInterDirNeighbours[j]&0x2) 4657 4855 #if MERL_VSP_C0152 … … 4822 5020 { 4823 5021 if( pcCorner && !pcCorner->isIntra( uiCornerPUIdx ) 4824 #if MERL_VSP_C0152 5022 #if MERL_VSP_C0152 & !QC_BVSP_CleanUP_D0191 4825 5023 && !pcCorner->getVSPIndex( uiCornerPUIdx ) 4826 5024 #endif … … 4968 5166 pcTmpCU = getPULeft(uiIdx, uiPartIdxLB, true, false); 4969 5167 if(pcTmpCU != NULL && !pcTmpCU->isIntra( uiIdx ) ) 4970 #if MERL_VSP_C0152 5168 #if MERL_VSP_C0152 & !QC_BVSP_CleanUP_D0191 4971 5169 if(! pcTmpCU->getVSPIndex(uiIdx)) 4972 5170 #endif … … 4993 5191 4994 5192 if(pcTmpCU != NULL && !pcTmpCU->isIntra( uiIdx )) 4995 #if MERL_VSP_C0152 5193 #if MERL_VSP_C0152 & !QC_BVSP_CleanUP_D0191 4996 5194 if(! pcTmpCU->getVSPIndex(uiIdx)) 4997 5195 #endif … … 5018 5216 pcTmpCU = getPUAboveRight(uiIdx, uiPartIdxRT, true, false, true); 5019 5217 if(pcTmpCU != NULL && !pcTmpCU->isIntra( uiIdx ) ) 5020 #if MERL_VSP_C0152 5218 #if MERL_VSP_C0152 & !QC_BVSP_CleanUP_D0191 5021 5219 if(! pcTmpCU->getVSPIndex(uiIdx)) 5022 5220 #endif … … 5042 5240 pcTmpCU = getPUBelowLeft(uiIdx, uiPartIdxLB, true, false); 5043 5241 if(pcTmpCU != NULL && !pcTmpCU->isIntra( uiIdx )) 5044 #if MERL_VSP_C0152 5242 #if MERL_VSP_C0152 & !QC_BVSP_CleanUP_D0191 5045 5243 if(! pcTmpCU->getVSPIndex(uiIdx)) 5046 5244 #endif … … 5069 5267 assert(uiPartIdxLT == (m_uiAbsIdxInLCU + uiPartAddr)); 5070 5268 if(pcTmpCU != NULL && !pcTmpCU->isIntra( uiIdx )) 5071 #if MERL_VSP_C0152 5269 #if MERL_VSP_C0152 & !QC_BVSP_CleanUP_D0191 5072 5270 if(! pcTmpCU->getVSPIndex(uiIdx)) 5073 5271 #endif … … 5277 5475 Int iPictureWidth = pcBaseViewDepthPicYuv->getWidth(); 5278 5476 Int iPictureHeight = pcBaseViewDepthPicYuv->getHeight(); 5279 5477 #if !QC_BVSP_CleanUP_D0191 5478 #if LGE_ROUND_OFFSET_D0135 5479 Int depthPosX = Clip3(0, iPictureWidth - iBlkWidth, iBlkX + ((mv->getHor()+2)>>2)); 5480 Int depthPosY = Clip3(0, iPictureHeight- iBlkHeight, iBlkY + ((mv->getVer()+2)>>2)); 5481 #else 5280 5482 Int depthPosX = Clip3(0, iPictureWidth - iBlkWidth, iBlkX + (mv->getHor()>>2)); 5281 5483 Int depthPosY = Clip3(0, iPictureHeight- iBlkHeight, iBlkY + (mv->getVer()>>2)); 5484 #endif 5282 5485 5283 5486 Pel *pDepthPel = pcBaseViewDepthPicYuv->getLumaAddr() + depthPosX + depthPosY * depStride; 5487 #endif 5284 5488 Pel maxDepthVal = 0; 5285 5489 5286 5490 if ( bSimpleDvpRefine ) 5287 5491 { 5492 #if LGE_ROUND_OFFSET_D0135 5493 Int depthStartPosX = Clip3(0, iPictureWidth - iBlkWidth, iBlkX + ((mv->getHor()+2)>>2)); 5494 Int depthStartPosY = Clip3(0, iPictureHeight- iBlkHeight, iBlkY + ((mv->getVer()+2)>>2)); 5495 Int depthEndPosX = Clip3(0, iPictureWidth - 1, iBlkX + iBlkWidth - 1 + ((mv->getHor()+2)>>2)); 5496 Int depthEndPosY = Clip3(0, iPictureHeight - 1, iBlkY + iBlkHeight - 1 + ((mv->getVer()+2)>>2)); 5497 #else 5288 5498 Int depthStartPosX = Clip3(0, iPictureWidth - iBlkWidth, iBlkX + (mv->getHor()>>2)); 5289 5499 Int depthStartPosY = Clip3(0, iPictureHeight- iBlkHeight, iBlkY + (mv->getVer()>>2)); 5290 5500 Int depthEndPosX = Clip3(0, iPictureWidth - 1, iBlkX + iBlkWidth - 1 + (mv->getHor()>>2)); 5291 5501 Int depthEndPosY = Clip3(0, iPictureHeight - 1, iBlkY + iBlkHeight - 1 + (mv->getVer()>>2)); 5502 #endif 5292 5503 #if !MTK_DEPTH_TO_DISP_D0138 5293 5504 Int iCenterX = (depthStartPosX + depthEndPosX) >> 1; … … 5312 5523 } 5313 5524 } 5525 #if !QC_BVSP_CleanUP_D0191 5314 5526 else 5315 5527 { … … 5324 5536 } 5325 5537 } 5538 #endif 5326 5539 5327 5540 Int iDisp = aiShiftLUT[ maxDepthVal ] << iShiftPrec; … … 5425 5638 } 5426 5639 } 5427 #if MERL_VSP_C0152 5640 #if MERL_VSP_C0152 & !QC_BVSP_CleanUP_D0191 5428 5641 else if (pcTmpCU->getVSPIndex(uiIdx) != 0) // is VSP 5429 5642 { … … 5576 5789 } 5577 5790 5791 #if MTK_D0156 5792 if( !m_pcSlice->getSPS()->getUseDVPRefine() ) 5793 { 5794 bDepthRefine = false; 5795 } 5796 #endif 5797 5578 5798 // Get Positions 5579 5799 PartSize eCUMode = getPartitionSize( uiPartAddr ); … … 5927 6147 */ 5928 6148 #if H3D_IVMP 6149 #if SEC_TWO_CANDIDATES_FOR_AMVP_D0122 5929 6150 Void TComDataCU::fillMvpCand ( UInt uiPartIdx, UInt uiPartAddr, RefPicList eRefPicList, Int iRefIdx, AMVPInfo* pInfo, Int iMVPIdx) 5930 6151 { 6152 fillMvpCandBase(uiPartIdx, uiPartAddr, eRefPicList, iRefIdx, pInfo); 6153 } 6154 #else 6155 Void TComDataCU::fillMvpCand ( UInt uiPartIdx, UInt uiPartAddr, RefPicList eRefPicList, Int iRefIdx, AMVPInfo* pInfo, Int iMVPIdx) 6156 { 6157 5931 6158 if (!m_pcSlice->getSPS()->getViewId() || !m_pcSlice->getSPS()->getMultiviewMvPredMode()) 5932 6159 { … … 6014 6241 } 6015 6242 } 6243 #endif 6016 6244 6017 6245 … … 6312 6540 } 6313 6541 6314 #if MERL_VSP_C0152 6542 #if MERL_VSP_C0152&!QC_BVSP_CleanUP_D0191 6315 6543 if(pcTmpCU != NULL && pcTmpCU->getVSPIndex(uiIdx)) 6316 6544 { … … 6428 6656 } 6429 6657 6430 #if MERL_VSP_C0152 6658 #if MERL_VSP_C0152 &!QC_BVSP_CleanUP_D0191 6431 6659 if(pcTmpCU->getVSPIndex(uiIdx)) 6432 6660 { … … 6591 6819 TComDataCU *pColCU = pColPic->getCU( uiCUAddr ); 6592 6820 iColViewIdx = pColCU->getSlice()->getViewId(); 6593 #if MERL_VSP_C0152 6821 #if MERL_VSP_C0152 & !QC_BVSP_CleanUP_D0191 6594 6822 if( pColCU->getCUMvField(eColRefPicList)->getRefIdx(uiAbsPartAddr) < 0) 6595 6823 { -
branches/HTM-6.2-dev0/source/Lib/TLibCommon/TComDataCU.h
r418 r427 282 282 Bool xAddMVPCandOrder ( AMVPInfo* pInfo, RefPicList eRefPicList, Int iRefIdx, UInt uiPartUnitIdx, MVP_DIR eDir ); 283 283 #if MERL_VSP_C0152 284 inline Bool xAddVspMergeCand ( UChar ucVspMergePos, Int vspIdx, Bool* bVspMvZeroDone, UInt uiDepth, Bool* abCandIsInter, Int& iCount, 285 UChar* puhInterDirNeighbours, TComMvField* pcMvFieldNeighbours, Int* iVSPIndexTrue, Int mrgCandIdx, DisInfo* pDisInfo 284 inline Bool xAddVspMergeCand ( 285 UChar ucVspMergePos, 286 #if !LGE_VSP_INHERIT_D0092 287 Int vspIdx, 288 Bool* bVspMvZeroDone, 289 #endif 290 UInt uiDepth, 291 Bool* abCandIsInter, 292 Int& iCount, 293 UChar* puhInterDirNeighbours, 294 TComMvField* pcMvFieldNeighbours, 295 Int* iVSPIndexTrue, 296 Int mrgCandIdx, 297 DisInfo* pDisInfo 286 298 #if MERL_VSP_NBDV_RefVId_Fix_D0166 287 299 , Int* iVspDirTrue = NULL 288 300 #endif 289 301 ); 290 302 inline Void xInheritVspMode ( TComDataCU* pcCURef, UInt uiIdx, Bool* bVspMvZeroDone, Int iCount, Int* iVSPIndexTrue, TComMvField* pcMvFieldNeighbours, DisInfo* pDInfo 303 #if QC_BVSP_CleanUP_D0191 304 ,UChar *puhInterDirNeighbours 305 #endif 291 306 #if MERL_VSP_NBDV_RefVId_Fix_D0166 292 307 , Int *iVSPDirTrue -
branches/HTM-6.2-dev0/source/Lib/TLibCommon/TComLoopFilter.cpp
r296 r427 428 428 //-- Set BS for Intra MB : BS = 4 or 3 429 429 if ( pcCUP->isIntra(uiPartP) || pcCUQ->isIntra(uiPartQ) 430 #if MERL_VSP_C0152 430 #if MERL_VSP_C0152 & !QC_BVSP_CleanUP_D0191 431 431 || pcCUP->getVSPIndex(uiPartP) || pcCUQ->getVSPIndex(uiPartQ) 432 432 #endif … … 438 438 //-- Set BS for not Intra MB : BS = 2 or 1 or 0 439 439 if ( !pcCUP->isIntra(uiPartP) && !pcCUQ->isIntra(uiPartQ) 440 #if MERL_VSP_C0152 440 #if MERL_VSP_C0152 & !QC_BVSP_CleanUP_D0191 441 441 && !pcCUP->getVSPIndex(uiPartP) && !pcCUQ->getVSPIndex(uiPartQ) 442 442 #endif … … 534 534 } // enf of "if( not Intra )" 535 535 536 #if MERL_VSP_C0152 536 #if MERL_VSP_C0152 & !QC_BVSP_CleanUP_D0191 537 537 if ( pcCUP->getVSPIndex(uiPartP) || pcCUQ->getVSPIndex(uiPartQ)) 538 538 { -
branches/HTM-6.2-dev0/source/Lib/TLibCommon/TComPrediction.cpp
r422 r427 927 927 if (vspIdx != 0) 928 928 { 929 #if !QC_BVSP_CleanUP_D0191 929 930 if (iRefIdx >= 0) 930 931 { … … 932 933 } 933 934 assert (iRefIdx < 0); // assert (iRefIdx == NOT_VALID); 935 #endif 934 936 } 935 937 else … … 1784 1786 Int dstStride = dstPic->getStride(); 1785 1787 Int depStride = pPicBaseDepth->getStride(); 1788 #if LGE_ROUND_OFFSET_D0135 1789 Int depthPosX = Clip3(0, widthLuma - sizeX, (posX/nTxtPerDepthX) + ((mv->getHor()+2)>>2)); 1790 Int depthPosY = Clip3(0, heightLuma- sizeY, (posY/nTxtPerDepthY) + ((mv->getVer()+2)>>2)); 1791 #else 1786 1792 Int depthPosX = Clip3(0, widthLuma - sizeX, (posX/nTxtPerDepthX) + (mv->getHor()>>2)); 1787 1793 Int depthPosY = Clip3(0, heightLuma- sizeY, (posY/nTxtPerDepthY) + (mv->getVer()>>2)); 1794 #endif 1788 1795 Pel *ref = refPic->getLumaAddr() + posX + posY * refStride; 1789 1796 Pel *dst = dstPic->getLumaAddr(partAddr); … … 2034 2041 nTxtPerDepthX = widthChroma / widthDepth; 2035 2042 nDepthPerTxtX = 1; 2043 #if LGE_ROUND_OFFSET_D0135 2044 depthPosX = posX / nTxtPerDepthX + ((mv->getHor()+2)>>2); //mv denotes the disparity for VSP 2045 #else 2036 2046 depthPosX = posX / nTxtPerDepthX + (mv->getHor()>>2); //mv denotes the disparity for VSP 2047 #endif 2037 2048 } 2038 2049 else … … 2040 2051 nTxtPerDepthX = 1; 2041 2052 nDepthPerTxtX = widthDepth / widthChroma; 2053 #if LGE_ROUND_OFFSET_D0135 2054 depthPosX = posX * nDepthPerTxtX + ((mv->getHor()+2)>>2); //mv denotes the disparity for VSP 2055 #else 2042 2056 depthPosX = posX * nDepthPerTxtX + (mv->getHor()>>2); //mv denotes the disparity for VSP 2057 #endif 2043 2058 } 2044 2059 depthPosX = Clip3(0, widthDepth - (sizeX<<1), depthPosX); … … 2047 2062 nTxtPerDepthY = heightChroma / heightDepth; 2048 2063 nDepthPerTxtY = 1; 2064 #if LGE_ROUND_OFFSET_D0135 2065 depthPosY = posY / nTxtPerDepthY + ((mv->getVer()+2)>>2); //mv denotes the disparity for VSP 2066 #else 2049 2067 depthPosY = posY / nTxtPerDepthY + (mv->getVer()>>2); //mv denotes the disparity for VSP 2068 #endif 2050 2069 } 2051 2070 else … … 2053 2072 nTxtPerDepthY = 1; 2054 2073 nDepthPerTxtY = heightDepth / heightChroma; 2074 #if LGE_ROUND_OFFSET_D0135 2075 depthPosY = posY * nDepthPerTxtY + ((mv->getVer()+2)>>2); //mv denotes the disparity for VSP 2076 #else 2055 2077 depthPosY = posY * nDepthPerTxtY + (mv->getVer()>>2); //mv denotes the disparity for VSP 2078 #endif 2056 2079 } 2057 2080 depthPosY = Clip3(0, heightDepth - (sizeY<<1), depthPosY); … … 2764 2787 iCUPelX = pcCU->getCUPelX() + g_auiRasterToPelX[g_auiZscanToRaster[pcCU->getZorderIdxInCU()]]; 2765 2788 iCUPelY = pcCU->getCUPelY() + g_auiRasterToPelY[g_auiZscanToRaster[pcCU->getZorderIdxInCU()]]; 2789 #if LGE_ROUND_OFFSET_D0135 2790 iRefX = iCUPelX + ((pMv->getHor()+2) >> 2); 2791 iRefY = iCUPelY + ((pMv->getVer()+2) >> 2); 2792 #else 2766 2793 iRefX = iCUPelX + (pMv->getHor() >> 2); 2767 2794 iRefY = iCUPelY + (pMv->getVer() >> 2); 2795 #endif 2768 2796 uiWidth = pcCU->getWidth(0); 2769 2797 uiHeight = pcCU->getHeight(0); … … 2777 2805 if(pcCU->getPUAbove(uiTmpPartIdx, pcCU->getZorderIdxInCU()) && iCUPelY > 0 && iRefY > 0) 2778 2806 { 2807 #if LGE_ROUND_OFFSET_D0135 2808 iRefOffset = ( (pMv->getHor()+2) >> 2 ) + ( (pMv->getVer()+2) >> 2 ) * iRefStride - iRefStride; 2809 #else 2779 2810 iRefOffset = ( pMv->getHor() >> 2 ) + ( pMv->getVer() >> 2 ) * iRefStride - iRefStride; 2811 #endif 2780 2812 pRef = pRefPic->getLumaAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) + iRefOffset; 2781 2813 pRec = pRecPic->getLumaAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) - iRecStride; … … 2794 2826 if(pcCU->getPULeft(uiTmpPartIdx, pcCU->getZorderIdxInCU()) && iCUPelX > 0 && iRefX > 0) 2795 2827 { 2828 #if LGE_ROUND_OFFSET_D0135 2829 iRefOffset = ( (pMv->getHor()+2) >> 2 ) + ( (pMv->getVer()+2) >> 2 ) * iRefStride - 1; 2830 #else 2796 2831 iRefOffset = ( pMv->getHor() >> 2 ) + ( pMv->getVer() >> 2 ) * iRefStride - 1; 2832 #endif 2797 2833 pRef = pRefPic->getLumaAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) + iRefOffset; 2798 2834 pRec = pRecPic->getLumaAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) - 1; … … 2912 2948 iCUPelX = pcCU->getCUPelX() + g_auiRasterToPelX[g_auiZscanToRaster[pcCU->getZorderIdxInCU()]]; 2913 2949 iCUPelY = pcCU->getCUPelY() + g_auiRasterToPelY[g_auiZscanToRaster[pcCU->getZorderIdxInCU()]]; 2950 #if LGE_ROUND_OFFSET_D0135 2951 iRefX = iCUPelX + ((pMv->getHor()+2) >> 2); 2952 iRefY = iCUPelY + ((pMv->getVer()+2) >> 2); 2953 #else 2914 2954 iRefX = iCUPelX + (pMv->getHor() >> 2); 2915 2955 iRefY = iCUPelY + (pMv->getVer() >> 2); 2956 #endif 2916 2957 uiWidth = pcCU->getWidth(0) >> 1; 2917 2958 uiHeight = pcCU->getHeight(0) >> 1; … … 2925 2966 if(pcCU->getPUAbove(uiTmpPartIdx, pcCU->getZorderIdxInCU()) && iCUPelY > 0 && iRefY > 0) 2926 2967 { 2968 #if LGE_ROUND_OFFSET_D0135 2969 iRefOffset = ( (pMv->getHor()+4) >> 3 ) + ( (pMv->getVer()+4) >> 3 ) * iRefStride - iRefStride; 2970 #else 2927 2971 iRefOffset = ( pMv->getHor() >> 3 ) + ( pMv->getVer() >> 3 ) * iRefStride - iRefStride; 2972 #endif 2928 2973 if (iChromaId == 0) // Cb 2929 2974 { … … 2950 2995 if(pcCU->getPULeft(uiTmpPartIdx, pcCU->getZorderIdxInCU()) && iCUPelX > 0 && iRefX > 0) 2951 2996 { 2997 #if LGE_ROUND_OFFSET_D0135 2998 iRefOffset = ( (pMv->getHor()+4) >> 3 ) + ( (pMv->getVer()+4) >> 3 ) * iRefStride - 1; 2999 #else 2952 3000 iRefOffset = ( pMv->getHor() >> 3 ) + ( pMv->getVer() >> 3 ) * iRefStride - 1; 3001 #endif 2953 3002 if (iChromaId == 0) // Cb 2954 3003 { -
branches/HTM-6.2-dev0/source/Lib/TLibCommon/TComSampleAdaptiveOffset.cpp
r296 r427 62 62 TComSampleAdaptiveOffset::TComSampleAdaptiveOffset() 63 63 { 64 #if !LGE_SAO_MIGRATION_D0091 64 65 m_pcPic = NULL; 66 #endif 65 67 m_iOffsetBo = NULL; 66 68 m_pClipTable = NULL; … … 71 73 m_iUpBufft = NULL; 72 74 ipSwap = NULL; 75 #if !LGE_SAO_MIGRATION_D0091 73 76 m_pcYuvTmp = NULL; 77 #endif 74 78 75 79 m_pTmpU1 = NULL; … … 85 89 } 86 90 91 #if !LGE_SAO_MIGRATION_D0091 87 92 const Int TComSampleAdaptiveOffset::m_aiNumPartsInRow[5] = 88 93 { … … 102 107 256 //level 4 103 108 }; 109 #endif 104 110 105 111 const Int TComSampleAdaptiveOffset::m_aiNumCulPartsLevel[5] = … … 124 130 0 125 131 }; 126 132 #if !LGE_SAO_MIGRATION_D0091 127 133 const UInt TComSampleAdaptiveOffset::m_iWeightSao[MAX_NUM_SAO_TYPE] = 128 134 { … … 146 152 6 147 153 }; 154 #endif 148 155 149 156 Int TComSampleAdaptiveOffset::m_iNumClass[MAX_NUM_SAO_TYPE] = … … 187 194 return idx; 188 195 } 196 #if !LGE_SAO_MIGRATION_D0091 189 197 /** convert quadtree Idx to Level, Row, and Col 190 198 * \param idx, *level, *row, *col … … 223 231 } 224 232 } 233 #endif 225 234 /** create SampleAdaptiveOffset memory. 226 235 * \param … … 317 326 } 318 327 319 328 #if LGE_SAO_MIGRATION_D0091 329 if (m_iUpBuff1) 330 { 331 m_iUpBuff1--; 332 delete [] m_iUpBuff1; m_iUpBuff1 = NULL; 333 } 334 if (m_iUpBuff2) 335 { 336 m_iUpBuff2--; 337 delete [] m_iUpBuff2; m_iUpBuff2 = NULL; 338 } 339 if (m_iUpBufft) 340 { 341 m_iUpBufft--; 342 delete [] m_iUpBufft; m_iUpBufft = NULL; 343 } 344 #else 320 345 m_iUpBuff1--; 321 346 m_iUpBuff2--; … … 334 359 delete [] m_iUpBufft; m_iUpBufft = NULL; 335 360 } 361 #endif 336 362 if (m_pTmpL1) 337 363 { … … 368 394 initSAOParam(pcSaoParam, 0, 0, 0, -1, 0, m_iNumCuInWidth-1, 0, m_iNumCuInHeight-1,1); 369 395 initSAOParam(pcSaoParam, 0, 0, 0, -1, 0, m_iNumCuInWidth-1, 0, m_iNumCuInHeight-1,2); 396 #if !LGE_SAO_MIGRATION_D0091 370 397 for(Int j=0;j<MAX_NUM_SAO_TYPE;j++) 371 398 { 372 399 pcSaoParam->iNumClass[j] = m_iNumClass[j]; 373 400 } 401 #endif 374 402 pcSaoParam->numCuInWidth = m_iNumCuInWidth; 375 403 pcSaoParam->numCuInHeight = m_iNumCuInHeight; … … 405 433 pSaoPart->iLength = 0; 406 434 435 #if LGE_SAO_MIGRATION_D0091 436 pSaoPart->subTypeIdx = 0; 437 #else 407 438 pSaoPart->bandPosition = 0; 439 #endif 408 440 409 441 for (j=0;j<MAX_NUM_SAO_OFFSETS;j++) … … 514 546 for(Int c=0; c<iNumComponet; c++) 515 547 { 548 #if LGE_SAO_MIGRATION_D0091 549 if (c<2) 550 { 516 551 pcSaoParam->bSaoFlag[c] = 0; 552 } 553 #else 554 pcSaoParam->bSaoFlag[c] = 0; 555 #endif 517 556 for(Int i=0; i< m_aiNumCulPartsLevel[m_uiMaxSplitLevel]; i++) 518 557 { … … 524 563 pcSaoParam->psSaoPart[c][i].iMinDist = MAX_INT; 525 564 pcSaoParam->psSaoPart[c][i].iMinRate = MAX_INT; 565 #if LGE_SAO_MIGRATION_D0091 566 pcSaoParam->psSaoPart[c][i].subTypeIdx = 0; 567 #else 526 568 pcSaoParam->psSaoPart[c][i].bandPosition = 0; 569 #endif 527 570 for (Int j=0;j<MAX_NUM_SAO_OFFSETS;j++) 528 571 { … … 557 600 m_pcPic = pcPic; 558 601 m_uiNumSlicesInPic = numSlicesInPic; 602 #if LGE_SAO_MIGRATION_D0091 603 m_iSGDepth = 0; 604 #else 559 605 m_iSGDepth = pcPic->getSliceGranularityForNDBFilter(); 606 #endif 560 607 m_bUseNIF = ( pcPic->getIndependentSliceBoundaryForNDBFilter() || pcPic->getIndependentTileBoundaryForNDBFilter() ); 561 608 if(m_bUseNIF) … … 958 1005 uiEdgeType = iSignDown + m_iUpBuff1[x] + 2; 959 1006 m_iUpBuff1[x]= -iSignDown; 960 961 1007 pRec[x] = m_pClipTable[pRec[x] + m_iOffsetEo[uiEdgeType]]; 962 1008 } … … 1065 1111 Void TComSampleAdaptiveOffset::SAOProcess(TComPic* pcPic, SAOParam* pcSaoParam) 1066 1112 { 1113 #if LGE_SAO_MIGRATION_D0091 1114 if (pcSaoParam->bSaoFlag[0] || pcSaoParam->bSaoFlag[1]) 1115 #else 1067 1116 if (pcSaoParam->bSaoFlag[0]) 1117 #endif 1068 1118 { 1069 1119 #if FULL_NBIT … … 1077 1127 m_pcPic->getPicYuvRec()->copyToPic(m_pcYuvTmp); 1078 1128 } 1079 1129 #if LGE_SAO_MIGRATION_D0091 1130 if (m_saoLcuBasedOptimization) 1131 #else 1080 1132 if (m_saoInterleavingFlag) 1133 #endif 1081 1134 { 1082 1135 pcSaoParam->oneUnitFlag[0] = 0; … … 1085 1138 } 1086 1139 Int iY = 0; 1140 #if LGE_SAO_MIGRATION_D0091 1141 if (pcSaoParam->bSaoFlag[0]) 1142 { 1143 processSaoUnitAll( pcSaoParam->saoLcuParam[iY], pcSaoParam->oneUnitFlag[iY], iY); 1144 } 1145 if(pcSaoParam->bSaoFlag[1]) 1146 { 1147 processSaoUnitAll( pcSaoParam->saoLcuParam[1], pcSaoParam->oneUnitFlag[1], 1);//Cb 1148 processSaoUnitAll( pcSaoParam->saoLcuParam[2], pcSaoParam->oneUnitFlag[2], 2);//Cr 1149 } 1150 #else 1087 1151 processSaoUnitAll( pcSaoParam->saoLcuParam[iY], pcSaoParam->oneUnitFlag[iY], iY); 1088 1152 … … 1097 1161 processSaoUnitAll( pcSaoParam->saoLcuParam[iCr], pcSaoParam->oneUnitFlag[iCr], iCr); 1098 1162 } 1099 1100 1163 #endif 1101 1164 m_pcPic = NULL; 1102 1165 } … … 1154 1217 Int typeIdx; 1155 1218 1219 #if LGE_SAO_MIGRATION_D0091 1220 Int offset[LUMA_GROUP_NUM+1]; 1221 #else 1156 1222 static Int offset[LUMA_GROUP_NUM+1]; 1223 #endif 1157 1224 Int idxX; 1158 1225 Int idxY; … … 1164 1231 Int isChroma = (yCbCr == 0) ? 0:1; 1165 1232 Bool mergeLeftFlag; 1166 1167 1233 #if LGE_SAO_MIGRATION_D0091 1234 offset[0] = 0; 1235 #endif 1168 1236 for (idxY = 0; idxY< frameHeightInCU; idxY++) 1169 1237 { … … 1201 1269 { 1202 1270 addr = idxY * frameWidthInCU + idxX; 1203 1204 1271 if (oneUnitFlag) 1205 1272 { … … 1225 1292 for (i=0; i<saoLcuParam[addr].length; i++) 1226 1293 { 1294 #if LGE_SAO_MIGRATION_D0091 1295 offset[ (saoLcuParam[addr].subTypeIdx +i)%SAO_MAX_BO_CLASSES +1] = saoLcuParam[addr].offset[i] << m_uiSaoBitIncrease; 1296 #else 1227 1297 offset[ (saoLcuParam[addr].bandPosition +i)%SAO_MAX_BO_CLASSES +1] = saoLcuParam[addr].offset[i] << m_uiSaoBitIncrease; 1298 #endif 1228 1299 } 1229 1300 … … 1304 1375 saoLcuParam[i].offset[j] = 0; 1305 1376 } 1377 #if LGE_SAO_MIGRATION_D0091 1378 saoLcuParam[i].subTypeIdx = 0; 1379 #else 1306 1380 saoLcuParam[i].bandPosition = 0; 1381 #endif 1307 1382 } 1308 1383 } … … 1353 1428 saoLcuParam[addr].partIdxTmp = (Int)partIdx; 1354 1429 saoLcuParam[addr].typeIdx = saoQTPart[partIdx].iBestType; 1430 #if LGE_SAO_MIGRATION_D0091 1431 saoLcuParam[addr].subTypeIdx = saoQTPart[partIdx].subTypeIdx; 1432 #else 1355 1433 saoLcuParam[addr].bandPosition = saoQTPart[partIdx].bandPosition; 1434 #endif 1356 1435 if (saoLcuParam[addr].typeIdx!=-1) 1357 1436 { … … 1365 1444 { 1366 1445 saoLcuParam[addr].length = 0; 1446 #if LGE_SAO_MIGRATION_D0091 1447 saoLcuParam[addr].subTypeIdx = saoQTPart[partIdx].subTypeIdx; 1448 #else 1367 1449 saoLcuParam[addr].bandPosition = saoQTPart[partIdx].bandPosition; 1450 #endif 1368 1451 for (j=0;j<MAX_NUM_SAO_OFFSETS;j++) 1369 1452 { … … 1375 1458 } 1376 1459 1377 1378 1460 #if LGE_SAO_MIGRATION_D0091 1461 Void TComSampleAdaptiveOffset::resetSaoUnit(SaoLcuParam* saoUnit) 1462 { 1463 saoUnit->partIdx = 0; 1464 saoUnit->partIdxTmp = 0; 1465 saoUnit->mergeLeftFlag = 0; 1466 saoUnit->mergeUpFlag = 0; 1467 saoUnit->typeIdx = -1; 1468 saoUnit->length = 0; 1469 saoUnit->subTypeIdx = 0; 1470 1471 for (Int i=0;i<4;i++) 1472 { 1473 saoUnit->offset[i] = 0; 1474 } 1475 } 1476 1477 Void TComSampleAdaptiveOffset::copySaoUnit(SaoLcuParam* saoUnitDst, SaoLcuParam* saoUnitSrc ) 1478 { 1479 saoUnitDst->mergeLeftFlag = saoUnitSrc->mergeLeftFlag; 1480 saoUnitDst->mergeUpFlag = saoUnitSrc->mergeUpFlag; 1481 saoUnitDst->typeIdx = saoUnitSrc->typeIdx; 1482 saoUnitDst->length = saoUnitSrc->length; 1483 1484 saoUnitDst->subTypeIdx = saoUnitSrc->subTypeIdx; 1485 for (Int i=0;i<4;i++) 1486 { 1487 saoUnitDst->offset[i] = saoUnitSrc->offset[i]; 1488 } 1489 } 1490 1491 /** PCM LF disable process. 1492 * \param pcPic picture (TComPic) pointer 1493 * \returns Void 1494 * 1495 * \note Replace filtered sample values of PCM mode blocks with the transmitted and reconstructed ones. 1496 */ 1497 Void TComSampleAdaptiveOffset::PCMLFDisableProcess (TComPic* pcPic) 1498 { 1499 xPCMRestoration(pcPic); 1500 } 1501 1502 /** Picture-level PCM restoration. 1503 * \param pcPic picture (TComPic) pointer 1504 * \returns Void 1505 */ 1506 Void TComSampleAdaptiveOffset::xPCMRestoration(TComPic* pcPic) 1507 { 1508 Bool bPCMFilter = (pcPic->getSlice(0)->getSPS()->getUsePCM() && pcPic->getSlice(0)->getSPS()->getPCMFilterDisableFlag())? true : false; 1509 #if LOSSLESS_CODING 1510 if(bPCMFilter || pcPic->getSlice(0)->getSPS()->getUseLossless()) 1511 #else 1512 if(bPCMFilter) 1513 #endif 1514 { 1515 for( UInt uiCUAddr = 0; uiCUAddr < pcPic->getNumCUsInFrame() ; uiCUAddr++ ) 1516 { 1517 TComDataCU* pcCU = pcPic->getCU(uiCUAddr); 1518 xPCMCURestoration(pcCU, 0, 0); 1519 } 1520 } 1521 } 1522 1523 /** PCM CU restoration. 1524 * \param pcCU pointer to current CU 1525 * \param uiAbsPartIdx part index 1526 * \param uiDepth CU depth 1527 * \returns Void 1528 */ 1529 Void TComSampleAdaptiveOffset::xPCMCURestoration ( TComDataCU* pcCU, UInt uiAbsZorderIdx, UInt uiDepth ) 1530 { 1531 TComPic* pcPic = pcCU->getPic(); 1532 UInt uiCurNumParts = pcPic->getNumPartInCU() >> (uiDepth<<1); 1533 UInt uiQNumParts = uiCurNumParts>>2; 1534 1535 // go to sub-CU 1536 if( pcCU->getDepth(uiAbsZorderIdx) > uiDepth ) 1537 { 1538 for ( UInt uiPartIdx = 0; uiPartIdx < 4; uiPartIdx++, uiAbsZorderIdx+=uiQNumParts ) 1539 { 1540 UInt uiLPelX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsZorderIdx] ]; 1541 UInt uiTPelY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsZorderIdx] ]; 1542 if( ( uiLPelX < pcCU->getSlice()->getSPS()->getPicWidthInLumaSamples() ) && ( uiTPelY < pcCU->getSlice()->getSPS()->getPicHeightInLumaSamples() ) ) 1543 xPCMCURestoration( pcCU, uiAbsZorderIdx, uiDepth+1 ); 1544 } 1545 return; 1546 } 1547 1548 // restore PCM samples 1549 if ((pcCU->getIPCMFlag(uiAbsZorderIdx)&& pcPic->getSlice(0)->getSPS()->getPCMFilterDisableFlag()) || pcCU->isLosslessCoded( uiAbsZorderIdx)) 1550 { 1551 xPCMSampleRestoration (pcCU, uiAbsZorderIdx, uiDepth, TEXT_LUMA ); 1552 xPCMSampleRestoration (pcCU, uiAbsZorderIdx, uiDepth, TEXT_CHROMA_U); 1553 xPCMSampleRestoration (pcCU, uiAbsZorderIdx, uiDepth, TEXT_CHROMA_V); 1554 } 1555 } 1556 1557 /** PCM sample restoration. 1558 * \param pcCU pointer to current CU 1559 * \param uiAbsPartIdx part index 1560 * \param uiDepth CU depth 1561 * \param ttText texture component type 1562 * \returns Void 1563 */ 1564 Void TComSampleAdaptiveOffset::xPCMSampleRestoration (TComDataCU* pcCU, UInt uiAbsZorderIdx, UInt uiDepth, TextType ttText) 1565 { 1566 TComPicYuv* pcPicYuvRec = pcCU->getPic()->getPicYuvRec(); 1567 Pel* piSrc; 1568 Pel* piPcm; 1569 UInt uiStride; 1570 UInt uiWidth; 1571 UInt uiHeight; 1572 UInt uiPcmLeftShiftBit; 1573 UInt uiX, uiY; 1574 UInt uiMinCoeffSize = pcCU->getPic()->getMinCUWidth()*pcCU->getPic()->getMinCUHeight(); 1575 UInt uiLumaOffset = uiMinCoeffSize*uiAbsZorderIdx; 1576 UInt uiChromaOffset = uiLumaOffset>>2; 1577 1578 if( ttText == TEXT_LUMA ) 1579 { 1580 piSrc = pcPicYuvRec->getLumaAddr( pcCU->getAddr(), uiAbsZorderIdx); 1581 piPcm = pcCU->getPCMSampleY() + uiLumaOffset; 1582 uiStride = pcPicYuvRec->getStride(); 1583 uiWidth = (g_uiMaxCUWidth >> uiDepth); 1584 uiHeight = (g_uiMaxCUHeight >> uiDepth); 1585 if ( pcCU->isLosslessCoded(uiAbsZorderIdx) ) 1586 { 1587 uiPcmLeftShiftBit = 0; 1588 } 1589 else 1590 { 1591 uiPcmLeftShiftBit = g_uiBitDepth + g_uiBitIncrement - pcCU->getSlice()->getSPS()->getPCMBitDepthLuma(); 1592 } 1593 } 1594 else 1595 { 1596 if( ttText == TEXT_CHROMA_U ) 1597 { 1598 piSrc = pcPicYuvRec->getCbAddr( pcCU->getAddr(), uiAbsZorderIdx ); 1599 piPcm = pcCU->getPCMSampleCb() + uiChromaOffset; 1600 } 1601 else 1602 { 1603 piSrc = pcPicYuvRec->getCrAddr( pcCU->getAddr(), uiAbsZorderIdx ); 1604 piPcm = pcCU->getPCMSampleCr() + uiChromaOffset; 1605 } 1606 1607 uiStride = pcPicYuvRec->getCStride(); 1608 uiWidth = ((g_uiMaxCUWidth >> uiDepth)/2); 1609 uiHeight = ((g_uiMaxCUWidth >> uiDepth)/2); 1610 if ( pcCU->isLosslessCoded(uiAbsZorderIdx) ) 1611 { 1612 uiPcmLeftShiftBit = 0; 1613 } 1614 else 1615 { 1616 uiPcmLeftShiftBit = g_uiBitDepth + g_uiBitIncrement - pcCU->getSlice()->getSPS()->getPCMBitDepthChroma(); 1617 } 1618 } 1619 1620 for( uiY = 0; uiY < uiHeight; uiY++ ) 1621 { 1622 for( uiX = 0; uiX < uiWidth; uiX++ ) 1623 { 1624 piSrc[uiX] = (piPcm[uiX] << uiPcmLeftShiftBit); 1625 } 1626 piPcm += uiWidth; 1627 piSrc += uiStride; 1628 } 1629 } 1630 #endif 1379 1631 //! \} -
branches/HTM-6.2-dev0/source/Lib/TLibCommon/TComSampleAdaptiveOffset.h
r296 r427 65 65 66 66 static UInt m_uiMaxDepth; 67 #if !LGE_SAO_MIGRATION_D0091 67 68 static const Int m_aiNumPartsInRow[5]; 68 69 static const Int m_aiNumPartsLevel[5]; 70 #endif 69 71 static const Int m_aiNumCulPartsLevel[5]; 70 72 static const UInt m_auiEoTable[9]; 73 #if !LGE_SAO_MIGRATION_D0091 71 74 static const UInt m_auiEoTable2D[9]; 72 75 static const UInt m_iWeightSao[MAX_NUM_SAO_TYPE]; 76 #endif 73 77 Int *m_iOffsetBo; 74 78 Int m_iOffsetEo[LUMA_GROUP_NUM]; … … 107 111 Int* m_iLcuPartIdx; 108 112 Int m_maxNumOffsetsPerPic; 113 #if LGE_SAO_MIGRATION_D0091 114 Bool m_saoLcuBoundary; 115 Bool m_saoLcuBasedOptimization; 116 117 Void xPCMRestoration (TComPic* pcPic); 118 Void xPCMCURestoration (TComDataCU* pcCU, UInt uiAbsZorderIdx, UInt uiDepth); 119 Void xPCMSampleRestoration (TComDataCU* pcCU, UInt uiAbsZorderIdx, UInt uiDepth, TextType ttText); 120 #else 109 121 Bool m_saoInterleavingFlag; 122 #endif 110 123 public: 111 124 TComSampleAdaptiveOffset (); … … 116 129 117 130 Int convertLevelRowCol2Idx(int level, int row, int col); 131 #if !LGE_SAO_MIGRATION_D0091 118 132 void convertIdx2LevelRowCol(int idx, int *level, int *row, int *col); 133 #endif 119 134 120 135 Void initSAOParam (SAOParam *pcSaoParam, Int iPartLevel, Int iPartRow, Int iPartCol, Int iParentPartIdx, Int StartCUX, Int EndCUX, Int StartCUY, Int EndCUY, Int iYCbCr); 121 136 Void allocSaoParam (SAOParam* pcSaoParam); 122 137 Void resetSAOParam (SAOParam *pcSaoParam); 138 #if LGE_SAO_MIGRATION_D0091 139 static Void freeSaoParam (SAOParam *pcSaoParam); 140 #else 123 141 Void freeSaoParam (SAOParam *pcSaoParam); 142 #endif 143 124 144 125 145 Void SAOProcess(TComPic* pcPic, SAOParam* pcSaoParam); 126 146 Void processSaoCu(Int iAddr, Int iSaoType, Int iYCbCr); 147 #if !LGE_SAO_MIGRATION_D0091 127 148 Void processSaoOnePart(SAOQTPart *psQTPart, UInt uiPartIdx, Int iYCbCr); 128 149 Void processSaoQuadTree(SAOQTPart *psQTPart, UInt uiPartIdx, Int iYCbCr); 150 #endif 129 151 Pel* getPicYuvAddr(TComPicYuv* pcPicYuv, Int iYCbCr,Int iAddr = 0); 130 152 … … 138 160 Void convertOnePart2SaoUnit(SAOParam *saoParam, UInt partIdx, Int yCbCr); 139 161 Void processSaoUnitAll(SaoLcuParam* saoLcuParam, Bool oneUnitFlag, Int yCbCr); 162 #if LGE_SAO_MIGRATION_D0091 163 Void setSaoLcuBoundary (Bool bVal) {m_saoLcuBoundary = bVal;} 164 Bool getSaoLcuBoundary () {return m_saoLcuBoundary;} 165 Void setSaoLcuBasedOptimization (Bool bVal) {m_saoLcuBasedOptimization = bVal;} 166 Bool getSaoLcuBasedOptimization () {return m_saoLcuBasedOptimization;} 167 Void resetSaoUnit(SaoLcuParam* saoUnit); 168 Void copySaoUnit(SaoLcuParam* saoUnitDst, SaoLcuParam* saoUnitSrc ); 169 Void PCMLFDisableProcess ( TComPic* pcPic); ///< interface function for ALF process 170 #else 140 171 Void setSaoInterleavingFlag (Bool bVal) {m_saoInterleavingFlag = bVal;} 141 172 Bool getSaoInterleavingFlag () {return m_saoInterleavingFlag;} 173 #endif 142 174 }; 143 175 -
branches/HTM-6.2-dev0/source/Lib/TLibCommon/TComSlice.cpp
r412 r427 113 113 #if LGE_ILLUCOMP_B0045 114 114 , m_bApplyIC ( false ) 115 #if SHARP_ILLUCOMP_PARSE_D0060 116 , m_icSkipParseFlag ( false ) 117 #endif 115 118 #endif 116 119 #if INTER_VIEW_VECTOR_SCALING_C0115 … … 822 825 823 826 m_saoEnabledFlag = pSrc->m_saoEnabledFlag; 827 #if LGE_SAO_MIGRATION_D0091 828 m_saoEnabledFlagChroma = pSrc->m_saoEnabledFlagChroma; 829 #else 824 830 m_saoInterleavingFlag = pSrc->m_saoInterleavingFlag; 825 831 m_saoEnabledFlagCb = pSrc->m_saoEnabledFlagCb; 826 832 m_saoEnabledFlagCr = pSrc->m_saoEnabledFlagCr; 833 #endif 827 834 #if CABAC_INIT_FLAG 828 835 m_cabacInitFlag = pSrc->m_cabacInitFlag; … … 831 838 832 839 m_bLMvdL1Zero = pSrc->m_bLMvdL1Zero; 840 #if SHARP_ILLUCOMP_PARSE_D0060 841 m_bApplyIC = pSrc->m_bApplyIC; 842 m_icSkipParseFlag = pSrc->m_icSkipParseFlag; 843 #endif 833 844 } 834 845 … … 2109 2120 m_scalingList = src.m_scalingList; 2110 2121 m_scalingListEnabled = src.m_scalingListEnabled; 2122 #if !LGE_SAO_MIGRATION_D0091 2111 2123 m_saoInterleavingFlag = src.m_saoInterleavingFlag; 2124 #endif 2112 2125 2113 2126 return *this; -
branches/HTM-6.2-dev0/source/Lib/TLibCommon/TComSlice.h
r412 r427 180 180 Bool m_bIVScalingFlag; 181 181 #endif 182 183 #if MTK_D0156 184 #if MERL_VSP_COMPENSATION_C0152 185 Bool m_abUseVSPCompensation[ MAX_TLAYER ]; 186 #endif 187 Bool m_abUseDVPRefine[ MAX_TLAYER ]; 188 #endif 189 182 190 public: 183 191 TComVPS(); … … 245 253 246 254 #endif 255 256 #if MTK_D0156 257 #if MERL_VSP_COMPENSATION_C0152 258 Bool getUseVSPCompensation( UInt tLayer ){ return m_abUseVSPCompensation[ tLayer ];} 259 Void setUseVSPCompensation( Bool bValue, UInt tLayer ){ m_abUseVSPCompensation[ tLayer ] = bValue;} 260 #endif 261 Bool getUseDVPRefine( UInt tLayer ){ return m_abUseDVPRefine[ tLayer ];} 262 Void setUseDVPRefine( Bool bValue, UInt tLayer ){ m_abUseDVPRefine[ tLayer ] = bValue;} 263 #endif 247 264 }; 248 265 … … 403 420 #if H3D_IVRP & !QC_ARP_D0177 404 421 TComResidualGenerator* m_pcResidualGenerator; 422 #endif 423 424 #if MTK_D0156 425 #if MERL_VSP_COMPENSATION_C0152 426 Bool m_bUseVSPCompensation; 427 #endif 428 Bool m_bUseDVPRefine; 405 429 #endif 406 430 … … 681 705 TComResidualGenerator* getResidualGenerator() { return m_pcResidualGenerator; } 682 706 #endif 707 708 #if MTK_D0156 709 710 #if MERL_VSP_COMPENSATION_C0152 711 Bool getUseVSPCompensation( ){ return m_bUseVSPCompensation;} 712 Void setUseVSPCompensation( Bool bValue ){ m_bUseVSPCompensation = bValue;} 713 #endif 714 715 Bool getUseDVPRefine( ){ return m_bUseDVPRefine;} 716 Void setUseDVPRefine( Bool bValue ){ m_bUseDVPRefine = bValue;} 717 718 #endif 683 719 }; 684 720 … … 940 976 Bool getScalingListEnabled () { return m_scalingListEnabled; } //!< get ScalingList enabled/disabled in APS 941 977 TComScalingList* getScalingList () { return m_scalingList; } //!< get ScalingList class pointer in APS 978 #if !LGE_SAO_MIGRATION_D0091 942 979 Bool getSaoInterleavingFlag() {return m_saoInterleavingFlag;} //!< get SAO interleaving flag in APS 943 980 Void setSaoInterleavingFlag(Bool bVal) {m_saoInterleavingFlag = bVal;} //!< set SAO interleaving flag in APS 981 #endif 944 982 945 983 private: … … 955 993 Bool m_scalingListEnabled; //!< ScalingList enabled/disabled in APS (true for enabled) 956 994 TComScalingList* m_scalingList; //!< ScalingList class pointer 995 #if !LGE_SAO_MIGRATION_D0091 957 996 Bool m_saoInterleavingFlag; //!< SAO interleaving flag 997 #endif 958 998 959 999 public: … … 987 1027 bool m_alfEnabledFlag; 988 1028 bool m_saoEnabledFlag; 1029 #if LGE_SAO_MIGRATION_D0091 1030 bool m_saoEnabledFlagChroma; ///< SAO Cb&Cr enabled flag 1031 #else 989 1032 bool m_saoInterleavingFlag; ///< SAO interleaving flag 990 1033 bool m_saoEnabledFlagCb; ///< SAO Cb enabled flag 991 1034 bool m_saoEnabledFlagCr; ///< SAO Cr enabled flag 1035 #endif 992 1036 Int m_iPPSId; ///< picture parameter set ID 993 1037 Bool m_PicOutputFlag; ///< pic_output_flag … … 1118 1162 #if LGE_ILLUCOMP_B0045 1119 1163 Bool m_bApplyIC; 1164 #if SHARP_ILLUCOMP_PARSE_D0060 1165 Bool m_icSkipParseFlag; 1166 #endif 1120 1167 #endif 1121 1168 #if MERL_VSP_NBDV_RefVId_Fix_D0166 … … 1181 1228 Void setSaoEnabledFlag(Bool s) {m_saoEnabledFlag =s; } 1182 1229 Bool getSaoEnabledFlag() { return m_saoEnabledFlag; } 1230 #if LGE_SAO_MIGRATION_D0091 1231 Void setSaoEnabledFlagChroma(Bool s) {m_saoEnabledFlagChroma =s; } //!< set SAO Cb&Cr enabled flag 1232 Bool getSaoEnabledFlagChroma() { return m_saoEnabledFlagChroma; } //!< get SAO Cb&Cr enabled flag 1233 #else 1183 1234 Void setSaoInterleavingFlag(Bool s) {m_saoInterleavingFlag =s; } //!< set SAO interleaving flag 1184 1235 Bool getSaoInterleavingFlag() { return m_saoInterleavingFlag; } //!< get SAO interleaving flag … … 1187 1238 Void setSaoEnabledFlagCr(Bool s) {m_saoEnabledFlagCr =s; } //!< set SAO Cr enabled flag 1188 1239 Bool getSaoEnabledFlagCr() { return m_saoEnabledFlagCr; } //!< get SAO Cr enabled flag 1240 #endif 1189 1241 Void setRPS ( TComReferencePictureSet *pcRPS ) { m_pcRPS = pcRPS; } 1190 1242 TComReferencePictureSet* getRPS () { return m_pcRPS; } … … 1429 1481 Bool getApplyIC () { return m_bApplyIC; } 1430 1482 Void xSetApplyIC (); 1483 #if SHARP_ILLUCOMP_PARSE_D0060 1484 Void setIcSkipParseFlag( Bool b ) { m_icSkipParseFlag = b; } 1485 Bool getIcSkipParseFlag() { return m_icSkipParseFlag; } 1486 #endif 1431 1487 #endif 1432 1488 #if QC_TMVP_MRG_REFIDX_C0047 -
branches/HTM-6.2-dev0/source/Lib/TLibCommon/TypeDef.h
r421 r427 84 84 // QC_C0051_FIXED_BY_MTK 1 // Bug fix for C0051 implementation 85 85 // QC_AMVP_MRG_UNIFY_IVCAN_C0051 1 86 #define SEC_TWO_CANDIDATES_FOR_AMVP_D0122 1 // SEC_TWO_CANDIDATES_FOR_AMVP_D0122, fixing # of AMVP candidates 3 to 2 86 87 87 88 … … 151 152 #endif 152 153 154 #define SHARP_ILLUCOMP_PARSE_D0060 1 // JCT3V-D0060 Removal of IC's parsing dependency 155 153 156 ///// ***** INTERVIEW SKIP ********* 154 157 #define HHI_INTERVIEW_SKIP 1 … … 167 170 #define FIX_APPENCTOP_T_ONLY 1 // For Texture-only coding 168 171 172 #define LGE_ROUND_OFFSET_D0135 1 // JCT3V-D0135 Rounding offset 173 #define LGE_SAO_MIGRATION_D0091 1 174 #if LGE_SAO_MIGRATION_D0091 175 #define SAO_SKIP_RIGHT 1 ///< H1101: disallow using unavailable pixel during RDO 176 #define SAO_ENCODING_CHOICE 1 ///< I0184: picture early termination 177 #if SAO_ENCODING_CHOICE 178 #define SAO_ENCODING_RATE 0.75 179 #define SAO_ENCODING_CHOICE_CHROMA 1 ///< J0044: picture early termination Luma and Chroma are handled separatenly 180 #if SAO_ENCODING_CHOICE_CHROMA 181 #define SAO_ENCODING_RATE_CHROMA 0.5 182 #define SAO_ENCODING_CHOICE_CHROMA_BF 1 /// K0156: Bug fix for SAO selection consistency 183 #endif 184 #endif 185 #endif 186 169 187 ///// ***** FCO ********* 170 188 #define FLEX_CODING_ORDER_M23723 1 … … 187 205 #if MERL_VSP_C0152 188 206 207 208 #define FIX_MERGE_D 1 // Fix for merge 189 209 #define MERL_General_Fix 1 // General fix by MERL 190 210 211 212 191 213 #define MERL_VSP_C0152_BugFix_ForNoDepthCase 1 // MERL bugfix for test condition of no depth 214 #define QC_BVSP_CleanUP_D0191 1 215 216 #define MTK_D0156 1 217 #define LGE_VSP_INHERIT_D0092 1 218 192 219 #define MERL_VSP_COMPENSATION_C0152 1 // JCT3V-C0152: 1: add VSP merge candidate to merging candidate list; 0: not to add (nocand). 193 220 … … 198 225 #define MERL_CVSP_D0165 0 // JCT3V-D0165: 1: enable CVSP; 0: disable CVSP. 199 226 #endif 200 227 #if LGE_VSP_INHERIT_D0092 228 #define VSP_MERGE_POS 3 // JCT3V-C0152: fixed position of VSP candidate in merge list, supported values: 3. 229 #else 201 230 #define VSP_MERGE_POS 5 // JCT3V-C0152: fixed position of VSP candidate in merge list, supported values: 5. 202 // MTK_DVPREFINE_BVSP_BUG_FIX 1231 #endif // MTK_DVPREFINE_BVSP_BUG_FIX 1 203 232 #define MTK_DEPTH_TO_DISP_D0138 1 // JCT3V-D0138: Use max among four corners for DoNBDV and BVSP 204 233 … … 370 399 #define C2FLAG_NUMBER 1 // maximum number of largerThan2 flag coded in one chunk: 16 in HM5 371 400 401 #if !LGE_SAO_MIGRATION_D0091 372 402 #define REMOVE_SAO_LCU_ENC_CONSTRAINTS_1 0 ///< disable the encoder constraint that does not test SAO/BO mode for chroma in interleaved mode 373 403 #define REMOVE_SAO_LCU_ENC_CONSTRAINTS_2 0 ///< disable the encoder constraint that reduce the range of SAO/EO for chroma in interleaved mode 404 #endif 374 405 #define REMOVE_SAO_LCU_ENC_CONSTRAINTS_3 0 ///< disable the encoder constraint that conditionally disable SAO for chroma for entire slice in interleaved mode 375 406 #define COLLOCATED_REF_IDX 1 ///< H0442: signal collocated reference index … … 644 675 Int iBestType; 645 676 Int iLength; 677 #if LGE_SAO_MIGRATION_D0091 678 Int subTypeIdx ; ///< indicates EO class or BO band position 679 #else 646 680 Int bandPosition ; 681 #endif 647 682 Int iOffset[4]; 648 683 Int StartCUX; … … 674 709 Bool mergeLeftFlag; 675 710 Int typeIdx; 711 #if LGE_SAO_MIGRATION_D0091 712 Int subTypeIdx; 713 #else 676 714 Int bandPosition; 715 #endif 677 716 Int offset[4]; 717 #if !LGE_SAO_MIGRATION_D0091 678 718 Int runDiff; 679 719 Int run; 720 #endif 680 721 Int partIdx; 681 722 Int partIdxTmp; -
branches/HTM-6.2-dev0/source/Lib/TLibDecoder/TDecCAVLC.cpp
r373 r427 265 265 xParseDblParam( aps ); 266 266 } 267 #if !LGE_SAO_MIGRATION_D0091 267 268 READ_FLAG(uiCode, "aps_sao_interleaving_flag"); aps->setSaoInterleavingFlag( (uiCode==1)?true:false ); 268 269 if(!aps->getSaoInterleavingFlag()) … … 275 276 } 276 277 } 278 #endif 277 279 READ_FLAG(uiCode, "aps_adaptive_loop_filter_flag"); aps->setAlfEnabled( (uiCode==1)?true:false ); 278 280 if(aps->getAlfEnabled()) … … 307 309 } 308 310 } 311 #if !LGE_SAO_MIGRATION_D0091 309 312 /** parse SAO parameters 310 313 * \param pSaoParam … … 532 535 } 533 536 } 534 537 #endif 535 538 536 539 Void TDecCavlc::xParseAlfParam(AlfParamSet* pAlfParamSet, Bool bSentInAPS, Int firstLCUAddr, Bool acrossSlice, Int numLCUInWidth, Int numLCUInHeight) … … 1623 1626 1624 1627 } 1628 1629 #if MTK_D0156 1630 1631 pcSPS->setUseVSPCompensation( false ); 1632 pcSPS->setUseDVPRefine( false ); 1633 1634 //Comments: Currently, BVSP and DoNBDV are not used for depth coding 1635 #if MERL_VSP_COMPENSATION_C0152 1636 READ_FLAG( uiCode, "view_synthesis_pred_flag" );pcSPS->setUseVSPCompensation( uiCode ? true : false ); 1637 #endif 1638 READ_FLAG( uiCode, "dv_refine_flag" ); pcSPS->setUseDVPRefine( uiCode ? true : false ); 1639 #endif 1625 1640 } 1626 1641 READ_FLAG( uiCode, "sps_extension2_flag"); … … 1686 1701 } 1687 1702 rpcSlice->setApplyIC(uiCodeTmp); 1703 #if SHARP_ILLUCOMP_PARSE_D0060 1704 if (rpcSlice->getApplyIC()) 1705 { 1706 READ_FLAG (uiCodeTmp, "ic_skip_mergeidx0"); 1707 rpcSlice->setIcSkipParseFlag(uiCodeTmp); 1708 } 1709 #endif 1688 1710 } 1689 1711 #endif … … 1868 1890 if (sps->getUseSAO()) 1869 1891 { 1892 #if LGE_SAO_MIGRATION_D0091 1893 READ_FLAG(uiCode, "slice_sao_luma_flag"); rpcSlice->setSaoEnabledFlag((Bool)uiCode); 1894 READ_FLAG(uiCode, "slice_sao_chroma_flag"); rpcSlice->setSaoEnabledFlagChroma((Bool)uiCode); 1895 #else 1870 1896 READ_FLAG(uiCode, "slice_sao_interleaving_flag"); rpcSlice->setSaoInterleavingFlag(uiCode); 1871 1897 READ_FLAG(uiCode, "slice_sample_adaptive_offset_flag"); rpcSlice->setSaoEnabledFlag((Bool)uiCode); … … 1880 1906 rpcSlice->setSaoEnabledFlagCr(0); 1881 1907 } 1908 #endif 1882 1909 } 1883 1910 READ_UVLC ( uiCode, "aps_id" ); rpcSlice->setAPSId(uiCode); -
branches/HTM-6.2-dev0/source/Lib/TLibDecoder/TDecCAVLC.h
r373 r427 180 180 protected: 181 181 Void xParseDblParam ( TComAPS* aps ); 182 #if !LGE_SAO_MIGRATION_D0091 182 183 Void xParseSaoParam ( SAOParam* pSaoParam ); 183 184 Void xParseSaoOffset (SaoLcuParam* saoLcuParam); 184 185 Void xParseSaoUnit (Int rx, Int ry, Int compIdx, SAOParam* saoParam, Bool& repeatedRow ); 186 #endif 185 187 Void xParseAlfParam(AlfParamSet* pAlfParamSet, Bool bSentInAPS = true, Int firstLCUAddr = 0, Bool acrossSlice = true, Int numLCUInWidth= -1, Int numLCUInHeight= -1); 186 188 Void parseAlfParamSet(AlfParamSet* pAlfParamSet, Int firstLCUAddr, Bool alfAcrossSlice); -
branches/HTM-6.2-dev0/source/Lib/TLibDecoder/TDecCu.cpp
r419 r427 415 415 UInt uiMergeIndex = pcCU->getMergeIndex(uiAbsPartIdx); 416 416 #if MERL_VSP_C0152 417 #if LGE_VSP_INHERIT_D0092 418 Int iVSPIndexTrue[MRG_MAX_NUM_CANDS_MEM]; 419 for (Int i=0; i<MRG_MAX_NUM_CANDS_MEM; i++) 420 { 421 iVSPIndexTrue[i] = 0; 422 } 423 #else 417 424 Int iVSPIndexTrue[3] = {-1, -1, -1}; 425 #endif 418 426 #if MERL_VSP_NBDV_RefVId_Fix_D0166 419 427 Int iVSPDirTrue[3] = {-1, -1, -1}; … … 422 430 m_ppcCU[uiDepth]->getInterMergeCandidates( 0, 0, uiDepth, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, iVSPIndexTrue, uiMergeIndex ); 423 431 #endif 432 #if MTK_D0156 433 if( !pcCU->getSlice()->getSPS()->getUseVSPCompensation() ) 434 { 435 pcCU->setVSPIndexSubParts( 0, uiAbsPartIdx, 0, uiDepth ); 436 } 437 else 438 #endif 424 439 { 425 440 Int iVSPIdx = 0; 441 #if LGE_VSP_INHERIT_D0092 442 if (iVSPIndexTrue[uiMergeIndex] == 1) 443 { 444 iVSPIdx = 1; 445 } 446 #else 426 447 Int numVspIdx; 427 448 numVspIdx = 3; … … 434 455 } 435 456 } 457 #endif 436 458 pcCU->setVSPIndexSubParts( iVSPIdx, uiAbsPartIdx, 0, uiDepth ); // Initialize 437 459 #if MERL_VSP_NBDV_RefVId_Fix_D0166 438 460 pcCU->setVSPDirSubParts( iVSPDirTrue[iVSPIdx-1], uiAbsPartIdx, 0, uiDepth ); 461 #endif 462 #if QC_BVSP_CleanUP_D0191 && !LGE_VSP_INHERIT_D0092 463 if(iVSPIdx != 0) 464 { 465 Int iIVCIdx = pcCU->getSlice()->getRefPic(REF_PIC_LIST_0, 0)->getPOC()==pcCU->getSlice()->getPOC() ? 0: pcCU->getSlice()->getNewRefIdx(REF_PIC_LIST_0); 466 cMvFieldNeighbours[ 2*uiMergeIndex].setRefIdx(iIVCIdx); 467 } 439 468 #endif 440 469 } -
branches/HTM-6.2-dev0/source/Lib/TLibDecoder/TDecEntropy.cpp
r412 r427 320 320 UInt uiMergeIndex = pcCU->getMergeIndex(uiSubPartIdx); 321 321 #if MERL_VSP_C0152 322 #if LGE_VSP_INHERIT_D0092 323 Int iVSPIndexTrue[MRG_MAX_NUM_CANDS_MEM]; 324 for (Int i=0; i<MRG_MAX_NUM_CANDS_MEM; i++) 325 { 326 iVSPIndexTrue[i] = 0; 327 } 328 #else 322 329 Int iVSPIndexTrue[3] = {-1, -1, -1}; 330 #endif 323 331 #if MERL_VSP_NBDV_RefVId_Fix_D0166 324 332 Int iVSPDirTrue[3] = {-1, -1, -1}; … … 344 352 else // MPI not used 345 353 #endif 354 #if MTK_D0156 355 if( !pcCU->getSlice()->getSPS()->getUseVSPCompensation() ) 356 { 357 pcCU->setVSPIndexSubParts( 0, uiSubPartIdx, uiPartIdx, uiDepth ); 358 } 359 else 360 #endif 346 361 { 347 362 Int iVSPIdx = 0; 363 #if LGE_VSP_INHERIT_D0092 364 if (iVSPIndexTrue[uiMergeIndex] == 1) 365 { 366 iVSPIdx = 1; 367 } 368 #else 348 369 Int numVspIdx; 349 370 numVspIdx = 3; … … 356 377 } 357 378 } 379 #endif 358 380 pcCU->setVSPIndexSubParts( iVSPIdx, uiSubPartIdx, uiPartIdx, uiDepth ); // Initialize 359 381 #if MERL_VSP_NBDV_RefVId_Fix_D0166 360 382 pcCU->setVSPDirSubParts( iVSPDirTrue[iVSPIdx-1], uiSubPartIdx, uiPartIdx, uiDepth ); // Initialize 383 #endif 384 #if QC_BVSP_CleanUP_D0191 && !LGE_VSP_INHERIT_D0092 385 if(iVSPIdx != 0) 386 { 387 Int iIVCIdx = pcCU->getSlice()->getRefPic(REF_PIC_LIST_0, 0)->getPOC()==pcCU->getSlice()->getPOC() ? 0: pcCU->getSlice()->getNewRefIdx(REF_PIC_LIST_0); 388 cMvFieldNeighbours[ 2*uiMergeIndex].setRefIdx(iIVCIdx); 389 } 361 390 #endif 362 391 } … … 509 538 { 510 539 #if H3D_IVMP 540 #if SEC_TWO_CANDIDATES_FOR_AMVP_D0122 541 const Int iNumAMVPCands = AMVP_MAX_NUM_CANDS; 542 #else 511 543 const Int iNumAMVPCands = AMVP_MAX_NUM_CANDS + ( pcSubCU->getSlice()->getSPS()->getMultiviewMvPredMode() ? 1 : 0 ); 544 #endif 512 545 m_pcEntropyDecoderIf->parseMVPIdx( iMVPIdx, iNumAMVPCands ); 513 546 #else -
branches/HTM-6.2-dev0/source/Lib/TLibDecoder/TDecEntropy.h
r373 r427 231 231 Void setSliceGranularity (Int iSliceGranularity) {m_pcEntropyDecoderIf->setSliceGranularity(iSliceGranularity);} 232 232 233 #if !LGE_SAO_MIGRATION_D0091 233 234 Void decodeSaoParam (SAOParam* saoParam); 234 235 void decodeSaoLcu(Int rx, Int ry, Int compIdx, SAOParam* saoParam, Bool &repeatedRow ); 235 236 Void decodeSaoOneLcu(SaoLcuParam* saoLcuParam); 237 #endif 236 238 237 239 Void decodeFlush() { m_pcEntropyDecoderIf->decodeFlush(); } -
branches/HTM-6.2-dev0/source/Lib/TLibDecoder/TDecGop.cpp
r373 r427 372 372 if( pcSlice->getSPS()->getUseSAO() ) 373 373 { 374 #if LGE_SAO_MIGRATION_D0091 375 if(pcSlice->getSaoEnabledFlag()||pcSlice->getSaoEnabledFlagChroma()) 376 { 377 SAOParam *saoParam = pcSlice->getAPS()->getSaoParam(); 378 saoParam->bSaoFlag[0] = pcSlice->getSaoEnabledFlag(); 379 saoParam->bSaoFlag[1] = pcSlice->getSaoEnabledFlagChroma(); 380 m_pcSAO->setSaoLcuBasedOptimization(1); 381 m_pcSAO->createPicSaoInfo(rpcPic, m_uiILSliceCount); 382 m_pcSAO->SAOProcess(rpcPic, saoParam); 383 m_pcSAO->PCMLFDisableProcess(rpcPic); 384 m_pcSAO->destroyPicSaoInfo(); 385 } 386 #else 374 387 if(pcSlice->getSaoEnabledFlag()) 375 388 { … … 388 401 m_pcSAO->destroyPicSaoInfo(); 389 402 } 403 #endif 390 404 } 391 405 -
branches/HTM-6.2-dev0/source/Lib/TLibDecoder/TDecSbac.cpp
r390 r427 91 91 , m_cALFSvlcSCModel ( 1, 1, NUM_ALF_SVLC_CTX , m_contextModels + m_numContextModels, m_numContextModels) 92 92 , m_cCUAMPSCModel ( 1, 1, NUM_CU_AMP_CTX , m_contextModels + m_numContextModels, m_numContextModels) 93 #if LGE_SAO_MIGRATION_D0091 94 , m_cSaoMergeSCModel ( 1, 1, NUM_SAO_MERGE_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) 95 , m_cSaoTypeIdxSCModel ( 1, 1, NUM_SAO_TYPE_IDX_CTX , m_contextModels + m_numContextModels, m_numContextModels) 96 #else 93 97 , m_cSaoFlagSCModel ( 1, 1, NUM_SAO_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) 94 98 , m_cSaoUvlcSCModel ( 1, 1, NUM_SAO_UVLC_CTX , m_contextModels + m_numContextModels, m_numContextModels) … … 97 101 , m_cSaoMergeUpSCModel ( 1, 1, NUM_SAO_MERGE_UP_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) 98 102 , m_cSaoTypeIdxSCModel ( 1, 1, NUM_SAO_TYPE_IDX_CTX , m_contextModels + m_numContextModels, m_numContextModels) 103 #endif 99 104 #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX 100 105 , m_cDmmFlagSCModel ( 1, 1, NUM_DMM_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) … … 190 195 m_cALFUvlcSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_ALF_UVLC ); 191 196 m_cALFSvlcSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_ALF_SVLC ); 197 #if LGE_SAO_MIGRATION_D0091 198 m_cSaoMergeSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_SAO_MERGE_FLAG ); 199 m_cSaoTypeIdxSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_SAO_TYPE_IDX ); 200 #else 192 201 m_cSaoFlagSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_SAO_FLAG ); 193 202 m_cSaoUvlcSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_SAO_UVLC ); … … 196 205 m_cSaoMergeUpSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_SAO_MERGE_UP_FLAG ); 197 206 m_cSaoTypeIdxSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_SAO_TYPE_IDX ); 207 #endif 198 208 199 209 m_cCUTransSubdivFlagSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_TRANS_SUBDIV_FLAG ); … … 280 290 m_cALFUvlcSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_ALF_UVLC ); 281 291 m_cALFSvlcSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_ALF_SVLC ); 292 #if LGE_SAO_MIGRATION_D0091 293 m_cSaoMergeSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SAO_MERGE_FLAG ); 294 m_cSaoTypeIdxSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SAO_TYPE_IDX ); 295 #else 282 296 m_cSaoFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SAO_FLAG ); 283 297 m_cSaoUvlcSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SAO_UVLC ); … … 286 300 m_cSaoMergeUpSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SAO_MERGE_UP_FLAG ); 287 301 m_cSaoTypeIdxSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SAO_TYPE_IDX ); 302 #endif 288 303 m_cCUTransSubdivFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_TRANS_SUBDIV_FLAG ); 289 304 #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX … … 1681 1696 } 1682 1697 1683 1698 #if LGE_SAO_MIGRATION_D0091 1699 Void TDecSbac::parseSaoMaxUvlc ( UInt& val, UInt maxSymbol ) 1700 { 1701 if (maxSymbol == 0) 1702 { 1703 val = 0; 1704 return; 1705 } 1706 1707 UInt code; 1708 Int i; 1709 m_pcTDecBinIf->decodeBinEP( code ); 1710 if ( code == 0 ) 1711 { 1712 val = 0; 1713 return; 1714 } 1715 1716 i=1; 1717 while (1) 1718 { 1719 m_pcTDecBinIf->decodeBinEP( code ); 1720 if ( code == 0 ) 1721 { 1722 break; 1723 } 1724 i++; 1725 if (i == maxSymbol) 1726 { 1727 break; 1728 } 1729 } 1730 1731 val = i; 1732 } 1733 1734 Void TDecSbac::parseSaoUflc (UInt uiLength, UInt& riVal) 1735 { 1736 m_pcTDecBinIf->decodeBinsEP ( riVal, uiLength ); 1737 } 1738 1739 Void TDecSbac::parseSaoMerge (UInt& ruiVal) 1740 { 1741 UInt uiCode; 1742 m_pcTDecBinIf->decodeBin( uiCode, m_cSaoMergeSCModel.get( 0, 0, 0 ) ); 1743 ruiVal = (Int)uiCode; 1744 } 1745 1746 Void TDecSbac::parseSaoTypeIdx (UInt& ruiVal) 1747 { 1748 UInt uiCode; 1749 m_pcTDecBinIf->decodeBin( uiCode, m_cSaoTypeIdxSCModel.get( 0, 0, 0 ) ); 1750 if (uiCode == 0) 1751 { 1752 ruiVal = 0; 1753 } 1754 else 1755 { 1756 m_pcTDecBinIf->decodeBinEP( uiCode ); 1757 if (uiCode == 0) 1758 { 1759 ruiVal = 5; 1760 } 1761 else 1762 { 1763 ruiVal = 1; 1764 } 1765 } 1766 } 1767 1768 inline Void copySaoOneLcuParam(SaoLcuParam* psDst, SaoLcuParam* psSrc) 1769 { 1770 Int i; 1771 psDst->partIdx = psSrc->partIdx; 1772 psDst->typeIdx = psSrc->typeIdx; 1773 if (psDst->typeIdx != -1) 1774 { 1775 psDst->subTypeIdx = psSrc->subTypeIdx ; 1776 psDst->length = psSrc->length; 1777 for (i=0;i<psDst->length;i++) 1778 { 1779 psDst->offset[i] = psSrc->offset[i]; 1780 } 1781 } 1782 else 1783 { 1784 psDst->length = 0; 1785 for (i=0;i<SAO_BO_LEN;i++) 1786 { 1787 psDst->offset[i] = 0; 1788 } 1789 } 1790 } 1791 1792 Void TDecSbac::parseSaoOffset(SaoLcuParam* psSaoLcuParam, UInt compIdx) 1793 { 1794 UInt uiSymbol; 1795 static Int iTypeLength[MAX_NUM_SAO_TYPE] = 1796 { 1797 SAO_EO_LEN, 1798 SAO_EO_LEN, 1799 SAO_EO_LEN, 1800 SAO_EO_LEN, 1801 SAO_BO_LEN 1802 }; 1803 1804 if (compIdx==2) 1805 { 1806 uiSymbol = (UInt)( psSaoLcuParam->typeIdx + 1); 1807 } 1808 else 1809 { 1810 parseSaoTypeIdx(uiSymbol); 1811 } 1812 psSaoLcuParam->typeIdx = (Int)uiSymbol - 1; 1813 1814 if (uiSymbol) 1815 { 1816 psSaoLcuParam->length = iTypeLength[psSaoLcuParam->typeIdx]; 1817 #if FULL_NBIT 1818 Int offsetTh = 1 << ( min((Int)(g_uiBitDepth + (g_uiBitDepth-8)-5),5) ); 1819 #else 1820 Int offsetTh = 1 << ( min((Int)(g_uiBitDepth + g_uiBitIncrement-5),5) ); 1821 #endif 1822 1823 if( psSaoLcuParam->typeIdx == SAO_BO ) 1824 { 1825 for(Int i=0; i< psSaoLcuParam->length; i++) 1826 { 1827 parseSaoMaxUvlc(uiSymbol, offsetTh -1 ); 1828 psSaoLcuParam->offset[i] = uiSymbol; 1829 } 1830 for(Int i=0; i< psSaoLcuParam->length; i++) 1831 { 1832 if (psSaoLcuParam->offset[i] != 0) 1833 { 1834 m_pcTDecBinIf->decodeBinEP ( uiSymbol); 1835 if (uiSymbol) 1836 { 1837 psSaoLcuParam->offset[i] = -psSaoLcuParam->offset[i] ; 1838 } 1839 } 1840 } 1841 parseSaoUflc(5, uiSymbol ); 1842 psSaoLcuParam->subTypeIdx = uiSymbol; 1843 } 1844 else if( psSaoLcuParam->typeIdx < 4 ) 1845 { 1846 parseSaoMaxUvlc(uiSymbol, offsetTh -1 ); psSaoLcuParam->offset[0] = uiSymbol; 1847 parseSaoMaxUvlc(uiSymbol, offsetTh -1 ); psSaoLcuParam->offset[1] = uiSymbol; 1848 parseSaoMaxUvlc(uiSymbol, offsetTh -1 ); psSaoLcuParam->offset[2] = -(Int)uiSymbol; 1849 parseSaoMaxUvlc(uiSymbol, offsetTh -1 ); psSaoLcuParam->offset[3] = -(Int)uiSymbol; 1850 if (compIdx != 2) 1851 { 1852 parseSaoUflc(2, uiSymbol ); 1853 psSaoLcuParam->subTypeIdx = uiSymbol; 1854 psSaoLcuParam->typeIdx += psSaoLcuParam->subTypeIdx; 1855 } 1856 } 1857 } 1858 else 1859 { 1860 psSaoLcuParam->length = 0; 1861 } 1862 } 1863 1864 Void TDecSbac::parseSaoOneLcuInterleaving(Int rx, Int ry, SAOParam* pSaoParam, TComDataCU* pcCU, Int iCUAddrInSlice, Int iCUAddrUpInSlice, Int allowMergeLeft, Int allowMergeUp) 1865 { 1866 Int iAddr = pcCU->getAddr(); 1867 UInt uiSymbol; 1868 1869 for (Int iCompIdx=0; iCompIdx<3; iCompIdx++) 1870 { 1871 pSaoParam->saoLcuParam[iCompIdx][iAddr].mergeUpFlag = 0; 1872 pSaoParam->saoLcuParam[iCompIdx][iAddr].mergeLeftFlag = 0; 1873 pSaoParam->saoLcuParam[iCompIdx][iAddr].subTypeIdx = 0; 1874 pSaoParam->saoLcuParam[iCompIdx][iAddr].typeIdx =-1; 1875 pSaoParam->saoLcuParam[iCompIdx][iAddr].offset[0] = 0; 1876 pSaoParam->saoLcuParam[iCompIdx][iAddr].offset[1] = 0; 1877 pSaoParam->saoLcuParam[iCompIdx][iAddr].offset[2] = 0; 1878 pSaoParam->saoLcuParam[iCompIdx][iAddr].offset[3] = 0; 1879 } 1880 if (pSaoParam->bSaoFlag[0] || pSaoParam->bSaoFlag[1] ) 1881 { 1882 if (rx>0 && iCUAddrInSlice!=0 && allowMergeLeft) 1883 { 1884 parseSaoMerge(uiSymbol); 1885 pSaoParam->saoLcuParam[0][iAddr].mergeLeftFlag = (Bool)uiSymbol; 1886 } 1887 if (pSaoParam->saoLcuParam[0][iAddr].mergeLeftFlag==0) 1888 { 1889 if ((ry > 0) && (iCUAddrUpInSlice>=0) && allowMergeUp) 1890 { 1891 parseSaoMerge(uiSymbol); 1892 pSaoParam->saoLcuParam[0][iAddr].mergeUpFlag = (Bool)uiSymbol; 1893 } 1894 } 1895 } 1896 1897 for (Int iCompIdx=0; iCompIdx<3; iCompIdx++) 1898 { 1899 if ((iCompIdx == 0 && pSaoParam->bSaoFlag[0]) || (iCompIdx > 0 && pSaoParam->bSaoFlag[1]) ) 1900 { 1901 if (rx>0 && iCUAddrInSlice!=0 && allowMergeLeft) 1902 { 1903 pSaoParam->saoLcuParam[iCompIdx][iAddr].mergeLeftFlag = pSaoParam->saoLcuParam[0][iAddr].mergeLeftFlag; 1904 } 1905 else 1906 { 1907 pSaoParam->saoLcuParam[iCompIdx][iAddr].mergeLeftFlag = 0; 1908 } 1909 1910 if (pSaoParam->saoLcuParam[iCompIdx][iAddr].mergeLeftFlag==0) 1911 { 1912 if ((ry > 0) && (iCUAddrUpInSlice>=0) && allowMergeUp) 1913 { 1914 pSaoParam->saoLcuParam[iCompIdx][iAddr].mergeUpFlag = pSaoParam->saoLcuParam[0][iAddr].mergeUpFlag; 1915 } 1916 else 1917 { 1918 pSaoParam->saoLcuParam[iCompIdx][iAddr].mergeUpFlag = 0; 1919 } 1920 1921 if (!pSaoParam->saoLcuParam[iCompIdx][iAddr].mergeUpFlag) 1922 { 1923 pSaoParam->saoLcuParam[2][iAddr].typeIdx = pSaoParam->saoLcuParam[1][iAddr].typeIdx; 1924 parseSaoOffset(&(pSaoParam->saoLcuParam[iCompIdx][iAddr]), iCompIdx); 1925 } 1926 else 1927 { 1928 copySaoOneLcuParam(&pSaoParam->saoLcuParam[iCompIdx][iAddr], &pSaoParam->saoLcuParam[iCompIdx][iAddr-pSaoParam->numCuInWidth]); 1929 } 1930 } 1931 else 1932 { 1933 copySaoOneLcuParam(&pSaoParam->saoLcuParam[iCompIdx][iAddr], &pSaoParam->saoLcuParam[iCompIdx][iAddr-1]); 1934 } 1935 } 1936 else 1937 { 1938 pSaoParam->saoLcuParam[iCompIdx][iAddr].typeIdx = -1; 1939 pSaoParam->saoLcuParam[iCompIdx][iAddr].subTypeIdx = 0; 1940 } 1941 } 1942 } 1943 #else 1684 1944 Void TDecSbac::parseSaoUvlc (UInt& ruiVal) 1685 1945 { … … 1918 2178 } 1919 2179 } 1920 2180 #endif 1921 2181 /** 1922 2182 - Initialize our contexts from the nominated source. -
branches/HTM-6.2-dev0/source/Lib/TLibDecoder/TDecSbac.h
r373 r427 110 110 #endif 111 111 112 #if LGE_SAO_MIGRATION_D0091 113 Void parseSaoMaxUvlc ( UInt& val, UInt maxSymbol ); 114 Void parseSaoMerge ( UInt& ruiVal ); 115 Void parseSaoTypeIdx ( UInt& ruiVal ); 116 Void parseSaoUflc ( UInt uiLength, UInt& ruiVal ); 117 Void parseSaoOneLcuInterleaving(Int rx, Int ry, SAOParam* pSaoParam, TComDataCU* pcCU, Int iCUAddrInSlice, Int iCUAddrUpInSlice, Int allowMergeLeft, Int allowMergeUp); 118 Void parseSaoOffset (SaoLcuParam* psSaoLcuParam, UInt compIdx); 119 #else 112 120 Void parseSaoUvlc ( UInt& ruiVal ); 113 121 Void parseSaoSvlc ( Int& riVal ); … … 118 126 Void parseSaoOneLcuInterleaving(Int rx, Int ry, SAOParam* pSaoParam, TComDataCU* pcCU, Int iCUAddrInSlice, Int iCUAddrUpInSlice, Bool bLFCrossSliceBoundaryFlag); 119 127 Void parseSaoOffset (SaoLcuParam* psSaoLcuParam); 128 #endif 120 129 121 130 #if RWTH_SDC_DLT_B0036 … … 251 260 ContextModel3DBuffer m_cALFSvlcSCModel; 252 261 ContextModel3DBuffer m_cCUAMPSCModel; 262 #if LGE_SAO_MIGRATION_D0091 263 ContextModel3DBuffer m_cSaoMergeSCModel; 264 ContextModel3DBuffer m_cSaoTypeIdxSCModel; 265 #else 253 266 ContextModel3DBuffer m_cSaoFlagSCModel; 254 267 ContextModel3DBuffer m_cSaoUvlcSCModel; … … 257 270 ContextModel3DBuffer m_cSaoMergeUpSCModel; 258 271 ContextModel3DBuffer m_cSaoTypeIdxSCModel; 272 #endif 259 273 260 274 #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX -
branches/HTM-6.2-dev0/source/Lib/TLibDecoder/TDecSlice.cpp
r296 r427 286 286 g_bJustDoIt = g_bEncDecTraceEnable; 287 287 #endif 288 #if LGE_SAO_MIGRATION_D0091 289 if ( pcSlice->getSPS()->getUseSAO() && (pcSlice->getSaoEnabledFlag()||pcSlice->getSaoEnabledFlagChroma()) ) 290 { 291 SAOParam *saoParam = pcSlice->getAPS()->getSaoParam(); 292 saoParam->bSaoFlag[0] = pcSlice->getSaoEnabledFlag(); 293 if (iCUAddr == iStartCUAddr) 294 { 295 saoParam->bSaoFlag[1] = pcSlice->getSaoEnabledFlagChroma(); 296 } 297 Int numCuInWidth = saoParam->numCuInWidth; 298 Int cuAddrInSlice = iCUAddr - rpcPic->getPicSym()->getCUOrderMap(pcSlice->getSliceCurStartCUAddr()/rpcPic->getNumPartInCU()); 299 Int cuAddrUpInSlice = cuAddrInSlice - numCuInWidth; 300 Int rx = iCUAddr % numCuInWidth; 301 Int ry = iCUAddr / numCuInWidth; 302 Int allowMergeLeft = 1; 303 Int allowMergeUp = 1; 304 if (rx!=0) 305 { 306 if (rpcPic->getPicSym()->getTileIdxMap(iCUAddr-1) != rpcPic->getPicSym()->getTileIdxMap(iCUAddr)) 307 { 308 allowMergeLeft = 0; 309 } 310 } 311 if (ry!=0) 312 { 313 if (rpcPic->getPicSym()->getTileIdxMap(iCUAddr-numCuInWidth) != rpcPic->getPicSym()->getTileIdxMap(iCUAddr)) 314 { 315 allowMergeUp = 0; 316 } 317 } 318 pcSbacDecoder->parseSaoOneLcuInterleaving(rx, ry, saoParam,pcCU, cuAddrInSlice, cuAddrUpInSlice, allowMergeLeft, allowMergeUp); 319 } 320 #else 288 321 if ( pcSlice->getSPS()->getUseSAO() && pcSlice->getSaoInterleavingFlag() && pcSlice->getSaoEnabledFlag() ) 289 322 { … … 301 334 pcSbacDecoder->parseSaoOneLcuInterleaving(rx, ry, pcSlice->getAPS()->getSaoParam(),pcCU, cuAddrInSlice, cuAddrUpInSlice, pcSlice->getSPS()->getLFCrossSliceBoundaryFlag() ); 302 335 } 336 #endif 303 337 304 338 m_pcCuDecoder->decodeCU ( pcCU, uiIsLast ); -
branches/HTM-6.2-dev0/source/Lib/TLibEncoder/TEncCavlc.cpp
r373 r427 720 720 #endif 721 721 } 722 723 #if MTK_D0156 724 #if MERL_VSP_COMPENSATION_C0152 725 WRITE_FLAG( pcSPS->getUseVSPCompensation() ? 1 : 0, "view_synthesis_pred_flag" ); 726 #endif 727 728 WRITE_FLAG( pcSPS->getUseDVPRefine() ? 1 : 0, "dv_refine_flag" ); 729 #endif 722 730 } 723 731 else … … 793 801 WRITE_FLAG( pcSlice->getApplyIC() ? 1 : 0, "applying IC flag" ); 794 802 } 803 #if SHARP_ILLUCOMP_PARSE_D0060 804 if (pcSlice->getApplyIC()) 805 { 806 WRITE_FLAG( pcSlice->getIcSkipParseFlag() ? 1 : 0, "ic_skip_mergeidx0" ); 807 } 808 #endif 795 809 } 796 810 #endif … … 960 974 if (pcSlice->getSPS()->getUseSAO()) 961 975 { 976 #if LGE_SAO_MIGRATION_D0091 977 WRITE_FLAG( pcSlice->getSaoEnabledFlag(), "slice_sao_luma_flag" ); 978 { 979 SAOParam *saoParam = pcSlice->getAPS()->getSaoParam(); 980 WRITE_FLAG( saoParam->bSaoFlag[1], "slice_sao_chroma_flag" ); 981 } 982 #else 962 983 WRITE_FLAG( pcSlice->getSaoInterleavingFlag(), "SAO interleaving flag" ); 963 984 assert (pcSlice->getSaoEnabledFlag() == pcSlice->getAPS()->getSaoEnabled()); … … 968 989 WRITE_FLAG( pcSlice->getAPS()->getSaoParam()->bSaoFlag[2], "SAO on/off flag for Cr in slice header" ); 969 990 } 991 #endif 970 992 } 971 993 WRITE_UVLC( pcSlice->getAPS()->getAPSID(), "aps_id"); … … 1499 1521 } 1500 1522 } 1501 1523 #if !LGE_SAO_MIGRATION_D0091 1502 1524 Void TEncCavlc::codeSaoFlag( UInt uiCode ) 1503 1525 { … … 1537 1559 WRITE_CODE( uiCode, uiLength, "sao_run_diff"); 1538 1560 } 1561 #endif 1539 1562 1540 1563 Void TEncCavlc::estBit( estBitsSbacStruct* pcEstBitsCabac, Int width, Int height, TextType eTType ) -
branches/HTM-6.2-dev0/source/Lib/TLibEncoder/TEncCavlc.h
r373 r427 142 142 Void codeAPSAlflag(UInt uiCode); 143 143 Void codeAlfFixedLengthIdx( UInt idx, UInt numFilterSetsInBuffer); 144 #if LGE_SAO_MIGRATION_D0091 145 Void codeSAOSign ( UInt code ) { printf("Not supported\n"); assert (0); } 146 Void codeSaoMaxUvlc ( UInt code, UInt maxSymbol ){printf("Not supported\n"); assert (0);} 147 Void codeSaoMerge ( UInt uiCode ){printf("Not supported\n"); assert (0);} 148 Void codeSaoTypeIdx ( UInt uiCode ){printf("Not supported\n"); assert (0);} 149 Void codeSaoUflc ( UInt uiLength, UInt uiCode ){ assert(uiCode < 32); printf("Not supported\n"); assert (0);} 150 #else 144 151 Void codeSaoFlag ( UInt uiCode ); 145 152 Void codeSaoUvlc ( UInt uiCode ); … … 150 157 Void codeSaoTypeIdx ( UInt uiCode ){ xWriteUvlc(uiCode );} 151 158 Void codeSaoUflc ( UInt uiCode ){ assert(uiCode < 32); xWriteCode(uiCode, 5);} 159 #endif 152 160 153 161 Void codeSkipFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx ); -
branches/HTM-6.2-dev0/source/Lib/TLibEncoder/TEncCfg.h
r373 r427 160 160 #endif 161 161 Int m_maxNumOffsetsPerPic; 162 #if LGE_SAO_MIGRATION_D0091 163 Bool m_saoLcuBoundary; 164 Bool m_saoLcuBasedOptimization; 165 #else 162 166 Bool m_saoInterleavingFlag; 167 #endif 163 168 164 169 //====== Lossless ======== … … 339 344 UInt m_uiMultiviewResPredMode; 340 345 #endif 346 #endif 347 348 #if MTK_D0156 349 #if MERL_VSP_COMPENSATION_C0152 350 Bool m_bUseVSPCompensation; 351 #endif 352 Bool m_bUseDVPRefine; 341 353 #endif 342 354 … … 673 685 Void setMaxNumOffsetsPerPic (Int iVal) { m_maxNumOffsetsPerPic = iVal; } 674 686 Int getMaxNumOffsetsPerPic () { return m_maxNumOffsetsPerPic; } 687 #if LGE_SAO_MIGRATION_D0091 688 Void setSaoLcuBoundary (Bool val) { m_saoLcuBoundary = val; } 689 Bool getSaoLcuBoundary () { return m_saoLcuBoundary; } 690 Void setSaoLcuBasedOptimization (Bool val) { m_saoLcuBasedOptimization = val; } 691 Bool getSaoLcuBasedOptimization () { return m_saoLcuBasedOptimization; } 692 #else 675 693 Void setSaoInterleavingFlag (bool bVal) { m_saoInterleavingFlag = bVal; } 676 694 Bool getSaoInterleavingFlag () { return m_saoInterleavingFlag; } 695 #endif 677 696 Void setTileBehaviorControlPresentFlag ( Int i ) { m_iTileBehaviorControlPresentFlag = i; } 678 697 Int getTileBehaviorControlPresentFlag () { return m_iTileBehaviorControlPresentFlag; } … … 822 841 #endif 823 842 843 #if MTK_D0156 844 845 #if MERL_VSP_COMPENSATION_C0152 846 Bool getUseVSPCompensation( ){ return m_bUseVSPCompensation;} 847 Void setUseVSPCompensation( Bool bValue ){ m_bUseVSPCompensation = bValue;} 848 #endif 849 850 851 Bool getUseDVPRefine( ){ return m_bUseDVPRefine;} 852 Void setUseDVPRefine( Bool bValue ){ m_bUseDVPRefine = bValue;} 853 #endif 854 824 855 }; 825 856 -
branches/HTM-6.2-dev0/source/Lib/TLibEncoder/TEncCu.cpp
r412 r427 721 721 722 722 #if LGE_ILLUCOMP_B0045 723 #if SHARP_ILLUCOMP_PARSE_D0060 724 bICEnabled = false; 725 #else 723 726 bICEnabled = rpcBestCU->getICFlag(0); 727 #endif 724 728 #endif 725 729 … … 787 791 Bool bResPredFlag = ( uiResPrdId > 0 ); 788 792 #if LGE_ILLUCOMP_B0045 793 #if SHARP_ILLUCOMP_PARSE_D0060 794 { 795 Bool bICFlag = false; 796 rpcTempCU->setICFlagSubParts(bICFlag, 0, 0, uiDepth); 797 #else 789 798 for(UInt uiICId = 0; uiICId < (bICEnabled ? 2 : 1); uiICId++) 790 799 { 791 800 Bool bICFlag = (uiICId ? true : false); 792 801 rpcTempCU->setICFlagSubParts(bICFlag, 0, 0, uiDepth); 802 #endif 793 803 #endif 794 804 #endif … … 1936 1946 rpcTempCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uhDepth ); // interprets depth relative to LCU level 1937 1947 #if MERL_VSP_C0152 1948 #if LGE_VSP_INHERIT_D0092 1949 Int iVSPIndexTrue[MRG_MAX_NUM_CANDS_MEM]; 1950 for (Int i=0; i<MRG_MAX_NUM_CANDS_MEM; i++) 1951 { 1952 iVSPIndexTrue[i] = 0; 1953 } 1954 #else 1938 1955 Int iVSPIndexTrue[3] = {-1, -1, -1}; 1956 #endif 1939 1957 #if MERL_VSP_NBDV_RefVId_Fix_D0166 1940 1958 Int iVSPDirTrue[3] = {-1, -1, -1}; … … 1962 1980 { 1963 1981 TComYuv* pcPredYuvTemp = NULL; 1982 #if SHARP_ILLUCOMP_PARSE_D0060 1983 if (rpcTempCU->getSlice()->getApplyIC() && rpcTempCU->getSlice()->getIcSkipParseFlag()) 1984 { 1985 if (bICFlag && uiMergeCand == 0) 1986 { 1987 continue; 1988 } 1989 } 1990 #endif 1964 1991 #if LOSSLESS_CODING 1965 1992 UInt iteration; … … 1998 2025 rpcTempCU->setMergeIndexSubParts( uiMergeCand, 0, 0, uhDepth ); // interprets depth relative to LCU level 1999 2026 #if MERL_VSP_C0152 2027 2028 #if MTK_D0156 2029 if( !rpcTempCU->getSlice()->getSPS()->getUseVSPCompensation() ) 2030 { 2031 rpcTempCU->setVSPIndexSubParts( 0, 0, 0, uhDepth ); 2032 } 2033 else 2034 #endif 2000 2035 { 2001 2036 Int iVSPIdx = 0; 2037 #if LGE_VSP_INHERIT_D0092 2038 if (iVSPIndexTrue[uiMergeCand] == 1) 2039 { 2040 iVSPIdx = 1; 2041 } 2042 #else 2002 2043 Int numVSPIdx; 2003 2044 numVSPIdx = 3; … … 2010 2051 } 2011 2052 } 2053 #endif 2012 2054 rpcTempCU->setVSPIndexSubParts( iVSPIdx, 0, 0, uhDepth ); 2013 2055 #if MERL_VSP_NBDV_RefVId_Fix_D0166 2014 2056 rpcTempCU->setVSPDirSubParts( iVSPDirTrue[iVSPIdx-1], 0, 0, uhDepth ); // interprets depth relative to LCU level 2057 #endif 2058 #if QC_BVSP_CleanUP_D0191 && !LGE_VSP_INHERIT_D0092 2059 if(iVSPIdx != 0) 2060 { 2061 Int iIVCIdx = rpcTempCU->getSlice()->getRefPic(REF_PIC_LIST_0, 0)->getPOC()==rpcTempCU->getSlice()->getPOC() ? 0: rpcTempCU->getSlice()->getNewRefIdx(REF_PIC_LIST_0); 2062 cMvFieldNeighbours[2*uiMergeCand].setRefIdx(iIVCIdx); 2063 } 2015 2064 #endif 2016 2065 } -
branches/HTM-6.2-dev0/source/Lib/TLibEncoder/TEncEntropy.cpp
r373 r427 54 54 if (pcSlice->getSPS()->getUseSAO()) 55 55 { 56 #if LGE_SAO_MIGRATION_D0091 57 if (pcSlice->getSPS()->getUseSAO()) 58 { 59 SAOParam *saoParam = pcSlice->getAPS()->getSaoParam(); 60 pcSlice->setSaoEnabledFlag (saoParam->bSaoFlag[0]); 61 { 62 pcSlice->setSaoEnabledFlagChroma (saoParam->bSaoFlag[1]); 63 } 64 } 65 #else 56 66 pcSlice->setSaoInterleavingFlag(pcSlice->getAPS()->getSaoInterleavingFlag()); 57 67 pcSlice->setSaoEnabledFlag (pcSlice->getAPS()->getSaoParam()->bSaoFlag[0]); … … 66 76 pcSlice->setSaoEnabledFlagCr (0); 67 77 } 78 #endif 68 79 } 69 80 … … 1384 1395 { 1385 1396 #if H3D_IVMP 1397 #if SEC_TWO_CANDIDATES_FOR_AMVP_D0122 1398 const Int iNumCands = AMVP_MAX_NUM_CANDS; 1399 #else 1386 1400 const Int iNumCands = AMVP_MAX_NUM_CANDS + ( pcCU->getSlice()->getSPS()->getMultiviewMvPredMode() ? 1 : 0 ); 1401 #endif 1387 1402 m_pcEntropyCoderIf->codeMVPIdx( pcCU, uiAbsPartIdx, eRefList, iNumCands ); 1388 1403 #else … … 1528 1543 } 1529 1544 1545 #if LGE_SAO_MIGRATION_D0091 1546 Void TEncEntropy::encodeSaoOffset(SaoLcuParam* saoLcuParam, UInt compIdx) 1547 { 1548 UInt uiSymbol; 1549 Int i; 1550 1551 uiSymbol = saoLcuParam->typeIdx + 1; 1552 if (compIdx!=2) 1553 { 1554 m_pcEntropyCoderIf->codeSaoTypeIdx(uiSymbol); 1555 } 1556 1557 if (uiSymbol) 1558 { 1559 if (saoLcuParam->typeIdx < 4 && compIdx != 2) 1560 { 1561 saoLcuParam->subTypeIdx = saoLcuParam->typeIdx; 1562 } 1563 #if FULL_NBIT 1564 Int offsetTh = 1 << ( min((Int)(g_uiBitDepth + (g_uiBitDepth-8)-5),5) ); 1565 #else 1566 Int offsetTh = 1 << ( min((Int)(g_uiBitDepth + g_uiBitIncrement-5),5) ); 1567 #endif 1568 if( saoLcuParam->typeIdx == SAO_BO ) 1569 { 1570 for( i=0; i< saoLcuParam->length; i++) 1571 { 1572 UInt absOffset = ( (saoLcuParam->offset[i] < 0) ? -saoLcuParam->offset[i] : saoLcuParam->offset[i]); 1573 m_pcEntropyCoderIf->codeSaoMaxUvlc(absOffset, offsetTh-1); 1574 } 1575 for( i=0; i< saoLcuParam->length; i++) 1576 { 1577 if (saoLcuParam->offset[i] != 0) 1578 { 1579 UInt sign = (saoLcuParam->offset[i] < 0) ? 1 : 0 ; 1580 m_pcEntropyCoderIf->codeSAOSign(sign); 1581 } 1582 } 1583 uiSymbol = (UInt) (saoLcuParam->subTypeIdx); 1584 m_pcEntropyCoderIf->codeSaoUflc(5, uiSymbol); 1585 } 1586 else if( saoLcuParam->typeIdx < 4 ) 1587 { 1588 m_pcEntropyCoderIf->codeSaoMaxUvlc( saoLcuParam->offset[0], offsetTh-1); 1589 m_pcEntropyCoderIf->codeSaoMaxUvlc( saoLcuParam->offset[1], offsetTh-1); 1590 m_pcEntropyCoderIf->codeSaoMaxUvlc(-saoLcuParam->offset[2], offsetTh-1); 1591 m_pcEntropyCoderIf->codeSaoMaxUvlc(-saoLcuParam->offset[3], offsetTh-1); 1592 1593 if (compIdx!=2) 1594 { 1595 uiSymbol = (UInt) (saoLcuParam->subTypeIdx); 1596 m_pcEntropyCoderIf->codeSaoUflc(2, uiSymbol); 1597 } 1598 } 1599 } 1600 } 1601 1602 /** Encode SAO unit interleaving 1603 * \param rx 1604 * \param ry 1605 * \param pSaoParam 1606 * \param pcCU 1607 * \param iCUAddrInSlice 1608 * \param iCUAddrUpInSlice 1609 * \param bLFCrossSliceBoundaryFlag 1610 */ 1611 Void TEncEntropy::encodeSaoUnitInterleaving(Int compIdx, Bool saoFlag, Int rx, Int ry, SaoLcuParam* saoLcuParam, Int cuAddrInSlice, Int cuAddrUpInSlice, Int allowMergeLeft, Int allowMergeUp) 1612 { 1613 if (saoFlag) 1614 { 1615 if (rx>0 && cuAddrInSlice!=0 && allowMergeLeft) 1616 { 1617 m_pcEntropyCoderIf->codeSaoMerge(saoLcuParam->mergeLeftFlag); 1618 } 1619 else 1620 { 1621 saoLcuParam->mergeLeftFlag = 0; 1622 } 1623 1624 if (saoLcuParam->mergeLeftFlag == 0) 1625 { 1626 if ( (ry > 0) && (cuAddrUpInSlice>=0) && allowMergeUp ) 1627 { 1628 m_pcEntropyCoderIf->codeSaoMerge(saoLcuParam->mergeUpFlag); 1629 } 1630 else 1631 { 1632 saoLcuParam->mergeUpFlag = 0; 1633 } 1634 1635 if (!saoLcuParam->mergeUpFlag) 1636 { 1637 encodeSaoOffset(saoLcuParam, compIdx); 1638 } 1639 } 1640 } 1641 } 1642 #else 1530 1643 /** Encode SAO Offset 1531 1644 * \param saoLcuParam SAO LCU paramters … … 1715 1828 } 1716 1829 } 1830 #endif 1717 1831 1718 1832 Int TEncEntropy::countNonZeroCoeffs( TCoeff* pcCoef, UInt uiSize ) -
branches/HTM-6.2-dev0/source/Lib/TLibEncoder/TEncEntropy.h
r373 r427 157 157 158 158 virtual Void codeAlfCtrlFlag ( UInt uiSymbol ) = 0; 159 #if LGE_SAO_MIGRATION_D0091 160 virtual Void codeSAOSign ( UInt code ) = 0; 161 virtual Void codeSaoMaxUvlc ( UInt code, UInt maxSymbol ) = 0; 162 virtual Void codeSaoMerge ( UInt uiCode ) = 0; 163 virtual Void codeSaoTypeIdx ( UInt uiCode) = 0; 164 virtual Void codeSaoUflc ( UInt uiLength, UInt uiCode ) = 0; 165 #else 159 166 virtual Void codeSaoFlag ( UInt uiCode ) = 0; 160 167 virtual Void codeSaoUvlc ( UInt uiCode ) = 0; … … 165 172 virtual Void codeSaoTypeIdx ( UInt uiCode) = 0; 166 173 virtual Void codeSaoUflc ( UInt uiCode) = 0; 174 #endif 167 175 virtual Void estBit (estBitsSbacStruct* pcEstBitsSbac, Int width, Int height, TextType eTType) = 0; 168 176 … … 316 324 Int golombEncode(int coeff, int k); 317 325 Int lengthGolomb(int coeffVal, int k); 326 #if LGE_SAO_MIGRATION_D0091 327 Void encodeSaoOffset(SaoLcuParam* saoLcuParam, UInt compIdx); 328 Void encodeSaoUnitInterleaving(Int compIdx, Bool saoFlag, Int rx, Int ry, SaoLcuParam* saoLcuParam, Int cuAddrInSlice, Int cuAddrUpInSlice, Int allowMergeLeft, Int allowMergeUp); 329 #else 318 330 Void encodeSaoUnit(Int rx, Int ry, Int compIdx, SAOParam* saoParam, Int repeatedRow); 319 331 Void encodeSaoOffset(SaoLcuParam* saoLcuParam); 320 332 Void encodeSaoUnitInterleaving(Int rx, Int ry, SAOParam* saoParam, TComDataCU* cu, Int cuAddrInSlice, Int cuAddrUpInSlice, Bool lfCrossSliceBoundaryFlag); 321 333 Void encodeSaoParam (TComAPS* aps); 334 #endif 322 335 323 336 static Int countNonZeroCoeffs( TCoeff* pcCoef, UInt uiSize ); -
branches/HTM-6.2-dev0/source/Lib/TLibEncoder/TEncGOP.cpp
r373 r427 1264 1264 TComAPS cAPS; 1265 1265 allocAPS(&cAPS, pcSlice->getSPS()); 1266 #if !LGE_SAO_MIGRATION_D0091 1266 1267 cAPS.setSaoInterleavingFlag(m_pcCfg->getSaoInterleavingFlag()); 1268 #endif 1267 1269 // set entropy coder for RD 1268 1270 m_pcEntropyCoder->setEntropyCoder ( m_pcCavlcCoder, pcSlice ); … … 1272 1274 m_pcEntropyCoder->resetEntropy(); 1273 1275 m_pcEntropyCoder->setBitstream( m_pcBitCounter ); 1276 #if LGE_SAO_MIGRATION_D0091 1277 m_pcSAO->startSaoEnc(pcPic, m_pcEntropyCoder, m_pcEncTop->getRDSbacCoder(), m_pcEncTop->getRDGoOnSbacCoder()); 1278 #else 1274 1279 m_pcSAO->startSaoEnc(pcPic, m_pcEntropyCoder, m_pcEncTop->getRDSbacCoder(), NULL); 1280 #endif 1275 1281 SAOParam& cSaoParam = *(cAPS.getSaoParam()); 1276 1282 1277 1283 #if SAO_CHROMA_LAMBDA 1284 #if LGE_SAO_MIGRATION_D0091 1285 #if SAO_ENCODING_CHOICE 1286 m_pcSAO->SAOProcess(&cSaoParam, pcPic->getSlice(0)->getLambdaLuma(), pcPic->getSlice(0)->getLambdaChroma(), pcPic->getSlice(0)->getDepth()); 1287 #else 1278 1288 m_pcSAO->SAOProcess(&cSaoParam, pcPic->getSlice(0)->getLambdaLuma(), pcPic->getSlice(0)->getLambdaChroma()); 1289 #endif 1290 #else 1291 m_pcSAO->SAOProcess(&cSaoParam, pcPic->getSlice(0)->getLambdaLuma(), pcPic->getSlice(0)->getLambdaChroma()); 1292 #endif 1279 1293 #else 1280 1294 #if ALF_CHROMA_LAMBDA … … 1561 1575 m_pcEntropyCoder->encodeDFParams(pcAPS); 1562 1576 } 1577 #if !LGE_SAO_MIGRATION_D0091 1563 1578 m_pcEntropyCoder->encodeSaoParam(pcAPS); 1579 #endif 1564 1580 m_pcEntropyCoder->encodeAPSAlfFlag( pcAPS->getAlfEnabled()?1:0); 1565 1581 if(pcAPS->getAlfEnabled()) -
branches/HTM-6.2-dev0/source/Lib/TLibEncoder/TEncSampleAdaptiveOffset.cpp
r296 r427 43 43 //! \ingroup TLibEncoder 44 44 //! \{ 45 45 #if LGE_SAO_MIGRATION_D0091 46 46 TEncSampleAdaptiveOffset::TEncSampleAdaptiveOffset() 47 47 { 48 m_pcEntropyCoder = NULL; 49 m_pppcRDSbacCoder = NULL; 50 m_pcRDGoOnSbacCoder = NULL; 51 m_pppcBinCoderCABAC = NULL; 52 m_iCount = NULL; 53 m_iOffset = NULL; 54 m_iOffsetOrg = NULL; 55 m_iRate = NULL; 56 m_iDist = NULL; 57 m_dCost = NULL; 58 m_dCostPartBest = NULL; 59 m_iDistOrg = NULL; 60 m_iTypePartBest = NULL; 61 } 48 m_pcEntropyCoder= NULL; 49 m_pppcRDSbacCoder = NULL; 50 m_pcRDGoOnSbacCoder = NULL; 51 m_pppcBinCoderCABAC = NULL; 52 m_iCount = NULL; 53 m_iOffset = NULL; 54 m_iOffsetOrg = NULL; 55 m_iRate = NULL; 56 m_iDist = NULL; 57 m_dCost = NULL; 58 m_dCostPartBest = NULL; 59 m_iDistOrg = NULL; 60 m_iTypePartBest = NULL; 61 #if SAO_ENCODING_CHOICE_CHROMA 62 m_depthSaoRate[0][0] = 0; 63 m_depthSaoRate[0][1] = 0; 64 m_depthSaoRate[0][2] = 0; 65 m_depthSaoRate[0][3] = 0; 66 m_depthSaoRate[1][0] = 0; 67 m_depthSaoRate[1][1] = 0; 68 m_depthSaoRate[1][2] = 0; 69 m_depthSaoRate[1][3] = 0; 70 #endif 71 } 72 62 73 TEncSampleAdaptiveOffset::~TEncSampleAdaptiveOffset() 63 74 { … … 76 87 { 77 88 #if FULL_NBIT 78 Int bitDepthMinus8 = g_uiBitDepth - 8;79 return ((x)>0) ? (Int)(((Int)(x)+(1<<(bitDepthMinus8-1)))/(1<<bitDepthMinus8)) : ((Int)(((Int)(x)-(1<<(bitDepthMinus8-1)))/(1<<bitDepthMinus8)));89 Int bitDepthMinus8 = g_uiBitDepth - 8; 90 return ((x)>0) ? (Int)(((Int)(x)+(1<<(bitDepthMinus8-1)))/(1<<bitDepthMinus8)) : ((Int)(((Int)(x)-(1<<(bitDepthMinus8-1)))/(1<<bitDepthMinus8))); 80 91 #else 81 return ((x)>0) ? (Int)(((Int)(x)+(1<<(g_uiBitIncrement-1)))/(1<<g_uiBitIncrement)) : ((Int)(((Int)(x)-(1<<(g_uiBitIncrement-1)))/(1<<g_uiBitIncrement)));92 return ((x)>0) ? (Int)(((Int)(x)+(1<<(g_uiBitIncrement-1)))/(1<<g_uiBitIncrement)) : ((Int)(((Int)(x)-(1<<(g_uiBitIncrement-1)))/(1<<g_uiBitIncrement))); 82 93 #endif 83 94 } … … 89 100 { 90 101 #if FULL_NBIT 91 return (g_uiBitDepth > 8 ? xRoundIbdi2((x)) : ((x)>=0 ? ((Int)((x)+0.5)) : ((Int)((x)-0.5)))) ;102 return (g_uiBitDepth > 8 ? xRoundIbdi2((x)) : ((x)>=0 ? ((Int)((x)+0.5)) : ((Int)((x)-0.5)))) ; 92 103 #else 93 return (g_uiBitIncrement >0 ? xRoundIbdi2((x)) : ((x)>=0 ? ((Int)((x)+0.5)) : ((Int)((x)-0.5)))) ; 94 #endif 95 } 96 97 104 return (g_uiBitIncrement >0 ? xRoundIbdi2((x)) : ((x)>=0 ? ((Int)((x)+0.5)) : ((Int)((x)-0.5)))) ; 105 #endif 106 } 98 107 99 108 /** process SAO for one partition 100 109 * \param *psQTPart, iPartIdx, dLambda 101 110 */ 102 Void TEncSampleAdaptiveOffset::rdoSaoOnePart(SAOQTPart *psQTPart, Int iPartIdx, Double dLambda) 103 { 104 Int iTypeIdx; 105 Int iNumTotalType = MAX_NUM_SAO_TYPE; 106 SAOQTPart* pOnePart = &(psQTPart[iPartIdx]); 107 108 Int64 iEstDist; 109 Int64 iOffsetOrg; 110 Int64 iOffset; 111 Int64 iCount; 112 Int iClassIdx; 113 Int uiShift = g_uiBitIncrement << 1; 114 UInt uiDepth = pOnePart->PartLevel; 115 116 m_iDistOrg [iPartIdx] = 0; 117 118 Double bestRDCostTableBo = MAX_DOUBLE; 119 Int bestClassTableBo = 0; 120 Int currentDistortionTableBo[MAX_NUM_SAO_CLASS]; 121 Double currentRdCostTableBo[MAX_NUM_SAO_CLASS]; 122 123 #if HHI_INTERVIEW_SKIP 124 Int iFrameWidthInCU = m_pcPic->getFrameWidthInCU(); 125 Int LcuIdxX = psQTPart->StartCUX; 126 Int LcuIdxY = psQTPart->StartCUY; 127 Int iAddr = LcuIdxY*iFrameWidthInCU + LcuIdxX; 128 TComDataCU *pcCU = m_pcPic->getCU(iAddr); 129 Bool bRenderable = pcCU->getRenderable(0) ; 130 131 #endif 132 for (iTypeIdx=-1; iTypeIdx<iNumTotalType; iTypeIdx++) 133 { 134 if( m_bUseSBACRD ) 135 { 136 m_pcRDGoOnSbacCoder->load(m_pppcRDSbacCoder[uiDepth][CI_CURR_BEST]); 137 m_pcRDGoOnSbacCoder->resetBits(); 111 Void TEncSampleAdaptiveOffset::rdoSaoOnePart(SAOQTPart *psQTPart, Int iPartIdx, Double dLambda, Int yCbCr) 112 { 113 Int iTypeIdx; 114 Int iNumTotalType = MAX_NUM_SAO_TYPE; 115 SAOQTPart* pOnePart = &(psQTPart[iPartIdx]); 116 117 Int64 iEstDist; 118 Int iClassIdx; 119 Int uiShift = g_uiBitIncrement << 1; 120 UInt uiDepth = pOnePart->PartLevel; 121 122 m_iDistOrg [iPartIdx] = 0; 123 124 Double bestRDCostTableBo = MAX_DOUBLE; 125 Int bestClassTableBo = 0; 126 Int currentDistortionTableBo[MAX_NUM_SAO_CLASS]; 127 Double currentRdCostTableBo[MAX_NUM_SAO_CLASS]; 128 129 Int addr; 130 Int allowMergeLeft; 131 Int allowMergeUp; 132 Int frameWidthInCU = m_pcPic->getFrameWidthInCU(); 133 SaoLcuParam saoLcuParamRdo; 134 135 for (iTypeIdx=-1; iTypeIdx<iNumTotalType; iTypeIdx++) 136 { 137 if( m_bUseSBACRD ) 138 { 139 m_pcRDGoOnSbacCoder->load(m_pppcRDSbacCoder[uiDepth][CI_CURR_BEST]); 140 m_pcRDGoOnSbacCoder->resetBits(); 141 } 142 else 143 { 144 m_pcEntropyCoder->resetEntropy(); 145 m_pcEntropyCoder->resetBits(); 146 } 147 148 iEstDist = 0; 149 150 if (iTypeIdx == -1) 151 { 152 for (Int ry = pOnePart->StartCUY; ry<= pOnePart->EndCUY; ry++) 153 { 154 for (Int rx = pOnePart->StartCUX; rx <= pOnePart->EndCUX; rx++) 155 { 156 addr = ry * frameWidthInCU + rx; 157 // get bits for iTypeIdx = -1 158 allowMergeLeft = 1; 159 allowMergeUp = 1; 160 if (rx != 0) 161 { 162 // check tile id and slice id 163 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())) 164 { 165 allowMergeLeft = 0; 166 } 167 } 168 if (ry!=0) 169 { 170 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())) 171 { 172 allowMergeUp = 0; 173 } 174 } 175 176 // reset 177 resetSaoUnit(&saoLcuParamRdo); 178 179 // set merge flag 180 saoLcuParamRdo.mergeUpFlag = 1; 181 saoLcuParamRdo.mergeLeftFlag = 1; 182 183 if (ry == pOnePart->StartCUY) 184 { 185 saoLcuParamRdo.mergeUpFlag = 0; 186 } 187 188 if (rx == pOnePart->StartCUX) 189 { 190 saoLcuParamRdo.mergeLeftFlag = 0; 191 } 192 193 m_pcEntropyCoder->encodeSaoUnitInterleaving(yCbCr, 1, rx, ry, &saoLcuParamRdo, 1, 1, allowMergeLeft, allowMergeUp); 194 195 } 196 } 197 } 198 199 if (iTypeIdx>=0) 200 { 201 iEstDist = estSaoTypeDist(iPartIdx, iTypeIdx, uiShift, dLambda, currentDistortionTableBo, currentRdCostTableBo); 202 if( iTypeIdx == SAO_BO ) 203 { 204 // Estimate Best Position 205 Double currentRDCost = 0.0; 206 207 for(Int i=0; i< SAO_MAX_BO_CLASSES -SAO_BO_LEN +1; i++) 208 { 209 currentRDCost = 0.0; 210 for(UInt uj = i; uj < i+SAO_BO_LEN; uj++) 211 { 212 currentRDCost += currentRdCostTableBo[uj]; 213 } 214 215 if( currentRDCost < bestRDCostTableBo) 216 { 217 bestRDCostTableBo = currentRDCost; 218 bestClassTableBo = i; 219 } 220 } 221 222 // Re code all Offsets 223 // Code Center 224 for(iClassIdx = bestClassTableBo; iClassIdx < bestClassTableBo+SAO_BO_LEN; iClassIdx++) 225 { 226 iEstDist += currentDistortionTableBo[iClassIdx]; 227 } 228 } 229 230 for (Int ry = pOnePart->StartCUY; ry<= pOnePart->EndCUY; ry++) 231 { 232 for (Int rx = pOnePart->StartCUX; rx <= pOnePart->EndCUX; rx++) 233 { 234 addr = ry * frameWidthInCU + rx; 235 236 // get bits for iTypeIdx = -1 237 allowMergeLeft = 1; 238 allowMergeUp = 1; 239 if (rx != 0) 240 { 241 // check tile id and slice id 242 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())) 243 { 244 allowMergeLeft = 0; 245 } 246 } 247 if (ry!=0) 248 { 249 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())) 250 { 251 allowMergeUp = 0; 252 } 253 } 254 255 // reset 256 resetSaoUnit(&saoLcuParamRdo); 257 258 // set merge flag 259 saoLcuParamRdo.mergeUpFlag = 1; 260 saoLcuParamRdo.mergeLeftFlag = 1; 261 262 if (ry == pOnePart->StartCUY) 263 { 264 saoLcuParamRdo.mergeUpFlag = 0; 265 } 266 267 if (rx == pOnePart->StartCUX) 268 { 269 saoLcuParamRdo.mergeLeftFlag = 0; 270 } 271 272 // set type and offsets 273 saoLcuParamRdo.typeIdx = iTypeIdx; 274 saoLcuParamRdo.subTypeIdx = (iTypeIdx==SAO_BO)?bestClassTableBo:0; 275 saoLcuParamRdo.length = m_iNumClass[iTypeIdx]; 276 for (iClassIdx = 0; iClassIdx < saoLcuParamRdo.length; iClassIdx++) 277 { 278 saoLcuParamRdo.offset[iClassIdx] = (Int)m_iOffset[iPartIdx][iTypeIdx][iClassIdx+saoLcuParamRdo.subTypeIdx+1]; 279 } 280 281 m_pcEntropyCoder->encodeSaoUnitInterleaving(yCbCr, 1, rx, ry, &saoLcuParamRdo, 1, 1, allowMergeLeft, allowMergeUp); 282 283 } 284 } 285 286 m_iDist[iPartIdx][iTypeIdx] = iEstDist; 287 m_iRate[iPartIdx][iTypeIdx] = m_pcEntropyCoder->getNumberOfWrittenBits(); 288 289 m_dCost[iPartIdx][iTypeIdx] = (Double)((Double)m_iDist[iPartIdx][iTypeIdx] + dLambda * (Double) m_iRate[iPartIdx][iTypeIdx]); 290 291 if(m_dCost[iPartIdx][iTypeIdx] < m_dCostPartBest[iPartIdx]) 292 { 293 m_iDistOrg [iPartIdx] = 0; 294 m_dCostPartBest[iPartIdx] = m_dCost[iPartIdx][iTypeIdx]; 295 m_iTypePartBest[iPartIdx] = iTypeIdx; 296 if( m_bUseSBACRD ) 297 m_pcRDGoOnSbacCoder->store( m_pppcRDSbacCoder[pOnePart->PartLevel][CI_TEMP_BEST] ); 298 } 299 } 300 else 301 { 302 if(m_iDistOrg[iPartIdx] < m_dCostPartBest[iPartIdx] ) 303 { 304 m_dCostPartBest[iPartIdx] = (Double) m_iDistOrg[iPartIdx] + m_pcEntropyCoder->getNumberOfWrittenBits()*dLambda ; 305 m_iTypePartBest[iPartIdx] = -1; 306 if( m_bUseSBACRD ) 307 m_pcRDGoOnSbacCoder->store( m_pppcRDSbacCoder[pOnePart->PartLevel][CI_TEMP_BEST] ); 308 } 309 } 310 } 311 312 pOnePart->bProcessed = true; 313 pOnePart->bSplit = false; 314 pOnePart->iMinDist = m_iTypePartBest[iPartIdx] >= 0 ? m_iDist[iPartIdx][m_iTypePartBest[iPartIdx]] : m_iDistOrg[iPartIdx]; 315 pOnePart->iMinRate = (Int) (m_iTypePartBest[iPartIdx] >= 0 ? m_iRate[iPartIdx][m_iTypePartBest[iPartIdx]] : 0); 316 pOnePart->dMinCost = pOnePart->iMinDist + dLambda * pOnePart->iMinRate; 317 pOnePart->iBestType = m_iTypePartBest[iPartIdx]; 318 if (pOnePart->iBestType != -1) 319 { 320 // pOnePart->bEnableFlag = 1; 321 pOnePart->iLength = m_iNumClass[pOnePart->iBestType]; 322 Int minIndex = 0; 323 if( pOnePart->iBestType == SAO_BO ) 324 { 325 pOnePart->subTypeIdx = bestClassTableBo; 326 minIndex = pOnePart->subTypeIdx; 327 } 328 for (Int i=0; i< pOnePart->iLength ; i++) 329 { 330 pOnePart->iOffset[i] = (Int) m_iOffset[iPartIdx][pOnePart->iBestType][minIndex+i+1]; 331 } 332 138 333 } 139 334 else 140 335 { 141 m_pcEntropyCoder->resetEntropy(); 142 m_pcEntropyCoder->resetBits(); 143 } 144 145 iEstDist = 0; 146 147 m_pcEntropyCoder->m_pcEntropyCoderIf->codeSaoTypeIdx(iTypeIdx+1); 148 149 if (iTypeIdx>=0) 150 { 151 152 for(iClassIdx=1; iClassIdx < ( (iTypeIdx < SAO_BO) ? m_iNumClass[iTypeIdx]+1 : SAO_MAX_BO_CLASSES+1); iClassIdx++) 153 { 154 if( iTypeIdx == SAO_BO) 155 { 156 currentDistortionTableBo[iClassIdx-1] = 0; 157 currentRdCostTableBo[iClassIdx-1] = dLambda; 158 } 159 #if HHI_INTERVIEW_SKIP 160 if(m_iCount [iPartIdx][iTypeIdx][iClassIdx] && !bRenderable) 161 #else 162 if(m_iCount [iPartIdx][iTypeIdx][iClassIdx]) 163 #endif 164 { 165 #if FULL_NBIT 166 m_iOffset[iPartIdx][iTypeIdx][iClassIdx] = (Int64) xRoundIbdi((Double)(m_iOffsetOrg[iPartIdx][iTypeIdx][iClassIdx]<<g_uiBitDepth-8) / (Double)(m_iCount [iPartIdx][iTypeIdx][iClassIdx]<<m_uiSaoBitIncrease)); 167 #else 168 m_iOffset[iPartIdx][iTypeIdx][iClassIdx] = (Int64) xRoundIbdi((Double)(m_iOffsetOrg[iPartIdx][iTypeIdx][iClassIdx]<<g_uiBitIncrement) / (Double)(m_iCount [iPartIdx][iTypeIdx][iClassIdx]<<m_uiSaoBitIncrease)); 169 #endif 170 m_iOffset[iPartIdx][iTypeIdx][iClassIdx] = Clip3(-m_iOffsetTh, m_iOffsetTh-1, (Int)m_iOffset[iPartIdx][iTypeIdx][iClassIdx]); 171 172 if (iTypeIdx < 4) 173 { 174 if ( m_iOffset[iPartIdx][iTypeIdx][iClassIdx]<0 && iClassIdx<3 ) 175 { 176 m_iOffset[iPartIdx][iTypeIdx][iClassIdx] = 0; 177 } 178 if ( m_iOffset[iPartIdx][iTypeIdx][iClassIdx]>0 && iClassIdx>=3) 179 { 180 m_iOffset[iPartIdx][iTypeIdx][iClassIdx] = 0; 181 } 182 } 183 { 184 //Clean up, best_q_offset. 185 Int64 iIterOffset, iTempOffset; 186 Int64 iTempDist, iTempRate; 187 Double dTempCost, dTempMinCost; 188 UInt uiLength, uiTemp; 189 190 iIterOffset = m_iOffset[iPartIdx][iTypeIdx][iClassIdx]; 191 m_iOffset[iPartIdx][iTypeIdx][iClassIdx] = 0; 192 dTempMinCost = dLambda; // 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. 193 194 while (iIterOffset != 0) 195 { 196 // Calculate the bits required for signalling the offset 197 uiLength = 1; 198 uiTemp = (UInt)((iIterOffset <= 0) ? ( (-iIterOffset<<1) + 1 ) : (iIterOffset<<1)); 199 while( 1 != uiTemp ) 200 { 201 uiTemp >>= 1; 202 uiLength += 2; 203 } 204 iTempRate = (uiLength >> 1) + ((uiLength+1) >> 1); 205 206 // Do the dequntization before distorion calculation 207 iTempOffset = iIterOffset << m_uiSaoBitIncrease; 208 iTempDist = (( m_iCount [iPartIdx][iTypeIdx][iClassIdx]*iTempOffset*iTempOffset-m_iOffsetOrg[iPartIdx][iTypeIdx][iClassIdx]*iTempOffset*2 ) >> uiShift); 209 210 dTempCost = ((Double)iTempDist + dLambda * (Double) iTempRate); 211 if(dTempCost < dTempMinCost) 212 { 213 dTempMinCost = dTempCost; 214 m_iOffset[iPartIdx][iTypeIdx][iClassIdx] = iIterOffset; 215 if(iTypeIdx == SAO_BO) 216 { 217 currentDistortionTableBo[iClassIdx-1] = (Int) iTempDist; 218 currentRdCostTableBo[iClassIdx-1] = dTempCost; 219 } 220 } 221 iIterOffset = (iIterOffset > 0) ? (iIterOffset-1):(iIterOffset+1); 222 } 223 224 } 225 } 226 else 227 { 228 m_iOffsetOrg[iPartIdx][iTypeIdx][iClassIdx] = 0; 229 m_iOffset[iPartIdx][iTypeIdx][iClassIdx] = 0; 230 } 231 if( iTypeIdx != SAO_BO ) 232 { 233 iCount = m_iCount [iPartIdx][iTypeIdx][iClassIdx]; 234 iOffset = m_iOffset[iPartIdx][iTypeIdx][iClassIdx] << m_uiSaoBitIncrease; 235 iOffsetOrg = m_iOffsetOrg[iPartIdx][iTypeIdx][iClassIdx]; 236 iEstDist += (( iCount*iOffset*iOffset-iOffsetOrg*iOffset*2 ) >> uiShift); 237 if (iTypeIdx < 4) 238 { 239 if (iClassIdx<3) 240 { 241 m_pcEntropyCoder->m_pcEntropyCoderIf->codeSaoUvlc((Int)m_iOffset[iPartIdx][iTypeIdx][iClassIdx]); 242 } 243 else 244 { 245 m_pcEntropyCoder->m_pcEntropyCoderIf->codeSaoUvlc((Int)-m_iOffset[iPartIdx][iTypeIdx][iClassIdx]); 246 } 247 } 248 else 249 { 250 m_pcEntropyCoder->m_pcEntropyCoderIf->codeSaoSvlc((Int)m_iOffset[iPartIdx][iTypeIdx][iClassIdx]); 251 } 252 } 253 } 254 255 if( iTypeIdx == SAO_BO ) 256 { 257 // Estimate Best Position 258 Double currentRDCost = 0.0; 259 260 for(Int i=0; i< SAO_MAX_BO_CLASSES -SAO_BO_LEN +1; i++) 261 { 262 currentRDCost = 0.0; 263 for(UInt uj = i; uj < i+SAO_BO_LEN; uj++) 264 { 265 currentRDCost += currentRdCostTableBo[uj]; 266 } 267 268 if( currentRDCost < bestRDCostTableBo) 269 { 270 bestRDCostTableBo = currentRDCost; 271 bestClassTableBo = i; 272 } 273 } 274 275 // Re code all Offsets 276 // Code Center 277 m_pcEntropyCoder->m_pcEntropyCoderIf->codeSaoUflc( (UInt) (bestClassTableBo) ); 278 279 for(iClassIdx = bestClassTableBo; iClassIdx < bestClassTableBo+SAO_BO_LEN; iClassIdx++) 280 { 281 m_pcEntropyCoder->m_pcEntropyCoderIf->codeSaoSvlc((Int)m_iOffset[iPartIdx][iTypeIdx][iClassIdx+1]); 282 iEstDist += currentDistortionTableBo[iClassIdx]; 283 } 284 } 285 286 m_iDist[iPartIdx][iTypeIdx] = iEstDist; 287 m_iRate[iPartIdx][iTypeIdx] = m_pcEntropyCoder->getNumberOfWrittenBits(); 288 289 m_dCost[iPartIdx][iTypeIdx] = (Double)((Double)m_iDist[iPartIdx][iTypeIdx] + dLambda * (Double) m_iRate[iPartIdx][iTypeIdx]); 290 291 if(m_dCost[iPartIdx][iTypeIdx] < m_dCostPartBest[iPartIdx]) 292 { 293 m_iDistOrg [iPartIdx] = 0; 294 m_dCostPartBest[iPartIdx] = m_dCost[iPartIdx][iTypeIdx]; 295 m_iTypePartBest[iPartIdx] = iTypeIdx; 296 if( m_bUseSBACRD ) 297 m_pcRDGoOnSbacCoder->store( m_pppcRDSbacCoder[pOnePart->PartLevel][CI_TEMP_BEST] ); 298 } 299 } 300 else 301 { 302 if(m_iDistOrg[iPartIdx] < m_dCostPartBest[iPartIdx] ) 303 { 304 m_dCostPartBest[iPartIdx] = (Double) m_iDistOrg[iPartIdx] + m_pcEntropyCoder->getNumberOfWrittenBits()*dLambda ; 305 m_iTypePartBest[iPartIdx] = -1; 306 if( m_bUseSBACRD ) 307 m_pcRDGoOnSbacCoder->store( m_pppcRDSbacCoder[pOnePart->PartLevel][CI_TEMP_BEST] ); 308 } 309 } 310 } 311 312 pOnePart->bProcessed = true; 313 pOnePart->bSplit = false; 314 pOnePart->iMinDist = m_iTypePartBest[iPartIdx] >= 0 ? m_iDist[iPartIdx][m_iTypePartBest[iPartIdx]] : m_iDistOrg[iPartIdx]; 315 pOnePart->iMinRate = (Int) (m_iTypePartBest[iPartIdx] >= 0 ? m_iRate[iPartIdx][m_iTypePartBest[iPartIdx]] : 0); 316 pOnePart->dMinCost = pOnePart->iMinDist + dLambda * pOnePart->iMinRate; 317 pOnePart->iBestType = m_iTypePartBest[iPartIdx]; 318 if (pOnePart->iBestType != -1) 319 { 320 // pOnePart->bEnableFlag = 1; 321 pOnePart->iLength = m_iNumClass[pOnePart->iBestType]; 322 Int minIndex = 0; 323 if( pOnePart->iBestType == SAO_BO ) 324 { 325 pOnePart->bandPosition = bestClassTableBo; 326 minIndex = pOnePart->bandPosition; 327 } 328 for (Int i=0; i< pOnePart->iLength ; i++) 329 { 330 pOnePart->iOffset[i] = (Int) m_iOffset[iPartIdx][pOnePart->iBestType][minIndex+i+1]; 331 } 332 333 } 334 else 335 { 336 // pOnePart->bEnableFlag = 0; 337 pOnePart->iLength = 0; 338 } 336 // pOnePart->bEnableFlag = 0; 337 pOnePart->iLength = 0; 338 } 339 339 } 340 340 … … 343 343 Void TEncSampleAdaptiveOffset::disablePartTree(SAOQTPart *psQTPart, Int iPartIdx) 344 344 { 345 SAOQTPart* pOnePart= &(psQTPart[iPartIdx]);346 pOnePart->bSplit = false;347 pOnePart->iLength = 0;348 pOnePart->iBestType = -1;349 350 if (pOnePart->PartLevel < m_uiMaxSplitLevel)351 {352 for (Int i=0; i<NUM_DOWN_PART; i++)353 {354 disablePartTree(psQTPart, pOnePart->DownPartsIdx[i]);355 }356 }345 SAOQTPart* pOnePart= &(psQTPart[iPartIdx]); 346 pOnePart->bSplit = false; 347 pOnePart->iLength = 0; 348 pOnePart->iBestType = -1; 349 350 if (pOnePart->PartLevel < m_uiMaxSplitLevel) 351 { 352 for (Int i=0; i<NUM_DOWN_PART; i++) 353 { 354 disablePartTree(psQTPart, pOnePart->DownPartsIdx[i]); 355 } 356 } 357 357 } 358 358 … … 360 360 * \param iPartIdx, pcPicOrg, pcPicDec, pcPicRest, &dCostFinal 361 361 */ 362 Void TEncSampleAdaptiveOffset::runQuadTreeDecision(SAOQTPart *psQTPart, Int iPartIdx, Double &dCostFinal, Int iMaxLevel, Double dLambda) 363 { 364 SAOQTPart* pOnePart = &(psQTPart[iPartIdx]); 365 366 UInt uiDepth = pOnePart->PartLevel; 367 UInt uhNextDepth = uiDepth+1; 368 369 if (iPartIdx == 0) 370 { 371 dCostFinal = 0; 372 } 373 374 //SAO for this part 375 if(!pOnePart->bProcessed) 376 { 377 rdoSaoOnePart (psQTPart, iPartIdx, dLambda); 378 } 379 380 //SAO for sub 4 parts 381 if (pOnePart->PartLevel < iMaxLevel) 382 { 383 Double dCostNotSplit = dLambda + pOnePart->dMinCost; 384 Double dCostSplit = dLambda; 385 386 for (Int i=0; i< NUM_DOWN_PART ;i++) 387 { 388 if( m_bUseSBACRD ) 389 { 390 if ( 0 == i) //initialize RD with previous depth buffer 391 { 392 m_pppcRDSbacCoder[uhNextDepth][CI_CURR_BEST]->load(m_pppcRDSbacCoder[uiDepth][CI_CURR_BEST]); 362 Void TEncSampleAdaptiveOffset::runQuadTreeDecision(SAOQTPart *psQTPart, Int iPartIdx, Double &dCostFinal, Int iMaxLevel, Double dLambda, Int yCbCr) 363 { 364 SAOQTPart* pOnePart = &(psQTPart[iPartIdx]); 365 366 UInt uiDepth = pOnePart->PartLevel; 367 UInt uhNextDepth = uiDepth+1; 368 369 if (iPartIdx == 0) 370 { 371 dCostFinal = 0; 372 } 373 374 //SAO for this part 375 if(!pOnePart->bProcessed) 376 { 377 rdoSaoOnePart (psQTPart, iPartIdx, dLambda, yCbCr); 378 } 379 380 //SAO for sub 4 parts 381 if (pOnePart->PartLevel < iMaxLevel) 382 { 383 Double dCostNotSplit = dLambda + pOnePart->dMinCost; 384 Double dCostSplit = dLambda; 385 386 for (Int i=0; i< NUM_DOWN_PART ;i++) 387 { 388 if( m_bUseSBACRD ) 389 { 390 if ( 0 == i) //initialize RD with previous depth buffer 391 { 392 m_pppcRDSbacCoder[uhNextDepth][CI_CURR_BEST]->load(m_pppcRDSbacCoder[uiDepth][CI_CURR_BEST]); 393 } 394 else 395 { 396 m_pppcRDSbacCoder[uhNextDepth][CI_CURR_BEST]->load(m_pppcRDSbacCoder[uhNextDepth][CI_NEXT_BEST]); 397 } 398 } 399 runQuadTreeDecision(psQTPart, pOnePart->DownPartsIdx[i], dCostFinal, iMaxLevel, dLambda, yCbCr); 400 dCostSplit += dCostFinal; 401 if( m_bUseSBACRD ) 402 { 403 m_pppcRDSbacCoder[uhNextDepth][CI_NEXT_BEST]->load(m_pppcRDSbacCoder[uhNextDepth][CI_TEMP_BEST]); 404 } 405 } 406 407 if(dCostSplit < dCostNotSplit) 408 { 409 dCostFinal = dCostSplit; 410 pOnePart->bSplit = true; 411 pOnePart->iLength = 0; 412 pOnePart->iBestType = -1; 413 if( m_bUseSBACRD ) 414 { 415 m_pppcRDSbacCoder[uiDepth][CI_NEXT_BEST]->load(m_pppcRDSbacCoder[uhNextDepth][CI_NEXT_BEST]); 416 } 393 417 } 394 418 else 395 419 { 396 m_pppcRDSbacCoder[uhNextDepth][CI_CURR_BEST]->load(m_pppcRDSbacCoder[uhNextDepth][CI_NEXT_BEST]); 397 } 398 } 399 runQuadTreeDecision(psQTPart, pOnePart->DownPartsIdx[i], dCostFinal, iMaxLevel, dLambda); 400 dCostSplit += dCostFinal; 401 if( m_bUseSBACRD ) 402 { 403 m_pppcRDSbacCoder[uhNextDepth][CI_NEXT_BEST]->load(m_pppcRDSbacCoder[uhNextDepth][CI_TEMP_BEST]); 404 } 405 } 406 407 if(dCostSplit < dCostNotSplit) 408 { 409 dCostFinal = dCostSplit; 410 pOnePart->bSplit = true; 411 pOnePart->iLength = 0; 412 pOnePart->iBestType = -1; 413 if( m_bUseSBACRD ) 414 { 415 m_pppcRDSbacCoder[uiDepth][CI_NEXT_BEST]->load(m_pppcRDSbacCoder[uhNextDepth][CI_NEXT_BEST]); 416 } 420 dCostFinal = dCostNotSplit; 421 pOnePart->bSplit = false; 422 for (Int i=0; i<NUM_DOWN_PART; i++) 423 { 424 disablePartTree(psQTPart, pOnePart->DownPartsIdx[i]); 425 } 426 if( m_bUseSBACRD ) 427 { 428 m_pppcRDSbacCoder[uiDepth][CI_NEXT_BEST]->load(m_pppcRDSbacCoder[uiDepth][CI_TEMP_BEST]); 429 } 430 } 417 431 } 418 432 else 419 433 { 420 dCostFinal = dCostNotSplit; 421 pOnePart->bSplit = false; 422 for (Int i=0; i<NUM_DOWN_PART; i++) 423 { 424 disablePartTree(psQTPart, pOnePart->DownPartsIdx[i]); 425 } 426 if( m_bUseSBACRD ) 427 { 428 m_pppcRDSbacCoder[uiDepth][CI_NEXT_BEST]->load(m_pppcRDSbacCoder[uiDepth][CI_TEMP_BEST]); 429 } 430 } 431 } 432 else 433 { 434 dCostFinal = pOnePart->dMinCost; 435 } 434 dCostFinal = pOnePart->dMinCost; 435 } 436 436 } 437 437 … … 446 446 if (m_iCount [i][j]) 447 447 { 448 delete [] m_iCount [i][j]; 448 delete [] m_iCount [i][j]; 449 449 } 450 450 if (m_iOffset[i][j]) … … 454 454 if (m_iOffsetOrg[i][j]) 455 455 { 456 delete [] m_iOffsetOrg[i][j]; 456 delete [] m_iOffsetOrg[i][j]; 457 457 } 458 458 } … … 463 463 if (m_iDist[i]) 464 464 { 465 delete [] m_iDist[i]; 465 delete [] m_iDist[i]; 466 466 } 467 467 if (m_dCost[i]) … … 471 471 if (m_iCount [i]) 472 472 { 473 delete [] m_iCount [i]; 473 delete [] m_iCount [i]; 474 474 } 475 475 if (m_iOffset[i]) … … 479 479 if (m_iOffsetOrg[i]) 480 480 { 481 delete [] m_iOffsetOrg[i]; 482 } 483 481 delete [] m_iOffsetOrg[i]; 482 } 484 483 } 485 484 if (m_iDistOrg) … … 518 517 { 519 518 delete [] m_iOffsetOrg ; m_iOffsetOrg = NULL; 519 } 520 Int numLcu = m_iNumCuInWidth * m_iNumCuInHeight; 521 522 for (Int i=0;i<numLcu;i++) 523 { 524 for (Int j=0;j<3;j++) 525 { 526 for (Int k=0;k<MAX_NUM_SAO_TYPE;k++) 527 { 528 if (m_count_PreDblk [i][j][k]) 529 { 530 delete [] m_count_PreDblk [i][j][k]; 531 } 532 if (m_offsetOrg_PreDblk[i][j][k]) 533 { 534 delete [] m_offsetOrg_PreDblk[i][j][k]; 535 } 536 } 537 if (m_count_PreDblk [i][j]) 538 { 539 delete [] m_count_PreDblk [i][j]; 540 } 541 if (m_offsetOrg_PreDblk[i][j]) 542 { 543 delete [] m_offsetOrg_PreDblk[i][j]; 544 } 545 } 546 if (m_count_PreDblk [i]) 547 { 548 delete [] m_count_PreDblk [i]; 549 } 550 if (m_offsetOrg_PreDblk[i]) 551 { 552 delete [] m_offsetOrg_PreDblk[i]; 553 } 554 } 555 if (m_count_PreDblk) 556 { 557 delete [] m_count_PreDblk ; m_count_PreDblk = NULL; 558 } 559 if (m_offsetOrg_PreDblk) 560 { 561 delete [] m_offsetOrg_PreDblk ; m_offsetOrg_PreDblk = NULL; 520 562 } 521 563 … … 546 588 Void TEncSampleAdaptiveOffset::createEncBuffer() 547 589 { 548 m_iDistOrg = new Int64 [m_iNumTotalParts]; 549 m_dCostPartBest = new Double [m_iNumTotalParts]; 550 m_iTypePartBest = new Int [m_iNumTotalParts]; 590 m_iDistOrg = new Int64 [m_iNumTotalParts]; 591 m_dCostPartBest = new Double [m_iNumTotalParts]; 592 m_iTypePartBest = new Int [m_iNumTotalParts]; 551 593 552 594 m_iRate = new Int64* [m_iNumTotalParts]; … … 561 603 { 562 604 m_iRate[i] = new Int64 [MAX_NUM_SAO_TYPE]; 563 m_iDist[i] = new Int64 [MAX_NUM_SAO_TYPE]; 564 m_dCost[i] = new Double [MAX_NUM_SAO_TYPE]; 565 566 m_iCount [i] = new Int64 *[MAX_NUM_SAO_TYPE]; 567 m_iOffset[i] = new Int64 *[MAX_NUM_SAO_TYPE]; 568 m_iOffsetOrg[i] = new Int64 *[MAX_NUM_SAO_TYPE]; 605 m_iDist[i] = new Int64 [MAX_NUM_SAO_TYPE]; 606 m_dCost[i] = new Double [MAX_NUM_SAO_TYPE]; 607 608 m_iCount [i] = new Int64 *[MAX_NUM_SAO_TYPE]; 609 m_iOffset[i] = new Int64 *[MAX_NUM_SAO_TYPE]; 610 m_iOffsetOrg[i] = new Int64 *[MAX_NUM_SAO_TYPE]; 569 611 570 612 for (Int j=0;j<MAX_NUM_SAO_TYPE;j++) 571 613 { 572 m_iCount [i][j] = new Int64 [MAX_NUM_SAO_CLASS]; 573 m_iOffset[i][j] = new Int64 [MAX_NUM_SAO_CLASS]; 574 m_iOffsetOrg[i][j]= new Int64 [MAX_NUM_SAO_CLASS]; 614 m_iCount [i][j] = new Int64 [MAX_NUM_SAO_CLASS]; 615 m_iOffset[i][j] = new Int64 [MAX_NUM_SAO_CLASS]; 616 m_iOffsetOrg[i][j]= new Int64 [MAX_NUM_SAO_CLASS]; 617 } 618 } 619 Int numLcu = m_iNumCuInWidth * m_iNumCuInHeight; 620 m_count_PreDblk = new Int64 ***[numLcu]; 621 m_offsetOrg_PreDblk = new Int64 ***[numLcu]; 622 for (Int i=0; i<numLcu; i++) 623 { 624 m_count_PreDblk[i] = new Int64 **[3]; 625 m_offsetOrg_PreDblk[i] = new Int64 **[3]; 626 627 for (Int j=0;j<3;j++) 628 { 629 m_count_PreDblk [i][j] = new Int64 *[MAX_NUM_SAO_TYPE]; 630 m_offsetOrg_PreDblk[i][j] = new Int64 *[MAX_NUM_SAO_TYPE]; 631 632 for (Int k=0;k<MAX_NUM_SAO_TYPE;k++) 633 { 634 m_count_PreDblk [i][j][k] = new Int64 [MAX_NUM_SAO_CLASS]; 635 m_offsetOrg_PreDblk[i][j][k]= new Int64 [MAX_NUM_SAO_CLASS]; 636 } 575 637 } 576 638 } … … 606 668 607 669 /** Start SAO encoder 608 * \param pcPic, pcEntropyCoder, pppcRDSbacCoder, pcRDGoOnSbacCoder 670 * \param pcPic, pcEntropyCoder, pppcRDSbacCoder, pcRDGoOnSbacCoder 609 671 */ 610 672 Void TEncSampleAdaptiveOffset::startSaoEnc( TComPic* pcPic, TEncEntropy* pcEntropyCoder, TEncSbac*** pppcRDSbacCoder, TEncSbac* pcRDGoOnSbacCoder) 611 673 { 612 if( pcRDGoOnSbacCoder ) 613 m_bUseSBACRD = true; 614 else 615 m_bUseSBACRD = false; 616 674 m_bUseSBACRD = true; 617 675 m_pcPic = pcPic; 618 676 m_pcEntropyCoder = pcEntropyCoder; 619 677 620 678 m_pcRDGoOnSbacCoder = pcRDGoOnSbacCoder; 679 m_pcEntropyCoder->setEntropyCoder(m_pcRDGoOnSbacCoder, pcPic->getSlice(0)); 621 680 m_pcEntropyCoder->resetEntropy(); 622 681 m_pcEntropyCoder->resetBits(); … … 672 731 if (classIdx) 673 732 { 674 stats[classIdx] += (pOrg[x] - pRec[x]); 733 stats[classIdx] += (pOrg[x] - pRec[x]); 675 734 count[classIdx] ++; 676 735 } … … 685 744 pRec = pRecStart; 686 745 687 688 746 startX = (pbBorderAvail[SGU_L]) ? 0 : 1; 689 747 endX = (pbBorderAvail[SGU_R]) ? width : (width -1); … … 693 751 for (x=startX; x< endX; x++) 694 752 { 695 signRight = xSign(pRec[x] - pRec[x+1]); 753 signRight = xSign(pRec[x] - pRec[x+1]); 696 754 edgeType = signRight + signLeft + 2; 697 755 signLeft = -signRight; … … 726 784 for (x=0; x< width; x++) 727 785 { 728 signDown = xSign(pRec[x] - pRec[x+stride]); 786 signDown = xSign(pRec[x] - pRec[x+stride]); 729 787 edgeType = signDown + m_iUpBuff1[x] + 2; 730 788 m_iUpBuff1[x] = -signDown; … … 785 843 count[m_auiEoTable[edgeType]] ++; 786 844 787 m_iUpBufft[x+1] = -signDown1; 845 m_iUpBufft[x+1] = -signDown1; 788 846 } 789 847 m_iUpBufft[startX] = xSign(pRec[stride+startX] - pRec[startX-1]); … … 931 989 posOffset = (yPos* stride) + xPos; 932 990 933 #if HHI_INTERVIEW_SKIP934 if( !m_pcPic->getCU(iAddr)->getRenderable(0 ))935 {936 991 calcSaoStatsBlock(pPicRec+ posOffset, pPicOrg+ posOffset, stride, ppStats, ppCount,width, height, pbBorderAvail); 937 } 938 #else 939 calcSaoStatsBlock(pPicRec+ posOffset, pPicOrg+ posOffset, stride, ppStats, ppCount,width, height, pbBorderAvail); 940 #endif 941 } 942 } 943 992 } 993 } 944 994 } 945 995 … … 974 1024 Int iIsChroma = (iYCbCr!=0)? 1:0; 975 1025 Int numSkipLine = iIsChroma? 2:4; 1026 if (m_saoLcuBasedOptimization == 0) 1027 { 1028 numSkipLine = 0; 1029 } 1030 1031 #if SAO_SKIP_RIGHT 1032 Int numSkipLineRight = iIsChroma? 3:5; 1033 if (m_saoLcuBasedOptimization == 0) 1034 { 1035 numSkipLineRight = 0; 1036 } 1037 #endif 1038 1039 iPicWidthTmp = m_iPicWidth >> iIsChroma; 1040 iPicHeightTmp = m_iPicHeight >> iIsChroma; 1041 iLcuWidth = iLcuWidth >> iIsChroma; 1042 iLcuHeight = iLcuHeight >> iIsChroma; 1043 uiLPelX = uiLPelX >> iIsChroma; 1044 uiTPelY = uiTPelY >> iIsChroma; 1045 uiRPelX = uiLPelX + iLcuWidth ; 1046 uiBPelY = uiTPelY + iLcuHeight ; 1047 uiRPelX = uiRPelX > iPicWidthTmp ? iPicWidthTmp : uiRPelX; 1048 uiBPelY = uiBPelY > iPicHeightTmp ? iPicHeightTmp : uiBPelY; 1049 iLcuWidth = uiRPelX - uiLPelX; 1050 iLcuHeight = uiBPelY - uiTPelY; 1051 1052 iStride = (iYCbCr == 0)? m_pcPic->getStride(): m_pcPic->getCStride(); 1053 1054 //if(iSaoType == BO_0 || iSaoType == BO_1) 1055 { 1056 if( m_saoLcuBasedOptimization && m_saoLcuBoundary ) 1057 { 1058 numSkipLine = iIsChroma? 1:3; 1059 numSkipLineRight = iIsChroma? 2:4; 1060 } 1061 iStats = m_iOffsetOrg[iPartIdx][SAO_BO]; 1062 iCount = m_iCount [iPartIdx][SAO_BO]; 1063 1064 pOrg = getPicYuvAddr(m_pcPic->getPicYuvOrg(), iYCbCr, iAddr); 1065 pRec = getPicYuvAddr(m_pcPic->getPicYuvRec(), iYCbCr, iAddr); 1066 1067 #if SAO_SKIP_RIGHT 1068 iEndX = (uiRPelX == iPicWidthTmp) ? iLcuWidth : iLcuWidth-numSkipLineRight; 1069 #endif 1070 1071 iEndY = (uiBPelY == iPicHeightTmp) ? iLcuHeight : iLcuHeight-numSkipLine; 1072 for (y=0; y<iEndY; y++) 1073 { 1074 #if SAO_SKIP_RIGHT 1075 for (x=0; x<iEndX; x++) 1076 #else 1077 for (x=0; x<iLcuWidth; x++) 1078 #endif 1079 { 1080 iClassIdx = m_lumaTableBo[pRec[x]]; 1081 if (iClassIdx) 1082 { 1083 iStats[iClassIdx] += (pOrg[x] - pRec[x]); 1084 iCount[iClassIdx] ++; 1085 } 1086 } 1087 pOrg += iStride; 1088 pRec += iStride; 1089 } 1090 1091 } 1092 Int iSignLeft; 1093 Int iSignRight; 1094 Int iSignDown; 1095 Int iSignDown1; 1096 Int iSignDown2; 1097 1098 UInt uiEdgeType; 1099 1100 //if (iSaoType == EO_0 || iSaoType == EO_1 || iSaoType == EO_2 || iSaoType == EO_3) 1101 { 1102 //if (iSaoType == EO_0) 1103 { 1104 if( m_saoLcuBasedOptimization && m_saoLcuBoundary ) 1105 { 1106 numSkipLine = iIsChroma? 1:3; 1107 numSkipLineRight = iIsChroma? 3:5; 1108 } 1109 iStats = m_iOffsetOrg[iPartIdx][SAO_EO_0]; 1110 iCount = m_iCount [iPartIdx][SAO_EO_0]; 1111 1112 pOrg = getPicYuvAddr(m_pcPic->getPicYuvOrg(), iYCbCr, iAddr); 1113 pRec = getPicYuvAddr(m_pcPic->getPicYuvRec(), iYCbCr, iAddr); 1114 1115 iStartX = (uiLPelX == 0) ? 1 : 0; 1116 #if SAO_SKIP_RIGHT 1117 iEndX = (uiRPelX == iPicWidthTmp) ? iLcuWidth-1 : iLcuWidth-numSkipLineRight; 1118 #else 1119 iEndX = (uiRPelX == iPicWidthTmp) ? iLcuWidth-1 : iLcuWidth; 1120 #endif 1121 for (y=0; y<iLcuHeight-numSkipLine; y++) 1122 { 1123 iSignLeft = xSign(pRec[iStartX] - pRec[iStartX-1]); 1124 for (x=iStartX; x< iEndX; x++) 1125 { 1126 iSignRight = xSign(pRec[x] - pRec[x+1]); 1127 uiEdgeType = iSignRight + iSignLeft + 2; 1128 iSignLeft = -iSignRight; 1129 1130 iStats[m_auiEoTable[uiEdgeType]] += (pOrg[x] - pRec[x]); 1131 iCount[m_auiEoTable[uiEdgeType]] ++; 1132 } 1133 pOrg += iStride; 1134 pRec += iStride; 1135 } 1136 } 1137 1138 //if (iSaoType == EO_1) 1139 { 1140 if( m_saoLcuBasedOptimization && m_saoLcuBoundary ) 1141 { 1142 numSkipLine = iIsChroma? 2:4; 1143 numSkipLineRight = iIsChroma? 2:4; 1144 } 1145 iStats = m_iOffsetOrg[iPartIdx][SAO_EO_1]; 1146 iCount = m_iCount [iPartIdx][SAO_EO_1]; 1147 1148 pOrg = getPicYuvAddr(m_pcPic->getPicYuvOrg(), iYCbCr, iAddr); 1149 pRec = getPicYuvAddr(m_pcPic->getPicYuvRec(), iYCbCr, iAddr); 1150 1151 iStartY = (uiTPelY == 0) ? 1 : 0; 1152 #if SAO_SKIP_RIGHT 1153 iEndX = (uiRPelX == iPicWidthTmp) ? iLcuWidth : iLcuWidth-numSkipLineRight; 1154 #endif 1155 iEndY = (uiBPelY == iPicHeightTmp) ? iLcuHeight-1 : iLcuHeight-numSkipLine; 1156 if (uiTPelY == 0) 1157 { 1158 pOrg += iStride; 1159 pRec += iStride; 1160 } 1161 1162 for (x=0; x< iLcuWidth; x++) 1163 { 1164 m_iUpBuff1[x] = xSign(pRec[x] - pRec[x-iStride]); 1165 } 1166 for (y=iStartY; y<iEndY; y++) 1167 { 1168 #if SAO_SKIP_RIGHT 1169 for (x=0; x<iEndX; x++) 1170 #else 1171 for (x=0; x<iLcuWidth; x++) 1172 #endif 1173 { 1174 iSignDown = xSign(pRec[x] - pRec[x+iStride]); 1175 uiEdgeType = iSignDown + m_iUpBuff1[x] + 2; 1176 m_iUpBuff1[x] = -iSignDown; 1177 1178 iStats[m_auiEoTable[uiEdgeType]] += (pOrg[x] - pRec[x]); 1179 iCount[m_auiEoTable[uiEdgeType]] ++; 1180 } 1181 pOrg += iStride; 1182 pRec += iStride; 1183 } 1184 } 1185 //if (iSaoType == EO_2) 1186 { 1187 if( m_saoLcuBasedOptimization && m_saoLcuBoundary ) 1188 { 1189 numSkipLine = iIsChroma? 2:4; 1190 numSkipLineRight = iIsChroma? 3:5; 1191 } 1192 iStats = m_iOffsetOrg[iPartIdx][SAO_EO_2]; 1193 iCount = m_iCount [iPartIdx][SAO_EO_2]; 1194 1195 pOrg = getPicYuvAddr(m_pcPic->getPicYuvOrg(), iYCbCr, iAddr); 1196 pRec = getPicYuvAddr(m_pcPic->getPicYuvRec(), iYCbCr, iAddr); 1197 1198 iStartX = (uiLPelX == 0) ? 1 : 0; 1199 #if SAO_SKIP_RIGHT 1200 iEndX = (uiRPelX == iPicWidthTmp) ? iLcuWidth-1 : iLcuWidth-numSkipLineRight; 1201 #else 1202 iEndX = (uiRPelX == iPicWidthTmp) ? iLcuWidth-1 : iLcuWidth; 1203 #endif 1204 1205 iStartY = (uiTPelY == 0) ? 1 : 0; 1206 iEndY = (uiBPelY == iPicHeightTmp) ? iLcuHeight-1 : iLcuHeight-numSkipLine; 1207 if (uiTPelY == 0) 1208 { 1209 pOrg += iStride; 1210 pRec += iStride; 1211 } 1212 1213 for (x=iStartX; x<iEndX; x++) 1214 { 1215 m_iUpBuff1[x] = xSign(pRec[x] - pRec[x-iStride-1]); 1216 } 1217 for (y=iStartY; y<iEndY; y++) 1218 { 1219 iSignDown2 = xSign(pRec[iStride+iStartX] - pRec[iStartX-1]); 1220 for (x=iStartX; x<iEndX; x++) 1221 { 1222 iSignDown1 = xSign(pRec[x] - pRec[x+iStride+1]) ; 1223 uiEdgeType = iSignDown1 + m_iUpBuff1[x] + 2; 1224 m_iUpBufft[x+1] = -iSignDown1; 1225 iStats[m_auiEoTable[uiEdgeType]] += (pOrg[x] - pRec[x]); 1226 iCount[m_auiEoTable[uiEdgeType]] ++; 1227 } 1228 m_iUpBufft[iStartX] = iSignDown2; 1229 ipSwap = m_iUpBuff1; 1230 m_iUpBuff1 = m_iUpBufft; 1231 m_iUpBufft = ipSwap; 1232 1233 pRec += iStride; 1234 pOrg += iStride; 1235 } 1236 } 1237 //if (iSaoType == EO_3 ) 1238 { 1239 if( m_saoLcuBasedOptimization && m_saoLcuBoundary ) 1240 { 1241 numSkipLine = iIsChroma? 2:4; 1242 numSkipLineRight = iIsChroma? 3:5; 1243 } 1244 iStats = m_iOffsetOrg[iPartIdx][SAO_EO_3]; 1245 iCount = m_iCount [iPartIdx][SAO_EO_3]; 1246 1247 pOrg = getPicYuvAddr(m_pcPic->getPicYuvOrg(), iYCbCr, iAddr); 1248 pRec = getPicYuvAddr(m_pcPic->getPicYuvRec(), iYCbCr, iAddr); 1249 1250 iStartX = (uiLPelX == 0) ? 1 : 0; 1251 #if SAO_SKIP_RIGHT 1252 iEndX = (uiRPelX == iPicWidthTmp) ? iLcuWidth-1 : iLcuWidth-numSkipLineRight; 1253 #else 1254 iEndX = (uiRPelX == iPicWidthTmp) ? iLcuWidth-1 : iLcuWidth; 1255 #endif 1256 1257 iStartY = (uiTPelY == 0) ? 1 : 0; 1258 iEndY = (uiBPelY == iPicHeightTmp) ? iLcuHeight-1 : iLcuHeight-numSkipLine; 1259 if (iStartY == 1) 1260 { 1261 pOrg += iStride; 1262 pRec += iStride; 1263 } 1264 1265 for (x=iStartX-1; x<iEndX; x++) 1266 { 1267 m_iUpBuff1[x] = xSign(pRec[x] - pRec[x-iStride+1]); 1268 } 1269 1270 for (y=iStartY; y<iEndY; y++) 1271 { 1272 for (x=iStartX; x<iEndX; x++) 1273 { 1274 iSignDown1 = xSign(pRec[x] - pRec[x+iStride-1]) ; 1275 uiEdgeType = iSignDown1 + m_iUpBuff1[x] + 2; 1276 m_iUpBuff1[x-1] = -iSignDown1; 1277 iStats[m_auiEoTable[uiEdgeType]] += (pOrg[x] - pRec[x]); 1278 iCount[m_auiEoTable[uiEdgeType]] ++; 1279 } 1280 m_iUpBuff1[iEndX-1] = xSign(pRec[iEndX-1 + iStride] - pRec[iEndX]); 1281 1282 pRec += iStride; 1283 pOrg += iStride; 1284 } 1285 } 1286 } 1287 } 1288 1289 1290 Void TEncSampleAdaptiveOffset::calcSaoStatsCu_BeforeDblk( TComPic* pcPic ) 1291 { 1292 Int addr, yCbCr; 1293 Int x,y; 1294 TComSPS *pTmpSPS = pcPic->getSlice(0)->getSPS(); 1295 1296 Pel* pOrg; 1297 Pel* pRec; 1298 Int stride; 1299 Int lcuWidth = pTmpSPS->getMaxCUHeight(); 1300 Int lcuHeight = pTmpSPS->getMaxCUWidth(); 1301 UInt rPelX; 1302 UInt bPelY; 1303 Int64* stats; 1304 Int64* count; 1305 Int classIdx; 1306 Int picWidthTmp = 0; 1307 Int picHeightTmp = 0; 1308 Int startX; 1309 Int startY; 1310 Int endX; 1311 Int endY; 1312 Int firstX, firstY; 1313 1314 Int idxY; 1315 Int idxX; 1316 Int frameHeightInCU = m_iNumCuInHeight; 1317 Int frameWidthInCU = m_iNumCuInWidth; 1318 Int j, k; 1319 1320 Int isChroma; 1321 Int numSkipLine, numSkipLineRight; 1322 1323 UInt lPelX, tPelY; 1324 TComDataCU *pTmpCu; 1325 1326 for (idxY = 0; idxY< frameHeightInCU; idxY++) 1327 { 1328 for (idxX = 0; idxX< frameWidthInCU; idxX++) 1329 { 1330 lcuWidth = pTmpSPS->getMaxCUHeight(); 1331 lcuHeight = pTmpSPS->getMaxCUWidth(); 1332 addr = idxX + frameWidthInCU*idxY; 1333 pTmpCu = pcPic->getCU(addr); 1334 lPelX = pTmpCu->getCUPelX(); 1335 tPelY = pTmpCu->getCUPelY(); 1336 for( yCbCr = 0; yCbCr < 3; yCbCr++ ) 1337 { 1338 isChroma = (yCbCr!=0)? 1:0; 1339 1340 for ( j=0;j<MAX_NUM_SAO_TYPE;j++) 1341 { 1342 for ( k=0;k< MAX_NUM_SAO_CLASS;k++) 1343 { 1344 m_count_PreDblk [addr][yCbCr][j][k] = 0; 1345 m_offsetOrg_PreDblk[addr][yCbCr][j][k] = 0; 1346 } 1347 } 1348 if( yCbCr == 0 ) 1349 { 1350 picWidthTmp = m_iPicWidth; 1351 picHeightTmp = m_iPicHeight; 1352 } 1353 else if( yCbCr == 1 ) 1354 { 1355 picWidthTmp = m_iPicWidth >> isChroma; 1356 picHeightTmp = m_iPicHeight >> isChroma; 1357 lcuWidth = lcuWidth >> isChroma; 1358 lcuHeight = lcuHeight >> isChroma; 1359 lPelX = lPelX >> isChroma; 1360 tPelY = tPelY >> isChroma; 1361 } 1362 rPelX = lPelX + lcuWidth ; 1363 bPelY = tPelY + lcuHeight ; 1364 rPelX = rPelX > picWidthTmp ? picWidthTmp : rPelX; 1365 bPelY = bPelY > picHeightTmp ? picHeightTmp : bPelY; 1366 lcuWidth = rPelX - lPelX; 1367 lcuHeight = bPelY - tPelY; 1368 1369 stride = (yCbCr == 0)? pcPic->getStride(): pcPic->getCStride(); 1370 1371 //if(iSaoType == BO) 1372 1373 numSkipLine = isChroma? 1:3; 1374 numSkipLineRight = isChroma? 2:4; 1375 1376 stats = m_offsetOrg_PreDblk[addr][yCbCr][SAO_BO]; 1377 count = m_count_PreDblk[addr][yCbCr][SAO_BO]; 1378 1379 pOrg = getPicYuvAddr(pcPic->getPicYuvOrg(), yCbCr, addr); 1380 pRec = getPicYuvAddr(pcPic->getPicYuvRec(), yCbCr, addr); 1381 1382 startX = (rPelX == picWidthTmp) ? lcuWidth : lcuWidth-numSkipLineRight; 1383 startY = (bPelY == picHeightTmp) ? lcuHeight : lcuHeight-numSkipLine; 1384 1385 for (y=0; y<lcuHeight; y++) 1386 { 1387 for (x=0; x<lcuWidth; x++) 1388 { 1389 if( x < startX && y < startY ) 1390 continue; 1391 1392 classIdx = m_lumaTableBo[pRec[x]]; 1393 if (classIdx) 1394 { 1395 stats[classIdx] += (pOrg[x] - pRec[x]); 1396 count[classIdx] ++; 1397 } 1398 } 1399 pOrg += stride; 1400 pRec += stride; 1401 } 1402 1403 Int signLeft; 1404 Int signRight; 1405 Int signDown; 1406 Int signDown1; 1407 Int signDown2; 1408 1409 UInt uiEdgeType; 1410 1411 //if (iSaoType == EO_0) 1412 1413 numSkipLine = isChroma? 1:3; 1414 numSkipLineRight = isChroma? 3:5; 1415 1416 stats = m_offsetOrg_PreDblk[addr][yCbCr][SAO_EO_0]; 1417 count = m_count_PreDblk[addr][yCbCr][SAO_EO_0]; 1418 1419 pOrg = getPicYuvAddr(pcPic->getPicYuvOrg(), yCbCr, addr); 1420 pRec = getPicYuvAddr(pcPic->getPicYuvRec(), yCbCr, addr); 1421 1422 startX = (rPelX == picWidthTmp) ? lcuWidth-1 : lcuWidth-numSkipLineRight; 1423 startY = (bPelY == picHeightTmp) ? lcuHeight : lcuHeight-numSkipLine; 1424 firstX = (lPelX == 0) ? 1 : 0; 1425 endX = (rPelX == picWidthTmp) ? lcuWidth-1 : lcuWidth; 1426 1427 for (y=0; y<lcuHeight; y++) 1428 { 1429 signLeft = xSign(pRec[firstX] - pRec[firstX-1]); 1430 for (x=firstX; x< endX; x++) 1431 { 1432 signRight = xSign(pRec[x] - pRec[x+1]); 1433 uiEdgeType = signRight + signLeft + 2; 1434 signLeft = -signRight; 1435 1436 if( x < startX && y < startY ) 1437 continue; 1438 1439 stats[m_auiEoTable[uiEdgeType]] += (pOrg[x] - pRec[x]); 1440 count[m_auiEoTable[uiEdgeType]] ++; 1441 } 1442 pOrg += stride; 1443 pRec += stride; 1444 } 1445 1446 //if (iSaoType == EO_1) 1447 1448 numSkipLine = isChroma? 2:4; 1449 numSkipLineRight = isChroma? 2:4; 1450 1451 stats = m_offsetOrg_PreDblk[addr][yCbCr][SAO_EO_1]; 1452 count = m_count_PreDblk[addr][yCbCr][SAO_EO_1]; 1453 1454 pOrg = getPicYuvAddr(pcPic->getPicYuvOrg(), yCbCr, addr); 1455 pRec = getPicYuvAddr(pcPic->getPicYuvRec(), yCbCr, addr); 1456 1457 startX = (rPelX == picWidthTmp) ? lcuWidth : lcuWidth-numSkipLineRight; 1458 startY = (bPelY == picHeightTmp) ? lcuHeight-1 : lcuHeight-numSkipLine; 1459 firstY = (tPelY == 0) ? 1 : 0; 1460 endY = (bPelY == picHeightTmp) ? lcuHeight-1 : lcuHeight; 1461 if (firstY == 1) 1462 { 1463 pOrg += stride; 1464 pRec += stride; 1465 } 1466 1467 for (x=0; x< lcuWidth; x++) 1468 { 1469 m_iUpBuff1[x] = xSign(pRec[x] - pRec[x-stride]); 1470 } 1471 for (y=firstY; y<endY; y++) 1472 { 1473 for (x=0; x<lcuWidth; x++) 1474 { 1475 signDown = xSign(pRec[x] - pRec[x+stride]); 1476 uiEdgeType = signDown + m_iUpBuff1[x] + 2; 1477 m_iUpBuff1[x] = -signDown; 1478 1479 if( x < startX && y < startY ) 1480 continue; 1481 1482 stats[m_auiEoTable[uiEdgeType]] += (pOrg[x] - pRec[x]); 1483 count[m_auiEoTable[uiEdgeType]] ++; 1484 } 1485 pOrg += stride; 1486 pRec += stride; 1487 } 1488 1489 //if (iSaoType == EO_2) 1490 1491 numSkipLine = isChroma? 2:4; 1492 numSkipLineRight = isChroma? 3:5; 1493 1494 stats = m_offsetOrg_PreDblk[addr][yCbCr][SAO_EO_2]; 1495 count = m_count_PreDblk[addr][yCbCr][SAO_EO_2]; 1496 1497 pOrg = getPicYuvAddr(pcPic->getPicYuvOrg(), yCbCr, addr); 1498 pRec = getPicYuvAddr(pcPic->getPicYuvRec(), yCbCr, addr); 1499 1500 startX = (rPelX == picWidthTmp) ? lcuWidth-1 : lcuWidth-numSkipLineRight; 1501 startY = (bPelY == picHeightTmp) ? lcuHeight-1 : lcuHeight-numSkipLine; 1502 firstX = (lPelX == 0) ? 1 : 0; 1503 firstY = (tPelY == 0) ? 1 : 0; 1504 endX = (rPelX == picWidthTmp) ? lcuWidth-1 : lcuWidth; 1505 endY = (bPelY == picHeightTmp) ? lcuHeight-1 : lcuHeight; 1506 if (firstY == 1) 1507 { 1508 pOrg += stride; 1509 pRec += stride; 1510 } 1511 1512 for (x=firstX; x<endX; x++) 1513 { 1514 m_iUpBuff1[x] = xSign(pRec[x] - pRec[x-stride-1]); 1515 } 1516 for (y=firstY; y<endY; y++) 1517 { 1518 signDown2 = xSign(pRec[stride+startX] - pRec[startX-1]); 1519 for (x=firstX; x<endX; x++) 1520 { 1521 signDown1 = xSign(pRec[x] - pRec[x+stride+1]) ; 1522 uiEdgeType = signDown1 + m_iUpBuff1[x] + 2; 1523 m_iUpBufft[x+1] = -signDown1; 1524 1525 if( x < startX && y < startY ) 1526 continue; 1527 1528 stats[m_auiEoTable[uiEdgeType]] += (pOrg[x] - pRec[x]); 1529 count[m_auiEoTable[uiEdgeType]] ++; 1530 } 1531 m_iUpBufft[firstX] = signDown2; 1532 ipSwap = m_iUpBuff1; 1533 m_iUpBuff1 = m_iUpBufft; 1534 m_iUpBufft = ipSwap; 1535 1536 pRec += stride; 1537 pOrg += stride; 1538 } 1539 1540 //if (iSaoType == EO_3) 1541 1542 numSkipLine = isChroma? 2:4; 1543 numSkipLineRight = isChroma? 3:5; 1544 1545 stats = m_offsetOrg_PreDblk[addr][yCbCr][SAO_EO_3]; 1546 count = m_count_PreDblk[addr][yCbCr][SAO_EO_3]; 1547 1548 pOrg = getPicYuvAddr(pcPic->getPicYuvOrg(), yCbCr, addr); 1549 pRec = getPicYuvAddr(pcPic->getPicYuvRec(), yCbCr, addr); 1550 1551 startX = (rPelX == picWidthTmp) ? lcuWidth-1 : lcuWidth-numSkipLineRight; 1552 startY = (bPelY == picHeightTmp) ? lcuHeight-1 : lcuHeight-numSkipLine; 1553 firstX = (lPelX == 0) ? 1 : 0; 1554 firstY = (tPelY == 0) ? 1 : 0; 1555 endX = (rPelX == picWidthTmp) ? lcuWidth-1 : lcuWidth; 1556 endY = (bPelY == picHeightTmp) ? lcuHeight-1 : lcuHeight; 1557 if (firstY == 1) 1558 { 1559 pOrg += stride; 1560 pRec += stride; 1561 } 1562 1563 for (x=firstX-1; x<endX; x++) 1564 { 1565 m_iUpBuff1[x] = xSign(pRec[x] - pRec[x-stride+1]); 1566 } 1567 1568 for (y=firstY; y<endY; y++) 1569 { 1570 for (x=firstX; x<endX; x++) 1571 { 1572 signDown1 = xSign(pRec[x] - pRec[x+stride-1]) ; 1573 uiEdgeType = signDown1 + m_iUpBuff1[x] + 2; 1574 m_iUpBuff1[x-1] = -signDown1; 1575 1576 if( x < startX && y < startY ) 1577 continue; 1578 1579 stats[m_auiEoTable[uiEdgeType]] += (pOrg[x] - pRec[x]); 1580 count[m_auiEoTable[uiEdgeType]] ++; 1581 } 1582 m_iUpBuff1[endX-1] = xSign(pRec[endX-1 + stride] - pRec[endX]); 1583 1584 pRec += stride; 1585 pOrg += stride; 1586 } 1587 } 1588 } 1589 } 1590 } 1591 1592 1593 /** get SAO statistics 1594 * \param *psQTPart, iYCbCr 1595 */ 1596 Void TEncSampleAdaptiveOffset::getSaoStats(SAOQTPart *psQTPart, Int iYCbCr) 1597 { 1598 Int iLevelIdx, iPartIdx, iTypeIdx, iClassIdx; 1599 Int i; 1600 Int iNumTotalType = MAX_NUM_SAO_TYPE; 1601 Int LcuIdxX; 1602 Int LcuIdxY; 1603 Int iAddr; 1604 Int iFrameWidthInCU = m_pcPic->getFrameWidthInCU(); 1605 Int iDownPartIdx; 1606 Int iPartStart; 1607 Int iPartEnd; 1608 SAOQTPart* pOnePart; 1609 1610 if (m_uiMaxSplitLevel == 0) 1611 { 1612 iPartIdx = 0; 1613 pOnePart = &(psQTPart[iPartIdx]); 1614 for (LcuIdxY = pOnePart->StartCUY; LcuIdxY<= pOnePart->EndCUY; LcuIdxY++) 1615 { 1616 for (LcuIdxX = pOnePart->StartCUX; LcuIdxX<= pOnePart->EndCUX; LcuIdxX++) 1617 { 1618 iAddr = LcuIdxY*iFrameWidthInCU + LcuIdxX; 1619 calcSaoStatsCu(iAddr, iPartIdx, iYCbCr); 1620 } 1621 } 1622 } 1623 else 1624 { 1625 for(iPartIdx=m_aiNumCulPartsLevel[m_uiMaxSplitLevel-1]; iPartIdx<m_aiNumCulPartsLevel[m_uiMaxSplitLevel]; iPartIdx++) 1626 { 1627 pOnePart = &(psQTPart[iPartIdx]); 1628 for (LcuIdxY = pOnePart->StartCUY; LcuIdxY<= pOnePart->EndCUY; LcuIdxY++) 1629 { 1630 for (LcuIdxX = pOnePart->StartCUX; LcuIdxX<= pOnePart->EndCUX; LcuIdxX++) 1631 { 1632 iAddr = LcuIdxY*iFrameWidthInCU + LcuIdxX; 1633 calcSaoStatsCu(iAddr, iPartIdx, iYCbCr); 1634 } 1635 } 1636 } 1637 for (iLevelIdx = m_uiMaxSplitLevel-1; iLevelIdx>=0; iLevelIdx-- ) 1638 { 1639 iPartStart = (iLevelIdx > 0) ? m_aiNumCulPartsLevel[iLevelIdx-1] : 0; 1640 iPartEnd = m_aiNumCulPartsLevel[iLevelIdx]; 1641 1642 for(iPartIdx = iPartStart; iPartIdx < iPartEnd; iPartIdx++) 1643 { 1644 pOnePart = &(psQTPart[iPartIdx]); 1645 for (i=0; i< NUM_DOWN_PART; i++) 1646 { 1647 iDownPartIdx = pOnePart->DownPartsIdx[i]; 1648 for (iTypeIdx=0; iTypeIdx<iNumTotalType; iTypeIdx++) 1649 { 1650 for (iClassIdx=0; iClassIdx< (iTypeIdx < SAO_BO ? m_iNumClass[iTypeIdx] : SAO_MAX_BO_CLASSES) +1; iClassIdx++) 1651 { 1652 m_iOffsetOrg[iPartIdx][iTypeIdx][iClassIdx] += m_iOffsetOrg[iDownPartIdx][iTypeIdx][iClassIdx]; 1653 m_iCount [iPartIdx][iTypeIdx][iClassIdx] += m_iCount [iDownPartIdx][iTypeIdx][iClassIdx]; 1654 } 1655 } 1656 } 1657 } 1658 } 1659 } 1660 } 1661 1662 /** reset offset statistics 1663 * \param 1664 */ 1665 Void TEncSampleAdaptiveOffset::resetStats() 1666 { 1667 for (Int i=0;i<m_iNumTotalParts;i++) 1668 { 1669 m_dCostPartBest[i] = MAX_DOUBLE; 1670 m_iTypePartBest[i] = -1; 1671 m_iDistOrg[i] = 0; 1672 for (Int j=0;j<MAX_NUM_SAO_TYPE;j++) 1673 { 1674 m_iDist[i][j] = 0; 1675 m_iRate[i][j] = 0; 1676 m_dCost[i][j] = 0; 1677 for (Int k=0;k<MAX_NUM_SAO_CLASS;k++) 1678 { 1679 m_iCount [i][j][k] = 0; 1680 m_iOffset[i][j][k] = 0; 1681 m_iOffsetOrg[i][j][k] = 0; 1682 } 1683 } 1684 } 1685 } 1686 1687 #if SAO_CHROMA_LAMBDA 1688 /** Sample adaptive offset process 1689 * \param pcSaoParam 1690 * \param dLambdaLuma 1691 * \param dLambdaChroma 1692 */ 1693 #if SAO_ENCODING_CHOICE 1694 Void TEncSampleAdaptiveOffset::SAOProcess(SAOParam *pcSaoParam, Double dLambdaLuma, Double dLambdaChroma, Int depth) 1695 #else 1696 Void TEncSampleAdaptiveOffset::SAOProcess(SAOParam *pcSaoParam, Double dLambdaLuma, Double dLambdaChroma) 1697 #endif 1698 #else 1699 /** Sample adaptive offset process 1700 * \param dLambda 1701 */ 1702 Void TEncSampleAdaptiveOffset::SAOProcess(SAOParam *pcSaoParam, Double dLambda) 1703 #endif 1704 { 1705 m_eSliceType = m_pcPic->getSlice(0)->getSliceType(); 1706 m_iPicNalReferenceIdc = (m_pcPic->getSlice(0)->isReferenced() ? 1 :0); 1707 1708 #if SAO_CHROMA_LAMBDA 1709 m_dLambdaLuma = dLambdaLuma; 1710 m_dLambdaChroma = dLambdaChroma; 1711 #else 1712 m_dLambdaLuma = dLambda; 1713 m_dLambdaChroma = dLambda; 1714 #endif 1715 1716 if(m_bUseNIF) 1717 { 1718 m_pcPic->getPicYuvRec()->copyToPic(m_pcYuvTmp); 1719 } 1720 1721 #if FULL_NBIT 1722 m_uiSaoBitIncrease = g_uiBitDepth + (g_uiBitDepth-8) - min((Int)(g_uiBitDepth + (g_uiBitDepth-8)), 10); 1723 #else 1724 m_uiSaoBitIncrease = g_uiBitDepth + g_uiBitIncrement - min((Int)(g_uiBitDepth + g_uiBitIncrement), 10); 1725 #endif 1726 1727 #if FULL_NBIT 1728 m_iOffsetTh = 1 << ( min((Int)(g_uiBitDepth + (g_uiBitDepth-8)-5),5) ); 1729 #else 1730 m_iOffsetTh = 1 << ( min((Int)(g_uiBitDepth + g_uiBitIncrement-5),5) ); 1731 #endif 1732 1733 resetSAOParam(pcSaoParam); 1734 if( !m_saoLcuBasedOptimization || !m_saoLcuBoundary ) 1735 { 1736 resetStats(); 1737 } 1738 Double dCostFinal = 0; 1739 if ( m_saoLcuBasedOptimization) 1740 { 1741 #if SAO_ENCODING_CHOICE 1742 rdoSaoUnitAll(pcSaoParam, dLambdaLuma, dLambdaChroma, depth); 1743 #else 1744 rdoSaoUnitAll(pcSaoParam, dLambdaLuma, dLambdaChroma); 1745 #endif 1746 } 1747 else 1748 { 1749 pcSaoParam->bSaoFlag[0] = 1; 1750 pcSaoParam->bSaoFlag[1] = 0; 1751 dCostFinal = 0; 1752 Double lambdaRdo = dLambdaLuma; 1753 resetStats(); 1754 getSaoStats(pcSaoParam->psSaoPart[0], 0); 1755 runQuadTreeDecision(pcSaoParam->psSaoPart[0], 0, dCostFinal, m_uiMaxSplitLevel, lambdaRdo, 0); 1756 pcSaoParam->bSaoFlag[0] = dCostFinal < 0 ? 1:0; 1757 if(pcSaoParam->bSaoFlag[0]) 1758 { 1759 convertQT2SaoUnit(pcSaoParam, 0, 0); 1760 assignSaoUnitSyntax(pcSaoParam->saoLcuParam[0], pcSaoParam->psSaoPart[0], pcSaoParam->oneUnitFlag[0], 0); 1761 } 1762 } 1763 1764 if (pcSaoParam->bSaoFlag[0]) 1765 { 1766 processSaoUnitAll( pcSaoParam->saoLcuParam[0], pcSaoParam->oneUnitFlag[0], 0); 1767 } 1768 if (pcSaoParam->bSaoFlag[1]) 1769 { 1770 processSaoUnitAll( pcSaoParam->saoLcuParam[1], pcSaoParam->oneUnitFlag[1], 1); 1771 processSaoUnitAll( pcSaoParam->saoLcuParam[2], pcSaoParam->oneUnitFlag[2], 2); 1772 } 1773 } 1774 /** Check merge SAO unit 1775 * \param saoUnitCurr current SAO unit 1776 * \param saoUnitCheck SAO unit tobe check 1777 * \param dir direction 1778 */ 1779 Void TEncSampleAdaptiveOffset::checkMerge(SaoLcuParam * saoUnitCurr, SaoLcuParam * saoUnitCheck, Int dir) 1780 { 1781 Int i ; 1782 Int countDiff = 0; 1783 if (saoUnitCurr->partIdx != saoUnitCheck->partIdx) 1784 { 1785 if (saoUnitCurr->typeIdx !=-1) 1786 { 1787 if (saoUnitCurr->typeIdx == saoUnitCheck->typeIdx) 1788 { 1789 for (i=0;i<saoUnitCurr->length;i++) 1790 { 1791 countDiff += (saoUnitCurr->offset[i] != saoUnitCheck->offset[i]); 1792 } 1793 countDiff += (saoUnitCurr->subTypeIdx != saoUnitCheck->subTypeIdx); 1794 if (countDiff ==0) 1795 { 1796 saoUnitCurr->partIdx = saoUnitCheck->partIdx; 1797 if (dir == 1) 1798 { 1799 saoUnitCurr->mergeUpFlag = 1; 1800 saoUnitCurr->mergeLeftFlag = 0; 1801 } 1802 else 1803 { 1804 saoUnitCurr->mergeUpFlag = 0; 1805 saoUnitCurr->mergeLeftFlag = 1; 1806 } 1807 } 1808 } 1809 } 1810 else 1811 { 1812 if (saoUnitCurr->typeIdx == saoUnitCheck->typeIdx) 1813 { 1814 saoUnitCurr->partIdx = saoUnitCheck->partIdx; 1815 if (dir == 1) 1816 { 1817 saoUnitCurr->mergeUpFlag = 1; 1818 saoUnitCurr->mergeLeftFlag = 0; 1819 } 1820 else 1821 { 1822 saoUnitCurr->mergeUpFlag = 0; 1823 saoUnitCurr->mergeLeftFlag = 1; 1824 } 1825 } 1826 } 1827 } 1828 } 1829 /** Assign SAO unit syntax from picture-based algorithm 1830 * \param saoLcuParam SAO LCU parameters 1831 * \param saoPart SAO part 1832 * \param oneUnitFlag SAO one unit flag 1833 * \param iYCbCr color component Index 1834 */ 1835 Void TEncSampleAdaptiveOffset::assignSaoUnitSyntax(SaoLcuParam* saoLcuParam, SAOQTPart* saoPart, Bool &oneUnitFlag, Int yCbCr) 1836 { 1837 if (saoPart->bSplit == 0) 1838 { 1839 oneUnitFlag = 1; 1840 } 1841 else 1842 { 1843 Int i,j, addr, addrUp, addrLeft, idx, idxUp, idxLeft, idxCount; 1844 1845 oneUnitFlag = 0; 1846 1847 idxCount = -1; 1848 saoLcuParam[0].mergeUpFlag = 0; 1849 saoLcuParam[0].mergeLeftFlag = 0; 1850 1851 for (j=0;j<m_iNumCuInHeight;j++) 1852 { 1853 for (i=0;i<m_iNumCuInWidth;i++) 1854 { 1855 addr = i + j*m_iNumCuInWidth; 1856 addrLeft = (addr%m_iNumCuInWidth == 0) ? -1 : addr - 1; 1857 addrUp = (addr<m_iNumCuInWidth) ? -1 : addr - m_iNumCuInWidth; 1858 idx = saoLcuParam[addr].partIdxTmp; 1859 idxLeft = (addrLeft == -1) ? -1 : saoLcuParam[addrLeft].partIdxTmp; 1860 idxUp = (addrUp == -1) ? -1 : saoLcuParam[addrUp].partIdxTmp; 1861 1862 if(idx!=idxLeft && idx!=idxUp) 1863 { 1864 saoLcuParam[addr].mergeUpFlag = 0; idxCount++; 1865 saoLcuParam[addr].mergeLeftFlag = 0; 1866 saoLcuParam[addr].partIdx = idxCount; 1867 } 1868 else if (idx==idxLeft) 1869 { 1870 saoLcuParam[addr].mergeUpFlag = 1; 1871 saoLcuParam[addr].mergeLeftFlag = 1; 1872 saoLcuParam[addr].partIdx = saoLcuParam[addrLeft].partIdx; 1873 } 1874 else if (idx==idxUp) 1875 { 1876 saoLcuParam[addr].mergeUpFlag = 1; 1877 saoLcuParam[addr].mergeLeftFlag = 0; 1878 saoLcuParam[addr].partIdx = saoLcuParam[addrUp].partIdx; 1879 } 1880 if (addrUp != -1) 1881 { 1882 checkMerge(&saoLcuParam[addr], &saoLcuParam[addrUp], 1); 1883 } 1884 if (addrLeft != -1) 1885 { 1886 checkMerge(&saoLcuParam[addr], &saoLcuParam[addrLeft], 0); 1887 } 1888 } 1889 } 1890 } 1891 } 1892 /** rate distortion optimization of all SAO units 1893 * \param saoParam SAO parameters 1894 * \param lambda 1895 * \param lambdaChroma 1896 */ 1897 #if SAO_ENCODING_CHOICE 1898 Void TEncSampleAdaptiveOffset::rdoSaoUnitAll(SAOParam *saoParam, Double lambda, Double lambdaChroma, Int depth) 1899 #else 1900 Void TEncSampleAdaptiveOffset::rdoSaoUnitAll(SAOParam *saoParam, Double lambda, Double lambdaChroma) 1901 #endif 1902 { 1903 Int idxY; 1904 Int idxX; 1905 Int frameHeightInCU = saoParam->numCuInHeight; 1906 Int frameWidthInCU = saoParam->numCuInWidth; 1907 Int j, k; 1908 Int addr = 0; 1909 Int addrUp = -1; 1910 Int addrLeft = -1; 1911 Int compIdx = 0; 1912 SaoLcuParam mergeSaoParam[3][2]; 1913 Double compDistortion[3]; 1914 1915 saoParam->bSaoFlag[0] = true; 1916 saoParam->bSaoFlag[1] = true; 1917 saoParam->oneUnitFlag[0] = false; 1918 saoParam->oneUnitFlag[1] = false; 1919 saoParam->oneUnitFlag[2] = false; 1920 1921 #if SAO_ENCODING_CHOICE 1922 #if SAO_ENCODING_CHOICE_CHROMA 1923 Int numNoSao[2]; 1924 numNoSao[0] = 0;// Luma 1925 numNoSao[1] = 0;// Chroma 1926 if( depth > 0 && m_depthSaoRate[0][depth-1] > SAO_ENCODING_RATE ) 1927 { 1928 saoParam->bSaoFlag[0] = false; 1929 } 1930 1931 if( depth > 0 && m_depthSaoRate[1][depth-1] > SAO_ENCODING_RATE_CHROMA ) 1932 { 1933 saoParam->bSaoFlag[1] = false; 1934 } 1935 #else 1936 Int numNoSao = 0; 1937 1938 if( depth > 0 && m_depth0SaoRate > SAO_ENCODING_RATE ) 1939 { 1940 saoParam->bSaoFlag[0] = false; 1941 saoParam->bSaoFlag[1] = false; 1942 } 1943 #endif 1944 #endif 1945 1946 for (idxY = 0; idxY< frameHeightInCU; idxY++) 1947 { 1948 for (idxX = 0; idxX< frameWidthInCU; idxX++) 1949 { 1950 addr = idxX + frameWidthInCU*idxY; 1951 addrUp = addr < frameWidthInCU ? -1:idxX + frameWidthInCU*(idxY-1); 1952 addrLeft = idxX == 0 ? -1:idxX-1 + frameWidthInCU*idxY; 1953 Int allowMergeLeft = 1; 1954 Int allowMergeUp = 1; 1955 UInt rate; 1956 Double bestCost, mergeCost; 1957 1958 if (idxX!=0) 1959 { 1960 // check tile id and slice id 1961 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())) 1962 { 1963 allowMergeLeft = 0; 1964 } 1965 } 1966 else 1967 { 1968 allowMergeLeft = 0; 1969 } 1970 if (idxY!=0) 1971 { 1972 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())) 1973 { 1974 allowMergeUp = 0; 1975 } 1976 } 1977 else 1978 { 1979 allowMergeUp = 0; 1980 } 1981 1982 compDistortion[0] = 0; 1983 compDistortion[1] = 0; 1984 compDistortion[2] = 0; 1985 m_pcRDGoOnSbacCoder->load(m_pppcRDSbacCoder[0][CI_CURR_BEST]); 1986 1987 if (allowMergeLeft) 1988 { 1989 m_pcEntropyCoder->m_pcEntropyCoderIf->codeSaoMerge(0); 1990 } 1991 if (allowMergeUp) 1992 { 1993 m_pcEntropyCoder->m_pcEntropyCoderIf->codeSaoMerge(0); 1994 } 1995 1996 m_pcRDGoOnSbacCoder->store( m_pppcRDSbacCoder[0][CI_TEMP_BEST] ); 1997 1998 // reset stats Y, Cb, Cr 1999 for ( compIdx=0;compIdx<3;compIdx++) 2000 { 2001 for ( j=0;j<MAX_NUM_SAO_TYPE;j++) 2002 { 2003 for ( k=0;k< MAX_NUM_SAO_CLASS;k++) 2004 { 2005 m_iOffset [compIdx][j][k] = 0; 2006 if( m_saoLcuBasedOptimization && m_saoLcuBoundary ) 2007 { 2008 m_iCount [compIdx][j][k] = m_count_PreDblk [addr][compIdx][j][k]; 2009 m_iOffsetOrg[compIdx][j][k] = m_offsetOrg_PreDblk[addr][compIdx][j][k]; 2010 } 2011 else 2012 { 2013 m_iCount [compIdx][j][k] = 0; 2014 m_iOffsetOrg[compIdx][j][k] = 0; 2015 } 2016 } 2017 } 2018 saoParam->saoLcuParam[compIdx][addr].typeIdx = -1; 2019 saoParam->saoLcuParam[compIdx][addr].mergeUpFlag = 0; 2020 saoParam->saoLcuParam[compIdx][addr].mergeLeftFlag = 0; 2021 saoParam->saoLcuParam[compIdx][addr].subTypeIdx = 0; 2022 #if SAO_ENCODING_CHOICE 2023 if( (compIdx ==0 && saoParam->bSaoFlag[0])|| (compIdx >0 && saoParam->bSaoFlag[1]) ) 2024 #endif 2025 { 2026 calcSaoStatsCu(addr, compIdx, compIdx); 2027 } 2028 } 2029 saoComponentParamDist(allowMergeLeft, allowMergeUp, saoParam, addr, addrUp, addrLeft, 0, lambda, &mergeSaoParam[0][0], &compDistortion[0]); 2030 sao2ChromaParamDist(allowMergeLeft, allowMergeUp, saoParam, addr, addrUp, addrLeft, lambdaChroma, &mergeSaoParam[1][0], &mergeSaoParam[2][0], &compDistortion[0]); 2031 if( saoParam->bSaoFlag[0] || saoParam->bSaoFlag[1] ) 2032 { 2033 // Cost of new SAO_params 2034 m_pcRDGoOnSbacCoder->load(m_pppcRDSbacCoder[0][CI_CURR_BEST]); 2035 m_pcRDGoOnSbacCoder->resetBits(); 2036 if (allowMergeLeft) 2037 { 2038 m_pcEntropyCoder->m_pcEntropyCoderIf->codeSaoMerge(0); 2039 } 2040 if (allowMergeUp) 2041 { 2042 m_pcEntropyCoder->m_pcEntropyCoderIf->codeSaoMerge(0); 2043 } 2044 for ( compIdx=0;compIdx<3;compIdx++) 2045 { 2046 if( (compIdx ==0 && saoParam->bSaoFlag[0]) || (compIdx >0 && saoParam->bSaoFlag[1])) 2047 { 2048 m_pcEntropyCoder->encodeSaoOffset(&saoParam->saoLcuParam[compIdx][addr], compIdx); 2049 } 2050 } 2051 2052 rate = m_pcEntropyCoder->getNumberOfWrittenBits(); 2053 bestCost = compDistortion[0] + (Double)rate; 2054 m_pcRDGoOnSbacCoder->store(m_pppcRDSbacCoder[0][CI_TEMP_BEST]); 2055 2056 // Cost of Merge 2057 for(Int mergeUp=0; mergeUp<2; ++mergeUp) 2058 { 2059 if ( (allowMergeLeft && (mergeUp==0)) || (allowMergeUp && (mergeUp==1)) ) 2060 { 2061 m_pcRDGoOnSbacCoder->load(m_pppcRDSbacCoder[0][CI_CURR_BEST]); 2062 m_pcRDGoOnSbacCoder->resetBits(); 2063 if (allowMergeLeft) 2064 { 2065 m_pcEntropyCoder->m_pcEntropyCoderIf->codeSaoMerge(1-mergeUp); 2066 } 2067 if ( allowMergeUp && (mergeUp==1) ) 2068 { 2069 m_pcEntropyCoder->m_pcEntropyCoderIf->codeSaoMerge(1); 2070 } 2071 2072 rate = m_pcEntropyCoder->getNumberOfWrittenBits(); 2073 mergeCost = compDistortion[mergeUp+1] + (Double)rate; 2074 if (mergeCost < bestCost) 2075 { 2076 bestCost = mergeCost; 2077 m_pcRDGoOnSbacCoder->store(m_pppcRDSbacCoder[0][CI_TEMP_BEST]); 2078 for ( compIdx=0;compIdx<3;compIdx++) 2079 { 2080 mergeSaoParam[compIdx][mergeUp].mergeLeftFlag = 1-mergeUp; 2081 mergeSaoParam[compIdx][mergeUp].mergeUpFlag = mergeUp; 2082 if( (compIdx==0 && saoParam->bSaoFlag[0]) || (compIdx>0 && saoParam->bSaoFlag[1])) 2083 { 2084 copySaoUnit(&saoParam->saoLcuParam[compIdx][addr], &mergeSaoParam[compIdx][mergeUp] ); 2085 } 2086 } 2087 } 2088 } 2089 } 2090 #if SAO_ENCODING_CHOICE 2091 #if SAO_ENCODING_CHOICE_CHROMA 2092 if( saoParam->saoLcuParam[0][addr].typeIdx == -1) 2093 { 2094 numNoSao[0]++; 2095 } 2096 if( saoParam->saoLcuParam[1][addr].typeIdx == -1) 2097 { 2098 numNoSao[1]+=2; 2099 } 2100 #else 2101 for ( compIdx=0;compIdx<3;compIdx++) 2102 { 2103 if( depth == 0 && saoParam->saoLcuParam[compIdx][addr].typeIdx == -1) 2104 { 2105 numNoSao++; 2106 } 2107 } 2108 #endif 2109 #endif 2110 m_pcRDGoOnSbacCoder->load(m_pppcRDSbacCoder[0][CI_TEMP_BEST]); 2111 m_pcRDGoOnSbacCoder->store(m_pppcRDSbacCoder[0][CI_CURR_BEST]); 2112 } 2113 } 2114 } 2115 #if SAO_ENCODING_CHOICE 2116 #if SAO_ENCODING_CHOICE_CHROMA 2117 #if SAO_ENCODING_CHOICE_CHROMA_BF 2118 if( !saoParam->bSaoFlag[0]) 2119 { 2120 m_depthSaoRate[0][depth] = 1.0; 2121 } 2122 else 2123 { 2124 m_depthSaoRate[0][depth] = numNoSao[0]/((Double) frameHeightInCU*frameWidthInCU); 2125 } 2126 if( !saoParam->bSaoFlag[1]) 2127 { 2128 m_depthSaoRate[1][depth] = 1.0; 2129 } 2130 else 2131 { 2132 m_depthSaoRate[1][depth] = numNoSao[1]/((Double) frameHeightInCU*frameWidthInCU*2); 2133 } 2134 #else 2135 m_depthSaoRate[0][depth] = numNoSao[0]/((Double) frameHeightInCU*frameWidthInCU); 2136 m_depthSaoRate[1][depth] = numNoSao[1]/((Double) frameHeightInCU*frameWidthInCU*2); 2137 #endif 2138 #else 2139 if( depth == 0) 2140 { 2141 // update SAO Rate 2142 m_depth0SaoRate = numNoSao/((Double) frameHeightInCU*frameWidthInCU*3); 2143 } 2144 #endif 2145 #endif 2146 } 2147 /** rate distortion optimization of SAO unit 2148 * \param saoParam SAO parameters 2149 * \param addr address 2150 * \param addrUp above address 2151 * \param addrLeft left address 2152 * \param yCbCr color component index 2153 * \param lambda 2154 */ 2155 inline Int64 TEncSampleAdaptiveOffset::estSaoTypeDist(Int compIdx, Int typeIdx, Int shift, Double lambda, Int *currentDistortionTableBo, Double *currentRdCostTableBo) 2156 { 2157 Int64 estDist = 0; 2158 Int classIdx; 2159 for(classIdx=1; classIdx < ( (typeIdx < SAO_BO) ? m_iNumClass[typeIdx]+1 : SAO_MAX_BO_CLASSES+1); classIdx++) 2160 { 2161 if( typeIdx == SAO_BO) 2162 { 2163 currentDistortionTableBo[classIdx-1] = 0; 2164 currentRdCostTableBo[classIdx-1] = lambda; 2165 } 2166 if(m_iCount [compIdx][typeIdx][classIdx]) 2167 { 2168 #if FULL_NBIT 2169 m_iOffset[compIdx][typeIdx][classIdx] = (Int64) xRoundIbdi((Double)(m_iOffsetOrg[compIdx][typeIdx][classIdx]<<g_uiBitDepth-8) / (Double)(m_iCount [compIdx][typeIdx][classIdx]<<m_uiSaoBitIncrease)); 2170 #else 2171 m_iOffset[compIdx][typeIdx][classIdx] = (Int64) xRoundIbdi((Double)(m_iOffsetOrg[compIdx][typeIdx][classIdx]<<g_uiBitIncrement) / (Double)(m_iCount [compIdx][typeIdx][classIdx]<<m_uiSaoBitIncrease)); 2172 #endif 2173 m_iOffset[compIdx][typeIdx][classIdx] = Clip3(-m_iOffsetTh+1, m_iOffsetTh-1, (Int)m_iOffset[compIdx][typeIdx][classIdx]); 2174 if (typeIdx < 4) 2175 { 2176 if ( m_iOffset[compIdx][typeIdx][classIdx]<0 && classIdx<3 ) 2177 { 2178 m_iOffset[compIdx][typeIdx][classIdx] = 0; 2179 } 2180 if ( m_iOffset[compIdx][typeIdx][classIdx]>0 && classIdx>=3) 2181 { 2182 m_iOffset[compIdx][typeIdx][classIdx] = 0; 2183 } 2184 } 2185 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, m_uiSaoBitIncrease, currentDistortionTableBo, currentRdCostTableBo ); 2186 } 2187 else 2188 { 2189 m_iOffsetOrg[compIdx][typeIdx][classIdx] = 0; 2190 m_iOffset[compIdx][typeIdx][classIdx] = 0; 2191 } 2192 if( typeIdx != SAO_BO ) 2193 { 2194 estDist += estSaoDist( m_iCount [compIdx][typeIdx][classIdx], m_iOffset[compIdx][typeIdx][classIdx] << m_uiSaoBitIncrease, m_iOffsetOrg[compIdx][typeIdx][classIdx], shift); 2195 } 2196 } 2197 return estDist; 2198 } 2199 2200 inline Int64 TEncSampleAdaptiveOffset::estSaoDist(Int64 count, Int64 offset, Int64 offsetOrg, Int shift) 2201 { 2202 return (( count*offset*offset-offsetOrg*offset*2 ) >> shift); 2203 } 2204 inline Int64 TEncSampleAdaptiveOffset::estIterOffset(Int typeIdx, Int classIdx, double lambda, Int64 offsetInput, Int64 count, Int64 offsetOrg, Int shift, Int bitIncrease, Int *currentDistortionTableBo, Double *currentRdCostTableBo ) 2205 { 2206 //Clean up, best_q_offset. 2207 Int64 iterOffset, tempOffset; 2208 Int64 tempDist, tempRate; 2209 Double tempCost, tempMinCost; 2210 Int64 offsetOutput = 0; 2211 iterOffset = offsetInput; 2212 // 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. 2213 tempMinCost = lambda; 2214 while (iterOffset != 0) 2215 { 2216 // Calculate the bits required for signalling the offset 2217 tempRate = (typeIdx == SAO_BO) ? (abs((Int)iterOffset)+2) : (abs((Int)iterOffset)+1); 2218 if (abs((Int)iterOffset)==m_iOffsetTh-1) 2219 { 2220 tempRate --; 2221 } 2222 // Do the dequntization before distorion calculation 2223 tempOffset = iterOffset << bitIncrease; 2224 tempDist = estSaoDist( count, tempOffset, offsetOrg, shift); 2225 tempCost = ((Double)tempDist + lambda * (Double) tempRate); 2226 if(tempCost < tempMinCost) 2227 { 2228 tempMinCost = tempCost; 2229 offsetOutput = iterOffset; 2230 if(typeIdx == SAO_BO) 2231 { 2232 currentDistortionTableBo[classIdx-1] = (Int) tempDist; 2233 currentRdCostTableBo[classIdx-1] = tempCost; 2234 } 2235 } 2236 iterOffset = (iterOffset > 0) ? (iterOffset-1):(iterOffset+1); 2237 } 2238 return offsetOutput; 2239 } 2240 2241 Void TEncSampleAdaptiveOffset::saoComponentParamDist(Int allowMergeLeft, Int allowMergeUp, SAOParam *saoParam, Int addr, Int addrUp, Int addrLeft, Int yCbCr, Double lambda, SaoLcuParam *compSaoParam, Double *compDistortion) 2242 { 2243 Int typeIdx; 2244 Int64 estDist; 2245 Int classIdx; 2246 2247 Int shift = g_uiBitIncrement << 1; 2248 2249 Int64 bestDist; 2250 2251 SaoLcuParam* saoLcuParam = &(saoParam->saoLcuParam[yCbCr][addr]); 2252 SaoLcuParam* saoLcuParamNeighbor = NULL; 2253 2254 resetSaoUnit(saoLcuParam); 2255 resetSaoUnit(&compSaoParam[0]); 2256 resetSaoUnit(&compSaoParam[1]); 2257 2258 Double dCostPartBest = MAX_DOUBLE; 2259 2260 Double bestRDCostTableBo = MAX_DOUBLE; 2261 Int bestClassTableBo = 0; 2262 Int currentDistortionTableBo[MAX_NUM_SAO_CLASS]; 2263 Double currentRdCostTableBo[MAX_NUM_SAO_CLASS]; 2264 2265 SaoLcuParam saoLcuParamRdo; 2266 Double estRate = 0; 2267 2268 resetSaoUnit(&saoLcuParamRdo); 2269 2270 m_pcRDGoOnSbacCoder->load(m_pppcRDSbacCoder[0][CI_TEMP_BEST]); 2271 m_pcRDGoOnSbacCoder->resetBits(); 2272 m_pcEntropyCoder->encodeSaoOffset(&saoLcuParamRdo, yCbCr); 2273 dCostPartBest = m_pcEntropyCoder->getNumberOfWrittenBits()*lambda ; 2274 2275 copySaoUnit(saoLcuParam, &saoLcuParamRdo ); 2276 2277 bestDist = 0; 2278 2279 for (typeIdx=0; typeIdx<MAX_NUM_SAO_TYPE; typeIdx++) 2280 { 2281 estDist = estSaoTypeDist(yCbCr, typeIdx, shift, lambda, currentDistortionTableBo, currentRdCostTableBo); 2282 if( typeIdx == SAO_BO ) 2283 { 2284 // Estimate Best Position 2285 Double currentRDCost = 0.0; 2286 2287 for(Int i=0; i< SAO_MAX_BO_CLASSES -SAO_BO_LEN +1; i++) 2288 { 2289 currentRDCost = 0.0; 2290 for(UInt uj = i; uj < i+SAO_BO_LEN; uj++) 2291 { 2292 currentRDCost += currentRdCostTableBo[uj]; 2293 } 2294 2295 if( currentRDCost < bestRDCostTableBo) 2296 { 2297 bestRDCostTableBo = currentRDCost; 2298 bestClassTableBo = i; 2299 } 2300 } 2301 2302 // Re code all Offsets 2303 // Code Center 2304 estDist = 0; 2305 for(classIdx = bestClassTableBo; classIdx < bestClassTableBo+SAO_BO_LEN; classIdx++) 2306 { 2307 estDist += currentDistortionTableBo[classIdx]; 2308 } 2309 } 2310 resetSaoUnit(&saoLcuParamRdo); 2311 saoLcuParamRdo.length = m_iNumClass[typeIdx]; 2312 saoLcuParamRdo.typeIdx = typeIdx; 2313 saoLcuParamRdo.mergeLeftFlag = 0; 2314 saoLcuParamRdo.mergeUpFlag = 0; 2315 saoLcuParamRdo.subTypeIdx = (typeIdx == SAO_BO) ? bestClassTableBo : 0; 2316 for (classIdx = 0; classIdx < saoLcuParamRdo.length; classIdx++) 2317 { 2318 saoLcuParamRdo.offset[classIdx] = (Int)m_iOffset[yCbCr][typeIdx][classIdx+saoLcuParamRdo.subTypeIdx+1]; 2319 } 2320 m_pcRDGoOnSbacCoder->load(m_pppcRDSbacCoder[0][CI_TEMP_BEST]); 2321 m_pcRDGoOnSbacCoder->resetBits(); 2322 m_pcEntropyCoder->encodeSaoOffset(&saoLcuParamRdo, yCbCr); 2323 2324 estRate = m_pcEntropyCoder->getNumberOfWrittenBits(); 2325 m_dCost[yCbCr][typeIdx] = (Double)((Double)estDist + lambda * (Double) estRate); 2326 2327 if(m_dCost[yCbCr][typeIdx] < dCostPartBest) 2328 { 2329 dCostPartBest = m_dCost[yCbCr][typeIdx]; 2330 copySaoUnit(saoLcuParam, &saoLcuParamRdo ); 2331 bestDist = estDist; 2332 } 2333 } 2334 2335 compDistortion[0] += ((Double)bestDist/lambda); 2336 m_pcRDGoOnSbacCoder->load(m_pppcRDSbacCoder[0][CI_TEMP_BEST]); 2337 m_pcEntropyCoder->encodeSaoOffset(saoLcuParam, yCbCr); 2338 m_pcRDGoOnSbacCoder->store( m_pppcRDSbacCoder[0][CI_TEMP_BEST] ); 2339 2340 // merge left or merge up 2341 for (Int idxNeighbor=0;idxNeighbor<2;idxNeighbor++) 2342 { 2343 saoLcuParamNeighbor = NULL; 2344 if (allowMergeLeft && addrLeft>=0 && idxNeighbor ==0) 2345 { 2346 saoLcuParamNeighbor = &(saoParam->saoLcuParam[yCbCr][addrLeft]); 2347 } 2348 else if (allowMergeUp && addrUp>=0 && idxNeighbor ==1) 2349 { 2350 saoLcuParamNeighbor = &(saoParam->saoLcuParam[yCbCr][addrUp]); 2351 } 2352 if (saoLcuParamNeighbor!=NULL) 2353 { 2354 estDist = 0; 2355 typeIdx = saoLcuParamNeighbor->typeIdx; 2356 if (typeIdx>=0) 2357 { 2358 Int mergeBandPosition = (typeIdx == SAO_BO)?saoLcuParamNeighbor->subTypeIdx:0; 2359 Int merge_iOffset; 2360 for(classIdx = 0; classIdx < m_iNumClass[typeIdx]; classIdx++) 2361 { 2362 merge_iOffset = saoLcuParamNeighbor->offset[classIdx]; 2363 estDist += estSaoDist(m_iCount [yCbCr][typeIdx][classIdx+mergeBandPosition+1], merge_iOffset, m_iOffsetOrg[yCbCr][typeIdx][classIdx+mergeBandPosition+1], shift); 2364 } 2365 } 2366 else 2367 { 2368 estDist = 0; 2369 } 2370 2371 copySaoUnit(&compSaoParam[idxNeighbor], saoLcuParamNeighbor ); 2372 compSaoParam[idxNeighbor].mergeUpFlag = idxNeighbor; 2373 compSaoParam[idxNeighbor].mergeLeftFlag = !idxNeighbor; 2374 2375 compDistortion[idxNeighbor+1] += ((Double)estDist/lambda); 2376 } 2377 } 2378 } 2379 2380 Void TEncSampleAdaptiveOffset::sao2ChromaParamDist(Int allowMergeLeft, Int allowMergeUp, SAOParam *saoParam, Int addr, Int addrUp, Int addrLeft, Double lambda, SaoLcuParam *crSaoParam, SaoLcuParam *cbSaoParam, Double *distortion) 2381 { 2382 Int typeIdx; 2383 2384 Int64 estDist[2]; 2385 Int classIdx; 2386 Int shift = g_uiBitIncrement << 1; 2387 Int64 bestDist = 0; 2388 2389 SaoLcuParam* saoLcuParam[2] = {&(saoParam->saoLcuParam[1][addr]), &(saoParam->saoLcuParam[2][addr])}; 2390 SaoLcuParam* saoLcuParamNeighbor[2] = {NULL, NULL}; 2391 SaoLcuParam* saoMergeParam[2][2]; 2392 saoMergeParam[0][0] = &crSaoParam[0]; 2393 saoMergeParam[0][1] = &crSaoParam[1]; 2394 saoMergeParam[1][0] = &cbSaoParam[0]; 2395 saoMergeParam[1][1] = &cbSaoParam[1]; 2396 2397 resetSaoUnit(saoLcuParam[0]); 2398 resetSaoUnit(saoLcuParam[1]); 2399 resetSaoUnit(saoMergeParam[0][0]); 2400 resetSaoUnit(saoMergeParam[0][1]); 2401 resetSaoUnit(saoMergeParam[1][0]); 2402 resetSaoUnit(saoMergeParam[1][1]); 2403 2404 Double costPartBest = MAX_DOUBLE; 2405 2406 Double bestRDCostTableBo; 2407 Int bestClassTableBo[2] = {0, 0}; 2408 Int currentDistortionTableBo[MAX_NUM_SAO_CLASS]; 2409 Double currentRdCostTableBo[MAX_NUM_SAO_CLASS]; 2410 2411 SaoLcuParam saoLcuParamRdo[2]; 2412 Double estRate = 0; 2413 2414 resetSaoUnit(&saoLcuParamRdo[0]); 2415 resetSaoUnit(&saoLcuParamRdo[1]); 2416 2417 m_pcRDGoOnSbacCoder->load(m_pppcRDSbacCoder[0][CI_TEMP_BEST]); 2418 m_pcRDGoOnSbacCoder->resetBits(); 2419 m_pcEntropyCoder->encodeSaoOffset(&saoLcuParamRdo[0], 1); 2420 m_pcEntropyCoder->encodeSaoOffset(&saoLcuParamRdo[1], 2); 2421 2422 costPartBest = m_pcEntropyCoder->getNumberOfWrittenBits()*lambda ; 2423 copySaoUnit(saoLcuParam[0], &saoLcuParamRdo[0] ); 2424 copySaoUnit(saoLcuParam[1], &saoLcuParamRdo[1] ); 2425 2426 for (typeIdx=0; typeIdx<MAX_NUM_SAO_TYPE; typeIdx++) 2427 { 2428 if( typeIdx == SAO_BO ) 2429 { 2430 // Estimate Best Position 2431 for(Int compIdx = 0; compIdx < 2; compIdx++) 2432 { 2433 Double currentRDCost = 0.0; 2434 bestRDCostTableBo = MAX_DOUBLE; 2435 estDist[compIdx] = estSaoTypeDist(compIdx+1, typeIdx, shift, lambda, currentDistortionTableBo, currentRdCostTableBo); 2436 2437 for(Int i=0; i< SAO_MAX_BO_CLASSES -SAO_BO_LEN +1; i++) 2438 { 2439 currentRDCost = 0.0; 2440 for(UInt uj = i; uj < i+SAO_BO_LEN; uj++) 2441 { 2442 currentRDCost += currentRdCostTableBo[uj]; 2443 } 2444 2445 if( currentRDCost < bestRDCostTableBo) 2446 { 2447 bestRDCostTableBo = currentRDCost; 2448 bestClassTableBo[compIdx] = i; 2449 } 2450 } 2451 2452 // Re code all Offsets 2453 // Code Center 2454 estDist[compIdx] = 0; 2455 for(classIdx = bestClassTableBo[compIdx]; classIdx < bestClassTableBo[compIdx]+SAO_BO_LEN; classIdx++) 2456 { 2457 estDist[compIdx] += currentDistortionTableBo[classIdx]; 2458 } 2459 } 2460 } 2461 else 2462 { 2463 estDist[0] = estSaoTypeDist(1, typeIdx, shift, lambda, currentDistortionTableBo, currentRdCostTableBo); 2464 estDist[1] = estSaoTypeDist(2, typeIdx, shift, lambda, currentDistortionTableBo, currentRdCostTableBo); 2465 } 2466 2467 m_pcRDGoOnSbacCoder->load(m_pppcRDSbacCoder[0][CI_TEMP_BEST]); 2468 m_pcRDGoOnSbacCoder->resetBits(); 2469 2470 for(Int compIdx = 0; compIdx < 2; compIdx++) 2471 { 2472 resetSaoUnit(&saoLcuParamRdo[compIdx]); 2473 saoLcuParamRdo[compIdx].length = m_iNumClass[typeIdx]; 2474 saoLcuParamRdo[compIdx].typeIdx = typeIdx; 2475 saoLcuParamRdo[compIdx].mergeLeftFlag = 0; 2476 saoLcuParamRdo[compIdx].mergeUpFlag = 0; 2477 saoLcuParamRdo[compIdx].subTypeIdx = (typeIdx == SAO_BO) ? bestClassTableBo[compIdx] : 0; 2478 for (classIdx = 0; classIdx < saoLcuParamRdo[compIdx].length; classIdx++) 2479 { 2480 saoLcuParamRdo[compIdx].offset[classIdx] = (Int)m_iOffset[compIdx+1][typeIdx][classIdx+saoLcuParamRdo[compIdx].subTypeIdx+1]; 2481 } 2482 m_pcEntropyCoder->encodeSaoOffset(&saoLcuParamRdo[compIdx], compIdx+1); 2483 } 2484 estRate = m_pcEntropyCoder->getNumberOfWrittenBits(); 2485 m_dCost[1][typeIdx] = (Double)((Double)(estDist[0] + estDist[1]) + lambda * (Double) estRate); 2486 2487 if(m_dCost[1][typeIdx] < costPartBest) 2488 { 2489 costPartBest = m_dCost[1][typeIdx]; 2490 copySaoUnit(saoLcuParam[0], &saoLcuParamRdo[0] ); 2491 copySaoUnit(saoLcuParam[1], &saoLcuParamRdo[1] ); 2492 bestDist = (estDist[0]+estDist[1]); 2493 } 2494 } 2495 2496 distortion[0] += ((Double)bestDist/lambda); 2497 m_pcRDGoOnSbacCoder->load(m_pppcRDSbacCoder[0][CI_TEMP_BEST]); 2498 m_pcEntropyCoder->encodeSaoOffset(saoLcuParam[0], 1); 2499 m_pcEntropyCoder->encodeSaoOffset(saoLcuParam[1], 2); 2500 m_pcRDGoOnSbacCoder->store( m_pppcRDSbacCoder[0][CI_TEMP_BEST] ); 2501 2502 // merge left or merge up 2503 2504 for (Int idxNeighbor=0;idxNeighbor<2;idxNeighbor++) 2505 { 2506 for(Int compIdx = 0; compIdx < 2; compIdx++) 2507 { 2508 saoLcuParamNeighbor[compIdx] = NULL; 2509 if (allowMergeLeft && addrLeft>=0 && idxNeighbor ==0) 2510 { 2511 saoLcuParamNeighbor[compIdx] = &(saoParam->saoLcuParam[compIdx+1][addrLeft]); 2512 } 2513 else if (allowMergeUp && addrUp>=0 && idxNeighbor ==1) 2514 { 2515 saoLcuParamNeighbor[compIdx] = &(saoParam->saoLcuParam[compIdx+1][addrUp]); 2516 } 2517 if (saoLcuParamNeighbor[compIdx]!=NULL) 2518 { 2519 estDist[compIdx] = 0; 2520 typeIdx = saoLcuParamNeighbor[compIdx]->typeIdx; 2521 if (typeIdx>=0) 2522 { 2523 Int mergeBandPosition = (typeIdx == SAO_BO)?saoLcuParamNeighbor[compIdx]->subTypeIdx:0; 2524 Int merge_iOffset; 2525 for(classIdx = 0; classIdx < m_iNumClass[typeIdx]; classIdx++) 2526 { 2527 merge_iOffset = saoLcuParamNeighbor[compIdx]->offset[classIdx]; 2528 estDist[compIdx] += estSaoDist(m_iCount [compIdx+1][typeIdx][classIdx+mergeBandPosition+1], merge_iOffset, m_iOffsetOrg[compIdx+1][typeIdx][classIdx+mergeBandPosition+1], shift); 2529 } 2530 } 2531 else 2532 { 2533 estDist[compIdx] = 0; 2534 } 2535 2536 copySaoUnit(saoMergeParam[compIdx][idxNeighbor], saoLcuParamNeighbor[compIdx] ); 2537 saoMergeParam[compIdx][idxNeighbor]->mergeUpFlag = idxNeighbor; 2538 saoMergeParam[compIdx][idxNeighbor]->mergeLeftFlag = !idxNeighbor; 2539 distortion[idxNeighbor+1] += ((Double)estDist[compIdx]/lambda); 2540 } 2541 } 2542 } 2543 } 2544 #else 2545 TEncSampleAdaptiveOffset::TEncSampleAdaptiveOffset() 2546 { 2547 m_pcEntropyCoder = NULL; 2548 m_pppcRDSbacCoder = NULL; 2549 m_pcRDGoOnSbacCoder = NULL; 2550 m_pppcBinCoderCABAC = NULL; 2551 m_iCount = NULL; 2552 m_iOffset = NULL; 2553 m_iOffsetOrg = NULL; 2554 m_iRate = NULL; 2555 m_iDist = NULL; 2556 m_dCost = NULL; 2557 m_dCostPartBest = NULL; 2558 m_iDistOrg = NULL; 2559 m_iTypePartBest = NULL; 2560 } 2561 TEncSampleAdaptiveOffset::~TEncSampleAdaptiveOffset() 2562 { 2563 2564 } 2565 // ==================================================================================================================== 2566 // Constants 2567 // ==================================================================================================================== 2568 2569 2570 // ==================================================================================================================== 2571 // Tables 2572 // ==================================================================================================================== 2573 2574 inline Double xRoundIbdi2(Double x) 2575 { 2576 #if FULL_NBIT 2577 Int bitDepthMinus8 = g_uiBitDepth - 8; 2578 return ((x)>0) ? (Int)(((Int)(x)+(1<<(bitDepthMinus8-1)))/(1<<bitDepthMinus8)) : ((Int)(((Int)(x)-(1<<(bitDepthMinus8-1)))/(1<<bitDepthMinus8))); 2579 #else 2580 return ((x)>0) ? (Int)(((Int)(x)+(1<<(g_uiBitIncrement-1)))/(1<<g_uiBitIncrement)) : ((Int)(((Int)(x)-(1<<(g_uiBitIncrement-1)))/(1<<g_uiBitIncrement))); 2581 #endif 2582 } 2583 2584 /** rounding with IBDI 2585 * \param x 2586 */ 2587 inline Double xRoundIbdi(Double x) 2588 { 2589 #if FULL_NBIT 2590 return (g_uiBitDepth > 8 ? xRoundIbdi2((x)) : ((x)>=0 ? ((Int)((x)+0.5)) : ((Int)((x)-0.5)))) ; 2591 #else 2592 return (g_uiBitIncrement >0 ? xRoundIbdi2((x)) : ((x)>=0 ? ((Int)((x)+0.5)) : ((Int)((x)-0.5)))) ; 2593 #endif 2594 } 2595 2596 2597 2598 /** process SAO for one partition 2599 * \param *psQTPart, iPartIdx, dLambda 2600 */ 2601 Void TEncSampleAdaptiveOffset::rdoSaoOnePart(SAOQTPart *psQTPart, Int iPartIdx, Double dLambda) 2602 { 2603 Int iTypeIdx; 2604 Int iNumTotalType = MAX_NUM_SAO_TYPE; 2605 SAOQTPart* pOnePart = &(psQTPart[iPartIdx]); 2606 2607 Int64 iEstDist; 2608 Int64 iOffsetOrg; 2609 Int64 iOffset; 2610 Int64 iCount; 2611 Int iClassIdx; 2612 Int uiShift = g_uiBitIncrement << 1; 2613 UInt uiDepth = pOnePart->PartLevel; 2614 2615 m_iDistOrg [iPartIdx] = 0; 2616 2617 Double bestRDCostTableBo = MAX_DOUBLE; 2618 Int bestClassTableBo = 0; 2619 Int currentDistortionTableBo[MAX_NUM_SAO_CLASS]; 2620 Double currentRdCostTableBo[MAX_NUM_SAO_CLASS]; 2621 2622 #if HHI_INTERVIEW_SKIP 2623 Int iFrameWidthInCU = m_pcPic->getFrameWidthInCU(); 2624 Int LcuIdxX = psQTPart->StartCUX; 2625 Int LcuIdxY = psQTPart->StartCUY; 2626 Int iAddr = LcuIdxY*iFrameWidthInCU + LcuIdxX; 2627 TComDataCU *pcCU = m_pcPic->getCU(iAddr); 2628 Bool bRenderable = pcCU->getRenderable(0) ; 2629 2630 #endif 2631 for (iTypeIdx=-1; iTypeIdx<iNumTotalType; iTypeIdx++) 2632 { 2633 if( m_bUseSBACRD ) 2634 { 2635 m_pcRDGoOnSbacCoder->load(m_pppcRDSbacCoder[uiDepth][CI_CURR_BEST]); 2636 m_pcRDGoOnSbacCoder->resetBits(); 2637 } 2638 else 2639 { 2640 m_pcEntropyCoder->resetEntropy(); 2641 m_pcEntropyCoder->resetBits(); 2642 } 2643 2644 iEstDist = 0; 2645 2646 m_pcEntropyCoder->m_pcEntropyCoderIf->codeSaoTypeIdx(iTypeIdx+1); 2647 2648 if (iTypeIdx>=0) 2649 { 2650 2651 for(iClassIdx=1; iClassIdx < ( (iTypeIdx < SAO_BO) ? m_iNumClass[iTypeIdx]+1 : SAO_MAX_BO_CLASSES+1); iClassIdx++) 2652 { 2653 if( iTypeIdx == SAO_BO) 2654 { 2655 currentDistortionTableBo[iClassIdx-1] = 0; 2656 currentRdCostTableBo[iClassIdx-1] = dLambda; 2657 } 2658 #if HHI_INTERVIEW_SKIP 2659 if(m_iCount [iPartIdx][iTypeIdx][iClassIdx] && !bRenderable) 2660 #else 2661 if(m_iCount [iPartIdx][iTypeIdx][iClassIdx]) 2662 #endif 2663 { 2664 #if FULL_NBIT 2665 m_iOffset[iPartIdx][iTypeIdx][iClassIdx] = (Int64) xRoundIbdi((Double)(m_iOffsetOrg[iPartIdx][iTypeIdx][iClassIdx]<<g_uiBitDepth-8) / (Double)(m_iCount [iPartIdx][iTypeIdx][iClassIdx]<<m_uiSaoBitIncrease)); 2666 #else 2667 m_iOffset[iPartIdx][iTypeIdx][iClassIdx] = (Int64) xRoundIbdi((Double)(m_iOffsetOrg[iPartIdx][iTypeIdx][iClassIdx]<<g_uiBitIncrement) / (Double)(m_iCount [iPartIdx][iTypeIdx][iClassIdx]<<m_uiSaoBitIncrease)); 2668 #endif 2669 m_iOffset[iPartIdx][iTypeIdx][iClassIdx] = Clip3(-m_iOffsetTh, m_iOffsetTh-1, (Int)m_iOffset[iPartIdx][iTypeIdx][iClassIdx]); 2670 2671 if (iTypeIdx < 4) 2672 { 2673 if ( m_iOffset[iPartIdx][iTypeIdx][iClassIdx]<0 && iClassIdx<3 ) 2674 { 2675 m_iOffset[iPartIdx][iTypeIdx][iClassIdx] = 0; 2676 } 2677 if ( m_iOffset[iPartIdx][iTypeIdx][iClassIdx]>0 && iClassIdx>=3) 2678 { 2679 m_iOffset[iPartIdx][iTypeIdx][iClassIdx] = 0; 2680 } 2681 } 2682 { 2683 //Clean up, best_q_offset. 2684 Int64 iIterOffset, iTempOffset; 2685 Int64 iTempDist, iTempRate; 2686 Double dTempCost, dTempMinCost; 2687 UInt uiLength, uiTemp; 2688 2689 iIterOffset = m_iOffset[iPartIdx][iTypeIdx][iClassIdx]; 2690 m_iOffset[iPartIdx][iTypeIdx][iClassIdx] = 0; 2691 dTempMinCost = dLambda; // 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. 2692 2693 while (iIterOffset != 0) 2694 { 2695 // Calculate the bits required for signalling the offset 2696 uiLength = 1; 2697 uiTemp = (UInt)((iIterOffset <= 0) ? ( (-iIterOffset<<1) + 1 ) : (iIterOffset<<1)); 2698 while( 1 != uiTemp ) 2699 { 2700 uiTemp >>= 1; 2701 uiLength += 2; 2702 } 2703 iTempRate = (uiLength >> 1) + ((uiLength+1) >> 1); 2704 2705 // Do the dequntization before distorion calculation 2706 iTempOffset = iIterOffset << m_uiSaoBitIncrease; 2707 iTempDist = (( m_iCount [iPartIdx][iTypeIdx][iClassIdx]*iTempOffset*iTempOffset-m_iOffsetOrg[iPartIdx][iTypeIdx][iClassIdx]*iTempOffset*2 ) >> uiShift); 2708 2709 dTempCost = ((Double)iTempDist + dLambda * (Double) iTempRate); 2710 if(dTempCost < dTempMinCost) 2711 { 2712 dTempMinCost = dTempCost; 2713 m_iOffset[iPartIdx][iTypeIdx][iClassIdx] = iIterOffset; 2714 if(iTypeIdx == SAO_BO) 2715 { 2716 currentDistortionTableBo[iClassIdx-1] = (Int) iTempDist; 2717 currentRdCostTableBo[iClassIdx-1] = dTempCost; 2718 } 2719 } 2720 iIterOffset = (iIterOffset > 0) ? (iIterOffset-1):(iIterOffset+1); 2721 } 2722 2723 } 2724 } 2725 else 2726 { 2727 m_iOffsetOrg[iPartIdx][iTypeIdx][iClassIdx] = 0; 2728 m_iOffset[iPartIdx][iTypeIdx][iClassIdx] = 0; 2729 } 2730 if( iTypeIdx != SAO_BO ) 2731 { 2732 iCount = m_iCount [iPartIdx][iTypeIdx][iClassIdx]; 2733 iOffset = m_iOffset[iPartIdx][iTypeIdx][iClassIdx] << m_uiSaoBitIncrease; 2734 iOffsetOrg = m_iOffsetOrg[iPartIdx][iTypeIdx][iClassIdx]; 2735 iEstDist += (( iCount*iOffset*iOffset-iOffsetOrg*iOffset*2 ) >> uiShift); 2736 if (iTypeIdx < 4) 2737 { 2738 if (iClassIdx<3) 2739 { 2740 m_pcEntropyCoder->m_pcEntropyCoderIf->codeSaoUvlc((Int)m_iOffset[iPartIdx][iTypeIdx][iClassIdx]); 2741 } 2742 else 2743 { 2744 m_pcEntropyCoder->m_pcEntropyCoderIf->codeSaoUvlc((Int)-m_iOffset[iPartIdx][iTypeIdx][iClassIdx]); 2745 } 2746 } 2747 else 2748 { 2749 m_pcEntropyCoder->m_pcEntropyCoderIf->codeSaoSvlc((Int)m_iOffset[iPartIdx][iTypeIdx][iClassIdx]); 2750 } 2751 } 2752 } 2753 2754 if( iTypeIdx == SAO_BO ) 2755 { 2756 // Estimate Best Position 2757 Double currentRDCost = 0.0; 2758 2759 for(Int i=0; i< SAO_MAX_BO_CLASSES -SAO_BO_LEN +1; i++) 2760 { 2761 currentRDCost = 0.0; 2762 for(UInt uj = i; uj < i+SAO_BO_LEN; uj++) 2763 { 2764 currentRDCost += currentRdCostTableBo[uj]; 2765 } 2766 2767 if( currentRDCost < bestRDCostTableBo) 2768 { 2769 bestRDCostTableBo = currentRDCost; 2770 bestClassTableBo = i; 2771 } 2772 } 2773 2774 // Re code all Offsets 2775 // Code Center 2776 m_pcEntropyCoder->m_pcEntropyCoderIf->codeSaoUflc( (UInt) (bestClassTableBo) ); 2777 2778 for(iClassIdx = bestClassTableBo; iClassIdx < bestClassTableBo+SAO_BO_LEN; iClassIdx++) 2779 { 2780 m_pcEntropyCoder->m_pcEntropyCoderIf->codeSaoSvlc((Int)m_iOffset[iPartIdx][iTypeIdx][iClassIdx+1]); 2781 iEstDist += currentDistortionTableBo[iClassIdx]; 2782 } 2783 } 2784 2785 m_iDist[iPartIdx][iTypeIdx] = iEstDist; 2786 m_iRate[iPartIdx][iTypeIdx] = m_pcEntropyCoder->getNumberOfWrittenBits(); 2787 2788 m_dCost[iPartIdx][iTypeIdx] = (Double)((Double)m_iDist[iPartIdx][iTypeIdx] + dLambda * (Double) m_iRate[iPartIdx][iTypeIdx]); 2789 2790 if(m_dCost[iPartIdx][iTypeIdx] < m_dCostPartBest[iPartIdx]) 2791 { 2792 m_iDistOrg [iPartIdx] = 0; 2793 m_dCostPartBest[iPartIdx] = m_dCost[iPartIdx][iTypeIdx]; 2794 m_iTypePartBest[iPartIdx] = iTypeIdx; 2795 if( m_bUseSBACRD ) 2796 m_pcRDGoOnSbacCoder->store( m_pppcRDSbacCoder[pOnePart->PartLevel][CI_TEMP_BEST] ); 2797 } 2798 } 2799 else 2800 { 2801 if(m_iDistOrg[iPartIdx] < m_dCostPartBest[iPartIdx] ) 2802 { 2803 m_dCostPartBest[iPartIdx] = (Double) m_iDistOrg[iPartIdx] + m_pcEntropyCoder->getNumberOfWrittenBits()*dLambda ; 2804 m_iTypePartBest[iPartIdx] = -1; 2805 if( m_bUseSBACRD ) 2806 m_pcRDGoOnSbacCoder->store( m_pppcRDSbacCoder[pOnePart->PartLevel][CI_TEMP_BEST] ); 2807 } 2808 } 2809 } 2810 2811 pOnePart->bProcessed = true; 2812 pOnePart->bSplit = false; 2813 pOnePart->iMinDist = m_iTypePartBest[iPartIdx] >= 0 ? m_iDist[iPartIdx][m_iTypePartBest[iPartIdx]] : m_iDistOrg[iPartIdx]; 2814 pOnePart->iMinRate = (Int) (m_iTypePartBest[iPartIdx] >= 0 ? m_iRate[iPartIdx][m_iTypePartBest[iPartIdx]] : 0); 2815 pOnePart->dMinCost = pOnePart->iMinDist + dLambda * pOnePart->iMinRate; 2816 pOnePart->iBestType = m_iTypePartBest[iPartIdx]; 2817 if (pOnePart->iBestType != -1) 2818 { 2819 // pOnePart->bEnableFlag = 1; 2820 pOnePart->iLength = m_iNumClass[pOnePart->iBestType]; 2821 Int minIndex = 0; 2822 if( pOnePart->iBestType == SAO_BO ) 2823 { 2824 pOnePart->bandPosition = bestClassTableBo; 2825 minIndex = pOnePart->bandPosition; 2826 } 2827 for (Int i=0; i< pOnePart->iLength ; i++) 2828 { 2829 pOnePart->iOffset[i] = (Int) m_iOffset[iPartIdx][pOnePart->iBestType][minIndex+i+1]; 2830 } 2831 2832 } 2833 else 2834 { 2835 // pOnePart->bEnableFlag = 0; 2836 pOnePart->iLength = 0; 2837 } 2838 } 2839 2840 /** Run partition tree disable 2841 */ 2842 Void TEncSampleAdaptiveOffset::disablePartTree(SAOQTPart *psQTPart, Int iPartIdx) 2843 { 2844 SAOQTPart* pOnePart= &(psQTPart[iPartIdx]); 2845 pOnePart->bSplit = false; 2846 pOnePart->iLength = 0; 2847 pOnePart->iBestType = -1; 2848 2849 if (pOnePart->PartLevel < m_uiMaxSplitLevel) 2850 { 2851 for (Int i=0; i<NUM_DOWN_PART; i++) 2852 { 2853 disablePartTree(psQTPart, pOnePart->DownPartsIdx[i]); 2854 } 2855 } 2856 } 2857 2858 /** Run quadtree decision function 2859 * \param iPartIdx, pcPicOrg, pcPicDec, pcPicRest, &dCostFinal 2860 */ 2861 Void TEncSampleAdaptiveOffset::runQuadTreeDecision(SAOQTPart *psQTPart, Int iPartIdx, Double &dCostFinal, Int iMaxLevel, Double dLambda) 2862 { 2863 SAOQTPart* pOnePart = &(psQTPart[iPartIdx]); 2864 2865 UInt uiDepth = pOnePart->PartLevel; 2866 UInt uhNextDepth = uiDepth+1; 2867 2868 if (iPartIdx == 0) 2869 { 2870 dCostFinal = 0; 2871 } 2872 2873 //SAO for this part 2874 if(!pOnePart->bProcessed) 2875 { 2876 rdoSaoOnePart (psQTPart, iPartIdx, dLambda); 2877 } 2878 2879 //SAO for sub 4 parts 2880 if (pOnePart->PartLevel < iMaxLevel) 2881 { 2882 Double dCostNotSplit = dLambda + pOnePart->dMinCost; 2883 Double dCostSplit = dLambda; 2884 2885 for (Int i=0; i< NUM_DOWN_PART ;i++) 2886 { 2887 if( m_bUseSBACRD ) 2888 { 2889 if ( 0 == i) //initialize RD with previous depth buffer 2890 { 2891 m_pppcRDSbacCoder[uhNextDepth][CI_CURR_BEST]->load(m_pppcRDSbacCoder[uiDepth][CI_CURR_BEST]); 2892 } 2893 else 2894 { 2895 m_pppcRDSbacCoder[uhNextDepth][CI_CURR_BEST]->load(m_pppcRDSbacCoder[uhNextDepth][CI_NEXT_BEST]); 2896 } 2897 } 2898 runQuadTreeDecision(psQTPart, pOnePart->DownPartsIdx[i], dCostFinal, iMaxLevel, dLambda); 2899 dCostSplit += dCostFinal; 2900 if( m_bUseSBACRD ) 2901 { 2902 m_pppcRDSbacCoder[uhNextDepth][CI_NEXT_BEST]->load(m_pppcRDSbacCoder[uhNextDepth][CI_TEMP_BEST]); 2903 } 2904 } 2905 2906 if(dCostSplit < dCostNotSplit) 2907 { 2908 dCostFinal = dCostSplit; 2909 pOnePart->bSplit = true; 2910 pOnePart->iLength = 0; 2911 pOnePart->iBestType = -1; 2912 if( m_bUseSBACRD ) 2913 { 2914 m_pppcRDSbacCoder[uiDepth][CI_NEXT_BEST]->load(m_pppcRDSbacCoder[uhNextDepth][CI_NEXT_BEST]); 2915 } 2916 } 2917 else 2918 { 2919 dCostFinal = dCostNotSplit; 2920 pOnePart->bSplit = false; 2921 for (Int i=0; i<NUM_DOWN_PART; i++) 2922 { 2923 disablePartTree(psQTPart, pOnePart->DownPartsIdx[i]); 2924 } 2925 if( m_bUseSBACRD ) 2926 { 2927 m_pppcRDSbacCoder[uiDepth][CI_NEXT_BEST]->load(m_pppcRDSbacCoder[uiDepth][CI_TEMP_BEST]); 2928 } 2929 } 2930 } 2931 else 2932 { 2933 dCostFinal = pOnePart->dMinCost; 2934 } 2935 } 2936 2937 /** delete allocated memory of TEncSampleAdaptiveOffset class. 2938 */ 2939 Void TEncSampleAdaptiveOffset::destroyEncBuffer() 2940 { 2941 for (Int i=0;i<m_iNumTotalParts;i++) 2942 { 2943 for (Int j=0;j<MAX_NUM_SAO_TYPE;j++) 2944 { 2945 if (m_iCount [i][j]) 2946 { 2947 delete [] m_iCount [i][j]; 2948 } 2949 if (m_iOffset[i][j]) 2950 { 2951 delete [] m_iOffset[i][j]; 2952 } 2953 if (m_iOffsetOrg[i][j]) 2954 { 2955 delete [] m_iOffsetOrg[i][j]; 2956 } 2957 } 2958 if (m_iRate[i]) 2959 { 2960 delete [] m_iRate[i]; 2961 } 2962 if (m_iDist[i]) 2963 { 2964 delete [] m_iDist[i]; 2965 } 2966 if (m_dCost[i]) 2967 { 2968 delete [] m_dCost[i]; 2969 } 2970 if (m_iCount [i]) 2971 { 2972 delete [] m_iCount [i]; 2973 } 2974 if (m_iOffset[i]) 2975 { 2976 delete [] m_iOffset[i]; 2977 } 2978 if (m_iOffsetOrg[i]) 2979 { 2980 delete [] m_iOffsetOrg[i]; 2981 } 2982 2983 } 2984 if (m_iDistOrg) 2985 { 2986 delete [] m_iDistOrg ; m_iDistOrg = NULL; 2987 } 2988 if (m_dCostPartBest) 2989 { 2990 delete [] m_dCostPartBest ; m_dCostPartBest = NULL; 2991 } 2992 if (m_iTypePartBest) 2993 { 2994 delete [] m_iTypePartBest ; m_iTypePartBest = NULL; 2995 } 2996 if (m_iRate) 2997 { 2998 delete [] m_iRate ; m_iRate = NULL; 2999 } 3000 if (m_iDist) 3001 { 3002 delete [] m_iDist ; m_iDist = NULL; 3003 } 3004 if (m_dCost) 3005 { 3006 delete [] m_dCost ; m_dCost = NULL; 3007 } 3008 if (m_iCount) 3009 { 3010 delete [] m_iCount ; m_iCount = NULL; 3011 } 3012 if (m_iOffset) 3013 { 3014 delete [] m_iOffset ; m_iOffset = NULL; 3015 } 3016 if (m_iOffsetOrg) 3017 { 3018 delete [] m_iOffsetOrg ; m_iOffsetOrg = NULL; 3019 } 3020 3021 Int iMaxDepth = 4; 3022 Int iDepth; 3023 for ( iDepth = 0; iDepth < iMaxDepth+1; iDepth++ ) 3024 { 3025 for (Int iCIIdx = 0; iCIIdx < CI_NUM; iCIIdx ++ ) 3026 { 3027 delete m_pppcRDSbacCoder[iDepth][iCIIdx]; 3028 delete m_pppcBinCoderCABAC[iDepth][iCIIdx]; 3029 } 3030 } 3031 3032 for ( iDepth = 0; iDepth < iMaxDepth+1; iDepth++ ) 3033 { 3034 delete [] m_pppcRDSbacCoder[iDepth]; 3035 delete [] m_pppcBinCoderCABAC[iDepth]; 3036 } 3037 3038 delete [] m_pppcRDSbacCoder; 3039 delete [] m_pppcBinCoderCABAC; 3040 } 3041 3042 /** create Encoder Buffer for SAO 3043 * \param 3044 */ 3045 Void TEncSampleAdaptiveOffset::createEncBuffer() 3046 { 3047 m_iDistOrg = new Int64 [m_iNumTotalParts]; 3048 m_dCostPartBest = new Double [m_iNumTotalParts]; 3049 m_iTypePartBest = new Int [m_iNumTotalParts]; 3050 3051 m_iRate = new Int64* [m_iNumTotalParts]; 3052 m_iDist = new Int64* [m_iNumTotalParts]; 3053 m_dCost = new Double*[m_iNumTotalParts]; 3054 3055 m_iCount = new Int64 **[m_iNumTotalParts]; 3056 m_iOffset = new Int64 **[m_iNumTotalParts]; 3057 m_iOffsetOrg = new Int64 **[m_iNumTotalParts]; 3058 3059 for (Int i=0;i<m_iNumTotalParts;i++) 3060 { 3061 m_iRate[i] = new Int64 [MAX_NUM_SAO_TYPE]; 3062 m_iDist[i] = new Int64 [MAX_NUM_SAO_TYPE]; 3063 m_dCost[i] = new Double [MAX_NUM_SAO_TYPE]; 3064 3065 m_iCount [i] = new Int64 *[MAX_NUM_SAO_TYPE]; 3066 m_iOffset[i] = new Int64 *[MAX_NUM_SAO_TYPE]; 3067 m_iOffsetOrg[i] = new Int64 *[MAX_NUM_SAO_TYPE]; 3068 3069 for (Int j=0;j<MAX_NUM_SAO_TYPE;j++) 3070 { 3071 m_iCount [i][j] = new Int64 [MAX_NUM_SAO_CLASS]; 3072 m_iOffset[i][j] = new Int64 [MAX_NUM_SAO_CLASS]; 3073 m_iOffsetOrg[i][j]= new Int64 [MAX_NUM_SAO_CLASS]; 3074 } 3075 } 3076 3077 Int iMaxDepth = 4; 3078 m_pppcRDSbacCoder = new TEncSbac** [iMaxDepth+1]; 3079 #if FAST_BIT_EST 3080 m_pppcBinCoderCABAC = new TEncBinCABACCounter** [iMaxDepth+1]; 3081 #else 3082 m_pppcBinCoderCABAC = new TEncBinCABAC** [iMaxDepth+1]; 3083 #endif 3084 3085 for ( Int iDepth = 0; iDepth < iMaxDepth+1; iDepth++ ) 3086 { 3087 m_pppcRDSbacCoder[iDepth] = new TEncSbac* [CI_NUM]; 3088 #if FAST_BIT_EST 3089 m_pppcBinCoderCABAC[iDepth] = new TEncBinCABACCounter* [CI_NUM]; 3090 #else 3091 m_pppcBinCoderCABAC[iDepth] = new TEncBinCABAC* [CI_NUM]; 3092 #endif 3093 for (Int iCIIdx = 0; iCIIdx < CI_NUM; iCIIdx ++ ) 3094 { 3095 m_pppcRDSbacCoder[iDepth][iCIIdx] = new TEncSbac; 3096 #if FAST_BIT_EST 3097 m_pppcBinCoderCABAC [iDepth][iCIIdx] = new TEncBinCABACCounter; 3098 #else 3099 m_pppcBinCoderCABAC [iDepth][iCIIdx] = new TEncBinCABAC; 3100 #endif 3101 m_pppcRDSbacCoder [iDepth][iCIIdx]->init( m_pppcBinCoderCABAC [iDepth][iCIIdx] ); 3102 } 3103 } 3104 } 3105 3106 /** Start SAO encoder 3107 * \param pcPic, pcEntropyCoder, pppcRDSbacCoder, pcRDGoOnSbacCoder 3108 */ 3109 Void TEncSampleAdaptiveOffset::startSaoEnc( TComPic* pcPic, TEncEntropy* pcEntropyCoder, TEncSbac*** pppcRDSbacCoder, TEncSbac* pcRDGoOnSbacCoder) 3110 { 3111 if( pcRDGoOnSbacCoder ) 3112 m_bUseSBACRD = true; 3113 else 3114 m_bUseSBACRD = false; 3115 3116 m_pcPic = pcPic; 3117 m_pcEntropyCoder = pcEntropyCoder; 3118 3119 m_pcRDGoOnSbacCoder = pcRDGoOnSbacCoder; 3120 m_pcEntropyCoder->resetEntropy(); 3121 m_pcEntropyCoder->resetBits(); 3122 3123 if( m_bUseSBACRD ) 3124 { 3125 m_pcRDGoOnSbacCoder->store( m_pppcRDSbacCoder[0][CI_NEXT_BEST]); 3126 m_pppcRDSbacCoder[0][CI_CURR_BEST]->load( m_pppcRDSbacCoder[0][CI_NEXT_BEST]); 3127 } 3128 } 3129 3130 /** End SAO encoder 3131 */ 3132 Void TEncSampleAdaptiveOffset::endSaoEnc() 3133 { 3134 m_pcPic = NULL; 3135 m_pcEntropyCoder = NULL; 3136 } 3137 3138 inline int xSign(int x) 3139 { 3140 return ((x >> 31) | ((int)( (((unsigned int) -x)) >> 31))); 3141 } 3142 3143 /** Calculate SAO statistics for non-cross-slice or non-cross-tile processing 3144 * \param pRecStart to-be-filtered block buffer pointer 3145 * \param pOrgStart original block buffer pointer 3146 * \param stride picture buffer stride 3147 * \param ppStat statistics buffer 3148 * \param ppCount counter buffer 3149 * \param width block width 3150 * \param height block height 3151 * \param pbBorderAvail availabilities of block border pixels 3152 */ 3153 Void TEncSampleAdaptiveOffset::calcSaoStatsBlock( Pel* pRecStart, Pel* pOrgStart, Int stride, Int64** ppStats, Int64** ppCount, UInt width, UInt height, Bool* pbBorderAvail) 3154 { 3155 Int64 *stats, *count; 3156 Int classIdx, posShift, startX, endX, startY, endY, signLeft,signRight,signDown,signDown1; 3157 Pel *pOrg, *pRec; 3158 UInt edgeType; 3159 Int x, y; 3160 3161 //--------- Band offset-----------// 3162 stats = ppStats[SAO_BO]; 3163 count = ppCount[SAO_BO]; 3164 pOrg = pOrgStart; 3165 pRec = pRecStart; 3166 for (y=0; y< height; y++) 3167 { 3168 for (x=0; x< width; x++) 3169 { 3170 classIdx = m_lumaTableBo[pRec[x]]; 3171 if (classIdx) 3172 { 3173 stats[classIdx] += (pOrg[x] - pRec[x]); 3174 count[classIdx] ++; 3175 } 3176 } 3177 pOrg += stride; 3178 pRec += stride; 3179 } 3180 //---------- Edge offset 0--------------// 3181 stats = ppStats[SAO_EO_0]; 3182 count = ppCount[SAO_EO_0]; 3183 pOrg = pOrgStart; 3184 pRec = pRecStart; 3185 3186 3187 startX = (pbBorderAvail[SGU_L]) ? 0 : 1; 3188 endX = (pbBorderAvail[SGU_R]) ? width : (width -1); 3189 for (y=0; y< height; y++) 3190 { 3191 signLeft = xSign(pRec[startX] - pRec[startX-1]); 3192 for (x=startX; x< endX; x++) 3193 { 3194 signRight = xSign(pRec[x] - pRec[x+1]); 3195 edgeType = signRight + signLeft + 2; 3196 signLeft = -signRight; 3197 3198 stats[m_auiEoTable[edgeType]] += (pOrg[x] - pRec[x]); 3199 count[m_auiEoTable[edgeType]] ++; 3200 } 3201 pRec += stride; 3202 pOrg += stride; 3203 } 3204 3205 //---------- Edge offset 1--------------// 3206 stats = ppStats[SAO_EO_1]; 3207 count = ppCount[SAO_EO_1]; 3208 pOrg = pOrgStart; 3209 pRec = pRecStart; 3210 3211 startY = (pbBorderAvail[SGU_T]) ? 0 : 1; 3212 endY = (pbBorderAvail[SGU_B]) ? height : height-1; 3213 if (!pbBorderAvail[SGU_T]) 3214 { 3215 pRec += stride; 3216 pOrg += stride; 3217 } 3218 3219 for (x=0; x< width; x++) 3220 { 3221 m_iUpBuff1[x] = xSign(pRec[x] - pRec[x-stride]); 3222 } 3223 for (y=startY; y<endY; y++) 3224 { 3225 for (x=0; x< width; x++) 3226 { 3227 signDown = xSign(pRec[x] - pRec[x+stride]); 3228 edgeType = signDown + m_iUpBuff1[x] + 2; 3229 m_iUpBuff1[x] = -signDown; 3230 3231 stats[m_auiEoTable[edgeType]] += (pOrg[x] - pRec[x]); 3232 count[m_auiEoTable[edgeType]] ++; 3233 } 3234 pOrg += stride; 3235 pRec += stride; 3236 } 3237 //---------- Edge offset 2--------------// 3238 stats = ppStats[SAO_EO_2]; 3239 count = ppCount[SAO_EO_2]; 3240 pOrg = pOrgStart; 3241 pRec = pRecStart; 3242 3243 posShift= stride + 1; 3244 3245 startX = (pbBorderAvail[SGU_L]) ? 0 : 1 ; 3246 endX = (pbBorderAvail[SGU_R]) ? width : (width-1); 3247 3248 //prepare 2nd line upper sign 3249 pRec += stride; 3250 for (x=startX; x< endX+1; x++) 3251 { 3252 m_iUpBuff1[x] = xSign(pRec[x] - pRec[x- posShift]); 3253 } 3254 3255 //1st line 3256 pRec -= stride; 3257 if(pbBorderAvail[SGU_TL]) 3258 { 3259 x= 0; 3260 edgeType = xSign(pRec[x] - pRec[x- posShift]) - m_iUpBuff1[x+1] + 2; 3261 stats[m_auiEoTable[edgeType]] += (pOrg[x] - pRec[x]); 3262 count[m_auiEoTable[edgeType]] ++; 3263 } 3264 if(pbBorderAvail[SGU_T]) 3265 { 3266 for(x= 1; x< endX; x++) 3267 { 3268 edgeType = xSign(pRec[x] - pRec[x- posShift]) - m_iUpBuff1[x+1] + 2; 3269 stats[m_auiEoTable[edgeType]] += (pOrg[x] - pRec[x]); 3270 count[m_auiEoTable[edgeType]] ++; 3271 } 3272 } 3273 pRec += stride; 3274 pOrg += stride; 3275 3276 //middle lines 3277 for (y= 1; y< height-1; y++) 3278 { 3279 for (x=startX; x<endX; x++) 3280 { 3281 signDown1 = xSign(pRec[x] - pRec[x+ posShift]) ; 3282 edgeType = signDown1 + m_iUpBuff1[x] + 2; 3283 stats[m_auiEoTable[edgeType]] += (pOrg[x] - pRec[x]); 3284 count[m_auiEoTable[edgeType]] ++; 3285 3286 m_iUpBufft[x+1] = -signDown1; 3287 } 3288 m_iUpBufft[startX] = xSign(pRec[stride+startX] - pRec[startX-1]); 3289 3290 ipSwap = m_iUpBuff1; 3291 m_iUpBuff1 = m_iUpBufft; 3292 m_iUpBufft = ipSwap; 3293 3294 pRec += stride; 3295 pOrg += stride; 3296 } 3297 3298 //last line 3299 if(pbBorderAvail[SGU_B]) 3300 { 3301 for(x= startX; x< width-1; x++) 3302 { 3303 edgeType = xSign(pRec[x] - pRec[x+ posShift]) + m_iUpBuff1[x] + 2; 3304 stats[m_auiEoTable[edgeType]] += (pOrg[x] - pRec[x]); 3305 count[m_auiEoTable[edgeType]] ++; 3306 } 3307 } 3308 if(pbBorderAvail[SGU_BR]) 3309 { 3310 x= width -1; 3311 edgeType = xSign(pRec[x] - pRec[x+ posShift]) + m_iUpBuff1[x] + 2; 3312 stats[m_auiEoTable[edgeType]] += (pOrg[x] - pRec[x]); 3313 count[m_auiEoTable[edgeType]] ++; 3314 } 3315 3316 //---------- Edge offset 3--------------// 3317 3318 stats = ppStats[SAO_EO_3]; 3319 count = ppCount[SAO_EO_3]; 3320 pOrg = pOrgStart; 3321 pRec = pRecStart; 3322 3323 posShift = stride - 1; 3324 startX = (pbBorderAvail[SGU_L]) ? 0 : 1; 3325 endX = (pbBorderAvail[SGU_R]) ? width : (width -1); 3326 3327 //prepare 2nd line upper sign 3328 pRec += stride; 3329 for (x=startX-1; x< endX; x++) 3330 { 3331 m_iUpBuff1[x] = xSign(pRec[x] - pRec[x- posShift]); 3332 } 3333 3334 3335 //first line 3336 pRec -= stride; 3337 if(pbBorderAvail[SGU_T]) 3338 { 3339 for(x= startX; x< width -1; x++) 3340 { 3341 edgeType = xSign(pRec[x] - pRec[x- posShift]) -m_iUpBuff1[x-1] + 2; 3342 stats[m_auiEoTable[edgeType]] += (pOrg[x] - pRec[x]); 3343 count[m_auiEoTable[edgeType]] ++; 3344 } 3345 } 3346 if(pbBorderAvail[SGU_TR]) 3347 { 3348 x= width-1; 3349 edgeType = xSign(pRec[x] - pRec[x- posShift]) -m_iUpBuff1[x-1] + 2; 3350 stats[m_auiEoTable[edgeType]] += (pOrg[x] - pRec[x]); 3351 count[m_auiEoTable[edgeType]] ++; 3352 } 3353 pRec += stride; 3354 pOrg += stride; 3355 3356 //middle lines 3357 for (y= 1; y< height-1; y++) 3358 { 3359 for(x= startX; x< endX; x++) 3360 { 3361 signDown1 = xSign(pRec[x] - pRec[x+ posShift]) ; 3362 edgeType = signDown1 + m_iUpBuff1[x] + 2; 3363 3364 stats[m_auiEoTable[edgeType]] += (pOrg[x] - pRec[x]); 3365 count[m_auiEoTable[edgeType]] ++; 3366 m_iUpBuff1[x-1] = -signDown1; 3367 3368 } 3369 m_iUpBuff1[endX-1] = xSign(pRec[endX-1 + stride] - pRec[endX]); 3370 3371 pRec += stride; 3372 pOrg += stride; 3373 } 3374 3375 //last line 3376 if(pbBorderAvail[SGU_BL]) 3377 { 3378 x= 0; 3379 edgeType = xSign(pRec[x] - pRec[x+ posShift]) + m_iUpBuff1[x] + 2; 3380 stats[m_auiEoTable[edgeType]] += (pOrg[x] - pRec[x]); 3381 count[m_auiEoTable[edgeType]] ++; 3382 3383 } 3384 if(pbBorderAvail[SGU_B]) 3385 { 3386 for(x= 1; x< endX; x++) 3387 { 3388 edgeType = xSign(pRec[x] - pRec[x+ posShift]) + m_iUpBuff1[x] + 2; 3389 stats[m_auiEoTable[edgeType]] += (pOrg[x] - pRec[x]); 3390 count[m_auiEoTable[edgeType]] ++; 3391 } 3392 } 3393 } 3394 3395 /** Calculate SAO statistics for current LCU 3396 * \param iAddr, iPartIdx, iYCbCr 3397 */ 3398 Void TEncSampleAdaptiveOffset::calcSaoStatsCu(Int iAddr, Int iPartIdx, Int iYCbCr) 3399 { 3400 if(!m_bUseNIF) 3401 { 3402 calcSaoStatsCuOrg( iAddr, iPartIdx, iYCbCr); 3403 } 3404 else 3405 { 3406 Int64** ppStats = m_iOffsetOrg[iPartIdx]; 3407 Int64** ppCount = m_iCount [iPartIdx]; 3408 3409 //parameters 3410 Int isChroma = (iYCbCr != 0)? 1:0; 3411 Int stride = (iYCbCr != 0)?(m_pcPic->getCStride()):(m_pcPic->getStride()); 3412 Pel* pPicOrg = getPicYuvAddr (m_pcPic->getPicYuvOrg(), iYCbCr); 3413 Pel* pPicRec = getPicYuvAddr(m_pcYuvTmp, iYCbCr); 3414 3415 std::vector<NDBFBlockInfo>& vFilterBlocks = *(m_pcPic->getCU(iAddr)->getNDBFilterBlocks()); 3416 3417 //variables 3418 UInt xPos, yPos, width, height; 3419 Bool* pbBorderAvail; 3420 UInt posOffset; 3421 3422 for(Int i=0; i< vFilterBlocks.size(); i++) 3423 { 3424 xPos = vFilterBlocks[i].posX >> isChroma; 3425 yPos = vFilterBlocks[i].posY >> isChroma; 3426 width = vFilterBlocks[i].width >> isChroma; 3427 height = vFilterBlocks[i].height >> isChroma; 3428 pbBorderAvail = vFilterBlocks[i].isBorderAvailable; 3429 3430 posOffset = (yPos* stride) + xPos; 3431 3432 #if HHI_INTERVIEW_SKIP 3433 if( !m_pcPic->getCU(iAddr)->getRenderable(0 )) 3434 { 3435 calcSaoStatsBlock(pPicRec+ posOffset, pPicOrg+ posOffset, stride, ppStats, ppCount,width, height, pbBorderAvail); 3436 } 3437 #else 3438 calcSaoStatsBlock(pPicRec+ posOffset, pPicOrg+ posOffset, stride, ppStats, ppCount,width, height, pbBorderAvail); 3439 #endif 3440 } 3441 } 3442 3443 } 3444 3445 /** Calculate SAO statistics for current LCU without non-crossing slice 3446 * \param iAddr, iPartIdx, iYCbCr 3447 */ 3448 Void TEncSampleAdaptiveOffset::calcSaoStatsCuOrg(Int iAddr, Int iPartIdx, Int iYCbCr) 3449 { 3450 Int x,y; 3451 TComDataCU *pTmpCu = m_pcPic->getCU(iAddr); 3452 TComSPS *pTmpSPS = m_pcPic->getSlice(0)->getSPS(); 3453 3454 Pel* pOrg; 3455 Pel* pRec; 3456 Int iStride; 3457 Int iLcuWidth = pTmpSPS->getMaxCUHeight(); 3458 Int iLcuHeight = pTmpSPS->getMaxCUWidth(); 3459 UInt uiLPelX = pTmpCu->getCUPelX(); 3460 UInt uiTPelY = pTmpCu->getCUPelY(); 3461 UInt uiRPelX; 3462 UInt uiBPelY; 3463 Int64* iStats; 3464 Int64* iCount; 3465 Int iClassIdx; 3466 Int iPicWidthTmp; 3467 Int iPicHeightTmp; 3468 Int iStartX; 3469 Int iStartY; 3470 Int iEndX; 3471 Int iEndY; 3472 3473 Int iIsChroma = (iYCbCr!=0)? 1:0; 3474 Int numSkipLine = iIsChroma? 2:4; 976 3475 if (m_saoInterleavingFlag == 0) 977 3476 { … … 1974 4473 1975 4474 } 4475 #endif 1976 4476 1977 4477 -
branches/HTM-6.2-dev0/source/Lib/TLibEncoder/TEncSampleAdaptiveOffset.h
r296 r427 71 71 Int64 ***m_iOffset; //[MAX_NUM_SAO_PART][MAX_NUM_SAO_TYPE][MAX_NUM_SAO_CLASS]; 72 72 Int64 ***m_iOffsetOrg; //[MAX_NUM_SAO_PART][MAX_NUM_SAO_TYPE]; 73 #if LGE_SAO_MIGRATION_D0091 74 Int64 ****m_count_PreDblk; //[LCU][YCbCr][MAX_NUM_SAO_TYPE][MAX_NUM_SAO_CLASS]; 75 Int64 ****m_offsetOrg_PreDblk; //[LCU][YCbCr][MAX_NUM_SAO_TYPE][MAX_NUM_SAO_CLASS]; 76 #endif 73 77 Int64 **m_iRate; //[MAX_NUM_SAO_PART][MAX_NUM_SAO_TYPE]; 74 78 Int64 **m_iDist; //[MAX_NUM_SAO_PART][MAX_NUM_SAO_TYPE]; … … 79 83 Int m_iOffsetTh; 80 84 Bool m_bUseSBACRD; 85 #if SAO_ENCODING_CHOICE 86 #if SAO_ENCODING_CHOICE_CHROMA 87 Double m_depthSaoRate[2][4]; 88 #else 89 Double m_depth0SaoRate; 90 #endif 91 #endif 81 92 82 93 public: … … 88 99 Void resetStats(); 89 100 #if SAO_CHROMA_LAMBDA 101 #if SAO_ENCODING_CHOICE 102 Void SAOProcess(SAOParam *pcSaoParam, Double dLambda, Double dLambdaChroma, Int depth); 103 #else 90 104 Void SAOProcess(SAOParam *pcSaoParam, Double dLambda, Double dLambdaChroma); 105 #endif 91 106 #else 92 107 Void SAOProcess(SAOParam *pcSaoParam, Double dLambda); 93 108 #endif 109 110 #if LGE_SAO_MIGRATION_D0091 111 Void runQuadTreeDecision(SAOQTPart *psQTPart, Int iPartIdx, Double &dCostFinal, Int iMaxLevel, Double dLambda, Int yCbCr); 112 Void rdoSaoOnePart(SAOQTPart *psQTPart, Int iPartIdx, Double dLambda, Int yCbCr); 113 #else 94 114 Void runQuadTreeDecision(SAOQTPart *psQTPart, Int iPartIdx, Double &dCostFinal, Int iMaxLevel, Double dLambda); 95 115 Void rdoSaoOnePart(SAOQTPart *psQTPart, Int iPartIdx, Double dLambda); 116 #endif 117 96 118 Void disablePartTree(SAOQTPart *psQTPart, Int iPartIdx); 97 119 Void getSaoStats(SAOQTPart *psQTPart, Int iYCbCr); … … 99 121 Void calcSaoStatsBlock( Pel* pRecStart, Pel* pOrgStart, Int stride, Int64** ppStats, Int64** ppCount, UInt width, UInt height, Bool* pbBorderAvail); 100 122 Void calcSaoStatsCuOrg(Int iAddr, Int iPartIdx, Int iYCbCr); 123 #if LGE_SAO_MIGRATION_D0091 124 Void calcSaoStatsCu_BeforeDblk( TComPic* pcPic ); 125 #endif 101 126 Void destroyEncBuffer(); 102 127 Void createEncBuffer(); 103 128 Void assignSaoUnitSyntax(SaoLcuParam* saoLcuParam, SAOQTPart* saoPart, Bool &oneUnitFlag, Int yCbCr); 104 129 Void checkMerge(SaoLcuParam * lcuParamCurr,SaoLcuParam * lcuParamCheck, Int dir); 130 #if SAO_ENCODING_CHOICE 131 Void rdoSaoUnitAll(SAOParam *saoParam, Double lambda, Double lambdaChroma, Int depth); 132 #else 105 133 Void rdoSaoUnitAll(SAOParam *saoParam, Double lambda, Double lambdaChroma); 134 #endif 135 #if LGE_SAO_MIGRATION_D0091 136 Void saoComponentParamDist(Int allowMergeLeft, Int allowMergeUp, SAOParam *saoParam, Int addr, Int addrUp, Int addrLeft, Int yCbCr, Double lambda, SaoLcuParam *compSaoParam, Double *distortion); 137 Void sao2ChromaParamDist(Int allowMergeLeft, Int allowMergeUp, SAOParam *saoParam, Int addr, Int addrUp, Int addrLeft, Double lambda, SaoLcuParam *crSaoParam, SaoLcuParam *cbSaoParam, Double *distortion); 138 inline Int64 estSaoDist(Int64 count, Int64 offset, Int64 offsetOrg, Int shift); 139 inline Int64 estIterOffset(Int typeIdx, Int classIdx, double lambda, Int64 offsetInput, Int64 count, Int64 offsetOrg, Int shift, Int bitIncrease, Int *currentDistortionTableBo, Double *currentRdCostTableBo ); 140 inline Int64 estSaoTypeDist(Int compIdx, Int typeIdx, Int shift, Double lambda, Int *currentDistortionTableBo, Double *currentRdCostTableBo); 141 #else 106 142 Void rdoSaoUnit(SAOParam *saoParam, Int addr, Int addrUp, Int addrLeft, Int yCbCr, Double lambda); 143 #endif 107 144 Void setMaxNumOffsetsPerPic(Int iVal) {m_maxNumOffsetsPerPic = iVal; } 108 145 Int getMaxNumOffsetsPerPic() {return m_maxNumOffsetsPerPic; } -
branches/HTM-6.2-dev0/source/Lib/TLibEncoder/TEncSbac.cpp
r373 r427 99 99 , m_cALFSvlcSCModel ( 1, 1, NUM_ALF_SVLC_CTX , m_contextModels + m_numContextModels, m_numContextModels) 100 100 , m_cCUAMPSCModel ( 1, 1, NUM_CU_AMP_CTX , m_contextModels + m_numContextModels, m_numContextModels) 101 #if LGE_SAO_MIGRATION_D0091 102 , m_cSaoMergeSCModel ( 1, 1, NUM_SAO_MERGE_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) 103 , m_cSaoTypeIdxSCModel ( 1, 1, NUM_SAO_TYPE_IDX_CTX , m_contextModels + m_numContextModels, m_numContextModels) 104 #else 101 105 , m_cSaoFlagSCModel ( 1, 1, NUM_SAO_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) 102 106 , m_cSaoUvlcSCModel ( 1, 1, NUM_SAO_UVLC_CTX , m_contextModels + m_numContextModels, m_numContextModels) … … 105 109 , m_cSaoMergeUpSCModel ( 1, 1, NUM_SAO_MERGE_UP_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) 106 110 , m_cSaoTypeIdxSCModel ( 1, 1, NUM_SAO_TYPE_IDX_CTX , m_contextModels + m_numContextModels, m_numContextModels) 111 #endif 107 112 #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX 108 113 , m_cDmmFlagSCModel ( 1, 1, NUM_DMM_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) … … 186 191 m_cALFSvlcSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_ALF_SVLC ); 187 192 m_cCUTransSubdivFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_TRANS_SUBDIV_FLAG ); 193 #if LGE_SAO_MIGRATION_D0091 194 m_cSaoMergeSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SAO_MERGE_FLAG ); 195 m_cSaoTypeIdxSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SAO_TYPE_IDX ); 196 #else 188 197 m_cSaoFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SAO_FLAG ); 189 198 m_cSaoUvlcSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SAO_UVLC ); … … 192 201 m_cSaoMergeUpSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SAO_MERGE_UP_FLAG ); 193 202 m_cSaoTypeIdxSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SAO_TYPE_IDX ); 203 #endif 194 204 #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX 195 205 m_cDmmFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_DMM_FLAG ); … … 272 282 curCost += m_cALFSvlcSCModel.calcCost ( curSliceType, qp, (UChar*)INIT_ALF_SVLC ); 273 283 curCost += m_cCUTransSubdivFlagSCModel.calcCost ( curSliceType, qp, (UChar*)INIT_TRANS_SUBDIV_FLAG ); 284 #if LGE_SAO_MIGRATION_D0091 285 curCost += m_cSaoMergeSCModel.calcCost ( curSliceType, qp, (UChar*)INIT_SAO_MERGE_FLAG ); 286 curCost += m_cSaoTypeIdxSCModel.calcCost ( curSliceType, qp, (UChar*)INIT_SAO_TYPE_IDX ); 287 #else 274 288 curCost += m_cSaoFlagSCModel.calcCost ( curSliceType, qp, (UChar*)INIT_SAO_FLAG ); 275 289 curCost += m_cSaoUvlcSCModel.calcCost ( curSliceType, qp, (UChar*)INIT_SAO_UVLC ); … … 278 292 curCost += m_cSaoMergeUpSCModel.calcCost ( curSliceType, qp, (UChar*)INIT_SAO_MERGE_UP_FLAG ); 279 293 curCost += m_cSaoTypeIdxSCModel.calcCost ( curSliceType, qp, (UChar*)INIT_SAO_TYPE_IDX ); 294 #endif 280 295 281 296 if (curCost < bestCost) … … 342 357 m_cALFSvlcSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_ALF_SVLC ); 343 358 m_cCUTransSubdivFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_TRANS_SUBDIV_FLAG ); 359 #if LGE_SAO_MIGRATION_D0091 360 m_cSaoMergeSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SAO_MERGE_FLAG ); 361 m_cSaoTypeIdxSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SAO_TYPE_IDX ); 362 #else 344 363 m_cSaoFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SAO_FLAG ); 345 364 m_cSaoUvlcSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SAO_UVLC ); … … 348 367 m_cSaoMergeUpSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SAO_MERGE_UP_FLAG ); 349 368 m_cSaoTypeIdxSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SAO_TYPE_IDX ); 369 #endif 350 370 #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX 351 371 m_cDmmFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_DMM_FLAG ); … … 1913 1933 } 1914 1934 } 1915 1935 #if LGE_SAO_MIGRATION_D0091 1936 Void TEncSbac::codeSAOSign( UInt code ) 1937 { 1938 m_pcBinIf->encodeBinEP( code ); 1939 } 1940 1941 Void TEncSbac::codeSaoMaxUvlc ( UInt code, UInt maxSymbol ) 1942 { 1943 if (maxSymbol == 0) 1944 { 1945 return; 1946 } 1947 1948 Int i; 1949 Bool bCodeLast = ( maxSymbol > code ); 1950 1951 if ( code == 0 ) 1952 { 1953 m_pcBinIf->encodeBinEP( 0 ); 1954 } 1955 else 1956 { 1957 m_pcBinIf->encodeBinEP( 1 ); 1958 for ( i=0; i<code-1; i++ ) 1959 { 1960 m_pcBinIf->encodeBinEP( 1 ); 1961 } 1962 if( bCodeLast ) 1963 { 1964 m_pcBinIf->encodeBinEP( 0 ); 1965 } 1966 } 1967 } 1968 1969 /** Code SAO EO class or BO band position 1970 * \param uiLength 1971 * \param uiCode 1972 */ 1973 Void TEncSbac::codeSaoUflc ( UInt uiLength, UInt uiCode ) 1974 { 1975 m_pcBinIf->encodeBinsEP ( uiCode, uiLength ); 1976 } 1977 /** Code SAO merge flags 1978 * \param uiCode 1979 * \param uiCompIdx 1980 */ 1981 Void TEncSbac::codeSaoMerge ( UInt uiCode ) 1982 { 1983 if (uiCode == 0) 1984 { 1985 m_pcBinIf->encodeBin(0, m_cSaoMergeSCModel.get( 0, 0, 0 )); 1986 } 1987 else 1988 { 1989 m_pcBinIf->encodeBin(1, m_cSaoMergeSCModel.get( 0, 0, 0 )); 1990 } 1991 } 1992 /** Code SAO type index 1993 * \param uiCode 1994 */ 1995 Void TEncSbac::codeSaoTypeIdx ( UInt uiCode) 1996 { 1997 if (uiCode == 0) 1998 { 1999 m_pcBinIf->encodeBin( 0, m_cSaoTypeIdxSCModel.get( 0, 0, 0 ) ); 2000 } 2001 else 2002 { 2003 m_pcBinIf->encodeBin( 1, m_cSaoTypeIdxSCModel.get( 0, 0, 0 ) ); 2004 m_pcBinIf->encodeBinEP( uiCode <= 4 ? 1 : 0 ); //determine edge or band 2005 } 2006 } 2007 #else 1916 2008 Void TEncSbac::codeSaoFlag ( UInt uiCode ) 1917 2009 { … … 2029 2121 } 2030 2122 } 2123 #endif 2031 2124 /*! 2032 2125 **************************************************************************** -
branches/HTM-6.2-dev0/source/Lib/TLibEncoder/TEncSbac.h
r373 r427 126 126 Void codeAlfCtrlFlag ( UInt uiSymbol ); 127 127 Void codeApsExtensionFlag () { assert (0); return; }; 128 #if LGE_SAO_MIGRATION_D0091 129 Void codeSaoMaxUvlc ( UInt code, UInt maxSymbol ); 130 Void codeSaoMerge ( UInt uiCode ); 131 Void codeSaoTypeIdx ( UInt uiCode); 132 Void codeSaoUflc ( UInt uiLength, UInt uiCode ); 133 Void codeSAOSign ( UInt uiCode); //<! code SAO offset sign 134 #else 128 135 Void codeSaoFlag ( UInt uiCode ); 129 136 Void codeSaoUvlc ( UInt uiCode ); … … 134 141 Void codeSaoTypeIdx ( UInt uiCode); 135 142 Void codeSaoUflc ( UInt uiCode); 143 #endif 136 144 Void codeScalingList ( TComScalingList* scalingList ){ assert (0); return;}; 137 145 … … 298 306 ContextModel3DBuffer m_cALFSvlcSCModel; 299 307 ContextModel3DBuffer m_cCUAMPSCModel; 308 #if LGE_SAO_MIGRATION_D0091 309 ContextModel3DBuffer m_cSaoMergeSCModel; 310 ContextModel3DBuffer m_cSaoTypeIdxSCModel; 311 #else 300 312 ContextModel3DBuffer m_cSaoFlagSCModel; 301 313 ContextModel3DBuffer m_cSaoUvlcSCModel; … … 304 316 ContextModel3DBuffer m_cSaoMergeUpSCModel; 305 317 ContextModel3DBuffer m_cSaoTypeIdxSCModel; 318 #endif 306 319 307 320 #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX -
branches/HTM-6.2-dev0/source/Lib/TLibEncoder/TEncSearch.cpp
r412 r427 206 206 207 207 #if H3D_IVMP 208 #if SEC_TWO_CANDIDATES_FOR_AMVP_D0122 209 const Int iNumAMVPCands = AMVP_MAX_NUM_CANDS; 210 #else 208 211 const Int iNumAMVPCands = AMVP_MAX_NUM_CANDS + 1; 212 #endif 209 213 for( Int iNum = 0; iNum < iNumAMVPCands+1; iNum++) 210 214 for( Int iIdx = 0; iIdx < iNumAMVPCands; iIdx++) … … 2998 3002 pcCU->getCUMvField(REF_PIC_LIST_1)->setAllMvField( cMvFieldNeighbours[1 + 2*uiMergeCand], ePartSize, uiAbsPartIdx, 0, iPUIdx ); 2999 3003 #if MERL_VSP_C0152 3004 #if MTK_D0156 3005 if( !pcCU->getSlice()->getSPS()->getUseVSPCompensation() ) 3006 { 3007 pcCU->setVSPIndexSubParts( 0, uiAbsPartIdx, iPUIdx, pcCU->getDepth( uiAbsPartIdx ) ); 3008 } 3009 else 3010 #endif 3000 3011 { 3001 3012 Int iVSPIdx = 0; 3013 #if LGE_VSP_INHERIT_D0092 3014 if (iVSPIndexTrue[uiMergeCand] == 1) 3015 { 3016 iVSPIdx = 1; 3017 } 3018 #else 3002 3019 Int numVSPIdx; 3003 3020 numVSPIdx = 3; … … 3010 3027 } 3011 3028 } 3029 #endif 3012 3030 pcCU->setVSPIndexSubParts( iVSPIdx, uiAbsPartIdx, iPUIdx, pcCU->getDepth( uiAbsPartIdx ) ); 3013 3031 #if MERL_VSP_NBDV_RefVId_Fix_D0166 3014 3032 pcCU->setVSPDirSubParts( iVSPDirTrue[iVSPIdx-1], uiAbsPartIdx, iPUIdx, pcCU->getDepth( uiAbsPartIdx ) ); 3033 #endif 3034 #if QC_BVSP_CleanUP_D0191 && !LGE_VSP_INHERIT_D0092 3035 if(iVSPIdx != 0) 3036 { 3037 Int iIVCIdx = pcCU->getSlice()->getRefPic(REF_PIC_LIST_0, 0)->getPOC()==pcCU->getSlice()->getPOC() ? 0: pcCU->getSlice()->getNewRefIdx(REF_PIC_LIST_0); 3038 cMvFieldNeighbours[ 2*uiMergeIndex].setRefIdx(iIVCIdx); 3039 } 3015 3040 #endif 3016 3041 } … … 3125 3150 3126 3151 #if H3D_IVMP 3152 #if SEC_TWO_CANDIDATES_FOR_AMVP_D0122 3153 Int iNumAMVPCands = AMVP_MAX_NUM_CANDS; 3154 #else 3127 3155 Int iNumAMVPCands = AMVP_MAX_NUM_CANDS + ( pcCU->getSlice()->getSPS()->getMultiviewMvPredMode() ? 1 : 0 ); 3156 #endif 3128 3157 #endif 3129 3158 … … 3676 3705 UInt uiMRGIndex = 0; 3677 3706 #if MERL_VSP_C0152 3707 #if LGE_VSP_INHERIT_D0092 3708 Int iVSPIndexTrue[MRG_MAX_NUM_CANDS_MEM]; 3709 for (Int i=0; i<MRG_MAX_NUM_CANDS_MEM; i++) 3710 { 3711 iVSPIndexTrue[i] = 0; 3712 } 3713 #else 3678 3714 Int iVSPIndexTrue[3] = {-1, -1, -1}; 3715 #endif 3679 3716 #if MERL_VSP_NBDV_RefVId_Fix_D0166 3680 3717 Int iVSPDirTrue[3] = {-1, -1, -1}; … … 3728 3765 pcCU->setMergeIndexSubParts( uiMRGIndex, uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) ); 3729 3766 #if MERL_VSP_C0152 3767 3768 #if MTK_D0156 3769 if( !pcCU->getSlice()->getSPS()->getUseVSPCompensation() ) 3770 { 3771 pcCU->setVSPIndexSubParts( 0, uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) ); 3772 } 3773 else 3774 #endif 3730 3775 { 3731 3776 Int iVSPIdx = 0; 3777 #if LGE_VSP_INHERIT_D0092 3778 if (iVSPIndexTrue[uiMRGIndex] == 1) 3779 { 3780 iVSPIdx = 1; 3781 } 3782 #else 3732 3783 Int numVSPIdx; 3733 3784 numVSPIdx = 3; … … 3740 3791 } 3741 3792 } 3793 #endif 3742 3794 pcCU->setVSPIndexSubParts( iVSPIdx, uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) ); 3743 3795 #if MERL_VSP_NBDV_RefVId_Fix_D0166 3744 3796 pcCU->setVSPDirSubParts( iVSPDirTrue[iVSPIdx-1], uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) ); 3797 #endif 3798 #if QC_BVSP_CleanUP_D0191 && !LGE_VSP_INHERIT_D0092 3799 if(iVSPIdx != 0) 3800 { 3801 Int iIVCIdx = pcCU->getSlice()->getRefPic(REF_PIC_LIST_0, 0)->getPOC()==pcCU->getSlice()->getPOC() ? 0: pcCU->getSlice()->getNewRefIdx(REF_PIC_LIST_0); 3802 cMRGMvField[ 0].setRefIdx(iIVCIdx); 3803 } 3745 3804 #endif 3746 3805 } … … 3830 3889 { 3831 3890 #if H3D_IVMP 3891 #if SEC_TWO_CANDIDATES_FOR_AMVP_D0122 3892 Int iNumAMVPCands = AMVP_MAX_NUM_CANDS; 3893 #else 3832 3894 Int iNumAMVPCands = AMVP_MAX_NUM_CANDS + ( pcCU->getSlice()->getSPS()->getMultiviewMvPredMode() ? 1 : 0 ); 3895 #endif 3833 3896 #if ZERO_MVD_EST 3834 3897 (*puiDistBiP) = xGetTemplateCost( pcCU, uiPartIdx, uiPartAddr, pcOrgYuv, &m_cYuvPredTemp, rcMvPred, 0, iNumAMVPCands, eRefPicList, iRefIdx, iRoiWidth, iRoiHeight, uiDist ); … … 3865 3928 UInt uiTmpCost; 3866 3929 #if H3D_IVMP 3930 #if SEC_TWO_CANDIDATES_FOR_AMVP_D0122 3931 Int iNumAMVPCands = AMVP_MAX_NUM_CANDS; 3932 #else 3867 3933 Int iNumAMVPCands = AMVP_MAX_NUM_CANDS + ( pcCU->getSlice()->getSPS()->getMultiviewMvPredMode() ? 1 : 0 ); 3934 #endif 3868 3935 #if ZERO_MVD_EST 3869 3936 uiTmpCost = xGetTemplateCost( pcCU, uiPartIdx, uiPartAddr, pcOrgYuv, &m_cYuvPredTemp, pcAMVPInfo->m_acMvCand[i], i, iNumAMVPCands, eRefPicList, iRefIdx, iRoiWidth, iRoiHeight, uiDist ); … … 3998 4065 3999 4066 #if H3D_IVMP 4067 #if SEC_TWO_CANDIDATES_FOR_AMVP_D0122 4068 Int iNumAMVPCands = AMVP_MAX_NUM_CANDS; 4069 #else 4000 4070 Int iNumAMVPCands = AMVP_MAX_NUM_CANDS + ( pcCU->getSlice()->getSPS()->getMultiviewMvPredMode() ? 1 : 0 ); 4071 #endif 4001 4072 #endif 4002 4073 -
branches/HTM-6.2-dev0/source/Lib/TLibEncoder/TEncSlice.cpp
r418 r427 787 787 { 788 788 pcSlice ->xSetApplyIC(); 789 #if SHARP_ILLUCOMP_PARSE_D0060 790 if (pcSlice->getApplyIC()) 791 { 792 pcSlice->setIcSkipParseFlag(rpcPic->getCurrSlice()->getPOC() % m_pcCfg->getIntraPeriod() != 0); 793 } 794 #endif 789 795 } 790 796 #endif … … 1218 1224 TComDataCU*& pcCU = rpcPic->getCU( uiCUAddr ); 1219 1225 1226 #if LGE_SAO_MIGRATION_D0091 1227 if ( pcSlice->getSPS()->getUseSAO() && (pcSlice->getSaoEnabledFlag()||pcSlice->getSaoEnabledFlagChroma()) ) 1228 { 1229 SAOParam *saoParam = pcSlice->getAPS()->getSaoParam(); 1230 Int iNumCuInWidth = saoParam->numCuInWidth; 1231 Int iCUAddrInSlice = uiCUAddr - rpcPic->getPicSym()->getCUOrderMap(pcSlice->getSliceCurStartCUAddr()/rpcPic->getNumPartInCU()); 1232 Int iCUAddrUpInSlice = iCUAddrInSlice - iNumCuInWidth; 1233 Int rx = uiCUAddr % iNumCuInWidth; 1234 Int ry = uiCUAddr / iNumCuInWidth; 1235 Int allowMergeLeft = 1; 1236 Int allowMergeUp = 1; 1237 1238 if (rx!=0) 1239 { 1240 if (rpcPic->getPicSym()->getTileIdxMap(uiCUAddr-1) != rpcPic->getPicSym()->getTileIdxMap(uiCUAddr)) 1241 { 1242 allowMergeLeft = 0; 1243 } 1244 } 1245 if (ry!=0) 1246 { 1247 if (rpcPic->getPicSym()->getTileIdxMap(uiCUAddr-iNumCuInWidth) != rpcPic->getPicSym()->getTileIdxMap(uiCUAddr)) 1248 { 1249 allowMergeUp = 0; 1250 } 1251 } 1252 1253 Int addr = pcCU->getAddr(); 1254 allowMergeLeft = allowMergeLeft && (rx>0) && (iCUAddrInSlice!=0); 1255 allowMergeUp = allowMergeUp && (ry>0) && (iCUAddrUpInSlice>=0); 1256 1257 if( saoParam->bSaoFlag[0] || saoParam->bSaoFlag[1] ) 1258 { 1259 Int mergeLeft = saoParam->saoLcuParam[0][addr].mergeLeftFlag; 1260 Int mergeUp = saoParam->saoLcuParam[0][addr].mergeUpFlag; 1261 1262 if (allowMergeLeft) 1263 { 1264 m_pcEntropyCoder->m_pcEntropyCoderIf->codeSaoMerge(mergeLeft); 1265 } 1266 else 1267 { 1268 mergeLeft = 0; 1269 } 1270 if(mergeLeft == 0) 1271 { 1272 if (allowMergeUp) 1273 { 1274 m_pcEntropyCoder->m_pcEntropyCoderIf->codeSaoMerge(mergeUp); 1275 } 1276 else 1277 { 1278 mergeUp = 0; 1279 } 1280 if(mergeUp == 0) 1281 { 1282 for (Int compIdx=0;compIdx<3;compIdx++) 1283 { 1284 if( (compIdx == 0 && saoParam->bSaoFlag[0]) || (compIdx > 0 && saoParam->bSaoFlag[1])) 1285 { 1286 m_pcEntropyCoder->encodeSaoOffset(&saoParam->saoLcuParam[compIdx][addr], compIdx); 1287 } 1288 } 1289 } 1290 } 1291 } 1292 } 1293 #else 1220 1294 if ( pcSlice->getSPS()->getUseSAO() && pcSlice->getAPS()->getSaoInterleavingFlag() && pcSlice->getSaoEnabledFlag() ) 1221 1295 { … … 1227 1301 m_pcEntropyCoder->encodeSaoUnitInterleaving( rx, ry, pcSlice->getAPS()->getSaoParam(),pcCU, iCUAddrInSlice, iCUAddrUpInSlice, pcSlice->getSPS()->getLFCrossSliceBoundaryFlag()); 1228 1302 } 1303 #endif 1229 1304 #if ENC_DEC_TRACE 1230 1305 g_bJustDoIt = g_bEncDecTraceEnable; -
branches/HTM-6.2-dev0/source/Lib/TLibEncoder/TEncTop.cpp
r373 r427 103 103 if (m_bUseSAO) 104 104 { 105 #if LGE_SAO_MIGRATION_D0091 106 m_cEncSAO.setSaoLcuBoundary(getSaoLcuBoundary()); 107 m_cEncSAO.setSaoLcuBasedOptimization(getSaoLcuBasedOptimization()); 108 #else 105 109 m_cEncSAO.setSaoInterleavingFlag(getSaoInterleavingFlag()); 110 #endif 106 111 m_cEncSAO.setMaxNumOffsetsPerPic(getMaxNumOffsetsPerPic()); 107 112 m_cEncSAO.create( getSourceWidth(), getSourceHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth ); … … 708 713 #if HHI_MPI 709 714 m_cSPS.setUseMVI( m_bUseMVI ); 715 #endif 716 717 718 #if MTK_D0156 719 #if MERL_VSP_COMPENSATION_C0152 720 m_cSPS.setUseVSPCompensation ( m_bUseVSPCompensation ); 721 #endif 722 m_cSPS.setUseDVPRefine ( m_bUseDVPRefine ); 710 723 #endif 711 724
Note: See TracChangeset for help on using the changeset viewer.